Class JGroupsBroadcastEndpoint
- java.lang.Object
-
- org.apache.activemq.artemis.api.core.JGroupsBroadcastEndpoint
-
- All Implemented Interfaces:
BroadcastEndpoint
- Direct Known Subclasses:
JGroupsChannelBroadcastEndpoint,JGroupsFileBroadcastEndpoint,JGroupsPropertiesBroadcastEndpoint
public abstract class JGroupsBroadcastEndpoint extends java.lang.Object implements BroadcastEndpoint
This class is the implementation of ActiveMQ Artemis members discovery that will use JGroups.
-
-
Constructor Summary
Constructors Constructor Description JGroupsBroadcastEndpoint(JChannelManager manager, java.lang.String channelName)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidbroadcast(byte[] data)Broadcasting data to the cluster.voidclose(boolean isBroadcast)Close the endpoint.abstract org.jgroups.JChannelcreateChannel()JGroupsBroadcastEndpointinitChannel()protected voidinternalCloseChannel(JChannelWrapper channel)Closes the channel used in this JGroups Broadcast.protected voidinternalOpen()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, java.util.concurrent.TimeUnit unit)Receives the broadcast data with a timeout.
-
-
-
Constructor Detail
-
JGroupsBroadcastEndpoint
public JGroupsBroadcastEndpoint(JChannelManager manager, java.lang.String channelName)
-
-
Method Detail
-
broadcast
public void broadcast(byte[] data) throws java.lang.ExceptionDescription copied from interface:BroadcastEndpointBroadcasting data to the cluster.- Specified by:
broadcastin interfaceBroadcastEndpoint- Parameters:
data- : a byte array containing the data.- Throws:
java.lang.Exception
-
receiveBroadcast
public byte[] receiveBroadcast() throws java.lang.ExceptionDescription copied from interface:BroadcastEndpointReceives the broadcast data. It blocks until data is available.- Specified by:
receiveBroadcastin interfaceBroadcastEndpoint- Returns:
- the received data as byte array.
- Throws:
java.lang.Exception
-
receiveBroadcast
public byte[] receiveBroadcast(long time, java.util.concurrent.TimeUnit unit) throws java.lang.ExceptionDescription copied from interface:BroadcastEndpointReceives the broadcast data with a timeout. It blocks until either the data is available or the timeout is reached, whichever comes first.- Specified by:
receiveBroadcastin interfaceBroadcastEndpoint- 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:
java.lang.Exception
-
openClient
public void openClient() throws java.lang.ExceptionDescription copied from interface:BroadcastEndpointThis method initializes a BroadcastEndpoint as a receiving end for broadcasts. After that data can be received using one of its receiveBroadcast() methods.- Specified by:
openClientin interfaceBroadcastEndpoint- Throws:
java.lang.Exception
-
openBroadcaster
public void openBroadcaster() throws java.lang.ExceptionDescription copied from interface:BroadcastEndpointThis method initializes a BroadcastEndpint as a broadcaster. After that data can be sent via its broadcast() method.- Specified by:
openBroadcasterin interfaceBroadcastEndpoint- Throws:
java.lang.Exception
-
createChannel
public abstract org.jgroups.JChannel createChannel() throws java.lang.Exception- Throws:
java.lang.Exception
-
initChannel
public JGroupsBroadcastEndpoint initChannel() throws java.lang.Exception
- Throws:
java.lang.Exception
-
internalOpen
protected void internalOpen() throws java.lang.Exception- Throws:
java.lang.Exception
-
close
public void close(boolean isBroadcast) throws java.lang.ExceptionDescription copied from interface:BroadcastEndpointClose the endpoint. Any related resources should be cleaned up in this method.- Specified by:
closein interfaceBroadcastEndpoint- Parameters:
isBroadcast- : indicates whether this endpoint serves as a broadcast or not.- Throws:
java.lang.Exception
-
internalCloseChannel
protected void internalCloseChannel(JChannelWrapper channel)
Closes the channel used in this JGroups Broadcast. Can be overridden by implementations that use an externally managed channel.- Parameters:
channel-
-
-