com.caucho.server.cluster
Class ServletService

java.lang.Object
  extended by com.caucho.server.cluster.ServletService
All Implemented Interfaces:
ClassLoaderListener, InvocationBuilder, AlarmListener, Dependency, java.util.EventListener

public class ServletService
extends java.lang.Object
implements AlarmListener, ClassLoaderListener, InvocationBuilder, Dependency


Constructor Summary
ServletService(Resin resin)
          Creates a new servlet server.
 
Method Summary
 void add(DispatchRule rewriteRule)
           
 void addEarDefault(EarConfig config)
          Adds an EarDefault
 void addErrorPage(ErrorPage errorPage)
          Adds an error page
 void addHost(HostConfig host)
          Adds the host.
 void addHostDefault(HostConfig init)
          Adds a HostDefault.
 void addHostDeploy(HostExpandDeployGenerator deploy)
          Adds a HostDeploy.
 void addSendfileCount()
           
 void addWebAppDefault(WebAppConfig init)
          Adds a WebAppDefault.
 HttpBufferStore allocateHttpBuffer()
           
 Invocation buildInvocation(Invocation invocation)
          Sets the invocation
 void classLoaderDestroy(DynamicClassLoader loader)
          Handles the case where a class loader is dropped.
 void classLoaderInit(DynamicClassLoader loader)
          Handles the case where a class loader is activated.
 void clearCache()
          Clears the proxy cache.
 void clearCacheByPattern(java.lang.String hostPattern, java.lang.String uriPattern)
          Clears the catch by matching the invocation.
protected  ServerAdmin createAdmin()
           
 ActorSender createAdminClient(java.lang.String uid)
          Creates a bam client to the admin.
 ActorSender createAdminClient(java.lang.String uid, java.lang.String resource)
          Creates a bam client to the admin.
protected  HempBrokerManager createBrokerManager()
          Creates the bam broker manager
 HostExpandDeployGenerator createHostDeploy()
          Adds a HostDeploy.
 AbstractProxyCache createProxyCache()
          Creates the http cache.
 RewriteDispatch createRewriteDispatch()
          Adds rewrite-dispatch.
 void destroy()
          Closes the server.
 void freeHttpBuffer(HttpBufferStore buffer)
           
 ServerMXBean getAdmin()
          Returns the admin.
 AdminAuthenticator getAdminAuthenticator()
           
 ManagedBroker getAdminBroker()
          Returns the bam broker.
 BamManager getAdminBrokerManager()
          Returns the bam broker.
 java.lang.String getAlternateSessionURLPrefix()
          Gets the alternate session url prefix.
 java.lang.String getBamAdminName()
          Returns the bam name.
 ManagedBroker getBamBroker()
          Returns the bam broker.
 BamManager getBamManager()
           
 Broker getBroker()
          Returns the admin broker.
 EnvironmentClassLoader getClassLoader()
          Returns the classLoader
 CloudCluster getCluster()
          Returns the cluster
 CloudCluster[] getClusterList()
          Returns all the clusters
protected  ClusterServer getClusterServer()
          Returns the cluster server
 java.lang.Throwable getConfigException()
          Returns the configuration exception
 java.lang.String getConnectionErrorPage()
          Gets the connection error page.
 double getCpuLoad()
           
