com.caucho.server.cluster
Class Cluster

java.lang.Object
  extended by com.caucho.server.cluster.Cluster
All Implemented Interfaces:
SchemaBean, EnvironmentListener

public abstract class Cluster
extends java.lang.Object
implements EnvironmentListener, SchemaBean

Defines a set of clustered servers.


Nested Class Summary
 class Cluster.ClusterVar
          EL variables
 
Constructor Summary
protected Cluster(Resin resin)
           
 
Method Summary
 void addContentProgram(ConfigProgram program)
          Adds a program.
 void addDynamicServer(java.lang.String serverId, java.lang.String address, int port)
          Adds a new server to the cluster.
 void addServer(ClusterServer server)
          Adds a new server to the cluster during configuration.
 void addServerDefault(ContainerProgram program)
          Adds a new server to the cluster.
 void classLoaderDestroy(DynamicClassLoader loader)
          Handles the case where a class loader is dropped.
 void classLoaderInit(DynamicClassLoader loader)
          Handles the case where a class loader has completed initialization
 void close()
          Closes the cluster.
protected  void configureServerDefault(ClusterServer server)
          Configure the default values for the server
 ClusterPod createPod()
          Adds a new pod to the cluster
abstract  ClusterServer createServer()
          Adds a new server to the cluster during configuration.
 void environmentBind(EnvironmentClassLoader loader)
          Handles the case where the environment is starting (after init).
 void environmentConfigure(EnvironmentClassLoader loader)
          Handles the case where the environment is configured (after init).
 void environmentStart(EnvironmentClassLoader loader)
          Handles the case where the environment is starting (after init).
 void environmentStop(EnvironmentClassLoader loader)
          Handles the case where the environment is stopping
 ClusterPod findPod(int podIndex)
          Finds the first server with the given server-id.
 ClusterServer findServer(int podIndex, int index)
          Finds the first server with the given server-id.
 ClusterServer findServer(java.lang.String id)
          Finds the first server with the given server-id.
 ClusterServer findServer(java.lang.String address, int port)
          Finds the first server with the given server-id.
 ClusterServer findServerByPrefix(java.lang.String prefix)
          Finds the first server with the given server-id.
 ClusterMXBean getAdmin()
          Returns the admin.
 java.lang.String getId()
          Gets the cluster id.
abstract  ClusterPod[] getPodList()
          Returns the list of pods for the cluster
 Resin getResin()
          Returns the owning resin container.
 java.lang.String getSchema()
          Returns the relax schema.
 Server getServer()
          Returns the server
 long getVersion()
          Returns the version
 void init()
          Initializes the cluster.
 boolean isActive()
          Returns true if the cluster is active
 boolean isDynamicServerEnable()
          Enables dynamic servers
 void removeDynamicServer(ClusterServer server)
          Adds a new server to the cluster.
 void setDynamicServerEnable(boolean isEnable)
          Enables dynamic servers
 void setId(java.lang.String id)
          Sets the cluster id.
protected  void setSelfServer(ClusterServer server)
           
 void start()
          Start the cluster.
 void startRemote()
          Start any work in notifying other members in the cluster that the server is active.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Cluster

protected Cluster(Resin resin)
Method Detail

setId

public void setId(java.lang.String id)
Sets the cluster id.


getId

public java.lang.String getId()
Gets the cluster id.


getResin

public Resin getResin()
Returns the owning resin container.


getServer

public Server getServer()
Returns the server


getSchema

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

Specified by:
getSchema in interface SchemaBean

setDynamicServerEnable

public void setDynamicServerEnable(boolean isEnable)
Enables dynamic servers


isDynamicServerEnable

public boolean isDynamicServerEnable()
Enables dynamic servers


getVersion

public long getVersion()
Returns the version


getAdmin

public ClusterMXBean getAdmin()
Returns the admin.


getPodList

public abstract ClusterPod[] getPodList()
Returns the list of pods for the cluster


findServer

public ClusterServer findServer(java.lang.String id)
Finds the first server with the given server-id.


findServer

public ClusterServer findServer(int podIndex,
                                int index)
Finds the first server with the given server-id.


findPod

public ClusterPod findPod(int podIndex)
Finds the first server with the given server-id.


findServerByPrefix

public ClusterServer findServerByPrefix(java.lang.String prefix)
Finds the first server with the given server-id.


findServer

public ClusterServer findServer(java.lang.String address,
                                int port)
Finds the first server with the given server-id.


addServerDefault

public void addServerDefault(ContainerProgram program)
Adds a new server to the cluster.


createPod

public ClusterPod createPod()
Adds a new pod to the cluster


createServer

public abstract ClusterServer createServer()
Adds a new server to the cluster during configuration.


addServer

public void addServer(ClusterServer server)
Adds a new server to the cluster during configuration.


configureServerDefault

protected void configureServerDefault(ClusterServer server)
Configure the default values for the server


addDynamicServer

public void addDynamicServer(java.lang.String serverId,
                             java.lang.String address,
                             int port)
                      throws ConfigException
Adds a new server to the cluster.

Throws:
ConfigException

setSelfServer

protected void setSelfServer(ClusterServer server)

removeDynamicServer

public void removeDynamicServer(ClusterServer server)
                         throws ConfigException
Adds a new server to the cluster.

Throws:
ConfigException

addContentProgram

public void addContentProgram(ConfigProgram program)
Adds a program.


isActive

public boolean isActive()
Returns true if the cluster is active


init

@PostConstruct
public void init()
          throws ConfigException
Initializes the cluster.

Throws:
ConfigException

start

public void start()
           throws ConfigException
Start the cluster.

Throws:
ConfigException

classLoaderInit

public void classLoaderInit(DynamicClassLoader loader)
Handles the case where a class loader has completed initialization


classLoaderDestroy

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


startRemote

public void startRemote()
Start any work in notifying other members in the cluster that the server is active.


environmentConfigure

public void environmentConfigure(EnvironmentClassLoader loader)
Handles the case where the environment is configured (after init).

Specified by:
environmentConfigure in interface EnvironmentListener

environmentBind

public void environmentBind(EnvironmentClassLoader loader)
Handles the case where the environment is starting (after init).

Specified by:
environmentBind in interface EnvironmentListener

environmentStart

public void environmentStart(EnvironmentClassLoader loader)
Handles the case where the environment is starting (after init).

Specified by:
environmentStart in interface EnvironmentListener

environmentStop

public void environmentStop(EnvironmentClassLoader loader)
Handles the case where the environment is stopping

Specified by:
environmentStop in interface EnvironmentListener

close

public void close()
Closes the cluster.


toString

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