Example usage for org.apache.hadoop.yarn.api.records.timeline TimelineDomain getId

List of usage examples for org.apache.hadoop.yarn.api.records.timeline TimelineDomain getId

Introduction

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

Prototype

@XmlElement(name = "id")
public String getId() 

Source Link

Document

Get the domain ID

Usage

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   w w  w  .  jav  a2 s.co 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
    }
}