org.ow2.jonas.lib.management.domain
Class DomainMonitor

java.lang.Object
  extended by org.ow2.jonas.lib.management.domain.DomainMonitor

public class DomainMonitor
extends Object

A DomainMonitor instance is created for each Master Server in the domain. It manages the servers and the clusters in the domain.

Author:
danesa, durieuxp refactoring, S. Ali Tokmen

Constructor Summary
DomainMonitor(String domain, String serverName)
          Constructor
 
Method Summary
 void addAuthenticationInformation(String name, String username, String password)
          Adds authentication information for a given server or the domain.
 String createCluster(String name)
          Create a logical cluster.
 void deployOnTarget(String target, String fileName)
          Deploy a module on a target which may be a server or a cluster
 void discoveryNotification(DiscoveryEvent event)
          Handle notifications from Discovery Service.
 void discoveryNotificationForClusterd(DiscoveryEvent event)
          Handles Notifications from Discovery Service for clusterd daemons
 BaseCluster findCluster(String name)
          Get a Cluster by its name.
 ClusterDaemonProxy findClusterDaemonProxy(String name)
          Get a ClusterDaemon by its name
 ServerProxy findServerProxy(String name)
          Get a ServerProxy by its name.
 void forgetAllDeploy()
          Forget all deploy information
 AuthenticationInformation getAuthenticationInformation(String name)
          Gets the authentication information for a given server or cluster daemon name defined in the domain.xml file.
 Collection<ClusterDaemonProxy> getClusterDaemonList()
           
 String[] getClusterDaemons()
           
 String getClusterdaemonState(String clusterdaemonName)
          Return the state of a cluster daemon in the domain.
 String[] getClusters()
          MBean method.
 String getClusterState(String clusterName)
          Return the state of a cluster in the domain.
 String getClusterType(String clusterName)
          Return the type of a cluster in the domain.
 MBeanServerConnection getConnection(String serverName)
          Return a JMX connection to a given server in the domain.
 String[] getDeployServers(String filename)
          Get the list of server where a file is being deployed
 String getDeployState(String filename, String servername)
          Get the current state (string form) of deployment operation
 String getDescription()
           
 String getDomainName()
           
 String getErrorMessage(String filename, String servername)
          Get the error message associated to the error state
static DomainMonitor getInstance()
          Singleton: Each server (master or slave) must have 1 unique DomainMonitor object.
 JmxService getJmxService()
           
 Collection getLogicalClusterList()
          Get the list of logical clusters.
 int getMonitoringPeriod()
           
 String[] getProxys()
          MBean method To be replaced by J2EEDomain.getServers()
 String getServerClusterdaemon(String serverName)
          Return the cluster daemon name of a server in the domain.
 Collection getServerList()
          Get the list of ServerProxy.
 String[] getServerNames()
           
 String[] getServerNames(String clusterName)
           
 String[] getServers(boolean started)
           
 String[] getServersInCluster(String clusterName)
           
 String[] getServersNotInCluster(String clusterName)
           
 String getServerState(String serverName)
          Return the state of a server in the domain.
 Collection getTotalClusterList()
           
 void haltServer(String serverName)
          Halt a managed JOnAS Server
 boolean isCluster(String clusterName)
          Check if a cluster exists.
 boolean isMaster()
           
 void notifyServerProxyRunning(ServerProxy sp)
          Notify to all the cluster factories that a server started in the domain
 void readDomainConfig()
           
 void refreshStates()
          Try to refresh the server states TODO notify thread only.
 void registerClusterDaemonProxy(String cdName, String serverName, Collection urls)
          Register a cluster daemon proxy in the domain.
 boolean registerDeployAction(DeployAction action)
          Register a DeployAction
 void removeAuthenticationInformation(String name)
          Removes authentication information for a given server or the domain.
 void setJmxService(JmxService jmxService)
           
 void setMaster()
           
 void setMonitoringPeriod(int sec)
           
 boolean startRemoteTarget(String target)
          Start a server or a cluster
 void startServer(String serverName)
          Start a managed JOnAS Server
 boolean stopRemoteTarget(String target)
          Stop a server or a cluster
 void stopServer(String serverName)
          Stop a managed JOnAS Server
 void unDeployOnTarget(String target, String fileName)
          Undeploy a module on a target which may be a server or a cluster
 boolean uploadDeployFileOn(String target, String filename)
          Upload and deploy a module on a target.
 void uploadDeployOnTarget(String target, String fileName, boolean replaceExisting)
          Upload a module on a target which may be a server or a cluster
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomainMonitor

public DomainMonitor(String domain,
                     String serverName)
Constructor

Method Detail

getInstance

public static DomainMonitor getInstance()
Singleton: Each server (master or slave) must have 1 unique DomainMonitor object.

