Class UDPDiscoverySender
java.lang.Object
org.apache.commons.jcs3.utils.discovery.UDPDiscoverySender
- All Implemented Interfaces:
AutoCloseable
This is a generic sender for the UDPDiscovery process.
-
Constructor Summary
ConstructorsConstructorDescriptionUDPDiscoverySender
(String host, int port, int udpTTL) Deprecated.Specify serializer implementation explicitlyUDPDiscoverySender
(String mcastInterface, String host, int port, int udpTTL, IElementSerializer serializer) Constructor for the UDPDiscoverySender objectUDPDiscoverySender
(UDPDiscoveryAttributes udpDiscoveryAttributes, IElementSerializer serializer) Constructor for the UDPDiscoverySender object -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the socket connection.void
passiveBroadcast
(String host, int port, ArrayList<String> cacheNames) This sends a message broadcasting out that the host and port is available for connections.protected void
passiveBroadcast
(String host, int port, ArrayList<String> cacheNames, long listenerId) This allows you to set the sender id.void
removeBroadcast
(String host, int port, ArrayList<String> cacheNames) This sends a message broadcasting our that the host and port is no longer available.protected void
removeBroadcast
(String host, int port, ArrayList<String> cacheNames, long listenerId) This allows you to set the sender id.void
Ask other to broadcast their info the multicast address.void
send
(UDPDiscoveryMessage message) Send messages.
-
Constructor Details
-
UDPDiscoverySender
Deprecated.Specify serializer implementation explicitlyConstructor for the UDPDiscoverySender objectThis sender can be used to send multiple messages.
When you are done sending, you should destroy the socket sender.
- Parameters:
host
-port
-udpTTL
- the Datagram packet time-to-live- Throws:
IOException
-
UDPDiscoverySender
public UDPDiscoverySender(UDPDiscoveryAttributes udpDiscoveryAttributes, IElementSerializer serializer) throws IOException Constructor for the UDPDiscoverySender objectThis sender can be used to send multiple messages.
When you are done sending, you should destroy the socket sender.
- Parameters:
udpDiscoveryAttributes
- configuration objectserializer
- the Serializer to use when sending messages- Throws:
IOException
- Since:
- 3.1
-
UDPDiscoverySender
public UDPDiscoverySender(String mcastInterface, String host, int port, int udpTTL, IElementSerializer serializer) throws IOException Constructor for the UDPDiscoverySender objectThis sender can be used to send multiple messages.
When you are done sending, you should destroy the socket sender.
- Parameters:
mcastInterface
- the Multicast interface name to use, if null, try to autodetecthost
-port
-udpTTL
- the Datagram packet time-to-liveserializer
- the Serializer to use when sending messages- Throws:
IOException
- Since:
- 3.1
-
-
Method Details
-
close
Closes the socket connection.- Specified by:
close
in interfaceAutoCloseable
-
send
Send messages.- Parameters:
message
-- Throws:
IOException
-
requestBroadcast
Ask other to broadcast their info the multicast address. If a lateral is non receiving it can use this. This is also called on startup so we can get info.- Throws:
IOException
-
passiveBroadcast
public void passiveBroadcast(String host, int port, ArrayList<String> cacheNames) throws IOException This sends a message broadcasting out that the host and port is available for connections.It uses the vmid as the requesterDI
- Parameters:
host
-port
-cacheNames
-- Throws:
IOException
-
passiveBroadcast
protected void passiveBroadcast(String host, int port, ArrayList<String> cacheNames, long listenerId) throws IOException This allows you to set the sender id. This is mainly for testing.- Parameters:
host
-port
-cacheNames
- names of the cache regionslistenerId
-- Throws:
IOException
-
removeBroadcast
This sends a message broadcasting our that the host and port is no longer available.It uses the vmid as the requesterID
- Parameters:
host
- hostport
- portcacheNames
- names of the cache regions- Throws:
IOException
- on error
-
removeBroadcast
protected void removeBroadcast(String host, int port, ArrayList<String> cacheNames, long listenerId) throws IOException This allows you to set the sender id. This is mainly for testing.- Parameters:
host
- hostport
- portcacheNames
- names of the cache regionslistenerId
- listener ID- Throws:
IOException
- on error
-