org.ow2.jonas.cluster.daemon
Class ClusterDaemon

java.lang.Object
  extended by org.ow2.jonas.cluster.daemon.ClusterDaemon
All Implemented Interfaces:
ClusterDaemonMBean

public class ClusterDaemon
extends Object
implements ClusterDaemonMBean

ClusterDaemon is provided to control JOnAS instances remotely. The ClusterDaemon is an independent Java program, and runs on every node (machine) in the cluster. It receives remote commands (JMX), and does something such as starting or stopping JOnAS instances.

Author:
zhengzz (initial version for PKUAS), Benoit Pelletier (integration in JOnAS), eyindanga (Administration), S. Ali Tokmen (JMX security)

Field Summary
static String JONAS_CMD_NAME_UNIX_DEF
          JOnAS command name in unix environmment.
static String JONAS_CMD_NAME_WIN_DEF
          JOnAS command name in windows environmment.
static String LONG_TYPE_DYN_INFO
          Used to exclude attribute that are not Long typed when getting.
static int SLEEP_DELAY
          Sleep before exit of JVM.
 
Method Summary
 void addServer(String name, String description, String jonasRoot, String jonasBase, String javaHome, String xprem, String autoBoot, String jonasCmd, String saveIt)
          Add a server to cluster daemon control.
 void buildRuntimeInfo()
          Gets runtime info of current platform.
 boolean checkServerState(String srvName)
          Retrieve the state of the given controlled server.
 void displayDynamicAttributes()
          displaying dynamic host attributes.
 String getAutoBoot4Server(String name)
          True if autoboot is enabled for the given server.
 ArrayList getControlledServersNames()
          Controlled servers.
 Hashtable<String,String> getDynamicHostAttributes()
          Get dynamic host attributes.
 String getJavaHome4Server(String name)
          (MBean interface).
 String getJmxUrl()
          Get jmx url of the cluster daemon.
 String getJonasBase4Server(String name)
          (MBean interface).
 String getJonasCmd4Server(String name)
          Get command for the given server.
 String getJonasRoot4Server(String name)
          (MBean interface).
 String getName()
           
 String getobjectName()
           
 String getOperatingSystemArch()
          Gets OS architecture
 String getOperatingSystemAvailableProcessors()
          Get available processors of the OS.
 String getOperatingSystemName()
          Get OS name.
 String getOperatingSystemVersion()
          Get OS version.
 String getOsCurrentUsedSpace()
          Getting Operating system Current used space.
 String getOsTotalSpace()
          Getting Operating system Current used space.
 String getRunTimeSpecVendor()
          Get spec.
 String getRunTimeSpecVersion()
          Get runtime spec.
 String getRunTimeVmName()
          Get runtime vm name.
 String getRunTimeVmVendor()
          Get runtime vendor.
 String getRunTimeVmVersion()
          Get runtime vm version.
 String getVmCurrentUsedHeapMemory()
          Getting remote Vm's Current used Heap memory.
 String getVmCurrentUsedMemory()
          Get remote Vm used Memory.
 String getVmCurrentUsedNonHeapMemory()
          Getting remote Vm's Current used non Heap memory.
 String getVmTotalMemory()
          Getting remote Vm Total Memory.
 String getXprm4Server(String name)
          Get extra parameters for the given server.
 void haltJOnAS(String name)
          Halt a JOnAS instance (MBean interface).
 void initHostInfos()
          Initializes platform infos.
 boolean iseventProvider()
           
 boolean isstateManageable()
           
 boolean isstatisticsProvider()
           
