org.apache.hadoop.yarn.server.timeline.NameValuePair Java Examples

The following examples show how to use org.apache.hadoop.yarn.server.timeline.NameValuePair. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplicationHistoryManagerOnTimelineStore.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
public Map<ApplicationAttemptId, ApplicationAttemptReport>
    getApplicationAttempts(ApplicationId appId)
        throws YarnException, IOException {
  ApplicationReportExt app = getApplication(
      appId, ApplicationReportField.USER_AND_ACLS);
  checkAccess(app);
  TimelineEntities entities = timelineDataManager.getEntities(
      AppAttemptMetricsConstants.ENTITY_TYPE,
      new NameValuePair(
          AppAttemptMetricsConstants.PARENT_PRIMARY_FILTER, appId
              .toString()), null, null, null, null, null,
      Long.MAX_VALUE, EnumSet.allOf(Field.class),
      UserGroupInformation.getLoginUser());
  Map<ApplicationAttemptId, ApplicationAttemptReport> appAttempts =
      new LinkedHashMap<ApplicationAttemptId, ApplicationAttemptReport>();
  for (TimelineEntity entity : entities.getEntities()) {
    ApplicationAttemptReport appAttempt =
        convertToApplicationAttemptReport(entity);
    appAttempts.put(appAttempt.getApplicationAttemptId(), appAttempt);
  }
  return appAttempts;
}
 
Example #2
Source File: ApplicationHistoryManagerOnTimelineStore.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
public Map<ContainerId, ContainerReport> getContainers(
    ApplicationAttemptId appAttemptId) throws YarnException, IOException {
  ApplicationReportExt app = getApplication(
      appAttemptId.getApplicationId(), ApplicationReportField.USER_AND_ACLS);
  checkAccess(app);
  TimelineEntities entities = timelineDataManager.getEntities(
      ContainerMetricsConstants.ENTITY_TYPE,
      new NameValuePair(
          ContainerMetricsConstants.PARENT_PRIMARIY_FILTER,
          appAttemptId.toString()), null, null, null,
      null, null, Long.MAX_VALUE, EnumSet.allOf(Field.class),
      UserGroupInformation.getLoginUser());
  Map<ContainerId, ContainerReport> containers =
      new LinkedHashMap<ContainerId, ContainerReport>();
  if (entities != null && entities.getEntities() != null) {
    for (TimelineEntity entity : entities.getEntities()) {
      ContainerReport container = convertToContainerReport(
          entity, serverHttpAddress, app.appReport.getUser());
      containers.put(container.getContainerId(), container);
    }
  }
  return containers;
}
 
Example #3
Source File: ApplicationHistoryManagerOnTimelineStore.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
public Map<ApplicationAttemptId, ApplicationAttemptReport>
    getApplicationAttempts(ApplicationId appId)
        throws YarnException, IOException {
  ApplicationReportExt app = getApplication(
      appId, ApplicationReportField.USER_AND_ACLS);
  checkAccess(app);
  TimelineEntities entities = timelineDataManager.getEntities(
      AppAttemptMetricsConstants.ENTITY_TYPE,
      new NameValuePair(
          AppAttemptMetricsConstants.PARENT_PRIMARY_FILTER, appId
              .toString()), null, null, null, null, null,
      Long.MAX_VALUE, EnumSet.allOf(Field.class),
      UserGroupInformation.getLoginUser());
  Map<ApplicationAttemptId, ApplicationAttemptReport> appAttempts =
      new LinkedHashMap<ApplicationAttemptId, ApplicationAttemptReport>();
  for (TimelineEntity entity : entities.getEntities()) {
    ApplicationAttemptReport appAttempt =
        convertToApplicationAttemptReport(entity);
    appAttempts.put(appAttempt.getApplicationAttemptId(), appAttempt);
  }
  return appAttempts;
}
 
Example #4
Source File: ApplicationHistoryManagerOnTimelineStore.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
public Map<ContainerId, ContainerReport> getContainers(
    ApplicationAttemptId appAttemptId) throws YarnException, IOException {
  ApplicationReportExt app = getApplication(
      appAttemptId.getApplicationId(), ApplicationReportField.USER_AND_ACLS);
  checkAccess(app);
  TimelineEntities entities = timelineDataManager.getEntities(
      ContainerMetricsConstants.ENTITY_TYPE,
      new NameValuePair(
          ContainerMetricsConstants.PARENT_PRIMARIY_FILTER,
          appAttemptId.toString()), null, null, null,
      null, null, Long.MAX_VALUE, EnumSet.allOf(Field.class),
      UserGroupInformation.getLoginUser());
  Map<ContainerId, ContainerReport> containers =
      new LinkedHashMap<ContainerId, ContainerReport>();
  if (entities != null && entities.getEntities() != null) {
    for (TimelineEntity entity : entities.getEntities()) {
      ContainerReport container = convertToContainerReport(
          entity, serverHttpAddress, app.appReport.getUser());
      containers.put(container.getContainerId(), container);
    }
  }
  return containers;
}
 
