Overview | Package | Class | Use | Tree | Deprecated | Index | Help
|  | BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

WebLogic Server 6.0sp2 API Reference

## weblogic.common
Class Sequencer

    java.lang.Object
      |
      +--weblogic.common.Sequencer

public class Sequencer
extends java.lang.Object
implements Triggerable

This class takes an out-of-order stream of objects and reorders them using a "push" flow model. (Descibed in Lea 1997, p. 220.) Items which enter the stream out of order are cached until all preceding items have been received and processed. Each object inserted into the Sequencer must implement the Sequenced interface.

The producer (typically the Action object associated with a WebLogic Event) calls Sequencer.insert(Sequenced s) to insert new objects into the Sequencer. The consumer registers itself as a SequenceListener with the Sequencer, and the Sequencer delivers SequenceEvents that contain either the next object in the Sequence or some exceptional condition.

The Sequencer handles the two canonical error conditions:

- Lost items/gap detection. If the cache is filled while waiting for a missing item to be inserted into the sequence, a SequenceEvent.WINDOW_OVERFLOW is raised with the overflow item. The overflow item is passed to the SequenceListener, and otherwise ignored by the Sequencer.

- Starvation. If the cache is non-empty and no additional items are inserted into the Sequencer between calls of the trigger method, then a SequenceEvent.TIMEOUT event is raised. The sequence number of the missing item is a parameter of the TIMEOUT event.

The Sequencer also handles two canonical warning conditions:

- Flow control. As the cache is filling up (but is not yet full), SequenceEvent.BACKFLOW_THRESHOLD_REACHED events are generated so that the listener can inform the producer to slow down and to retransmit any missing messages. The threshold at which these events are generated is configurable.

- Duplicates. When a Sequenced item arrives that has already been received, a SequenceEvent.DUPLICATE event is generated containing the duplicate item.

  Author:
    Copyright (c) 1998 by WebLogic, Inc. All Rights Reserved., Copyright (c) 1999-2000 BEA Systems, Inc. All Rights Reserved.
    Copyright © 2001 BEA Systems, Inc. All Rights Reserved.

  Field Summary
  `static int` | `DEFAULT_BACKFLOW_THRESHOLD` Default threshold at which back pressure on the Sequencer is applied.
  `static int` | `DEFAULT_INITIAL_SEQUENCE_NUMBER` Default initial sequence number is 1.
  `static int` | `DEFAULT_WINDOW_SIZE` Default size of the sequence window.

  Constructor Summary
  `Sequencer()` Default constructor.
  `Sequencer(int windowSize, int initialSequenceNumber, int backflowThreshold)` Constructs a Sequencer with the specified window size, initial sequence number, and backflow threshold.

  Method Summary
  `void` | `addSequenceListener(SequenceListener sfListener)` Adds a single SequenceListener to a Sequence.
  `int` | `getNextSeq()` Gets the index of the next item in a sequence.
  `void` | `insert(Sequenced s)` Inserts a Sequenced object into a Sequence.
  `void` | `trigger(Schedulable sch)` Implements the Triggerable object so that it can be part of a trigger.

  Methods inherited from class java.lang.Object
  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  Field Detail

  ### DEFAULT_WINDOW_SIZE

      public static final int DEFAULT_WINDOW_SIZE

    Default size of the sequence window.

  ### DEFAULT_INITIAL_SEQUENCE_NUMBER

      public static final int DEFAULT_INITIAL_SEQUENCE_NUMBER

    Default initial sequence number is 1.

  ### DEFAULT_BACKFLOW_THRESHOLD

      public static final int DEFAULT_BACKFLOW_THRESHOLD

    Default threshold at which back pressure on the Sequencer is applied.

  Constructor Detail

  ### Sequencer

      public Sequencer()

    Default constructor. Sets the Sequencer to a default window size (16), a default initial sequence number of 1, and the default backflow threshold, which is half the size of the window.

  ### Sequencer

      public Sequencer(int windowSize,
                       int initialSequenceNumber,
                       int backflowThreshold)

    Constructs a Sequencer with the specified window size, initial sequence number, and backflow threshold. The backflow threshold events are generated in advance of the cache filling up so that the listener can inform the producer to slow down and retransmit any missing messages.

    Parameters:
      `windowSize` - Size of the Sequencer cache
      `initialSequenceNumber` - Beginning of index into the Sequencer cache
      `backflowThreshold` - Point at which cache begins to fill

  Method Detail

  ### getNextSeq

      public int getNextSeq()

    Gets the index of the next item in a sequence.

    Returns:
      Index as int

  ### addSequenceListener

      public void addSequenceListener(SequenceListener sfListener)

    Adds a single SequenceListener to a Sequence. There can only be one failure listener at a time.

    Parameters:
      `sfListener` - SequenceListener for failure conditions

  ### insert

      public void insert(Sequenced s)

    Inserts a Sequenced object into a Sequence.

    Parameters:
      `s` - Object that implements the Sequenced interface

  ### trigger

      public void trigger(Schedulable sch)

    Implements the Triggerable object so that it can be part of a trigger.
    Specified by:
      trigger in interface Triggerable

    Parameters:
      `sch` - Object that implements the Schedulable interface

  Overview | Package | Class | Use | Tree | Deprecated | Index | Help
  | Documentation is available at http://e-docs.bea.com/wls/docs60
  PREV CLASS NEXT CLASS | FRAMES NO FRAMES
  SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD