com.caucho.server.cluster
Class Server

java.lang.Object
  extended by com.caucho.server.dispatch.DispatchServer
      extended by com.caucho.server.port.ProtocolDispatchServer
          extended by com.caucho.server.cluster.Server
All Implemented Interfaces:
SchemaBean, ClassLoaderListener, EnvironmentBean, AlarmListener, Dependency, java.util.EventListener

public class Server
extends ProtocolDispatchServer
implements EnvironmentBean, SchemaBean, AlarmListener, ClassLoaderListener


Nested Class Summary
static class Server.SelectManagerCompat
           
 
Constructor Summary
Server(ClusterServer clusterServer)
          Creates a new servlet server.
 
Method Summary
 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 addPing(ResourceAdapter ping)
          Deprecated. 
 void addSelectManager(Server.SelectManagerCompat selectManager)
           
 void addWebAppDefault(WebAppConfig init)
          Adds a WebAppDefault.
 void bindPorts()
          Bind the ports.
 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.
 AbstractCache createCache()
          Adds the cache.
 HostExpandDeployGenerator createHostDeploy()
          Adds a HostDeploy.
 Management createManagement()
           
 ResourceAdapter createPing()
          Deprecated. 
 RewriteDispatch createRewriteDispatch()
          Adds rewrite-dispatch.
 void destroy()
          Closes the server.
 int getAcceptListenBacklog()
          Gets the socket's listen property
 int getAcceptThreadMax()
          Sets the maximum spare listen.
 int getAcceptThreadMin()
          Gets the minimum spare listen.
 ServerMXBean getAdmin()
          Returns the admin.
 java.lang.String getAlternateSessionURLPrefix()
          Gets the alternate session url prefix.
 java.util.ArrayList<CacheItem> getCacheStatistics()
          Returns the cache stuff.
 java.lang.ClassLoader getClassLoader()
          Returns the classLoader
 Cluster getCluster()
          Returns the cluster.
 java.lang.Throwable getConfigException()
          Returns the configuration exception
 java.lang.String getConnectionErrorPage()
          Gets the connection error page.
 long getDependencyCheckInterval()
          Returns the dependency check interval.
 WebApp getErrorWebApp()
          Returns the error webApp during startup.
 int getFreeKeepaliveSelect()
          Returns the number of select keepalives available.
 Host getHost(java.lang.String hostName, int port)
          Returns the matching servlet pattern for a URL.
 java.util.Collection<HostController> getHostControllers()
          Returns the host controllers.
 long getKeepaliveConnectionTimeMax()
          Sets the keepalive timeout
 int getKeepaliveMax()
          Returns the thread-based keepalive max.
 int getKeepaliveSelectCount()
          Returns the select keepalive count.
 long getKeepaliveSelectThreadTimeout()
          Sets the select-based keepalive timeout
 void getKeepaliveSelectThreadTimeout(Period period)
          Sets the select-based keepalive timeout
 long getKeepaliveTimeout()
          Sets the keepalive timeout
 long getMemoryFreeMin()
          Sets the minimum free memory after a GC
 java.util.Collection<Port> getPorts()
          Returns the Ports for this server.
 long getProxyCacheHitCount()
          Returns the proxy cache hit count.
 long getProxyCacheMissCount()
          Returns the proxy cache miss count.
 Path getRootDirectory()
          Sets the root directory.
 java.lang.String getSchema()
          Returns the relax schema.
 java.lang.String getServerHeader()
          Gets the server header.
 java.lang.String getServerId()
          Returns the id.
 java.lang.String getServletPattern(java.lang.String hostName, int port, java.lang.String url)
          Returns the matching servlet pattern for a URL.
 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.
 long getSocketTimeout()
          Gets the read timeout for the request sockets.
 java.lang.String getSSLSessionCookie()
          Gets the ssl session cookie
 long getStartTime()
          Returns the time the server started in ms.
 java.lang.String getState()
          Returns the lifecycle state
 long getSuspendTimeMax()
          Sets the suspend timeout
 WebApp getWebApp(java.lang.String hostName, int port, java.lang.String url)
          Returns the matching servlet pattern for a URL.
 void handleAlarm(Alarm alarm)
          Handles the alarm.
 void init()
          Initialization.
 boolean isActive()
          Returns true if the server is currently active and accepting requests
 boolean isBindPortsAfterStart()
          If true, ports are bound at end.
 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 isKeepaliveSelectEnable()
          Gets the select-based keepalive timeout
 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 isSelectManagerEnabled()
          Sets true if the select manager should be enabled
 boolean isStopped()
          Returns true if the server is stopped.
 boolean isStopping()
          Returns true if the server is stopped.
 void setAcceptListenBacklog(int backlog)
          Sets the socket's listen property
 void setAcceptThreadMax(int maxSpare)
          Sets the maximum spare listen.
 void setAcceptThreadMin(int minSpare)
          Sets the minimum spare listen.
 void setAccessLog(AccessLog log)
          Sets the access log.
 void setAlternateSessionURLPrefix(java.lang.String urlPrefix)
          Sets the alternate session url prefix.
 void setBindPortsAfterStart(boolean bindAtEnd)
          If true, ports are bound at end.
 void setConfigException(java.lang.Throwable exn)
          Returns the configuration instance.
 void setConnectionErrorPage(java.lang.String errorPage)
          Sets the connection error page.
 void setKeepaliveConnectionTimeMax(Period period)
          Sets the keepalive connection timeout
 void setKeepaliveMax(int max)
          Sets the maximum keepalive
 void setKeepaliveSelectEnable(boolean enable)
          Sets the select-based keepalive timeout
 void setKeepaliveTimeout(Period period)
          Sets the keepalive timeout
 void setMemoryFreeMin(Bytes min)
          Sets the minimum free memory after a GC
 void setRootDir(Path path)
          Sets the root directory.
 void setRootDirectory(Path path)
          Sets the root directory.
 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 setSocketTimeout(Period period)
          Sets the default read/write timeout for the request sockets.
 void setSSLSessionCookie(java.lang.String cookie)
          Sets the ssl session cookie
 void setSuspendTimeMax(Period period)
          Sets the suspend timeout
 void setThreadExecutorTaskMax(int max)
          Sets the maximum executor (background) thread.
 void setThreadIdleMax(int max)
          Sets the maximum number of idle threads in the thread pool.
 void setThreadIdleMin(int min)
          Sets the minimum number of idle threads in the thread pool.
 void setThreadMax(int max)
          Sets the maximum thread-based keepalive
 void setURLCharacterEncoding(java.lang.String encoding)
          Sets URL encoding.
 void start()
          Start the server.
 void startPorts()
          Start the ports.
 void stop()
          Closes the server.
 java.lang.String toString()
           
 