Example #5
Source File: TestTimelineCachePluginImpl.java    From tez with Apache License 2.0 6 votes vote down vote up
@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()));
    }
  }
}
 
Example #6
Source File: TestTimelineCachePluginImpl.java    From tez with Apache License 2.0 6 votes vote down vote up
@Test
public void testInvalidTypeRequests() {
  TimelineCachePluginImpl plugin = createPlugin(-1, null);
  Assert.assertNull(plugin.getTimelineEntityGroupId(EntityTypes.TEZ_APPLICATION.name(),
      appId1.toString()));
  Assert.assertNull(plugin.getTimelineEntityGroupId(EntityTypes.TEZ_APPLICATION_ATTEMPT.name(),
      appAttemptId1.toString()));
  Assert.assertNull(plugin.getTimelineEntityGroupId(EntityTypes.TEZ_CONTAINER_ID.name(),
      appId1.toString()));

  Assert.assertNull(plugin.getTimelineEntityGroupId(EntityTypes.TEZ_TASK_ID.name(), null,
      new HashSet<String>()));
  Assert.assertNull(plugin.getTimelineEntityGroupId(EntityTypes.TEZ_TASK_ID.name(), null,
      new HashSet<NameValuePair>()));

}
 
Example #7
Source File: TimelineWebServices.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private static NameValuePair parsePairStr(String str, String delimiter) {
  if (str == null) {
    return null;
  }
  String[] strs = str.split(delimiter, 2);
  try {
    return new NameValuePair(strs[0].trim(),
        GenericObjectMapper.OBJECT_READER.readValue(strs[1].trim()));
  } catch (Exception e) {
    // didn't work as an Object, keep it as a String
    return new NameValuePair(strs[0].trim(), strs[1].trim());
  }
}
 
Example #8
Source File: TimelineWebServices.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private static Collection<NameValuePair> parsePairsStr(
    String str, String aDelimiter, String pDelimiter) {
  if (str == null) {
    return null;
  }
  String[] strs = str.split(aDelimiter);
  Set<NameValuePair> pairs = new HashSet<NameValuePair>();
  for (String aStr : strs) {
    pairs.add(parsePairStr(aStr, pDelimiter));
  }
  return pairs;
}
 
Example #9
Source File: TimelineWebServices.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static NameValuePair parsePairStr(String str, String delimiter) {
  if (str == null) {
    return null;
  }
  String[] strs = str.split(delimiter, 2);
  try {
    return new NameValuePair(strs[0].trim(),
        GenericObjectMapper.OBJECT_READER.readValue(strs[1].trim()));
  } catch (Exception e) {
    // didn't work as an Object, keep it as a String
    return new NameValuePair(strs[0].trim(), strs[1].trim());
  }
}
 
Example #10
Source File: TimelineWebServices.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static Collection<NameValuePair> parsePairsStr(
    String str, String aDelimiter, String pDelimiter) {
  if (str == null) {
    return null;
  }
  String[] strs = str.split(aDelimiter);
  Set<NameValuePair> pairs = new HashSet<NameValuePair>();
  for (String aStr : strs) {
    pairs.add(parsePairStr(aStr, pDelimiter));
  }
  return pairs;
}
 
Example #11
Source File: TimelineCachePluginImpl.java    From tez with Apache License 2.0 5 votes vote down vote up
@Override
public Set<TimelineEntityGroupId> getTimelineEntityGroupId(String entityType,
    NameValuePair primaryFilter,
    Collection<NameValuePair> secondaryFilters) {
  if (!knownEntityTypes.contains(entityType)
      || primaryFilter == null
      || !knownEntityTypes.contains(primaryFilter.getName())
      || summaryEntityTypes.contains(entityType)) {
    return null;
  }
  return convertToTimelineEntityGroupIds(primaryFilter.getName(), primaryFilter.getValue().toString());
}
 
