incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r1151771 [3/3] - in /incubator/hama/trunk: ./ bin/ conf/ src/docs/ src/docs/src/documentation/ src/docs/src/documentation/classes/ src/docs/src/documentation/content/xdocs/ src/docs/src/documentation/content/xdocs/docs/r0.2.0/ src/docs/src/...
Date Thu, 28 Jul 2011 09:28:10 GMT
Modified: incubator/hama/trunk/src/java/org/apache/hama/http/HttpServer.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/http/HttpServer.java?rev=1151771&r1=1151770&r2=1151771&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/http/HttpServer.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/http/HttpServer.java Thu Jul 28 09:28:02 2011
@@ -1,501 +1,501 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hama.http;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.net.BindException;
-import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-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.conf.Configuration;
-import org.apache.hadoop.log.LogLevel;
-import org.apache.hadoop.util.ReflectionUtils;
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.ContextHandlerCollection;
-import org.mortbay.jetty.nio.SelectChannelConnector;
-import org.mortbay.jetty.security.SslSocketConnector;
-import org.mortbay.jetty.servlet.Context;
-import org.mortbay.jetty.servlet.DefaultServlet;
-import org.mortbay.jetty.servlet.FilterHolder;
-import org.mortbay.jetty.servlet.FilterMapping;
-import org.mortbay.jetty.servlet.ServletHandler;
-import org.mortbay.jetty.servlet.ServletHolder;
-import org.mortbay.jetty.webapp.WebAppContext;
-import org.mortbay.thread.BoundedThreadPool;
-import org.mortbay.util.MultiException;
-
-/**
- * Create a Jetty embedded server to answer http requests. The primary goal is
- * to serve up status information for the server. There are three contexts:
- * "/logs/" -> points to the log directory "/static/" -> points to common static
- * files (src/webapps/static) "/" -> the jsp server code from
- * (src/webapps/<name>)
- */
-public class HttpServer {
-  public static final Log LOG = LogFactory.getLog(HttpServer.class);
-
-  static final String FILTER_INITIALIZER_PROPERTY = "hama.http.filter.initializers";
-
-  protected final Server webServer;
-  protected final Connector listener;
-  protected final WebAppContext webAppContext;
-  protected final boolean findPort;
-  protected final Map<Context, Boolean> defaultContexts = new HashMap<Context, Boolean>();
-  protected final List<String> filterNames = new ArrayList<String>();
-  private static final int MAX_RETRIES = 10;
-
-  /** Same as this(name, bindAddress, port, findPort, null); */
-  public HttpServer(String name, String bindAddress, int port, boolean findPort)
-      throws IOException {
-    this(name, bindAddress, port, findPort, new Configuration());
-  }
-
-  /**
-   * Create a status server on the given port. The jsp scripts are taken from
-   * src/webapps/<name>.
-   * 
-   * @param name The name of the server
-   * @param port The port to use on the server
-   * @param findPort whether the server should start at the given port and
-   *          increment by 1 until it finds a free port.
-   * @param conf Configuration
-   */
-  public HttpServer(String name, String bindAddress, int port,
-      boolean findPort, Configuration conf) throws IOException {
-    webServer = new Server();
-    this.findPort = findPort;
-
-    listener = createBaseListener(conf);
-    listener.setHost(bindAddress);
-    listener.setPort(port);
-    webServer.addConnector(listener);
-
-    webServer.setThreadPool(new BoundedThreadPool());
-
-    final String appDir = getWebAppsPath();
-    ContextHandlerCollection contexts = new ContextHandlerCollection();
-    webServer.setHandler(contexts);
-    webAppContext = new WebAppContext();
-
-    System.setProperty("java.naming.factory.initial",
-        "org.mortbay.naming.InitialContextFactory");
-    System.setProperty("java.naming.factory.url.pkgs", "org.mortbay.naming");
-
-    webAppContext.setContextPath("/");
-    webAppContext.setWar(appDir + "/" + name);
-    webServer.addHandler(webAppContext);
-
-    addDefaultApps(contexts, appDir);
-
-    addDefaultServlets();
-  }
-
-  /**
-   * Create a required listener for the Jetty instance listening on the port
-   * provided. This wrapper and all subclasses must create at least one
-   * listener.
-   */
-  protected Connector createBaseListener(Configuration conf) throws IOException {
-    SelectChannelConnector ret = new SelectChannelConnector();
-    ret.setLowResourceMaxIdleTime(10000);
-    ret.setAcceptQueueSize(128);
-    ret.setResolveNames(false);
-    ret.setUseDirectBuffers(false);
-    return ret;
-  }
-
-  /**
-   * Add default apps.
-   * 
-   * @param appDir The application directory
-   * @throws IOException
-   */
-  protected void addDefaultApps(ContextHandlerCollection parent,
-      final String appDir) throws IOException {
-    // set up the context for "/logs/" if "hama.log.dir" property is defined.
-    String logDir = System.getProperty("hama.log.dir");
-    if (logDir != null) {
-      Context logContext = new Context(parent, "/logs");
-      logContext.setResourceBase(logDir);
-      logContext.addServlet(DefaultServlet.class, "/");
-      defaultContexts.put(logContext, true);
-    }
-    // set up the context for "/static/*"
-    Context staticContext = new Context(parent, "/static");
-    staticContext.setResourceBase(appDir + "/static");
-    staticContext.addServlet(DefaultServlet.class, "/*");
-    defaultContexts.put(staticContext, true);
-  }
-
-  /**
-   * Add default servlets.
-   */
-  protected void addDefaultServlets() {
-    // set up default servlets
-    addServlet("stacks", "/stacks", StackServlet.class);
-    addServlet("logLevel", "/logLevel", LogLevel.Servlet.class);
-  }
-
-  public void addContext(Context ctxt, boolean isFiltered) throws IOException {
-    webServer.addHandler(ctxt);
-    defaultContexts.put(ctxt, isFiltered);
-  }
-
-  /**
-   * Add a context
-   * 
-   * @param pathSpec The path spec for the context
-   * @param dir The directory containing the context
-   * @param isFiltered if true, the servlet is added to the filter path mapping
-   * @throws IOException
-   */
-  protected void addContext(String pathSpec, String dir, boolean isFiltered)
-      throws IOException {
-    if (0 == webServer.getHandlers().length) {
-      throw new RuntimeException("Couldn't find handler");
-    }
-    WebAppContext webAppCtx = new WebAppContext();
-    webAppCtx.setContextPath(pathSpec);
-    webAppCtx.setWar(dir);
-    addContext(webAppCtx, true);
-  }
-
-  /**
-   * 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) {
-    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 clazz The servlet class
-   */
-  public void addServlet(String name, String pathSpec,
-      Class<? extends HttpServlet> clazz) {
-    addInternalServlet(name, pathSpec, clazz);
-    addFilterPathMapping(pathSpec, webAppContext);
-  }
-
-  /**
-   * Add an internal 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 clazz The servlet class
-   * @deprecated this is a temporary method
-   */
-  @Deprecated
-  public void addInternalServlet(String name, String pathSpec,
-      Class<? extends HttpServlet> clazz) {
-    ServletHolder holder = new ServletHolder(clazz);
-    if (name != null) {
-      holder.setName(name);
-    }
-    webAppContext.addServlet(holder, pathSpec);
-  }
-
-  /**
-   * Define a filter for a context and set up default url mappings.
-   */
-  protected void defineFilter(Context ctx, String name, String classname,
-      Map<String, String> parameters, String[] urls) {
-
-    FilterHolder holder = new FilterHolder();
-    holder.setName(name);
-    holder.setClassName(classname);
-    holder.setInitParameters(parameters);
-    FilterMapping fmap = new FilterMapping();
-    fmap.setPathSpecs(urls);
-    fmap.setDispatches(Handler.ALL);
-    fmap.setFilterName(name);
-    ServletHandler handler = ctx.getServletHandler();
-    handler.addFilter(holder, fmap);
-  }
-
-  /**
-   * Add the path spec to the filter path mapping.
-   * 
-   * @param pathSpec The path spec
-   * @param webAppCtx The WebApplicationContext to add to
-   */
-  protected void addFilterPathMapping(String pathSpec, Context webAppCtx) {
-    ServletHandler handler = webAppCtx.getServletHandler();
-    for (String name : filterNames) {
-      FilterMapping fmap = new FilterMapping();
-      fmap.setPathSpec(pathSpec);
-      fmap.setFilterName(name);
-      fmap.setDispatches(Handler.ALL);
-      handler.addFilterMapping(fmap);
-    }
-  }
-
-  /**
-   * 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 webAppContext.getAttribute(name);
-  }
-
-  /**
-   * Get the pathname to the webapps files.
-   * 
-   * @return the pathname as a URL
-   * @throws IOException if 'webapps' directory cannot be found on CLASSPATH.
-   */
-  protected String getWebAppsPath() throws IOException {
-    // URL url = BSPMaster.class.getClassLoader().getResource("webapps");
-    // if (url == null)
-    // throw new IOException("webapps not found in CLASSPATH");
-    // return url.toString();
-    return "src/webapps";
-  }
-
-  /**
-   * Get the port that the server is on
-   * 
-   * @return the port
-   */
-  public int getPort() {
-    return webServer.getConnectors()[0].getLocalPort();
-  }
-
-  /**
-   * Set the min, max number of worker threads (simultaneous connections).
-   */
-  public void setThreads(int min, int max) {
-    BoundedThreadPool pool = (BoundedThreadPool) webServer.getThreadPool();
-    pool.setMinThreads(min);
-    pool.setMaxThreads(max);
-  }
-
-  /**
-   * Configure an ssl listener on the server.
-   * 
-   * @param addr address to listen on
-   * @param keystore location of the keystore
-   * @param storPass password for the keystore
-   * @param keyPass password for the key
-   * @deprecated Use
-   *             {@link #addSslListener(InetSocketAddress, Configuration, boolean)}
-   */
-  @Deprecated
-  public void addSslListener(InetSocketAddress addr, String keystore,
-      String storPass, String keyPass) throws IOException {
-    if (webServer.isStarted()) {
-      throw new IOException("Failed to add ssl listener");
-    }
-    SslSocketConnector sslListener = new SslSocketConnector();
-    sslListener.setHost(addr.getHostName());
-    sslListener.setPort(addr.getPort());
-    sslListener.setKeystore(keystore);
-    sslListener.setPassword(storPass);
-    sslListener.setKeyPassword(keyPass);
-    webServer.addConnector(sslListener);
-  }
-
-  /**
-   * Configure an ssl listener on the server.
-   * 
-   * @param addr address to listen on
-   * @param sslConf conf to retrieve ssl options
-   * @param needClientAuth whether client authentication is required
-   */
-  public void addSslListener(InetSocketAddress addr, Configuration sslConf,
-      boolean needClientAuth) throws IOException {
-    if (webServer.isStarted()) {
-      throw new IOException("Failed to add ssl listener");
-    }
-    if (needClientAuth) {
-      // setting up SSL truststore for authenticating clients
-      System.setProperty("javax.net.ssl.trustStore", sslConf.get(
-          "ssl.server.truststore.location", ""));
-      System.setProperty("javax.net.ssl.trustStorePassword", sslConf.get(
-          "ssl.server.truststore.password", ""));
-      System.setProperty("javax.net.ssl.trustStoreType", sslConf.get(
-          "ssl.server.truststore.type", "jks"));
-    }
-    SslSocketConnector sslListener = new SslSocketConnector();
-    sslListener.setHost(addr.getHostName());
-    sslListener.setPort(addr.getPort());
-    sslListener.setKeystore(sslConf.get("ssl.server.keystore.location"));
-    sslListener.setPassword(sslConf.get("ssl.server.keystore.password", ""));
-    sslListener.setKeyPassword(sslConf.get("ssl.server.keystore.keypassword",
-        ""));
-    sslListener.setKeystoreType(sslConf.get("ssl.server.keystore.type", "jks"));
-    sslListener.setNeedClientAuth(needClientAuth);
-    webServer.addConnector(sslListener);
-  }
-
-  /**
-   * Start the server. Does not wait for the server to start.
-   */
-  public void start() throws IOException {
-    try {
-      int port = 0;
-      int oriPort = listener.getPort(); // The original requested port
-      while (true) {
-        try {
-          port = webServer.getConnectors()[0].getLocalPort();
-          LOG.info("Port returned by webServer.getConnectors()[0]."
-              + "getLocalPort() before open() is " + port
-              + ". Opening the listener on " + oriPort);
-          listener.open();
-          port = listener.getLocalPort();
-          LOG.info("listener.getLocalPort() returned "
-              + listener.getLocalPort()
-              + " webServer.getConnectors()[0].getLocalPort() returned "
-              + webServer.getConnectors()[0].getLocalPort());
-          // Workaround to handle the problem reported in HADOOP-4744
-          if (port < 0) {
-            Thread.sleep(100);
-            int numRetries = 1;
-            while (port < 0) {
-              LOG.warn("listener.getLocalPort returned " + port);
-              if (numRetries++ > MAX_RETRIES) {
-                throw new Exception(" listener.getLocalPort is returning "
-                    + "less than 0 even after " + numRetries + " resets");
-              }
-              for (int i = 0; i < 2; i++) {
-                LOG.info("Retrying listener.getLocalPort()");
-                port = listener.getLocalPort();
-                if (port > 0) {
-                  break;
-                }
-                Thread.sleep(200);
-              }
-              if (port > 0) {
-                break;
-              }
-              LOG.info("Bouncing the listener");
-              listener.close();
-              Thread.sleep(1000);
-              listener.setPort(oriPort == 0 ? 0 : (oriPort += 1));
-              listener.open();
-              Thread.sleep(100);
-              port = listener.getLocalPort();
-            }
-          } // Workaround end
-          LOG.info("Jetty bound to port " + port);
-          webServer.start();
-          // Workaround for HADOOP-6386
-          port = listener.getLocalPort();
-          if (port < 0) {
-            LOG.warn("Bounds port is " + port + " after webserver start");
-            for (int i = 0; i < MAX_RETRIES / 2; i++) {
-              try {
-                webServer.stop();
-              } catch (Exception e) {
-                LOG.warn("Can't stop  web-server", e);
-              }
-              Thread.sleep(1000);
-
-              listener.setPort(oriPort == 0 ? 0 : (oriPort += 1));
-              listener.open();
-              Thread.sleep(100);
-              webServer.start();
-              LOG.info(i + "attempts to restart webserver");
-              port = listener.getLocalPort();
-              if (port > 0)
-                break;
-            }
-            if (port < 0)
-              throw new Exception("listener.getLocalPort() is returning "
-                  + "less than 0 even after " + MAX_RETRIES + " resets");
-          }
-          // End of HADOOP-6386 workaround
-          break;
-        } catch (IOException ex) {
-          // if this is a bind exception,
-          // then try the next port number.
-          if (ex instanceof BindException) {
-            if (!findPort) {
-              throw (BindException) ex;
-            }
-          } else {
-            LOG.info("HttpServer.start() threw a non Bind IOException");
-            throw ex;
-          }
-        } catch (MultiException ex) {
-          LOG.info("HttpServer.start() threw a MultiException");
-          throw ex;
-        }
-        listener.setPort((oriPort += 1));
-      }
-    } catch (IOException e) {
-      throw e;
-    } catch (Exception e) {
-      throw new IOException("Problem starting http server", e);
-    }
-  }
-
-  /**
-   * stop the server
-   */
-  public void stop() throws Exception {
-    listener.close();
-    webServer.stop();
-  }
-
-  public void join() throws InterruptedException {
-    webServer.join();
-  }
-
-  /**
-   * 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.
-   */
-  public static class StackServlet extends HttpServlet {
-    private static final long serialVersionUID = -6284183679759467039L;
-
-    @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);
-    }
-  }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hama.http;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.BindException;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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.conf.Configuration;
+import org.apache.hadoop.log.LogLevel;
+import org.apache.hadoop.util.ReflectionUtils;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.ContextHandlerCollection;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.security.SslSocketConnector;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.DefaultServlet;
+import org.mortbay.jetty.servlet.FilterHolder;
+import org.mortbay.jetty.servlet.FilterMapping;
+import org.mortbay.jetty.servlet.ServletHandler;
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.mortbay.jetty.webapp.WebAppContext;
+import org.mortbay.thread.BoundedThreadPool;
+import org.mortbay.util.MultiException;
+
+/**
+ * Create a Jetty embedded server to answer http requests. The primary goal is
+ * to serve up status information for the server. There are three contexts:
+ * "/logs/" -> points to the log directory "/static/" -> points to common static
+ * files (src/webapps/static) "/" -> the jsp server code from
+ * (src/webapps/<name>)
+ */
+public class HttpServer {
+  public static final Log LOG = LogFactory.getLog(HttpServer.class);
+
+  static final String FILTER_INITIALIZER_PROPERTY = "hama.http.filter.initializers";
+
+  protected final Server webServer;
+  protected final Connector listener;
+  protected final WebAppContext webAppContext;
+  protected final boolean findPort;
+  protected final Map<Context, Boolean> defaultContexts = new HashMap<Context, Boolean>();
+  protected final List<String> filterNames = new ArrayList<String>();
+  private static final int MAX_RETRIES = 10;
+
+  /** Same as this(name, bindAddress, port, findPort, null); */
+  public HttpServer(String name, String bindAddress, int port, boolean findPort)
+      throws IOException {
+    this(name, bindAddress, port, findPort, new Configuration());
+  }
+
+  /**
+   * Create a status server on the given port. The jsp scripts are taken from
+   * src/webapps/<name>.
+   * 
+   * @param name The name of the server
+   * @param port The port to use on the server
+   * @param findPort whether the server should start at the given port and
+   *          increment by 1 until it finds a free port.
+   * @param conf Configuration
+   */
+  public HttpServer(String name, String bindAddress, int port,
+      boolean findPort, Configuration conf) throws IOException {
+    webServer = new Server();
+    this.findPort = findPort;
+
+    listener = createBaseListener(conf);
+    listener.setHost(bindAddress);
+    listener.setPort(port);
+    webServer.addConnector(listener);
+
+    webServer.setThreadPool(new BoundedThreadPool());
+
+    final String appDir = getWebAppsPath();
+    ContextHandlerCollection contexts = new ContextHandlerCollection();
+    webServer.setHandler(contexts);
+    webAppContext = new WebAppContext();
+
+    System.setProperty("java.naming.factory.initial",
+        "org.mortbay.naming.InitialContextFactory");
+    System.setProperty("java.naming.factory.url.pkgs", "org.mortbay.naming");
+
+    webAppContext.setContextPath("/");
+    webAppContext.setWar(appDir + "/" + name);
+    webServer.addHandler(webAppContext);
+
+    addDefaultApps(contexts, appDir);
+
+    addDefaultServlets();
+  }
+
+  /**
+   * Create a required listener for the Jetty instance listening on the port
+   * provided. This wrapper and all subclasses must create at least one
+   * listener.
+   */
+  protected Connector createBaseListener(Configuration conf) throws IOException {
+    SelectChannelConnector ret = new SelectChannelConnector();
+    ret.setLowResourceMaxIdleTime(10000);
+    ret.setAcceptQueueSize(128);
+    ret.setResolveNames(false);
+    ret.setUseDirectBuffers(false);
+    return ret;
+  }
+
+  /**
+   * Add default apps.
+   * 
+   * @param appDir The application directory
+   * @throws IOException
+   */
+  protected void addDefaultApps(ContextHandlerCollection parent,
+      final String appDir) throws IOException {
+    // set up the context for "/logs/" if "hama.log.dir" property is defined.
+    String logDir = System.getProperty("hama.log.dir");
+    if (logDir != null) {
+      Context logContext = new Context(parent, "/logs");
+      logContext.setResourceBase(logDir);
+      logContext.addServlet(DefaultServlet.class, "/");
+      defaultContexts.put(logContext, true);
+    }
+    // set up the context for "/static/*"
+    Context staticContext = new Context(parent, "/static");
+    staticContext.setResourceBase(appDir + "/static");
+    staticContext.addServlet(DefaultServlet.class, "/*");
+    defaultContexts.put(staticContext, true);
+  }
+
+  /**
+   * Add default servlets.
+   */
+  protected void addDefaultServlets() {
+    // set up default servlets
+    addServlet("stacks", "/stacks", StackServlet.class);
+    addServlet("logLevel", "/logLevel", LogLevel.Servlet.class);
+  }
+
+  public void addContext(Context ctxt, boolean isFiltered) throws IOException {
+    webServer.addHandler(ctxt);
+    defaultContexts.put(ctxt, isFiltered);
+  }
+
+  /**
+   * Add a context
+   * 
+   * @param pathSpec The path spec for the context
+   * @param dir The directory containing the context
+   * @param isFiltered if true, the servlet is added to the filter path mapping
+   * @throws IOException
+   */
+  protected void addContext(String pathSpec, String dir, boolean isFiltered)
+      throws IOException {
+    if (0 == webServer.getHandlers().length) {
+      throw new RuntimeException("Couldn't find handler");
+    }
+    WebAppContext webAppCtx = new WebAppContext();
+    webAppCtx.setContextPath(pathSpec);
+    webAppCtx.setWar(dir);
+    addContext(webAppCtx, true);
+  }
+
+  /**
+   * 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) {
+    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 clazz The servlet class
+   */
+  public void addServlet(String name, String pathSpec,
+      Class<? extends HttpServlet> clazz) {
+    addInternalServlet(name, pathSpec, clazz);
+    addFilterPathMapping(pathSpec, webAppContext);
+  }
+
+  /**
+   * Add an internal 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 clazz The servlet class
+   * @deprecated this is a temporary method
+   */
+  @Deprecated
+  public void addInternalServlet(String name, String pathSpec,
+      Class<? extends HttpServlet> clazz) {
+    ServletHolder holder = new ServletHolder(clazz);
+    if (name != null) {
+      holder.setName(name);
+    }
+    webAppContext.addServlet(holder, pathSpec);
+  }
+
+  /**
+   * Define a filter for a context and set up default url mappings.
+   */
+  protected void defineFilter(Context ctx, String name, String classname,
+      Map<String, String> parameters, String[] urls) {
+
+    FilterHolder holder = new FilterHolder();
+    holder.setName(name);
+    holder.setClassName(classname);
+    holder.setInitParameters(parameters);
+    FilterMapping fmap = new FilterMapping();
+    fmap.setPathSpecs(urls);
+    fmap.setDispatches(Handler.ALL);
+    fmap.setFilterName(name);
+    ServletHandler handler = ctx.getServletHandler();
+    handler.addFilter(holder, fmap);
+  }
+
+  /**
+   * Add the path spec to the filter path mapping.
+   * 
+   * @param pathSpec The path spec
+   * @param webAppCtx The WebApplicationContext to add to
+   */
+  protected void addFilterPathMapping(String pathSpec, Context webAppCtx) {
+    ServletHandler handler = webAppCtx.getServletHandler();
+    for (String name : filterNames) {
+      FilterMapping fmap = new FilterMapping();
+      fmap.setPathSpec(pathSpec);
+      fmap.setFilterName(name);
+      fmap.setDispatches(Handler.ALL);
+      handler.addFilterMapping(fmap);
+    }
+  }
+
+  /**
+   * 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 webAppContext.getAttribute(name);
+  }
+
+  /**
+   * Get the pathname to the webapps files.
+   * 
+   * @return the pathname as a URL
+   * @throws IOException if 'webapps' directory cannot be found on CLASSPATH.
+   */
+  protected String getWebAppsPath() throws IOException {
+    // URL url = BSPMaster.class.getClassLoader().getResource("webapps");
+    // if (url == null)
+    // throw new IOException("webapps not found in CLASSPATH");
+    // return url.toString();
+    return "src/webapps";
+  }
+
+  /**
+   * Get the port that the server is on
+   * 
+   * @return the port
+   */
+  public int getPort() {
+    return webServer.getConnectors()[0].getLocalPort();
+  }
+
+  /**
+   * Set the min, max number of worker threads (simultaneous connections).
+   */
+  public void setThreads(int min, int max) {
+    BoundedThreadPool pool = (BoundedThreadPool) webServer.getThreadPool();
+    pool.setMinThreads(min);
+    pool.setMaxThreads(max);
+  }
+
+  /**
+   * Configure an ssl listener on the server.
+   * 
+   * @param addr address to listen on
+   * @param keystore location of the keystore
+   * @param storPass password for the keystore
+   * @param keyPass password for the key
+   * @deprecated Use
+   *             {@link #addSslListener(InetSocketAddress, Configuration, boolean)}
+   */
+  @Deprecated
+  public void addSslListener(InetSocketAddress addr, String keystore,
+      String storPass, String keyPass) throws IOException {
+    if (webServer.isStarted()) {
+      throw new IOException("Failed to add ssl listener");
+    }
+    SslSocketConnector sslListener = new SslSocketConnector();
+    sslListener.setHost(addr.getHostName());
+    sslListener.setPort(addr.getPort());
+    sslListener.setKeystore(keystore);
+    sslListener.setPassword(storPass);
+    sslListener.setKeyPassword(keyPass);
+    webServer.addConnector(sslListener);
+  }
+
+  /**
+   * Configure an ssl listener on the server.
+   * 
+   * @param addr address to listen on
+   * @param sslConf conf to retrieve ssl options
+   * @param needClientAuth whether client authentication is required
+   */
+  public void addSslListener(InetSocketAddress addr, Configuration sslConf,
+      boolean needClientAuth) throws IOException {
+    if (webServer.isStarted()) {
+      throw new IOException("Failed to add ssl listener");
+    }
+    if (needClientAuth) {
+      // setting up SSL truststore for authenticating clients
+      System.setProperty("javax.net.ssl.trustStore", sslConf.get(
+          "ssl.server.truststore.location", ""));
+      System.setProperty("javax.net.ssl.trustStorePassword", sslConf.get(
+          "ssl.server.truststore.password", ""));
+      System.setProperty("javax.net.ssl.trustStoreType", sslConf.get(
+          "ssl.server.truststore.type", "jks"));
+    }
+    SslSocketConnector sslListener = new SslSocketConnector();
+    sslListener.setHost(addr.getHostName());
+    sslListener.setPort(addr.getPort());
+    sslListener.setKeystore(sslConf.get("ssl.server.keystore.location"));
+    sslListener.setPassword(sslConf.get("ssl.server.keystore.password", ""));
+    sslListener.setKeyPassword(sslConf.get("ssl.server.keystore.keypassword",
+        ""));
+    sslListener.setKeystoreType(sslConf.get("ssl.server.keystore.type", "jks"));
+    sslListener.setNeedClientAuth(needClientAuth);
+    webServer.addConnector(sslListener);
+  }
+
+  /**
+   * Start the server. Does not wait for the server to start.
+   */
+  public void start() throws IOException {
+    try {
+      int port = 0;
+      int oriPort = listener.getPort(); // The original requested port
+      while (true) {
+        try {
+          port = webServer.getConnectors()[0].getLocalPort();
+          LOG.info("Port returned by webServer.getConnectors()[0]."
+              + "getLocalPort() before open() is " + port
+              + ". Opening the listener on " + oriPort);
+          listener.open();
+          port = listener.getLocalPort();
+          LOG.info("listener.getLocalPort() returned "
+              + listener.getLocalPort()
+              + " webServer.getConnectors()[0].getLocalPort() returned "
+              + webServer.getConnectors()[0].getLocalPort());
+          // Workaround to handle the problem reported in HADOOP-4744
+          if (port < 0) {
+            Thread.sleep(100);
+            int numRetries = 1;
+            while (port < 0) {
+              LOG.warn("listener.getLocalPort returned " + port);
+              if (numRetries++ > MAX_RETRIES) {
+                throw new Exception(" listener.getLocalPort is returning "
+                    + "less than 0 even after " + numRetries + " resets");
+              }
+              for (int i = 0; i < 2; i++) {
+                LOG.info("Retrying listener.getLocalPort()");
+                port = listener.getLocalPort();
+                if (port > 0) {
+                  break;
+                }
+                Thread.sleep(200);
+              }
+              if (port > 0) {
+                break;
+              }
+              LOG.info("Bouncing the listener");
+              listener.close();
+              Thread.sleep(1000);
+              listener.setPort(oriPort == 0 ? 0 : (oriPort += 1));
+              listener.open();
+              Thread.sleep(100);
+              port = listener.getLocalPort();
+            }
+          } // Workaround end
+          LOG.info("Jetty bound to port " + port);
+          webServer.start();
+          // Workaround for HADOOP-6386
+          port = listener.getLocalPort();
+          if (port < 0) {
+            LOG.warn("Bounds port is " + port + " after webserver start");
+            for (int i = 0; i < MAX_RETRIES / 2; i++) {
+              try {
+                webServer.stop();
+              } catch (Exception e) {
+                LOG.warn("Can't stop  web-server", e);
+              }
+              Thread.sleep(1000);
+
+              listener.setPort(oriPort == 0 ? 0 : (oriPort += 1));
+              listener.open();
+              Thread.sleep(100);
+              webServer.start();
+              LOG.info(i + "attempts to restart webserver");
+              port = listener.getLocalPort();
+              if (port > 0)
+                break;
+            }
+            if (port < 0)
+              throw new Exception("listener.getLocalPort() is returning "
+                  + "less than 0 even after " + MAX_RETRIES + " resets");
+          }
+          // End of HADOOP-6386 workaround
+          break;
+        } catch (IOException ex) {
+          // if this is a bind exception,
+          // then try the next port number.
+          if (ex instanceof BindException) {
+            if (!findPort) {
+              throw (BindException) ex;
+            }
+          } else {
+            LOG.info("HttpServer.start() threw a non Bind IOException");
+            throw ex;
+          }
+        } catch (MultiException ex) {
+          LOG.info("HttpServer.start() threw a MultiException");
+          throw ex;
+        }
+        listener.setPort((oriPort += 1));
+      }
+    } catch (IOException e) {
+      throw e;
+    } catch (Exception e) {
+      throw new IOException("Problem starting http server", e);
+    }
+  }
+
+  /**
+   * stop the server
+   */
+  public void stop() throws Exception {
+    listener.close();
+    webServer.stop();
+  }
+
+  public void join() throws InterruptedException {
+    webServer.join();
+  }
+
+  /**
+   * 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.
+   */
+  public static class StackServlet extends HttpServlet {
+    private static final long serialVersionUID = -6284183679759467039L;
+
+    @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);
+    }
+  }
+}