static ServletService getCurrent()
          Returns the current server
 WebApp getDefaultWebApp()
          Returns the default web-app or error web-app for top-level errors
 long getDependencyCheckInterval()
          Returns the dependency check interval.
 EnvironmentMXBean getEnvironmentAdmin()
          Returns the admin for the current environment.
 ErrorPageManager getErrorPageManager()
           
 WebApp getErrorWebApp()
          Returns the error webApp during startup.
 int getHeaderCountMax()
          Gets the header-count-max
 int getHeaderSizeMax()
          Gets the header-size-max
 MessageStream getHmtpStream()
          Returns any HMTP stream
 Host getHost(java.lang.String hostName, int port)
          Returns the matching servlet pattern for a URL.
 HostController getHostController(java.lang.String hostName, int port)
          Returns the matching servlet pattern for a URL.
 HostController[] getHostControllers()
          Returns the host controllers.
 InvocationDecoder getInvocationDecoder()
           
 InvocationServer getInvocationServer()
           
 PersistentStoreConfig getPersistentStore()
           
 CloudPod getPod()
          Returns the self server's pod
 AbstractProxyCache getProxyCache()
           
 long getProxyCacheHitCount()
          Returns the proxy cache hit count.
 long getProxyCacheMissCount()
          Returns the proxy cache miss count.
 Resin getResin()
          Returns the resin server
 Path getResinDataDirectory()
          Returns the admin path
 ResinSystem getResinSystem()
           
 Path getRootDirectory()
          Sets the root directory.
 ClusterServer getSelfServer()
          Returns the self server
 long getSendfileCount()
           
 long getSendfileMinLength()
           
 java.lang.String getServerHeader()
          Gets the server header.
 java.lang.String getServerId()
          Returns the id.
 int getServerIndex()
           
 java.lang.String getSessionCookie()
          Gets the session cookie
 java.lang.String getSessionURLPrefix()
          Gets the session url prefix.
 long getShutdownWaitMax()
          Gets the max wait time for a shutdown.
 java.lang.String getSSLSessionCookie()
          Gets the ssl session cookie
 java.lang.String getStage()
          Returns the stage id
 long getStartTime()
          Returns the time the server started in ms.
 java.lang.String getState()
          Returns the lifecycle state
 ClusterCache getSystemStore()
          Returns the reliable system store
 java.lang.String getUniqueServerName()
           
 java.lang.String getURLCharacterEncoding()
           
 int getUrlLengthMax()
          Gets the url-length-max
 WebApp getWebApp(java.lang.String hostName, int port, java.lang.String url)
          Returns the matching web-app for a URL.
 void handleAlarm(Alarm alarm)
          Handles the alarm.
 void init()
          Initialization.
protected  AbstractProxyCache instantiateProxyCache()
           
 boolean isActive()
          Returns true if the server is currently active and accepting requests
 boolean isAfterStarting()
          Returns true if the server is starting or active
 boolean isDeployError()
          Return true if idle.
 boolean isDestroyed()
          Returns true if the server is closed.
 boolean isDestroying()
          Returns true if the server is closed.
 boolean isDevelopmentModeErrorPage()
          Development mode error pages.
 boolean isEnabled()
          Returns true for an enabled service.
 boolean isIgnoreClientDisconnect()
          True if client disconnects should be invisible to servlets.
 boolean isModified()
          Returns true if the server has been modified and needs restarting.
 boolean isModifiedNow()
          Returns true if the server has been modified and needs restarting.
 boolean isPreview()
          Returns true in preview mode
 boolean isResinServer()
           
 boolean isSendfileEnable()
          Returns true if sendfile is enabled.
 boolean isStopped()
          Returns true if the server is stopped.
 boolean isStopping()
          Returns true if the server is stopped.
 boolean isWatchdog()
          Returns true for the watchdog server.
 boolean logModified(java.util.logging.Logger log)
          Log the reason for a modification, returning true if this dependency was modified.
protected  void logModules()
          Display activated modules
protected  void notifyStop()
          Notifications to cluster servers that we've stopped.
protected  void preInit()
           
 void restart()
           
 void setAccessLog(AccessLog log)
          Sets the access log.
 void setAlternateSessionURLPrefix(java.lang.String urlPrefix)
          Sets the alternate session url prefix.
 void setConfigException(java.lang.Throwable exn)
          Returns the configuration instance.
 void setConnectionErrorPage(java.lang.String errorPage)
          Sets the connection error page.
 void setDevelopmentModeErrorPage(boolean isEnable)
          Development mode error pages.
 void setEnabled(boolean isEnabled)
           
 void setHeaderCountMax(int length)
          Sets the header-size-max
 void setHeaderSizeMax(int length)
          Sets the header-size-max
 void setIgnoreClientDisconnect(boolean isIgnore)
          True if client disconnections should be invisible to servlets.
 void setPersistentStore(PersistentStoreConfig config)
           
 void setRootDirectory(Path path)
          Sets the root directory.
 void setSendfileEnable(boolean isEnable)
          Returns true if sendfile is enabled.
 void setSendfileMinLength(long bytes)
           
 void setServerHeader(java.lang.String server)
          Sets the server header.
 void setSessionCookie(java.lang.String cookie)
          Sets the session cookie
 void setSessionURLPrefix(java.lang.String urlPrefix)
          Sets the session url prefix.
 void setShutdownWaitMax(Period waitTime)
          Sets the max wait time for shutdown.
 void setSSLSessionCookie(java.lang.String cookie)
          Sets the ssl session cookie
 void setStage(java.lang.String stage)
          Sets the stage id
 void setURLCharacterEncoding(java.lang.String encoding)
          Sets URL encoding.
 void setUrlLengthMax(int length)
          Sets the url-length-max
 void start()
          Start the server.