static void main(String[] args)
          Main method
 void modifyServer(String name, String description, String javaHome, String jonasRoot, String jonasBase, String xprm, String autoBoot, String jonasCmd)
          Modify a server configuration (MBean interface).
 int pingJOnAS(String name)
          Ping a JOnAS instance (MBean interface).
 void reloadConfiguration()
          Reload the configuration (MBean interface).
 void removeServer(String serverName)
          Remove a server configuration (MBean interface).
 void removeServer(String serverName, String saveIt)
          Remove This server from cluster daemon control.
 void saveConfiguration()
          Save current configuration
 ArrayList serversNames()
          Get jmx url of the cluster daemon.
 void setJmxUrl(String url)
           
 void setobjectName(String name)
          Sets the object name of this mbean.
 void setOperatingSystemArch(String operatingSystemArch)
          Sets OS Architecture
 void setOperatingSystemAvailableProcessors(String operatingSystemAvailableProcessors)
           
 void setOperatingSystemName(String operatingSystemName)
          Sets operating system name.
 void setOperatingSystemVersion(String operatingSystemVersion)
          Sets OS version
 void setRunTimeSpecVendor(String runTimeSpecVendor)
          Sets Runtime vendor.
 void setRunTimeSpecVersion(String runTimeSpecVersion)
          Sets Runtime spec.
 void setRunTimeVmName(String runTimeVmName)
           
 void setRunTimeVmVendor(String runTimeVmVendor)
          Sets Runtime VM vendor.
 void setRunTimeVmVersion(String runTimeVmVersion)
          Sets runtime VM version.
 void start(String[] args)
          Main function.
 String startAllJOnAS(String domainName, String prm)
          Start all the JOnAS instances configured with auto-reboot.
 void startJOnAS(String name, String domainName, String prm)
          Start a JOnAS instance (MBean interface).
 String stopAllJOnAS()
          Stop all the JOnAS instances.
 void stopClusterDaemon()
          Stop the current instance.
 void stopJOnAS(String name)
          Stop a JOnAS instance (MBean interface).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SLEEP_DELAY

public static final int SLEEP_DELAY
Sleep before exit of JVM.

See Also:
Constant Field Values

LONG_TYPE_DYN_INFO

public static final String LONG_TYPE_DYN_INFO
Used to exclude attribute that are not Long typed when getting. Operating System dynamic attributes

See Also:
Constant Field Values

JONAS_CMD_NAME_WIN_DEF

public static final String JONAS_CMD_NAME_WIN_DEF
JOnAS command name in windows environmment.

See Also:
Constant Field Values

JONAS_CMD_NAME_UNIX_DEF

public static final String JONAS_CMD_NAME_UNIX_DEF
JOnAS command name in unix environmment.

See Also:
Constant Field Values
Method Detail

checkServerState

public boolean checkServerState(String srvName)
                         throws ClusterDaemonException
Retrieve the state of the given controlled server.

Specified by:
checkServerState in interface ClusterDaemonMBean
Parameters:
srvName - server's name.
Returns:
true if the server is running
Throws:
ClusterDaemonException - any.

buildRuntimeInfo

public void buildRuntimeInfo()
Gets runtime info of current platform.


start

public void start(String[] args)
           throws ClusterDaemonException
Main function.

Parameters:
args - arguments list
Throws:
ClusterDaemonException - if an error occurs

displayDynamicAttributes

public void displayDynamicAttributes()
displaying dynamic host attributes.


main

public static void main(String[] args)
Main method

Parameters:
args - the arguments of the cluster daemon

getobjectName

public String getobjectName()
Specified by:
getobjectName in interface ClusterDaemonMBean
Returns:
Object Name.

setobjectName

public void setobjectName(String name)
Sets the object name of this mbean.

Specified by:
setobjectName in interface ClusterDaemonMBean
Parameters:
name - the Object Name

iseventProvider

public boolean iseventProvider()
Specified by:
iseventProvider in interface ClusterDaemonMBean
Returns:
true if it is an event provider

isstateManageable

public boolean isstateManageable()
Specified by:
isstateManageable in interface ClusterDaemonMBean
Returns:
true if this managed object implements J2EE State Management Model

isstatisticsProvider

public boolean isstatisticsProvider()
Specified by:
isstatisticsProvider in interface ClusterDaemonMBean
Returns:
true if this managed object implements the J2EE StatisticProvider Model

getJavaHome4Server

public String getJavaHome4Server(String name)
                          throws ClusterDaemonException
(MBean interface).

Specified by:
getJavaHome4Server in interface ClusterDaemonMBean
Parameters:
name - JOnAS instance name
Returns:
the JAVA_HOME for a specified server name
Throws:
ClusterDaemonException - any.

getJonasBase4Server

public String getJonasBase4Server(String name)
                           throws ClusterDaemonException
(MBean interface).

Specified by:
getJonasBase4Server in interface ClusterDaemonMBean
Parameters:
name - JOnAS instance name
Returns:
the JONAS_BASE for a specified server name
Throws:
ClusterDaemonException - any.

getJonasRoot4Server

public String getJonasRoot4Server(String name)
                           throws ClusterDaemonException
