Java Code Examples for org.apache.hadoop.yarn.api.records.timeline.TimelineEntities

The following examples show how to use org.apache.hadoop.yarn.api.records.timeline.TimelineEntities. These examples are extracted from open source projects. 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 Project: hadoop   Source File: TestTimelineClient.java    License: Apache License 2.0 6 votes vote down vote up
private static ClientResponse mockEntityClientResponse(
    TimelineClientImpl client, ClientResponse.Status status,
    boolean hasError, boolean hasRuntimeError) {
  ClientResponse response = mock(ClientResponse.class);
  if (hasRuntimeError) {
    doThrow(new ClientHandlerException(new ConnectException())).when(client)
        .doPostingObject(any(TimelineEntities.class), any(String.class));
    return response;
  }
  doReturn(response).when(client)
      .doPostingObject(any(TimelineEntities.class), any(String.class));
  when(response.getClientResponseStatus()).thenReturn(status);
  TimelinePutResponse.TimelinePutError error =
      new TimelinePutResponse.TimelinePutError();
  error.setEntityId("test entity id");
  error.setEntityType("test entity type");
  error.setErrorCode(TimelinePutResponse.TimelinePutError.IO_EXCEPTION);
  TimelinePutResponse putResponse = new TimelinePutResponse();
  if (hasError) {
    putResponse.addError(error);
  }
  when(response.getEntity(TimelinePutResponse.class)).thenReturn(putResponse);
  return response;
}
 
Example 2
@Override
public Map<ApplicationId, ApplicationReport> getAllApplications()
    throws YarnException, IOException {
  TimelineEntities entities = timelineDataManager.getEntities(
      ApplicationMetricsConstants.ENTITY_TYPE, null, null, null, null,
      null, null, Long.MAX_VALUE, EnumSet.allOf(Field.class),
      UserGroupInformation.getLoginUser());
  Map<ApplicationId, ApplicationReport> apps =
      new LinkedHashMap<ApplicationId, ApplicationReport>();
  if (entities != null && entities.getEntities() != null) {
    for (TimelineEntity entity : entities.getEntities()) {
      try {
        ApplicationReportExt app =
            generateApplicationReport(entity, ApplicationReportField.ALL);
        apps.put(app.appReport.getApplicationId(), app.appReport);
      } catch (Exception e) {
        LOG.error("Error on generating application report for " +
            entity.getEntityId(), e);
      }
    }
  }
  return apps;
}
 
Example 3
@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
@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 Project: hadoop   Source File: TimelineWebServices.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Store the given entities into the timeline store, and return the errors
 * that happen during storing.
 */
@POST
@Consumes({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */})
public TimelinePutResponse postEntities(
    @Context HttpServletRequest req,
    @Context HttpServletResponse res,
    TimelineEntities entities) {
  init(res);
  UserGroupInformation callerUGI = getUser(req);
  if (callerUGI == null) {
    String msg = "The owner of the posted timeline entities is not set";
    LOG.error(msg);
    throw new ForbiddenException(msg);
  }
  try {
    return timelineDataManager.postEntities(entities, callerUGI);
  } catch (Exception e) {
    LOG.error("Error putting entities", e);
    throw new WebApplicationException(e,
        Response.Status.INTERNAL_SERVER_ERROR);
  }
}
 
Example 6
Source Project: hadoop   Source File: TestTimelineDataManager.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testGetOldEntitiesWithOutDomainId() throws Exception {
  TimelineEntities entities = dataManaer.getEntities(
      "OLD_ENTITY_TYPE_1", null, null, null, null, null, null, null, null,
      UserGroupInformation.getCurrentUser());
  Assert.assertEquals(2, entities.getEntities().size());
  Assert.assertEquals("OLD_ENTITY_ID_2",
      entities.getEntities().get(0).getEntityId());
  Assert.assertEquals("OLD_ENTITY_TYPE_1",
      entities.getEntities().get(0).getEntityType());
  Assert.assertEquals(TimelineDataManager.DEFAULT_DOMAIN_ID,
      entities.getEntities().get(0).getDomainId());
  Assert.assertEquals("OLD_ENTITY_ID_1",
      entities.getEntities().get(1).getEntityId());
  Assert.assertEquals("OLD_ENTITY_TYPE_1",
      entities.getEntities().get(1).getEntityType());
  Assert.assertEquals(TimelineDataManager.DEFAULT_DOMAIN_ID,
      entities.getEntities().get(1).getDomainId());
}
 
