com.adventnet.services.cascading
Class Cascader

java.lang.Object
  |
  +--javax.management.NotificationBroadcasterSupport
        |
        +--com.adventnet.services.cascading.Cascader

public class Cascader
extends NotificationBroadcasterSupport
implements DynamicMBean, NotificationListener, NotificationFilter, MBeanRegistration, HeartBeatListener

The Cascader class helps to achieve Master-Sub Agent architecture in Multi-Protocol Agent. The cascader uses the Client side APIs provided by AdventNet AgentToolkit API to connect to the SubAgents and mirror the MBeans on the MasterAgent side. The protocols as of now supported are RMI CORBA HTTP The cascader implements the DynamicMBean interface thereby becoming an MBean by nature and exposing the management details of the Cascader.

See Also:
Serialized Form

Field Summary
(package private)  MBeanServer server
          Variable storing the reference to the MBeanServer where the Cascader is registered.
 
Fields inherited from class javax.management.NotificationBroadcasterSupport
li
 
Constructor Summary
Cascader()
          The NoArg constructor used to initialize the Cascader in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServer.findMBeanServer(...) method.
Cascader(java.lang.String host, int port, java.lang.String protocol)
          Constructor used to initialize the Cascador in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServer.findMBeanServer(...) method.
Cascader(java.lang.String host, int port, java.lang.String protocol, MBeanServer server)
          Constructor used to initialize the Cascador in forming the MBeanInfo and that takes the MBeanServer as a parameter.
 
Method Summary
 void enableHeartBeat(boolean heartBeatState)
          Enable heartBeat if heartBeatState is true.
 java.lang.Object getAttribute(java.lang.String attribute)
          Gets the value of a specific attribute of this MBean.
 AttributeList getAttributes(java.lang.String[] attributes)
          Enables the values of several attributes of this MBean.
(package private)  Client getClient()
          Getter for the client used by the Cascader.
 boolean getHeartBeatStatus()
          Returns status of the HeartBeat support
 java.lang.String getHost()
          Returns the host name of the remote sub agent to which the adaptor client associated with this service should get connected.
 MBeanInfo getMBeanInfo()
          This method discovers the attributes and operations this MBean exposes for management.
 NotificationFilter getNotificationFilter()
          This method acts as the getter for NotificationFilter used by the Cascader.
 java.lang.String getObjectName()
          Returns the ObjectName of this cascader with which it has been registered with the MBeanServer.
 java.lang.Integer getPort()
          Returns the port number on the remote sub agent to which the adaptor client associated with this service should get connected.
 java.lang.String getProtocol()
          Gets the protocol by which this Cascader contacts the sub-agent through the adaptor client.
(package private)  java.util.Hashtable getProxyTable()
          Getter for the Proxy MBeans repository.
 java.lang.Integer getRemoteObjectsCount()
          Gets the number of remote objects present in the subagent cascaded with the Master JMX agent
 ObjectName[] getRemoteObjectsList()
          Gets the remote objects ObjectName list which are present in the subagent cascaded with the Master JMX agent
 java.lang.Integer getState()
          Returns the state, whether ON_STATE/OFF_STATE, of this service.
 void handleHeartBeat(HeartBeatEvent event)
          This method will be called by connector clients when relevant connector present in the JMX server is down
 void handleNotification(Notification notification, java.lang.Object handback)
          Invoked when an JMX notification occurs.
 java.lang.Object invoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)
          Invokes an action on the original MBean associated with this MBean.
 boolean isNotificationEnabled(Notification notification)
          Invoked before sending the specified notification to the listener.
 void postDeregister()
          Allows this MBean to perform any operations needed after having been de-registered in the MBeanServer.
 void postRegister(java.lang.Boolean registrationDone)
          Allows this MBean to perform any operations needed after having been registered in the MBeanServer or after the registration has failed.
 void preDeregister()
          Allows this MBean to perform any operations it needs before being de-registered by the MBeanServer.
 ObjectName preRegister(MBeanServer server, ObjectName name)
          Allows the MBean to perform any operations it needs before being registered in the MBeanServer.
 void setAdaptorInfo(java.lang.Object info)
           
 void setAttribute(Attribute attribute)
          Sets the value of a specific attribute of this MBean.
 AttributeList setAttributes(AttributeList attributes)
          Sets the values of several attributes of this MBean.
 void setHeartBeatRate(int rate)
          Sets the heart beat rate.
 void setHost(java.lang.String host)
          Sets the host name the remote sub agent to which the adaptor client associated with this service should get connected.
 void setNotificationFilter(NotificationFilter filter)
          This method sets the NotificationFilter to be used on the Cascader.
 void setPort(java.lang.Integer port)
          Sets the port number on the remote sub agent to which the adaptor client associated with this service should get connected.
 void setProtocol(java.lang.String protocol)
          Sets the protocol by which this Cascader contacts the sub-agent through the adaptor client.
 void setUserContext(com.adventnet.agent.security.UserContext userContext)
          Sets the UserContext to be authenticated.
 void startService()
          This method starts the cascader service and registers the SubAgent MBeans as mirror MBeans on the Master Agent side.started.
 void stopService()
          This method stops the Cascader and unregisters the SubAgent MBeans available on the Master Agent.
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

