com.sun.jdmk.discovery
Interface DiscoveryMonitorMBean

All Known Implementing Classes:
DiscoveryMonitor

public interface DiscoveryMonitorMBean

Describe an MBean that listens for registering and unregistering information sent by DiscoveryResponder objects on a given multicast group. Any agent that is to use multicast discovery must have a DiscoveryResponder registered in its MBean server. When a DiscoveryResponder is registered in an MBean server and when its start or stop methods are called, it informs the rest of the multicast group by sending a multicast message. The format of this message is not exposed. Whenever a DiscoveryMonitor receives a registration or unregistration message, it sends a DiscoveryResponderNotification to its notification listener.

A DiscoveryMonitor can be instantiated either in stand alone mode (Client side) or added to an MBean Server. In the first case, the client should call the appropriate constructor to initialize the multicastGroup and multicastPort parameters. The default values for the group and the port are 224.224.224.224 and 9000. A DiscoveryMonitor can be stopped by calling the stop method. When it is stopped, the DiscoveryMonitor no longer listens for registering and unregistering messages from DiscoveryResponder objects. A DiscoveryMonitor can be restarted by invoking the start method.

A DiscoveryMonitor has a state property which reflects its activity.

DiscoveryMonitor State
running ONLINE
stopped OFFLINE
stopping STOPPING

The transition between ONLINE and OFFLINE may not be immediate. The DiscoveryMonitor may need some time to finish or interrupt the active requests. During this time the state of the DiscoveryMonitor is STOPPING. When a DiscoveryMonitor is removed from a Java DMK agent, it is automatically stopped.


Method Summary
 String getMulticastGroup()
          Returns the multicast group.
 int getMulticastPort()
          Returns the multicast port.
 Integer getState()
          Returns the state of this DiscoveryMonitor.
 String getStateString()
          Returns the state of this DiscoveryMonitor in string form.
 void setMulticastGroup(String multicastGroup)
          Sets the multicast group name.
 void setMulticastPort(int multicastPort)
          Sets the multicast port.
 void start()
          Starts listening for DiscoveryResponder objects registering/unregistering.
 void stop()
          Stops this DiscoveryMonitor.
 boolean waitState(int state, long timeout)
          Waits until either the State attribute of this MBean equals the specified state parameter, or the specified timeout has elapsed.
 

Method Detail

start

void start()
           throws IOException
Starts listening for DiscoveryResponder objects registering/unregistering.

This method has no effect if the DiscoveryMonitor is ONLINE or STOPPING.

Throws:
IOException - The creation of the Multicast socket failed.

stop

void stop()
Stops this DiscoveryMonitor.

This method has no effect if the monitor is OFFLINE or STOPPING.


getState

Integer getState()
Returns the state of this DiscoveryMonitor.

Returns:
ONLINE,OFFLINE or STOPPING.

getStateString

String getStateString()
Returns the state of this DiscoveryMonitor in string form.

Returns:
One of the strings "ONLINE", "OFFLINE" or "STOPPING".

getMulticastGroup

String getMulticastGroup()
Returns the multicast group.

Returns:
A string containing the multicast group name.

setMulticastGroup

void setMulticastGroup(String multicastGroup)
                       throws IllegalStateException
Sets the multicast group name. A multicast group is specified by a class D IP address, those in the range 224.0.0.1 to 239.255.255.255.

Only available if state in OFFLINE

Parameters:
multicastGroup - The multicast group name.
Throws:
IllegalStateException - This method has been invoked while the DiscoveryMonitor was ONLINE or STARTING.

getMulticastPort

int getMulticastPort()
Returns the multicast port.

Returns:
The multicast port number.

setMulticastPort

void setMulticastPort(int multicastPort)
                      throws IllegalStateException
Sets the multicast port. It can be any standard UDP port number.

Only available if state in OFFLINE

Parameters:
multicastPort - The multicast port.
Throws:
IllegalStateException - This method has been invoked while the DiscoveryMonitor was ONLINE or STARTING.

waitState

boolean waitState(int state,
                  long timeout)
Waits until either the State attribute of this MBean equals the specified state parameter, or the specified timeout has elapsed. The method waitState returns with a boolean value indicating whether the specified state parameter equals the value of this MBean's State attribute at the time the method terminates. Two special cases for the timeout parameter value are:

Parameters:
state - The value of this MBean's State attribute to wait for. state can be one of: DiscoveryMonitor.OFFLINE, DiscoveryMonitor.ONLINE, DiscoveryMonitor.STARTING, DiscoveryMonitor.STOPPING.
timeout - The maximum time to wait for, in milliseconds, if positive. Infinite time out if 0, or no waiting at all if negative.
Returns:
true if the value of this MBean's State attribute is the same as the state parameter; false otherwise.

Open Source build 02
opendmk-1.0-b02 2007.10.01_19:17:46_MEST

Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.