Top Description Fields Constructors Methods
org.eclipse.persistence.sessions.coordination

public Class DiscoveryManager

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.net.*, java.io.IOException, org.eclipse.persistence.exceptions.DiscoveryException, org.eclipse.persistence.internal.sessions.coordination.*, org.eclipse.persistence.sessions.SessionProfiler

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.

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

Field Summary

Modifier and TypeField and Description
protected int
announcementDelay

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

protected MulticastSocket
communicationSocket

The multicast socket used for discovery

public static final int
public static final String
DEFAULT_MULTICAST_GROUP

Default value constants

public static final int
public static final int
protected 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

AccessConstructor and Description
public
DiscoveryManager(RemoteCommandManager mgr)

Constructors to create a discovery manager.

public
public
DiscoveryManager(String address, int port, int delay, RemoteCommandManager mgr)

Method Summary

Modifier and TypeMethod and Description
public void
announceSession()

INTERNAL: Send out an announcement that we are here.

public void
createCommunicationSocket()

INTERNAL: Create the multicast socket and join the multicast group.

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.

public MulticastSocket
getCommunicationSocket()

INTERNAL: Return the socket that will be used for the multicast.

public String
getMulticastGroupAddress()

PUBLIC: Return the host address of the multicast group.

public int
getMulticastPort()

PUBLIC: Return the multicast port used for discovery.

public int
getPacketTimeToLive()

PUBLIC: Returns the number of hops the data packets of the session announcement will take before expiring.

public boolean
isDiscoveryStopped()

ADVANCED: Return true if discovery has been stopped at the time this method is called.

public void
receivedAnnouncement(ServiceId serviceId)

INTERNAL: Process the announcement that indicates that a new service is online

public void
run()

Implements java.lang.Runnable.run.

INTERNAL: This is the main execution method of discovery.
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.

public void
setMulticastGroupAddress(String address)

PUBLIC: Set the host address of the multicast group.

public void
setMulticastPort(int port)

PUBLIC: Set the multicast port used for discovery.

public 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.

public void
startDiscovery()

ADVANCED: Announce the local service and join the cluster

public void
startListening()

INTERNAL: This method puts us into the listening mode loop.

public void
stopDiscovery()

ADVANCED: Stop accepting announcements from other services becoming available.

public void
stopListening()

INTERNAL: Signal this instance to stop listening.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

announcementDelayback to summary
protected int announcementDelay

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

communicationSocketback to summary
protected MulticastSocket communicationSocket

The multicast socket used for discovery

DEFAULT_ANNOUNCEMENT_DELAYback to summary
public static final int DEFAULT_ANNOUNCEMENT_DELAY
DEFAULT_MULTICAST_GROUPback to summary
public static final String DEFAULT_MULTICAST_GROUP

Default value constants

DEFAULT_MULTICAST_PORTback to summary
public static final int DEFAULT_MULTICAST_PORT
DEFAULT_PACKET_TIME_TO_LIVEback to summary
public static final int DEFAULT_PACKET_TIME_TO_LIVE
multicastGroupAddressback to summary
protected String multicastGroupAddress

Defines the IP address of the multicast group

multicastPortback to summary
protected int multicastPort

Defines the port the multicast socket will be using

packetTimeToLiveback to summary
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.

rcmback to summary
protected RemoteCommandManager rcm

The remote command manager responsible for this service

stopListeningback to summary
protected boolean stopListening

Indicates to the listening thread that it should stop

Constructor Detail

DiscoveryManagerback to summary
public DiscoveryManager(RemoteCommandManager mgr)

Constructors to create a discovery manager.

DiscoveryManagerback to summary
public DiscoveryManager(String address, int port, RemoteCommandManager mgr)
DiscoveryManagerback to summary
public DiscoveryManager(String address, int port, int delay, RemoteCommandManager mgr)

Method Detail

announceSessionback to summary
public void announceSession()

INTERNAL: Send out an announcement that we are here.

createCommunicationSocketback to summary
public void createCommunicationSocket()

INTERNAL: Create the multicast socket and join the multicast group.

getAnnouncementDelayback to summary
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.

getCommunicationSocketback to summary
public MulticastSocket getCommunicationSocket()

INTERNAL: Return the socket that will be used for the multicast.

getMulticastGroupAddressback to summary
public String getMulticastGroupAddress()

PUBLIC: Return the host address of the multicast group.

getMulticastPortback to summary
public int getMulticastPort()

PUBLIC: Return the multicast port used for discovery.

getPacketTimeToLiveback to summary
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.

isDiscoveryStoppedback to summary
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.

receivedAnnouncementback to summary
public void receivedAnnouncement(ServiceId serviceId)

INTERNAL: Process the announcement that indicates that a new service is online

runback to summary
public void run()

Implements java.lang.Runnable.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.

Annotations
@Override
setAnnouncementDelayback to summary
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.

setMulticastGroupAddressback to summary
public void setMulticastGroupAddress(String address)

PUBLIC: Set the host address of the multicast group. Takes effect the next time listening is started.

setMulticastPortback to summary
public void setMulticastPort(int port)

PUBLIC: Set the multicast port used for discovery. Takes effect the next time listening is started.

setPacketTimeToLiveback to summary
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.

shallowCopyback to summary
protected void shallowCopy(DiscoveryManager dmgr)

INTERNAL: invoke when the RCM shutdown. Subclass overrides this method if necessary.

startDiscoveryback to summary
public void startDiscovery()

ADVANCED: Announce the local service and join the cluster

startListeningback to summary
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.

stopDiscoveryback to summary
public void stopDiscovery()

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

stopListeningback to summary
public void stopListening()

INTERNAL: Signal this instance to stop listening.