Example usage for org.apache.hadoop.yarn.api.records.timeline TimelineEvent setEventType

List of usage examples for org.apache.hadoop.yarn.api.records.timeline TimelineEvent setEventType

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.api.records.timeline TimelineEvent setEventType.

Prototype

public void setEventType(String eventType) 

Source Link

Document

Set the event type

Usage

From source file:io.hops.tensorflow.TimelineHandler.java

License:Apache License

public void publishContainerStartEvent(Container container) {
    final TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(container.getId().toString());
    entity.setEntityType(ApplicationMaster.YarntfEntity.YARNTF_CONTAINER.toString());
    entity.setDomainId(domainId);//w  w w .  jav  a2s . c o  m
    entity.addPrimaryFilter("user", ugi.getShortUserName());
    TimelineEvent event = new TimelineEvent();
    event.setTimestamp(System.currentTimeMillis());
    event.setEventType(ApplicationMaster.YarntfEvent.YARNTF_CONTAINER_START.toString());
    event.addEventInfo("Node", container.getNodeId().toString());
    event.addEventInfo("Resources", container.getResource().toString());
    entity.addEvent(event);

    try {
        ugi.doAs(new PrivilegedExceptionAction<TimelinePutResponse>() {
            @Override
            public TimelinePutResponse run() throws Exception {
                return timelineClient.putEntities(entity);
            }
        });
    } catch (Exception e) {
        LOG.error("Container start event could not be published for " + container.getId().toString(),
                e instanceof UndeclaredThrowableException ? e.getCause() : e);
    }
}

From source file:io.hops.tensorflow.TimelineHandler.java

License:Apache License

public void publishContainerEndEvent(ContainerStatus container) {
    final TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(container.getContainerId().toString());
    entity.setEntityType(ApplicationMaster.YarntfEntity.YARNTF_CONTAINER.toString());
    entity.setDomainId(domainId);/*from  ww  w . java2  s.  c  o m*/
    entity.addPrimaryFilter("user", ugi.getShortUserName());
    TimelineEvent event = new TimelineEvent();
    event.setTimestamp(System.currentTimeMillis());
    event.setEventType(ApplicationMaster.YarntfEvent.YARNTF_CONTAINER_END.toString());
    event.addEventInfo("State", container.getState().name());
    event.addEventInfo("Exit Status", container.getExitStatus());
    entity.addEvent(event);
    try {
        timelineClient.putEntities(entity);
    } catch (YarnException | IOException e) {
        LOG.error("Container end event could not be published for " + container.getContainerId().toString(), e);
    }
}

From source file:io.hops.tensorflow.TimelineHandler.java

License:Apache License

public void publishApplicationAttemptEvent(ApplicationMaster.YarntfEvent appEvent) {
    final TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(appAttemptId);/*  w  w  w .j  a  va 2  s.  com*/
    entity.setEntityType(ApplicationMaster.YarntfEntity.YARNTF_APP_ATTEMPT.toString());
    entity.setDomainId(domainId);
    entity.addPrimaryFilter("user", ugi.getShortUserName());
    TimelineEvent event = new TimelineEvent();
    event.setEventType(appEvent.toString());
    event.setTimestamp(System.currentTimeMillis());
    entity.addEvent(event);
    try {
        timelineClient.putEntities(entity);
    } catch (YarnException | IOException e) {
        LOG.error("App Attempt "
                + (appEvent.equals(ApplicationMaster.YarntfEvent.YARNTF_APP_ATTEMPT_START) ? "start" : "end")
                + " event could not be published for " + appAttemptId.toString(), e);
    }
}

From source file:org.apache.metron.maas.service.yarn.YarnUtils.java

License:Apache License

