HttpServer (Hadoop 0.20.2-cdh3u3 API)
Date: 2012-03-20

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.hadoop.http
Class HttpServer

    java.lang.Object
      org.apache.hadoop.http.HttpServer

All Implemented Interfaces:
  FilterContainer

    public class HttpServer

extends Object
implements FilterContainer

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

Nested Class Summary
`static class` | `HttpServer.QuotingInputFilter` A Servlet input filter that quotes all HTML active characters in the parameter names and values.
`static class` | `HttpServer.StackServlet` A very simple servlet to serve up a text representation of the current stack traces.

Field Summary
`static String` | `CONF_CONTEXT_ATTRIBUTE`
`protected Map<org.mortbay.jetty.servlet.Context,Boolean>` | `defaultContexts`
`protected List<String>` | `filterNames`
`protected boolean` | `findPort`
`protected org.mortbay.jetty.Connector` | `listener`
`static org.apache.commons.logging.Log` | `LOG`
`protected org.mortbay.jetty.webapp.WebAppContext` | `webAppContext`
`protected org.mortbay.jetty.Server` | `webServer`

Constructor Summary
`HttpServer(String name, String bindAddress, int port, boolean findPort)` Same as this(name, bindAddress, port, findPort, null);
`HttpServer(String name, String bindAddress, int port, boolean findPort, Configuration conf)`
`HttpServer(String name, String bindAddress, int port, boolean findPort, Configuration conf, AccessControlList adminsAcl)` Create a status server on the given port.
`HttpServer(String name, String bindAddress, int port, boolean findPort, Configuration conf, AccessControlList adminsAcl, org.mortbay.jetty.Connector connector)`
`HttpServer(String name, String bindAddress, int port, boolean findPort, Configuration conf, org.mortbay.jetty.Connector connector)`

Method Summary
`void` | `addContext(org.mortbay.jetty.servlet.Context ctxt, boolean isFiltered)`
`protected void` | `addContext(String pathSpec, String dir, boolean isFiltered)` Add a context
`protected void` | `addDefaultApps(org.mortbay.jetty.handler.ContextHandlerCollection parent, String appDir)` Add default apps.
`protected void` | `addDefaultServlets()` Add default servlets.
`void` | `addFilter(String name, String classname, Map<String,String> parameters)` Add a filter to the container.
`protected void` | `addFilterPathMapping(String pathSpec, org.mortbay.jetty.servlet.Context webAppCtx)` Add the path spec to the filter path mapping.
`void` | `addGlobalFilter(String name, String classname, Map<String,String> parameters)` Add a global filter to the container.
`void` | `addInternalServlet(String name, String pathSpec, Class<? extends javax.servlet.http.HttpServlet> clazz)` Deprecated. this is a temporary method
`void` | `addInternalServlet(String name, String pathSpec, Class<? extends javax.servlet.http.HttpServlet> clazz, boolean requireAuth)` Add an internal servlet in the server, specifying whether or not to protect with Kerberos authentication.
`void` | `addServlet(String name, String pathSpec, Class<? extends javax.servlet.http.HttpServlet> clazz)` Add a servlet in the server.
`void` | `addSslListener(InetSocketAddress addr, Configuration sslConf, boolean needClientAuth)` Configure an ssl listener on the server.
`void` | `addSslListener(InetSocketAddress addr, Configuration sslConf, boolean needCertsAuth, boolean needKrbAuth)` Configure an ssl listener on the server.
`void` | `addSslListener(InetSocketAddress addr, String keystore, String storPass, String keyPass)` Deprecated. Use `addSslListener(InetSocketAddress, Configuration, boolean)`
`org.mortbay.jetty.Connector` | `createBaseListener(Configuration conf)` Create a required listener for the Jetty instance listening on the port provided.
`static org.mortbay.jetty.Connector` | `createDefaultChannelConnector()`
`protected void` | `defineFilter(org.mortbay.jetty.servlet.Context ctx, String name, String classname, Map<String,String> parameters, String[] urls)` Define a filter for a context and set up default url mappings.
`Object` | `getAttribute(String name)` Get the value in the webapp context.
`int` | `getPort()` Get the port that the server is on
`protected String` | `getWebAppsPath()` Get the pathname to the webapps files.
`static boolean` | `hasAdministratorAccess(javax.servlet.ServletContext servletContext, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)` Does the user sending the HttpServletRequest has the administrator ACLs? If it isn't the case, response will be modified to send an error to the user.
`void` | `join()`
`void` | `setAttribute(String name, Object value)` Set a value in the webapp context.
`void` | `setThreads(int min, int max)` Set the min, max number of worker threads (simultaneous connections).
`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`