Methods inherited from class com.caucho.server.port.ProtocolDispatchServer
getFreeSelectKeepalive, getSelectManager, initSelectManager, isIgnoreClientDisconnect, setIgnoreClientDisconnect
 
Methods inherited from class com.caucho.server.dispatch.DispatchServer
addServerListener, buildInvocation, createInvocation, createInvocationDecoder, getAttribute, getAttributeNames, getDispatchBuilder, getInvocation, getInvocationCacheHitCount, getInvocationCacheMissCount, getInvocationDecoder, getInvocations, getURLCharacterEncoding, invalidateMatchingInvocations, logModified, removeAttribute, restart, setAttribute, setDispatchBuilder, setInvocationCacheMaxURLLength, setInvocationCacheSize, setServerId, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Server

public Server(ClusterServer clusterServer)
Creates a new servlet server.

Method Detail

getClassLoader

public java.lang.ClassLoader getClassLoader()
Returns the classLoader

Specified by:
getClassLoader in interface EnvironmentBean
Overrides:
getClassLoader in class DispatchServer

getConfigException

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


setConfigException

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


setAcceptListenBacklog

public void setAcceptListenBacklog(int backlog)
Sets the socket's listen property


getAcceptListenBacklog

public int getAcceptListenBacklog()
Gets the socket's listen property


setAcceptThreadMin

public void setAcceptThreadMin(int minSpare)
                        throws ConfigException
Sets the minimum spare listen.

Throws:
ConfigException

getAcceptThreadMin

public int getAcceptThreadMin()
Gets the minimum spare listen.


setAcceptThreadMax

public void setAcceptThreadMax(int maxSpare)
                        throws ConfigException
Sets the maximum spare listen.

Throws:
ConfigException

getAcceptThreadMax

public int getAcceptThreadMax()
Sets the maximum spare listen.


setMemoryFreeMin

public void setMemoryFreeMin(Bytes min)
Sets the minimum free memory after a GC


getMemoryFreeMin

public long getMemoryFreeMin()
Sets the minimum free memory after a GC


setKeepaliveMax

public void setKeepaliveMax(int max)
Sets the maximum keepalive


getKeepaliveMax

public int getKeepaliveMax()
Returns the thread-based keepalive max.

Overrides:
getKeepaliveMax in class ProtocolDispatchServer
Returns:
the keepalive max.

setKeepaliveTimeout

public void setKeepaliveTimeout(Period period)
Sets the keepalive timeout


getKeepaliveTimeout

public long getKeepaliveTimeout()
Sets the keepalive timeout


setKeepaliveConnectionTimeMax

public void setKeepaliveConnectionTimeMax(Period period)
Sets the keepalive connection timeout


getKeepaliveConnectionTimeMax

public long getKeepaliveConnectionTimeMax()
Sets the keepalive timeout


setKeepaliveSelectEnable

