Package org.jgroups.tests.rt.transports
Class JGroupsTransport
- java.lang.Object
-
- org.jgroups.tests.rt.transports.JGroupsTransport
-
- All Implemented Interfaces:
Receiver,RtTransport
public class JGroupsTransport extends java.lang.Object implements Receiver, RtTransport
- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description protected JChannelchprotected booleandont_bundleprotected Loglogprotected booleanoobprotected RtReceiverreceiverprotected Viewview
-
Constructor Summary
Constructors Constructor Description JGroupsTransport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<Address>clusterMembers()Returns the addresses of all cluster members.AddresslocalAddress()Returns the local addres of this member.java.lang.String[]options()Prints the accepted options, e.g.voidoptions(java.lang.String... options)Sets options on this transport.voidreceive(Message msg)Called when a message is received.voidreceive(MessageBatch batch)Called when a batch of messages is receivedvoidreceiver(RtReceiver receiver)Sets the receiver whoseRtReceiver.receive(Object,byte[],int,int)callback will be invoked whenever a message is receivedvoidsend(java.lang.Object dest, byte[] buf, int offset, int length)Sends a messagevoidstart(java.lang.String... options)Starts the transport, e.g.voidstop()Stops the transport, e.g.voidviewAccepted(View view)Called when a change in membership has occurred.
-
-
-
Field Detail
-
ch
protected JChannel ch
-
receiver
protected RtReceiver receiver
-
view
protected View view
-
oob
protected boolean oob
-
dont_bundle
protected boolean dont_bundle
-
log
protected final Log log
-
-
Method Detail
-
options
public java.lang.String[] options()
Description copied from interface:RtTransportPrints the accepted options, e.g. [-host host] [-port port] [-server host]- Specified by:
optionsin interfaceRtTransport- Returns:
-
options
public void options(java.lang.String... options) throws java.lang.ExceptionDescription copied from interface:RtTransportSets options on this transport. Usually done after creation and beforeRtTransport.start(String...)is called, but may also be called at runtime.- Specified by:
optionsin interfaceRtTransport- Parameters:
options- The options- Throws:
java.lang.Exception
-
receiver
public void receiver(RtReceiver receiver)
Description copied from interface:RtTransportSets the receiver whoseRtReceiver.receive(Object,byte[],int,int)callback will be invoked whenever a message is received- Specified by:
receiverin interfaceRtTransport
-
localAddress
public Address localAddress()
Description copied from interface:RtTransportReturns the local addres of this member.- Specified by:
localAddressin interfaceRtTransport- Returns:
- The local address. Implementations without cluster membership may return null
-
clusterMembers
public java.util.List<Address> clusterMembers()
Description copied from interface:RtTransportReturns the addresses of all cluster members. May return null if not implemented- Specified by:
clusterMembersin interfaceRtTransport- Returns:
- The list of all members in the cluster
-
start
public void start(java.lang.String... options) throws java.lang.ExceptionDescription copied from interface:RtTransportStarts the transport, e.g. connecting to a server socket- Specified by:
startin interfaceRtTransport- Parameters:
options- Options passed to the transport at startup time. May be null- Throws:
java.lang.Exception
-
stop
public void stop()
Description copied from interface:RtTransportStops the transport, e.g. stopping the accept() loop in a TCP-based server- Specified by:
stopin interfaceRtTransport
-
send
public void send(java.lang.Object dest, byte[] buf, int offset, int length) throws java.lang.ExceptionDescription copied from interface:RtTransportSends a message- Specified by:
sendin interfaceRtTransport- Parameters:
dest- The destination addressbuf- The bufferoffset- The offset at which the data startslength- The length (in bytes) of the data to send- Throws:
java.lang.Exception
-
receive
public void receive(MessageBatch batch)
Description copied from interface:ReceiverCalled when a batch of messages is received
-
receive
public void receive(Message msg)
Description copied from interface:ReceiverCalled when a message is received.
-
viewAccepted
public void viewAccepted(View view)
Description copied from interface:ReceiverCalled when a change in membership has occurred. No long running actions, sending of messages or anything that could block should be done in this callback. If some long running action needs to be performed, it should be done in a separate thread.
Note that on reception of the first view (a new member just joined), the channel will not yet be in the connected state. This only happens whenJChannel.connect(String)returns.- Specified by:
viewAcceptedin interfaceReceiver
-
-