Example usage for org.apache.hadoop.yarn.api.records.timeline TimelineEntityGroupId getTimelineEntityGroupId

List of usage examples for org.apache.hadoop.yarn.api.records.timeline TimelineEntityGroupId getTimelineEntityGroupId

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.api.records.timeline TimelineEntityGroupId getTimelineEntityGroupId.

Prototype

public String getTimelineEntityGroupId() 

Source Link

Document

Get the timelineEntityGroupId.

Usage

From source file:org.apache.tez.dag.history.ats.acls.TestATSHistoryV15.java

License:Apache License

@Test
public void testGetGroupId() {
    ApplicationId appId = ApplicationId.newInstance(1000l, 1);
    TezDAGID dagid = TezDAGID.getInstance(appId, 1);
    for (final HistoryEventType eventType : HistoryEventType.values()) {
        HistoryEvent historyEvent = new HistoryEvent() {
            @Override//www  .  ja  va 2  s.  co m
            public HistoryEventType getEventType() {
                return eventType;
            }

            @Override
            public boolean isRecoveryEvent() {
                return false;
            }

            @Override
            public boolean isHistoryEvent() {
                return false;
            }

            @Override
            public void toProtoStream(OutputStream outputStream) throws IOException {

            }

            @Override
            public void fromProtoStream(InputStream inputStream) throws IOException {

            }
        };
        DAGHistoryEvent event = new DAGHistoryEvent(dagid, historyEvent);
        ATSV15HistoryLoggingService service = new ATSV15HistoryLoggingService();
        AppContext appContext = mock(AppContext.class);
        when(appContext.getApplicationID()).thenReturn(appId);
        service.setAppContext(appContext);

        TimelineEntityGroupId grpId = service.getGroupId(event);
        Assert.assertNotNull(grpId);
        Assert.assertEquals(appId, grpId.getApplicationId());
        switch (eventType) {
        case AM_LAUNCHED:
        case APP_LAUNCHED:
        case AM_STARTED:
        case CONTAINER_LAUNCHED:
        case CONTAINER_STOPPED:
            Assert.assertEquals(appId.toString(), grpId.getTimelineEntityGroupId());
            break;
        default:
            Assert.assertEquals(dagid.toString(), grpId.getTimelineEntityGroupId());
        }
    }
}

From source file:org.apache.tez.dag.history.logging.ats.TestTimelineCachePluginImpl.java

License:Apache License

@Test
public void testGetTimelineEntityGroupIdByPrimaryFilter() {
    for (Entry<String, String> entry : typeIdMap1.entrySet()) {
        NameValuePair primaryFilter = new NameValuePair(entry.getKey(), entry.getValue());
        Assert.assertNull(/*from   ww  w .j a  v  a  2  s  .co  m*/
                plugin.getTimelineEntityGroupId(EntityTypes.TEZ_APPLICATION.name(), primaryFilter, null));
        Set<TimelineEntityGroupId> groupIds = plugin.getTimelineEntityGroupId(entry.getKey(), primaryFilter,
                null);
        if (entry.getKey().equals(EntityTypes.TEZ_DAG_ID.name())) {
            Assert.assertNull(groupIds);
            continue;
        }
        Assert.assertEquals(2, groupIds.size());
        Iterator<TimelineEntityGroupId> iter = groupIds.iterator();
        while (iter.hasNext()) {
            TimelineEntityGroupId groupId = iter.next();
            Assert.assertEquals(appId1, groupId.getApplicationId());
            Assert.assertTrue((dagID1.toString().equals(groupId.getTimelineEntityGroupId()))
                    || (appId1.toString().equals(groupId.getTimelineEntityGroupId())));
        }
    }
}

From source file:org.apache.tez.dag.history.logging.ats.TestTimelineCachePluginImpl.java

License:Apache License

@Test
public void testGetTimelineEntityGroupIdById() {
    for (Entry<String, String> entry : typeIdMap1.entrySet()) {
        Set<TimelineEntityGroupId> groupIds = plugin.getTimelineEntityGroupId(entry.getValue(), entry.getKey());
        if (entry.getKey().equals(EntityTypes.TEZ_DAG_ID.name())) {
            Assert.assertNull(groupIds);
            continue;
        }//from  w w  w.  j  av a  2 s.  c o  m
        Assert.assertEquals(2, groupIds.size());
        Iterator<TimelineEntityGroupId> iter = groupIds.iterator();
        while (iter.hasNext()) {
            TimelineEntityGroupId groupId = iter.next();
            Assert.assertEquals(appId1, groupId.getApplicationId());
            Assert.assertTrue((dagID1.toString().equals(groupId.getTimelineEntityGroupId()))
                    || (appId1.toString().equals(groupId.getTimelineEntityGroupId())));
        }
    }
}