protected  void startImpl()
           
 void stop()
          Closes the server.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServletService

public ServletService(Resin resin)
Creates a new servlet server.

Method Detail

preInit

protected void preInit()

getCurrent

public static ServletService getCurrent()
Returns the current server


getResinSystem

public ResinSystem getResinSystem()

isResinServer

public boolean isResinServer()

getUniqueServerName

public java.lang.String getUniqueServerName()

getClassLoader

public EnvironmentClassLoader getClassLoader()
Returns the classLoader


getConfigException

public java.lang.Throwable getConfigException()
Returns the configuration exception


setConfigException

public void setConfigException(java.lang.Throwable exn)
Returns the configuration instance.


getResin

public Resin getResin()
Returns the resin server


isWatchdog

public boolean isWatchdog()
Returns true for the watchdog server.


getCluster

public CloudCluster getCluster()
Returns the cluster


getClusterList

public CloudCluster[] getClusterList()
Returns all the clusters


getResinDataDirectory

public Path getResinDataDirectory()
Returns the admin path


createBrokerManager

protected HempBrokerManager createBrokerManager()
Creates the bam broker manager


getClusterServer

protected ClusterServer getClusterServer()
Returns the cluster server


getSelfServer

public ClusterServer getSelfServer()
Returns the self server


getPod

public CloudPod getPod()
Returns the self server's pod


getBamManager

public BamManager getBamManager()

getBamBroker

public ManagedBroker getBamBroker()
Returns the bam broker.


getAdminBroker

public ManagedBroker getAdminBroker()
Returns the bam broker.


getAdminBrokerManager

public BamManager getAdminBrokerManager()
Returns the bam broker.


createAdminClient

public ActorSender createAdminClient(java.lang.String uid)
Creates a bam client to the admin.


createAdminClient

public ActorSender createAdminClient(java.lang.String uid,
                                     java.lang.String resource)
Creates a bam client to the admin.


getBamAdminName

public java.lang.String getBamAdminName()
Returns the bam name.


getBroker

public Broker getBroker()
Returns the admin broker.


getAdminAuthenticator

public AdminAuthenticator getAdminAuthenticator()

isDevelopmentModeErrorPage

public boolean isDevelopmentModeErrorPage()
Development mode error pages.


setDevelopmentModeErrorPage

public void setDevelopmentModeErrorPage(boolean isEnable)
Development mode error pages.


setStage

public void setStage(java.lang.String stage)
Sets the stage id


getStage

public java.lang.String getStage()
Returns the stage id


isPreview

public boolean isPreview()
Returns true in preview mode


isEnabled

public boolean isEnabled()
Returns true for an enabled service.


setEnabled

public void setEnabled(boolean isEnabled)

setShutdownWaitMax

public void setShutdownWaitMax(Period waitTime)
Sets the max wait time for shutdown.


getShutdownWaitMax

public long getShutdownWaitMax()
Gets the max wait time for a shutdown.


setConnectionErrorPage

public void setConnectionErrorPage(java.lang.String errorPage)
Sets the connection error page.


getConnectionErrorPage

public java.lang.String getConnectionErrorPage()
Gets the connection error page.


isDeployError

public boolean isDeployError()
Return true if idle.


isIgnoreClientDisconnect

public boolean isIgnoreClientDisconnect()
True if client disconnects should be invisible to servlets.


