Search in sources :

Example 11 with TimelineEntityGroupId

use of org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId in project tez by apache.

the class TestTimelineCachePluginImpl method testGetTimelineEntityGroupIdByIds.

@Test
public void testGetTimelineEntityGroupIdByIds() {
    TimelineCachePluginImpl plugin = createPlugin(100, null);
    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;
        }
        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)) {
                String entityGroupId = groupId.getTimelineEntityGroupId();
                if (getGroupIds(dagID1, 100).contains(entityGroupId)) {
                    ++found;
                } else {
                    Assert.fail("Unexpected group id: " + entityGroupId);
                }
            } else if (groupId.getApplicationId().equals(appId2)) {
                String entityGroupId = groupId.getTimelineEntityGroupId();
                if (getGroupIds(dagID2, 100).contains(entityGroupId)) {
                    ++found;
                } else {
                    Assert.fail("Unexpected group id: " + entityGroupId);
                }
            } else {
                Assert.fail("Unexpected appId: " + groupId.getApplicationId());
            }
        }
        Assert.assertEquals("All groupIds not returned", 4, found);
    }
}
Also used : TreeSet(java.util.TreeSet) TimelineEntityGroupId(org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId) Test(org.junit.Test)

Example 12 with TimelineEntityGroupId

use of org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId in project tez by apache.

the class TestTimelineCachePluginImpl method testGetTimelineEntityGroupIdById.

@Test
public void testGetTimelineEntityGroupIdById() {
    TimelineCachePluginImpl plugin = createPlugin(100, null);
    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;
        }
        Assert.assertEquals(2, groupIds.size());
        Iterator<TimelineEntityGroupId> iter = groupIds.iterator();
        while (iter.hasNext()) {
            TimelineEntityGroupId groupId = iter.next();
            Assert.assertEquals(appId1, groupId.getApplicationId());
            Assert.assertTrue(getGroupIds(dagID1, 100).contains(groupId.getTimelineEntityGroupId()));
        }
    }
}
Also used : TimelineEntityGroupId(org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId) Test(org.junit.Test)

Example 13 with TimelineEntityGroupId

use of org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId in project tez by apache.

the class TestTimelineCachePluginImpl method testGetTimelineEntityGroupIdByPrimaryFilter.

@Test
public void testGetTimelineEntityGroupIdByPrimaryFilter() {
    TimelineCachePluginImpl plugin = createPlugin(100, null);
    for (Entry<String, String> entry : typeIdMap1.entrySet()) {
        NameValuePair primaryFilter = new NameValuePair(entry.getKey(), entry.getValue());
        Assert.assertNull(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(getGroupIds(dagID1, 100).contains(groupId.getTimelineEntityGroupId()));
        }
    }
}
Also used : NameValuePair(org.apache.hadoop.yarn.server.timeline.NameValuePair) TimelineEntityGroupId(org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId) Test(org.junit.Test)

Example 14 with TimelineEntityGroupId

use of org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId in project tez by apache.

the class TestTimelineCachePluginImpl method testGetTimelineEntityGroupIdByIdWithOldGroupIdsEmpty.

@Test
public void testGetTimelineEntityGroupIdByIdWithOldGroupIdsEmpty() {
    TimelineCachePluginImpl plugin = createPlugin(100, "");
    for (Entry<String, String> entry : typeIdMap2.entrySet()) {
        Set<TimelineEntityGroupId> groupIds = plugin.getTimelineEntityGroupId(entry.getValue(), entry.getKey());
        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(appId2, groupId.getApplicationId());
            Assert.assertTrue(getGroupIds(dagID2, 100).contains(groupId.getTimelineEntityGroupId()));
        }
    }
}
Also used : TimelineEntityGroupId(org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId) Test(org.junit.Test)

Example 15 with TimelineEntityGroupId

use of org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId in project tez by apache.

the class TestTimelineCachePluginImpl method testContainerIdConversion.

@Test
public void testContainerIdConversion() {
    TimelineCachePluginImpl plugin = createPlugin(-1, null);
    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;
        } 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);
}
Also used : TreeSet(java.util.TreeSet) TimelineEntityGroupId(org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId) Test(org.junit.Test)

Aggregations

TimelineEntityGroupId (org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId)17 Test (org.junit.Test)12 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)5 TreeSet (java.util.TreeSet)2 Path (org.apache.hadoop.fs.Path)2 TimelineEntity (org.apache.hadoop.yarn.api.records.timeline.TimelineEntity)2 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)1 NameValuePair (org.apache.hadoop.yarn.server.timeline.NameValuePair)1 AppContext (org.apache.tez.dag.app.AppContext)1 DAGHistoryEvent (org.apache.tez.dag.history.DAGHistoryEvent)1 HistoryEvent (org.apache.tez.dag.history.HistoryEvent)1 HistoryEventType (org.apache.tez.dag.history.HistoryEventType)1 ATSV15HistoryLoggingService (org.apache.tez.dag.history.logging.ats.ATSV15HistoryLoggingService)1