org.objectweb.dream.queue
Class BufferAscendingSequenceNumberImpl

java.lang.Object
  extended by org.objectweb.dream.AbstractComponent
      extended by org.objectweb.dream.queue.AbstractBufferImpl
          extended by org.objectweb.dream.queue.BufferAscendingSequenceNumberImpl
All Implemented Interfaces:
ContextualBindingController, NeedAsyncStartController, PrepareStopLifeCycleController, Loggable, BufferAdd, BufferAttributeController, BufferAttributeControllerAscendingSequenceNumber, BufferAttributeControllerSorted, BufferRemove, AttributeController, BindingController, LifeCycleController

public class BufferAscendingSequenceNumberImpl
extends AbstractBufferImpl
implements BufferAttributeControllerAscendingSequenceNumber

Implementation of the Buffer interface using a sorted list. This buffer sorts messages according to a sequence number. For that purpose all messages must contain a SequenceNumberChunkchunk. The name under which this chunk is registered is specified using the BufferAttributeControllerSorted.

This buffer guarantees that if message m1 (with sequence number sn ) is removed from the buffer, then next message to be removed will have sequence number sn+1 . As a consequence, the number of available message may be different from the number of stored messages.

Note: This buffer DOES NOT ALLOW incoming handlers that drop messages. Indicators on available space, available messages, and stored messages are expressed as number of messages.

See Also:
BufferAdd, BufferRemove, AbstractBufferImpl

Nested Class Summary
static class BufferAscendingSequenceNumberImpl.Element
          This class represents elements of a linked list.
 
Field Summary
protected  BufferAscendingSequenceNumberImpl.Element first
          The first element stored in this buffer.
protected  BufferAscendingSequenceNumberImpl.Element last
          The last element stored in this buffer.
protected  long lastInSequence
          The last sequence number in sequence.
protected  String sortingChunkName
          The name under which the chunk containing the sequence number is registered.
 
Fields inherited from class org.objectweb.dream.queue.AbstractBufferImpl
availableMessagesCount, CLIENT_INTERFACE_NAMES, lock, maxCapacity, messageManagerItf, storedMessagesCount
 
Fields inherited from class org.objectweb.dream.AbstractComponent
bindingLogger, fcNeedAsyncStart, fcState, lifeCycleLogger, logger, weaveableC
 
Fields inherited from interface org.objectweb.dream.queue.BufferAdd
ITF_NAME
 
Fields inherited from interface org.objectweb.dream.queue.BufferRemove
ITF_NAME
 
Fields inherited from interface org.objectweb.fractal.api.control.LifeCycleController
STARTED, STOPPED
 
Constructor Summary
BufferAscendingSequenceNumberImpl()
           
 
Method Summary
protected  void doAdd(Message message)
          Adds a message to the buffer.
protected  Message doGet()
          Gets a message from the buffer.
protected  Message doRemove()
          Removes a message from the buffer.
 Message doRemoveAll()
          Removes all the messages stored into the buffer.
 long getLastInSequence()
          Returns the sequence number of the last delivered message.
 String getSortingChunkName()
          Returns the name of the chunk to be used to sort messages.
 String[] listFc()
           
 void setLastInSequence(long lastInSequence)
          Sets the sequence number of the last delivered message.
 void setSortingChunkName(String name)
          Sets the name of the chunk to be used to sort messages.
 
Methods inherited from class org.objectweb.dream.queue.AbstractBufferImpl
add, availableSpace, bindFc, canAdd, get, getCurrentSize, getMaxCapacity, hasAvailableMessage, incrementAvailableMessagesCount, incrementStoredMessagesCount, remove, removeAll, setMaxCapacity, tryAdd, tryGet, tryRemove
 
Methods inherited from class org.objectweb.dream.AbstractComponent
beforeFirstStart, bindFc, getFcNeedAsyncStart, getFcState, initComponent, lookupFc, prepareStopFc, setLogger, startFc, stopFc, unbindFc
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.dream.queue.BufferAttributeController
getCurrentSize, getMaxCapacity, setMaxCapacity
 

