|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface DiscoveryClientMBean
Provides methods to discover Java DMK agents.
A Java DMK agent can only discovered if it has a
DiscoveryResponder
registered in its MBean server.
A discovery operation is executed in two steps:
DiscoveryClient
broadcasts a discovery request on a
multicast groupDiscoveryResponder
MBeans listening on the multicast group
catch the request. Each DiscoveryResponder
sends a discovery response to the DiscoveryClient
A DiscoveryClient
can only reach the
DiscoveryResponder
objects that listen on the same multicast group and
port. The default group is 224.224.224.224 and the default port is 9000. Other values
can be used by configuring the multicastGroup
and
multicastPort
properties on the DiscoveryClient
and DiscoveryResponder
objects.
The scope of the discovery depends on the time-to-live used by
the MulticastSocket
. By default, the time-to-live is 1. It
can be changed by setting the property timeToLive
on the
DiscoveryClient
.
After it has sent its discovery request, a DiscoveryClient
waits a finite time for responses. The default is 1 second.
This can be customized by setting the timeOut
property on the
DiscoveryClient
.
An application triggers a discovery operation by invoking either the
findMBeanServers
method or the findCommunicators
method on a DiscoveryClient
object.
These methods represent the discovery result by a Vector
of
DiscoveryResponse
. A DiscoveryResponse
is included
for each discovered Java DMK agent. It provides the host name and the MBean server information of the
agent ( see MBeanServerDelegate
and DiscoveryResponse
) and optionally
the list of communicator (Adaptor and connector) available in the agent.
A DiscoveryResponder
can send back responses using two modes:
DiscoveryResponder
to the DiscoveryClient
. The response is NOT multicasted to the group.
The default datagram socket port is 9001. The datagram socket Inet
address is defined by the local host name. It cannot be customized.
To enable unicast mode, set the pointToPointResponse
property to true
.
(Unicast mode is enabled by default.)
DiscoveryResponder
and the DiscoveryClient
. The response is multicasted to the group. This
behavior allows DiscoveryMonitor
objects to be aware of changes.
To enable multicast mode, set the pointToPointResponse
property to false
.
It is possible to instantiate multiple DiscoveryClient
objects with
different groups and ports for multicast responses and datagram sockets for unicast responses.
Field Summary | |
---|---|
static int |
OFFLINE
Marks the "state" property as stopped. |
static int |
ONLINE
Marks the "state" property as running. |
static int |
STOPPING
Marks the "state" property as in-transition from ONLINE to OFFLINE. |
Method Summary | |
---|---|
Vector |
findCommunicators()
Discovers all Java DMK agents and associated communicators (adaptors or connectors). |
Vector |
findCommunicators(String SelectedHost)
Discovers all Java DMK agents and associated communicators (adaptors or connectors) present on an host. |
Vector |
findMBeanServers()
Discovers all Java DMK agents. |
Vector |
findMBeanServers(String SelectedHost)
Discovers whether Java DMK agents with a DiscoveryResponder
registered in any MBean server is on a host. |
String |
getMulticastGroup()
Returns the multicast group. |
int |
getMulticastPort()
Returns the multicast port. |
boolean |
getPointToPointResponse()
Get the unicast datagram socket mode for the Java DMK agent response. |
Integer |
getState()
Returns the state of this DiscoveryClient . |
String |
getStateString()
Returns the state of this DiscoveryClient in string form. |
int |
getTimeOut()
Returns the time to wait for discovery responses in milliseconds. |
int |
getTimeToLive()
Get the time-to-live. |
boolean |
isActive()
Tests if the DiscoveryClient is active. |
void |
setMulticastGroup(String multicastGroup)
Sets the multicast group name. |
void |
setMulticastPort(int multicastPort)
Sets the multicast port. |
void |
setPointToPointResponse(boolean pointToPointResponse)
Set unicast datagram socket mode for the Java DMK agent response. |
void |
setTimeOut(int timeOut)
Sets the time during which the DiscoveryClient waits
for discovery responses. |
void |
setTimeToLive(int ttl)
Sets the default time-to-live for this DiscoveryClient . |
void |
start()
Create a multicast socket and join the multicast group. |
void |
stop()
Leaves the multicast group. |
Field Detail |
---|
static final int ONLINE
static final int OFFLINE
static final int STOPPING
Method Detail |
---|
void start() throws IOException
DiscoveryClient
will then join the multicast group.
IOException
- The creation of the Multicast socket failed.void stop()
DiscoveryClient
leaves its multicast group,
and the multicast socket is released.
boolean isActive()
DiscoveryClient
is active.
True
is returned if the DiscoveryClient
is started (DiscoveryClient
has join the multicast group).
Vector findMBeanServers() throws CommunicationException
Returns a vector of DiscoveryResponse
, one element for each discovered Java DMK agent.
Each DiscoveryResponse
contains the host name and the MBean server information of the
discovered agent ( see MBeanServerDelegate
and DiscoveryResponse
).
The communicators list is not relevant: it is set to null.
DiscoveryResponse
.
CommunicationException
- An error occurred during the discovery.Vector findMBeanServers(String SelectedHost) throws CommunicationException
DiscoveryResponder
registered in any MBean server is on a host.
Returns a vector of DiscoveryResponse
, one element for each discovered Java DMK agent on the specified host.
Each DiscoveryResponse
only contains the host name and the MBean server information of the
discovered agent ( see MBeanServerDelegate
and DiscoveryResponse
) of the specified host.
The communicators list is not relevant: it is set to null.
SelectedHost
- The host on which the discovery is to be performed.
DiscoveryResponse
.
CommunicationException
- An error occurred during the discovery.Vector findCommunicators() throws CommunicationException
Returns a vector of DiscoveryResponse
, one element for each discovered Java DMK agent.
Each DiscoveryResponse
contains the host name, the MBean server information of the
discovered agent ( see MBeanServerDelegate
and DiscoveryResponse
) and
the communicators list.
DiscoveryResponse
.
CommunicationException
- An error occurred during the discovery.Vector findCommunicators(String SelectedHost) throws CommunicationException
Returns a vector of DiscoveryResponse
, one element for each discovered Java DMK agent.
Each DiscoveryResponse
contains the host name, the MBean server information of the
discovered agent ( see MBeanServerDelegate
and DiscoveryResponse
) and
the communicators list.
SelectedHost
- The host on which the discovery is to be performed.
DiscoveryResponse
.
CommunicationException
- An error occurred during the discovery.String getMulticastGroup()
void setMulticastGroup(String multicastGroup) throws IllegalStateException
Only available if the state is OFFLINE
multicastGroup
- The multicast group name.
IllegalStateException
- This method has been invoked while
the DiscoveryClient
was ONLINE or STARTING.int getMulticastPort()
void setMulticastPort(int multicastPort) throws IllegalStateException
Only available if the state is OFFLINE
multicastPort
- The multicast port.
IllegalStateException
- This method has been invoked while
the DiscoveryClient
was ONLINE or STARTING.void setTimeOut(int timeOut) throws IOException
DiscoveryClient
waits
for discovery responses.
This time is expressed in milliseconds. The default value is 1000.
If the specified argument is negative or zero, the timeOut
is
reset to 1000.
The methods findMBeanServers
and findCommunicators
block until this
time elapsed.
timeOut
- The timeOut
in milliseconds.
IOException
- If the socket rejected the specified value (See java.net.MulticastSocket
).
This exception can be thrown only if the state in ONLINE: the actual java.net.MulticastSocket
setting
is done when the DiscoveryClient
is ONLINE
.int getTimeOut()
timeOut
in milliseconds.void setTimeToLive(int ttl) throws IOException, IllegalArgumentException
DiscoveryClient
.
The time-to-live is the number of 'hops' that the multicast packet is forwarded on the network.
ttl
- A number between 1 and 255.
IllegalArgumentException
- The input ttl value is not in the 1 to 255 range.
IOException
- If the socket rejected the specified value. This means the the state in ONLINE.int getTimeToLive()
TimeToLive
has not
been set.
boolean getPointToPointResponse()
void setPointToPointResponse(boolean pointToPointResponse)
The client sends a request for a unicast response in each discovery request. The multicast group Inet address is used for the unicast response.
pointToPointResponse
- The datagram socket mode.
false value unsets the use of unicast socket for the response,
multicast is used instead.Integer getState()
DiscoveryClient
.
ONLINE
, OFFLINE
or STOPPING
.String getStateString()
DiscoveryClient
in string form.
|
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 |