Example 7
Source Project: hadoop   Source File: TestTimelineWebServices.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testFromId() throws Exception {
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("timeline")
      .path("type_1").queryParam("fromId", "id_2")
      .accept(MediaType.APPLICATION_JSON)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  assertEquals(2, response.getEntity(TimelineEntities.class).getEntities()
      .size());

  response = r.path("ws").path("v1").path("timeline")
      .path("type_1").queryParam("fromId", "id_1")
      .accept(MediaType.APPLICATION_JSON)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  assertEquals(3, response.getEntity(TimelineEntities.class).getEntities()
      .size());
}
 
Example 8
Source Project: hadoop   Source File: TestTimelineWebServices.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testFromTs() throws Exception {
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("timeline")
      .path("type_1").queryParam("fromTs", Long.toString(beforeTime))
      .accept(MediaType.APPLICATION_JSON)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  assertEquals(0, response.getEntity(TimelineEntities.class).getEntities()
      .size());

  response = r.path("ws").path("v1").path("timeline")
      .path("type_1").queryParam("fromTs", Long.toString(
          System.currentTimeMillis()))
      .accept(MediaType.APPLICATION_JSON)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  assertEquals(3, response.getEntity(TimelineEntities.class).getEntities()
      .size());
}
 
Example 9
Source Project: hadoop   Source File: TestTimelineWebServices.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testPostEntitiesWithPrimaryFilter() throws Exception {
  TimelineEntities entities = new TimelineEntities();
  TimelineEntity entity = new TimelineEntity();
  Map<String, Set<Object>> filters = new HashMap<String, Set<Object>>();
  filters.put(TimelineStore.SystemFilter.ENTITY_OWNER.toString(),
      new HashSet<Object>());
  entity.setPrimaryFilters(filters);
  entity.setEntityId("test id 6");
  entity.setEntityType("test type 6");
  entity.setStartTime(System.currentTimeMillis());
  entities.addEntity(entity);
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("timeline")
      .queryParam("user.name", "tester")
      .accept(MediaType.APPLICATION_JSON)
      .type(MediaType.APPLICATION_JSON)
      .post(ClientResponse.class, entities);
  TimelinePutResponse putResposne =
      response.getEntity(TimelinePutResponse.class);
  Assert.assertEquals(0, putResposne.getErrors().size());
}
 
Example 10
Source Project: hadoop   Source File: TestLeveldbTimelineStore.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testRelatingToNonExistingEntity() throws IOException {
  TimelineEntity entityToStore = new TimelineEntity();
  entityToStore.setEntityType("TEST_ENTITY_TYPE_1");
  entityToStore.setEntityId("TEST_ENTITY_ID_1");
  entityToStore.setDomainId(TimelineDataManager.DEFAULT_DOMAIN_ID);
  entityToStore.addRelatedEntity("TEST_ENTITY_TYPE_2", "TEST_ENTITY_ID_2");
  TimelineEntities entities = new TimelineEntities();
  entities.addEntity(entityToStore);
  store.put(entities);
  TimelineEntity entityToGet =
      store.getEntity("TEST_ENTITY_ID_2", "TEST_ENTITY_TYPE_2", null);
  Assert.assertNotNull(entityToGet);
  Assert.assertEquals("DEFAULT", entityToGet.getDomainId());
  Assert.assertEquals("TEST_ENTITY_TYPE_1",
      entityToGet.getRelatedEntities().keySet().iterator().next());
  Assert.assertEquals("TEST_ENTITY_ID_1",
      entityToGet.getRelatedEntities().values().iterator().next()
          .iterator().next());
}
 
Example 11
Source Project: big-c   Source File: TestTimelineClient.java    License: Apache License 2.0 6 votes vote down vote up
private static ClientResponse mockEntityClientResponse(
    TimelineClientImpl client, ClientResponse.Status status,
    boolean hasError, boolean hasRuntimeError) {
  ClientResponse response = mock(ClientResponse.class);
  if (hasRuntimeError) {
    doThrow(new ClientHandlerException(new ConnectException())).when(client)
        .doPostingObject(any(TimelineEntities.class), any(String.class));
    return response;
  }
  doReturn(response).when(client)
      .doPostingObject(any(TimelineEntities.class), any(String.class));
  when(response.getClientResponseStatus()).thenReturn(status);
  TimelinePutResponse.TimelinePutError error =
      new TimelinePutResponse.TimelinePutError();
  error.setEntityId("test entity id");
  error.setEntityType("test entity type");
  error.setErrorCode(TimelinePutResponse.TimelinePutError.IO_EXCEPTION);
  TimelinePutResponse putResponse = new TimelinePutResponse();
  if (hasError) {
    putResponse.addError(error);
  }
  when(response.getEntity(TimelinePutResponse.class)).thenReturn(putResponse);
  return response;
}
 