Field Detail

### LOG

    public static final org.apache.commons.logging.Log LOG

### CONF_CONTEXT_ATTRIBUTE

    public static final String CONF_CONTEXT_ATTRIBUTE

See Also:
  Constant Field Values

### webServer

    protected final org.mortbay.jetty.Server webServer

### listener

    protected final org.mortbay.jetty.Connector listener

### webAppContext

    protected final org.mortbay.jetty.webapp.WebAppContext webAppContext

### findPort

    protected final boolean findPort

### defaultContexts

    protected final Map<org.mortbay.jetty.servlet.Context,Boolean> defaultContexts

### filterNames

    protected final List<String> filterNames

Constructor Detail

### HttpServer

    public HttpServer(String name,
                      String bindAddress,
                      int port,
                      boolean findPort)
               throws IOException

  Same as this(name, bindAddress, port, findPort, null);

  Throws:
    `IOException`

### HttpServer

    public HttpServer(String name,
                      String bindAddress,
                      int port,
                      boolean findPort,
                      Configuration conf)
               throws IOException

Throws:
  `IOException`

### HttpServer

    public HttpServer(String name,
                      String bindAddress,
                      int port,
                      boolean findPort,
                      Configuration conf,
                      org.mortbay.jetty.Connector connector)
               throws IOException

Throws:
  `IOException`

### HttpServer

    public HttpServer(String name,
                      String bindAddress,
                      int port,
                      boolean findPort,
                      Configuration conf,
                      AccessControlList adminsAcl)
               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.
    `conf` - Configuration
    `adminsAcl` - `AccessControlList` of the admins
  Throws:
    `IOException`

### HttpServer

    public HttpServer(String name,
                      String bindAddress,
                      int port,
                      boolean findPort,
                      Configuration conf,
                      AccessControlList adminsAcl,
                      org.mortbay.jetty.Connector connector)
               throws IOException

Throws:
  `IOException`

Method Detail

### createBaseListener

    public org.mortbay.jetty.Connector createBaseListener(Configuration conf)
                                                   throws IOException

  Create a required listener for the Jetty instance listening on the port provided. This wrapper and all subclasses must create at least one listener.

  Throws:
    `IOException`

### createDefaultChannelConnector

    public static org.mortbay.jetty.Connector createDefaultChannelConnector()

### addDefaultApps

    protected void addDefaultApps(org.mortbay.jetty.handler.ContextHandlerCollection parent,
                                  String appDir)
                           throws IOException

  Add default apps.

  Parameters:
    `appDir` - The application directory
  Throws:
    `IOException`

### addDefaultServlets

    protected void addDefaultServlets()

  Add default servlets.

### addContext

    public void addContext(org.mortbay.jetty.servlet.Context ctxt,
                           boolean isFiltered)
                    throws IOException

  Throws:
    `IOException`

### addContext

    protected void addContext(String pathSpec,
                              String dir,
                              boolean isFiltered)
                       throws IOException

  Add a context

  Parameters:
    `pathSpec` - The path spec for the context
    `dir` - The directory containing the context
    `isFiltered` - if true, the servlet is added to the filter path mapping
  Throws:
    `IOException`

### 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,
                           Class<? extends javax.servlet.http.HttpServlet> clazz)

  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
    `clazz` - The servlet class

### addInternalServlet

    @Deprecated
    public void addInternalServlet(String name,
                                              String pathSpec,
                                              Class<? extends javax.servlet.http.HttpServlet> clazz)

  Deprecated. this is a temporary method

  Add an internal servlet in the server.

  Parameters:
    `name` - The name of the servlet (can be passed as null)
    `pathSpec` - The path spec for the servlet
    `clazz` - The servlet class

