Class UDPDiscoverySender

java.lang.Object
org.apache.commons.jcs3.utils.discovery.UDPDiscoverySender
All Implemented Interfaces:
AutoCloseable

public class UDPDiscoverySender extends Object implements AutoCloseable
This is a generic sender for the UDPDiscovery process.
  • Constructor Details

    • UDPDiscoverySender

      @Deprecated public UDPDiscoverySender(String host, int port, int udpTTL) throws IOException
      Deprecated.
      Specify serializer implementation explicitly
      Constructor for the UDPDiscoverySender object

      This 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 object

      This sender can be used to send multiple messages.

      When you are done sending, you should destroy the socket sender.

      Parameters:
      udpDiscoveryAttributes - configuration object
      serializer - 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 object

      This 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 autodetect
      host -
      port -
      udpTTL - the Datagram packet time-to-live
      serializer - the Serializer to use when sending messages
      Throws:
      IOException
      Since:
      3.1
  • Method Details

    • close

      public void close()
      Closes the socket connection.
      Specified by:
      close in interface AutoCloseable
    • send

      public void send(UDPDiscoveryMessage message) throws IOException
      Send messages.

      Parameters:
      message -
      Throws:
      IOException
    • requestBroadcast

      public void requestBroadcast() throws IOException
      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 regions
      listenerId -
      Throws:
      IOException
    • removeBroadcast

      public void removeBroadcast(String host, int port, ArrayList<String> cacheNames) throws IOException
      This sends a message broadcasting our that the host and port is no longer available.

      It uses the vmid as the requesterID

      Parameters:
      host - host
      port - port
      cacheNames - 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 - host
      port - port
      cacheNames - names of the cache regions
      listenerId - listener ID
      Throws:
      IOException - on error