public void publishContainerEndEvent(final TimelineClient timelineClient, ContainerStatus container,
        String domainId, UserGroupInformation ugi) {
    final TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(container.getContainerId().toString());
    entity.setEntityType(ApplicationMaster.DSEntity.DS_CONTAINER.toString());
    entity.setDomainId(domainId);//  w  w  w.j  a v a 2 s  .c  o m
    entity.addPrimaryFilter("user", ugi.getShortUserName());
    TimelineEvent event = new TimelineEvent();
    event.setTimestamp(System.currentTimeMillis());
    event.setEventType(ContainerEvents.CONTAINER_END.toString());
    event.addEventInfo("State", container.getState().name());
    event.addEventInfo("Exit Status", container.getExitStatus());
    entity.addEvent(event);
    try {
        timelineClient.putEntities(entity);
    } catch (YarnException | IOException e) {
        LOG.error("Container end event could not be published for " + container.getContainerId().toString(), e);
    }
}

From source file:org.apache.metron.maas.service.yarn.YarnUtils.java

License:Apache License

public void publishApplicationAttemptEvent(final TimelineClient timelineClient, String appAttemptId,
        ContainerEvents appEvent, String domainId, UserGroupInformation ugi) {
    final TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(appAttemptId);/*  w  ww. j  a v  a  2s .  co m*/
    entity.setEntityType(ApplicationMaster.DSEntity.DS_APP_ATTEMPT.toString());
    entity.setDomainId(domainId);
    entity.addPrimaryFilter("user", ugi.getShortUserName());
    TimelineEvent event = new TimelineEvent();
    event.setEventType(appEvent.toString());
    event.setTimestamp(System.currentTimeMillis());
    entity.addEvent(event);
    try {
        timelineClient.putEntities(entity);
    } catch (YarnException | IOException e) {
        LOG.error("App Attempt " + (appEvent.equals(ContainerEvents.APP_ATTEMPT_START) ? "start" : "end")
                + " event could not be published for " + appAttemptId.toString(), e);
    }
}

From source file:org.apache.metron.maas.service.yarn.YarnUtils.java

License:Apache License

public void publishContainerStartEvent(final TimelineClient timelineClient, Container container,
        String domainId, UserGroupInformation ugi) {
    final TimelineEntity entity = new TimelineEntity();
    entity.setEntityId("" + container.getId());
    entity.setEntityType(ApplicationMaster.DSEntity.DS_CONTAINER.toString());
    entity.setDomainId(domainId);// ww w  .  j  av a  2  s  .c o m
    entity.addPrimaryFilter("user", ugi.getShortUserName());
    TimelineEvent event = new TimelineEvent();
    event.setTimestamp(System.currentTimeMillis());
    event.setEventType(ContainerEvents.CONTAINER_START.toString());
    event.addEventInfo("Node", container.getNodeId().toString());
    event.addEventInfo("Resources", container.getResource().toString());
    entity.addEvent(event);

    try {
        ugi.doAs(new PrivilegedExceptionAction<TimelinePutResponse>() {
            @Override
            public TimelinePutResponse run() throws Exception {
                return timelineClient.putEntities(entity);
            }
        });
    } catch (Exception e) {
        LOG.error("Container start event could not be published for " + container.getId().toString(),
                e instanceof UndeclaredThrowableException ? e.getCause() : e);
    }
}

From source file:org.apache.tez.dag.history.logging.ats.HistoryEventTimelineConversion.java

License:Apache License

private static TimelineEntity convertAMLaunchedEvent(AMLaunchedEvent event) {
    TimelineEntity atsEntity = new TimelineEntity();
    atsEntity.setEntityId("tez_" + event.getApplicationAttemptId().toString());
    atsEntity.setEntityType(EntityTypes.TEZ_APPLICATION_ATTEMPT.name());

    atsEntity.addRelatedEntity(ATSConstants.APPLICATION_ID,
            event.getApplicationAttemptId().getApplicationId().toString());
    atsEntity.addRelatedEntity(ATSConstants.APPLICATION_ATTEMPT_ID, event.getApplicationAttemptId().toString());
    atsEntity.addRelatedEntity(ATSConstants.USER, event.getUser());

    atsEntity.addPrimaryFilter(ATSConstants.USER, event.getUser());
    atsEntity.addPrimaryFilter(ATSConstants.APPLICATION_ID,
            event.getApplicationAttemptId().getApplicationId().toString());

    atsEntity.setStartTime(event.getLaunchTime());

    TimelineEvent launchEvt = new TimelineEvent();
    launchEvt.setEventType(HistoryEventType.AM_LAUNCHED.name());
    launchEvt.setTimestamp(event.getLaunchTime());
    atsEntity.addEvent(launchEvt);// w w  w . j a  va2s.  c  om

    atsEntity.addOtherInfo(ATSConstants.APP_SUBMIT_TIME, event.getAppSubmitTime());

    return atsEntity;
}