setIgnoreClientDisconnect

public void setIgnoreClientDisconnect(boolean isIgnore)
True if client disconnections should be invisible to servlets.


getServerId

public java.lang.String getServerId()
Returns the id.


setRootDirectory

public void setRootDirectory(Path path)
Sets the root directory.


getRootDirectory

public Path getRootDirectory()
Sets the root directory.


setServerHeader

public void setServerHeader(java.lang.String server)
Sets the server header.


getServerHeader

public java.lang.String getServerHeader()
Gets the server header.


setUrlLengthMax

public void setUrlLengthMax(int length)
Sets the url-length-max


getUrlLengthMax

public int getUrlLengthMax()
Gets the url-length-max


setHeaderSizeMax

public void setHeaderSizeMax(int length)
Sets the header-size-max


getHeaderSizeMax

public int getHeaderSizeMax()
Gets the header-size-max


setHeaderCountMax

public void setHeaderCountMax(int length)
Sets the header-size-max


getHeaderCountMax

public int getHeaderCountMax()
Gets the header-count-max


addWebAppDefault

public void addWebAppDefault(WebAppConfig init)
Adds a WebAppDefault.


addEarDefault

public void addEarDefault(EarConfig config)
Adds an EarDefault


addHostDefault

public void addHostDefault(HostConfig init)
Adds a HostDefault.


createHostDeploy

public HostExpandDeployGenerator createHostDeploy()
Adds a HostDeploy.


addHostDeploy

public void addHostDeploy(HostExpandDeployGenerator deploy)
Adds a HostDeploy.


addHost

public void addHost(HostConfig host)
Adds the host.


createRewriteDispatch

public RewriteDispatch createRewriteDispatch()
Adds rewrite-dispatch.


add

public void add(DispatchRule rewriteRule)

getProxyCache

public AbstractProxyCache getProxyCache()

createProxyCache

public final AbstractProxyCache createProxyCache()
                                          throws ConfigException
Creates the http cache.

Throws:
ConfigException

instantiateProxyCache

protected AbstractProxyCache instantiateProxyCache()

setSendfileEnable

public void setSendfileEnable(boolean isEnable)
Returns true if sendfile is enabled.


isSendfileEnable

public boolean isSendfileEnable()
Returns true if sendfile is enabled.


getSendfileMinLength

public long getSendfileMinLength()

setSendfileMinLength

public void setSendfileMinLength(long bytes)

getSendfileCount

public long getSendfileCount()

addSendfileCount

public void addSendfileCount()

setAccessLog

public void setAccessLog(AccessLog log)
Sets the access log.


getDependencyCheckInterval

public long getDependencyCheckInterval()
Returns the dependency check interval.


setSessionCookie

public void setSessionCookie(java.lang.String cookie)
Sets the session cookie


getSessionCookie

public java.lang.String getSessionCookie()
Gets the session cookie


setSSLSessionCookie

public void setSSLSessionCookie(java.lang.String cookie)
Sets the ssl session cookie


getSSLSessionCookie

public java.lang.String getSSLSessionCookie()
Gets the ssl session cookie


setSessionURLPrefix

public void setSessionURLPrefix(java.lang.String urlPrefix)
Sets the session url prefix.


getSessionURLPrefix

public java.lang.String getSessionURLPrefix()
Gets the session url prefix.


setAlternateSessionURLPrefix

public void setAlternateSessionURLPrefix(java.lang.String urlPrefix)
                                  throws ConfigException
Sets the alternate session url prefix.

Throws:
ConfigException

getAlternateSessionURLPrefix

public java.lang.String getAlternateSessionURLPrefix()
Gets the alternate session url prefix.


setURLCharacterEncoding

public void setURLCharacterEncoding(java.lang.String encoding)
                             throws ConfigException
Sets URL encoding.

Throws:
ConfigException

getURLCharacterEncoding

public java.lang.String getURLCharacterEncoding()

getInvocationDecoder

public InvocationDecoder getInvocationDecoder()

getInvocationServer

public InvocationServer getInvocationServer()

addErrorPage

public void addErrorPage(ErrorPage errorPage)
Adds an error page


