Interface BroadcastEndpoint

All Known Implementing Classes:
JGroupsBroadcastEndpoint, JGroupsChannelBroadcastEndpoint, JGroupsFileBroadcastEndpoint

public interface BroadcastEndpoint
BroadcastEndpint is used in BroadcastGroups and DiscoveryGroups for topology updates.

A BroadcastEndpoint can perform one of the two following tasks:

  • when being used in BroadcastGroups, it broadcasts connector informations
  • when being used in DiscoveryGroups, it receives broadcasts

The two tasks are mutual exclusive, meaning a BroadcastEndpoint can either be a broadcaster or a receiver, but not both.

It is an abstraction of various concrete broadcasting mechanisms. Different implementations of this interface may use different broadcasting techniques like UDP multicasting or JGroups channels.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    broadcast(byte[] data)
    Broadcasting data to the cluster.
    void
    close(boolean isBroadcast)
    Close the endpoint.
    void
    This method initializes a BroadcastEndpint as a broadcaster.
    void
    This method initializes a BroadcastEndpoint as a receiving end for broadcasts.
    byte[]
    Receives the broadcast data.
    byte[]
    receiveBroadcast(long time, TimeUnit unit)
    Receives the broadcast data with a timeout.
  • Method Details

    • openClient

      void openClient() throws Exception
      This method initializes a BroadcastEndpoint as a receiving end for broadcasts. After that data can be received using one of its receiveBroadcast() methods.
      Throws:
      Exception
    • openBroadcaster

      void openBroadcaster() throws Exception
      This method initializes a BroadcastEndpint as a broadcaster. After that data can be sent via its broadcast() method.
      Throws:
      Exception
    • close

      void close(boolean isBroadcast) throws Exception
      Close the endpoint. Any related resources should be cleaned up in this method.
      Parameters:
      isBroadcast - : indicates whether this endpoint serves as a broadcast or not.
      Throws:
      Exception
    • broadcast

      void broadcast(byte[] data) throws Exception
      Broadcasting data to the cluster.
      Parameters:
      data - : a byte array containing the data.
      Throws:
      Exception
    • receiveBroadcast

      byte[] receiveBroadcast() throws Exception
      Receives the broadcast data. It blocks until data is available.
      Returns:
      the received data as byte array.
      Throws:
      Exception
    • receiveBroadcast

      byte[] receiveBroadcast(long time, TimeUnit unit) throws Exception
      Receives the broadcast data with a timeout. It blocks until either the data is available or the timeout is reached, whichever comes first.
      Parameters:
      time - : how long the method should wait for the data to arrive.
      unit - : unit of the time.
      Returns:
      a byte array if data is arrived within the timeout, or null if no data is available after the timeout.
      Throws:
      Exception