|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface DiscoveryResponderMBean
Implements the MBean that responds to the discovery requests. Any agent that needs to be discovered
must instantiate and register a DiscoveryResponder
in its
MBean server.
When the DiscoveryResponder
start
method is called, the MBean
creates a multicast socket. The DiscoveryResponder
then sends a join message
to the multicast group.
When a DiscoveryResponder
is unregistered from the MBean server,
or when stop
method is called, the MBean
sends a leave message to the multicast group. The format of these messages
is not exposed. These messages allow DiscoveryMonitor
objects to
maintain a list of agents with DiscoveryResponder
objects
registered in their MBean server.
When start
method is called, and when a
join message has been sent, the DiscoveryResponder
starts to listen for
discovery requests.
The multicast socket uses the group and port specified by the
properties multicastGroup
and multicastPort
.
The default values for the group and the port are 224.224.224.224 and 9000.
These values can be changed using appropriate constructor.
These values can be also changed using setMulticastGroup
and
setMulticastPort
methods when the DiscoveryResponder
is OFFLINE.
When join/leave message are sent to the multicast group, a default
time-to-live (see java.net.MulticastSocket
) value is used. The
time-to-live value specifies how many "hops" that the packet is forwarded on
the network before it expires.
DiscoveryResponder
objects use a time-to-live specified by the property
ttl
.
The default time-to-live value is 1. It can be changed using setTimeToLive
method when the DiscoveryResponder
is OFFLINE.
Method Summary | |
---|---|
String |
getMulticastGroup()
Returns the multicast group. |
int |
getMulticastPort()
Returns the multicast port. |
Integer |
getState()
Returns the state of this DiscoveryResponder . |
String |
getStateString()
Returns the state of this DiscoveryResponder in string form. |
int |
getTimeToLive()
Returns the time-to-live value. |
byte[] |
getUserData()
Returns a byte[] containing the additional information that the user added in the DiscoveryResponse . |
boolean |
isActive()
Tests if the DiscoveryResponder is active. |
void |
setMulticastGroup(String multicastGroup)
Sets the multicast group name. |
void |
setMulticastPort(int multicastPort)
Sets the multicast port. |
void |
setTimeToLive(int ttl)
Sets the default Time to Live to be used to send join and leave message to the Multicast group. |
void |
setUserData(byte[] data)
Allows the user to specify additional information in the DiscoveryResponse message. |
void |
start()
Create a multicast socket and join the multicast group. |
void |
stop()
Sends a leave message to the multicast group and leaves it. |
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 |
---|
void start() throws IOException
DiscoveryResponder
will then join the multicast group and send a join message.
IOException
- The creation of the Multicast socket failed.void stop()
DiscoveryResponder
leaves its multicast group.
boolean isActive()
DiscoveryResponder
is active.
True
is returned if the DiscoveryResponder
is started (DiscoveryResponder
has join the multicast group).
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).
state
- The value of this MBean's State attribute
to wait for. state can be one of:
CommunicatorServer.OFFLINE
,
CommunicatorServer.ONLINE
,
CommunicatorServer.STARTING
,
CommunicatorServer.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.String getMulticastGroup()
void setMulticastGroup(String multicastGroup) throws IllegalStateException
Only available if state in OFFLINE
multicastGroup
- The multicast group name.
IllegalStateException
- This method has been invoked while
the DiscoveryResponder
was ONLINE or STARTING.int getMulticastPort()
void setMulticastPort(int multicastPort) throws IllegalStateException
Only available if state in OFFLINE
multicastPort
- The multicast port.
IllegalStateException
- This method has been invoked while
the DiscoveryResponder
was ONLINE or STARTING.int getTimeToLive()
void setTimeToLive(int ttl) throws IllegalStateException
Time to Live should an integer verifying the following condition: 0 < ttl <= 255 Only available if state in OFFLINE
ttl
- The Time to live value.
IllegalArgumentException
- The input ttl value is not
in the 1 to 255 range.
IllegalStateException
- This method has been invoked while
the DiscoveryResponder
was ONLINE or STARTING.Integer getState()
DiscoveryResponder
.
ONLINE
, OFFLINE
or STOPPING
.String getStateString()
DiscoveryResponder
in string form.
void setUserData(byte[] data)
DiscoveryResponse
message.
The following limitation applies to the length of the byte array
parameter:
The length of a UDP packet is maximum 64 Kbytes. In addition to the
specified user data, the discovery response UDP packet contains the
following :
byte[] getUserData()
DiscoveryResponse
.
|
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 |