Package org.jgroups.tests.rt.transports
Class ServerTransport
- java.lang.Object
-
- org.jgroups.blocks.cs.ReceiverAdapter
-
- org.jgroups.tests.rt.transports.ServerTransport
-
- All Implemented Interfaces:
Receiver,RtTransport
public class ServerTransport extends ReceiverAdapter implements RtTransport
- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description protected java.net.InetAddresshostprotected Loglogprotected booleannioprotected intportprotected RtReceiverreceiverprotected booleanserverprotected BaseServersrv
-
Constructor Summary
Constructors Constructor Description ServerTransport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.lang.Object>clusterMembers()Returns the addresses of all cluster members.java.lang.ObjectlocalAddress()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(Address sender, byte[] buf, int offset, int length)Delivers a message from a given sender to the applicationvoidreceive(Address sender, java.io.DataInput in)voidreceiver(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.
-
-
-
Field Detail
-
srv
protected BaseServer srv
-
receiver
protected RtReceiver receiver
-
host
protected java.net.InetAddress host
-
port
protected int port
-
server
protected boolean server
-
nio
protected boolean nio
-
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 java.lang.Object 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<java.lang.Object> 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(Address sender, byte[] buf, int offset, int length)
Description copied from interface:ReceiverDelivers a message from a given sender to the application- Specified by:
receivein interfaceReceiver- Overrides:
receivein classReceiverAdapter- Parameters:
sender- The sender of the messagebuf- The buffer. An application typically de-serializes data from the buffer into objects used by the application. Note that when receive() returns, it is not safe to use the buffer any longer; if an application needs to use a buffer after this callback returns, it must make a copy.offset- The offset at which the received data startslength- The length of the received data
-
receive
public void receive(Address sender, java.io.DataInput in) throws java.lang.Exception
- Specified by:
receivein interfaceReceiver- Overrides:
receivein classReceiverAdapter- Throws:
java.lang.Exception
-
-