EclipseLink 2.2.0, build 'v20110202-r8913' API Reference

org.eclipse.persistence.sessions.coordination
Class DiscoveryManager

java.lang.Object
  extended by org.eclipse.persistence.sessions.coordination.DiscoveryManager
All Implemented Interfaces:
java.lang.Runnable

public class DiscoveryManager
extends java.lang.Object
implements java.lang.Runnable

Purpose: Detects new members of a logical EclipseLink cluster.

Description: Each RemoteCommandManager has its own DiscoveryManager, which handles the detection of other remote command services as they become available. The DiscoveryManager is an active object (in that it extends Thread) and becomes a separate thread when it is started using startDiscovery().

Discovery is done through the use of a multicast. Each discovery manager joins the multicast group and announces itself to the group. As it receives service announcements from other discovery managers it notifies the RCM to establish connections to and from the new service.

See Also:
RemoteCommandManager, MulticastSocket
Author:
Steven Vo
Since:
OracleAS TopLink 10g (9.0.4)

Field Summary
protected  int announcementDelay
          Delay time in millis between initialization and when the announcement is sent
protected  java.net.MulticastSocket communicationSocket
          The multicast socket used for discovery
static int DEFAULT_ANNOUNCEMENT_DELAY
           
static java.lang.String DEFAULT_MULTICAST_GROUP
          Default value constants
static int DEFAULT_MULTICAST_PORT
           
static int DEFAULT_PACKET_TIME_TO_LIVE
           
protected  java.lang.String multicastGroupAddress
          Defines the IP address of the multicast group
protected  int multicastPort
          Defines the port the multicast socket will be using
protected  int packetTimeToLive
          Number of hops in the life of the datapacket Default is 2, a hub and an interface card to prevent the data packets from leaving the localnetwork.
protected  RemoteCommandManager rcm
          The remote command manager responsible for this service
protected  boolean stopListening
          Indicates to the listening thread that it should stop
 
Constructor Summary
DiscoveryManager(RemoteCommandManager mgr)
          Constructors to create a discovery manager.
DiscoveryManager(java.lang.String address, int port, int delay, RemoteCommandManager mgr)
           
DiscoveryManager(java.lang.String address, int port, RemoteCommandManager mgr)
           
 
Method Summary
 void announceSession()
          INTERNAL: Send out an announcement that we are here.
 void createCommunicationSocket()
          INTERNAL: Create the multicast socket and join the multicast group.
 int getAnnouncementDelay()
          PUBLIC: Return the amount of time in millis that the service should wait between the time that this Remote Service is available and a session announcement is sent out to other discovery managers.
 java.net.MulticastSocket getCommunicationSocket()
          INTERNAL: Return the socket that will be used for the multicast.
 java.lang.String getMulticastGroupAddress()
          PUBLIC: Return the host address of the multicast group.
 int getMulticastPort()
          PUBLIC: Return the multicast port used for discovery.
 int getPacketTimeToLive()
          PUBLIC: Returns the number of hops the data packets of the session announcement will take before expiring.
 boolean isDiscoveryStopped()
          ADVANCED: Return true if discovery has been stopped at the time this method is called.
 void receivedAnnouncement(ServiceId serviceId)
          INTERNAL: Process the announcement that indicates that a new service is online
 void run()
          INTERNAL: This is the main execution method of discovery.
 void setAnnouncementDelay(int millisecondsToDelay)
          PUBLIC: Set the amount of time in millis that the service should wait between the time that this Remote Service is available and a session announcement is sent out to other discovery managers.
 void setMulticastGroupAddress(java.lang.String address)
          PUBLIC: Set the host address of the multicast group.
 void setMulticastPort(int port)
          PUBLIC: Set the multicast port used for discovery.
 void setPacketTimeToLive(int newPacketTimeToLive)
          PUBLIC: Set the number of hops the data packets of the session announcement will take before expiring.
protected  void shallowCopy(DiscoveryManager dmgr)
          INTERNAL: invoke when the RCM shutdown.
 void startDiscovery()
          ADVANCED: Announce the local service and join the cluster
 void startListening()
          INTERNAL: This method puts us into the listening mode loop.
 void stopDiscovery()
          ADVANCED: Stop accepting announcements from other services becoming available.
 void stopListening()
          INTERNAL: Signal this instance to stop listening.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MULTICAST_GROUP

public static final java.lang.String DEFAULT_MULTICAST_GROUP
Default value constants

See Also:
Constant Field Values

DEFAULT_MULTICAST_PORT

public static final int DEFAULT_MULTICAST_PORT
See Also:
Constant Field Values

DEFAULT_PACKET_TIME_TO_LIVE

public static final int DEFAULT_PACKET_TIME_TO_LIVE
See Also:
Constant Field Values

