Package org.jgroups.protocols
Class FORWARD_TO_COORD
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- org.jgroups.protocols.FORWARD_TO_COORD
-
public class FORWARD_TO_COORD extends Protocol
Forwards a message to the current coordinator. When the coordinator changes, forwards all pending messages to the new coordinator. Only looks at unicast messages. Note that the ordering of messages sent in parallel to the resending of messages is currently (Sept 2012) undefined: when resending messages 1-4, and concurrently sending (new) messages 5 and 6, then FORWARD_TO_COORD only guarantees that messages [1,2,3,4] are delivered in that order and messages [5,6] are delivered in that order, too, but there are no guarantees regarding the ordering between [1,2,3,4] and [5,6], e.g. a receiver could deliver 1,5,2,3,6,4. This is currently not an issue, as the main consumer of FORWARD_TO_COORD is RELAY2, which is used by Infinispan to invoke sync or async RPCs across sites. In the former case, a unicast #2 will not be sent until unicast #1 is either ack'ed or times out. In a future version, ordering may be provided. Note though that OOB or UNRELIABLE messages don't need to be ordered.- Since:
- 3.2
- Author:
- Bela Ban
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
FORWARD_TO_COORD.ForwardHeader
-
Field Summary
Fields Modifier and Type Field Description protected Address
coord
the address of the current coordinator, all msgs are forwarded to itprotected java.util.concurrent.atomic.AtomicLong
current_id
ID to be used to identify forwarded messages.protected ForwardQueue
fwd_queue
protected Address
local_addr
protected boolean
received_not_coord
Set when NOT_COORD message has been received.-
Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, log, stack, stats, up_prot
-
-
Constructor Summary
Constructors Constructor Description FORWARD_TO_COORD()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
down(Event evt)
An event is to be sent down the stack.int
getDeliveryTableSize()
int
getForwardTableSize()
protected long
getNextId()
protected void
handleViewChange(View view)
java.util.List<java.lang.Integer>
providedUpServices()
List of events that are provided to layers above (they will be handled when sent down from above)protected void
send(Address target, long ack_id, byte type)
protected void
sendAck(Address target, long ack_id)
protected void
sendNotCoord(Address target, long ack_id)
void
start()
This method is called on aJChannel.connect(String)
.void
stop()
This method is called on aJChannel.disconnect()
.java.lang.Object
up(Event evt)
An event was received from the protocol below.java.lang.Object
up(Message msg)
A single message was received.-
Methods inherited from class org.jgroups.stack.Protocol
accept, afterCreationHook, destroy, down, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, init, isErgonomics, level, parse, providedDownServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, statsEnabled, up
-
-
-
-
Field Detail
-
coord
protected volatile Address coord
the address of the current coordinator, all msgs are forwarded to it
-
local_addr
protected volatile Address local_addr
-
current_id
protected final java.util.concurrent.atomic.AtomicLong current_id
ID to be used to identify forwarded messages. Wrap-around shouldn't be an issue.
-
fwd_queue
protected final ForwardQueue fwd_queue
-
received_not_coord
protected volatile boolean received_not_coord
Set when NOT_COORD message has been received. This will trigger a fwd_queue flush even if the coord didn't change
-
-
Method Detail
-
getForwardTableSize
public int getForwardTableSize()
-
getDeliveryTableSize
public int getDeliveryTableSize()
-
providedUpServices
public java.util.List<java.lang.Integer> providedUpServices()
Description copied from class:Protocol
List of events that are provided to layers above (they will be handled when sent down from above)- Overrides:
providedUpServices
in classProtocol
-
start
public void start() throws java.lang.Exception
Description copied from class:Protocol
This method is called on aJChannel.connect(String)
. Starts work. Protocols are connected and queues are ready to receive events. Will be called from bottom to top. This call will replace the START and START_OK events.- Overrides:
start
in classProtocol
- Throws:
java.lang.Exception
- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack to fail, soJChannel.connect(String)
will throw an exception
-
stop
public void stop()
Description copied from class:Protocol
This method is called on aJChannel.disconnect()
. Stops work (e.g. by closing multicast socket). Will be called from top to bottom. This means that at the time of the method invocation the neighbor protocol below is still working. This method will replace the STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that when this method is called all messages in the down queue will have been flushed
-
down
public java.lang.Object down(Event evt)
Description copied from class:Protocol
An event is to be sent down the stack. A protocol may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the protocol may need to add a header to it (or do nothing at all) before sending it down the stack usingdown_prot.down()
.
-
up
public java.lang.Object up(Event evt)
Description copied from class:Protocol
An event was received from the protocol below. Usually the current protocol will want to examine the event type and - depending on its type - perform some computation (e.g. removing headers from a MSG event type, or updating the internal membership list when receiving a VIEW_CHANGE event). Finally the event is either a) discarded, or b) an event is sent down the stack usingdown_prot.down()
or c) the event (or another event) is sent up the stack usingup_prot.up()
.
-
up
public java.lang.Object up(Message msg)
Description copied from class:Protocol
A single message was received. Protocols may examine the message and do something (e.g. add a header) with it before passing it up.
-
getNextId
protected long getNextId()
-
handleViewChange
protected void handleViewChange(View view)
-
sendAck
protected void sendAck(Address target, long ack_id)
-
sendNotCoord
protected void sendNotCoord(Address target, long ack_id)
-
send
protected void send(Address target, long ack_id, byte type)
-
-