From source file:org.apache.tez.dag.history.logging.ats.TestTimelineCachePluginImpl.java

License:Apache License

@Test
public void testGetTimelineEntityGroupIdByIds() {
    for (Entry<String, String> entry : typeIdMap1.entrySet()) {
        SortedSet<String> entityIds = new TreeSet<String>();
        entityIds.add(entry.getValue());
        entityIds.add(typeIdMap2.get(entry.getKey()));
        Set<TimelineEntityGroupId> groupIds = plugin.getTimelineEntityGroupId(entry.getKey(), entityIds, null);
        if (entry.getKey().equals(EntityTypes.TEZ_DAG_ID.name())) {
            Assert.assertNull(groupIds);
            continue;
        }/*w  w  w.j  av  a 2 s. c om*/
        Assert.assertEquals(4, groupIds.size());
        int found = 0;
        Iterator<TimelineEntityGroupId> iter = groupIds.iterator();
        while (iter.hasNext()) {
            TimelineEntityGroupId groupId = iter.next();
            if (groupId.getApplicationId().equals(appId1)
                    && groupId.getTimelineEntityGroupId().equals(dagID1.toString())) {
                ++found;
            } else if (groupId.getApplicationId().equals(appId2)
                    && groupId.getTimelineEntityGroupId().equals(dagID2.toString())) {
                ++found;
            } else if (groupId.getApplicationId().equals(appId1)
                    && groupId.getTimelineEntityGroupId().equals(appId1.toString())) {
                ++found;
            } else if (groupId.getApplicationId().equals(appId2)
                    && groupId.getTimelineEntityGroupId().equals(appId2.toString())) {
                ++found;
            }
        }
        Assert.assertEquals("All groupIds not returned", 4, found);
    }
}

From source file:org.apache.tez.dag.history.logging.ats.TestTimelineCachePluginImpl.java

License:Apache License

@Test
public void testContainerIdConversion() {

    String entityType = EntityTypes.TEZ_CONTAINER_ID.name();
    SortedSet<String> entityIds = new TreeSet<String>();
    entityIds.add("tez_" + cId1.toString());
    entityIds.add("tez_" + cId2.toString());
    Set<TimelineEntityGroupId> groupIds = plugin.getTimelineEntityGroupId(entityType, entityIds, null);
    Assert.assertEquals(2, groupIds.size());
    int found = 0;
    Iterator<TimelineEntityGroupId> iter = groupIds.iterator();
    while (iter.hasNext()) {
        TimelineEntityGroupId groupId = iter.next();
        if (groupId.getApplicationId().equals(appId1)
                && groupId.getTimelineEntityGroupId().equals(appId1.toString())) {
            ++found;//from  w  w w . j  a  va 2s .c  o  m
        } else if (groupId.getApplicationId().equals(appId2)
                && groupId.getTimelineEntityGroupId().equals(appId2.toString())) {
            ++found;
        }
    }
    Assert.assertEquals("All groupIds not returned", 2, found);

    groupIds.clear();
    groupIds = plugin.getTimelineEntityGroupId(cId1.toString(), entityType);
    Assert.assertEquals(1, groupIds.size());
    found = 0;
    iter = groupIds.iterator();
    while (iter.hasNext()) {
        TimelineEntityGroupId groupId = iter.next();
        if (groupId.getApplicationId().equals(appId1)
                && groupId.getTimelineEntityGroupId().equals(appId1.toString())) {
            ++found;
        }
    }
    Assert.assertEquals("All groupIds not returned", 1, found);

    groupIds.clear();
    groupIds = plugin.getTimelineEntityGroupId("tez_" + cId2.toString(), entityType);
    Assert.assertEquals(1, groupIds.size());
    found = 0;
    iter = groupIds.iterator();
    while (iter.hasNext()) {
        TimelineEntityGroupId groupId = iter.next();
        if (groupId.getApplicationId().equals(appId2)
                && groupId.getTimelineEntityGroupId().equals(appId2.toString())) {
            ++found;
        }
    }
    Assert.assertEquals("All groupIds not returned", 1, found);

}