org.archive.queue
Class StoredQueue<E extends java.io.Serializable>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<E>
          extended by org.archive.queue.StoredQueue<E>
Type Parameters:
E -
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.Queue<E>

public class StoredQueue<E extends java.io.Serializable>
extends java.util.AbstractQueue<E>
implements java.io.Serializable

Queue backed by a JE Collections StoredSortedMap.

Author:
gojomo
See Also:
Serialized Form

Field Summary
(package private)  java.util.concurrent.atomic.AtomicLong headIndex
           
(package private)  com.sleepycat.je.Database queueDb
           
(package private)  com.sleepycat.collections.StoredSortedMap queueMap
           
(package private)  java.util.concurrent.atomic.AtomicLong tailIndex
           
 
Constructor Summary
StoredQueue(com.sleepycat.je.Database db, java.lang.Class clsOrNull, com.sleepycat.bind.serial.StoredClassCatalog classCatalog)
          Create a StoredQueue backed by the given Database.
 
Method Summary
 void close()
           
static com.sleepycat.je.DatabaseConfig databaseConfig()
          A suitable DatabaseConfig for the Database backing a StoredQueue.
 void hookupDatabase(com.sleepycat.je.Database db, java.lang.Class clsOrNull, com.sleepycat.bind.serial.StoredClassCatalog classCatalog)
           
 java.util.Iterator<E> iterator()
           
 boolean offer(E o)
           
 E peek()
           
 E poll()
           
 int size()
           
 
Methods inherited from class java.util.AbstractQueue
add, addAll, clear, element, remove
 
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Field Detail

queueMap

transient com.sleepycat.collections.StoredSortedMap queueMap

queueDb

transient com.sleepycat.je.Database queueDb

tailIndex

java.util.concurrent.atomic.AtomicLong tailIndex

headIndex

java.util.concurrent.atomic.AtomicLong headIndex
Constructor Detail

StoredQueue

public StoredQueue(com.sleepycat.je.Database db,
                   java.lang.Class clsOrNull,
                   com.sleepycat.bind.serial.StoredClassCatalog classCatalog)
Create a StoredQueue backed by the given Database. The Class of values to be queued may be provided; there is only a benefit when a primitive type is specified. A StoredClassCatalog must be provided if a primitive type is not supplied.

Parameters:
db -
clsOrNull -
classCatalog -
Method Detail

hookupDatabase

public void hookupDatabase(com.sleepycat.je.Database db,
                           java.lang.Class clsOrNull,
                           com.sleepycat.bind.serial.StoredClassCatalog classCatalog)
Parameters:
db -
clsOrNull -
classCatalog -

iterator

public java.util.Iterator<E> iterator()
Specified by:
iterator in interface java.lang.Iterable<E extends java.io.Serializable>
Specified by:
iterator in interface java.util.Collection<E extends java.io.Serializable>
Specified by:
iterator in class java.util.AbstractCollection<E extends java.io.Serializable>

size

public int size()
Specified by:
size in interface java.util.Collection<E extends java.io.Serializable>
Specified by:
size in class java.util.AbstractCollection<E extends java.io.Serializable>

offer

public boolean offer(E o)
Specified by:
offer in interface java.util.Queue<E extends java.io.Serializable>

peek

public E peek()
Specified by:
peek in interface java.util.Queue<E extends java.io.Serializable>

poll

public E poll()
Specified by:
poll in interface java.util.Queue<E extends java.io.Serializable>

databaseConfig

public static com.sleepycat.je.DatabaseConfig databaseConfig()
A suitable DatabaseConfig for the Database backing a StoredQueue. (However, it is not necessary to use these config options.)

Returns:
DatabaseConfig suitable for queue

close

public void close()


Copyright © 2003-2011 Internet Archive. All Rights Reserved.