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

The following examples show how to use org.apache.hadoop.yarn.api.records.timeline.TimelineEntities. 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: TestTimelineWebServices.java    From big-c with 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 #2
Source File: TimelineWebServices.java    From big-c with 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 #3
Source File: TestTimelineWebServices.java    From hadoop with 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 #4
Source File: TestTimelineWebServices.java    From hadoop with 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 #5
Source File: TestTimelineWebServices.java    From hadoop with 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 #6
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 #7
Source File: TestTimelineDataManager.java    From big-c with 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 #8
Source File: TestTimelineDataManager.java    From hadoop with 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 #9
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 #10
Source File: ApplicationHistoryManagerOnTimelineStore.java    From big-c with Apache License 2.0 6 votes vote down vote up
@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 #11
Source File: TestTimelineWebServices.java    From big-c with 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 #12
Source File: TestTimelineClient.java    From big-c with 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 #13
Source File: TimelineWebServices.java    From hadoop with 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 #14
Source File: TestLeveldbTimelineStore.java    From big-c with 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 #15
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 #16
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 #17
Source File: ApplicationHistoryManagerOnTimelineStore.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@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 #18
Source File: TestTimelineClient.java    From hadoop with 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 #19
Source File: TestLeveldbTimelineStore.java    From hadoop with 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 #20
Source File: TestTimelineWebServices.java    From big-c with 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 #21
Source File: TimelineDataManager.java    From big-c with 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 #22
Source File: TestTimelineWebServices.java    From big-c with 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());
}
 
Example #23
Source File: TestApplicationHistoryManagerOnTimelineStore.java    From big-c with Apache License 2.0 5 votes vote down vote up
@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 File: TestTimelineWebServices.java    From big-c with 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 #25
Source File: TestTimelineWebServices.java    From big-c with 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 #26
Source File: TestTimelineWebServices.java    From big-c with 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 #27
Source File: TestTimelineWebServices.java    From big-c with 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 #28
Source File: TestTimelineWebServices.java    From big-c with 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 #29
Source File: TestTimelineDataManager.java    From big-c with 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 #30
Source File: TestTimelineWebServices.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testSecondaryFilters() {
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("timeline")
      .path("type_1")
      .queryParam("secondaryFilter",
          "user:username,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));
}