org.objectweb.jonas.management.monitoring
Class DomainMonitor

java.lang.Object
  extended by org.objectweb.jonas.management.monitoring.DomainMonitor

public class DomainMonitor
extends Object

This class represents the Master Server of the Domain. It manages the servers and the clusters in the domain.

Author:
danesa, durieuxp refactoring

Constructor Summary
DomainMonitor(String domain)
          Constructor
 
Method Summary
 ServerProxy addLocalServer(String svname, Collection urls)
          Add the local J2EEServer to the list of servers
 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
 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 Server by its name
 void forgetAllDeploy()
          Forget all deploy information
 Collection getClusterDaemonList()
          Get the list of all ClusterDaemonProxy
 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[] getConnectorServerURLs(String serverName)
          Return the JMX ConnectorServerURLs of 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.
 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()
          Get the list of all clusters of any type
 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.
 boolean registerDeployAction(DeployAction action)
          Register a DeployAction
 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)
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()

addLocalServer

public ServerProxy addLocalServer(String svname,
                                  Collection urls)
Add the local J2EEServer to the list of servers


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 Server 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.

getServerList

public Collection getServerList()
Get the list of ServerProxy

Returns:
Collection of all ServerProxy in the Domain

getClusterDaemonList

public Collection getClusterDaemonList()
Get the list of all ClusterDaemonProxy


getTotalClusterList

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

Returns:
Collection of all Clusters in the domain

getLogicalClusterList

public Collection getLogicalClusterList()
Get the list of 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 -

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.

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.

getConnectorServerURLs

public String[] getConnectorServerURLs(String serverName)
Return the JMX ConnectorServerURLs of a given server in the domain. Use for that, the ServerProxy associated to the server.

Parameters:
serverName - the name of the server
Returns:
the ConnectorServerURLs provided by its ServerProxy if there is a ServerProxy object in this domain that corresponds to the server named serverName. Null if thger is no such serverProxy or if the serverName is null. Alse null if the ConnectorServerURLs list 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

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


Copyright © 2007 OW2 Consortium. All Rights Reserved.