|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.infinispan.loaders.AbstractCacheLoader
org.infinispan.loaders.AbstractCacheStore
org.infinispan.loaders.LockSupportCacheStore
public abstract class LockSupportCacheStore
This class extends AbstractCacheStore
adding lock support for consistently accessing stored data.
StripedLock
. You can tune the concurrency level of the striped lock (see the Javadocs
of StripedLock for details on what this is) by using the LockSupportCacheStoreConfig.setLockConcurrencyLevel(int)
setter.
Field Summary |
---|
Fields inherited from class org.infinispan.loaders.AbstractCacheStore |
---|
cache, marshaller, multiThreadedPurge, purgerService |
Constructor Summary | |
---|---|
LockSupportCacheStore()
|
Method Summary | |
---|---|
protected void |
acquireGlobalLock(boolean exclusive)
Based on the supplied param, acquires a global read(false) or write (true) lock. |
void |
clear()
Clears all entries in the store |
protected abstract void |
clearLockSafe()
|
void |
fromStream(ObjectInput objectInput)
Writes contents of the stream to the store. |
protected abstract void |
fromStreamLockSafe(ObjectInput ois)
|
protected abstract String |
getLockFromKey(Object key)
|
int |
getTotalLockCount()
|
protected boolean |
immediateLockForWriting(String key)
Same as lockForWriting(String) , but with 0 timeout. |
void |
init(CacheLoaderConfig config,
Cache<?,?> cache,
Marshaller m)
Used to initialize a cache loader. |
InternalCacheEntry |
load(Object key)
Loads an entry mapped to by a given key. |
Set<InternalCacheEntry> |
loadAll()
Loads all entries in the loader. |
protected abstract Set<InternalCacheEntry> |
loadAllLockSafe()
|
protected abstract InternalCacheEntry |
loadLockSafe(Object key,
String lockingKey)
|
protected void |
lockForReading(String key)
Acquires read lock on the given key. |
protected void |
lockForWriting(String key)
Acquires write lock on the given key. |
protected void |
releaseGlobalLock(boolean exclusive)
Based on the supplied param, releases a global read(false) or write (true) lock. |
boolean |
remove(Object key)
Removes an entry in the store. |
protected abstract boolean |
removeLockSafe(Object key,
String lockingKey)
|
void |
start()
|
void |
store(InternalCacheEntry ed)
Stores an entry |
protected abstract void |
storeLockSafe(InternalCacheEntry ed,
String lockingKey)
|
void |
toStream(ObjectOutput objectOutput)
Loads the entire state into a stream, using whichever format is most efficient for the cache loader implementation. |
protected abstract void |
toStreamLockSafe(ObjectOutput oos)
|
protected void |
unlock(String key)
Release the locks (either read or write). |
Methods inherited from class org.infinispan.loaders.AbstractCacheStore |
---|
applyModifications, commit, getCacheStoreConfig, getConcurrencyLevel, getMarshaller, prepare, purgeExpired, purgeInternal, removeAll, rollback, safeClose, safeClose, stop, supportsMultiThreadedPurge |
Methods inherited from class org.infinispan.loaders.AbstractCacheLoader |
---|
containsKey |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.infinispan.loaders.CacheLoader |
---|
containsKey, getConfigurationClass |
Constructor Detail |
---|
public LockSupportCacheStore()
Method Detail |
---|
public void init(CacheLoaderConfig config, Cache<?,?> cache, Marshaller m) throws CacheLoaderException
CacheLoader
CacheLoaderManager
when setting up cache loaders.
init
in interface CacheLoader
init
in class AbstractCacheStore
config
- the cache loader configuration beancache
- cache associated with this cache loader. Implementations may use this to determine cache name when
selecting where refer to state in storage, for example, a different database table name.m
- marshaller to use when loading state from a stream, if supported by the implementation.
CacheLoaderException
public void start() throws CacheLoaderException
start
in interface CacheLoader
start
in class AbstractCacheStore
CacheLoaderException
protected final void unlock(String key)
protected final void lockForWriting(String key) throws CacheLoaderException
CacheLoaderException
protected final void lockForReading(String key) throws CacheLoaderException
CacheLoaderException
protected final boolean immediateLockForWriting(String key) throws CacheLoaderException
lockForWriting(String)
, but with 0 timeout.
CacheLoaderException
protected final void acquireGlobalLock(boolean exclusive) throws CacheLoaderException
CacheLoaderException
protected final void releaseGlobalLock(boolean exclusive)
public final InternalCacheEntry load(Object key) throws CacheLoaderException
CacheLoader
key
- key
CacheLoaderException
- in the event of problems reading from sourcepublic final Set<InternalCacheEntry> loadAll() throws CacheLoaderException
CacheLoader
CacheLoaderException
- in the event of problems reading from sourcepublic final void store(InternalCacheEntry ed) throws CacheLoaderException
CacheStore
ed
- entry to store
CacheLoaderException
- in the event of problems writing to the storepublic final boolean remove(Object key) throws CacheLoaderException
CacheStore
key
- key to remove
CacheLoaderException
- in the event of problems writing to the storepublic final void fromStream(ObjectInput objectInput) throws CacheLoaderException
CacheStore
CacheStore.toStream(java.io.ObjectOutput)
. While not a
requirement, it is recommended that implementations make use of the Marshaller
when dealing with the stream to make use of efficient marshalling.
It is imperative that implementations do not close the stream after finishing with it.
It is also recommended that implementations use their own start and end markers on the stream since
other processes may write additional data to the stream after the cache store has written to it. As such, either
markers or some other mechanism to prevent the store from reading too much information should be employed when
writing to the stream in CacheStore.fromStream(java.io.ObjectInput)
to prevent data corruption.
It can be assumed that the stream passed in already performs buffering such that the cache store implementation
doesn't have to.
objectInput
- stream to read from
CacheLoaderException
- in the event of problems writing to the storepublic void toStream(ObjectOutput objectOutput) throws CacheLoaderException
CacheStore
CacheStore.fromStream(java.io.ObjectInput)
.
While not a requirement, it is recommended that implementations make use of the Marshaller
when dealing with the stream to make use of efficient marshalling.
It is imperative that implementations do not flush or close the stream after finishing with it.
It is also recommended that implementations use their own start and end markers on the stream since
other processes may write additional data to the stream after the cache store has written to it. As such, either
markers or some other mechanism to prevent the store from reading too much information in CacheStore.fromStream(java.io.ObjectInput)
should be employed, to prevent data corruption.
It can be assumed that the stream passed in already performs buffering such that the cache store implementation
doesn't have to.
objectOutput
- stream to write to
CacheLoaderException
- in the event of problems reading from the storepublic final void clear() throws CacheLoaderException
CacheStore
CacheLoaderException
- in the event of problems writing to the storepublic int getTotalLockCount()
protected abstract void clearLockSafe() throws CacheLoaderException
CacheLoaderException
protected abstract Set<InternalCacheEntry> loadAllLockSafe() throws CacheLoaderException
CacheLoaderException
protected abstract void toStreamLockSafe(ObjectOutput oos) throws CacheLoaderException
CacheLoaderException
protected abstract void fromStreamLockSafe(ObjectInput ois) throws CacheLoaderException
CacheLoaderException
protected abstract boolean removeLockSafe(Object key, String lockingKey) throws CacheLoaderException
CacheLoaderException
protected abstract void storeLockSafe(InternalCacheEntry ed, String lockingKey) throws CacheLoaderException
CacheLoaderException
protected abstract InternalCacheEntry loadLockSafe(Object key, String lockingKey) throws CacheLoaderException
CacheLoaderException
protected abstract String getLockFromKey(Object key) throws CacheLoaderException
CacheLoaderException
|
Google Analytics | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |