Class DiscoveryManager
java.lang.Object
org.eclipse.persistence.sessions.coordination.DiscoveryManager
- All Implemented Interfaces:
- 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:
- Author:
- Steven Vo
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected intDelay time in millis between initialization and when the announcement is sentprotected MulticastSocketThe multicast socket used for discoverystatic final intstatic final StringDefault value constantsstatic final intstatic final intprotected StringDefines the IP address of the multicast groupprotected intDefines the port the multicast socket will be usingprotected intNumber 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 RemoteCommandManagerThe remote command manager responsible for this serviceprotected booleanIndicates to the listening thread that it should stop
- 
Constructor SummaryConstructorsConstructorDescriptionDiscoveryManager(String address, int port, int delay, RemoteCommandManager mgr) DiscoveryManager(String address, int port, RemoteCommandManager mgr) Constructors to create a discovery manager.
- 
Method SummaryModifier and TypeMethodDescriptionvoidINTERNAL: Send out an announcement that we are here.voidINTERNAL: Create the multicast socket and join the multicast group.intPUBLIC: 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.INTERNAL: Return the socket that will be used for the multicast.PUBLIC: Return the host address of the multicast group.intPUBLIC: Return the multicast port used for discovery.intPUBLIC: Returns the number of hops the data packets of the session announcement will take before expiring.booleanADVANCED: Return true if discovery has been stopped at the time this method is called.voidreceivedAnnouncement(ServiceId serviceId) INTERNAL: Process the announcement that indicates that a new service is onlinevoidrun()INTERNAL: This is the main execution method of discovery.voidsetAnnouncementDelay(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.voidsetMulticastGroupAddress(String address) PUBLIC: Set the host address of the multicast group.voidsetMulticastPort(int port) PUBLIC: Set the multicast port used for discovery.voidsetPacketTimeToLive(int newPacketTimeToLive) PUBLIC: Set the number of hops the data packets of the session announcement will take before expiring.protected voidshallowCopy(DiscoveryManager dmgr) INTERNAL: invoke when the RCM shutdown.voidADVANCED: Announce the local service and join the clustervoidINTERNAL: This method puts us into the listening mode loop.voidADVANCED: Stop accepting announcements from other services becoming available.voidINTERNAL: Signal this instance to stop listening.
- 
Field Details- 
DEFAULT_MULTICAST_GROUPDefault value constants- See Also:
 
- 
DEFAULT_MULTICAST_PORTpublic static final int DEFAULT_MULTICAST_PORT- See Also:
 
- 
DEFAULT_PACKET_TIME_TO_LIVEpublic static final int DEFAULT_PACKET_TIME_TO_LIVE- See Also:
 
- 
DEFAULT_ANNOUNCEMENT_DELAYpublic static final int DEFAULT_ANNOUNCEMENT_DELAY- See Also:
 
- 
multicastGroupAddressDefines the IP address of the multicast group
- 
multicastPortprotected int multicastPortDefines the port the multicast socket will be using
- 
communicationSocketThe multicast socket used for discovery
- 
packetTimeToLiveprotected int packetTimeToLiveNumber 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.
- 
stopListeningprotected boolean stopListeningIndicates to the listening thread that it should stop
- 
announcementDelayprotected int announcementDelayDelay time in millis between initialization and when the announcement is sent
- 
rcmThe remote command manager responsible for this service
 
- 
- 
Constructor Details- 
DiscoveryManagerConstructors to create a discovery manager.
- 
DiscoveryManager
- 
DiscoveryManager
 
- 
- 
Method Details- 
announceSessionpublic void announceSession()INTERNAL: Send out an announcement that we are here.
- 
startDiscoverypublic void startDiscovery()ADVANCED: Announce the local service and join the cluster
- 
stopDiscoverypublic void stopDiscovery()ADVANCED: Stop accepting announcements from other services becoming available. Note that this does not remove the local service from the cluster.
- 
isDiscoveryStoppedpublic 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.
- 
createCommunicationSocketpublic void createCommunicationSocket()INTERNAL: Create the multicast socket and join the multicast group.
- 
getCommunicationSocketINTERNAL: Return the socket that will be used for the multicast.
- 
runpublic 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.
- 
startListeningpublic 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.
- 
stopListeningpublic void stopListening()INTERNAL: Signal this instance to stop listening.
- 
receivedAnnouncementINTERNAL: Process the announcement that indicates that a new service is online
- 
setAnnouncementDelaypublic 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.
- 
getAnnouncementDelaypublic 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.
- 
getMulticastGroupAddressPUBLIC: Return the host address of the multicast group.
- 
setMulticastGroupAddressPUBLIC: Set the host address of the multicast group. Takes effect the next time listening is started.
- 
setMulticastPortpublic void setMulticastPort(int port) PUBLIC: Set the multicast port used for discovery. Takes effect the next time listening is started.
- 
getMulticastPortpublic int getMulticastPort()PUBLIC: Return the multicast port used for discovery.
- 
shallowCopyINTERNAL: invoke when the RCM shutdown. Subclass overrides this method if necessary.
- 
getPacketTimeToLivepublic 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.
- 
setPacketTimeToLivepublic 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.
 
-