Class 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
    • 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.
      • 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 JChannel.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 JChannel.connect(String) will throw an exception
      • stop

        public void stop()
        Description copied from class: Protocol
        This method is called on a JChannel.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. 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 using down_prot.down().
        Overrides:
        down in class Protocol
      • 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 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
      • 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.
        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)