Propchange: incubator/hama/trunk/src/java/org/apache/hama/http/HttpServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/org/apache/hama/http/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/org/apache/hama/ipc/BSPPeerProtocol.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/org/apache/hama/ipc/GroomProtocol.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/org/apache/hama/ipc/HamaRPCProtocolVersion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/org/apache/hama/ipc/JobSubmissionProtocol.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/org/apache/hama/ipc/MasterProtocol.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/org/apache/hama/ipc/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/org/apache/hama/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/hama/trunk/src/java/org/apache/hama/util/BSPServletUtil.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/util/BSPServletUtil.java?rev=1151771&r1=1151770&r2=1151771&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/util/BSPServletUtil.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/util/BSPServletUtil.java Thu Jul 28 09:28:02 2011
@@ -1,82 +1,82 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hama.util;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.Calendar;
-
-import org.apache.hadoop.util.ServletUtil;
-import org.apache.hama.bsp.JobStatus;
-
-public class BSPServletUtil extends ServletUtil {
-
-  public static final String HTML_TAIL = "<hr />\n"
-      + "<a href='http://incubator.apache.org/hama/'>Hama</a>, "
-      + Calendar.getInstance().get(Calendar.YEAR) + ".\n" + "</body></html>";
-
-  /**
-   * HTML footer to be added in the jsps.
-   * 
-   * @return the HTML footer.
-   */
-  public static String htmlFooter() {
-    return HTML_TAIL;
-  }
-
-  /**
-   * Method used to generate the Job table for Job pages.
-   * 
-   * @param label display heading to be used in the job table.
-   * @param jobs vector of jobs to be displayed in table.
-   * @param refresh refresh interval to be used in jobdetails page.
-   * @param rowId beginning row id to be used in the table.
-   * @return generated HTML
-   * @throws IOException
-   */
-  public static String generateJobTable(String label, JobStatus[] jobs,
-      int refresh, int rowId) throws IOException {
-
-    StringBuffer sb = new StringBuffer();
-
-    if (jobs.length > 0) {
-      sb.append("<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\">\n");
-      sb.append("<tr><th>Jobid</th>" + "<th>User</th>" + "<th>Name</th>"
-          + "<th>SuperStep</th>" + "<th>Starttime</th>" + "</tr>\n");
-      for (JobStatus status : jobs) {
-        sb.append("<tr><td><a href=\"bspjob.jsp?jobid="+status.getJobID()+ "\">");
-        sb.append(status.getJobID());
-        sb.append("</a></td><td>");
-        sb.append(status.getUsername());
-        sb.append("</td><td>");
-        sb.append(status.getName());
-        sb.append("</td><td>");
-        sb.append(status.getSuperstepCount());
-        sb.append("</td><td>");
-        sb.append(new Date(status.getStartTime()));
-        sb.append("</td></tr>\n");
-      }
-      sb.append("</table>");
-    } else {
-      sb.append("No jobs found!");
-    }
-
-    return sb.toString();
-  }
-
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hama.util;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.Calendar;
+
+import org.apache.hadoop.util.ServletUtil;
+import org.apache.hama.bsp.JobStatus;
+
+public class BSPServletUtil extends ServletUtil {
+
+  public static final String HTML_TAIL = "<hr />\n"
+      + "<a href='http://incubator.apache.org/hama/'>Hama</a>, "
+      + Calendar.getInstance().get(Calendar.YEAR) + ".\n" + "</body></html>";
+
+  /**
+   * HTML footer to be added in the jsps.
+   * 
+   * @return the HTML footer.
+   */
+  public static String htmlFooter() {
+    return HTML_TAIL;
+  }
+
+  /**
+   * Method used to generate the Job table for Job pages.
+   * 
+   * @param label display heading to be used in the job table.
+   * @param jobs vector of jobs to be displayed in table.
+   * @param refresh refresh interval to be used in jobdetails page.
+   * @param rowId beginning row id to be used in the table.
+   * @return generated HTML
+   * @throws IOException
+   */
+  public static String generateJobTable(String label, JobStatus[] jobs,
+      int refresh, int rowId) throws IOException {
+
+    StringBuffer sb = new StringBuffer();
+
+    if (jobs.length > 0) {
+      sb.append("<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\">\n");
+      sb.append("<tr><th>Jobid</th>" + "<th>User</th>" + "<th>Name</th>"
+          + "<th>SuperStep</th>" + "<th>Starttime</th>" + "</tr>\n");
+      for (JobStatus status : jobs) {
+        sb.append("<tr><td><a href=\"bspjob.jsp?jobid="+status.getJobID()+ "\">");
+        sb.append(status.getJobID());
+        sb.append("</a></td><td>");
+        sb.append(status.getUsername());
+        sb.append("</td><td>");
+        sb.append(status.getName());
+        sb.append("</td><td>");
+        sb.append(status.getSuperstepCount());
+        sb.append("</td><td>");
+        sb.append(new Date(status.getStartTime()));
+        sb.append("</td></tr>\n");
+      }
+      sb.append("</table>");
+    } else {
+      sb.append("No jobs found!");
+    }
+
+    return sb.toString();
+  }
+
+}

Propchange: incubator/hama/trunk/src/java/org/apache/hama/util/BSPServletUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/org/apache/hama/util/Bytes.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/org/apache/hama/util/ClusterUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/hama/trunk/src/java/org/apache/hama/util/RandomVariable.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/util/RandomVariable.java?rev=1151771&r1=1151770&r2=1151771&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/util/RandomVariable.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/util/RandomVariable.java Thu Jul 28 09:28:02 2011
@@ -1,227 +1,227 @@
-/**
- * Copyright 2007 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hama.util;
-
-/**
- * The RandomVaraibale Class provides static methods for generating random
- * numbers.
- */
-public class RandomVariable {
-  
-  /**
-   * Generate a random number between 0 and 1.
-   * 
-   * @return a double between 0 and 1.
-   */
-  public static double rand() {
-    double x = Math.random();
-    return x;
-  }
-
-  /**
-   * Generate a random integer.
-   * 
-   * @param i0 min of the random variable.
-   * @param i1 max of the random variable.
-   * @return an int between i0 and i1.
-   */
-  public static int randInt(int i0, int i1) {
-    double x = rand();
-    int i = i0 + (int) Math.floor((i1 - i0 + 1) * x);
-    return i;
-  }
-  
-  /**
-    * Generate a random string using the specified prefix and a fixed length. 
-    * @param prefix
-    *        the specified string prefix.
-    * @param length
-    *        the length of the string to be appended.
-    * @return random string.
-    */
-  public static String randString(String prefix, int length) {
-    StringBuilder result = new StringBuilder(prefix);
-    for (int i = 0; i < length; i++) {
-      char ch = (char) ((Math.random() * 26) + 97);
-      result.append(ch);
-    }
-      
-    return result.toString();
-  }
-
-  /**
-   * Generate a random number from a uniform random variable.
-   * 
-   * @param min min of the random variable.
-   * @param max max of the random variable.
-   * @return a double.
-   */
-  public static double uniform(double min, double max) {
-    double x = min + (max - min) * rand();
-    return x;
-  }
-
-  /**
-   * Generate a random number from a discrete random variable.
-   * 
-   * @param values discrete values.
-   * @param prob probability of each value.
-   * @return a double.
-   */
-  public static double dirac(double[] values, double[] prob) {
-    double[] prob_cumul = new double[values.length];
-    prob_cumul[0] = prob[0];
-    for (int i = 1; i < values.length; i++) {
-      prob_cumul[i] = prob_cumul[i - 1] + prob[i];
-    }
-    double y = rand();
-    double x = 0;
-    for (int i = 0; i < values.length - 1; i++) {
-      if ((y > prob_cumul[i]) && (y < prob_cumul[i + 1])) {
-        x = values[i];
-      }
-    }
-    return x;
-  }
-
-  /**
-   * Generate a random number from a Gaussian (Normal) random variable.
-   * 
-   * @param mu mean of the random variable.
-   * @param sigma standard deviation of the random variable.
-   * @return a double.
-   */
-  public static double normal(double mu, double sigma) {
-    double x = mu + sigma * Math.cos(2 * Math.PI * rand())
-        * Math.sqrt(-2 * Math.log(rand()));
-    return x;
-  }
-
-  /**
-   * Generate a random number from a Chi-2 random variable.
-   * 
-   * @param n degrees of freedom of the chi2 random variable.
-   * @return a double.
-   */
-  public static double chi2(int n) {
-    double x = 0;
-    for (int i = 0; i < n; i++) {
-      double norm = normal(0, 1);
-      x += norm * norm;
-    }
-    return x;
-  }
-
-  /**
-   * Generate a random number from a LogNormal random variable.
-   * 
-   * @param mu mean of the Normal random variable.
-   * @param sigma standard deviation of the Normal random variable.
-   * @return a double.
-   */
-  public static double logNormal(double mu, double sigma) {
-    double x = mu + sigma * Math.cos(2 * Math.PI * rand())
-        * Math.sqrt(-2 * Math.log(rand()));
-    return x;
-  }
-
-  /**
-   * Generate a random number from an exponantial random variable (Mean =
-   * 1/lambda, variance = 1/lambda^2).
-   * 
-   * @param lambda parmaeter of the exponential random variable.
-   * @return a double.
-   */
-  public static double exponential(double lambda) {
-    double x = -1 / lambda * Math.log(rand());
-    return x;
-  }
-
-  /**
-   * Generate a random number from a symetric triangular random variable.
-   * 
-   * @param min min of the random variable.
-   * @param max max of the random variable.
-   * @return a double.
-   */
-  public static double triangular(double min, double max) {
-    double x = min / 2 + (max - min) * rand() / 2 + min / 2 + (max - min)
-        * rand() / 2;
-    return x;
-  }
-
-  /**
-   * Generate a random number from a non-symetric triangular random variable.
-   * 
-   * @param min min of the random variable.
-   * @param med value of the random variable with max density.
-   * @param max max of the random variable.
-   * @return a double.
-   */
-  public static double triangular(double min, double med, double max) {
-    double y = rand();
-    double x = (y < ((med - min) / (max - min))) ? (min + Math.sqrt(y
-        * (max - min) * (med - min))) : (max - Math.sqrt((1 - y) * (max - min)
-        * (max - med)));
-    return x;
-  }
-
-  /**
-   * Generate a random number from a beta random variable.
-   * 
-   * @param a first parameter of the Beta random variable.
-   * @param b second parameter of the Beta random variable.
-   * @return a double.
-   */
-  public static double beta(double a, double b) {
-    double try_x;
-    double try_y;
-    do {
-      try_x = Math.pow(rand(), 1 / a);
-      try_y = Math.pow(rand(), 1 / b);
-    } while ((try_x + try_y) > 1);
-    return try_x / (try_x + try_y);
-  }
-
-  /**
-   * Generate a random number from a Cauchy random variable (Mean = Inf, and
-   * Variance = Inf).
-   * 
-   * @param mu median of the Weibull random variable
-   * @param sigma second parameter of the Cauchy random variable.
-   * @return a double.
-   */
-  public static double cauchy(double mu, double sigma) {
-    double x = sigma * Math.tan(Math.PI * (rand() - 0.5)) + mu;
-    return x;
-  }
-
-  /**
-   * Generate a random number from a Weibull random variable.
-   * 
-   * @param lambda first parameter of the Weibull random variable.
-   * @param c second parameter of the Weibull random variable.
-   * @return a double.
-   */
-  public static double weibull(double lambda, double c) {
-    double x = Math.pow(-Math.log(1 - rand()), 1 / c) / lambda;
-    return x;
-  }
-}
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hama.util;
+
+/**
+ * The RandomVaraibale Class provides static methods for generating random
+ * numbers.
+ */
+public class RandomVariable {
+  
+  /**
+   * Generate a random number between 0 and 1.
+   * 
+   * @return a double between 0 and 1.
+   */
+  public static double rand() {
+    double x = Math.random();
+    return x;
+  }
+
+  /**
+   * Generate a random integer.
+   * 
+   * @param i0 min of the random variable.
+   * @param i1 max of the random variable.
+   * @return an int between i0 and i1.
+   */
+  public static int randInt(int i0, int i1) {
+    double x = rand();
+    int i = i0 + (int) Math.floor((i1 - i0 + 1) * x);
+    return i;
+  }
+  
+  /**
+    * Generate a random string using the specified prefix and a fixed length. 
+    * @param prefix
+    *        the specified string prefix.
+    * @param length
+    *        the length of the string to be appended.
+    * @return random string.
+    */
+  public static String randString(String prefix, int length) {
+    StringBuilder result = new StringBuilder(prefix);
+    for (int i = 0; i < length; i++) {
+      char ch = (char) ((Math.random() * 26) + 97);
+      result.append(ch);
+    }
+      
+    return result.toString();
+  }
+
+  /**
+   * Generate a random number from a uniform random variable.
+   * 
+   * @param min min of the random variable.
+   * @param max max of the random variable.
+   * @return a double.
+   */
+  public static double uniform(double min, double max) {
+    double x = min + (max - min) * rand();
+    return x;
+  }
+
+  /**
+   * Generate a random number from a discrete random variable.
+   * 
+   * @param values discrete values.
+   * @param prob probability of each value.
+   * @return a double.
+   */
+  public static double dirac(double[] values, double[] prob) {
+    double[] prob_cumul = new double[values.length];
+    prob_cumul[0] = prob[0];
+    for (int i = 1; i < values.length; i++) {
+      prob_cumul[i] = prob_cumul[i - 1] + prob[i];
+    }
+    double y = rand();
+    double x = 0;
+    for (int i = 0; i < values.length - 1; i++) {
+      if ((y > prob_cumul[i]) && (y < prob_cumul[i + 1])) {
+        x = values[i];
+      }
+    }
+    return x;
+  }
+
+  /**
+   * Generate a random number from a Gaussian (Normal) random variable.
+   * 
+   * @param mu mean of the random variable.
+   * @param sigma standard deviation of the random variable.
+   * @return a double.
+   */
+  public static double normal(double mu, double sigma) {
+    double x = mu + sigma * Math.cos(2 * Math.PI * rand())
+        * Math.sqrt(-2 * Math.log(rand()));
+    return x;
+  }
+
+  /**
+   * Generate a random number from a Chi-2 random variable.
+   * 
+   * @param n degrees of freedom of the chi2 random variable.
+   * @return a double.
+   */
+  public static double chi2(int n) {
+    double x = 0;
+    for (int i = 0; i < n; i++) {
+      double norm = normal(0, 1);
+      x += norm * norm;
+    }
+    return x;
+  }
+
+  /**
+   * Generate a random number from a LogNormal random variable.
+   * 
+   * @param mu mean of the Normal random variable.
+   * @param sigma standard deviation of the Normal random variable.
+   * @return a double.
+   */
+  public static double logNormal(double mu, double sigma) {
+    double x = mu + sigma * Math.cos(2 * Math.PI * rand())
+        * Math.sqrt(-2 * Math.log(rand()));
+    return x;
+  }
+
+  /**
+   * Generate a random number from an exponantial random variable (Mean =
+   * 1/lambda, variance = 1/lambda^2).
+   * 
+   * @param lambda parmaeter of the exponential random variable.
+   * @return a double.
+   */
+  public static double exponential(double lambda) {
+    double x = -1 / lambda * Math.log(rand());
+    return x;
+  }
+
+  /**
+   * Generate a random number from a symetric triangular random variable.
+   * 
+   * @param min min of the random variable.
+   * @param max max of the random variable.
+   * @return a double.
+   */
+  public static double triangular(double min, double max) {
+    double x = min / 2 + (max - min) * rand() / 2 + min / 2 + (max - min)
+        * rand() / 2;
+    return x;
+  }
+
+  /**
+   * Generate a random number from a non-symetric triangular random variable.
+   * 
+   * @param min min of the random variable.
+   * @param med value of the random variable with max density.
+   * @param max max of the random variable.
+   * @return a double.
+   */
+  public static double triangular(double min, double med, double max) {
+    double y = rand();
+    double x = (y < ((med - min) / (max - min))) ? (min + Math.sqrt(y
+        * (max - min) * (med - min))) : (max - Math.sqrt((1 - y) * (max - min)
+        * (max - med)));
+    return x;
+  }
+
+  /**
+   * Generate a random number from a beta random variable.
+   * 
+   * @param a first parameter of the Beta random variable.
+   * @param b second parameter of the Beta random variable.
+   * @return a double.
+   */
+  public static double beta(double a, double b) {
+    double try_x;
+    double try_y;
+    do {
+      try_x = Math.pow(rand(), 1 / a);
+      try_y = Math.pow(rand(), 1 / b);
+    } while ((try_x + try_y) > 1);
+    return try_x / (try_x + try_y);
+  }
+
+  /**
+   * Generate a random number from a Cauchy random variable (Mean = Inf, and
+   * Variance = Inf).
+   * 
+   * @param mu median of the Weibull random variable
+   * @param sigma second parameter of the Cauchy random variable.
+   * @return a double.
+   */
+  public static double cauchy(double mu, double sigma) {
+    double x = sigma * Math.tan(Math.PI * (rand() - 0.5)) + mu;
+    return x;
+  }
+
+  /**
+   * Generate a random number from a Weibull random variable.
+   * 
+   * @param lambda first parameter of the Weibull random variable.
+   * @param c second parameter of the Weibull random variable.
+   * @return a double.
+   */
+  public static double weibull(double lambda, double c) {
+    double x = Math.pow(-Math.log(1 - rand()), 1 / c) / lambda;
+    return x;
+  }
+}

Propchange: incubator/hama/trunk/src/java/org/apache/hama/util/RandomVariable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/org/apache/hama/util/RunJar.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/org/apache/hama/util/VersionInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/org/apache/hama/util/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/org/apache/hama/zookeeper/QuorumPeer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/org/apache/hama/zookeeper/ZKServerTool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/org/apache/hama/zookeeper/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/java/overview.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/test/org/apache/hama/HamaCluster.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/test/org/apache/hama/HamaClusterTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/test/org/apache/hama/HamaTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/test/org/apache/hama/MiniBSPCluster.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/test/org/apache/hama/bsp/TestBSPMasterGroomServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/test/org/apache/hama/bsp/TestBSPMessageBundle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/test/org/apache/hama/bsp/TestClusterStatus.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/test/org/apache/hama/bsp/TestMessages.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/test/org/apache/hama/ipc/TestIPC.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/test/org/apache/hama/ipc/TestRPC.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/test/org/apache/hama/util/TestBytes.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/test/org/apache/hama/util/TestNumeric.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/test/org/apache/hama/util/TestRandomVariable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/test/org/apache/hama/zookeeper/TestZKTools.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/trunk/src/test/testjar/ClassSerializePrinting.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/hama/trunk/src/webapps/bspmaster/bspjob.jsp
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/webapps/bspmaster/bspjob.jsp?rev=1151771&r1=1151770&r2=1151771&view=diff
==============================================================================
--- incubator/hama/trunk/src/webapps/bspmaster/bspjob.jsp (original)
+++ incubator/hama/trunk/src/webapps/bspmaster/bspjob.jsp Thu Jul 28 09:28:02 2011
@@ -1,66 +1,66 @@
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
--->
-<%@ page contentType="text/html; charset=UTF-8" import="javax.servlet.*"
-	import="javax.servlet.http.*" import="java.io.*" import="java.util.*"
-	import="java.text.DecimalFormat" import="org.apache.hama.bsp.*"
-	import="org.apache.hama.util.*"%>
-<%!private static final long serialVersionUID = 1L;%>
-<%
-  BSPMaster tracker = (BSPMaster) application
-      .getAttribute("bsp.master");
-  String idString = request.getParameter("jobid");
-  JobStatus status = tracker.getJobStatus(BSPJobID.forName(idString));
-  JobStatus.State state = status.getState();
-%>
-
-<html>
-
-<title>Hama BSP Job Summary</title>
-
-<body>
-  <h1><%=status.getName()%></h1>
-
-  <b>State: </b>  <%=state.toString() %> 
-  
-  <br/> <br/>
-  <table border="1" cellpadding="5" cellspacing="0">
-    <tr>
-      <th>Name</th>
-      <th>User</th>
-      <th>SuperStep</th>
-      <th>StartTime</th>
-      <th>FinishTime</th>
-    </tr>
-
-    <tr>
-      <td><%=status.getName() %></td>
-      <td><%=status.getUsername() %></td>
-      <td><%=status.getSuperstepCount() %></td>
-      <td><%=new Date(status.getStartTime()).toString() %></td>
-      <td>
-        <% if(status.getFinishTime() != 0L) {out.write(new Date(status.getFinishTime()).toString());} %>
-      </td>
-    </tr>
-
-  </table>
-  
-  <hr>
-  <a href="bspmaster.jsp">Back to BSPMaster</a>
-
-  <%
-    out.println(BSPServletUtil.htmlFooter());
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<%@ page contentType="text/html; charset=UTF-8" import="javax.servlet.*"
+	import="javax.servlet.http.*" import="java.io.*" import="java.util.*"
+	import="java.text.DecimalFormat" import="org.apache.hama.bsp.*"
+	import="org.apache.hama.util.*"%>
+<%!private static final long serialVersionUID = 1L;%>
+<%
+  BSPMaster tracker = (BSPMaster) application
+      .getAttribute("bsp.master");
+  String idString = request.getParameter("jobid");
+  JobStatus status = tracker.getJobStatus(BSPJobID.forName(idString));
+  JobStatus.State state = status.getState();
+%>
+
+<html>
+
+<title>Hama BSP Job Summary</title>
+
+<body>
+  <h1><%=status.getName()%></h1>
+
+  <b>State: </b>  <%=state.toString() %> 
+  
+  <br/> <br/>
+  <table border="1" cellpadding="5" cellspacing="0">
+    <tr>
+      <th>Name</th>
+      <th>User</th>
+      <th>SuperStep</th>
+      <th>StartTime</th>
+      <th>FinishTime</th>
+    </tr>
+
+    <tr>
+      <td><%=status.getName() %></td>
+      <td><%=status.getUsername() %></td>
+      <td><%=status.getSuperstepCount() %></td>
+      <td><%=new Date(status.getStartTime()).toString() %></td>
+      <td>
+        <% if(status.getFinishTime() != 0L) {out.write(new Date(status.getFinishTime()).toString());} %>
+      </td>
+    </tr>
+
+  </table>
+  
+  <hr>
+  <a href="bspmaster.jsp">Back to BSPMaster</a>
+
+  <%
+    out.println(BSPServletUtil.htmlFooter());
   %>
\ No newline at end of file

Propchange: incubator/hama/trunk/src/webapps/bspmaster/bspjob.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/hama/trunk/src/webapps/bspmaster/bspmaster.jsp
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/webapps/bspmaster/bspmaster.jsp?rev=1151771&r1=1151770&r2=1151771&view=diff
==============================================================================
--- incubator/hama/trunk/src/webapps/bspmaster/bspmaster.jsp (original)
+++ incubator/hama/trunk/src/webapps/bspmaster/bspmaster.jsp Thu Jul 28 09:28:02 2011
@@ -1,82 +1,82 @@
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
--->
-<%@ page contentType="text/html; charset=UTF-8" import="javax.servlet.*"
-	import="javax.servlet.http.*" import="java.io.*" import="java.util.*"
-	import="java.text.DecimalFormat" import="org.apache.hama.bsp.*"
-	import="org.apache.hama.util.*"%>
-<%!private static final long serialVersionUID = 1L;%>
-<%
-  BSPMaster tracker = (BSPMaster) application
-      .getAttribute("bsp.master");
-  ClusterStatus status = tracker.getClusterStatus(true);
-  String trackerName = tracker.getBSPMasterName();
-  JobStatus[] runningJobs = tracker.jobsToComplete();
-  JobStatus[] allJobs = tracker.getAllJobs();
-%>
-<%!private static DecimalFormat percentFormat = new DecimalFormat("##0.00");
- 
-  public void generateSummaryTable(JspWriter out, ClusterStatus status,
-      BSPMaster tracker) throws IOException {
-    String tasksPerNode = status.getGroomServers() > 0 ? percentFormat
-        .format(((double) (status.getMaxTasks()) / status
-            .getGroomServers())) : "-";
-    out.print("<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\">\n"
-        + "<tr>" + "<th>Groom Servers</th><th>BSP Task Capacity</th>"
-        + "<th>Avg. Tasks/Node</th>"
-        + "<th>Blacklisted Nodes</th></tr>\n");
-    out.print("<tr><td><a href=\"machines.jsp?type=active\">"
-        + status.getActiveGroomNames().size() + "</a></td><td>"
-        + status.getMaxTasks() + "</td><td>" + tasksPerNode
-        + "</td><td><a href=\"machines.jsp?type=blacklisted\">" + 0
-        + "</a>" + "</td></tr></table>\n");
-
-    out.print("<br>");
-  }%>
-
-
-<html>
-<head>
-<title><%=trackerName%> Hama BSP Administration</title>
-<!--  <link rel="stylesheet" type="text/css" href="/static/hadoop.css">-->
-</head>
-<body>
-
-<h1><%=trackerName%> Hama BSP Administration</h1>
-
-<b>State:</b>
-<%=status.getBSPMasterState()%><br>
-<b>Started:</b>
-<%=new Date(tracker.getStartTime())%><br>
-<b>Identifier:</b>
-<%=tracker.getBSPMasterIdentifier()%><br>
-
-<hr>
-<%
-  generateSummaryTable(out, status, tracker);
-%>
-<hr />
-
-<h2 id="running_jobs">Running Jobs</h2>
-<%=BSPServletUtil.generateJobTable("Running", runningJobs,
-          30, 0)%>
-<hr> 
-<h2 id="running_jobs">All Jobs History</h2>
-<%=BSPServletUtil.generateJobTable("All", allJobs,
-          30, 0)%>
-<%
-  out.println(BSPServletUtil.htmlFooter());
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<%@ page contentType="text/html; charset=UTF-8" import="javax.servlet.*"
+	import="javax.servlet.http.*" import="java.io.*" import="java.util.*"
+	import="java.text.DecimalFormat" import="org.apache.hama.bsp.*"
+	import="org.apache.hama.util.*"%>
+<%!private static final long serialVersionUID = 1L;%>
+<%
+  BSPMaster tracker = (BSPMaster) application
+      .getAttribute("bsp.master");
+  ClusterStatus status = tracker.getClusterStatus(true);
+  String trackerName = tracker.getBSPMasterName();
+  JobStatus[] runningJobs = tracker.jobsToComplete();
+  JobStatus[] allJobs = tracker.getAllJobs();
+%>
+<%!private static DecimalFormat percentFormat = new DecimalFormat("##0.00");
+ 
+  public void generateSummaryTable(JspWriter out, ClusterStatus status,
+      BSPMaster tracker) throws IOException {
+    String tasksPerNode = status.getGroomServers() > 0 ? percentFormat
+        .format(((double) (status.getMaxTasks()) / status
+            .getGroomServers())) : "-";
+    out.print("<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\">\n"
+        + "<tr>" + "<th>Groom Servers</th><th>BSP Task Capacity</th>"
+        + "<th>Avg. Tasks/Node</th>"
+        + "<th>Blacklisted Nodes</th></tr>\n");
+    out.print("<tr><td><a href=\"machines.jsp?type=active\">"
+        + status.getActiveGroomNames().size() + "</a></td><td>"
+        + status.getMaxTasks() + "</td><td>" + tasksPerNode
+        + "</td><td><a href=\"machines.jsp?type=blacklisted\">" + 0
+        + "</a>" + "</td></tr></table>\n");
+
+    out.print("<br>");
+  }%>
+
+
+<html>
+<head>
+<title><%=trackerName%> Hama BSP Administration</title>
+<!--  <link rel="stylesheet" type="text/css" href="/static/hadoop.css">-->
+</head>
+<body>
+
+<h1><%=trackerName%> Hama BSP Administration</h1>
+
+<b>State:</b>
+<%=status.getBSPMasterState()%><br>
+<b>Started:</b>
+<%=new Date(tracker.getStartTime())%><br>
+<b>Identifier:</b>
+<%=tracker.getBSPMasterIdentifier()%><br>
+
+<hr>
+<%
+  generateSummaryTable(out, status, tracker);
+%>
+<hr />
+
+<h2 id="running_jobs">Running Jobs</h2>
+<%=BSPServletUtil.generateJobTable("Running", runningJobs,
+          30, 0)%>
+<hr> 
+<h2 id="running_jobs">All Jobs History</h2>
+<%=BSPServletUtil.generateJobTable("All", allJobs,
+          30, 0)%>
+<%
+  out.println(BSPServletUtil.htmlFooter());
 %>
\ No newline at end of file

Propchange: incubator/hama/trunk/src/webapps/bspmaster/bspmaster.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/hama/trunk/src/webapps/bspmaster/index.html
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/webapps/bspmaster/index.html?rev=1151771&r1=1151770&r2=1151771&view=diff
==============================================================================
--- incubator/hama/trunk/src/webapps/bspmaster/index.html (original)
+++ incubator/hama/trunk/src/webapps/bspmaster/index.html Thu Jul 28 09:28:02 2011
@@ -1,36 +1,36 @@
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
--->
-<meta HTTP-EQUIV="REFRESH" content="0;url=bspmaster.jsp"/>
-<html>
-
-<head>
-<title>Hama Administration</title>
-</head>
-
-<body>
-
-<h1>Hama Administration</h1>
-
-<ul>
-
-<li><a href="bspmaster.jsp">BSPMaster</a></li>
-
-</ul>
-
-</body>
-
-</html>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<meta HTTP-EQUIV="REFRESH" content="0;url=bspmaster.jsp"/>
+<html>
+
+<head>
+<title>Hama Administration</title>
+</head>
+
+<body>
+
+<h1>Hama Administration</h1>
+
+<ul>
+
+<li><a href="bspmaster.jsp">BSPMaster</a></li>
+
+</ul>
+
+</body>
+
+</html>

Propchange: incubator/hama/trunk/src/webapps/bspmaster/index.html
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/hama/trunk/src/webapps/bspmaster/machines.jsp
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/webapps/bspmaster/machines.jsp?rev=1151771&r1=1151770&r2=1151771&view=diff
==============================================================================
--- incubator/hama/trunk/src/webapps/bspmaster/machines.jsp (original)
+++ incubator/hama/trunk/src/webapps/bspmaster/machines.jsp Thu Jul 28 09:28:02 2011
@@ -1,61 +1,61 @@
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
--->
-<%@ page contentType="text/html; charset=UTF-8" import="javax.servlet.*"
-	import="javax.servlet.http.*" import="java.io.*" import="java.util.*"
-	import="java.text.DecimalFormat" import="org.apache.hama.bsp.*"
-	import="org.apache.hama.util.*"%>
-<%!private static final long serialVersionUID = 1L;%>
-<%
-	BSPMaster tracker = (BSPMaster) application
-			.getAttribute("bsp.master");
-	ClusterStatus status = tracker.getClusterStatus(true);
-	String trackerName = tracker.getBSPMasterName();
-	String type = request.getParameter("type");
-%>
-<%!public void generateGroomsTable(JspWriter out, String type,
-			ClusterStatus status, BSPMaster master) throws IOException {
-	out.print("<center>\n");
-    out.print("<table border=\"2\" cellpadding=\"5\" cellspacing=\"2\">\n");
-    out.print("<tr><td align=\"center\" colspan=\"6\"><b>Groom Servers</b></td></tr>\n");
-    out.print("<tr><td><b>Name</b></td>" + "<td><b>Host</b></td>"
-        + "<td><b># running tasks</b></td></tr>\n");
-    for (Map.Entry<String, String> entry : status.getActiveGroomNames()
-        .entrySet()) {
-      out.print("<tr><td><a href=\"http://");
-      out.print(entry.getKey() + ":" + master.getHttpPort() + "/\">");
-      out.print(entry.getValue() + "</a></td><td>");
-      out.print(entry.getValue() + "</td>" + "<td>" + 1 + "</td></tr>\n");
-    }
-    out.print("</table>\n");
-    out.print("</center>\n");
-  }%>
-
-<html>
-
-<title><%=trackerName%> Hama Machine List</title>
-
-<body>
-<h1><a href="bspmaster.jsp"><%=trackerName%></a> Hama Machine List</h1>
-
-<h2>Grooms</h2>
-<%
-  generateGroomsTable(out, type, status, tracker);
-%>
-
-<%
-  out.println(BSPServletUtil.htmlFooter());
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<%@ page contentType="text/html; charset=UTF-8" import="javax.servlet.*"
+	import="javax.servlet.http.*" import="java.io.*" import="java.util.*"
+	import="java.text.DecimalFormat" import="org.apache.hama.bsp.*"
+	import="org.apache.hama.util.*"%>
+<%!private static final long serialVersionUID = 1L;%>
+<%
+	BSPMaster tracker = (BSPMaster) application
+			.getAttribute("bsp.master");
+	ClusterStatus status = tracker.getClusterStatus(true);
+	String trackerName = tracker.getBSPMasterName();
+	String type = request.getParameter("type");
+%>
+<%!public void generateGroomsTable(JspWriter out, String type,
+			ClusterStatus status, BSPMaster master) throws IOException {
+	out.print("<center>\n");
+    out.print("<table border=\"2\" cellpadding=\"5\" cellspacing=\"2\">\n");
+    out.print("<tr><td align=\"center\" colspan=\"6\"><b>Groom Servers</b></td></tr>\n");
+    out.print("<tr><td><b>Name</b></td>" + "<td><b>Host</b></td>"
+        + "<td><b># running tasks</b></td></tr>\n");
+    for (Map.Entry<String, String> entry : status.getActiveGroomNames()
+        .entrySet()) {
+      out.print("<tr><td><a href=\"http://");
+      out.print(entry.getKey() + ":" + master.getHttpPort() + "/\">");
+      out.print(entry.getValue() + "</a></td><td>");
+      out.print(entry.getValue() + "</td>" + "<td>" + 1 + "</td></tr>\n");
+    }
+    out.print("</table>\n");
+    out.print("</center>\n");
+  }%>
+
+<html>
+
+<title><%=trackerName%> Hama Machine List</title>
+
+<body>
+<h1><a href="bspmaster.jsp"><%=trackerName%></a> Hama Machine List</h1>
+
+<h2>Grooms</h2>
+<%
+  generateGroomsTable(out, type, status, tracker);
+%>
+
+<%
+  out.println(BSPServletUtil.htmlFooter());
 %>
\ No newline at end of file

Propchange: incubator/hama/trunk/src/webapps/bspmaster/machines.jsp
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message