@InterfaceAudience.Private @InterfaceStability.Evolving public class HttpServer extends Object implements FilterContainer
Modifier and Type | Class and Description |
---|---|
static class |
HttpServer.Builder
Class to construct instances of HTTP server with specific options.
|
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.
|
Modifier and Type | Field and Description |
---|---|
static String |
ADMINS_ACL |
static String |
APP_DIR |
protected String |
appDir |
static String |
BIND_ADDRESS |
static String |
CONF_CONTEXT_ATTRIBUTE |
protected Map<org.mortbay.jetty.servlet.Context,Boolean> |
defaultContexts |
protected List<String> |
filterNames |
protected boolean |
findPort |
static org.apache.commons.logging.Log |
LOG |
protected String |
logDir |
static String |
NO_CACHE_FILTER |
static String |
SPNEGO_FILTER |
protected org.mortbay.jetty.webapp.WebAppContext |
webAppContext |
protected org.mortbay.jetty.Server |
webServer |
Constructor and Description |
---|
HttpServer(String name,
String bindAddress,
int port,
boolean findPort)
Deprecated.
|
HttpServer(String name,
String bindAddress,
int port,
boolean findPort,
org.apache.hadoop.conf.Configuration conf)
Deprecated.
|
HttpServer(String name,
String bindAddress,
int port,
boolean findPort,
org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.security.authorize.AccessControlList adminsAcl)
Deprecated.
|
HttpServer(String name,
String bindAddress,
int port,
boolean findPort,
org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.security.authorize.AccessControlList adminsAcl,
org.mortbay.jetty.Connector connector)
Deprecated.
|
HttpServer(String name,
String bindAddress,
int port,
boolean findPort,
org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.security.authorize.AccessControlList adminsAcl,
org.mortbay.jetty.Connector connector,
String[] pathSpecs)
Deprecated.
|
HttpServer(String name,
String bindAddress,
int port,
boolean findPort,
org.apache.hadoop.conf.Configuration conf,
org.mortbay.jetty.Connector connector)
Deprecated.
|
HttpServer(String name,
String bindAddress,
int port,
boolean findPort,
org.apache.hadoop.conf.Configuration conf,
String[] pathSpecs)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
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,
org.apache.hadoop.conf.Configuration conf)
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 - This global filter will be
applied to all available web contexts.
|
void |
addInternalServlet(String name,
String pathSpec,
Class<? extends javax.servlet.http.HttpServlet> clazz)
Add an internal servlet in the server.
|
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 |
addJerseyResourcePackage(String packageName,
String pathSpec)
Add a Jersey resource package.
|
void |
addServlet(String name,
String pathSpec,
Class<? extends javax.servlet.http.HttpServlet> clazz)
Add a servlet in the server.
|
org.mortbay.jetty.Connector |
createBaseListener(org.apache.hadoop.conf.Configuration conf)
Create a required listener for the Jetty instance listening on the port
provided.
|
static org.mortbay.jetty.Connector |
createDefaultChannelConnector() |
static 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.
|
InetSocketAddress |
getConnectorAddress(int index)
Get the address that corresponds to a particular connector.
|
int |
getPort()
Deprecated.
|
org.mortbay.jetty.webapp.WebAppContext |
getWebAppContext() |
String |
getWebAppsPath(String appName) |
protected String |
getWebAppsPath(String webapps,
String appName)
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.
|
boolean |
isAlive()
Test for the availability of the web server
|
static boolean |
isInstrumentationAccessAllowed(javax.servlet.ServletContext servletContext,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Checks the user has privileges to access to instrumentation servlets.
|
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
|
String |
toString()
Return the host and port of the HttpServer, if live
|
static boolean |
userHasAdministratorAccess(javax.servlet.ServletContext servletContext,
String remoteUser)
Get the admin ACLs from the given ServletContext and check if the given
user is in the ACL.
|
public static final org.apache.commons.logging.Log LOG
public static final String CONF_CONTEXT_ATTRIBUTE
public static final String ADMINS_ACL
public static final String BIND_ADDRESS
public static final String SPNEGO_FILTER
public static final String NO_CACHE_FILTER
public static final String APP_DIR
protected final org.mortbay.jetty.Server webServer
protected String appDir
protected String logDir
protected final org.mortbay.jetty.webapp.WebAppContext webAppContext
protected final boolean findPort
@Deprecated public HttpServer(String name, String bindAddress, int port, boolean findPort) throws IOException
IOException
@Deprecated public HttpServer(String name, String bindAddress, int port, boolean findPort, org.apache.hadoop.conf.Configuration conf, org.mortbay.jetty.Connector connector) throws IOException
IOException
@Deprecated public HttpServer(String name, String bindAddress, int port, boolean findPort, org.apache.hadoop.conf.Configuration conf, String[] pathSpecs) throws IOException
name
- The name of the serverbindAddress
- The address for this serverport
- The port to use on the serverfindPort
- whether the server should start at the given port and
increment by 1 until it finds a free port.conf
- ConfigurationpathSpecs
- Path specifications that this httpserver will be serving.
These will be added to any filters.IOException
@Deprecated public HttpServer(String name, String bindAddress, int port, boolean findPort, org.apache.hadoop.conf.Configuration conf) throws IOException
name
- The name of the serverport
- The port to use on the serverfindPort
- whether the server should start at the given port and
increment by 1 until it finds a free port.conf
- ConfigurationIOException
@Deprecated public HttpServer(String name, String bindAddress, int port, boolean findPort, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.security.authorize.AccessControlList adminsAcl) throws IOException
IOException
@Deprecated public HttpServer(String name, String bindAddress, int port, boolean findPort, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.security.authorize.AccessControlList adminsAcl, org.mortbay.jetty.Connector connector) throws IOException
name
- The name of the serverbindAddress
- The address for this serverport
- The port to use on the serverfindPort
- whether the server should start at the given port and
increment by 1 until it finds a free port.conf
- ConfigurationadminsAcl
- AccessControlList
of the adminsconnector
- The jetty Connector
to useIOException
@Deprecated public HttpServer(String name, String bindAddress, int port, boolean findPort, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.security.authorize.AccessControlList adminsAcl, org.mortbay.jetty.Connector connector, String[] pathSpecs) throws IOException
name
- The name of the serverbindAddress
- The address for this serverport
- The port to use on the serverfindPort
- whether the server should start at the given port and
increment by 1 until it finds a free port.conf
- ConfigurationadminsAcl
- AccessControlList
of the adminsconnector
- A jetty connection listenerpathSpecs
- Path specifications that this httpserver will be serving.
These will be added to any filters.IOException
public org.mortbay.jetty.Connector createBaseListener(org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
@InterfaceAudience.Private public static org.mortbay.jetty.Connector createDefaultChannelConnector()
protected void addDefaultApps(org.mortbay.jetty.handler.ContextHandlerCollection parent, String appDir, org.apache.hadoop.conf.Configuration conf) throws IOException
appDir
- The application directoryIOException
protected void addDefaultServlets()
public void addContext(org.mortbay.jetty.servlet.Context ctxt, boolean isFiltered) throws IOException
IOException
protected void addContext(String pathSpec, String dir, boolean isFiltered) throws IOException
pathSpec
- The path spec for the contextdir
- The directory containing the contextisFiltered
- if true, the servlet is added to the filter path mappingIOException
public void setAttribute(String name, Object value)
name
- The name of the attributevalue
- The value of the attributepublic void addJerseyResourcePackage(String packageName, String pathSpec)
packageName
- The Java package name containing the Jersey resource.pathSpec
- The path spec for the servletpublic void addServlet(String name, String pathSpec, Class<? extends javax.servlet.http.HttpServlet> clazz)
name
- The name of the servlet (can be passed as null)pathSpec
- The path spec for the servletclazz
- The servlet classpublic void addInternalServlet(String name, String pathSpec, Class<? extends javax.servlet.http.HttpServlet> clazz)
name
- The name of the servlet (can be passed as null)pathSpec
- The path spec for the servletclazz
- The servlet classpublic void addInternalServlet(String name, String pathSpec, Class<? extends javax.servlet.http.HttpServlet> clazz, boolean requireAuth)
name
- The name of the servlet (can be passed as null)pathSpec
- The path spec for the servletclazz
- The servlet classrequireAuth
- Require Kerberos authenticate to access servletpublic void addFilter(String name, String classname, Map<String,String> parameters)
FilterContainer
addFilter
in interface FilterContainer
name
- Filter nameclassname
- Filter class nameparameters
- a map from parameter names to initial valuespublic void addGlobalFilter(String name, String classname, Map<String,String> parameters)
FilterContainer
addGlobalFilter
in interface FilterContainer
name
- filter nameclassname
- filter class nameparameters
- a map from parameter names to initial valuespublic static void defineFilter(org.mortbay.jetty.servlet.Context ctx, String name, String classname, Map<String,String> parameters, String[] urls)
protected void addFilterPathMapping(String pathSpec, org.mortbay.jetty.servlet.Context webAppCtx)
pathSpec
- The path specwebAppCtx
- The WebApplicationContext to add topublic Object getAttribute(String name)
name
- The name of the attributepublic org.mortbay.jetty.webapp.WebAppContext getWebAppContext()
public String getWebAppsPath(String appName) throws FileNotFoundException
FileNotFoundException
protected String getWebAppsPath(String webapps, String appName) throws FileNotFoundException
appName
- eg "secondary" or "datanode"FileNotFoundException
- if 'webapps' directory cannot be found on CLASSPATH.@Deprecated public int getPort()
public InetSocketAddress getConnectorAddress(int index)
public void setThreads(int min, int max)
public void start() throws IOException
IOException
public void join() throws InterruptedException
InterruptedException
public boolean isAlive()
public String toString()
public static boolean isInstrumentationAccessAllowed(javax.servlet.ServletContext servletContext, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
hadoop.security.instrumentation.requires.admin
is set to FALSE
(default value) it always returns TRUE.
If hadoop.security.instrumentation.requires.admin
is set to TRUE
it will check that if the current user is in the admin ACLS. If the user is
in the admin ACLs it returns TRUE, otherwise it returns FALSE.servletContext
- the servlet context.request
- the servlet request.response
- the servlet response.IOException
public static boolean hasAdministratorAccess(javax.servlet.ServletContext servletContext, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
servletContext
- request
- response
- used to send the error response if user does not have admin access.IOException
public static boolean userHasAdministratorAccess(javax.servlet.ServletContext servletContext, String remoteUser)
servletContext
- the context containing the admin ACL.remoteUser
- the remote user to check for.Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.