Java Code Examples for org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse.TimelinePutError#getErrorCode()

The following examples show how to use org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse.TimelinePutError#getErrorCode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ATSV15HistoryLoggingService.java    From tez with Apache License 2.0 6 votes vote down vote up
private void logEntity(TimelineEntityGroupId groupId, TimelineEntity entity, String domainId) {
  if (historyACLPolicyManager != null && domainId != null && !domainId.isEmpty()) {
    historyACLPolicyManager.updateTimelineEntityDomain(entity, domainId);
  }

  try {
    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);
  }
}
 
Example 2
Source File: ATSHistoryLoggingService.java    From incubator-tez with Apache License 2.0 4 votes vote down vote up
private void handleEvent(DAGHistoryEvent event) {
  HistoryEventType eventType = event.getHistoryEvent().getEventType();

  TezDAGID dagId = event.getDagID();

  if (eventType.equals(HistoryEventType.DAG_SUBMITTED)) {
    DAGSubmittedEvent dagSubmittedEvent =
        (DAGSubmittedEvent) event.getHistoryEvent();
    String dagName = dagSubmittedEvent.getDAGName();
    if (dagName != null
        && dagName.startsWith(
        TezConfiguration.TEZ_PREWARM_DAG_NAME_PREFIX)) {
      // Skip recording pre-warm DAG events
      skippedDAGs.add(dagId);
      return;
    }
  }
  if (eventType.equals(HistoryEventType.DAG_FINISHED)) {
    // Remove from set to keep size small
    // No more events should be seen after this point.
    if (skippedDAGs.remove(dagId)) {
      return;
    }
  }

  if (dagId != null && skippedDAGs.contains(dagId)) {
    // Skip pre-warm DAGs
    return;
  }

  try {
    TimelinePutResponse response =
        timelineClient.putEntities(
            HistoryEventTimelineConversion.convertToTimelineEntity(event.getHistoryEvent()));
    if (response != null
      && !response.getErrors().isEmpty()) {
      TimelinePutError err = response.getErrors().get(0);
      if (err.getErrorCode() != 0) {
        LOG.warn("Could not post history event to ATS, eventType="
            + eventType
            + ", atsPutError=" + err.getErrorCode());
      }
    }
    // Do nothing additional, ATS client library should handle throttling
    // or auto-disable as needed
  } catch (Exception e) {
    LOG.warn("Could not handle history event, eventType="
        + eventType, e);
  }
}
 
Example 3
Source File: ATSHistoryLoggingService.java    From tez with Apache License 2.0 4 votes vote down vote up
private void handleEvents(List<DAGHistoryEvent> events) {
  List<TimelineEntity> entities = new ArrayList<>(events.size());
  for (DAGHistoryEvent event : events) {
    String domainId = getDomainForEvent(event);
    // skippedDags is updated in the above call so check again.
    if (event.getDagID() != null && skippedDAGs.contains(event.getDagID())) {
      continue;
    }
    List<TimelineEntity> eventEntities = HistoryEventTimelineConversion.convertToTimelineEntities(
        event.getHistoryEvent());
    entities.addAll(eventEntities);
    if (historyACLPolicyManager != null && domainId != null && !domainId.isEmpty()) {
      for (TimelineEntity entity: eventEntities) {
        historyACLPolicyManager.updateTimelineEntityDomain(entity, domainId);
      }
    }
  }

  if (LOG.isDebugEnabled()) {
    LOG.debug("Sending event batch to Timeline, batchSize=" + events.size());
  }
  try {
    TimelinePutResponse response =
        timelineClient.putEntities(entities.toArray(new TimelineEntity[entities.size()]));
    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);
  }
}