Java Code Examples for org.apache.hadoop.util.ReflectionUtils#logThreadInfo()

The following examples show how to use org.apache.hadoop.util.ReflectionUtils#logThreadInfo() . 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: TaskTracker.java    From RDFS with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
  LOG.info("Starting HeartbeatMonitor");
  boolean forceExit = false;
  long gap = 0;
  while (running && !shuttingDown) {
    long now = System.currentTimeMillis();
    gap = now - lastHeartbeat;
    if (gap > maxHeartbeatGap) {
      forceExit = true;
      break;
    }
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
    }
  }
  if (forceExit) {
    LOG.fatal("No heartbeat for " + gap + " msec, TaskTracker has to die");
    ReflectionUtils.logThreadInfo(LOG, "No heartbeat", 1);
    System.exit(-1);
  } else {
    LOG.info("Stopping HeartbeatMonitor, running=" + running +
      ", shuttingDown=" + shuttingDown);
  }
}
 
Example 2
Source File: HttpServer2.java    From knox with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
  if (!HttpServer2.isInstrumentationAccessAllowed(getServletContext(),
      request, response)) {
    return;
  }
  response.setContentType("text/plain; charset=UTF-8");
  try (PrintStream out = new PrintStream(
      response.getOutputStream(), false, "UTF-8")) {
    ReflectionUtils.printThreadInfo(out, "");
  }
  ReflectionUtils.logThreadInfo(LOG, "jsp requested", 1);
}
 
Example 3
Source File: HttpServer.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
  
  PrintWriter out = new PrintWriter(response.getOutputStream());
  ReflectionUtils.printThreadInfo(out, "");
  out.close();
  ReflectionUtils.logThreadInfo(LOG, "jsp requested", 1);      
}
 
Example 4
Source File: TaskTracker.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
/**
 * Kill any tasks that have not reported progress in the last X seconds.
 */
private synchronized void markUnresponsiveTasks() throws IOException {
  long now = System.currentTimeMillis();
  for (TaskInProgress tip: runningTasks.values()) {
    if (tip.getRunState() == TaskStatus.State.RUNNING ||
        tip.getRunState() == TaskStatus.State.COMMIT_PENDING ||
        tip.isCleaningup()) {
      // Check the per-job timeout interval for tasks;
      // an interval of '0' implies it is never timed-out
      long jobTaskTimeout = tip.getTaskTimeout();
      if (jobTaskTimeout == 0) {
        continue;
      }
        
      // Check if the task has not reported progress for a 
      // time-period greater than the configured time-out
      long timeSinceLastReport = now - tip.getLastProgressReport();
      if (timeSinceLastReport > jobTaskTimeout && !tip.wasKilled) {
        String msg = 
          "Task " + tip.getTask().getTaskID() + " failed to report status for " 
          + (timeSinceLastReport / 1000) + " seconds. Killing!";
        LOG.info(tip.getTask().getTaskID() + ": " + msg);
        ReflectionUtils.logThreadInfo(LOG, "lost task", 30);
        tip.reportDiagnosticInfo(msg);
        myInstrumentation.timedoutTask(tip.getTask().getTaskID());
        purgeTask(tip, true);
      }
    }
  }
}
 
Example 5
Source File: HttpServer.java    From RDFS with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
  
  PrintWriter out = new PrintWriter
                (HtmlQuoting.quoteOutputStream(response.getOutputStream()));
  ReflectionUtils.printThreadInfo(out, "");
  out.close();
  ReflectionUtils.logThreadInfo(LOG, "jsp requested", 1);      
}
 
Example 6
Source File: TaskTracker.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Kill any tasks that have not reported progress in the last X seconds.
 */
protected synchronized void markUnresponsiveTasks() throws IOException {
  long now = System.currentTimeMillis();
  for (TaskInProgress tip: runningTasks.values()) {
    if (tip.getRunState() == TaskStatus.State.RUNNING ||
        tip.getRunState() == TaskStatus.State.COMMIT_PENDING ||
        tip.isCleaningup()) {
      // Check the per-job timeout interval for tasks;
      // an interval of '0' implies it is never timed-out
      long jobTaskTimeout = tip.getTaskTimeout();
      if (jobTaskTimeout == 0) {
        continue;
      }

      // Check if the task has not reported progress for a
      // time-period greater than the configured time-out
      long timeSinceLastReport = now - tip.getLastProgressReport();
      if (timeSinceLastReport > jobTaskTimeout && !tip.wasKilled) {
        String msg =
          "Task " + tip.getTask().getTaskID() + " failed to report status for "
          + (timeSinceLastReport / 1000) + " seconds. Killing!";
        LOG.info(tip.getTask().getTaskID() + ": " + msg);
        ReflectionUtils.logThreadInfo(LOG, "lost task", 30);
        tip.reportDiagnosticInfo(msg);
        myInstrumentation.timedoutTask(tip.getTask().getTaskID());
        purgeTask(tip, true);
      }
    }
  }
}
 