Field Detail

sortingChunkName

protected String sortingChunkName
The name under which the chunk containing the sequence number is registered.


lastInSequence

protected long lastInSequence
The last sequence number in sequence.


first

protected BufferAscendingSequenceNumberImpl.Element first
The first element stored in this buffer.


last

protected BufferAscendingSequenceNumberImpl.Element last
The last element stored in this buffer.

Constructor Detail

BufferAscendingSequenceNumberImpl

public BufferAscendingSequenceNumberImpl()
Method Detail

doAdd

protected void doAdd(Message message)
Description copied from class: AbstractBufferImpl
Adds a message to the buffer. This method should not check if there is enough available space provided it has already been done in the AbstractBufferImpl.add(org.objectweb.dream.message.Message)method. The lockhas been acquired when this method is called.

Specified by:
doAdd in class AbstractBufferImpl
Parameters:
message - the message to be added.
See Also:
AbstractBufferImpl.doAdd(Message)

doRemove

protected Message doRemove()
Description copied from class: AbstractBufferImpl
Removes a message from the buffer. This method should not check if there is a message available provided it has already been done in the AbstractBufferImpl.remove()method. The lockhas been acquired when this method is called.

Specified by:
doRemove in class AbstractBufferImpl
Returns:
a message.
See Also:
AbstractBufferImpl.doRemove()

doGet

protected Message doGet()
Description copied from class: AbstractBufferImpl
Gets a message from the buffer. This method should not check if there is a message available provided it has already been done in the AbstractBufferImpl.get() method. The lockhas been acquired when this method is called.

Specified by:
doGet in class AbstractBufferImpl
Returns:
a message.
See Also:
AbstractBufferImpl.doGet()

doRemoveAll

public Message doRemoveAll()
Description copied from class: AbstractBufferImpl
Removes all the messages stored into the buffer. The lockhas been acquired when this method is called.

Specified by:
doRemoveAll in class AbstractBufferImpl
Returns:
an aggregated message.
See Also:
AbstractBufferImpl.doRemoveAll()

getSortingChunkName

public String getSortingChunkName()
Description copied from interface: BufferAttributeControllerSorted
Returns the name of the chunk to be used to sort messages.

Specified by:
getSortingChunkName in interface BufferAttributeControllerSorted
Returns:
the name of the chunk to be used to sort messages.
See Also:
BufferAttributeControllerSorted.getSortingChunkName()

setSortingChunkName

public void setSortingChunkName(String name)
Description copied from interface: BufferAttributeControllerSorted
Sets the name of the chunk to be used to sort messages.

Specified by:
setSortingChunkName in interface BufferAttributeControllerSorted
Parameters:
name - the name of the chunk to be used to sort messages.
See Also:
BufferAttributeControllerSorted.setSortingChunkName(String)

getLastInSequence

public long getLastInSequence()
Description copied from interface: BufferAttributeControllerAscendingSequenceNumber
Returns the sequence number of the last delivered message.

Specified by:
getLastInSequence in interface BufferAttributeControllerAscendingSequenceNumber
Returns:
the sequence number of the last delivered message.
See Also:
BufferAttributeControllerAscendingSequenceNumber.getLastInSequence()

setLastInSequence

public void setLastInSequence(long lastInSequence)
Description copied from interface: BufferAttributeControllerAscendingSequenceNumber
Sets the sequence number of the last delivered message.

Specified by:
setLastInSequence in interface BufferAttributeControllerAscendingSequenceNumber
Parameters:
lastInSequence - the sequence number to be set.
See Also:
BufferAttributeControllerAscendingSequenceNumber.setLastInSequence(long)

listFc

public String[] listFc()
Specified by:
listFc in interface BindingController
Overrides:
listFc in class AbstractBufferImpl
See Also:
BindingController.listFc()


Copyright © 2003, 2005 - INRIA Rhone-Alpes - All Rights Reserved.