All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.jaw.impl.agent.services.jawdiscovery.DiscoveryClient

java.lang.Object
   |
   +----com.sun.jaw.impl.agent.services.jawdiscovery.DiscoveryClient

public class DiscoveryClient
extends Object
implements Serializable, ActivatableIf
The DiscoveryClient class provides methods to discover agents. An agent can only discovered if it has a DiscoveryResponder registered in its framework. A discovery operation is executed in two steps:

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 performFindHosts method or the performFindAdaptors method on a DiscoveryClient object. These methods represent the discovery result by a Vector of DiscoveryResponse. A DiscoveryResponse is included for each discovered agent, it provides the host of the agent and optionally the list of adaptors available in the agent.

A DiscoveryResponder can send back responses using two modes:

It is possible to instantiate multiple DiscoveryClient objects with different groups and ports for multicast responses and datagram sockets for unicast responses.


Variable Index

 o OFFLINE
 o ONLINE
 o STOPPING

Constructor Index

 o DiscoveryClient()
Class constructor.

Method Index

 o deleteCmf()
For Java DMK internal use only.
 o getClassVersion()
Returns the version of this class.
 o getMulticastGroup()
Returns the multicast group.
 o getMulticastPort()
Returns the multicast port.
 o getPointToPointResponse()
Get the unicast datagram socket port for the Java DMK agent response.
 o getState()
Returns the state of this DiscoveryResponder.
 o getStateString()
Returns the state of this DiscoveryResponder in string form.
 o getTimeOut()
Returns the time to wait for discovery responses in milliseconds.
 o getTimeToLiveByte()
Returns the time-to-live as a byte value.
 o getTimeToLiveInt()
Returns the time-to-live as a int value.
 o initCmf(Framework, ObjectName, boolean, ModificationList)
For Java DMK internal use only.
 o isActive()
Tests if the AdaptorServer is active.
 o performFindAdaptors()
Discovers all agents and associated adaptors.
 o performFindAdaptors(String)
Discovers all agents and associated adaptors present on an host.
 o performFindHosts()
Discovers all agents.
 o performFindHosts(String)
Discovers whether a Java DMK agent with a DiscoveryResponder registered in its framework is on a host.
 o performStart()
Connects this DiscoveryClient, the socket joins its multicast group.
 o performStop()
Disconnects this DiscoveryClient, the socket leaves its multicast group.
 o setMulticastGroup(String)
Sets the multicast group name.
 o setMulticastPort(int)
Sets the multicast port.
 o setPointToPointResponse(boolean)
Set unicast datagram socket mode for the Java DMK agent response.
 o setTimeOut(int)
Sets the time during which the DiscoveryClient waits for discovery responses.
 o setTimeToLiveByte(byte)
Sets the default time-to-live expressed as a byte value.
 o setTimeToLiveInt(int)
Sets the default time-to-live for this DiscoveryClient.

Variables

 o ONLINE
 public static final int ONLINE
 o OFFLINE
 public static final int OFFLINE
 o STOPPING
 public static final int STOPPING

Constructors

 o DiscoveryClient
 public DiscoveryClient() throws IOException
Class constructor. This constructor creates a multicast socket that is used to broadcast the discovery request using the default group (224.224.224.224) and port (9000).

Throws: IOException
The creation of the socket failed.

Methods

 o initCmf
 public void initCmf(Framework cmf,
                     ObjectName name,
                     boolean db,
                     ModificationList list) throws IllegalAccessException, ServiceNotFoundException, InstanceAlreadyExistException
For Java DMK internal use only.

 o deleteCmf
 public void deleteCmf() throws InstanceNotFoundException, IllegalAccessException, ServiceNotFoundException
For Java DMK internal use only.

 o performStart
 public void performStart()
Connects this DiscoveryClient, the socket joins its multicast group.

 o performStop
 public void performStop()
Disconnects this DiscoveryClient, the socket leaves its multicast group.

 o isActive
 public boolean isActive()
Tests if the AdaptorServer is active.

 o performFindHosts
 public Vector performFindHosts() throws CommunicationException
Discovers all agents. Each DiscoveryResponse contains the host names of all agents that were discovered.

Returns:
A vector of DiscoveryResponse.
Throws: CommunicationException
An error occurred during the discovery.
See Also:
DiscoveryResponse
 o performFindHosts
 public Vector performFindHosts(String SelectedHost) throws CommunicationException
Discovers whether a Java DMK agent with a DiscoveryResponder registered in its framework is on a host. The DiscoveryResponse only contains the host name.

Parameters:
SelectedHost - The host on which the discovery is to be performed.
Returns:
A vector of DiscoveryResponse.
Throws: CommunicationException
An error occurred during the discovery.
See Also:
DiscoveryResponse
 o performFindAdaptors
 public Vector performFindAdaptors() throws CommunicationException
Discovers all agents and associated adaptors.

Returns:
A vector of DiscoveryResponse.
Throws: CommunicationException
An error occurred during the discovery.
See Also:
DiscoveryResponse
 o performFindAdaptors
 public Vector performFindAdaptors(String SelectedHost) throws CommunicationException
Discovers all agents and associated adaptors present on an host.

Parameters:
SelectedHost - The host on which the discovery is to be performed.
Returns:
A vector of DiscoveryResponse.
Throws: CommunicationException
An error occurred during the discovery.
 o getClassVersion
 public String getClassVersion()
Returns the version of this class.

 o getMulticastGroup
 public String getMulticastGroup()
Returns the multicast group.

 o setMulticastGroup
 public void setMulticastGroup(String multicastGroup)
Sets the multicast group name. Only available if state in OFFLINE

Parameters:
multicastGroup - The multicast group name.
 o getMulticastPort
 public int getMulticastPort()
Returns the multicast port.

 o setMulticastPort
 public void setMulticastPort(int multicastPort)
Sets the multicast port. Only available if state in OFFLINE

Parameters:
multicastPort - The multicast port.
 o setTimeOut
 public void setTimeOut(int timeOut)
Sets the time during which the 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 performFindHosts and performFindAdaptors block until this time elapsed.

Parameters:
timeOut - The timeOut in milliseconds.
See Also:
getTimeOut
 o getTimeOut
 public int getTimeOut()
Returns the time to wait for discovery responses in milliseconds.

Returns:
The timeOut in milliseconds.
See Also:
 o setTimeToLiveInt
 public void setTimeToLiveInt(int ttl) throws IOException
Sets the default time-to-live for this DiscoveryClient. The time-to-live is the number of 'hops' that the multicast packet is forwarded on the network.

Parameters:
ttl - A number between 1 and 255.
Throws: IOException
If the socket rejected the specified value.
 o setTimeToLiveByte
 public void setTimeToLiveByte(byte ttl) throws IOException
Sets the default time-to-live expressed as a byte value.

Parameters:
ttl - A byte value.
Throws: IOException
If the socket rejected the specified value.
 o getTimeToLiveByte
 public byte getTimeToLiveByte()
Returns the time-to-live as a byte value.

Returns:
The time-to-live as a byte value.
 o getTimeToLiveInt
 public int getTimeToLiveInt()
Returns the time-to-live as a int value.

Returns:
The time-to-live as a int value.
 o getPointToPointResponse
 public boolean getPointToPointResponse()
Get the unicast datagram socket port for the Java DMK agent response.

Returns:
True indicates that unicast datagram socket is being used. false indicates that the multicast response mode is being used.
 o setPointToPointResponse
 public void setPointToPointResponse(boolean pointToPointResponse)
Set unicast datagram socket mode for the Java DMK agent response. The client sends a request for a unicast response in each discovery request. The multicast group Inet address is used for the unicast response.

Parameters:
pointToPointResponse - The datagram socket mode. false value unsets the use of unicast socket for the response, multicast is used instead.
 o getState
 public Integer getState()
Returns the state of this DiscoveryResponder.

Returns:
ONLINE, OFFLINE or STOPPING.
 o getStateString
 public String getStateString()
Returns the state of this DiscoveryResponder in string form.

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

All Packages  Class Hierarchy  This Package  Previous  Next  Index