Example 7
Source File: HttpServer2.java    From knox with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
  if (!HttpServer2.isInstrumentationAccessAllowed(getServletContext(),
      request, response)) {
    return;
  }
  response.setContentType("text/plain; charset=UTF-8");
  try (PrintStream out = new PrintStream(
      response.getOutputStream(), false, "UTF-8")) {
    ReflectionUtils.printThreadInfo(out, "");
  }
  ReflectionUtils.logThreadInfo(LOG, "jsp requested", 1);
}
 
Example 8
Source File: HttpServer2.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
  if (!HttpServer2.isInstrumentationAccessAllowed(getServletContext(),
      request, response)) {
    return;
  }
  response.setContentType("text/plain; charset=UTF-8");
  try (PrintStream out = new PrintStream(
      response.getOutputStream(), false, "UTF-8")) {
    ReflectionUtils.printThreadInfo(out, "");
  }
  ReflectionUtils.logThreadInfo(LOG, "jsp requested", 1);
}
 
Example 9
Source File: HttpServer2.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
  if (!HttpServer2.isInstrumentationAccessAllowed(getServletContext(),
      request, response)) {
    return;
  }
  response.setContentType("text/plain; charset=UTF-8");
  try (PrintStream out = new PrintStream(
      response.getOutputStream(), false, "UTF-8")) {
    ReflectionUtils.printThreadInfo(out, "");
  }
  ReflectionUtils.logThreadInfo(LOG, "jsp requested", 1);
}
 
Example 10
Source File: HttpServer2.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
  if (!HttpServer2.isInstrumentationAccessAllowed(getServletContext(),
                                                  request, response)) {
    return;
  }
  response.setContentType("text/plain; charset=UTF-8");
  try (PrintStream out = new PrintStream(
      response.getOutputStream(), false, "UTF-8")) {
    ReflectionUtils.printThreadInfo(out, "");
  }
  ReflectionUtils.logThreadInfo(LOG, "jsp requested", 1);
}
 
Example 11
Source File: HttpServer.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
  if (!HttpServer.isInstrumentationAccessAllowed(getServletContext(),
                                                 request, response)) {
    return;
  }
  response.setContentType("text/plain; charset=UTF-8");
  try (PrintStream out = new PrintStream(
      response.getOutputStream(), false, "UTF-8")) {
    ReflectionUtils.printThreadInfo(out, "");
  }
  ReflectionUtils.logThreadInfo(LOG, "jsp requested", 1);      
}
 
Example 12
Source File: HttpServer2.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
  if (!HttpServer2.isInstrumentationAccessAllowed(getServletContext(),
                                                  request, response)) {
    return;
  }
  response.setContentType("text/plain; charset=UTF-8");
  try (PrintStream out = new PrintStream(
      response.getOutputStream(), false, "UTF-8")) {
    ReflectionUtils.printThreadInfo(out, "");
  }
  ReflectionUtils.logThreadInfo(LOG, "jsp requested", 1);
}
 
Example 13
Source File: HttpServer.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
  if (!HttpServer.isInstrumentationAccessAllowed(getServletContext(),
                                                 request, response)) {
    return;
  }
  response.setContentType("text/plain; charset=UTF-8");
  try (PrintStream out = new PrintStream(
      response.getOutputStream(), false, "UTF-8")) {
    ReflectionUtils.printThreadInfo(out, "");
  }
  ReflectionUtils.logThreadInfo(LOG, "jsp requested", 1);      
}
 
