hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r467492 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/mapred/StatusHttpServer.java
Date Tue, 24 Oct 2006 21:23:48 GMT
Author: cutting
Date: Tue Oct 24 14:23:48 2006
New Revision: 467492

URL: http://svn.apache.org/viewvc?view=rev&rev=467492
Log:
HADOOP-625.  Add a servlet to all http daemons that displays a stack dump, useful for debugging.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/StatusHttpServer.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=467492&r1=467491&r2=467492
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Tue Oct 24 14:23:48 2006
@@ -34,6 +34,9 @@
  9. HADOOP-610.  Fix TaskTracker to survive more exceptions, keeping
     tasks from becoming lost.  (omalley via cutting)
 
+10. HADOOP-625.  Add a servlet to all http daemons that displays a
+    stack dump, useful for debugging.  (omalley via cutting)
+
 
 Release 0.7.2 - 2006-10-18
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/StatusHttpServer.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/StatusHttpServer.java?view=diff&rev=467492&r1=467491&r2=467492
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/StatusHttpServer.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/StatusHttpServer.java Tue Oct 24
14:23:48 2006
@@ -15,14 +15,18 @@
  */
 package org.apache.hadoop.mapred;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
+import java.io.*;
 import java.net.URL;
 import java.net.URLDecoder;
 
+import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.util.*;
 import org.mortbay.http.HttpContext;
 import org.mortbay.http.handler.ResourceHandler;
 import org.mortbay.http.SocketListener;
@@ -44,6 +48,8 @@
   private SocketListener listener;
   private boolean findPort;
   private WebApplicationContext webAppContext;
+  private static final Log LOG =
+    LogFactory.getLog(StatusHttpServer.class.getName());
   
   /**
    * Create a status server on the given port.
@@ -80,7 +86,8 @@
 
     // set up the context for "/" jsp files
     webAppContext = 
-      webServer.addWebApplication("/", appDir + File.separator + name);      
+      webServer.addWebApplication("/", appDir + File.separator + name);
+    addServlet("stacks", "/stacks", StackServlet.class);
   }
 
   /**
@@ -207,4 +214,23 @@
   public void stop() throws InterruptedException {
     webServer.stop();
   }
+  
+  /**
+   * A very simple servlet to serve up a text representation of the current
+   * stack traces. It both returns the stacks to the caller and logs them.
+   * Currently the stack traces are done sequentially rather than exactly the
+   * same data.
+   * @author Owen O'Malley
+   */
+  public static class StackServlet extends HttpServlet {
+    public void doGet(HttpServletRequest request, 
+                      HttpServletResponse response
+                     ) throws ServletException, IOException {
+      OutputStream outStream = response.getOutputStream();
+      ReflectionUtils.printThreadInfo(new PrintWriter(outStream), "");
+      outStream.close();
+      ReflectionUtils.logThreadInfo(LOG, "jsp requested", 1);      
+    }
+  }
+
 }



Mime
View raw message