org.jgroups.protocols
Class FORWARD_TO_COORD

java.lang.Object
  extended by org.jgroups.stack.Protocol
      extended by 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
protected static class FORWARD_TO_COORD.ForwardHeader
           
 
Field Summary
protected  Address coord
          the address of the current coordinator, all msgs are forwarded to it
protected  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.
protected  long resend_delay
          Deprecated. 
 
Fields inherited from class org.jgroups.stack.Protocol
down_prot, ergonomics, id, log, name, stack, stats, up_prot
 
Constructor Summary
FORWARD_TO_COORD()
           
 
Method Summary
 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 a Channel.connect(String).
 void stop()
          This method is called on a Channel.disconnect().
 java.lang.Object up(Event evt)
          An event was received from the layer below.
 
Methods inherited from class org.jgroups.stack.Protocol
destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, init, isErgonomics, printStats, providedDownServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, statsEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resend_delay

@Deprecated
protected long resend_delay
Deprecated. 

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

Constructor Detail

FORWARD_TO_COORD

public FORWARD_TO_COORD()
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 class Protocol

start

public void start()
           throws java.lang.Exception
Description copied from class: Protocol
This method is called on a Channel.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 class Protocol
Throws:
java.lang.Exception - Thrown if protocol cannot be started successfully. This will cause the ProtocolStack to fail, so Channel.connect(String) will throw an exception

stop

public void stop()
Description copied from class: Protocol
This method is called on a Channel.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

Overrides:
stop in class Protocol

down

public java.lang.Object down(Event evt)
Description copied from class: Protocol
An event is to be sent down the stack. The layer 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 layer may need to add a header to it (or do nothing at all) before sending it down the stack using down_prot.down(). In case of a GET_ADDRESS event (which tries to retrieve the stack's address from one of the bottom layers), the layer may need to send a new response event back up the stack using up_prot.up().

Overrides:
down in class Protocol

up

public java.lang.Object up(Event evt)
Description copied from class: Protocol
An event was received from the layer below. Usually the current layer 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 using down_prot.down() or c) the event (or another event) is sent up the stack using up_prot.up().

Overrides:
up in class Protocol

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)


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.