### addInternalServlet

    public void addInternalServlet(String name,
                                   String pathSpec,
                                   Class<? extends javax.servlet.http.HttpServlet> clazz,
                                   boolean requireAuth)

  Add an internal servlet in the server, specifying whether or not to protect with Kerberos authentication. Note: This method is to be used for adding servlets that facilitate internal communication and not for user facing functionality. For servlets added using this method, filters (except internal Kerberized filters) are not enabled.

  Parameters:
    `name` - The name of the servlet (can be passed as null)
    `pathSpec` - The path spec for the servlet
    `clazz` - The servlet class

### addFilter

    public void addFilter(String name,
                          String classname,
                          Map<String,String> parameters)

  Add a filter to the container.

  Specified by:
    `addFilter` in interface `FilterContainer`
  Parameters:
    `name` - Filter name
    `classname` - Filter class name
    `parameters` - a map from parameter names to initial values

### addGlobalFilter

    public void addGlobalFilter(String name,
                                String classname,
                                Map<String,String> parameters)

  Add a global filter to the container.

  Specified by:
    `addGlobalFilter` in interface `FilterContainer`
  Parameters:
    `name` - filter name
    `classname` - filter class name
    `parameters` - a map from parameter names to initial values

### defineFilter

    protected void defineFilter(org.mortbay.jetty.servlet.Context ctx,
                                String name,
                                String classname,
                                Map<String,String> parameters,
                                String[] urls)

  Define a filter for a context and set up default url mappings.

### addFilterPathMapping

    protected void addFilterPathMapping(String pathSpec,
                                        org.mortbay.jetty.servlet.Context webAppCtx)

  Add the path spec to the filter path mapping.

  Parameters:
    `pathSpec` - The path spec
    `webAppCtx` - The WebApplicationContext to add to

### 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

### getWebAppsPath

    protected String getWebAppsPath()
                             throws IOException

  Get the pathname to the webapps files.

  Returns:
    the pathname as a URL
  Throws:
    `IOException` - if 'webapps' directory cannot be found on CLASSPATH.

### getPort

    public int getPort()

  Get the port that the server is on

  Returns:
    the port

### setThreads

    public void setThreads(int min,
                           int max)

  Set the min, max number of worker threads (simultaneous connections).

### addSslListener

    @Deprecated
    public void addSslListener(InetSocketAddress addr,
                                          String keystore,
                                          String storPass,
                                          String keyPass)
                        throws IOException

  Deprecated. Use `addSslListener(InetSocketAddress, Configuration, boolean)`

  Configure an ssl listener on the server.

  Parameters:
    `addr` - address to listen on
    `keystore` - location of the keystore
    `storPass` - password for the keystore
    `keyPass` - password for the key
  Throws:
    `IOException`

### addSslListener

    public void addSslListener(InetSocketAddress addr,
                               Configuration sslConf,
                               boolean needClientAuth)
                        throws IOException

  Configure an ssl listener on the server.

  Parameters:
    `addr` - address to listen on
    `sslConf` - conf to retrieve ssl options
    `needClientAuth` - whether client authentication is required
  Throws:
    `IOException`

### addSslListener

    public void addSslListener(InetSocketAddress addr,
                               Configuration sslConf,
                               boolean needCertsAuth,
                               boolean needKrbAuth)
                        throws IOException

  Configure an ssl listener on the server.

  Parameters:
    `addr` - address to listen on
    `sslConf` - conf to retrieve ssl options
    `needCertsAuth` - whether x509 certificate authentication is required
    `needKrbAuth` - whether to allow kerberos auth
  Throws:
    `IOException`

### start

    public void start()
               throws IOException

  Start the server. Does not wait for the server to start.

  Throws:
    `IOException`

### stop

    public void stop()
              throws Exception

  stop the server

  Throws:
    `Exception`

### join

    public void join()
              throws InterruptedException

  Throws:
    `InterruptedException`

### hasAdministratorAccess

    public static boolean hasAdministratorAccess(javax.servlet.ServletContext servletContext,
                                                 javax.servlet.http.HttpServletRequest request,
                                                 javax.servlet.http.HttpServletResponse response)
                                          throws IOException

  Does the user sending the HttpServletRequest has the administrator ACLs? If it isn't the case, response will be modified to send an error to the user.

  Parameters:
    `servletContext` -
    `request` -
    `response` -
  Returns:
    true if admin-authorized, false otherwise
  Throws:
    `IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 The Apache Software Foundation