|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.dream.AbstractComponent
org.objectweb.dream.queue.keyed.BufferAscendingKeyKeyChunkAddDoubleKeyedRemoveImpl
public class BufferAscendingKeyKeyChunkAddDoubleKeyedRemoveImpl
This buffer stores every incoming message according to
keyChunk
) that is contained in the message as a
AbstractChunk
which name can be specified as a Fractal component
attribute using the
BufferAttributeControllerKeyChunkAdd
interface. This method is used when adding the message using the
add(Message, Object)
method.key
) that is explicitely passed as a parameter,
when adding the message using the add(Message, Object)
method.remove(Object, Object)
method. This method returns the message with
the highest key for the specified keyChunk
key.
Field Summary | |
---|---|
protected static String[] |
CLIENT_INTERFACE_NAMES
The names of client interfaces. |
protected String |
keyChunkName
|
protected Object |
lock
The lock object. |
protected int |
maxCapacity
The maximal capacity of the buffer. |
protected MessageManager |
messageManagerItf
Can be used by subclasses to create aggregated messages in DoubleKeyedBufferRemove.removeAll() . |
protected Map<AbstractChunk,TreeMap<Object,Message>> |
queue
Used to sort the messages according to the key stored in each message as a chunk . |
protected int |
storedMessagesCount
The count of stored messages into the buffer. |
Fields inherited from class org.objectweb.dream.AbstractComponent |
---|
bindingLogger, fcNeedAsyncStart, fcState, lifeCycleLogger, logger, weaveableC |
Fields inherited from interface org.objectweb.dream.queue.keyed.KeyedBufferAdd |
---|
ITF_NAME |
Fields inherited from interface org.objectweb.dream.queue.keyed.DoubleKeyedBufferRemove |
---|
ITF_NAME |
Fields inherited from interface org.objectweb.fractal.api.control.LifeCycleController |
---|
STARTED, STOPPED |
Constructor Summary | |
---|---|
BufferAscendingKeyKeyChunkAddDoubleKeyedRemoveImpl()
|
Method Summary | |
---|---|
void |
add(Message message,
Object key)
Adds the specified message to the buffer, associated with the specified key object. |
protected int |
availableSpace()
|
void |
bindFc(String clientItfName,
Object serverItf)
|
protected boolean |
canAdd(Message message)
Checks whether the given message can be added into the buffer. |
protected void |
doAdd(Message message,
Object key)
|
Message |
get(Object key1,
Object key2)
Gets the message from the buffer that is associated with the specified keys. |
int |
getCurrentSize()
Returns the current size of the queue. |
String |
getKeyChunkName()
Returns the name of the chunk that is used as a key. |
Object[] |
getKeys()
Returns an array containing the keys that are used in the buffer. |
int |
getMaxCapacity()
Returns the maximum capacity of the queue. |
protected void |
incrementStoredMessagesCount(int delta,
Object key)
Increments the count of stored messages. |
String[] |
listFc()
|
Message |
remove(Object key1,
Object key2)
Removes the message from the buffer that is associated with the specified keys. |
Message |
removeAll()
Removes all the available messages from the buffer. |
Message |
removeAll(Object key)
Removes all the available messages from the buffer that maps the specified key. |
void |
setKeyChunkName(String keyChunkName)
Sets the name of the chunk that is used as a key. |
void |
setMaxCapacity(int maxCapacity)
Sets the maximum capacity of the queue. |
boolean |
tryAdd(Message message,
Object key)
Adds the specified message to the buffer, associated with the specified key object. |
Message |
tryGet(Object key1,
Object key2)
Gets the message from the buffer that is associated with the specified keys. |
Message |
tryRemove(Object key1,
Object key2)
Removes the message from the buffer that is associated with the specified keys. |
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 |
Field Detail |
---|
protected static final String[] CLIENT_INTERFACE_NAMES
protected MessageManager messageManagerItf
DoubleKeyedBufferRemove.removeAll()
.
protected int maxCapacity
protected int storedMessagesCount
incrementStoredMessagesCount(int, Object)
method.
protected String keyChunkName
protected Map<AbstractChunk,TreeMap<Object,Message>> queue
chunk
.
protected final Object lock
Constructor Detail |
---|
public BufferAscendingKeyKeyChunkAddDoubleKeyedRemoveImpl()
Method Detail |
---|
public void add(Message message, Object key) throws InterruptedException
KeyedBufferAdd
Buffers may place limitations on what elements may be added to this buffer. In particular, some buffers require that messages contain particular chunks.
add
in interface KeyedBufferAdd
message
- the message to be added; never null
.key
- the key that is associated with the message to be added; never
null
.
InterruptedException
- if it is interrupted while waiting for a
message to be removed.KeyedBufferAdd.add(Message, Object)
public boolean tryAdd(Message message, Object key)
KeyedBufferAdd
Buffers may place limitations on what elements may be added to this buffer. In particular, some buffers require that messages contain particular chunks.
tryAdd
in interface KeyedBufferAdd
message
- the message to be added; never null
.key
- the key that is associated with the message to be added; never
null
.
true
if the message has been added.KeyedBufferAdd.tryAdd(Message, Object)
public Message remove(Object key1, Object key2) throws InterruptedException
DoubleKeyedBufferRemove
remove
in interface DoubleKeyedBufferRemove
key1
- the first key that is associated with the message to get; never
null
.key2
- the second key that is associated with the message to get; can
be null
.
null
.
InterruptedException
- if it is interrupted while waiting for a
message to be added.DoubleKeyedBufferRemove.remove(Object, Object)
public Message tryRemove(Object key1, Object key2)
DoubleKeyedBufferRemove
tryRemove
in interface DoubleKeyedBufferRemove
key1
- the first key that is associated with the message to get; never
null
.key2
- the second key that is associated with the message to get; can
be null
.
null
otherwise.DoubleKeyedBufferRemove.tryRemove(Object, Object)
public Message get(Object key1, Object key2) throws InterruptedException
DoubleKeyedBufferRemove
get
in interface DoubleKeyedBufferRemove
key1
- the first key that is associated with the message to get; never
null
.key2
- the second key that is associated with the message to get; can
be null
.
null
.
InterruptedException
- if it is interrupted while waiting for a
message to be added.DoubleKeyedBufferRemove.get(Object, Object)
public Message tryGet(Object key1, Object key2)
DoubleKeyedBufferRemove
tryGet
in interface DoubleKeyedBufferRemove
key1
- the first key that is associated with the message to get; never
null
.key2
- the second key that is associated with the message to get; can
be null
.
null
otherwise.DoubleKeyedBufferRemove.tryGet(Object, Object)
public Message removeAll(Object key)
DoubleKeyedBufferRemove
null
. This method does not
block.
removeAll
in interface DoubleKeyedBufferRemove
key
- the key which messages that are removed must match.
null
if no message was available.DoubleKeyedBufferRemove.removeAll(Object)
public Message removeAll()
DoubleKeyedBufferRemove
null
. This method does not block.
removeAll
in interface DoubleKeyedBufferRemove
null
if no message was available.DoubleKeyedBufferRemove.removeAll()
protected boolean canAdd(Message message)
lock
has been acquired when this method is called.
message
- the message to be tested.
true
if the message can be added.protected void doAdd(Message message, Object key)
protected int availableSpace()
protected void incrementStoredMessagesCount(int delta, Object key)
lock
must have already been acquired.
delta
- the value that must be added to previous indicator.public int getMaxCapacity()
BufferAttributeController
getMaxCapacity
in interface BufferAttributeController
BufferAttributeController.getMaxCapacity()
public void setMaxCapacity(int maxCapacity)
BufferAttributeController
setMaxCapacity
in interface BufferAttributeController
maxCapacity
- the maximum capacity of the queue.BufferAttributeController.setMaxCapacity(int)
public int getCurrentSize()
BufferAttributeController
getCurrentSize
in interface BufferAttributeController
BufferAttributeController.getCurrentSize()
public void setKeyChunkName(String keyChunkName)
BufferAttributeControllerKeyChunkAdd
setKeyChunkName
in interface BufferAttributeControllerKeyChunkAdd
keyChunkName
- the name of the chunk.BufferAttributeControllerKeyChunkAdd.setKeyChunkName(String)
public String getKeyChunkName()
BufferAttributeControllerKeyChunkAdd
getKeyChunkName
in interface BufferAttributeControllerKeyChunkAdd
BufferAttributeControllerKeyChunkAdd.getKeyChunkName()
public Object[] getKeys()
BufferAttributeControllerKeyed
getKeys
in interface BufferAttributeControllerKeyed
BufferAttributeControllerKeyed.getKeys()
public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException
bindFc
in interface BindingController
bindFc
in class AbstractComponent
NoSuchInterfaceException
IllegalBindingException
IllegalLifeCycleException
BindingController.bindFc(String,
Object)
public String[] listFc()
listFc
in interface BindingController
BindingController.listFc()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |