|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.infinispan.loaders.AbstractCacheLoader org.infinispan.loaders.AbstractCacheStore org.infinispan.loaders.LockSupportCacheStore org.infinispan.loaders.bucket.BucketBasedCacheStore
public abstract class BucketBasedCacheStore
Base class for CacheStore implementations that combine entries into buckets when storing data.
A hashing algorithm is used to map keys to buckets, and a bucket consists of a collection of key/value pairs. This approach, while adding an overhead of having to search through the contents of buckets a relevant entry, allows us to use any Serializable object as a key since the bucket is identified by a hash code. This hash code is often easy to represent in a physical store, such as a file system, database, etc.
Nested Class Summary | |
---|---|
protected static interface |
BucketBasedCacheStore.BucketHandler
|
protected class |
BucketBasedCacheStore.CollectionGeneratingBucketHandler<T>
|
Field Summary |
---|
Fields inherited from class org.infinispan.loaders.AbstractCacheStore |
---|
multiThreadedPurge, purgerService |
Fields inherited from class org.infinispan.loaders.AbstractCacheLoader |
---|
cache, marshaller |
Constructor Summary | |
---|---|
BucketBasedCacheStore()
|
Method Summary | |
---|---|
protected String |
getLockFromKey(Object key)
For BucketBasedCacheStore s the lock should be acquired at bucket level. |
protected void |
insertBucket(Bucket bucket)
Inserts a new Bucket in the storage system. |
protected Set<Object> |
loadAllKeysLockSafe(Set<Object> keysToExclude)
|
protected Set<InternalCacheEntry> |
loadAllLockSafe()
|
protected abstract Bucket |
loadBucket(String hash)
Loads a Bucket from the store, based on the hash code of the bucket. |
protected Set<InternalCacheEntry> |
loadLockSafe(int max)
|
protected InternalCacheEntry |
loadLockSafe(Object key,
String lockingKey)
Loads an entry from a Bucket, locating the relevant Bucket using the key's hash code. |
protected abstract void |
loopOverBuckets(BucketBasedCacheStore.BucketHandler handler)
A mechanism to loop over all buckets in the cache store. |
protected boolean |
removeLockSafe(Object key,
String lockingKey)
Removes an entry from a Bucket, locating the relevant Bucket using the key's hash code. |
protected void |
storeLockSafe(InternalCacheEntry entry,
String lockingKey)
Stores an entry in an appropriate Bucket, based on the key's hash code. |
protected abstract void |
updateBucket(Bucket bucket)
Updates a bucket in the store with the Bucket passed in to the method. |
Methods inherited from class org.infinispan.loaders.LockSupportCacheStore |
---|
acquireGlobalLock, clear, clearLockSafe, fromStream, fromStreamLockSafe, getTotalLockCount, immediateLockForWriting, init, load, load, loadAll, loadAllKeys, lockForReading, lockForWriting, releaseGlobalLock, remove, start, store, toStream, toStreamLockSafe, unlock |
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 BucketBasedCacheStore()
Method Detail |
---|
protected InternalCacheEntry loadLockSafe(Object key, String lockingKey) throws CacheLoaderException
loadLockSafe
in class LockSupportCacheStore
key
- key of the entry to remove.lockingKey
- the hash of the key, as returned by LockSupportCacheStore.getLockFromKey(Object)
. This
is required in order to avoid hash re-computation.
CacheLoaderException
protected void storeLockSafe(InternalCacheEntry entry, String lockingKey) throws CacheLoaderException
storeLockSafe
in class LockSupportCacheStore
entry
- the entry to storelockingKey
- the hash of the key, as returned by LockSupportCacheStore.getLockFromKey(Object)
. This
is required in order to avoid hash re-computation.
CacheLoaderException
protected boolean removeLockSafe(Object key, String lockingKey) throws CacheLoaderException
removeLockSafe
in class LockSupportCacheStore
key
- key of the entry to remove.lockingKey
- the hash of the key, as returned by LockSupportCacheStore.getLockFromKey(Object)
. This
is required in order to avoid hash re-computation.
CacheLoaderException
protected String getLockFromKey(Object key)
BucketBasedCacheStore
s the lock should be acquired at bucket level. So we're locking based on the
hash code of the key, as all keys having same hash code will be mapped to same bucket.
getLockFromKey
in class LockSupportCacheStore
protected void insertBucket(Bucket bucket) throws CacheLoaderException
updateBucket(Bucket)
.
bucket
- bucket to insert
CacheLoaderException
- in case of problems with the store.protected Set<InternalCacheEntry> loadAllLockSafe() throws CacheLoaderException
loadAllLockSafe
in class LockSupportCacheStore
CacheLoaderException
protected Set<InternalCacheEntry> loadLockSafe(int max) throws CacheLoaderException
loadLockSafe
in class LockSupportCacheStore
CacheLoaderException
protected Set<Object> loadAllKeysLockSafe(Set<Object> keysToExclude) throws CacheLoaderException
loadAllKeysLockSafe
in class LockSupportCacheStore
CacheLoaderException
protected abstract void loopOverBuckets(BucketBasedCacheStore.BucketHandler handler) throws CacheLoaderException
BucketBasedCacheStore.BucketHandler.handle(Bucket)
returns true or there are no more buckets available.
handler
-
CacheLoaderException
protected abstract void updateBucket(Bucket bucket) throws CacheLoaderException
insertBucket(Bucket)
as well so that it doesn't blindly
forward calls to updateBucket(Bucket)
.
bucket
- bucket to update.
CacheLoaderException
- in case of problems with the store.protected abstract Bucket loadBucket(String hash) throws CacheLoaderException
hash
- String representation of the Bucket's hash
CacheLoaderException
- in case of problems with the store.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |