Class FLUSH

java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.pbcast.FLUSH
All Implemented Interfaces:
Lifecycle

@Deprecated(since="5.3.5", forRemoval=true) public class FLUSH extends Protocol
Deprecated, for removal: This API element is subject to removal in a future version.
Over 20 years old and nodoby uses it. Will be removed in 5.4
Flush, as it name implies, forces group members to flush their pending messages while blocking them to send any additional messages. The process of flushing acquiesces the group so that state transfer or a join can be done. It is also called stop-the-world model as nobody will be able to send messages while a flush is in process.

Flush is needed for:

(1) State transfer. When a member requests state transfer, the coordinator tells everyone to stop sending messages and waits for everyone's ack. Then it asks the application for its state and ships it back to the requester. After the requester has received and set the state successfully, the coordinator tells everyone to resume sending messages.

(2) View changes (e.g.a join). Before installing a new view V2, flushing would ensure that all messages *sent* in the current view V1 are indeed *delivered* in V1, rather than in V2 (in all non-faulty members). This is essentially Virtual Synchrony.

Since:
2.4
  • Field Details

    • SUCCESS_START_FLUSH

      private static final FLUSH.FlushStartResult SUCCESS_START_FLUSH
      Deprecated, for removal: This API element is subject to removal in a future version.
    • timeout

      protected long timeout
      Deprecated, for removal: This API element is subject to removal in a future version.
    • start_flush_timeout

      protected long start_flush_timeout
      Deprecated, for removal: This API element is subject to removal in a future version.
    • end_flush_timeout

      protected long end_flush_timeout
      Deprecated, for removal: This API element is subject to removal in a future version.
    • retry_timeout

      protected long retry_timeout
      Deprecated, for removal: This API element is subject to removal in a future version.
    • enable_reconciliation

      protected boolean enable_reconciliation
      Deprecated, for removal: This API element is subject to removal in a future version.
    • bypass

      protected boolean bypass
      Deprecated, for removal: This API element is subject to removal in a future version.
    • startFlushTime

      private long startFlushTime
      Deprecated, for removal: This API element is subject to removal in a future version.
    • totalTimeInFlush

      private long totalTimeInFlush
      Deprecated, for removal: This API element is subject to removal in a future version.
    • numberOfFlushes

      private int numberOfFlushes
      Deprecated, for removal: This API element is subject to removal in a future version.
    • averageFlushDuration

      private double averageFlushDuration
      Deprecated, for removal: This API element is subject to removal in a future version.
    • currentView

      private View currentView
      Deprecated, for removal: This API element is subject to removal in a future version.
    • flushCoordinator

      private Address flushCoordinator
      Deprecated, for removal: This API element is subject to removal in a future version.
      Group member that requested FLUSH. For view installations flush coordinator is the group coordinator For state transfer flush coordinator is the state requesting member
    • flushMembers

      private final List<Address> flushMembers
      Deprecated, for removal: This API element is subject to removal in a future version.
    • viewCounter

      private final AtomicInteger viewCounter
      Deprecated, for removal: This API element is subject to removal in a future version.
    • flushCompletedMap

      private final Map<Address,Digest> flushCompletedMap
      Deprecated, for removal: This API element is subject to removal in a future version.
    • flushNotCompletedMap

      private final List<Address> flushNotCompletedMap
      Deprecated, for removal: This API element is subject to removal in a future version.
    • suspected

      private final Set<Address> suspected
      Deprecated, for removal: This API element is subject to removal in a future version.
    • reconcileOks

      private final List<Address> reconcileOks
      Deprecated, for removal: This API element is subject to removal in a future version.
    • sharedLock

      private final Object sharedLock
      Deprecated, for removal: This API element is subject to removal in a future version.
    • blockMutex

      private final ReentrantLock blockMutex
      Deprecated, for removal: This API element is subject to removal in a future version.
    • notBlockedDown

      private final Condition notBlockedDown
      Deprecated, for removal: This API element is subject to removal in a future version.
    • isBlockingFlushDown

      private volatile boolean isBlockingFlushDown
      Deprecated, for removal: This API element is subject to removal in a future version.
      Indicates if FLUSH.down() is currently blocking threads Condition predicate associated with blockMutex
    • flushCompleted

      private boolean flushCompleted
      Deprecated, for removal: This API element is subject to removal in a future version.
    • flush_promise

      private final Promise<FLUSH.FlushStartResult> flush_promise
      Deprecated, for removal: This API element is subject to removal in a future version.
    • flush_unblock_promise

      private final Promise<Boolean> flush_unblock_promise
      Deprecated, for removal: This API element is subject to removal in a future version.
    • flushInProgress

      private final AtomicBoolean flushInProgress
      Deprecated, for removal: This API element is subject to removal in a future version.
    • sentBlock

      private final AtomicBoolean sentBlock
      Deprecated, for removal: This API element is subject to removal in a future version.
    • sentUnblock

      private final AtomicBoolean sentUnblock
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Constructor Details

    • FLUSH

      public FLUSH()
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • getStartFlushTimeout

      public long getStartFlushTimeout()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setStartFlushTimeout

      public FLUSH setStartFlushTimeout(long start_flush_timeout)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getRetryTimeout

      public long getRetryTimeout()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setRetryTimeout

      public FLUSH setRetryTimeout(long retry_timeout)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • start

      public void start() throws Exception
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from class: Protocol
      This method is called on a JChannel.connect(String); starts work. Protocols are connected ready to receive events. Will be called from bottom to top.
      Specified by:
      start in interface Lifecycle
      Overrides:
      start in class Protocol
      Throws:
      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()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from class: Protocol
      Called on a JChannel.disconnect(); stops work (e.g. by closing multicast socket). Will be called from top to bottom.
      Specified by:
      stop in interface Lifecycle
      Overrides:
      stop in class Protocol
    • getAverageFlushDuration

      public double getAverageFlushDuration()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getTotalTimeInFlush

      public long getTotalTimeInFlush()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getNumberOfFlushes

      public int getNumberOfFlushes()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setBypass

      public boolean setBypass(boolean flag)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • startFlush

      public void startFlush()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • startFlush

      private void startFlush(Event evt)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • startFlush

      private void startFlush(List<Address> flushParticipants)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • stopFlush

      public void stopFlush()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • down

      public Object down(Event evt)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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
    • down

      public Object down(Message msg)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from class: Protocol
      A message is sent down the stack. Protocols may examine the message and do something (e.g. add a header) with it, before passing it down.
      Overrides:
      down in class Protocol
    • handleConnect

      private Object handleConnect(Event evt, boolean waitForUnblock)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • blockMessageDuringFlush

      private void blockMessageDuringFlush()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • up

      public Object up(Event evt)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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 Object up(Message msg)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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
    • up

      public void up(MessageBatch batch)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from class: Protocol
      Sends up a multiple messages in a MessageBatch. The sender of the batch is always the same, and so is the destination (null == multicast messages). Messages in a batch can be OOB messages, regular messages, or mixed messages, although the transport itself will create initial MessageBatches that contain only either OOB or regular messages.

      The default processing below sends messages up the stack individually, based on a matching criteria (calling Protocol.accept(Message)), and - if true - calls Protocol.up(org.jgroups.Event) for that message and removes the message. If the batch is not empty, it is passed up, or else it is dropped.

      Subclasses should check if there are any messages destined for them (e.g. using MessageBatch.iterator(Predicate)), then possibly remove and process them and finally pass the batch up to the next protocol. Protocols can also modify messages in place, e.g. ENCRYPT could decrypt all encrypted messages in the batch, not remove them, and pass the batch up when done.

      Overrides:
      up in class Protocol
      Parameters:
      batch - The message batch
    • waitForUnblock

      private void waitForUnblock()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • onFlushReconcileOK

      private void onFlushReconcileOK(Message msg)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • handleFlushReconcile

      private void handleFlushReconcile(Message msg)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • handleStartFlush

      private void handleStartFlush(Message msg, FLUSH.FlushHeader fh)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • rejectFlush

      private void rejectFlush(Collection<? extends Address> participants, long viewId)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • providedDownServices

      public List<Integer> providedDownServices()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from class: Protocol
      List of events that are provided to layers below (they will be handled when sent from down below)
      Overrides:
      providedDownServices in class Protocol
    • sendBlockUpToChannel

      private void sendBlockUpToChannel()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • sendUnBlockUpToChannel

      private void sendUnBlockUpToChannel()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • isCurrentFlushMessage

      private boolean isCurrentFlushMessage(FLUSH.FlushHeader fh)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • currentViewId

      private long currentViewId()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • onViewChange

      private boolean onViewChange(View view)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • onStopFlush

      private void onStopFlush()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • resetForNextFlush

      private void resetForNextFlush()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • onSuspend

      private void onSuspend(List<Address> members)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Starts the flush protocol
      Parameters:
      members - List of participants in the flush protocol. Guaranteed to be non-null
    • onResume

      private void onResume(Event evt)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • onStartFlush

      private void onStartFlush(Address flushStarter, Message msg, FLUSH.FlushHeader fh)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • onFlushCompleted

      private void onFlushCompleted(Address address, Message m, FLUSH.FlushHeader header)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • hasVirtualSynchronyGaps

      private boolean hasVirtualSynchronyGaps()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • same

      protected static boolean same(List<Digest> digests)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • findHighestSequences

      private Digest findHighestSequences(View view)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • maxSeqnos

      protected static Digest maxSeqnos(View view, List<Digest> digests)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns a digest which contains, for all members of view, the highest delivered and received seqno of all digests
    • onSuspect

      private void onSuspect(Collection<Address> addresses)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • marshal

      protected static ByteArray marshal(Collection<? extends Address> participants, Digest digest)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • readParticipantsAndDigest

      protected Tuple<Collection<? extends Address>,Digest> readParticipantsAndDigest(byte[] buffer, int offset, int length)
      Deprecated, for removal: This API element is subject to removal in a future version.