(MBean interface).

Specified by:
getJonasRoot4Server in interface ClusterDaemonMBean
Parameters:
name - JOnAS instance name
Returns:
the JONAS_ROOT for a specified server name
Throws:
ClusterDaemonException - any.

getJonasCmd4Server

public String getJonasCmd4Server(String name)
                          throws ClusterDaemonException
Description copied from interface: ClusterDaemonMBean
Get command for the given server.

Specified by:
getJonasCmd4Server in interface ClusterDaemonMBean
Parameters:
name - JOnAS instance name
Returns:
the user command for a specified server name.
Throws:
ClusterDaemonException - any.

getXprm4Server

public String getXprm4Server(String name)
                      throws ClusterDaemonException
Description copied from interface: ClusterDaemonMBean
Get extra parameters for the given server.

Specified by:
getXprm4Server in interface ClusterDaemonMBean
Parameters:
name - JOnAS instance name
Returns:
the xprm for a specified server name
Throws:
ClusterDaemonException - any.

getAutoBoot4Server

public String getAutoBoot4Server(String name)
                          throws ClusterDaemonException
Description copied from interface: ClusterDaemonMBean
True if autoboot is enabled for the given server.

Specified by:
getAutoBoot4Server in interface ClusterDaemonMBean
Parameters:
name - JOnAS instance name
Returns:
the autoboot value for a specified server name
Throws:
ClusterDaemonException - any.

removeServer

public void removeServer(String serverName)
                  throws ClusterDaemonException
Remove a server configuration (MBean interface).

Specified by:
removeServer in interface ClusterDaemonMBean
Parameters:
name - server name
Throws:
ClusterDaemonException - if an error occurs

modifyServer

public void modifyServer(String name,
                         String description,
                         String javaHome,
                         String jonasRoot,
                         String jonasBase,
                         String xprm,
                         String autoBoot,
                         String jonasCmd)
                  throws ClusterDaemonException
Modify a server configuration (MBean interface).

Specified by:
modifyServer in interface ClusterDaemonMBean
Parameters:
name - server name
description - server description
javaHome - JAVA_HOME dir
jonasBase - JONAS_BASE dir
jonasRoot - JONAS_ROOT dir
xprm - extra JVM parameters
autoBoot - automatic start
jonasCmd - user command
Throws:
ClusterDaemonException - if an error occurs

reloadConfiguration

public void reloadConfiguration()
                         throws ClusterDaemonException
Reload the configuration (MBean interface).

Specified by:
reloadConfiguration in interface ClusterDaemonMBean
Throws:
ClusterDaemonException - if an error occurs

startJOnAS

public void startJOnAS(String name,
                       String domainName,
                       String prm)
Start a JOnAS instance (MBean interface).

Specified by:
startJOnAS in interface ClusterDaemonMBean
Parameters:
name - instance name
domainName - domain name
prm - extra parameters
Throws:
ClusterDaemonException - if an error occurs

stopJOnAS

public void stopJOnAS(String name)
               throws ClusterDaemonException
Stop a JOnAS instance (MBean interface).

Specified by:
stopJOnAS in interface ClusterDaemonMBean
Parameters:
name - instance name
Throws:
ClusterDaemonException - if an error occurs

haltJOnAS

public void haltJOnAS(String name)
               throws ClusterDaemonException
Halt a JOnAS instance (MBean interface).

Specified by:
haltJOnAS in interface ClusterDaemonMBean
Parameters:
name - instance name
Throws:
ClusterDaemonException - if an error occurs

pingJOnAS

public int pingJOnAS(String name)
              throws ClusterDaemonException
Ping a JOnAS instance (MBean interface).

Specified by:
pingJOnAS in interface ClusterDaemonMBean
Parameters:
name - instance name
Returns:
exit code of the ping (0 ok, 1 ko)
Throws:
ClusterDaemonException - if an error occurs

startAllJOnAS

public String startAllJOnAS(String domainName,
                            String prm)
                     throws ClusterDaemonException
Start all the JOnAS instances configured with auto-reboot.

Specified by:
startAllJOnAS in interface ClusterDaemonMBean
Parameters:
domainName - domain name
prm - extra parameters
Returns:
the nodes list with an indicator started/starting failed
Throws:
ClusterDaemonException - any.

stopAllJOnAS