From source file:org.apache.tez.dag.history.logging.ats.HistoryEventTimelineConversion.java

License:Apache License

private static TimelineEntity convertAMStartedEvent(AMStartedEvent event) {
    TimelineEntity atsEntity = new TimelineEntity();
    atsEntity.setEntityId("tez_" + event.getApplicationAttemptId().toString());
    atsEntity.setEntityType(EntityTypes.TEZ_APPLICATION_ATTEMPT.name());

    atsEntity.addPrimaryFilter(ATSConstants.USER, event.getUser());
    atsEntity.addPrimaryFilter(ATSConstants.APPLICATION_ID,
            event.getApplicationAttemptId().getApplicationId().toString());

    TimelineEvent startEvt = new TimelineEvent();
    startEvt.setEventType(HistoryEventType.AM_STARTED.name());
    startEvt.setTimestamp(event.getStartTime());
    atsEntity.addEvent(startEvt);// w  w  w  . ja  va2 s. co m

    return atsEntity;
}

From source file:org.apache.tez.dag.history.logging.ats.HistoryEventTimelineConversion.java

License:Apache License

private static TimelineEntity convertContainerLaunchedEvent(ContainerLaunchedEvent event) {
    TimelineEntity atsEntity = new TimelineEntity();
    atsEntity.setEntityId("tez_" + event.getContainerId().toString());
    atsEntity.setEntityType(EntityTypes.TEZ_CONTAINER_ID.name());

    atsEntity.addRelatedEntity(EntityTypes.TEZ_APPLICATION_ATTEMPT.name(),
            "tez_" + event.getApplicationAttemptId().toString());
    atsEntity.addRelatedEntity(ATSConstants.CONTAINER_ID, event.getContainerId().toString());

    atsEntity.addPrimaryFilter(ATSConstants.APPLICATION_ID,
            event.getApplicationAttemptId().getApplicationId().toString());

    atsEntity.setStartTime(event.getLaunchTime());

    TimelineEvent launchEvt = new TimelineEvent();
    launchEvt.setEventType(HistoryEventType.CONTAINER_LAUNCHED.name());
    launchEvt.setTimestamp(event.getLaunchTime());
    atsEntity.addEvent(launchEvt);// www.  j a  va  2  s  .  c o  m

    return atsEntity;
}

From source file:org.apache.tez.dag.history.logging.ats.HistoryEventTimelineConversion.java

License:Apache License

private static TimelineEntity convertContainerStoppedEvent(ContainerStoppedEvent event) {
    TimelineEntity atsEntity = new TimelineEntity();
    atsEntity.setEntityId("tez_" + event.getContainerId().toString());
    atsEntity.setEntityType(EntityTypes.TEZ_CONTAINER_ID.name());

    // In case, a container is stopped in a different attempt
    atsEntity.addRelatedEntity(EntityTypes.TEZ_APPLICATION_ATTEMPT.name(),
            "tez_" + event.getApplicationAttemptId().toString());

    TimelineEvent stoppedEvt = new TimelineEvent();
    stoppedEvt.setEventType(HistoryEventType.CONTAINER_STOPPED.name());
    stoppedEvt.setTimestamp(event.getStoppedTime());
    atsEntity.addEvent(stoppedEvt);//from w w  w .  j  a va 2s.  c o  m

    atsEntity.addPrimaryFilter(ATSConstants.APPLICATION_ID,
            event.getApplicationAttemptId().getApplicationId().toString());
    atsEntity.addPrimaryFilter(ATSConstants.EXIT_STATUS, event.getExitStatus());

    atsEntity.addOtherInfo(ATSConstants.EXIT_STATUS, event.getExitStatus());
    atsEntity.addOtherInfo(ATSConstants.FINISH_TIME, event.getStoppedTime());

    return atsEntity;
}