setPersistentStore

public void setPersistentStore(PersistentStoreConfig config)

getPersistentStore

public PersistentStoreConfig getPersistentStore()

getServerIndex

public int getServerIndex()

getStartTime

public long getStartTime()
Returns the time the server started in ms.


getState

public java.lang.String getState()
Returns the lifecycle state


getCpuLoad

public double getCpuLoad()

buildInvocation

public Invocation buildInvocation(Invocation invocation)
                           throws ConfigException
Sets the invocation

Specified by:
buildInvocation in interface InvocationBuilder
Throws:
ConfigException

getAdmin

public ServerMXBean getAdmin()
Returns the admin.


getEnvironmentAdmin

public EnvironmentMXBean getEnvironmentAdmin()
Returns the admin for the current environment.


getDefaultWebApp

public WebApp getDefaultWebApp()
Returns the default web-app or error web-app for top-level errors


getWebApp

public WebApp getWebApp(java.lang.String hostName,
                        int port,
                        java.lang.String url)
Returns the matching web-app for a URL.


getErrorWebApp

public WebApp getErrorWebApp()
Returns the error webApp during startup.


getErrorPageManager

public ErrorPageManager getErrorPageManager()

getHostControllers

public HostController[] getHostControllers()
Returns the host controllers.


getHost

public Host getHost(java.lang.String hostName,
                    int port)
Returns the matching servlet pattern for a URL.


getHostController

public HostController getHostController(java.lang.String hostName,
                                        int port)
Returns the matching servlet pattern for a URL.


getSystemStore

public ClusterCache getSystemStore()
Returns the reliable system store


allocateHttpBuffer

public HttpBufferStore allocateHttpBuffer()

freeHttpBuffer

public void freeHttpBuffer(HttpBufferStore buffer)

classLoaderInit

public void classLoaderInit(DynamicClassLoader loader)
Handles the case where a class loader is activated.

Specified by:
classLoaderInit in interface ClassLoaderListener

classLoaderDestroy

public void classLoaderDestroy(DynamicClassLoader loader)
Handles the case where a class loader is dropped.

Specified by:
classLoaderDestroy in interface ClassLoaderListener

init

@PostConstruct
public void init()
Initialization.


createAdmin

protected ServerAdmin createAdmin()

start

public void start()
Start the server.


startImpl

protected void startImpl()

logModules

protected void logModules()
Display activated modules


handleAlarm

public void handleAlarm(Alarm alarm)
Handles the alarm.

Specified by:
handleAlarm in interface AlarmListener

isModified

public boolean isModified()
Returns true if the server has been modified and needs restarting.

Specified by:
isModified in interface Dependency

logModified

public boolean logModified(java.util.logging.Logger log)
Description copied from interface: Dependency
Log the reason for a modification, returning true if this dependency was modified.

Specified by:
logModified in interface Dependency

isModifiedNow

public boolean isModifiedNow()
Returns true if the server has been modified and needs restarting.


isAfterStarting

public boolean isAfterStarting()
Returns true if the server is starting or active


isStopping

public boolean isStopping()
Returns true if the server is stopped.


isStopped

public boolean isStopped()
Returns true if the server is stopped.


isDestroyed

public boolean isDestroyed()
Returns true if the server is closed.


isDestroying

public boolean isDestroying()
Returns true if the server is closed.


isActive

public boolean isActive()
Returns true if the server is currently active and accepting requests


clearCacheByPattern

public void clearCacheByPattern(java.lang.String hostPattern,
                                java.lang.String uriPattern)
Clears the catch by matching the invocation.


clearCache

public void clearCache()
Clears the proxy cache.


getProxyCacheHitCount

public long getProxyCacheHitCount()
Returns the proxy cache hit count.


getProxyCacheMissCount

public long getProxyCacheMissCount()
Returns the proxy cache miss count.


getHmtpStream

public MessageStream getHmtpStream()
Returns any HMTP stream


restart

public void restart()

stop

public void stop()
Closes the server.


notifyStop

protected void notifyStop()
Notifications to cluster servers that we've stopped.


destroy

public void destroy()
Closes the server.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object