public void setKeepaliveSelectEnable(boolean enable)
Sets the select-based keepalive timeout


isKeepaliveSelectEnable

public boolean isKeepaliveSelectEnable()
Gets the select-based keepalive timeout


getKeepaliveSelectThreadTimeout

public void getKeepaliveSelectThreadTimeout(Period period)
Sets the select-based keepalive timeout


getKeepaliveSelectThreadTimeout

public long getKeepaliveSelectThreadTimeout()
Sets the select-based keepalive timeout


createManagement

public Management createManagement()

setShutdownWaitMax

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


setSuspendTimeMax

public void setSuspendTimeMax(Period period)
Sets the suspend timeout


getSuspendTimeMax

public long getSuspendTimeMax()
Sets the suspend timeout


getShutdownWaitMax

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


setSocketTimeout

public void setSocketTimeout(Period period)
Sets the default read/write timeout for the request sockets.


getSocketTimeout

public long getSocketTimeout()
Gets the read timeout for the request sockets.


setThreadMax

public void setThreadMax(int max)
Sets the maximum thread-based keepalive


setThreadExecutorTaskMax

public void setThreadExecutorTaskMax(int max)
Sets the maximum executor (background) thread.


setThreadIdleMin

public void setThreadIdleMin(int min)
Sets the minimum number of idle threads in the thread pool.


setThreadIdleMax

public void setThreadIdleMax(int max)
Sets the maximum number of idle threads in the thread pool.


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.


getSchema

public java.lang.String getSchema()
Returns the relax schema.

Specified by:
getSchema in interface SchemaBean

getServerId

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

Overrides:
getServerId in class DispatchServer

setRootDirectory

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


getRootDirectory

public Path getRootDirectory()
Sets the root directory.


setRootDir

public void setRootDir(Path path)
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.


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)
             throws java.lang.Exception
Adds the host.

Throws:
java.lang.Exception

getCluster

public Cluster getCluster()
Returns the cluster.


createRewriteDispatch

public RewriteDispatch createRewriteDispatch()
Adds rewrite-dispatch.


createCache

public AbstractCache createCache()
                          throws ConfigException
Adds the cache.

Throws:
ConfigException

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

createPing

@Deprecated
public ResourceAdapter createPing()
                           throws ConfigException
Deprecated. 

Creates the ping.

Throws:
ConfigException

addPing

@Deprecated
public void addPing(ResourceAdapter ping)
             throws ConfigException
Deprecated. 

Adds the ping.

Throws:
ConfigException

isSelectManagerEnabled

public boolean isSelectManagerEnabled()
Sets true if the select manager should be enabled

Overrides:
isSelectManagerEnabled in class ProtocolDispatchServer

addSelectManager

public void addSelectManager(Server.SelectManagerCompat selectManager)

getFreeKeepaliveSelect

public int getFreeKeepaliveSelect()
Returns the number of select keepalives available.


addErrorPage

public void addErrorPage(ErrorPage errorPage)
Adds an error page


getStartTime

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


getState

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


getKeepaliveSelectCount

public int getKeepaliveSelectCount()
Returns the select keepalive count.


getCacheStatistics

public java.util.ArrayList<CacheItem> getCacheStatistics()
Returns the cache stuff.


buildInvocation

public Invocation buildInvocation(Invocation invocation)
                           throws java.lang.Throwable
Sets the invocation

Overrides:
buildInvocation in class DispatchServer
Throws:
java.lang.Throwable

getServletPattern

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


getAdmin

public ServerMXBean getAdmin()
Returns the admin.


getWebApp

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


getErrorWebApp

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


getHostControllers

public java.util.Collection<HostController> getHostControllers()
Returns the host controllers.


getHost

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


setBindPortsAfterStart

public void setBindPortsAfterStart(boolean bindAtEnd)
If true, ports are bound at end.


isBindPortsAfterStart

public boolean isBindPortsAfterStart()
If true, ports are bound at end.


getPorts

public java.util.Collection<Port> getPorts()
Returns the Ports for this server.


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

public void init()
Initialization.

Overrides:
init in class DispatchServer

start

public void start()
Start the server.


bindPorts

public void bindPorts()
               throws java.lang.Exception
Bind the ports.

Throws:
java.lang.Exception

startPorts

public void startPorts()
                throws java.lang.Exception
Start the ports.

Throws:
java.lang.Exception

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
Overrides:
isModified in class DispatchServer

isModifiedNow

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


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.

Overrides:
isDestroyed in class DispatchServer

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

Overrides:
isActive in class ProtocolDispatchServer

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.

Overrides:
clearCache in class DispatchServer

getProxyCacheHitCount

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


getProxyCacheMissCount

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


stop

public void stop()
Closes the server.

Overrides:
stop in class ProtocolDispatchServer

destroy

public void destroy()
Closes the server.

Overrides:
destroy in class DispatchServer

toString

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