Example 12
@Override
public Map<ApplicationId, ApplicationReport> getAllApplications()
    throws YarnException, IOException {
  TimelineEntities entities = timelineDataManager.getEntities(
      ApplicationMetricsConstants.ENTITY_TYPE, null, null, null, null,
      null, null, Long.MAX_VALUE, EnumSet.allOf(Field.class),
      UserGroupInformation.getLoginUser());
  Map<ApplicationId, ApplicationReport> apps =
      new LinkedHashMap<ApplicationId, ApplicationReport>();
  if (entities != null && entities.getEntities() != null) {
    for (TimelineEntity entity : entities.getEntities()) {
      try {
        ApplicationReportExt app =
            generateApplicationReport(entity, ApplicationReportField.ALL);
        apps.put(app.appReport.getApplicationId(), app.appReport);
      } catch (Exception e) {
        LOG.error("Error on generating application report for " +
            entity.getEntityId(), e);
      }
    }
  }
  return apps;
}
 
Example 13
@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 14
@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 15
Source Project: big-c   Source File: TimelineWebServices.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Store the given entities into the timeline store, and return the errors
 * that happen during storing.
 */
@POST
@Consumes({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */})
public TimelinePutResponse postEntities(
    @Context HttpServletRequest req,
    @Context HttpServletResponse res,
    TimelineEntities entities) {
  init(res);
  UserGroupInformation callerUGI = getUser(req);
  if (callerUGI == null) {
    String msg = "The owner of the posted timeline entities is not set";
    LOG.error(msg);
    throw new ForbiddenException(msg);
  }
  try {
    return timelineDataManager.postEntities(entities, callerUGI);
  } catch (Exception e) {
    LOG.error("Error putting entities", e);
    throw new WebApplicationException(e,
        Response.Status.INTERNAL_SERVER_ERROR);
  }
}
 
Example 16
Source Project: big-c   Source File: TestTimelineDataManager.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testGetOldEntitiesWithOutDomainId() throws Exception {
  TimelineEntities entities = dataManaer.getEntities(
      "OLD_ENTITY_TYPE_1", null, null, null, null, null, null, null, null,
      UserGroupInformation.getCurrentUser());
  Assert.assertEquals(2, entities.getEntities().size());
  Assert.assertEquals("OLD_ENTITY_ID_2",
      entities.getEntities().get(0).getEntityId());
  Assert.assertEquals("OLD_ENTITY_TYPE_1",
      entities.getEntities().get(0).getEntityType());
  Assert.assertEquals(TimelineDataManager.DEFAULT_DOMAIN_ID,
      entities.getEntities().get(0).getDomainId());
  Assert.assertEquals("OLD_ENTITY_ID_1",
      entities.getEntities().get(1).getEntityId());
  Assert.assertEquals("OLD_ENTITY_TYPE_1",
      entities.getEntities().get(1).getEntityType());
  Assert.assertEquals(TimelineDataManager.DEFAULT_DOMAIN_ID,
      entities.getEntities().get(1).getDomainId());
}
 
Example 17
Source Project: big-c   Source File: TestTimelineWebServices.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testFromId() throws Exception {
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("timeline")
      .path("type_1").queryParam("fromId", "id_2")
      .accept(MediaType.APPLICATION_JSON)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  assertEquals(2, response.getEntity(TimelineEntities.class).getEntities()
      .size());

  response = r.path("ws").path("v1").path("timeline")
      .path("type_1").queryParam("fromId", "id_1")
      .accept(MediaType.APPLICATION_JSON)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  assertEquals(3, response.getEntity(TimelineEntities.class).getEntities()
      .size());
}
 
Example 18
Source Project: big-c   Source File: TestTimelineWebServices.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testFromTs() throws Exception {
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("timeline")
      .path("type_1").queryParam("fromTs", Long.toString(beforeTime))
      .accept(MediaType.APPLICATION_JSON)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  assertEquals(0, response.getEntity(TimelineEntities.class).getEntities()
      .size());

  response = r.path("ws").path("v1").path("timeline")
      .path("type_1").queryParam("fromTs", Long.toString(
          System.currentTimeMillis()))
      .accept(MediaType.APPLICATION_JSON)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  assertEquals(3, response.getEntity(TimelineEntities.class).getEntities()
      .size());
}
 