transient MBeanServer server
Variable storing the reference to the MBeanServer where the Cascader is registered.
Constructor Detail

Cascader

public Cascader()
The NoArg constructor used to initialize the Cascader in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServer.findMBeanServer(...) method. It initializes the server to the first instance of the list of the servers found.

Cascader

public Cascader(java.lang.String host,
                int port,
                java.lang.String protocol)
Constructor used to initialize the Cascador in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServer.findMBeanServer(...) method. It initializes the server to the first instance of the list of the servers found.
Parameters:
host - The host name.
port - The Port number.
protocol - The protocol name.

Cascader

public Cascader(java.lang.String host,
                int port,
                java.lang.String protocol,
                MBeanServer server)
Constructor used to initialize the Cascador in forming the MBeanInfo and that takes the MBeanServer as a parameter.
Parameters:
host - The host name.
port - The Port number.
protocol - The protocol name.
Method Detail

setUserContext

public void setUserContext(com.adventnet.agent.security.UserContext userContext)
Sets the UserContext to be authenticated.
Parameters:
userContext - The UserContext to be authenticated

startService

public void startService()
This method starts the cascader service and registers the SubAgent MBeans as mirror MBeans on the Master Agent side.started.

stopService

public void stopService()
This method stops the Cascader and unregisters the SubAgent MBeans available on the Master Agent. It also cleans up the Cascader Resources.

setAdaptorInfo

public void setAdaptorInfo(java.lang.Object info)

enableHeartBeat

public void enableHeartBeat(boolean heartBeatState)
Enable heartBeat if heartBeatState is true.
Parameters:
heartBeatState - - The state of heart beat service.

setHeartBeatRate

public void setHeartBeatRate(int rate)
Sets the heart beat rate. Once in every heart beat rate the client is checked whether it is alive or not.

getPort

public java.lang.Integer getPort()
Returns the port number on the remote sub agent to which the adaptor client associated with this service should get connected.
Returns:
The port number.

setPort

public void setPort(java.lang.Integer port)
             throws java.lang.IllegalStateException
Sets the port number on the remote sub agent to which the adaptor client associated with this service should get connected.
Parameters:
port - the new port number.

getHost

public java.lang.String getHost()
Returns the host name of the remote sub agent to which the adaptor client associated with this service should get connected.
Returns:
The Host Name.

setHost

public void setHost(java.lang.String host)
             throws java.lang.IllegalStateException
Sets the host name the remote sub agent to which the adaptor client associated with this service should get connected.
Parameters:
host - The host name.

getState

public java.lang.Integer getState()
Returns the state, whether ON_STATE/OFF_STATE, of this service.
Returns:
The state, whether ON_STATE/OFF_STATE, of this service.

getRemoteObjectsCount

public java.lang.Integer getRemoteObjectsCount()
Gets the number of remote objects present in the subagent cascaded with the Master JMX agent
Returns:
The number of remote objects

setNotificationFilter

public void setNotificationFilter(NotificationFilter filter)
This method sets the NotificationFilter to be used on the Cascader.
Parameters:
filter - the instance of NotificationFilter.

getNotificationFilter

public NotificationFilter getNotificationFilter()
This method acts as the getter for NotificationFilter used by the Cascader.
Returns:
NotificationFilter object

getRemoteObjectsList

public ObjectName[] getRemoteObjectsList()
Gets the remote objects ObjectName list which are present in the subagent cascaded with the Master JMX agent
Returns:
The remote objects ObjectName list

getObjectName

public java.lang.String getObjectName()
Returns the ObjectName of this cascader with which it has been registered with the MBeanServer.
Returns:
The ObjectName.

getProtocol

public java.lang.String getProtocol()
Gets the protocol by which this Cascader contacts the sub-agent through the adaptor client. Currently the supported protocols are RMI and IIOP and HTTP.
Returns:
The protocol by which this Cascader contacts the sub-agent through the adaptor client.

setProtocol

public void setProtocol(java.lang.String protocol)
                 throws java.lang.IllegalStateException
Sets the protocol by which this Cascader contacts the sub-agent through the adaptor client. Currently the supported protocols are RMI and IIOP
Parameters:
protocol - The name of the protocol.

getHeartBeatStatus

public boolean getHeartBeatStatus()
Returns status of the HeartBeat support

getClient

Client getClient()
Getter for the client used by the Cascader. This will be referred by mirror Mbeans.

getProxyTable

java.util.Hashtable getProxyTable()
Getter for the Proxy MBeans repository.

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
                       throws java.lang.Exception
Allows the MBean to perform any operations it needs before being registered in the MBeanServer. If the name of the MBean is not specified, the MBean can provide a name for its registration. If any exception is raised, the MBean will not be registered in the MBeanServer.
Specified by:
preRegister in interface MBeanRegistration
Parameters:
server - The MBeanServer in which the MBean will be registered.
name - The object name of the MBean.
Returns:
The name of the MBean registered.
Throws:
java.lang.Exception - - This exception should be caught by the MBeanServer and re-thrown as an MBeanRegistrationException.