public String stopAllJOnAS()
Stop all the JOnAS instances.

Specified by:
stopAllJOnAS in interface ClusterDaemonMBean
Returns:
the nodes list with an indicator stopped/stopping failed
Throws:
ClusterDaemonException - any.

stopClusterDaemon

public void stopClusterDaemon()
Stop the current instance.

Specified by:
stopClusterDaemon in interface ClusterDaemonMBean

getName

public String getName()
Returns:
clusterd name.

getControlledServersNames

public ArrayList getControlledServersNames()
                                    throws ClusterDaemonException
Controlled servers.

Specified by:
getControlledServersNames in interface ClusterDaemonMBean
Returns:
cluster daemon controlled server names.
Throws:
ClusterDaemonException - any.

serversNames

public ArrayList serversNames()
                       throws ClusterDaemonException
Get jmx url of the cluster daemon.

Specified by:
serversNames in interface ClusterDaemonMBean
Returns:
clusterd jmx url
Throws:
ClusterDaemonException - any.

getJmxUrl

public String getJmxUrl()
Get jmx url of the cluster daemon.

Specified by:
getJmxUrl in interface ClusterDaemonMBean
Returns:
clusterd jmx url

setJmxUrl

public void setJmxUrl(String url)
Parameters:
url - the url used by the JMX Remote connector

getOperatingSystemAvailableProcessors

public String getOperatingSystemAvailableProcessors()
Get available processors of the OS.

Specified by:
getOperatingSystemAvailableProcessors in interface ClusterDaemonMBean
Returns:
Operating system processors number

setOperatingSystemAvailableProcessors

public void setOperatingSystemAvailableProcessors(String operatingSystemAvailableProcessors)
Parameters:
operatingSystemAvailableProcessors. -

getOperatingSystemName

public String getOperatingSystemName()
Get OS name.

Specified by:
getOperatingSystemName in interface ClusterDaemonMBean
Returns:
OS name
Throws:
ClusterDaemonException - any.

setOperatingSystemName

public void setOperatingSystemName(String operatingSystemName)
Sets operating system name.

Parameters:
operatingSystemName -

getOperatingSystemVersion

public String getOperatingSystemVersion()
Get OS version.

Specified by:
getOperatingSystemVersion in interface ClusterDaemonMBean
Returns:
OS version
Throws:
ClusterDaemonException - any.

setOperatingSystemVersion

public void setOperatingSystemVersion(String operatingSystemVersion)
Sets OS version

Parameters:
operatingSystemVersion -

getRunTimeSpecVendor

public String getRunTimeSpecVendor()
Get spec. vendor.

Specified by:
getRunTimeSpecVendor in interface ClusterDaemonMBean
Returns:
Spec vendor
Throws:
ClusterDaemonException - any.

setRunTimeSpecVendor

public void setRunTimeSpecVendor(String runTimeSpecVendor)
Sets Runtime vendor.

Parameters:
runTimeSpecVendor -

getRunTimeSpecVersion

public String getRunTimeSpecVersion()
Get runtime spec. version.

Specified by:
getRunTimeSpecVersion in interface ClusterDaemonMBean
Returns:
Spec version
Throws:
ClusterDaemonException - any.

setRunTimeSpecVersion

public void setRunTimeSpecVersion(String runTimeSpecVersion)
Sets Runtime spec. version.

Parameters:
runTimeSpecVersion -

getRunTimeVmName

public String getRunTimeVmName()
Get runtime vm name.

Specified by:
getRunTimeVmName in interface ClusterDaemonMBean
Returns:
the Vm name
Throws:
ClusterDaemonException - any.

setRunTimeVmName

public void setRunTimeVmName(String runTimeVmName)
Parameters:
runTimeVmName -

getRunTimeVmVendor

public String getRunTimeVmVendor()
Get runtime vendor.

Specified by:
getRunTimeVmVendor in interface ClusterDaemonMBean
Returns:
Vm vendor
Throws:
ClusterDaemonException - any.

setRunTimeVmVendor

public void setRunTimeVmVendor(String runTimeVmVendor)
Sets Runtime VM vendor.

Parameters:
runTimeVmVendor -

getRunTimeVmVersion

public String getRunTimeVmVersion()
Get runtime vm version.

Specified by:
getRunTimeVmVersion in interface ClusterDaemonMBean
Returns:
Vm version
Throws:
ClusterDaemonException - any.

