Return-Path: Delivered-To: apmail-hadoop-hbase-commits-archive@locus.apache.org Received: (qmail 471 invoked from network); 31 Oct 2008 01:39:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 31 Oct 2008 01:39:49 -0000 Received: (qmail 31810 invoked by uid 500); 31 Oct 2008 01:39:54 -0000 Delivered-To: apmail-hadoop-hbase-commits-archive@hadoop.apache.org Received: (qmail 31790 invoked by uid 500); 31 Oct 2008 01:39:54 -0000 Mailing-List: contact hbase-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hbase-dev@hadoop.apache.org Delivered-To: mailing list hbase-commits@hadoop.apache.org Received: (qmail 31781 invoked by uid 99); 31 Oct 2008 01:39:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Oct 2008 18:39:54 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 Oct 2008 01:38:40 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 16335238889E; Thu, 30 Oct 2008 18:38:51 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r709322 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/util/InfoServer.java src/webapps/master/master.jsp Date: Fri, 31 Oct 2008 01:38:50 -0000 To: hbase-commits@hadoop.apache.org From: jdcryans@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081031013851.16335238889E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jdcryans Date: Thu Oct 30 18:38:50 2008 New Revision: 709322 URL: http://svn.apache.org/viewvc?rev=709322&view=rev Log: HBASE-785 Remove InfoServer, use HADOOP-3824 StatusHttpServer instead (requires hadoop 0.19) Modified: hadoop/hbase/trunk/CHANGES.txt hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/InfoServer.java hadoop/hbase/trunk/src/webapps/master/master.jsp Modified: hadoop/hbase/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=709322&r1=709321&r2=709322&view=diff ============================================================================== --- hadoop/hbase/trunk/CHANGES.txt (original) +++ hadoop/hbase/trunk/CHANGES.txt Thu Oct 30 18:38:50 2008 @@ -87,6 +87,8 @@ HBASE-949 Add an HBase Manual HBASE-839 Update hadoop libs in hbase; move hbase TRUNK on to an hadoop 0.19.0 RC + HBASE-785 Remove InfoServer, use HADOOP-3824 StatusHttpServer + instead (requires hadoop 0.19) NEW FEATURES HBASE-875 Use MurmurHash instead of JenkinsHash [in bloomfilters] Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/InfoServer.java URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/InfoServer.java?rev=709322&r1=709321&r2=709322&view=diff ============================================================================== --- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/InfoServer.java (original) +++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/InfoServer.java Thu Oct 30 18:38:50 2008 @@ -22,15 +22,9 @@ import java.io.IOException; import java.net.URL; -import javax.servlet.http.HttpServlet; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.mapred.StatusHttpServer; +import org.apache.hadoop.http.HttpServer; import org.mortbay.http.HttpContext; -import org.mortbay.http.SocketListener; import org.mortbay.http.handler.ResourceHandler; -import org.mortbay.jetty.servlet.WebApplicationContext; /** * Create a Jetty embedded server to answer http requests. The primary goal @@ -40,18 +34,7 @@ * "/static/" -> points to common static files (src/webapps/static) * "/" -> the jsp server code from (src/webapps/) */ -public class InfoServer { - // Bulk of this class is copied from - // {@link org.apache.hadoop.mapred.StatusHttpServer}. StatusHttpServer - // is not amenable to subclassing. It keeps webAppContext inaccessible - // and will find webapps only in the jar the class StatusHttpServer was - // loaded from. - private static final Log LOG = LogFactory.getLog(InfoServer.class.getName()); - private org.mortbay.jetty.Server webServer; - private SocketListener listener; - private boolean findPort; - private WebApplicationContext webAppContext; - +public class InfoServer extends HttpServer{ /** * Create a status server on the given port. * The jsp scripts are taken from src/webapps/name. @@ -62,17 +45,9 @@ */ public InfoServer(String name, String bindAddress, int port, boolean findPort) throws IOException { - this.webServer = new org.mortbay.jetty.Server(); - this.findPort = findPort; - this.listener = new SocketListener(); - this.listener.setPort(port); - this.listener.setHost(bindAddress); - this.webServer.addListener(listener); - - // Set up the context for "/static/*" - String appDir = getWebAppsPath(); + super(name, bindAddress, port, findPort); - // Set up the context for "/logs/" if "hadoop.log.dir" property is defined. + // Set up the context for "/logs/" if "hbase.log.dir" property is defined. String logDir = System.getProperty("hbase.log.dir"); if (logDir != null) { HttpContext logContext = new HttpContext(); @@ -81,159 +56,39 @@ logContext.addHandler(new ResourceHandler()); webServer.addContext(logContext); } - - HttpContext staticContext = new HttpContext(); - staticContext.setContextPath("/static/*"); - staticContext.setResourceBase(appDir + "/static"); - staticContext.addHandler(new ResourceHandler()); - this.webServer.addContext(staticContext); - - // set up the context for "/" jsp files - String webappDir = getWebAppDir(name); - this.webAppContext = - this.webServer.addWebApplication("/", webappDir); if (name.equals("master")) { // Put up the rest webapp. this.webServer.addWebApplication("/api", getWebAppDir("rest")); } - addServlet("stacks", "/stacks", StatusHttpServer.StackServlet.class); - addServlet("logLevel", "/logLevel", org.apache.hadoop.log.LogLevel.Servlet.class); - } - - public static String getWebAppDir(final String webappName) throws IOException { - String webappDir = null; - try { - webappDir = getWebAppsPath("webapps" + File.separator + webappName); - } catch (FileNotFoundException e) { - // Retry. Resource may be inside jar on a windows machine. - webappDir = getWebAppsPath("webapps/" + webappName); - } - return webappDir; - } - - /** - * Set a value in the webapp context. These values are available to the jsp - * pages as "application.getAttribute(name)". - * @param name The name of the attribute - * @param value The value of the attribute - */ - public void setAttribute(String name, Object value) { - this.webAppContext.setAttribute(name, value); - } - - /** - * Add a servlet in the server. - * @param name The name of the servlet (can be passed as null) - * @param pathSpec The path spec for the servlet - * @param servletClass The servlet class - */ - public void addServlet(String name, String pathSpec, - Class servletClass) { - WebApplicationContext context = webAppContext; - try { - if (name == null) { - context.addServlet(pathSpec, servletClass.getName()); - } else { - context.addServlet(name, pathSpec, servletClass.getName()); - } - } catch (ClassNotFoundException ex) { - throw makeRuntimeException("Problem instantiating class", ex); - } catch (InstantiationException ex) { - throw makeRuntimeException("Problem instantiating class", ex); - } catch (IllegalAccessException ex) { - throw makeRuntimeException("Problem instantiating class", ex); - } - } - - private static RuntimeException makeRuntimeException(String msg, Throwable cause) { - RuntimeException result = new RuntimeException(msg); - if (cause != null) { - result.initCause(cause); - } - return result; - } - - /** - * Get the value in the webapp context. - * @param name The name of the attribute - * @return The value of the attribute - */ - public Object getAttribute(String name) { - return this.webAppContext.getAttribute(name); - } - - /** - * Get the pathname to the webapps files. - * @return the pathname as a URL - */ - private static String getWebAppsPath() throws IOException { - return getWebAppsPath("webapps"); } /** - * Get the pathname to the patch files. - * @param path Path to find. - * @return the pathname as a URL - */ + * Get the pathname to the path files. + * @param path Path to find. + * @return the pathname as a URL + */ private static String getWebAppsPath(final String path) throws IOException { URL url = InfoServer.class.getClassLoader().getResource(path); if (url == null) throw new IOException("webapps not found in CLASSPATH: " + path); return url.toString(); } - - /** - * Get the port that the server is on - * @return the port - */ - public int getPort() { - return this.listener.getPort(); - } - public void setThreads(int min, int max) { - this.listener.setMinThreads(min); - this.listener.setMaxThreads(max); - } - /** - * Start the server. Does not wait for the server to start. + * Get the path for this web app + * @param webappName web app + * @return path + * @throws IOException */ - public void start() throws IOException { + public static String getWebAppDir(final String webappName) throws IOException { + String webappDir = null; try { - while (true) { - try { - this.webServer.start(); - break; - } catch (org.mortbay.util.MultiException ex) { - // look for the multi exception containing a bind exception, - // in that case try the next port number. - boolean needNewPort = false; - for(int i=0; i < ex.size(); ++i) { - Exception sub = ex.getException(i); - if (sub instanceof java.net.BindException) { - needNewPort = true; - break; - } - } - if (!findPort || !needNewPort) { - throw ex; - } - this.listener.setPort(listener.getPort() + 1); - } - } - } catch (IOException ie) { - throw ie; - } catch (Exception e) { - IOException ie = new IOException("Problem starting http server"); - ie.initCause(e); - throw ie; + webappDir = getWebAppsPath("webapps" + File.separator + webappName); + } catch (FileNotFoundException e) { + // Retry. Resource may be inside jar on a windows machine. + webappDir = getWebAppsPath("webapps/" + webappName); } + return webappDir; } - /** - * stop the server - */ - public void stop() throws InterruptedException { - this.webServer.stop(); - } } Modified: hadoop/hbase/trunk/src/webapps/master/master.jsp URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/webapps/master/master.jsp?rev=709322&r1=709321&r2=709322&view=diff ============================================================================== --- hadoop/hbase/trunk/src/webapps/master/master.jsp (original) +++ hadoop/hbase/trunk/src/webapps/master/master.jsp Thu Oct 30 18:38:50 2008 @@ -44,7 +44,6 @@ HBase Compiled<%= org.apache.hadoop.hbase.util.VersionInfo.getDate() %>, <%= org.apache.hadoop.hbase.util.VersionInfo.getUser() %>When HBase version was compiled and by whom Hadoop Version<%= org.apache.hadoop.util.VersionInfo.getVersion() %>, r<%= org.apache.hadoop.util.VersionInfo.getRevision() %>Hadoop version and svn revision Hadoop Compiled<%= org.apache.hadoop.util.VersionInfo.getDate() %>, <%= org.apache.hadoop.util.VersionInfo.getUser() %>When Hadoop version was compiled and by whom -Filesystem<%= conf.get("fs.default.name") %>Filesystem HBase is running on HBase Root Directory<%= master.getRootDir().toString() %>Location of HBase home directory Load average<%= master.getAverageLoad() %>Average load across all region servers. Naive computation.