public class MulticastPulseAgent extends java.lang.Object implements DiscoveryAgent, ServerService, SelfManaging
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BADURI |
static java.lang.String |
CLIENT |
static java.lang.String |
EMPTY |
static java.lang.String |
SERVER |
| Constructor and Description |
|---|
MulticastPulseAgent()
This agent listens for client pulses on a defined multicast channel.
|
| Modifier and Type | Method and Description |
|---|---|
DiscoveryListener |
getDiscoveryListener() |
java.lang.String |
getHosts()
Lists current broadcast hosts as a comma separated list.
|
java.lang.String |
getIP() |
java.lang.String |
getName() |
int |
getPort() |
java.net.DatagramPacket |
getResponsePacket() |
static java.net.MulticastSocket[] |
getSockets(java.lang.String multicastAddress,
int port)
Attempts to return at least one socket per valid network interface.
|
void |
init(java.util.Properties p) |
static boolean |
isLocalAddress(java.lang.String host,
boolean wildcardIsLocal)
Is the provided host a local host
|
static boolean |
isLoopback(java.lang.String host)
Is the provided host a valid loopback address
|
void |
registerService(java.net.URI uri)
register a service
|
boolean |
removeFromIgnore(java.lang.String host)
Remove a host from the ignore list.
|
void |
reportFailed(java.net.URI serviceUri)
A process actively using a service may see it go down before the DiscoveryAgent notices the
service's failure.
|
void |
service(java.io.InputStream in,
java.io.OutputStream out) |
void |
service(java.net.Socket socket) |
void |
setDiscoveryListener(DiscoveryListener listener)
Sets the discovery listener
|
void |
start() |
void |
stop() |
void |
unregisterService(java.net.URI uri)
register a service
|
public static final java.lang.String SERVER
public static final java.lang.String CLIENT
public static final java.lang.String BADURI
public static final java.lang.String EMPTY
public MulticastPulseAgent()
public void init(java.util.Properties p)
throws java.lang.Exception
public java.net.DatagramPacket getResponsePacket()
public void setDiscoveryListener(DiscoveryListener listener)
DiscoveryAgentsetDiscoveryListener in interface DiscoveryAgentpublic DiscoveryListener getDiscoveryListener()
public void registerService(java.net.URI uri)
throws java.io.IOException
DiscoveryAgentregisterService in interface DiscoveryAgentjava.io.IOExceptionpublic void unregisterService(java.net.URI uri)
throws java.io.IOException
DiscoveryAgentunregisterService in interface DiscoveryAgentjava.io.IOExceptionpublic void reportFailed(java.net.URI serviceUri)
throws java.io.IOException
DiscoveryAgentreportFailed in interface DiscoveryAgentjava.io.IOExceptionpublic void start()
throws ServiceException
start in interface ServerServiceServiceExceptionpublic void stop()
throws ServiceException
stop in interface ServerServiceServiceExceptionpublic void service(java.io.InputStream in,
java.io.OutputStream out)
throws ServiceException,
java.io.IOException
service in interface ServerServiceServiceExceptionjava.io.IOExceptionpublic void service(java.net.Socket socket)
throws ServiceException,
java.io.IOException
service in interface ServerServiceServiceExceptionjava.io.IOExceptionpublic java.lang.String getName()
getName in interface ServerServicepublic java.lang.String getIP()
getIP in interface ServerServicepublic int getPort()
getPort in interface ServerServicepublic java.lang.String getHosts()
public boolean removeFromIgnore(java.lang.String host)
host - Stringpublic static java.net.MulticastSocket[] getSockets(java.lang.String multicastAddress,
int port)
throws java.lang.Exception
multicastAddress - A valid multicast addressport - A valid multicast portjava.lang.Exception - On invalid parameterspublic static boolean isLoopback(java.lang.String host)
host - Host to testpublic static boolean isLocalAddress(java.lang.String host,
boolean wildcardIsLocal)
host - The host to testwildcardIsLocal - Should 0.0.0.0 or [::] be deemed as local