DEFAULT_ANNOUNCEMENT_DELAY

public static final int DEFAULT_ANNOUNCEMENT_DELAY
See Also:
Constant Field Values

multicastGroupAddress

protected java.lang.String multicastGroupAddress
Defines the IP address of the multicast group


multicastPort

protected int multicastPort
Defines the port the multicast socket will be using


communicationSocket

protected java.net.MulticastSocket communicationSocket
The multicast socket used for discovery


packetTimeToLive

protected int packetTimeToLive
Number of hops in the life of the datapacket Default is 2, a hub and an interface card to prevent the data packets from leaving the localnetwork.


stopListening

protected boolean stopListening
Indicates to the listening thread that it should stop


announcementDelay

protected int announcementDelay
Delay time in millis between initialization and when the announcement is sent


rcm

protected RemoteCommandManager rcm
The remote command manager responsible for this service

Constructor Detail

DiscoveryManager

public DiscoveryManager(RemoteCommandManager mgr)
Constructors to create a discovery manager.


DiscoveryManager

public DiscoveryManager(java.lang.String address,
                        int port,
                        RemoteCommandManager mgr)

DiscoveryManager

public DiscoveryManager(java.lang.String address,
                        int port,
                        int delay,
                        RemoteCommandManager mgr)
Method Detail

announceSession

public void announceSession()
INTERNAL: Send out an announcement that we are here.


startDiscovery

public void startDiscovery()
ADVANCED: Announce the local service and join the cluster


stopDiscovery

public void stopDiscovery()
ADVANCED: Stop accepting announcements from other services becoming available. Note that this does not remove the local service from the cluster.


isDiscoveryStopped

public boolean isDiscoveryStopped()
ADVANCED: Return true if discovery has been stopped at the time this method is called. If false is returned then it is undefined whether discovery is started or stopped. It may be started, or it may be in the process of starting or stopping.


createCommunicationSocket

public void createCommunicationSocket()
INTERNAL: Create the multicast socket and join the multicast group.


getCommunicationSocket

public java.net.MulticastSocket getCommunicationSocket()
INTERNAL: Return the socket that will be used for the multicast.


run

public void run()
INTERNAL: This is the main execution method of discovery. It will create a socket to listen on, create a local connection for this service and announce that we are open for business.

Specified by:
run in interface java.lang.Runnable

startListening

public void startListening()
INTERNAL: This method puts us into the listening mode loop. This thread blocks, waiting on announcements that we receive from other discovery managers.


stopListening

public void stopListening()
INTERNAL: Signal this instance to stop listening.


receivedAnnouncement

public void receivedAnnouncement(ServiceId serviceId)
INTERNAL: Process the announcement that indicates that a new service is online


setAnnouncementDelay

public void setAnnouncementDelay(int millisecondsToDelay)
PUBLIC: Set the amount of time in millis that the service should wait between the time that this Remote Service is available and a session announcement is sent out to other discovery managers. This may be needed to give some systems more time to post their connections into the naming service. Takes effect the next time listening is started.


getAnnouncementDelay

public int getAnnouncementDelay()
PUBLIC: Return the amount of time in millis that the service should wait between the time that this Remote Service is available and a session announcement is sent out to other discovery managers.


getMulticastGroupAddress

public java.lang.String getMulticastGroupAddress()
PUBLIC: Return the host address of the multicast group.


setMulticastGroupAddress

public void setMulticastGroupAddress(java.lang.String address)
PUBLIC: Set the host address of the multicast group. Takes effect the next time listening is started.


setMulticastPort

public void setMulticastPort(int port)
PUBLIC: Set the multicast port used for discovery. Takes effect the next time listening is started.


getMulticastPort

public int getMulticastPort()
PUBLIC: Return the multicast port used for discovery.


shallowCopy

protected void shallowCopy(DiscoveryManager dmgr)
INTERNAL: invoke when the RCM shutdown. Subclass overrides this method if necessary.


getPacketTimeToLive

public int getPacketTimeToLive()
PUBLIC: Returns the number of hops the data packets of the session announcement will take before expiring. The default is 2, a hub and an interface card to prevent the data packets from leaving the local network.


setPacketTimeToLive

public void setPacketTimeToLive(int newPacketTimeToLive)
PUBLIC: Set the number of hops the data packets of the session announcement will take before expiring. The default is 2, a hub and an interface card to prevent the data packets from leaving the local network. Note that if sessions are hosted on different LANs that are part of WAN, the announcement sending by one session may not reach other sessions. In this case, consult your network administrator for the right time-to-live value or test your network by increase the value until sessions receive announcement sent by others.


EclipseLink 2.2.0, build 'v20110202-r8913' API Reference