Example 19
Source Project: big-c   Source File: TestTimelineWebServices.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testPostEntitiesWithPrimaryFilter() throws Exception {
  TimelineEntities entities = new TimelineEntities();
  TimelineEntity entity = new TimelineEntity();
  Map<String, Set<Object>> filters = new HashMap<String, Set<Object>>();
  filters.put(TimelineStore.SystemFilter.ENTITY_OWNER.toString(),
      new HashSet<Object>());
  entity.setPrimaryFilters(filters);
  entity.setEntityId("test id 6");
  entity.setEntityType("test type 6");
  entity.setStartTime(System.currentTimeMillis());
  entities.addEntity(entity);
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("timeline")
      .queryParam("user.name", "tester")
      .accept(MediaType.APPLICATION_JSON)
      .type(MediaType.APPLICATION_JSON)
      .post(ClientResponse.class, entities);
  TimelinePutResponse putResposne =
      response.getEntity(TimelinePutResponse.class);
  Assert.assertEquals(0, putResposne.getErrors().size());
}
 
Example 20
Source Project: big-c   Source File: TestLeveldbTimelineStore.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testRelatingToNonExistingEntity() throws IOException {
  TimelineEntity entityToStore = new TimelineEntity();
  entityToStore.setEntityType("TEST_ENTITY_TYPE_1");
  entityToStore.setEntityId("TEST_ENTITY_ID_1");
  entityToStore.setDomainId(TimelineDataManager.DEFAULT_DOMAIN_ID);
  entityToStore.addRelatedEntity("TEST_ENTITY_TYPE_2", "TEST_ENTITY_ID_2");
  TimelineEntities entities = new TimelineEntities();
  entities.addEntity(entityToStore);
  store.put(entities);
  TimelineEntity entityToGet =
      store.getEntity("TEST_ENTITY_ID_2", "TEST_ENTITY_TYPE_2", null);
  Assert.assertNotNull(entityToGet);
  Assert.assertEquals("DEFAULT", entityToGet.getDomainId());
  Assert.assertEquals("TEST_ENTITY_TYPE_1",
      entityToGet.getRelatedEntities().keySet().iterator().next());
  Assert.assertEquals("TEST_ENTITY_ID_1",
      entityToGet.getRelatedEntities().values().iterator().next()
          .iterator().next());
}
 
Example 21
Source Project: hadoop   Source File: TimelineClientImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public TimelinePutResponse putEntities(
    TimelineEntity... entities) throws IOException, YarnException {
  TimelineEntities entitiesContainer = new TimelineEntities();
  entitiesContainer.addEntities(Arrays.asList(entities));
  ClientResponse resp = doPosting(entitiesContainer, null);
  return resp.getEntity(TimelinePutResponse.class);
}
 
Example 22
Source Project: hadoop   Source File: TimelineDataManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get the timeline entities that the given user have access to. The meaning
 * of each argument has been documented with
 * {@link TimelineReader#getEntities}.
 * 
 * @see TimelineReader#getEntities
 */
public TimelineEntities getEntities(
    String entityType,
    NameValuePair primaryFilter,
    Collection<NameValuePair> secondaryFilter,
    Long windowStart,
    Long windowEnd,
    String fromId,
    Long fromTs,
    Long limit,
    EnumSet<Field> fields,
    UserGroupInformation callerUGI) throws YarnException, IOException {
  TimelineEntities entities = null;
  entities = store.getEntities(
      entityType,
      limit,
      windowStart,
      windowEnd,
      fromId,
      fromTs,
      primaryFilter,
      secondaryFilter,
      fields,
      new CheckAclImpl(callerUGI));

  if (entities == null) {
    return new TimelineEntities();
  }
  return entities;
}
 
Example 23
@BeforeClass
public static void prepareStore() throws Exception {
  store = createStore(SCALE);
  TimelineEntities entities = new TimelineEntities();
  entities.addEntity(createApplicationTimelineEntity(
      ApplicationId.newInstance(0, SCALE + 1), true, true, false));
  entities.addEntity(createApplicationTimelineEntity(
      ApplicationId.newInstance(0, SCALE + 2), true, false, true));
  store.put(entities);
}
 
Example 24
Source Project: hadoop   Source File: TestTimelineDataManager.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testGetEntitiesAclEnabled() throws Exception {
  AdminACLsManager oldAdminACLsManager =
    aclsManager.setAdminACLsManager(adminACLsManager);
  try {
    TimelineEntities entities = dataManaer.getEntities(
      "ACL_ENTITY_TYPE_1", null, null, null, null, null, null, 1l, null,
      UserGroupInformation.createUserForTesting("owner_1", new String[] {"group1"}));
    Assert.assertEquals(1, entities.getEntities().size());
    Assert.assertEquals("ACL_ENTITY_ID_11",
      entities.getEntities().get(0).getEntityId());
  } finally {
    aclsManager.setAdminACLsManager(oldAdminACLsManager);
  }
}
 
Example 25
Source Project: hadoop   Source File: TestTimelineWebServices.java    License: Apache License 2.0 5 votes vote down vote up
private static void verifyEntities(TimelineEntities entities) {
  Assert.assertNotNull(entities);
  Assert.assertEquals(3, entities.getEntities().size());
  TimelineEntity entity1 = entities.getEntities().get(0);
  Assert.assertNotNull(entity1);
  Assert.assertEquals("id_1", entity1.getEntityId());
  Assert.assertEquals("type_1", entity1.getEntityType());
  Assert.assertEquals(123l, entity1.getStartTime().longValue());
  Assert.assertEquals(2, entity1.getEvents().size());
  Assert.assertEquals(4, entity1.getPrimaryFilters().size());
  Assert.assertEquals(4, entity1.getOtherInfo().size());
  TimelineEntity entity2 = entities.getEntities().get(1);
  Assert.assertNotNull(entity2);
  Assert.assertEquals("id_2", entity2.getEntityId());
  Assert.assertEquals("type_1", entity2.getEntityType());
  Assert.assertEquals(123l, entity2.getStartTime().longValue());
  Assert.assertEquals(2, entity2.getEvents().size());
  Assert.assertEquals(4, entity2.getPrimaryFilters().size());
  Assert.assertEquals(4, entity2.getOtherInfo().size());
  TimelineEntity entity3 = entities.getEntities().get(2);
  Assert.assertNotNull(entity2);
  Assert.assertEquals("id_6", entity3.getEntityId());
  Assert.assertEquals("type_1", entity3.getEntityType());
  Assert.assertEquals(61l, entity3.getStartTime().longValue());
  Assert.assertEquals(0, entity3.getEvents().size());
  Assert.assertEquals(4, entity3.getPrimaryFilters().size());
  Assert.assertEquals(4, entity3.getOtherInfo().size());
}
 
Example 26
Source Project: hadoop   Source File: TestTimelineWebServices.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testGetEntities() throws Exception {
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("timeline")
      .path("type_1")
      .accept(MediaType.APPLICATION_JSON)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  verifyEntities(response.getEntity(TimelineEntities.class));
}
 
Example 27
Source Project: hadoop   Source File: TestTimelineWebServices.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testPrimaryFilterString() {
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("timeline")
      .path("type_1").queryParam("primaryFilter", "user:username")
      .accept(MediaType.APPLICATION_JSON)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  verifyEntities(response.getEntity(TimelineEntities.class));
}
 
Example 28
Source Project: hadoop   Source File: TestTimelineWebServices.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testPrimaryFilterInteger() {
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("timeline")
      .path("type_1").queryParam("primaryFilter",
          "appname:" + Integer.toString(Integer.MAX_VALUE))
      .accept(MediaType.APPLICATION_JSON)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  verifyEntities(response.getEntity(TimelineEntities.class));
}
 
Example 29
Source Project: hadoop   Source File: TestTimelineWebServices.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testPrimaryFilterLong() {
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("timeline")
      .path("type_1").queryParam("primaryFilter",
          "long:" + Long.toString((long) Integer.MAX_VALUE + 1l))
      .accept(MediaType.APPLICATION_JSON)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  verifyEntities(response.getEntity(TimelineEntities.class));
}
 
Example 30
Source Project: hadoop   Source File: TestTimelineWebServices.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testPrimaryFilterNumericString() {
  // without quotes, 123abc is interpreted as the number 123,
  // which finds no entities
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("timeline")
      .path("type_1").queryParam("primaryFilter", "other:123abc")
      .accept(MediaType.APPLICATION_JSON)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  assertEquals(0, response.getEntity(TimelineEntities.class).getEntities()
      .size());
}