org.objectweb.jonas.management.monitoring
Class DomainMonitor

java.lang.Object
  extended by org.objectweb.jonas.management.monitoring.DomainMonitor
All Implemented Interfaces:
DomainMonitorMBean

public class DomainMonitor
extends java.lang.Object
implements DomainMonitorMBean

This class represents the Master Server of the Domain. Is created by the DiscoveryService if it detects it is the master. It is not instanciated for slave servers.

Author:
danesa, durieuxp refactoring, S. Ali Tokmen

Constructor Summary
DomainMonitor(java.lang.String domain)
          Constructor
 
Method Summary
 void addAuthenticationInformation(java.lang.String name, java.lang.String username, java.lang.String password)
          Adds authentication information for a given server or the domain.
 ServerProxy addLocalServer(java.lang.String svname)
          Add the local J2EEServer to the list of servers.
 LogicalCluster createLogicalCluster(java.lang.String name)
          Create a logical cluster
 void discoveryNotification(DiscEvent event)
          Handle Notifications from Discovery Service
 BaseCluster findCluster(java.lang.String name)
          Get a Cluster by its name.
 ClusterDaemonProxy findClusterDaemonProxy(java.lang.String name)
          Get a ClusterDaemon by its name
 J2EEServer findServer(java.lang.String name)
          Get a Server by its name
 ServerProxy findServerProxy(java.lang.String name)
          Get a Server by its name
 void forgetAllDeploy()
          Forget all deploy information
 AuthenticationInformation getAuthenticationInformation(java.lang.String name)
          Gets the authentication information for a given server or cluster daemon name defined in the domain.xml file.
 java.util.Collection getClusterDaemonList()
          Get the list of all ClusterDaemonProxy
 java.lang.String[] getClusters()
          MBean method
 java.lang.String[] getDeployServers(java.lang.String filename)
          Get the list of server where a file is being deployed
 java.lang.String getDeployState(java.lang.String filename, java.lang.String servername)
          Get the current state (string form) of deployment operation
 java.lang.String getDescription()
           
 java.lang.String getDomainName()
           
 java.lang.String getErrorMessage(java.lang.String filename, java.lang.String servername)
          Get the error message associated to the error state
 java.util.Collection getLogicalClusterList()
          Get the list of logical clusters
 int getMonitoringPeriod()
           
 java.lang.String[] getProxys()
          MBean method To be replaced by J2EEDomain.getServers()
 java.util.Collection getServerList()
          Get the list of ServerProxy
 java.util.Collection getTotalClusterList()
          Get the list of all clusters of any type
 void readDomainConfig()
           
 void refreshStates()
          Try to refresh the server states TODO notify thread only.
 boolean registerDeployAction(DeployAction action)
          Register a DeployAction
 void removeAuthenticationInformation(java.lang.String name)
          Removes authentication information for a given server or the domain.
 void setMonitoringPeriod(int sec)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomainMonitor

public DomainMonitor(java.lang.String domain)
Constructor

Method Detail

readDomainConfig

public void readDomainConfig()

getDescription

public java.lang.String getDescription()

getDomainName

public java.lang.String getDomainName()

setMonitoringPeriod

public void setMonitoringPeriod(int sec)
Specified by:
setMonitoringPeriod in interface DomainMonitorMBean
Parameters:
sec - monitoring period

getMonitoringPeriod

public int getMonitoringPeriod()
Specified by:
getMonitoringPeriod in interface DomainMonitorMBean
Returns:
the monitoring period in sec

addLocalServer

public ServerProxy addLocalServer(java.lang.String svname)
Add the local J2EEServer to the list of servers.

Parameters:
svname - name of the server.

findCluster

public BaseCluster findCluster(java.lang.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.

findServer

public J2EEServer findServer(java.lang.String name)
Get a Server by its name

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

findServerProxy

public ServerProxy findServerProxy(java.lang.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(java.lang.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.

getAuthenticationInformation

public AuthenticationInformation getAuthenticationInformation(java.lang.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(java.lang.String name,
                                         java.lang.String username,
                                         java.lang.String password)
                                  throws java.io.UnsupportedEncodingException
Adds authentication information for a given server or the domain.

Parameters:
name - Name of the server, null to change domain's 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:
java.io.UnsupportedEncodingException

removeAuthenticationInformation

public void removeAuthenticationInformation(java.lang.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 java.util.Collection getServerList()
Get the list of ServerProxy

Returns:
Collection of all ServerProxy in the Domain

getClusterDaemonList

public java.util.Collection getClusterDaemonList()
Get the list of all ClusterDaemonProxy


getTotalClusterList

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

Returns:
Collection of all Clusters in the domain

createLogicalCluster

public LogicalCluster createLogicalCluster(java.lang.String name)
Create a logical cluster


getLogicalClusterList

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


getProxys

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

Specified by:
getProxys in interface DomainMonitorMBean
Returns:
Array of OBJECT_NAMEs of all ServerProxy

getClusters

public java.lang.String[] getClusters()
MBean method

Specified by:
getClusters in interface DomainMonitorMBean
Returns:
Array of OBJECT_NAMEs of all cluster MBeans

discoveryNotification

public void discoveryNotification(DiscEvent event)
Handle Notifications from Discovery Service

Parameters:
event -

registerDeployAction

public boolean registerDeployAction(DeployAction action)
Register a DeployAction

Returns:
true if correctly aded in the list

getDeployServers

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

Specified by:
getDeployServers in interface DomainMonitorMBean
Parameters:
filename - file to deploy
Returns:
server name

getDeployState

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

Specified by:
getDeployState in interface DomainMonitorMBean
Parameters:
filename - file to deploy
servername - server where deployment is done
Returns:
one of "progress","ok","fail"

getErrorMessage

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

Specified by:
getErrorMessage in interface DomainMonitorMBean
Parameters:
filename - file to deploy
servername - server where deployment is done
Returns:
error message

forgetAllDeploy

public void forgetAllDeploy()
Forget all deploy information

Specified by:
forgetAllDeploy in interface DomainMonitorMBean

refreshStates

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