org.jboss.messaging.core.impl
Class PagingChannelSupport

java.lang.Object
  extended by org.jboss.messaging.core.impl.ChannelSupport
      extended by org.jboss.messaging.core.impl.PagingChannelSupport
All Implemented Interfaces:
Channel, DeliveryObserver, Receiver
Direct Known Subclasses:
MessagingQueue

public abstract class PagingChannelSupport
extends ChannelSupport

This channel implementation automatically pages message references to and from storage to prevent more than a maximum number of references being stored in memory at once. This allows us to support logical channels holding many millions of messages without running out of memory.

Version:
$Revision: 3132 $ $Id: PagingChannelSupport.java 3132 2007-09-21 11:06:17Z timfox $
Author:
Tim Fox

Field Summary
protected  java.util.List downCache
           
protected  int downCacheSize
          The maximum number of references paged to storage in one operation
protected  long firstPagingOrder
          The page order value for the first reference paged in storage
protected  int fullSize
          The maximum number of references this channel will hold before going into paging mode
protected  MessageStore ms
           
protected  long nextPagingOrder
          The value of page order for the next reference to page
protected  int pageSize
          The maximum number of references to load from storage in one go when unpaging
protected  boolean paging
          Are we in paging mode?
 
Fields inherited from class org.jboss.messaging.core.impl.ChannelSupport
active, channelID, deliveringCount, distributor, lock, maxSize, messageRefs, messagesAdded, pm, receiversReady, recoverable, scheduledDeliveries
 
Constructor Summary
PagingChannelSupport(long channelID, MessageStore ms, PersistenceManager pm, boolean recoverable, int maxSize)
          Constructor with default paging params.
PagingChannelSupport(long channelID, MessageStore ms, PersistenceManager pm, boolean recoverable, int maxSize, int fullSize, int pageSize, int downCacheSize)
          Constructor specifying paging params.
 
Method Summary
protected  MessageReference addFromRefInfo(PersistenceManager.ReferenceInfo info, java.util.Map refMap)
           
protected  void addReferenceInMemory(MessageReference ref)
           
protected  void addToDownCache(MessageReference ref, boolean cancelling)
           
protected  void cancelInternal(MessageReference ref)
           
protected  void doLoad(PersistenceManager.InitialLoadInfo ili)
           
 int downCacheCount()
           
protected  void flushDownCache()
           
 int getMessageCount()
          Returns the count of messages stored AND being delivered AND scheduled
 boolean isPaging()
           
 void load()
          Load any references for this channel from storage
protected  void loadPagedReferences(int number)
           
protected  java.util.Map processReferences(java.util.List refInfos)
           
protected  MessageReference removeFirstInMemory()
           
 void setPagingParams(int fullSize, int pageSize, int downCacheSize)
           
 void unload()
          Unload any references for this channel
 
Methods inherited from class org.jboss.messaging.core.impl.ChannelSupport
acknowledge, acknowledgeInternal, activate, browse, cancel, checkAndSchedule, checkClosed, clearAllScheduledDeliveries, close, deactivate, deliver, deliverInternal, deliverScheduled, getCallback, getChannelID, getDeliveringCount, getMaxSize, getMessagesAdded, getReceiversReady, getScheduledCount, handle, handleInternal, isActive, isRecoverable, memoryRefCount, processMessageBeforeStorage, removeAllReferences, setMaxSize, setReceiversReady, undelivered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

downCache

protected java.util.List downCache

fullSize

protected int fullSize
The maximum number of references this channel will hold before going into paging mode


pageSize

protected int pageSize
The maximum number of references to load from storage in one go when unpaging


downCacheSize

protected int downCacheSize
The maximum number of references paged to storage in one operation


paging

protected boolean paging
Are we in paging mode?


firstPagingOrder

protected long firstPagingOrder
The page order value for the first reference paged in storage


nextPagingOrder

protected long nextPagingOrder
The value of page order for the next reference to page


ms

protected MessageStore ms
Constructor Detail

PagingChannelSupport

public PagingChannelSupport(long channelID,
                            MessageStore ms,
                            PersistenceManager pm,
                            boolean recoverable,
                            int maxSize)
Constructor with default paging params.


PagingChannelSupport

public PagingChannelSupport(long channelID,
                            MessageStore ms,
                            PersistenceManager pm,
                            boolean recoverable,
                            int maxSize,
                            int fullSize,
                            int pageSize,
                            int downCacheSize)
Constructor specifying paging params.

Method Detail

getMessageCount

public int getMessageCount()
Description copied from class: ChannelSupport
Returns the count of messages stored AND being delivered AND scheduled

Specified by:
getMessageCount in interface Channel
Overrides:
getMessageCount in class ChannelSupport
Returns:
Total message count = undelivered + delivering + scheduled

downCacheCount

public int downCacheCount()

isPaging

public boolean isPaging()

setPagingParams

public void setPagingParams(int fullSize,
                            int pageSize,
                            int downCacheSize)

load

public void load()
          throws java.lang.Exception
Description copied from interface: Channel
Load any references for this channel from storage

Throws:
java.lang.Exception

unload

public void unload()
            throws java.lang.Exception
Description copied from interface: Channel
Unload any references for this channel

Throws:
java.lang.Exception

loadPagedReferences

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

cancelInternal

protected void cancelInternal(MessageReference ref)
                       throws java.lang.Exception
Overrides:
cancelInternal in class ChannelSupport
Throws:
java.lang.Exception

removeFirstInMemory

protected MessageReference removeFirstInMemory()
                                        throws java.lang.Exception
Overrides:
removeFirstInMemory in class ChannelSupport
Throws:
java.lang.Exception

addReferenceInMemory

protected void addReferenceInMemory(MessageReference ref)
                             throws java.lang.Exception
Overrides:
addReferenceInMemory in class ChannelSupport
Throws:
java.lang.Exception

addToDownCache

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

flushDownCache

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

doLoad

protected void doLoad(PersistenceManager.InitialLoadInfo ili)
               throws java.lang.Exception
Throws:
java.lang.Exception

addFromRefInfo

protected MessageReference addFromRefInfo(PersistenceManager.ReferenceInfo info,
                                          java.util.Map refMap)

processReferences

protected java.util.Map processReferences(java.util.List refInfos)
                                   throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 2006 JBoss Inc. All Rights Reserved.