Example usage for org.apache.hadoop.util ReflectionUtils logThreadInfo

List of usage examples for org.apache.hadoop.util ReflectionUtils logThreadInfo

Introduction

In this page you can find the example usage for org.apache.hadoop.util ReflectionUtils logThreadInfo.

Prototype

public static void logThreadInfo(Logger log, String title, long minInterval) 

Source Link

Document

Log the current thread stacks at INFO level.

Usage

From source file:org.apache.tez.mapreduce.processor.TezTaskReporterImpl.java

License:Apache License

/** 
 * The communication thread handles communication with the parent (Task Tracker). 
 * It sends progress updates if progress has been made or if the task needs to 
 * let the parent know that it's alive. It also pings the parent to see if it's alive. 
 *//*from  www  . ja v a2 s .  co m*/
public void run() {
    final int MAX_RETRIES = 3;
    int remainingRetries = MAX_RETRIES;
    // get current flag value and reset it as well
    boolean sendProgress = resetProgressFlag();
    while (!this.mrTask.taskDone.get()) {
        synchronized (lock) {
            done = false;
        }
        try {
            boolean taskFound = true; // whether TT knows about this task
            // sleep for a bit
            synchronized (lock) {
                if (this.mrTask.taskDone.get()) {
                    break;
                }
                lock.wait(MRTask.PROGRESS_INTERVAL);
            }
            if (this.mrTask.taskDone.get()) {
                break;
            }

            if (sendProgress) {
                // we need to send progress update
                this.mrTask.updateCounters();
                this.mrTask.getStatus().statusUpdate(taskProgress.get(), taskProgress.toString(),
                        this.mrTask.counters);
                taskFound = umbilical.statusUpdate(this.mrTask.getTaskAttemptId(), this.mrTask.getStatus());
                this.mrTask.getStatus().clearStatus();
            } else {
                // send ping 
                taskFound = umbilical.ping(this.mrTask.getTaskAttemptId());
            }

            // if Task Tracker is not aware of our task ID (probably because it died and 
            // came back up), kill ourselves
            if (!taskFound) {
                MRTask.LOG.warn("Parent died.  Exiting " + this.mrTask.getTaskAttemptId());
                resetDoneFlag();
                System.exit(66);
            }

            sendProgress = resetProgressFlag();
            remainingRetries = MAX_RETRIES;
        } catch (Throwable t) {
            MRTask.LOG.info("Communication exception: " + StringUtils.stringifyException(t));
            remainingRetries -= 1;
            if (remainingRetries == 0) {
                ReflectionUtils.logThreadInfo(MRTask.LOG, "Communication exception", 0);
                MRTask.LOG.warn("Last retry, killing " + this.mrTask.getTaskAttemptId());
                resetDoneFlag();
                System.exit(65);
            }
        }
    }
    //Notify that we are done with the work
    resetDoneFlag();
}