@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.
|
private static class |
HttpServer.ListenerInfo |
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 |
private org.apache.hadoop.security.authorize.AccessControlList |
adminsAcl |
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 |
(package private) static String |
FILTER_INITIALIZERS_PROPERTY |
protected List<String> |
filterNames |
protected boolean |
findPort |
(package private) static String |
HTTP_MAX_THREADS |
private List<HttpServer.ListenerInfo> |
listeners |
private static org.apache.commons.logging.Log |
LOG |
protected String |
logDir |
static String |
NO_CACHE_FILTER |
static String |
SPNEGO_FILTER |
(package private) static String |
STATE_DESCRIPTION_ALIVE |
(package private) static String |
STATE_DESCRIPTION_NOT_LIVE |
protected org.mortbay.jetty.webapp.WebAppContext |
webAppContext |
protected org.mortbay.jetty.Server |
webServer |
Modifier | Constructor and Description |
---|---|
private |
HttpServer(HttpServer.Builder b) |
|
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(org.mortbay.jetty.handler.ContextHandlerCollection contexts)
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.
|
private void |
addManagedListener(org.mortbay.jetty.Connector connector) |
private org.mortbay.util.MultiException |
addMultiException(org.mortbay.util.MultiException exception,
Exception e) |
private static void |
addNoCacheFilter(org.mortbay.jetty.webapp.WebAppContext ctxt) |
void |
addServlet(String name,
String pathSpec,
Class<? extends javax.servlet.http.HttpServlet> clazz)
Add a servlet in the server.
|
private void |
addUnmanagedListener(org.mortbay.jetty.Connector connector) |
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() |
private static org.mortbay.jetty.webapp.WebAppContext |
createWebAppContext(String name,
org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.security.authorize.AccessControlList adminsAcl,
String appDir) |
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.
|
private static FilterInitializer[] |
getFilterInitializers(org.apache.hadoop.conf.Configuration conf)
Get an array of FilterConfiguration specified in the conf
|
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.
|
private void |
initializeWebServer(String name,
String hostName,
org.apache.hadoop.conf.Configuration conf,
String[] pathSpecs) |
private void |
initSpnego(org.apache.hadoop.conf.Configuration conf,
String hostName,
String usernameConfKey,
String keytabConfKey) |
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() |
private void |
loadListeners() |
(package private) void |
openListeners()
Open the main listener for the server
|
void |
setAttribute(String name,
Object value)
Set a value in the webapp context.
|
private void |
setContextAttributes(org.mortbay.jetty.servlet.Context context,
org.apache.hadoop.conf.Configuration conf) |
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.
|
private static final org.apache.commons.logging.Log LOG
static final String FILTER_INITIALIZERS_PROPERTY
static final String HTTP_MAX_THREADS
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
private final org.apache.hadoop.security.authorize.AccessControlList adminsAcl
protected final org.mortbay.jetty.Server webServer
protected String appDir
protected String logDir
private final List<HttpServer.ListenerInfo> listeners
protected final org.mortbay.jetty.webapp.WebAppContext webAppContext
protected final boolean findPort
static final String STATE_DESCRIPTION_ALIVE
static final String STATE_DESCRIPTION_NOT_LIVE
@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
private HttpServer(HttpServer.Builder b) throws IOException
IOException
private void initializeWebServer(String name, String hostName, org.apache.hadoop.conf.Configuration conf, String[] pathSpecs) throws FileNotFoundException, IOException
FileNotFoundException
IOException
private void addUnmanagedListener(org.mortbay.jetty.Connector connector)
private void addManagedListener(org.mortbay.jetty.Connector connector)
private static org.mortbay.jetty.webapp.WebAppContext createWebAppContext(String name, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.security.authorize.AccessControlList adminsAcl, String appDir)
private static void addNoCacheFilter(org.mortbay.jetty.webapp.WebAppContext ctxt)
public org.mortbay.jetty.Connector createBaseListener(org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
@InterfaceAudience.Private public static org.mortbay.jetty.Connector createDefaultChannelConnector()
private static FilterInitializer[] getFilterInitializers(org.apache.hadoop.conf.Configuration conf)
protected void addDefaultApps(org.mortbay.jetty.handler.ContextHandlerCollection parent, String appDir, org.apache.hadoop.conf.Configuration conf) throws IOException
appDir
- The application directoryIOException
private void setContextAttributes(org.mortbay.jetty.servlet.Context context, org.apache.hadoop.conf.Configuration conf)
protected void addDefaultServlets(org.mortbay.jetty.handler.ContextHandlerCollection contexts) throws IOException
IOException
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)
private void initSpnego(org.apache.hadoop.conf.Configuration conf, String hostName, String usernameConfKey, String keytabConfKey) throws IOException
IOException
public void start() throws IOException
IOException
private void loadListeners()
void openListeners() throws Exception
Exception
private org.mortbay.util.MultiException addMultiException(org.mortbay.util.MultiException exception, Exception e)
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
If 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–2019 The Apache Software Foundation. All rights reserved.