Example usage for org.apache.hadoop.mapreduce Job getTaskCompletionEvents

List of usage examples for org.apache.hadoop.mapreduce Job getTaskCompletionEvents

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce Job getTaskCompletionEvents.

Prototype

public TaskCompletionEvent[] getTaskCompletionEvents(final int startFrom, final int numEvents)
        throws IOException, InterruptedException 

Source Link

Document

Get events indicating completion (success/failure) of component tasks.

Usage

From source file:org.apache.druid.indexer.Utils.java

License:Apache License

public static String getFailureMessage(Job failedJob, ObjectMapper jsonMapper) {
    try {/*from   w  ww  .j av  a2 s  .co  m*/
        Map<String, String> taskDiagsMap = new HashMap<>();
        TaskCompletionEvent[] completionEvents = failedJob.getTaskCompletionEvents(0, 100);
        for (TaskCompletionEvent tce : completionEvents) {
            String[] taskDiags = failedJob.getTaskDiagnostics(tce.getTaskAttemptId());
            String combinedTaskDiags = "";
            for (String taskDiag : taskDiags) {
                combinedTaskDiags += taskDiag;
            }
            taskDiagsMap.put(tce.getTaskAttemptId().toString(), combinedTaskDiags);
        }
        return jsonMapper.writeValueAsString(taskDiagsMap);
    } catch (IOException | InterruptedException ie) {
        log.error(ie, "couldn't get failure cause for job [%s]", failedJob.getJobName());
        return null;
    }
}