org.objectweb.jonas.management.cluster
Class BaseCluster

java.lang.Object
  extended byorg.objectweb.jonas.management.cluster.BaseCluster
All Implemented Interfaces:
BaseClusterMBean
Direct Known Subclasses:
CmiCluster, EjbHaCluster, JkCluster, LogicalCluster, TomcatCluster

public abstract class BaseCluster
extends java.lang.Object
implements BaseClusterMBean

Implements basics for cluster management. To be extended by the different cluster types. It implements cluster state transition diagram based on the members's state. A member is represented by a ClusterMember class instance.

Author:
Adriana Danes
See Also:
ClusterMember

Nested Class Summary
 class BaseCluster.DeployThread
           
 
Field Summary
protected  ClusterFactory cf
          ClusterFactory that created this Cluster
protected  DomainMonitor dm
          ref to the domainMonitor
protected  JmxService jmx
          ref to the Jmx Service
protected static org.objectweb.util.monolog.api.Logger logger
          domain management logger
protected  java.util.Map members
          The list of ClusterMember objects that compose this Cluster Key = name of the Member.
protected  java.lang.String name
          The name of this Cluster.
protected  javax.management.ObjectName objectName
          MBean OBJECT_NAME :type=,name= type may be one among: JkCluster, TomcatCluster, etc...
protected  int state
          The cluster state
static int STATE_DOWN
          All the members are in STOPPED state
static int STATE_FAILED
          All the members are in FAILED state
static int STATE_INIT
          This is the initial state, all members are in INITIAL state
static int STATE_PARTIALLY_DOWN
          At least one members is in STOPPED state, there is no failed member, there is no running memeber
static int STATE_PARTIALLY_FAILED
          At least one members is in FAILED state
static int STATE_PARTIALLY_UP
          At least one members is in RUNNING state, there is no failed member
static int STATE_UNKNOWN
          No member in FAILED state, no member in RUNNING state, no memeber in STOPPED state The members' state may be UNREACHABLE or UNKNOWN
static int STATE_UP
          All the members are in RUNNING state
 
Constructor Summary
BaseCluster(ClusterFactory cf)
          Constructor
 
Method Summary
 boolean addMember(ClusterMember m)
          Add a Member to the Cluster
 void addServer(java.lang.String svname, java.lang.String[] urls, java.lang.String cdn)
          MBean operation Add a server in the cluster (jonasAdmin) - this is only called for LogicalCluster
abstract  ClusterMember createClusterMember(java.lang.String svname, ServerProxy proxy)
          Create a new ClusterMember.
 void deployModule(java.lang.String file)
          MBean operation Deploy a module on all nodes.
 java.lang.String[] getMembers()
           
 java.lang.String getName()
           
 int getNbMembers()
           
 java.lang.String getObjectName()
           
 J2EEServer getServer(java.lang.String name)
          Get a server by its name.
 ServerProxy getServerProxy(java.lang.String name)
          Get a server by its name.
 java.util.Collection getServerProxyList()
           
 java.lang.String getState()
          Get the Cluster State
abstract  java.lang.String getType()
           
 void removeServer(java.lang.String svname)
          MBean operation Remove a server from the cluster (jonasAdmin)
 javax.management.ObjectName setName(java.lang.String name)
          Set the MBean name, that may be unknown when constructor is called.
 void startit()
          MBean operation Start all cluster nodes.
 void stopit()
          MBean operation Stop all cluster nodes.
 void undeployModule(java.lang.String file)
          MBean operation Undeploy a module on all nodes.
 void uploadDeployModule(java.lang.String file, boolean repl)
          MBean operation Upload adn deploy a module on all nodes.
 void uploadFile(java.lang.String file, boolean repl)
          MBean operation Upload a file on all nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
The name of this Cluster. This String is included in the MBean OBJECT_NAME.


objectName

protected javax.management.ObjectName objectName
MBean OBJECT_NAME :type=,name= type may be one among: JkCluster, TomcatCluster, etc...


members

protected java.util.Map members
The list of ClusterMember objects that compose this Cluster Key = name of the Member.


cf

protected ClusterFactory cf
ClusterFactory that created this Cluster


state

protected int state
The cluster state


STATE_INIT

public static final int STATE_INIT
This is the initial state, all members are in INITIAL state

See Also:
Constant Field Values

STATE_UP

public static final int STATE_UP
All the members are in RUNNING state

See Also:
Constant Field Values

STATE_DOWN

public static final int STATE_DOWN
All the members are in STOPPED state

See Also:
Constant Field Values

STATE_FAILED

public static final int STATE_FAILED
All the members are in FAILED state

See Also:
Constant Field Values

STATE_PARTIALLY_FAILED

public static final int STATE_PARTIALLY_FAILED
At least one members is in FAILED state

See Also:
Constant Field Values

STATE_PARTIALLY_UP

public static final int STATE_PARTIALLY_UP
At least one members is in RUNNING state, there is no failed member

