@InterfaceAudience.Private @InterfaceStability.Evolving public class HttpServer extends Object implements FilterContainer
| 限定符和类型 | 类和说明 |
|---|---|
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.
|
| 构造器和说明 |
|---|
HttpServer(String name,
String bindAddress,
int port,
boolean findPort)
已过时。
|
HttpServer(String name,
String bindAddress,
int port,
boolean findPort,
org.apache.hadoop.conf.Configuration conf)
已过时。
|
HttpServer(String name,
String bindAddress,
int port,
boolean findPort,
org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.security.authorize.AccessControlList adminsAcl)
已过时。
|
HttpServer(String name,
String bindAddress,
int port,
boolean findPort,
org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.security.authorize.AccessControlList adminsAcl,
String[] pathSpecs)
已过时。
|
HttpServer(String name,
String bindAddress,
int port,
boolean findPort,
org.apache.hadoop.conf.Configuration conf,
String[] pathSpecs)
已过时。
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
addDefaultApps(org.eclipse.jetty.server.handler.ContextHandlerCollection parent,
String appDir,
org.apache.hadoop.conf.Configuration conf)
Add default apps.
|
protected void |
addDefaultServlets(org.eclipse.jetty.server.handler.ContextHandlerCollection contexts,
org.apache.hadoop.conf.Configuration conf)
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.eclipse.jetty.webapp.WebAppContext 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 |
addJerseyResourcePackage(String packageName,
String pathSpec)
Add a Jersey resource package.
|
void |
addPrivilegedServlet(String name,
String pathSpec,
Class<? extends javax.servlet.http.HttpServlet> clazz)
Adds a servlet in the server that only administrators can access.
|
void |
addUnprivilegedServlet(String name,
String pathSpec,
Class<? extends javax.servlet.http.HttpServlet> clazz)
Adds a servlet in the server that any user can access.
|
static void |
defineFilter(org.eclipse.jetty.servlet.ServletContextHandler handler,
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()
已过时。
|
List<org.eclipse.jetty.server.ServerConnector> |
getServerConnectors() |
org.eclipse.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(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.security.authorize.AccessControlList acl,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
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?
|
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(org.apache.hadoop.security.authorize.AccessControlList acl,
String remoteUser) |
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 String HTTP_SPNEGO_AUTHENTICATION_PRINCIPAL_KEY
public static final String HTTP_SPNEGO_AUTHENTICATION_KEYTAB_KEY
public static final String HTTP_SPNEGO_AUTHENTICATION_KRB_NAME_KEY
public static final String HTTP_SPNEGO_AUTHENTICATION_PROXYUSER_ENABLE_KEY
public static final boolean HTTP_SPNEGO_AUTHENTICATION_PROXYUSER_ENABLE_DEFAULT
public static final String HTTP_AUTHENTICATION_SIGNATURE_SECRET_FILE_KEY
public static final String HTTP_SPNEGO_AUTHENTICATION_ADMIN_USERS_KEY
public static final String HTTP_SPNEGO_AUTHENTICATION_ADMIN_GROUPS_KEY
public static final boolean HTTP_PRIVILEGED_CONF_DEFAULT
protected final org.eclipse.jetty.server.Server webServer
protected String appDir
protected String logDir
protected final org.eclipse.jetty.webapp.WebAppContext webAppContext
protected final boolean findPort
protected final Map<org.eclipse.jetty.servlet.ServletContextHandler,Boolean> defaultContexts
protected final boolean authenticationEnabled
@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, 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, 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 adminspathSpecs - Path specifications that this httpserver will be serving.
These will be added to any filters.IOExceptionpublic List<org.eclipse.jetty.server.ServerConnector> getServerConnectors()
protected void addDefaultApps(org.eclipse.jetty.server.handler.ContextHandlerCollection parent,
String appDir,
org.apache.hadoop.conf.Configuration conf)
throws IOException
appDir - The application directoryIOExceptionprotected void addDefaultServlets(org.eclipse.jetty.server.handler.ContextHandlerCollection contexts,
org.apache.hadoop.conf.Configuration conf)
throws IOException
IOExceptionpublic 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 addUnprivilegedServlet(String name, String pathSpec, Class<? extends javax.servlet.http.HttpServlet> clazz)
addPrivilegedServlet(String, String, Class) in that any authenticated user
can interact with the servlet added by this method.name - The name of the servlet (can be passed as null)pathSpec - The path spec for the servletclazz - The servlet classpublic void addPrivilegedServlet(String name, String pathSpec, Class<? extends javax.servlet.http.HttpServlet> clazz)
addUnprivilegedServlet(String, String, Class) in that only those authenticated user
who are identified as administrators can interact with the servlet added by this method.public void addFilter(String name, String classname, Map<String,String> parameters)
FilterContaineraddFilter 在接口中 FilterContainername - Filter nameclassname - Filter class nameparameters - a map from parameter names to initial valuespublic void addGlobalFilter(String name, String classname, Map<String,String> parameters)
FilterContaineraddGlobalFilter 在接口中 FilterContainername - filter nameclassname - filter class nameparameters - a map from parameter names to initial valuespublic static void defineFilter(org.eclipse.jetty.servlet.ServletContextHandler handler,
String name,
String classname,
Map<String,String> parameters,
String[] urls)
protected void addFilterPathMapping(String pathSpec, org.eclipse.jetty.webapp.WebAppContext webAppCtx)
pathSpec - The path specwebAppCtx - The WebApplicationContext to add topublic Object getAttribute(String name)
name - The name of the attributepublic org.eclipse.jetty.webapp.WebAppContext getWebAppContext()
public String getWebAppsPath(String appName) throws 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
IOExceptionpublic void join()
throws 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.IOExceptionpublic 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.IOExceptionpublic static boolean hasAdministratorAccess(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.security.authorize.AccessControlList acl,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws IOException
IOExceptionpublic static boolean userHasAdministratorAccess(javax.servlet.ServletContext servletContext,
String remoteUser)
servletContext - the context containing the admin ACL.remoteUser - the remote user to check for.public static boolean userHasAdministratorAccess(org.apache.hadoop.security.authorize.AccessControlList acl,
String remoteUser)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.