public class MulticastDiscoveryAgent extends Object implements DiscoveryAgent, Runnable
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DISCOVERY_URI_STRING |
static String |
DEFAULT_HOST_IP |
static String |
DEFAULT_HOST_STR |
static int |
DEFAULT_PORT |
Constructor and Description |
---|
MulticastDiscoveryAgent(URI discoveryURI) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Stops the agent after which no new remote peers will be found.
|
DiscoveryListener |
getDiscoveryListener() |
URI |
getDiscvoeryURI() |
String |
getGroup() |
long |
getKeepAliveInterval() |
PacketParser |
getParser() |
String |
getService()
Returns the name of the service that is providing the discovery data for this agent such
as ActiveMQ.
|
int |
getTimeToLive() |
boolean |
isLoopBackMode() |
boolean |
isSchedulerRequired()
Indicates if this DiscoveryAgent requires a ScheduledExecutorService in order
to perform its discovery work.
|
void |
resume()
Resumes discovery by this agent if it was previously suspended.
|
void |
run() |
void |
setDiscoveryListener(DiscoveryListener listener)
Sets the discovery listener
|
void |
setGroup(String group)
Sets the multicast group this agent is assigned to.
|
void |
setInterface(String mcInterface) |
void |
setJoinNetworkInterface(String mcJoinNetwrokInterface) |
void |
setKeepAliveInterval(long keepAliveInterval) |
void |
setLoopBackMode(boolean loopBackMode) |
void |
setNetworkInterface(String mcNetworkInterface) |
void |
setParser(PacketParser parser)
Sets the datagram packet parser used to read the discovery data broadcast by the service
being monitored for remote peers.
|
void |
setScheduler(ScheduledExecutorService scheduler)
Provider a ScheduledExecutorService to the DiscoveryAgent that requires a
scheduler to perform its discovery work.
|
void |
setService(String name)
Sets the name of the service that is providing the remote peer discovery data.
|
void |
setTimeToLive(int timeToLive) |
void |
start()
Starts the agent after which new remote peers can start to be found.
|
void |
suspend()
Suspends the Agent which suppresses any new attempts to discover remote
peers until the agent is resumed.
|
String |
toString() |
static void |
trySetNetworkInterface(MulticastSocket mcastSock) |
public static final String DEFAULT_DISCOVERY_URI_STRING
public static final String DEFAULT_HOST_STR
public static final String DEFAULT_HOST_IP
public static final int DEFAULT_PORT
public MulticastDiscoveryAgent(URI discoveryURI)
public void setDiscoveryListener(DiscoveryListener listener)
DiscoveryAgent
setDiscoveryListener
in interface DiscoveryAgent
listener
- the listener to notify on discovery events, or null to clear.public DiscoveryListener getDiscoveryListener()
public void setScheduler(ScheduledExecutorService scheduler)
DiscoveryAgent
setScheduler
in interface DiscoveryAgent
scheduler
- An initialized Scheduler service that this agent can use for its work.public boolean isSchedulerRequired()
DiscoveryAgent
isSchedulerRequired
in interface DiscoveryAgent
public void start() throws IOException, IllegalStateException
DiscoveryAgent
start
in interface DiscoveryAgent
IOException
- if an IO error occurs while starting the agent.IllegalStateException
- if the agent is not properly configured.public void close()
DiscoveryAgent
close
in interface DiscoveryAgent
public void suspend()
DiscoveryAgent
suspend
in interface DiscoveryAgent
public void resume()
DiscoveryAgent
resume
in interface DiscoveryAgent
public URI getDiscvoeryURI()
public boolean isLoopBackMode()
public void setLoopBackMode(boolean loopBackMode)
loopBackMode
- The loopBackMode to set.public int getTimeToLive()
public void setTimeToLive(int timeToLive)
timeToLive
- The timeToLive to set.public long getKeepAliveInterval()
public void setKeepAliveInterval(long keepAliveInterval)
public void setInterface(String mcInterface)
public void setNetworkInterface(String mcNetworkInterface)
public void setJoinNetworkInterface(String mcJoinNetwrokInterface)
public String getGroup()
public void setGroup(String group)
group
- the multicast group the agent is assigned to.public String getService()
public void setService(String name)
name
- the name of the service that provides this agent with remote peer data.public PacketParser getParser()
public void setParser(PacketParser parser)
parser
- the datagram packet parser to use.public static void trySetNetworkInterface(MulticastSocket mcastSock) throws SocketException
SocketException
Copyright © 2013–2016 The Apache Software Foundation. All rights reserved.