Example #12
Source File: TestLeveldbTimelineStore.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testDeleteEntitiesPrimaryFilters()
    throws IOException, InterruptedException {
  Map<String, Set<Object>> primaryFilter =
      Collections.singletonMap("user", Collections.singleton(
          (Object) "otheruser"));
  TimelineEntities atsEntities = new TimelineEntities();
  atsEntities.setEntities(Collections.singletonList(createEntity(entityId1b,
      entityType1, 789l, Collections.singletonList(ev2), null, primaryFilter,
      null, domainId1)));
  TimelinePutResponse response = store.put(atsEntities);
  assertEquals(0, response.getErrors().size());

  NameValuePair pfPair = new NameValuePair("user", "otheruser");
  List<TimelineEntity> entities = getEntitiesWithPrimaryFilter("type_1",
      pfPair);
  assertEquals(1, entities.size());
  verifyEntityInfo(entityId1b, entityType1, Collections.singletonList(ev2),
      EMPTY_REL_ENTITIES, primaryFilter, EMPTY_MAP, entities.get(0),
      domainId1);

  entities = getEntitiesWithPrimaryFilter("type_1", userFilter);
  assertEquals(3, entities.size());
  verifyEntityInfo(entityId1, entityType1, events1, EMPTY_REL_ENTITIES,
      primaryFilters, otherInfo, entities.get(0), domainId1);
  verifyEntityInfo(entityId1b, entityType1, events1, EMPTY_REL_ENTITIES,
      primaryFilters, otherInfo, entities.get(1), domainId1);
  verifyEntityInfo(entityId6, entityType1, EMPTY_EVENTS, EMPTY_REL_ENTITIES,
      primaryFilters, otherInfo, entities.get(2), domainId2);

  ((LeveldbTimelineStore)store).discardOldEntities(-123l);
  assertEquals(1, getEntitiesWithPrimaryFilter("type_1", pfPair).size());
  assertEquals(3, getEntitiesWithPrimaryFilter("type_1", userFilter).size());

  ((LeveldbTimelineStore)store).discardOldEntities(123l);
  assertEquals(0, getEntities("type_1").size());
  assertEquals(0, getEntities("type_2").size());
  assertEquals(0, ((LeveldbTimelineStore)store).getEntityTypes().size());

  assertEquals(0, getEntitiesWithPrimaryFilter("type_1", pfPair).size());
  assertEquals(0, getEntitiesWithPrimaryFilter("type_1", userFilter).size());
}
 
Example #13
Source File: TestLeveldbTimelineStore.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testDeleteEntitiesPrimaryFilters()
    throws IOException, InterruptedException {
  Map<String, Set<Object>> primaryFilter =
      Collections.singletonMap("user", Collections.singleton(
          (Object) "otheruser"));
  TimelineEntities atsEntities = new TimelineEntities();
  atsEntities.setEntities(Collections.singletonList(createEntity(entityId1b,
      entityType1, 789l, Collections.singletonList(ev2), null, primaryFilter,
      null, domainId1)));
  TimelinePutResponse response = store.put(atsEntities);
  assertEquals(0, response.getErrors().size());

  NameValuePair pfPair = new NameValuePair("user", "otheruser");
  List<TimelineEntity> entities = getEntitiesWithPrimaryFilter("type_1",
      pfPair);
  assertEquals(1, entities.size());
  verifyEntityInfo(entityId1b, entityType1, Collections.singletonList(ev2),
      EMPTY_REL_ENTITIES, primaryFilter, EMPTY_MAP, entities.get(0),
      domainId1);

  entities = getEntitiesWithPrimaryFilter("type_1", userFilter);
  assertEquals(3, entities.size());
  verifyEntityInfo(entityId1, entityType1, events1, EMPTY_REL_ENTITIES,
      primaryFilters, otherInfo, entities.get(0), domainId1);
  verifyEntityInfo(entityId1b, entityType1, events1, EMPTY_REL_ENTITIES,
      primaryFilters, otherInfo, entities.get(1), domainId1);
  verifyEntityInfo(entityId6, entityType1, EMPTY_EVENTS, EMPTY_REL_ENTITIES,
      primaryFilters, otherInfo, entities.get(2), domainId2);

  ((LeveldbTimelineStore)store).discardOldEntities(-123l);
  assertEquals(1, getEntitiesWithPrimaryFilter("type_1", pfPair).size());
  assertEquals(3, getEntitiesWithPrimaryFilter("type_1", userFilter).size());

  ((LeveldbTimelineStore)store).discardOldEntities(123l);
  assertEquals(0, getEntities("type_1").size());
  assertEquals(0, getEntities("type_2").size());
  assertEquals(0, ((LeveldbTimelineStore)store).getEntityTypes().size());

  assertEquals(0, getEntitiesWithPrimaryFilter("type_1", pfPair).size());
  assertEquals(0, getEntitiesWithPrimaryFilter("type_1", userFilter).size());
}