Example usage for org.apache.hadoop.yarn.api.records.timeline TimelineEntity setEntityId

List of usage examples for org.apache.hadoop.yarn.api.records.timeline TimelineEntity setEntityId

Introduction

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

Prototype

public void setEntityId(String entityId) 

Source Link

Document

Set the entity Id

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);//from ww  w  .j a v a  2 s . com
    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 w w w .  j  a  v a2  s  . c om*/
    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);
    entity.setEntityType(ApplicationMaster.YarntfEntity.YARNTF_APP_ATTEMPT.toString());
    entity.setDomainId(domainId);/*from   w  w w .j a v a 2  s  . c o  m*/
    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);/* ww w . j a v  a 2s .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);
    entity.setEntityType(ApplicationMaster.DSEntity.DS_APP_ATTEMPT.toString());
    entity.setDomainId(domainId);/*ww  w .java  2  s .  co  m*/
    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);//from   w  w  w. j  a v  a  2s .  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.pig.backend.hadoop.ATSService.java

License:Apache License

synchronized public void logEvent(final ATSEvent event) {
    executor.submit(new Runnable() {
        @Override/*w  ww  . j a  va 2  s .  c om*/
        public void run() {
            TimelineEntity entity = new TimelineEntity();
            entity.setEntityId(event.pigScriptId);
            entity.setEntityType(EntityType);
            entity.addPrimaryFilter(EntityCallerId, event.callerId != null ? event.callerId : "default");
            try {
                timelineClient.putEntities(entity);
            } catch (Exception e) {
                log.info("Failed to submit plan to ATS: " + e.getMessage());
            }
        }
    });
}

From source file:org.apache.pig.backend.hadoop.PigATSClient.java

License:Apache License

synchronized public void logEvent(final ATSEvent event) {
    executor.submit(new Runnable() {
        @Override/*from  ww  w.  ja  v a 2s .  com*/
        public void run() {
            TimelineEntity entity = new TimelineEntity();
            entity.setEntityId(event.pigScriptId);
            entity.setEntityType(ENTITY_TYPE);
            entity.addPrimaryFilter(ENTITY_CALLERID, event.callerId != null ? event.callerId : "default");
            try {
                timelineClient.putEntities(entity);
            } catch (Exception e) {
                log.info("Failed to submit plan to ATS: " + e.getMessage());
            }
        }
    });
}

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

License:Apache License

private static TimelineEntity convertAppLaunchedEvent(AppLaunchedEvent event) {
    TimelineEntity atsEntity = new TimelineEntity();
    atsEntity.setEntityId("tez_" + event.getApplicationId().toString());
    atsEntity.setEntityType(EntityTypes.TEZ_APPLICATION.name());

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

    atsEntity.addPrimaryFilter(ATSConstants.USER, event.getUser());

    atsEntity.addOtherInfo(ATSConstants.CONFIG, DAGUtils.convertConfigurationToATSMap(event.getConf()));

    atsEntity.setStartTime(event.getLaunchTime());

    if (event.getVersion() != null) {
        atsEntity.addOtherInfo(ATSConstants.TEZ_VERSION,
                DAGUtils.convertTezVersionToATSMap(event.getVersion()));
    }//w w w.  j  ava2s.  com

    return atsEntity;
}

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  ww .ja v  a2 s. c  o m*/

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

    return atsEntity;
}