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:ApplicationMaster.java

License:Apache License

private static void publishContainerStartEvent(TimelineClient timelineClient, Container container)
        throws IOException, YarnException {
    TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(container.getId().toString());
    entity.setEntityType(DSEntity.DS_CONTAINER.toString());
    entity.addPrimaryFilter("user", UserGroupInformation.getCurrentUser().getShortUserName());
    TimelineEvent event = new TimelineEvent();
    event.setTimestamp(System.currentTimeMillis());
    event.setEventType(DSEvent.DS_CONTAINER_START.toString());
    event.addEventInfo("Node", container.getNodeId().toString());
    event.addEventInfo("Resources", container.getResource().toString());
    entity.addEvent(event);//from   www . j a va  2s.  c o  m

    timelineClient.putEntities(entity);
}

From source file:ApplicationMaster.java

License:Apache License

private static void publishContainerEndEvent(TimelineClient timelineClient, ContainerStatus container)
        throws IOException, YarnException {
    TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(container.getContainerId().toString());
    entity.setEntityType(DSEntity.DS_CONTAINER.toString());
    entity.addPrimaryFilter("user", UserGroupInformation.getCurrentUser().getShortUserName());
    TimelineEvent event = new TimelineEvent();
    event.setTimestamp(System.currentTimeMillis());
    event.setEventType(DSEvent.DS_CONTAINER_END.toString());
    event.addEventInfo("State", container.getState().name());
    event.addEventInfo("Exit Status", container.getExitStatus());
    entity.addEvent(event);/*from   w  w  w .  j  a  v a2  s.c  o  m*/

    timelineClient.putEntities(entity);
}

From source file:ApplicationMaster.java

License:Apache License

private static void publishApplicationAttemptEvent(TimelineClient timelineClient, String appAttemptId,
        DSEvent appEvent) throws IOException, YarnException {
    TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(appAttemptId);/*w  ww.  j  av a2 s .com*/
    entity.setEntityType(DSEntity.DS_APP_ATTEMPT.toString());
    entity.addPrimaryFilter("user", UserGroupInformation.getCurrentUser().getShortUserName());
    TimelineEvent event = new TimelineEvent();
    event.setEventType(appEvent.toString());
    event.setTimestamp(System.currentTimeMillis());
    entity.addEvent(event);

    timelineClient.putEntities(entity);
}

From source file:com.inforefiner.hdata.ApplicationMaster.java

License:Apache License

private static void publishContainerStartEvent(final TimelineClient timelineClient, Container container,
        String domainId, UserGroupInformation ugi) {
    final TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(container.getId().toString());
    entity.setEntityType(DSEntity.DS_CONTAINER.toString());
    entity.setDomainId(domainId);//from  w  w w  . j a  va 2  s  . c o m
    entity.addPrimaryFilter("user", ugi.getShortUserName());
    TimelineEvent event = new TimelineEvent();
    event.setTimestamp(System.currentTimeMillis());
    event.setEventType(DSEvent.DS_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:com.inforefiner.hdata.ApplicationMaster.java

License:Apache License

private static void publishContainerEndEvent(final TimelineClient timelineClient, ContainerStatus container,
        String domainId, UserGroupInformation ugi) {
    final TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(container.getContainerId().toString());
    entity.setEntityType(DSEntity.DS_CONTAINER.toString());
    entity.setDomainId(domainId);/*from  www  .  j a v a  2  s  .  c o m*/
    entity.addPrimaryFilter("user", ugi.getShortUserName());
    TimelineEvent event = new TimelineEvent();
    event.setTimestamp(System.currentTimeMillis());
    event.setEventType(DSEvent.DS_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:com.inforefiner.hdata.ApplicationMaster.java

License:Apache License

private static void publishApplicationAttemptEvent(final TimelineClient timelineClient, String appAttemptId,
        DSEvent appEvent, String domainId, UserGroupInformation ugi) {
    final TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(appAttemptId);/* w ww .ja v  a  2 s . c  o m*/
    entity.setEntityType(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(DSEvent.DS_APP_ATTEMPT_START) ? "start" : "end")
                + " event could not be published for " + appAttemptId.toString(), e);
    }
}

From source file:com.scistor.dshell.ScistorApplicationMaster.java

License:Apache License

private static void publishContainerStartEvent(TimelineClient timelineClient, Container container)
        throws IOException, YarnException {
    TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(container.getId().toString());
    entity.setEntityType(DSEntity.DS_CONTAINER.toString());
    entity.addPrimaryFilter("user", UserGroupInformation.getCurrentUser().toString());
    TimelineEvent event = new TimelineEvent();
    event.setTimestamp(System.currentTimeMillis());
    event.setEventType(DSEvent.DS_CONTAINER_START.toString());
    event.addEventInfo("Node", container.getNodeId().toString());
    event.addEventInfo("Resources", container.getResource().toString());
    entity.addEvent(event);// w  w  w .ja  v  a 2s  . co  m

    timelineClient.putEntities(entity);
}

From source file:com.scistor.dshell.ScistorApplicationMaster.java

License:Apache License

private static void publishContainerEndEvent(TimelineClient timelineClient, ContainerStatus container)
        throws IOException, YarnException {
    TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(container.getContainerId().toString());
    entity.setEntityType(DSEntity.DS_CONTAINER.toString());
    entity.addPrimaryFilter("user", UserGroupInformation.getCurrentUser().toString());
    TimelineEvent event = new TimelineEvent();
    event.setTimestamp(System.currentTimeMillis());
    event.setEventType(DSEvent.DS_CONTAINER_END.toString());
    event.addEventInfo("State", container.getState().name());
    event.addEventInfo("Exit Status", container.getExitStatus());
    entity.addEvent(event);/*from w ww.  ja va  2 s .c o  m*/

    timelineClient.putEntities(entity);
}

From source file:com.scistor.dshell.ScistorApplicationMaster.java

License:Apache License

private static void publishApplicationAttemptEvent(TimelineClient timelineClient, String appAttemptId,
        DSEvent appEvent) throws IOException, YarnException {
    TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(appAttemptId);//ww  w.ja v  a  2 s.  c om
    entity.setEntityType(DSEntity.DS_APP_ATTEMPT.toString());
    entity.addPrimaryFilter("user", UserGroupInformation.getCurrentUser().toString());
    TimelineEvent event = new TimelineEvent();
    event.setEventType(appEvent.toString());
    event.setTimestamp(System.currentTimeMillis());
    entity.addEvent(event);

    timelineClient.putEntities(entity);
}

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  ww.j av  a2  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);
    }
}