org.ow2.jonas.lib.management.domain.cluster
Class BaseCluster

java.lang.Object
  extended by org.ow2.jonas.lib.management.domain.cluster.BaseCluster
All Implemented Interfaces:
BaseClusterMBean
Direct Known Subclasses:
CmiCluster, EjbHaCluster, JkCluster, LogicalCluster, TomcatCluster

public abstract class BaseCluster
extends 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, S. Ali Tokmen
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  String domainName
           
protected  JmxService jmx
          ref to the Jmx Service
protected static org.objectweb.util.monolog.api.Logger logger
          domain management logger
protected  Map members
          The list of ClusterMember objects that compose this Cluster Key = name of the Member.
protected  String name
          The name of this Cluster.
protected  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(String name, String[] urls, String clusterd)
          Deprecated. addServer(String, String[], String, String, String)
 void addServer(String svname, String[] urls, String cdn, String username, String password)
          MBean operation Add a server in the cluster (jonasAdmin) - this is only called for LogicalCluster
abstract  ClusterMember createClusterMember(String svname, ServerProxy proxy)
          Create a new ClusterMember.
 void deployModule(String file)
          MBean operation Deploy a module on all nodes.
 String[] getMembers()
           
 String getName()
           
 int getNbMembers()
           
 String getObjectName()
           
 ServerProxy getRunningServerProxy()
          Get a server by its name.
 ServerProxy getServerProxy(String name)
          Get a server by its name.
 Collection<ServerProxy> getServerProxyList()
           
 String getState()
          Get the Cluster State
abstract  String getType()
           
 boolean isMember(String serverName)
          Check if a server is member of a cluster.
 void removeServer(String svname)
          MBean operation Remove a server from the cluster (jonasAdmin)
 ObjectName setName(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(String file)
          MBean operation Undeploy a module on all nodes.
 void uploadDeployModule(String file, boolean repl)
          MBean operation Upload adn deploy a module on all nodes.
 void uploadFile(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 String name
The name of this Cluster. This String is included in the MBean OBJECT_NAME.


objectName

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


members

protected 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


domainName

protected String domainName
Constructor Detail

BaseCluster

public BaseCluster(ClusterFactory cf)
Constructor

Parameters:
cf - Cluster Factory
Method Detail

createClusterMember

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

Parameters:
svname -
proxy -

setName

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

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

getObjectName

public String getObjectName()
Returns:
The MBean OBJECT_NAME

getType

public abstract 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.

getServerProxy

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

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

getRunningServerProxy

public ServerProxy getRunningServerProxy()
Get a server by its name.

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

getServerProxyList

public Collection<ServerProxy> getServerProxyList()
Returns:
The list of ServerProxy

getState

public String getState()
Get the Cluster State

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

getName

public 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 String[] getMembers()
Specified by:
getMembers in interface BaseClusterMBean
Returns:
the Member MBean OBJECT_NAMES

addServer

@Deprecated
public void addServer(String name,
                                 String[] urls,
                                 String clusterd)
               throws JMException
Deprecated. addServer(String, String[], String, String, String)

Calls addServer(String, String[], String, String, String)(name, urls, clusterd, null, null)

Specified by:
addServer in interface BaseClusterMBean
Parameters:
name - logical name of the server
urls - array of urls for connection
clusterd - possible clusterdaemon managing the server
Throws:
JMException - problem when trying to a server to a cluster

addServer

public void addServer(String svname,
                      String[] urls,
                      String cdn,
                      String username,
                      String password)
               throws 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
urls - array of urls for connection
cdn - clusterDaemon used to manage te server
username - user name to use when connecting if any. Null otherwise.
password - password to use when connecting if any. Null otherwise.
Throws:
JMException - problem when trying to a server to a cluster

removeServer

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

Specified by:
removeServer in interface BaseClusterMBean
Parameters:
svname - logical name of the server

isMember

public boolean isMember(String serverName)
Check if a server is member of a cluster. Suppose that the ClusterMember is inserted in the 'members' table using its name as key.

Parameters:
serverName - name of the server the caller would like to know if it is a cluster member
Returns:
true if the server is member of the current cluster

startit

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

Specified by:
startit in interface BaseClusterMBean
Throws:
JMException

stopit

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

Specified by:
stopit in interface BaseClusterMBean
Throws:
JMException

deployModule

public void deployModule(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(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(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(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


Copyright © 2010 OW2 Consortium. All Rights Reserved.