|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.infinispan.container.FIFODataContainer
@ThreadSafe public class FIFODataContainer
A container that maintains order of entries based on when they were placed in the container. Iterators obtained from this container maintain this order.
This container offers constant-time operation for all public API methods. This is implemented using a set of lockable segments, each of which is a hash table, not unlike the JDK'sConcurrentHashMap with the exception that each entry is also linked.
Links are maintained using techniques inspired by H. Sundell and P. Tsigas' 2008 paper, Lock Free Deques and Doubly
Linked Lists, M. Michael's 2002 paper, High
Performance Dynamic Lock-Free Hash Tables and List-Based Sets
This implementation uses a technique of delegating marker nodes similar to the technique used in Sun's
ConcurrentSkipListMap, which is deemed more memory efficient and better performing than
AtomicMarkableReferences.
| Nested Class Summary | |
|---|---|
protected class |
FIFODataContainer.EntryIterator
|
protected class |
FIFODataContainer.EntrySet
|
protected class |
FIFODataContainer.ImmutableEntryIterator
|
protected class |
FIFODataContainer.KeyIterator
|
protected class |
FIFODataContainer.KeySet
|
protected class |
FIFODataContainer.LinkedIterator
|
protected class |
FIFODataContainer.ValueIterator
|
protected class |
FIFODataContainer.Values
|
| Constructor Summary | |
|---|---|
FIFODataContainer(int concurrencyLevel)
|
|
| Method Summary | |
|---|---|
void |
clear()
Removes all entries in the container |
boolean |
containsKey(Object k)
Tests whether an entry exists in the container |
protected org.infinispan.container.FIFODataContainer.LinkedEntry |
correctPrev(org.infinispan.container.FIFODataContainer.LinkedEntry suggestedPreviousEntry,
org.infinispan.container.FIFODataContainer.LinkedEntry currentEntry)
Correct 'previous' links. |
Set<InternalCacheEntry> |
entrySet()
Returns a mutable set of immutable cache entries exposed as immutable Map.Entry instances. |
InternalCacheEntry |
get(Object k)
Retrieves a cached entry |
protected org.infinispan.container.FIFODataContainer.LinkedEntry |
getNext(org.infinispan.container.FIFODataContainer.LinkedEntry current)
Retrieves the next entry after a given entry, skipping marked entries accordingly. |
protected void |
initLinks()
Initializes links to an empty container |
protected boolean |
isMarkedForRemoval(org.infinispan.container.FIFODataContainer.LinkedEntry e)
Tests whether a given linked entry is marked for deletion. |
Iterator<InternalCacheEntry> |
iterator()
|
Set<Object> |
keySet()
Returns a set of keys in the container. |
protected void |
linkAtEnd(org.infinispan.container.FIFODataContainer.LinkedEntry entry)
Links a new entry at the end of the linked list. |
protected boolean |
markNextReference(org.infinispan.container.FIFODataContainer.LinkedEntry e)
Places a removal marker the 'next' reference on the given entry. |
protected boolean |
markPrevReference(org.infinispan.container.FIFODataContainer.LinkedEntry e)
Places a removal marker the 'previous' reference on the given entry. |
InternalCacheEntry |
peek(Object k)
Retrieves a cache entry in the same way as DataContainer.get(Object)}
except that it does not update or reorder any of the internal constructs. |
void |
purgeExpired()
Purges entries that have passed their expiry time |
void |
put(Object k,
Object v,
long lifespan,
long maxIdle)
Puts an entry in the cache along with a lifespan and a maxIdle time |
InternalCacheEntry |
remove(Object k)
Removes an entry from the cache |
int |
size()
|
protected void |
unlink(org.infinispan.container.FIFODataContainer.LinkedEntry entry)
Un-links an entry from the doubly linked list in a threadsafe, lock-free manner. |
Collection<Object> |
values()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FIFODataContainer(int concurrencyLevel)
| Method Detail |
|---|
protected final boolean isMarkedForRemoval(org.infinispan.container.FIFODataContainer.LinkedEntry e)
e - entry to test
protected final boolean markPrevReference(org.infinispan.container.FIFODataContainer.LinkedEntry e)
e - entry
protected final boolean markNextReference(org.infinispan.container.FIFODataContainer.LinkedEntry e)
e - entry
protected final void initLinks()
protected final void unlink(org.infinispan.container.FIFODataContainer.LinkedEntry entry)
entry - entry to unlinkprotected final void linkAtEnd(org.infinispan.container.FIFODataContainer.LinkedEntry entry)
unlink(org.infinispan.container.FIFODataContainer.LinkedEntry)ed.
entry - entry to link at endprotected final org.infinispan.container.FIFODataContainer.LinkedEntry getNext(org.infinispan.container.FIFODataContainer.LinkedEntry current)
current - current entry to inspect
protected final org.infinispan.container.FIFODataContainer.LinkedEntry correctPrev(org.infinispan.container.FIFODataContainer.LinkedEntry suggestedPreviousEntry,
org.infinispan.container.FIFODataContainer.LinkedEntry currentEntry)
suggestedPreviousEntry - suggested previous entrycurrentEntry - current entry
public InternalCacheEntry get(Object k)
DataContainer
get in interface DataContainerk - key under which entry is stored
public InternalCacheEntry peek(Object k)
DataContainerDataContainer.get(Object)}
except that it does not update or reorder any of the internal constructs.
I.e., expiration does not happen, and in the case of the LRU container,
the entry is not moved to the end of the chain.
This method should be used instead of DataContainer.get(Object)} when called
while iterating through the data container using methods like DataContainer.keySet()
to avoid changing the underlying collection's order.
peek in interface DataContainerk - key under which entry is stored
public void put(Object k,
Object v,
long lifespan,
long maxIdle)
DataContainer
put in interface DataContainerk - key under which to store entryv - value to storelifespan - lifespan in milliseconds. -1 means immortal.maxIdle - max idle time for which to store entry. -1 means forever.public boolean containsKey(Object k)
DataContainer
containsKey in interface DataContainerk - key to test
public InternalCacheEntry remove(Object k)
DataContainer
remove in interface DataContainerk - key to remove
public int size()
size in interface DataContainerpublic void clear()
DataContainer
clear in interface DataContainerpublic Set<Object> keySet()
DataContainer#get() method but instead #peek(), in order to avoid
changing the order of the underlying collection as a side of effect of iterating through it.
keySet in interface DataContainerpublic Collection<Object> values()
values in interface DataContainerpublic Set<InternalCacheEntry> entrySet()
DataContainer
entrySet in interface DataContainerpublic void purgeExpired()
DataContainer
purgeExpired in interface DataContainerpublic Iterator<InternalCacheEntry> iterator()
iterator in interface Iterable<InternalCacheEntry>
|
Google Analytics | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||