org.jboss.messaging.core
Class ChannelState

java.lang.Object
  extended byorg.jboss.messaging.core.ChannelState
All Implemented Interfaces:
State

public class ChannelState
extends java.lang.Object
implements State

Represents the state of a Channel.

Version:
1.3 ChannelState.java,v 1.3 2006/03/05 16:17:23 timfox Exp
Author:
Ovidiu Feodorov, Tim Fox

Field Summary
protected  boolean acceptReliableMessages
           
protected  Channel channel
           
protected  java.util.Set deliveries
           
protected  java.util.List downCache
           
protected  int downCacheSize
           
protected  int fullSize
           
protected  SynchronizedLong messageOrdering
           
protected  PrioritizedDeque messageRefs
           
protected  MemoryManager mm
           
protected  int pageSize
           
protected  boolean paging
           
protected  PersistenceManager pm
           
protected  boolean recoverable
           
protected  int refsInStorage
           
 
Constructor Summary
ChannelState(Channel channel, PersistenceManager pm, MemoryManager mm, boolean acceptReliableMessages, boolean recoverable, int fullSize, int pageSize, int downCacheSize)
           
 
Method Summary
 boolean acceptReliableMessages()
          A non-recoverable state cannot guarantee recoverability for reliable messages so by default it won't accept reliable messages.
 void acknowledge(Delivery d)
          A Delivery has been acknowledged in a non transactional context.
 void acknowledge(Delivery d, Transaction tx)
          A Delivery has been acknowledged in the presence of a JMS local transaction.
protected  void acknowledgeInMemory(Delivery d)
           
 void addDelivery(Delivery d)
          Add a Delivery to the state
 boolean addReference(MessageReference ref)
          Add a MessageReference to the State
 void addReference(MessageReference ref, Transaction tx)
          This method is called after a new message has arrived at the Channel in the presence of a JMS transaction.
protected  boolean addReferenceInMemory(MessageReference ref)
           
protected  void addToDownCache(MessageReference ref)
           
 java.util.List browse(Filter filter)
           
 void cancelDelivery(Delivery del)
          A Delivery has been cancelled.
protected  void checkLoad()
           
protected  void checkMemory()
           
 void clear()
          Clears non-recoverable state but not persisted state, so a recovery of the channel is possible TODO really?
 java.util.List delivering(Filter filter)
          A list of message references of messages in process of being delivered.
 int downCacheCount()
           
protected  void flushDownCache()
           
protected  org.jboss.messaging.core.ChannelState.InMemoryCallback getCallback(Transaction tx)
           
 boolean isPaging()
           
 boolean isRecoverable()
           
 void load()
           
protected  void load(int number)
           
 int memoryDeliveryCount()
           
 int memoryRefCount()
           
 int messageCount()
          Message amount.
 MessageReference peekFirst()
          Peek the MessageReference at the head of the state without actually removing it
 void removeAll()
          Remove all messages.
protected  void removeCompletely(MessageReference r)
           
 MessageReference removeFirstInMemory()
          Remove the MessageReference at the head of the queue from the state.
 java.lang.String toString()
           
 java.util.List undelivered(Filter filter)
          A list of message references of messages that are currently NOT being delivered by the channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

messageRefs

protected PrioritizedDeque messageRefs

deliveries

protected java.util.Set deliveries

channel

protected Channel channel

downCache

protected java.util.List downCache

acceptReliableMessages

protected boolean acceptReliableMessages

recoverable

protected boolean recoverable

messageOrdering

protected SynchronizedLong messageOrdering

pm

protected PersistenceManager pm

mm

protected MemoryManager mm

fullSize

protected int fullSize

pageSize

protected int pageSize

downCacheSize

protected int downCacheSize

paging

protected boolean paging

refsInStorage

protected int refsInStorage
Constructor Detail

ChannelState

public ChannelState(Channel channel,
                    PersistenceManager pm,
                    MemoryManager mm,
                    boolean acceptReliableMessages,
                    boolean recoverable,
                    int fullSize,
                    int pageSize,
                    int downCacheSize)
Method Detail

isRecoverable

public boolean isRecoverable()
Specified by:
isRecoverable in interface State
Returns:
true if the state can guarantee recoverability for reliable messages. Recoverability is not guaranteed for non-reliable messages (and should not be provided by default, for performance reasons), even if the channel is recoverable.

acceptReliableMessages

public boolean acceptReliableMessages()
Description copied from interface: State
A non-recoverable state cannot guarantee recoverability for reliable messages so by default it won't accept reliable messages. However, there are situations when discarding a reliable message is acceptable for a specific state instance, so it should be a way to configure the state to do so. A state instance indicates unequivocally whether it accepts reliable messages or not returning true or false as result of this method. The result also applies to deliveries, depending on what kind of message the delivery is related to. A recoverable state must always accept reliable messages, so this method must always return true for a recoverable state.

Specified by:
acceptReliableMessages in interface State
Returns:
false if the state doesn't accept reliable messages.

addReference

public void addReference(MessageReference ref,
                         Transaction tx)
                  throws java.lang.Throwable