setRunTimeVmVersion

public void setRunTimeVmVersion(String runTimeVmVersion)
Sets runtime VM version.

Parameters:
runTimeVmVersion -

getDynamicHostAttributes

public Hashtable<String,String> getDynamicHostAttributes()
                                                  throws ClusterDaemonException
Get dynamic host attributes.

Specified by:
getDynamicHostAttributes in interface ClusterDaemonMBean
Returns:
hashtable with dynamic attributes keys and values.
Throws:
ClusterDaemonException - any.

initHostInfos

public void initHostInfos()
                   throws ClusterDaemonException
Initializes platform infos.

Throws:
ClusterDaemonException - any.

getOperatingSystemArch

public String getOperatingSystemArch()
Gets OS architecture

Specified by:
getOperatingSystemArch in interface ClusterDaemonMBean
Returns:
operating system architecture

setOperatingSystemArch

public void setOperatingSystemArch(String operatingSystemArch)
Sets OS Architecture

Parameters:
operatingSystemArch -

getVmCurrentUsedNonHeapMemory

public String getVmCurrentUsedNonHeapMemory()
                                     throws ClusterDaemonException
Getting remote Vm's Current used non Heap memory.

Specified by:
getVmCurrentUsedNonHeapMemory in interface ClusterDaemonMBean
Returns:
the value of Vm's Current used non Heap memory
Throws:
ClusterDaemonException - any.

getOsCurrentUsedSpace

public String getOsCurrentUsedSpace()
                             throws ClusterDaemonException
Getting Operating system Current used space.

Specified by:
getOsCurrentUsedSpace in interface ClusterDaemonMBean
Returns:
the value of Operating system Current used space
Throws:
ClusterDaemonException - any.

getOsTotalSpace

public String getOsTotalSpace()
                       throws ClusterDaemonException
Getting Operating system Current used space.

Specified by:
getOsTotalSpace in interface ClusterDaemonMBean
Returns:
the value of Operating system Total space
Throws:
ClusterDaemonException - any.

getVmCurrentUsedHeapMemory

public String getVmCurrentUsedHeapMemory()
                                  throws ClusterDaemonException
Getting remote Vm's Current used Heap memory.

Specified by:
getVmCurrentUsedHeapMemory in interface ClusterDaemonMBean
Returns:
the value of Vm's Current used Heap memory
Throws:
ClusterDaemonException - any.

getVmCurrentUsedMemory

public String getVmCurrentUsedMemory()
                              throws ClusterDaemonException
Get remote Vm used Memory.

Specified by:
getVmCurrentUsedMemory in interface ClusterDaemonMBean
Returns:
the value of current used memory
Throws:
ClusterDaemonException - any.

getVmTotalMemory

public String getVmTotalMemory()
                        throws ClusterDaemonException
Getting remote Vm Total Memory.

Specified by:
getVmTotalMemory in interface ClusterDaemonMBean
Returns:
the value of Vm Total memory
Throws:
ClusterDaemonException - any.

addServer

public void addServer(String name,
                      String description,
                      String jonasRoot,
                      String jonasBase,
                      String javaHome,
                      String xprem,
                      String autoBoot,
                      String jonasCmd,
                      String saveIt)
               throws ClusterDaemonException
Add a server to cluster daemon control.

Specified by:
addServer in interface ClusterDaemonMBean
Parameters:
name - the server name
description - server description
javaHome - path to JRE
jonasRoot - path to bin repository
JonasBase - path to lib repository
xprem - extra parameter e.g: -Djava.net.preferIPv4Stack=true
autoBoot - true if the server is launched when cluster daemon starts
jonasCmd - user command
saveIt - boolean
Throws:
ClusterDaemonException - any.

removeServer

public void removeServer(String serverName,
                         String saveIt)
                  throws ClusterDaemonException
Remove This server from cluster daemon control.

Specified by:
removeServer in interface ClusterDaemonMBean
Parameters:
serverName - The server to remove
saveIt - True to flush clusterd configuration
Throws:
ClusterDaemonException - any.

saveConfiguration

public void saveConfiguration()
                       throws ClusterDaemonException
Save current configuration

Specified by:
saveConfiguration in interface ClusterDaemonMBean
Throws:
ClusterDaemonException - any.


Copyright © 2010 OW2 Consortium. All Rights Reserved.