Search in sources :

Example 56 with TimelineEntity

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

the class TestTimelineClient method testPostIncompleteEntities.

@Test
public void testPostIncompleteEntities() throws Exception {
    try {
        client.putEntities(new TimelineEntity());
        Assert.fail("Exception should have been thrown");
    } catch (YarnException e) {
    }
}
Also used : TimelineEntity(org.apache.hadoop.yarn.api.records.timeline.TimelineEntity) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 57 with TimelineEntity

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

the class TestTimelineClient method generateEntity.

private static TimelineEntity generateEntity() {
    TimelineEntity entity = new TimelineEntity();
    entity.setEntityId("entity id");
    entity.setEntityType("entity type");
    entity.setStartTime(System.currentTimeMillis());
    for (int i = 0; i < 2; ++i) {
        TimelineEvent event = new TimelineEvent();
        event.setTimestamp(System.currentTimeMillis());
        event.setEventType("test event type " + i);
        event.addEventInfo("key1", "val1");
        event.addEventInfo("key2", "val2");
        entity.addEvent(event);
    }
    entity.addRelatedEntity("test ref type 1", "test ref id 1");
    entity.addRelatedEntity("test ref type 2", "test ref id 2");
    entity.addPrimaryFilter("pkey1", "pval1");
    entity.addPrimaryFilter("pkey2", "pval2");
    entity.addOtherInfo("okey1", "oval1");
    entity.addOtherInfo("okey2", "oval2");
    entity.setDomainId("domain id 1");
    return entity;
}
Also used : TimelineEvent(org.apache.hadoop.yarn.api.records.timeline.TimelineEvent) TimelineEntity(org.apache.hadoop.yarn.api.records.timeline.TimelineEntity)

Example 58 with TimelineEntity

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

the class ApplicationHistoryManagerOnTimelineStore method getApplications.

@Override
public Map<ApplicationId, ApplicationReport> getApplications(long appsNum, long appStartedTimeBegin, long appStartedTimeEnd) throws YarnException, IOException {
    TimelineEntities entities = timelineDataManager.getEntities(ApplicationMetricsConstants.ENTITY_TYPE, null, null, appStartedTimeBegin, appStartedTimeEnd, null, null, appsNum == Long.MAX_VALUE ? this.maxLoadedApplications : appsNum, 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;
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) Field(org.apache.hadoop.yarn.server.timeline.TimelineReader.Field) TimelineEntities(org.apache.hadoop.yarn.api.records.timeline.TimelineEntities) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) TimelineEntity(org.apache.hadoop.yarn.api.records.timeline.TimelineEntity) AuthorizationException(org.apache.hadoop.security.authorize.AuthorizationException) ContainerNotFoundException(org.apache.hadoop.yarn.exceptions.ContainerNotFoundException) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) IOException(java.io.IOException) ApplicationAttemptNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException) LinkedHashMap(java.util.LinkedHashMap)

Example 59 with TimelineEntity

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

the class ApplicationHistoryManagerOnTimelineStore method getContainer.

@Override
public ContainerReport getContainer(ContainerId containerId) throws YarnException, IOException {
    ApplicationReportExt app = getApplication(containerId.getApplicationAttemptId().getApplicationId(), ApplicationReportField.USER_AND_ACLS);
    checkAccess(app);
    TimelineEntity entity = timelineDataManager.getEntity(ContainerMetricsConstants.ENTITY_TYPE, containerId.toString(), EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser());
    if (entity == null) {
        throw new ContainerNotFoundException("The entity for container " + containerId + " doesn't exist in the timeline store");
    } else {
        return convertToContainerReport(entity, serverHttpAddress, app.appReport.getUser());
    }
}
Also used : Field(org.apache.hadoop.yarn.server.timeline.TimelineReader.Field) TimelineEntity(org.apache.hadoop.yarn.api.records.timeline.TimelineEntity) ContainerNotFoundException(org.apache.hadoop.yarn.exceptions.ContainerNotFoundException)

Example 60 with TimelineEntity

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

the class KeyValueBasedTimelineStore method getEntityTimelines.

@Override
public synchronized TimelineEvents getEntityTimelines(String entityType, SortedSet<String> entityIds, Long limit, Long windowStart, Long windowEnd, Set<String> eventTypes) {
    if (getServiceStopped()) {
        LOG.info("Service stopped, return null for the storage");
        return null;
    }
    TimelineEvents allEvents = new TimelineEvents();
    if (entityIds == null) {
        return allEvents;
    }
    if (limit == null) {
        limit = DEFAULT_LIMIT;
    }
    if (windowStart == null) {
        windowStart = Long.MIN_VALUE;
    }
    if (windowEnd == null) {
        windowEnd = Long.MAX_VALUE;
    }
    for (String entityId : entityIds) {
        EntityIdentifier entityID = new EntityIdentifier(entityId, entityType);
        TimelineEntity entity = entities.get(entityID);
        if (entity == null) {
            continue;
        }
        EventsOfOneEntity events = new EventsOfOneEntity();
        events.setEntityId(entityId);
        events.setEntityType(entityType);
        for (TimelineEvent event : entity.getEvents()) {
            if (events.getEvents().size() >= limit) {
                break;
            }
            if (event.getTimestamp() <= windowStart) {
                continue;
            }
            if (event.getTimestamp() > windowEnd) {
                continue;
            }
            if (eventTypes != null && !eventTypes.contains(event.getEventType())) {
                continue;
            }
            events.addEvent(event);
        }
        allEvents.addEvent(events);
    }
    return allEvents;
}
Also used : TimelineEvent(org.apache.hadoop.yarn.api.records.timeline.TimelineEvent) EventsOfOneEntity(org.apache.hadoop.yarn.api.records.timeline.TimelineEvents.EventsOfOneEntity) TimelineEvents(org.apache.hadoop.yarn.api.records.timeline.TimelineEvents) TimelineEntity(org.apache.hadoop.yarn.api.records.timeline.TimelineEntity)

Aggregations

TimelineEntity (org.apache.hadoop.yarn.api.records.timeline.TimelineEntity)98 Test (org.junit.Test)37 TimelineEvent (org.apache.hadoop.yarn.api.records.timeline.TimelineEvent)32 TimelineEntities (org.apache.hadoop.yarn.api.records.timeline.TimelineEntities)30 TimelinePutResponse (org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse)20 HashMap (java.util.HashMap)16 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)16 IOException (java.io.IOException)15 ClientResponse (com.sun.jersey.api.client.ClientResponse)12 WebResource (com.sun.jersey.api.client.WebResource)11 Configuration (org.apache.hadoop.conf.Configuration)9 HashSet (java.util.HashSet)8 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)7 Field (org.apache.hadoop.yarn.server.timeline.TimelineReader.Field)6 LinkedHashMap (java.util.LinkedHashMap)5 Set (java.util.Set)5 Path (org.apache.hadoop.fs.Path)5 AdminACLsManager (org.apache.hadoop.yarn.security.AdminACLsManager)5 ClientHandlerException (com.sun.jersey.api.client.ClientHandlerException)4 ArrayList (java.util.ArrayList)4