Example usage for org.apache.hadoop.mapreduce TaskCompletionEvent getTaskAttemptId

List of usage examples for org.apache.hadoop.mapreduce TaskCompletionEvent getTaskAttemptId

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce TaskCompletionEvent getTaskAttemptId.

Prototype

public TaskAttemptID getTaskAttemptId() 

Source Link

Document

Returns task id.

Usage

From source file:cascading.stats.hadoop.HadoopNodeStats.java

License:Open Source License

protected void addAttempt(TaskCompletionEvent event) {
    // the event could be a housekeeping task, which we are not tracking
    String sliceID = sliceIDCache.get(event.getTaskAttemptId().getTaskID());

    if (sliceID == null)
        return;//ww  w .  ja  v  a  2  s  . c o  m

    FlowSliceStats stats;

    synchronized (sliceStatsMap) {
        stats = sliceStatsMap.get(sliceID);
    }

    if (stats == null)
        return;

    ((HadoopSliceStats) stats).addAttempt(event);
}

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

License:Apache License

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