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

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

Introduction

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

Prototype

public String[] getTaskDiagnostics(final TaskAttemptID taskid) throws IOException, InterruptedException 

Source Link

Document

Gets the diagnostic messages for a given task attempt.

Usage

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

License:Apache License

public static String getFailureMessage(Job failedJob, ObjectMapper jsonMapper) {
    try {/*w  w w  . ja  va  2  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;
    }
}