Returns:
the unique instance of the DomainMonitor

setMaster

public void setMaster()

isMaster

public boolean isMaster()

readDomainConfig

public void readDomainConfig()

getDescription

public String getDescription()

getDomainName

public String getDomainName()

setMonitoringPeriod

public void setMonitoringPeriod(int sec)

getMonitoringPeriod

public int getMonitoringPeriod()

findCluster

public BaseCluster findCluster(String name)
Get a Cluster by its name. Look in all cluster factories.

Parameters:
name - The name of the cluster
Returns:
the Cluster or null if unknown by the domain.

findServerProxy

public ServerProxy findServerProxy(String name)
Get a ServerProxy by its name.

Parameters:
name - The name of the server
Returns:
the ServerProxy or null if unknown by the domain.

findClusterDaemonProxy

public ClusterDaemonProxy findClusterDaemonProxy(String name)
Get a ClusterDaemon by its name

Parameters:
name - The name of the clusterdaemon
Returns:
the ClusterDaemonProxy or null if unknown by the domain.

registerClusterDaemonProxy

public void registerClusterDaemonProxy(String cdName,
                                       String serverName,
                                       Collection urls)
                                throws MalformedObjectNameException
Register a cluster daemon proxy in the domain.

Parameters:
cdName - the cluster daemon's name
serverName - name of the current jonas server (master instance)
urls - connection urls for the cluster daemon
Throws:
MalformedObjectNameException - can't create ObjectName for the ClusterDaemon's MBean

getAuthenticationInformation

public AuthenticationInformation getAuthenticationInformation(String name)
Gets the authentication information for a given server or cluster daemon name defined in the domain.xml file.

Parameters:
name - Name of the server, null to get default.
Returns:
Authentication information for server or cluster daemon name, if no authentication information defined for that name the default information for this domain, finally null if no default specified either.

addAuthenticationInformation

public void addAuthenticationInformation(String name,
                                         String username,
                                         String password)
                                  throws UnsupportedEncodingException
Adds authentication information for a given server or the domain.

Parameters:
name - Name of the server, null to change default.
username - User name to use when connecting.
password - Password to use when connecting. Must be passed in clear format, will be encoded by this method. throws UnsupportedEncodingException If encoding the password fails.
Throws:
UnsupportedEncodingException

removeAuthenticationInformation

public void removeAuthenticationInformation(String name)
Removes authentication information for a given server or the domain.

Parameters:
name - Name of the server, null to change domain's default.

getServerList

public Collection getServerList()
Get the list of ServerProxy.

Returns:
Collection of all ServerProxy in the Domain

getClusterDaemonList

public Collection<ClusterDaemonProxy> getClusterDaemonList()
Returns:
Get the list of all ClusterDaemonProxy.

getTotalClusterList

public Collection getTotalClusterList()
Returns:
Get the list of all clusters of any type

getLogicalClusterList

public Collection getLogicalClusterList()
Get the list of logical clusters.

Returns:
the list of the logical clusters

getProxys

public String[] getProxys()
MBean method To be replaced by J2EEDomain.getServers()

Returns:
Array of OBJECT_NAMEs of all ServerProxy

getClusters

public String[] getClusters()
MBean method.

Returns:
Array of OBJECT_NAMEs of all cluster MBeans

discoveryNotification

public void discoveryNotification(DiscoveryEvent event)
Handle notifications from Discovery Service.

Parameters:
event - received DiscoveryEvent.

discoveryNotificationForClusterd

public void discoveryNotificationForClusterd(DiscoveryEvent event)
Handles Notifications from Discovery Service for clusterd daemons

Parameters:
event -

notifyServerProxyRunning

public void notifyServerProxyRunning(ServerProxy sp)
Notify to all the cluster factories that a server started in the domain

Parameters:
sp - the server's proxy

registerDeployAction

public boolean registerDeployAction(DeployAction action)
Register a DeployAction

Returns:
true if correctly aded in the list

getDeployServers

public String[] getDeployServers(String filename)
Get the list of server where a file is being deployed

Parameters:
filename - file to deploy
Returns:
server name

getDeployState

public String getDeployState(String filename,
                             String servername)
Get the current state (string form) of deployment operation

Parameters:
filename - file to deploy
servername - server where deployment is done
Returns:
one of "progress","ok","fail"

getErrorMessage

public String getErrorMessage(String filename,
                              String servername)
Get the error message associated to the error state

Parameters:
filename - file to deploy
servername - server where deployment is done
Returns:
error message

forgetAllDeploy

public void forgetAllDeploy()
Forget all deploy information


refreshStates

public void refreshStates()
Try to refresh the server states TODO notify thread only.


getConnection

public MBeanServerConnection getConnection(String serverName)
Return a JMX connection to a given server in the domain. Use for that, the ServerProxy associated to the server or the current MBeanServerConnection if server is the current server.

