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

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

Introduction

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

Prototype

public void addPrimaryFilter(String key, Object value) 

Source Link

Document

Add a single piece of primary filter to the existing primary filter map

Usage

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);/*  w  ww.  j a v  a  2  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);/*from   ww w.  j  a  v a  2  s.c  o m*/
    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);/*from  w  w w .j av  a2  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);//from  www .  j a v  a2  s  . com
    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);//from w  w w  .  ja v  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.pig.backend.hadoop.ATSService.java

License:Apache License

synchronized public void logEvent(final ATSEvent event) {
    executor.submit(new Runnable() {
        @Override/*ww w  .j av  a  2s  .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/* ww  w .  ja va  2s  .c om*/
        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()));
    }/*ww w. jav  a 2s  . c o  m*/

    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);//from   www  .  j a  v a 2  s .c o  m

    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  v a 2 s.c  om*/

    return atsEntity;
}