|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractCollection
com.gemstone.bp.edu.emory.mathcs.backport.java.util.AbstractCollection
com.gemstone.bp.edu.emory.mathcs.backport.java.util.AbstractQueue
regionQueue.ServerQueue
public class ServerQueue
The server side of a distributed queue. The server holds the
contents of a queue in a RegionQueue that may be backed up
in other servers. It receives clients' requests to add and remove
items from the queue via a "communication region" that has a
special CacheLoader and CacheWriter that interact
with the queue.
This class implements the BlockingQueue interface so
it can be treated as a queue. However, it delegates all of the
queue-related functionality to the underlying
RegionQueue.
| Nested Class Summary | |
|---|---|
(package private) class |
ServerQueue.QueueLoader
A CacheLoader that perform some "get"-related
operation on the RegionQueue. |
(package private) class |
ServerQueue.QueueWriter
A CacheWriter that adds an element to the tail of
the queue. |
| Field Summary | |
|---|---|
(package private) static String |
COMM_REGION_NAME
The name of the subregion used for communication. |
protected String |
name
The name of this queue |
protected RegionQueue |
regionQueue
The region queue that stores the contents of this distributed queue. |
| Constructor Summary | |
|---|---|
ServerQueue(String name,
int capacity,
DistributedSystem system,
int port)
Creates a new ServerQueue whose contents is
available to ClientQueue via the given port. |
|
| Method Summary | |
|---|---|
void |
close()
Closes this ServerQueue and releases all resources
held by it including the Cache and all regions. |
int |
drainTo(Collection c)
|
int |
drainTo(Collection c,
int maxElements)
|
String |
getName()
|
boolean |
isEmpty()
|
Iterator |
iterator()
|
static void |
main(String[] args)
A main program that creates a ServerQueue. |
boolean |
offer(Object o)
|
boolean |
offer(Object o,
long timeout,
com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.TimeUnit unit)
|
Object |
peek()
|
Object |
poll()
|
Object |
poll(long timeout,
com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.TimeUnit unit)
|
void |
put(Object o)
|
int |
remainingCapacity()
|
int |
size()
|
Object |
take()
|
Object[] |
toArray()
|
Object[] |
toArray(Object[] array)
|
String |
toString()
|
| Methods inherited from class com.gemstone.bp.edu.emory.mathcs.backport.java.util.AbstractQueue |
|---|
add, addAll, clear, element, remove |
| Methods inherited from class java.util.AbstractCollection |
|---|
contains, containsAll, remove, removeAll, retainAll |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue |
|---|
add, contains, remove |
| Methods inherited from interface com.gemstone.bp.edu.emory.mathcs.backport.java.util.Queue |
|---|
element, remove |
| Methods inherited from interface java.util.Collection |
|---|
addAll, clear, containsAll, equals, hashCode, removeAll, retainAll |
| Field Detail |
|---|
static final String COMM_REGION_NAME
protected final String name
protected final RegionQueue regionQueue
| Constructor Detail |
|---|
public ServerQueue(String name,
int capacity,
DistributedSystem system,
int port)
throws TimeoutException
ServerQueue whose contents is
available to ClientQueue via the given port.
name - The name of the distributed queuesystem - The distributed system to which the queue belongsport - The port on which clients connect to the queuecapacity - The maximum number of elements allowed in the queue
TimeoutException - If a cache access times out which creating the queue
IllegalStateException - If the state of the cache prevents the queue from being
created| Method Detail |
|---|
public void close()
ServerQueue and releases all resources
held by it including the Cache and all regions.
public void put(Object o)
throws InterruptedException
put in interface com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.BlockingQueueInterruptedException
public Object take()
throws InterruptedException
take in interface com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.BlockingQueueInterruptedExceptionpublic Object peek()
peek in interface com.gemstone.bp.edu.emory.mathcs.backport.java.util.Queuepublic boolean isEmpty()
isEmpty in interface CollectionisEmpty in class AbstractCollectionpublic Object poll()
poll in interface com.gemstone.bp.edu.emory.mathcs.backport.java.util.Queuepublic int size()
size in interface Collectionsize in class AbstractCollectionpublic Object[] toArray(Object[] array)
toArray in interface CollectiontoArray in class com.gemstone.bp.edu.emory.mathcs.backport.java.util.AbstractCollectionpublic Object[] toArray()
toArray in interface CollectiontoArray in class com.gemstone.bp.edu.emory.mathcs.backport.java.util.AbstractCollection
public Object poll(long timeout,
com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.TimeUnit unit)
throws InterruptedException
poll in interface com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.BlockingQueueInterruptedExceptionpublic boolean offer(Object o)
offer in interface com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.BlockingQueueoffer in interface com.gemstone.bp.edu.emory.mathcs.backport.java.util.Queue
public boolean offer(Object o,
long timeout,
com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.TimeUnit unit)
throws InterruptedException
offer in interface com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.BlockingQueueInterruptedExceptionpublic int remainingCapacity()
remainingCapacity in interface com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.BlockingQueuepublic Iterator iterator()
iterator in interface Iterableiterator in interface Collectioniterator in class AbstractCollectionpublic int drainTo(Collection c)
drainTo in interface com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue
public int drainTo(Collection c,
int maxElements)
drainTo in interface com.gemstone.bp.edu.emory.mathcs.backport.java.util.concurrent.BlockingQueuepublic String getName()
public String toString()
toString in class AbstractCollection
public static void main(String[] args)
throws Throwable
ServerQueue.
Throwable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||