Description copied from interface: State
This method is called after a new message has arrived at the Channel in the presence of a JMS transaction. This method updates the transactional state of the Channel to include this message reference. Message delivery is not attempted until the transaction commits.

Specified by:
addReference in interface State
Parameters:
ref - The MessageReference to add
tx - The JMS local transaction
Throws:
java.lang.Throwable

addReference

public boolean addReference(MessageReference ref)
                     throws java.lang.Throwable
Description copied from interface: State
Add a MessageReference to the State

Specified by:
addReference in interface State
Parameters:
ref - The MessageReference to add
Returns:
true if the addition results in the ref being at the head of the queue. I.e. the queue was empty when the add occurred
Throws:
java.lang.Throwable

addDelivery

public void addDelivery(Delivery d)
                 throws java.lang.Throwable
Description copied from interface: State
Add a Delivery to the state

Specified by:
addDelivery in interface State
Parameters:
d - The set of delivery instances to add
Throws:
java.lang.Throwable

cancelDelivery

public void cancelDelivery(Delivery del)
                    throws java.lang.Throwable
Description copied from interface: State
A Delivery has been cancelled.

Specified by:
cancelDelivery in interface State
Parameters:
del - The delivery to cancel
Throws:
java.lang.Throwable

acknowledge

public void acknowledge(Delivery d,
                        Transaction tx)
                 throws java.lang.Throwable
Description copied from interface: State
A Delivery has been acknowledged in the presence of a JMS local transaction.

Specified by:
acknowledge in interface State
Parameters:
d - The delivery to acknowledge
tx - The JMS local transaction
Throws:
java.lang.Throwable

acknowledge

public void acknowledge(Delivery d)
                 throws java.lang.Throwable
Description copied from interface: State
A Delivery has been acknowledged in a non transactional context.

Specified by:
acknowledge in interface State
Parameters:
d - The delivery to acknowledge
Throws:
java.lang.Throwable

removeFirstInMemory

public MessageReference removeFirstInMemory()
                                     throws java.lang.Throwable
Description copied from interface: State
Remove the MessageReference at the head of the queue from the state. Note that this operation *does not* remove the MessageReference from RecoverableState - it only removes it from NonRecoverableState.

Specified by:
removeFirstInMemory in interface State
Returns:
The MessageReference
Throws:
java.lang.Throwable

peekFirst

public MessageReference peekFirst()
                           throws java.lang.Throwable
Description copied from interface: State
Peek the MessageReference at the head of the state without actually removing it

Specified by:
peekFirst in interface State
Returns:
The MessageReference
Throws:
java.lang.Throwable

delivering

public java.util.List delivering(Filter filter)
Description copied from interface: State
A list of message references of messages in process of being delivered.

Specified by:
delivering in interface State
Returns:
a copy of the internal storage.

undelivered

public java.util.List undelivered(Filter filter)
Description copied from interface: State
A list of message references of messages that are currently NOT being delivered by the channel.

Specified by:
undelivered in interface State
Returns:
a copy of the the internal storage.

browse

public java.util.List browse(Filter filter)
Specified by:
browse in interface State
Parameters:
filter - - may be null, in which case no filter is applied.
Returns:
a List containing message references of messages whose state is maintained by this State instance. The list includes references of messages in process of being delivered and references of messages for which delivery has not been attempted yet.

clear

public void clear()
Description copied from interface: State
Clears non-recoverable state but not persisted state, so a recovery of the channel is possible TODO really?

Specified by:
clear in interface State

messageCount

public int messageCount()
Description copied from interface: State
Message amount.

Specified by:
messageCount in interface State
Returns:
message amount.

load

public void load()
          throws java.lang.Exception
Specified by:
load in interface State
Throws:
java.lang.Exception

removeAll

public void removeAll()
Description copied from interface: State
Remove all messages.

Specified by:
removeAll in interface State

memoryRefCount

public int memoryRefCount()

memoryDeliveryCount

public int memoryDeliveryCount()

downCacheCount

public int downCacheCount()

isPaging

public boolean isPaging()

toString

public java.lang.String toString()

checkMemory

protected void checkMemory()

addReferenceInMemory

protected boolean addReferenceInMemory(MessageReference ref)
                                throws java.lang.Throwable
Throws:
java.lang.Throwable

addToDownCache

protected void addToDownCache(MessageReference ref)
                       throws java.lang.Exception
Throws:
java.lang.Exception

flushDownCache

protected void flushDownCache()
                       throws java.lang.Exception
Throws:
java.lang.Exception

acknowledgeInMemory

protected void acknowledgeInMemory(Delivery d)
                            throws java.lang.Throwable
Throws:
java.lang.Throwable

removeCompletely

protected void removeCompletely(MessageReference r)

checkLoad

protected void checkLoad()
                  throws java.lang.Throwable
Throws:
java.lang.Throwable

load

protected void load(int number)
             throws java.lang.Exception
Throws:
java.lang.Exception

getCallback

protected org.jboss.messaging.core.ChannelState.InMemoryCallback getCallback(Transaction tx)


Copyright © 2006 JBoss Inc. All Rights Reserved.