List of usage examples for org.apache.hadoop.yarn.api.records.timeline TimelinePutResponse getErrors
@XmlElement(name = "errors") public List<TimelinePutError> getErrors()
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 . j a va 2s. 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:org.apache.tez.dag.history.logging.ats.ATSHistoryLoggingService.java
License:Apache License
private void handleEvents(List<DAGHistoryEvent> events) { TimelineEntity[] entities = new TimelineEntity[events.size()]; for (int i = 0; i < events.size(); ++i) { DAGHistoryEvent event = events.get(i); String domainId = sessionDomainId; TezDAGID dagId = event.getDagID(); if (historyACLPolicyManager != null && dagId != null) { if (dagDomainIdMap.containsKey(dagId)) { domainId = dagDomainIdMap.get(dagId); }/*from w w w . java 2 s.c o m*/ } entities[i] = HistoryEventTimelineConversion.convertToTimelineEntity(event.getHistoryEvent()); if (historyACLPolicyManager != null) { if (domainId != null && !domainId.isEmpty()) { historyACLPolicyManager.updateTimelineEntityDomain(entities[i], domainId); } } } if (LOG.isDebugEnabled()) { LOG.debug("Sending event batch to Timeline, batchSize=" + events.size()); } try { TimelinePutResponse response = timelineClient.putEntities(entities); if (response != null && !response.getErrors().isEmpty()) { int count = response.getErrors().size(); for (int i = 0; i < count; ++i) { TimelinePutError err = response.getErrors().get(i); if (err.getErrorCode() != 0) { LOG.warn("Could not post history event to ATS" + ", atsPutError=" + err.getErrorCode() + ", entityId=" + entities[i].getEntityId() + ", eventType=" + events.get(i).getHistoryEvent().getEventType()); } } } // Do nothing additional, ATS client library should handle throttling // or auto-disable as needed } catch (Exception e) { LOG.warn("Could not handle history events", e); } }
From source file:org.apache.tez.dag.history.logging.ats.ATSV15HistoryLoggingService.java
License:Apache License
private void handleEvents(DAGHistoryEvent event) { String domainId = sessionDomainId; TezDAGID dagId = event.getDagID();//from w w w.j a v a 2 s . com if (historyACLPolicyManager != null && dagId != null) { if (dagDomainIdMap.containsKey(dagId)) { domainId = dagDomainIdMap.get(dagId); } } TimelineEntity entity = HistoryEventTimelineConversion.convertToTimelineEntity(event.getHistoryEvent()); if (historyACLPolicyManager != null) { if (HistoryEventType.isDAGSpecificEvent(event.getHistoryEvent().getEventType())) { if (domainId != null && !domainId.isEmpty()) { historyACLPolicyManager.updateTimelineEntityDomain(entity, domainId); } } else { if (sessionDomainId != null && !sessionDomainId.isEmpty()) { historyACLPolicyManager.updateTimelineEntityDomain(entity, sessionDomainId); } } } try { TimelineEntityGroupId groupId = getGroupId(event); TimelinePutResponse response = timelineClient.putEntities(appContext.getApplicationAttemptId(), groupId, entity); if (response != null && !response.getErrors().isEmpty()) { int count = response.getErrors().size(); for (int i = 0; i < count; ++i) { TimelinePutError err = response.getErrors().get(i); if (err.getErrorCode() != 0) { LOG.warn("Could not post history event to ATS" + ", atsPutError=" + err.getErrorCode() + ", entityId=" + err.getEntityId()); } } } // Do nothing additional, ATS client library should handle throttling // or auto-disable as needed } catch (Exception e) { LOG.warn("Could not handle history events", e); } }