Parameters:
serverName - the name of the server
Returns:
the connection provided by its ServerProxy if there is a ServerProxy object in this domain that corresponds to the server named serverName. Null if there is no such serverProxy or if the serverName is null.

getServers

public String[] getServers(boolean started)
Parameters:
started - if true, return only the servers which are in RUNNING state anyway, don't pat attention to the servers state
Returns:
an array containing the OBJECT_NAMEs of the J2EEServer MBeans associated to the managed servers in this domain.

getServerNames

public String[] getServerNames()
Returns:
an array containing the names of the managed servers in this domain.

getServerNames

public String[] getServerNames(String clusterName)
Parameters:
clusterName - the cluster name
Returns:
an array containing the names of the managed servers in the cluster.

getServerState

public String getServerState(String serverName)
Return the state of a server in the domain. Used by JonasAdmin.

Parameters:
serverName - the server name
Returns:
Get the state of a server in the domain

getClusterState

public String getClusterState(String clusterName)
Return the state of a cluster in the domain. Used by JonasAdmin.

Parameters:
clusterName - the cluster name
Returns:
Get the state of a cluster in the domain

getClusterdaemonState

public String getClusterdaemonState(String clusterdaemonName)
Return the state of a cluster daemon in the domain. Used by JonasAdmin.

Parameters:
clusterdaemonName - the cluster daemon name
Returns:
Get the state of a cluster daemon in the domain

getClusterType

public String getClusterType(String clusterName)
Return the type of a cluster in the domain. Used by JonasAdmin.

Parameters:
clusterName - the cluster name
Returns:
Get the type of a cluster in the domain

getClusterDaemons

public String[] getClusterDaemons()
Returns:
an array containing the OBJECT_NAMEs of the ClusterDaemons in this domain

createCluster

public String createCluster(String name)
Create a logical cluster.

Parameters:
name - the name of the cluster
Returns:
the OBJECT_NAME of the associated MBean

startServer

public void startServer(String serverName)
Start a managed JOnAS Server

Parameters:
serverName - name of the server

haltServer

public void haltServer(String serverName)
Halt a managed JOnAS Server

Parameters:
serverName - name of the server

stopServer

public void stopServer(String serverName)
Stop a managed JOnAS Server

Parameters:
serverName - name of the server

deployOnTarget

public void deployOnTarget(String target,
                           String fileName)
Deploy a module on a target which may be a server or a cluster

Parameters:
target - target name
fileName - file containing the module

uploadDeployOnTarget

public void uploadDeployOnTarget(String target,
                                 String fileName,
                                 boolean replaceExisting)
Upload a module on a target which may be a server or a cluster

Parameters:
target - target name
fileName - file containing the module
replaceExisting - true if the file can replace an existing one (same name)

unDeployOnTarget

public void unDeployOnTarget(String target,
                             String fileName)
Undeploy a module on a target which may be a server or a cluster

Parameters:
target - target name
fileName - file containing the module

stopRemoteTarget

public boolean stopRemoteTarget(String target)
                         throws JMException
Stop a server or a cluster

Parameters:
target - the name of the target to be stoped
Returns:
true is success, false otherwise
Throws:
JMException - problem when trying to stop

startRemoteTarget

public boolean startRemoteTarget(String target)
                          throws JMException
Start a server or a cluster

Parameters:
target - the name of the target to be started
Returns:
true is success, false otherwise
Throws:
JMException - problem when trying to start

uploadDeployFileOn

public boolean uploadDeployFileOn(String target,
                                  String filename)
Upload and deploy a module on a target.

Parameters:
target - the target name
filename - the file containing the module
Returns:
true is success, false otherwise

isCluster

public boolean isCluster(String clusterName)
Check if a cluster exists.

Parameters:
clusterName - the name of the cluster to check
Returns:
true if a cluster with this name exists

getServersNotInCluster

public String[] getServersNotInCluster(String clusterName)
Parameters:
clusterName - Name of the cluster
Returns:
the servers in the domain that doesn't belong to the cluster

getServersInCluster

public String[] getServersInCluster(String clusterName)
Parameters:
clusterName - Name of the cluster
Returns:
the servers in the domain that belong to the cluster

getServerClusterdaemon

public String getServerClusterdaemon(String serverName)
Return the cluster daemon name of a server in the domain. Used by JonasAdmin.

Parameters:
serverName - the server name
Returns:
Get the cluster daemon name of a server in the domain

setJmxService

public void setJmxService(JmxService jmxService)
Parameters:
jmxService - the jmxService to set

getJmxService

public JmxService getJmxService()
Returns:
reference to the jmxService


Copyright © 2010 OW2 Consortium. All Rights Reserved.