|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.management.NotificationBroadcasterSupport com.sun.jdmk.discovery.DiscoveryMonitor
public class DiscoveryMonitor
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 |
starting | STARTING |
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.
Field Summary | |
---|---|
static int |
OFFLINE
Marks the "state" property as stopped. |
static int |
ONLINE
Marks the "state" property as running. |
static int |
STARTING
Marks the "state" property as in-transition from OFFLINE to ONLINE. |
static int |
STOPPING
Marks the "state" property as in-transition from ONLINE to OFFLINE. |
Constructor Summary | |
---|---|
DiscoveryMonitor()
Constructs a DiscoveryMonitor . |
|
DiscoveryMonitor(String multicastGroup,
int multicastPort)
Constructs a DiscoveryMonitor . |
|
DiscoveryMonitor(String multicastGroup,
int multicastPort,
InetAddress inf)
Constructs a DiscoveryMonitor . |
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 |
postDeregister()
Allows the MBean to perform any operations needed after having been unregistered in the MBean server. |
void |
postRegister(Boolean registrationDone)
Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed. |
void |
preDeregister()
Allows the MBean to perform any operations it needs before being unregistered by the MBean server. |
ObjectName |
preRegister(MBeanServer server,
ObjectName name)
Allows the MBean to perform any operations it needs before being registered in the MBean server. |
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. |
Methods inherited from class javax.management.NotificationBroadcasterSupport |
---|
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int ONLINE
public static final int OFFLINE
public static final int STOPPING
public static final int STARTING
Constructor Detail |
---|
public DiscoveryMonitor()
DiscoveryMonitor
.
This constructor creates and initializes a
multicast socket used to listen for DiscoveryResponder
objects registering or unregistering.
The default group (224.224.224.224) and port (9000) are used.
No check is done on the default values: check will be performed by the start method.
public DiscoveryMonitor(String multicastGroup, int multicastPort)
DiscoveryMonitor
.
This constructor creates and initializes a
multicast socket used to listen for DiscoveryResponder
objects registering or unregistering.
No check is done on the parameter values: check will be performed by the start method.
multicastGroup
- The multicast group name.multicastPort
- The multicast port number.public DiscoveryMonitor(String multicastGroup, int multicastPort, InetAddress inf)
DiscoveryMonitor
.
This constructor creates and initializes a
multicast socket used to listen for DiscoveryResponder
objects registering or unregistering.
No check is done on the parameter values: check will be performed by the start method.
multicastGroup
- The multicast group name.multicastPort
- The multicast port number.inf
- The interface used by a MulticastSocket.Method Detail |
---|
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
preRegister
in interface MBeanRegistration
server
- The MBean server in which the MBean will be registered.name
- The object name of the MBean.
Exception
- This exception should be caught by the MBean server and re-thrown
as an MBeanRegistrationException
.public void postRegister(Boolean registrationDone)
postRegister
in interface MBeanRegistration
registrationDone
- Indicates whether or not the MBean has been successfully registered in
the MBean server. The value false means that the registration phase has failed.public void preDeregister() throws Exception
preDeregister
in interface MBeanRegistration
java.langException
- This exception should be caught by the MBean server and re-thrown
as an MBeanRegistrationException
.
Exception
public void postDeregister()
postDeregister
in interface MBeanRegistration
public void start() throws IOException
DiscoveryResponder
objects registering/unregistering.
This method has no effect if the DiscoveryMonitor
is ONLINE
or
STOPPING
or STARTING
.
start
in interface DiscoveryMonitorMBean
IOException
- The creation of the Multicast socket failed.public void stop()
DiscoveryMonitor
.
This method has no effect if the monitor is OFFLINE
or
STOPPING
or STARTING
.
stop
in interface DiscoveryMonitorMBean
public Integer getState()
DiscoveryMonitor
.
getState
in interface DiscoveryMonitorMBean
ONLINE
,OFFLINE
, STOPPING
or STARTING
.public String getStateString()
DiscoveryMonitor
in string form.
getStateString
in interface DiscoveryMonitorMBean
public String getMulticastGroup()
getMulticastGroup
in interface DiscoveryMonitorMBean
public void setMulticastGroup(String multicastGroup) throws IllegalStateException
Only available if state in OFFLINE
setMulticastGroup
in interface DiscoveryMonitorMBean
multicastGroup
- The multicast group name.
IllegalStateException
- This method has been invoked while
the DiscoveryMonitor
was ONLINE or STARTING.public int getMulticastPort()
getMulticastPort
in interface DiscoveryMonitorMBean
public void setMulticastPort(int multicastPort) throws IllegalStateException
Only available if state in OFFLINE
setMulticastPort
in interface DiscoveryMonitorMBean
multicastPort
- The multicast port.
IllegalStateException
- This method has been invoked while
the DiscoveryMonitor
was ONLINE or STARTING.public boolean waitState(int state, long timeout)
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:
waitState
returns immediately (i.e. does not wait at all),waitState
waits until the value of this MBean's State attribute is the same
as the state parameter (i.e. will wait indefinitely
if this condition is never met).
waitState
in interface DiscoveryMonitorMBean
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.
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 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |