org.apache.hadoop.mapred
Class StatusHttpServer

java.lang.Object
  extended by org.apache.hadoop.mapred.StatusHttpServer

public class StatusHttpServer
extends Object

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/)

Author:
Owen O'Malley

Constructor Summary
StatusHttpServer(String name, int port, boolean findPort)
          Create a status server on the given port.
 
Method Summary
 void addServlet(String name, String pathSpec, String classname, String contextPath)
          Add a servlet in the server
 Object getAttribute(String name)
          Get the value in the webapp context.
 int getPort()
          Get the port that the server is on
 void setAttribute(String name, Object value)
          Set a value in the webapp context.
 void setThreads(int min, int max)
           
 void start()
          Start the server.
 void stop()
          stop the server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatusHttpServer

public StatusHttpServer(String name,
                        int port,
                        boolean findPort)
                 throws IOException
Create a status server on the given port. The jsp scripts are taken from src/webapps/.

Parameters:
name - The name of the server
port - The port to use on the server
findPort - whether the server should start at the given port and increment by 1 until it finds a free port.
Throws:
IOException
Method Detail

setAttribute

public void setAttribute(String name,
                         Object value)
Set a value in the webapp context. These values are available to the jsp pages as "application.getAttribute(name)".

Parameters:
name - The name of the attribute
value - The value of the attribute

addServlet

public void addServlet(String name,
                       String pathSpec,
                       String classname,
                       String contextPath)
                throws ClassNotFoundException,
                       InstantiationException,
                       IllegalAccessException
Add a servlet in the server

Parameters:
name - The name of the servlet (can be passed as null)
pathSpec - The path spec for the servlet
classname - The class name for the servlet
contextPath - The context path (can be null, defaults to "/")
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException

getAttribute

public Object getAttribute(String name)
Get the value in the webapp context.

Parameters:
name - The name of the attribute
Returns:
The value of the attribute

getPort

public int getPort()
Get the port that the server is on

Returns:
the port

setThreads

public void setThreads(int min,
                       int max)

start

public void start()
           throws IOException
Start the server. Does not wait for the server to start.

Throws:
IOException

stop

public void stop()
          throws InterruptedException
stop the server

Throws:
InterruptedException


Copyright © 2006 The Apache Software Foundation