Example 14
Source File: ExecutionBlockContext.java    From tajo with Apache License 2.0 4 votes vote down vote up
Runnable createReporterThread() {

      return new Runnable() {
        int remainingRetries = MAX_RETRIES;
        @Override
        public void run() {
          while (!isStopped() && !Thread.interrupted()) {

            try {
              Interface masterStub = getStub();

              if(tasks.size() == 0){
                masterStub.ping(null, getExecutionBlockId().getProto(), NullCallback.get());
              } else {
                for (Task task : new ArrayList<>(tasks.values())){

                  if (task.getTaskContext().getState() ==
                      TajoProtos.TaskAttemptState.TA_RUNNING && task.isProgressChanged()) {
                    masterStub.statusUpdate(null, task.getReport(), NullCallback.get());
                  }
                  task.updateProgress();
                }
              }
            } catch (Throwable t) {
              LOG.error(t.getMessage(), t);
              remainingRetries -=1;
              if (remainingRetries == 0) {
                ReflectionUtils.logThreadInfo(LOG, "Communication exception", 0);
                LOG.warn("Last retry, exiting ");
                throw new RuntimeException(t);
              }
            } finally {
              if (remainingRetries > 0 && !isStopped()) {
                synchronized (reporterThread) {
                  try {
                    reporterThread.wait(PROGRESS_INTERVAL);
                  } catch (InterruptedException e) {
                  }
                }
              }
            }
          }
        }
      };
    }
 
Example 15
Source File: Task.java    From RDFS with Apache License 2.0 4 votes vote down vote up
/** 
 * 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. 
 */
public void run() {
  final int MAX_RETRIES = 10;
  int remainingRetries = MAX_RETRIES;
  // get current flag value and reset it as well
  boolean sendProgress = resetProgressFlag();
  while (!taskDone.get()) {
    try {
      boolean taskFound = true; // whether TT knows about this task
      // sleep for a bit
      try {
        Thread.sleep(PROGRESS_INTERVAL);
      } 
      catch (InterruptedException e) {
        if (taskDone.get()) {
          LOG.debug(getTaskID() + " Progress/ping thread exiting " +
                    "since it got interrupted");
          break;
        } else {
          LOG.warn ("Unexpected InterruptedException");
        }
      }

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

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

      sendProgress = resetProgressFlag(); 
      remainingRetries = MAX_RETRIES;
    } 
    catch (Throwable t) {
      LOG.info("Communication exception: " + StringUtils.stringifyException(t));
      remainingRetries -=1;
      if (remainingRetries == 0) {
        ReflectionUtils.logThreadInfo(LOG, "Communication exception", 0);
        LOG.warn("Last retry, killing "+taskId);
        System.exit(65);
      }
    }
  }
}
 
Example 16
Source File: Task.java    From big-c with Apache License 2.0 4 votes vote down vote up
/** 
 * 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. 
 */
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 (!taskDone.get()) {
    synchronized (lock) {
      done = false;
    }
    try {
      boolean taskFound = true; // whether TT knows about this task
      // sleep for a bit
      synchronized(lock) {
        if (taskDone.get()) {
          break;
        }
        lock.wait(PROGRESS_INTERVAL);
      }
      if (taskDone.get()) {
        break;
      }

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

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

      sendProgress = resetProgressFlag(); 
      remainingRetries = MAX_RETRIES;
    } 
    catch (Throwable t) {
      LOG.info("Communication exception: " + StringUtils.stringifyException(t));
      remainingRetries -=1;
      if (remainingRetries == 0) {
        ReflectionUtils.logThreadInfo(LOG, "Communication exception", 0);
        LOG.warn("Last retry, killing "+taskId);
        resetDoneFlag();
        System.exit(65);
      }
    }
  }
  //Notify that we are done with the work
  resetDoneFlag();
}
 
Example 17
Source File: Task.java    From hadoop-gpu with Apache License 2.0 4 votes vote down vote up
/** 
 * 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. 
 */
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 (!taskDone.get()) {
    try {
      boolean taskFound = true; // whether TT knows about this task
      // sleep for a bit
      try {
        Thread.sleep(PROGRESS_INTERVAL);
      } 
      catch (InterruptedException e) {
        LOG.debug(getTaskID() + " Progress/ping thread exiting " +
        "since it got interrupted");
        break;
      }

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

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

      sendProgress = resetProgressFlag(); 
      remainingRetries = MAX_RETRIES;
    } 
    catch (Throwable t) {
      LOG.info("Communication exception: " + StringUtils.stringifyException(t));
      remainingRetries -=1;
      if (remainingRetries == 0) {
        ReflectionUtils.logThreadInfo(LOG, "Communication exception", 0);
        LOG.warn("Last retry, killing "+taskId);
        System.exit(65);
      }
    }
  }
}
 
Example 18
Source File: Task.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/** 
 * 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. 
 */
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 (!taskDone.get()) {
    synchronized (lock) {
      done = false;
    }
    try {
      boolean taskFound = true; // whether TT knows about this task
      // sleep for a bit
      synchronized(lock) {
        if (taskDone.get()) {
          break;
        }
        lock.wait(PROGRESS_INTERVAL);
      }
      if (taskDone.get()) {
        break;
      }

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

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

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