postRegister

public void postRegister(java.lang.Boolean registrationDone)
Allows this MBean to perform any operations needed after having been registered in the MBeanServer or after the registration has failed.
Specified by:
postRegister in interface MBeanRegistration
Parameters:
registrationDone - Indicates whether or not the MBean has been successfully registered in the MBeanServer. The value false means that either the registration phase has failed.
registrationDone - indicates whether the mbean is registered properly with the server.

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Allows this MBean to perform any operations it needs before being de-registered by the MBeanServer.
Specified by:
preDeregister in interface MBeanRegistration
Throws:
java.langException - This exception should be caught by the MBeanServer and re-thrown as an MBeanRegistrationException.

postDeregister

public void postDeregister()
Allows this MBean to perform any operations needed after having been de-registered in the MBeanServer.
Specified by:
postDeregister in interface MBeanRegistration

isNotificationEnabled

public boolean isNotificationEnabled(Notification notification)
Invoked before sending the specified notification to the listener.
Specified by:
isNotificationEnabled in interface NotificationFilter
Parameters:
notification - - The notification to be sent.Returns:
Returns:
True if the notification has to be sent to the listener, false otherwise.

handleHeartBeat

public void handleHeartBeat(HeartBeatEvent event)
Description copied from interface: HeartBeatListener
This method will be called by connector clients when relevant connector present in the JMX server is down
Specified by:
handleHeartBeat in interface HeartBeatListener
Tags copied from interface: HeartBeatListener
Parameters:
the - heartbeat event to be triggered

handleNotification

public void handleNotification(Notification notification,
                               java.lang.Object handback)
Invoked when an JMX notification occurs.
Specified by:
handleNotification in interface NotificationListener
Parameters:
notification - - The notification.
handback - - An opaque object which helps the listener to associate information regarding the MBean emitter. This object was passed to the MBean during the addListener call and resend, without modification, to the listener. The MBean object should to use or modify the object.

getMBeanInfo

public MBeanInfo getMBeanInfo()
This method discovers the attributes and operations this MBean exposes for management.
Specified by:
getMBeanInfo in interface DynamicMBean
Returns:
An instance of MBeanInfo allowing to retrieve all attributes and operations of this MBean.

getAttribute

public java.lang.Object getAttribute(java.lang.String attribute)
                              throws AttributeNotFoundException,
                                     MBeanException,
                                     ReflectionException
Gets the value of a specific attribute of this MBean.
Specified by:
getAttribute in interface DynamicMBean
Parameters:
attribute - A String specifying the name of the attribute to be retrieved.
Returns:
The value of the retrieved attribute.
Throws:
AttributeNotFoundException - The specified attribute is not accessible in the MBean.
MBeanException - Wraps an exception thrown by the MBean's setter.
ReflectionException - Wraps an java.lang.Exception thrown while trying to invoke the setter.

getAttributes

public AttributeList getAttributes(java.lang.String[] attributes)
Enables the values of several attributes of this MBean.
Specified by:
getAttributes in interface DynamicMBean
Parameters:
attributes - A list of attributes to be retrieved.
Returns:
The value of the retrieved attributes as attributeList.

invoke

public java.lang.Object invoke(java.lang.String actionName,
                               java.lang.Object[] params,
                               java.lang.String[] signature)
                        throws MBeanException,
                               ReflectionException
Invokes an action on the original MBean associated with this MBean.
Specified by:
invoke in interface DynamicMBean
Parameters:
actionName - The name of the action to be invoked.
params - An array containing the parameters to be set when the action is invoked
signature - An array containing the signature of the action. The class objects will be loaded using the same class loader as the one used for loading the MBean on which the action was invoked.
Returns:
The object returned by the action, which represents the result ofinvoking the action on the specified MBean.
Throws:
MBeanException - Wraps an exception thrown by the MBean's setter.
ReflectionException - Wraps an java.lang.Exception thrown while trying to invoke the setter.

setAttribute

public void setAttribute(Attribute attribute)
                  throws AttributeNotFoundException,
                         InvalidAttributeValueException,
                         MBeanException,
                         ReflectionException
Sets the value of a specific attribute of this MBean.
Specified by:
setAttribute in interface DynamicMBean
Parameters:
attribute - The identification of the attribute to be set and the value it is to be set to.
Throws:
AttributeNotFoundException - The specified attribute is not accessible in the MBean.
InvalidAttributeValueException - The specified value for the attribute is not valid.
MBeanException - Wraps an exception thrown by the MBean's setter.
ReflectionException - Wraps an java.lang.Exception thrown while trying to invoke the setter.
RuntimeOperationsException - Wraps a java.lang.IllegalArgumentException: The object name in parameter is null or the attribute in parameter is null.

setAttributes

public AttributeList setAttributes(AttributeList attributes)
Sets the values of several attributes of this MBean.
Specified by:
setAttributes in interface DynamicMBean
Parameters:
attributes - A list of attributes: The identification of the attributes to be set and the values they are to be set to.
Returns:
The list of attributes that were set, with their new values.