Interface BroadcastEndpoint
-
- All Known Implementing Classes:
JGroupsBroadcastEndpoint,JGroupsChannelBroadcastEndpoint,JGroupsFileBroadcastEndpoint
public interface BroadcastEndpointBroadcastEndpint 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:
JGroupsBroadcastEndpoint
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidbroadcast(byte[] data)Broadcasting data to the cluster.voidclose(boolean isBroadcast)Close the endpoint.voidopenBroadcaster()This method initializes a BroadcastEndpint as a broadcaster.voidopenClient()This method initializes a BroadcastEndpoint as a receiving end for broadcasts.byte[]receiveBroadcast()Receives the broadcast data.byte[]receiveBroadcast(long time, TimeUnit unit)Receives the broadcast data with a timeout.
-
-
-
Method Detail
-
openClient
void openClient() throws ExceptionThis 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 ExceptionThis 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 ExceptionClose 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 ExceptionBroadcasting data to the cluster.- Parameters:
data- : a byte array containing the data.- Throws:
Exception
-
receiveBroadcast
byte[] receiveBroadcast() throws ExceptionReceives 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 ExceptionReceives 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
-
-