See Also:
Constant Field Values

STATE_PARTIALLY_DOWN

public static final int STATE_PARTIALLY_DOWN
At least one members is in STOPPED state, there is no failed member, there is no running memeber

See Also:
Constant Field Values

STATE_UNKNOWN

public static final int STATE_UNKNOWN
No member in FAILED state, no member in RUNNING state, no memeber in STOPPED state The members' state may be UNREACHABLE or UNKNOWN

See Also:
Constant Field Values

logger

protected static org.objectweb.util.monolog.api.Logger logger
domain management logger


jmx

protected JmxService jmx
ref to the Jmx Service


dm

protected DomainMonitor dm
ref to the domainMonitor

Constructor Detail

BaseCluster

public BaseCluster(ClusterFactory cf)
Constructor

Parameters:
cf - Cluster Factory
Method Detail

createClusterMember

public abstract ClusterMember createClusterMember(java.lang.String svname,
                                                  ServerProxy proxy)
Create a new ClusterMember. Depends on the underlaying class.

Parameters:
svname -
proxy -

setName

public javax.management.ObjectName setName(java.lang.String name)
                                    throws javax.management.JMException
Set the MBean name, that may be unknown when constructor is called.

Parameters:
name - its name.
Returns:
the MBean ObjectName
Throws:
javax.management.JMException - could not create MBean instance

getObjectName

public java.lang.String getObjectName()
Returns:
The MBean OBJECT_NAME

getType

public abstract java.lang.String getType()
Returns:
the type of this Cluster (string form)

addMember

public boolean addMember(ClusterMember m)
Add a Member to the Cluster

Parameters:
m - Member to add
Returns:
true if added, false if already there.

getServer

public J2EEServer getServer(java.lang.String name)
Get a server by its name.

Parameters:
name - fo the server
Returns:
the Server or null if not found.

getServerProxy

public ServerProxy getServerProxy(java.lang.String name)
Get a server by its name.

Parameters:
name - fo the server
Returns:
the ServerProxy or null if not found.

getServerProxyList

public java.util.Collection getServerProxyList()
Returns:
The list of ServerProxy

getState

public java.lang.String getState()
Get the Cluster State

Specified by:
getState in interface BaseClusterMBean
Returns:
A String representing the cluster current state

getName

public java.lang.String getName()
Specified by:
getName in interface BaseClusterMBean
Returns:
the cluster name

getNbMembers

public int getNbMembers()
Specified by:
getNbMembers in interface BaseClusterMBean
Returns:
the member number

getMembers

public java.lang.String[] getMembers()
Specified by:
getMembers in interface BaseClusterMBean
Returns:
the Member MBean OBJECT_NAMES

addServer

public void addServer(java.lang.String svname,
                      java.lang.String[] urls,
                      java.lang.String cdn)
               throws javax.management.JMException
MBean operation Add a server in the cluster (jonasAdmin) - this is only called for LogicalCluster

Specified by:
addServer in interface BaseClusterMBean
Parameters:
svname - logical name of the server
cdn - clusterDaemon used to manage te server
Throws:
javax.management.JMException

removeServer

public void removeServer(java.lang.String svname)
MBean operation Remove a server from the cluster (jonasAdmin)

Specified by:
removeServer in interface BaseClusterMBean
Parameters:
svname - logical name of the server
Returns:
the member corresponding to the server to be removed

startit

public void startit()
             throws javax.management.JMException
MBean operation Start all cluster nodes.

Specified by:
startit in interface BaseClusterMBean
Throws:
javax.management.JMException

stopit

public void stopit()
            throws javax.management.JMException
MBean operation Stop all cluster nodes.

Specified by:
stopit in interface BaseClusterMBean
Throws:
javax.management.JMException

deployModule

public void deployModule(java.lang.String file)
MBean operation Deploy a module on all nodes.

Specified by:
deployModule in interface BaseClusterMBean
Parameters:
file - file to upload. One among .war,.jar,.ear,.rar

undeployModule

public void undeployModule(java.lang.String file)
MBean operation Undeploy a module on all nodes.

Specified by:
undeployModule in interface BaseClusterMBean
Parameters:
file - file to upload. One among .war,.jar,.ear,.rar

uploadFile

public void uploadFile(java.lang.String file,
                       boolean repl)
MBean operation Upload a file on all nodes.

Specified by:
uploadFile in interface BaseClusterMBean
Parameters:
file - file to upload. One among .war,.jar,.ear,.rar
repl - true if the uploaded file can replace a file with the same name in the jars directory

uploadDeployModule

public void uploadDeployModule(java.lang.String file,
                               boolean repl)
MBean operation Upload adn deploy a module on all nodes.

Specified by:
uploadDeployModule in interface BaseClusterMBean
Parameters:
file - file to upload. One among .war,.jar,.ear,.rar
repl - true if the uploaded file can replace a file with the same name in the jars directory