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

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

Introduction

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

Prototype

public void setDomainId(String domainId) 

Source Link

Document

Set the ID of the domain that the entity is to be put

Usage

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);
    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);/*from   ww w. ja v  a 2  s  .  co  m*/

    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);
    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);//from   w w  w.j  ava 2s. co m
    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);/*from ww  w .  j  av 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:de.huberlin.wbi.hiway.am.WorkflowDriver.java

License:Apache License

private void timelineWrite(String entity, String message) {

    if (timelineClient == null)
        return;//from www  .  j a  v a 2  s .c  o  m

    try {
        TimelineDomain myDomain = new TimelineDomain();
        myDomain.setId("hiwayWorkflow");

        timelineClient.putDomain(myDomain);

        TimelineEntity myEntity = new TimelineEntity();
        myEntity.setDomainId(myDomain.getId());
        myEntity.setEntityType("APPLICATION");
        myEntity.setEntityId(entity);

        TimelinePutResponse response = timelineClient.putEntities(myEntity);
        if (response.getErrors().size() > 0)
            Logger.writeToStdErr(String.format("Errors in timelineWrite for putting entity %s: %s", entity,
                    response.getErrors().stream().map(Object::toString).collect(Collectors.joining("; "))));

        TimelineEvent event = new TimelineEvent();
        event.setEventType("LOG");
        event.setTimestamp(System.currentTimeMillis());
        event.addEventInfo("MESSAGE", message);

        myEntity.addEvent(event);
        response = timelineClient.putEntities(myEntity);
        if (response.getErrors().size() > 0)
            Logger.writeToStdErr(String.format("Errors in timelineWrite for putting event %s: %s", message,
                    response.getErrors().stream().map(Object::toString).collect(Collectors.joining("; "))));

    } catch (IOException e) {
        // Handle the exception
    } catch (RuntimeException e) {
        // In Hadoop 2.6, if attempts submit information to the Timeline Server fail more than the retry limit,
        // a RuntimeException will be raised. This may change in future releases, being
        // replaced with a IOException that is (or wraps) that which triggered retry failures.
    } catch (YarnException e) {
        // Handle the exception
    }
}

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);
    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);/* w ww  .  j av a  2s.c  o m*/

    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);
    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);/*w w  w  .  j ava  2  s  .c  o  m*/
    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 w w  w . j av  a2s  .  co 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);
    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);//ww  w .j a  v  a  2s.c o  m
    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  w  w w. j  a va  2s.  c  o 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);
    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);/*from   w  w  w.j a  va2  s. c om*/

    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);
    }
}