Package org.infinispan.persistence.sifs
Class IndexQueue
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<org.infinispan.persistence.sifs.IndexRequest>
-
- org.infinispan.persistence.sifs.IndexQueue
-
- All Implemented Interfaces:
Iterable<org.infinispan.persistence.sifs.IndexRequest>
,Collection<org.infinispan.persistence.sifs.IndexRequest>
,BlockingQueue<org.infinispan.persistence.sifs.IndexRequest>
,Queue<org.infinispan.persistence.sifs.IndexRequest>
public class IndexQueue extends AbstractQueue<org.infinispan.persistence.sifs.IndexRequest> implements BlockingQueue<org.infinispan.persistence.sifs.IndexRequest>
Splits the requests into several subqueues according to request.key.hashCode(). If the request has no key, inserts countdown into the request and puts it into all subqueues - the thread that retrieves such element should call countDown() and upon true handle the request (this preserves the FIFO ordering).- Author:
- Radim Vansa <rvansa@redhat.coPausem>
-
-
Constructor Summary
Constructors Constructor Description IndexQueue(int segments, int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
drainTo(Collection<? super org.infinispan.persistence.sifs.IndexRequest> c)
int
drainTo(Collection<? super org.infinispan.persistence.sifs.IndexRequest> c, int maxElements)
Iterator<org.infinispan.persistence.sifs.IndexRequest>
iterator()
boolean
offer(org.infinispan.persistence.sifs.IndexRequest indexRequest)
boolean
offer(org.infinispan.persistence.sifs.IndexRequest indexRequest, long timeout, TimeUnit unit)
org.infinispan.persistence.sifs.IndexRequest
peek()
org.infinispan.persistence.sifs.IndexRequest
poll()
org.infinispan.persistence.sifs.IndexRequest
poll(long timeout, TimeUnit unit)
void
put(org.infinispan.persistence.sifs.IndexRequest indexRequest)
int
remainingCapacity()
int
size()
BlockingQueue<org.infinispan.persistence.sifs.IndexRequest>
subQueue(int id)
org.infinispan.persistence.sifs.IndexRequest
take()
-
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.concurrent.BlockingQueue
add, contains, remove
-
Methods inherited from interface java.util.Collection
addAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
-
-
-
Method Detail
-
iterator
public Iterator<org.infinispan.persistence.sifs.IndexRequest> iterator()
- Specified by:
iterator
in interfaceCollection<org.infinispan.persistence.sifs.IndexRequest>
- Specified by:
iterator
in interfaceIterable<org.infinispan.persistence.sifs.IndexRequest>
- Specified by:
iterator
in classAbstractCollection<org.infinispan.persistence.sifs.IndexRequest>
-
size
public int size()
- Specified by:
size
in interfaceCollection<org.infinispan.persistence.sifs.IndexRequest>
- Specified by:
size
in classAbstractCollection<org.infinispan.persistence.sifs.IndexRequest>
-
put
public void put(org.infinispan.persistence.sifs.IndexRequest indexRequest) throws InterruptedException
- Specified by:
put
in interfaceBlockingQueue<org.infinispan.persistence.sifs.IndexRequest>
- Throws:
InterruptedException
-
offer
public boolean offer(org.infinispan.persistence.sifs.IndexRequest indexRequest, long timeout, TimeUnit unit) throws InterruptedException
- Specified by:
offer
in interfaceBlockingQueue<org.infinispan.persistence.sifs.IndexRequest>
- Throws:
InterruptedException
-
take
public org.infinispan.persistence.sifs.IndexRequest take() throws InterruptedException
- Specified by:
take
in interfaceBlockingQueue<org.infinispan.persistence.sifs.IndexRequest>
- Throws:
InterruptedException
-
poll
public org.infinispan.persistence.sifs.IndexRequest poll(long timeout, TimeUnit unit) throws InterruptedException
- Specified by:
poll
in interfaceBlockingQueue<org.infinispan.persistence.sifs.IndexRequest>
- Throws:
InterruptedException
-
remainingCapacity
public int remainingCapacity()
- Specified by:
remainingCapacity
in interfaceBlockingQueue<org.infinispan.persistence.sifs.IndexRequest>
-
drainTo
public int drainTo(Collection<? super org.infinispan.persistence.sifs.IndexRequest> c)
- Specified by:
drainTo
in interfaceBlockingQueue<org.infinispan.persistence.sifs.IndexRequest>
-
drainTo
public int drainTo(Collection<? super org.infinispan.persistence.sifs.IndexRequest> c, int maxElements)
- Specified by:
drainTo
in interfaceBlockingQueue<org.infinispan.persistence.sifs.IndexRequest>
-
offer
public boolean offer(org.infinispan.persistence.sifs.IndexRequest indexRequest)
- Specified by:
offer
in interfaceBlockingQueue<org.infinispan.persistence.sifs.IndexRequest>
- Specified by:
offer
in interfaceQueue<org.infinispan.persistence.sifs.IndexRequest>
-
poll
public org.infinispan.persistence.sifs.IndexRequest poll()
-
peek
public org.infinispan.persistence.sifs.IndexRequest peek()
-
subQueue
public BlockingQueue<org.infinispan.persistence.sifs.IndexRequest> subQueue(int id)
-
-