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.
RemoteCommandManager
, MulticastSocket
Modifier and Type | Field and Description |
---|---|
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 |
Constructor and Description |
---|
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) |
Modifier and Type | Method and Description |
---|---|
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.
|
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.
|
public static final java.lang.String DEFAULT_MULTICAST_GROUP
public static final int DEFAULT_MULTICAST_PORT
public static final int DEFAULT_PACKET_TIME_TO_LIVE
public static final int DEFAULT_ANNOUNCEMENT_DELAY
public DiscoveryManager(RemoteCommandManager mgr)
public DiscoveryManager(java.lang.String address, int port, RemoteCommandManager mgr)
public DiscoveryManager(java.lang.String address, int port, int delay, RemoteCommandManager mgr)
public void announceSession()
public void startDiscovery()
public void stopDiscovery()
public boolean isDiscoveryStopped()
public void createCommunicationSocket()
public java.net.MulticastSocket getCommunicationSocket()
public void run()
run
in interface java.lang.Runnable
public void startListening()
public void stopListening()
public void receivedAnnouncement(ServiceId serviceId)
public void setAnnouncementDelay(int millisecondsToDelay)
public int getAnnouncementDelay()
public java.lang.String getMulticastGroupAddress()
public void setMulticastGroupAddress(java.lang.String address)
public void setMulticastPort(int port)
public int getMulticastPort()
public int getPacketTimeToLive()
public void setPacketTimeToLive(int newPacketTimeToLive)