org.infinispan.loaders.file
Class FileCacheStore
java.lang.Object
org.infinispan.loaders.AbstractCacheLoader
org.infinispan.loaders.AbstractCacheStore
org.infinispan.loaders.LockSupportCacheStore<Integer>
org.infinispan.loaders.bucket.BucketBasedCacheStore
org.infinispan.loaders.file.FileCacheStore
- All Implemented Interfaces:
- CacheLoader, CacheStore
public class FileCacheStore
- extends BucketBasedCacheStore
A filesystem-based implementation of a BucketBasedCacheStore
. This file store
stores stuff in the following format: /{location}/cache name/bucket_number.bucket
- Since:
- 4.0
- Author:
- Manik Surtani, Mircea.Markus@jboss.com, Trustin Lee, Galder ZamarreƱo, Sanne Grinovero
Methods inherited from class org.infinispan.loaders.LockSupportCacheStore |
acquireGlobalLock, clear, fromStream, getTotalLockCount, immediateLockForWriting, load, load, loadAll, loadAllKeys, lockForReading, lockForWriting, releaseGlobalLock, remove, store, toStream, unlock |
Methods inherited from class org.infinispan.loaders.AbstractCacheStore |
applyModifications, commit, getCacheStoreConfig, getConcurrencyLevel, getMarshaller, prepare, purgeExpired, removeAll, rollback, safeClose, safeClose |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileCacheStore
public FileCacheStore()
getRoot
public File getRoot()
- Returns:
- root directory where all files for this
CacheStore
are written.
init
public void init(CacheLoaderConfig config,
Cache<?,?> cache,
StreamingMarshaller m)
throws CacheLoaderException
- Description copied from interface:
CacheLoader
- Used to initialize a cache loader. Typically invoked by the
CacheLoaderManager
when setting up cache loaders.
- Specified by:
init
in interface CacheLoader
- Overrides:
init
in class LockSupportCacheStore<Integer>
- Parameters:
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.
- Throws:
CacheLoaderException
loopOverBuckets
protected void loopOverBuckets(BucketBasedCacheStore.BucketHandler handler)
throws CacheLoaderException
- Description copied from class:
BucketBasedCacheStore
- A mechanism to loop over all buckets in the cache store. Implementations should, very simply, loop over all
available buckets, and for each deserialized bucket, pass it to the handler.
The implementation is expected to loop over all available buckets (in any order), until
BucketBasedCacheStore.BucketHandler.handle(Bucket)
returns true or there are no more buckets available.
- Specified by:
loopOverBuckets
in class BucketBasedCacheStore
- Throws:
CacheLoaderException
fromStreamLockSafe
protected void fromStreamLockSafe(ObjectInput objectInput)
throws CacheLoaderException
- Specified by:
fromStreamLockSafe
in class LockSupportCacheStore<Integer>
- Throws:
CacheLoaderException
toStreamLockSafe
protected void toStreamLockSafe(ObjectOutput objectOutput)
throws CacheLoaderException
- Specified by:
toStreamLockSafe
in class LockSupportCacheStore<Integer>
- Throws:
CacheLoaderException
clearLockSafe
protected void clearLockSafe()
throws CacheLoaderException
- Specified by:
clearLockSafe
in class LockSupportCacheStore<Integer>
- Throws:
CacheLoaderException
supportsMultiThreadedPurge
protected boolean supportsMultiThreadedPurge()
- Overrides:
supportsMultiThreadedPurge
in class AbstractCacheStore
purgeInternal
protected void purgeInternal()
throws CacheLoaderException
- Specified by:
purgeInternal
in class AbstractCacheStore
- Throws:
CacheLoaderException
loadBucket
protected Bucket loadBucket(Integer hash)
throws CacheLoaderException
- Description copied from class:
BucketBasedCacheStore
- Loads a Bucket from the store, based on the hash code of the bucket.
- Specified by:
loadBucket
in class BucketBasedCacheStore
- Parameters:
hash
- the Bucket's hash
- Returns:
- a Bucket if one exists, null otherwise.
- Throws:
CacheLoaderException
- in case of problems with the store.
loadBucket
protected Bucket loadBucket(File bucketFile)
throws CacheLoaderException,
InterruptedException
- Throws:
CacheLoaderException
InterruptedException
updateBucket
public void updateBucket(Bucket b)
throws CacheLoaderException
- Description copied from class:
BucketBasedCacheStore
- Updates a bucket in the store with the Bucket passed in to the method. This method assumes that the bucket
already exists in the store, however some implementations may choose to simply create a new bucket if the bucket
does not exist.
The default behavior is that non-existent buckets are created on the fly. If this is not the case in your
implementation, then you would have to override
BucketBasedCacheStore.insertBucket(Bucket)
as well so that it doesn't blindly
forward calls to BucketBasedCacheStore.updateBucket(Bucket)
.
- Specified by:
updateBucket
in class BucketBasedCacheStore
- Parameters:
b
- bucket to update.
- Throws:
CacheLoaderException
- in case of problems with the store.
getConfigurationClass
public Class<? extends CacheLoaderConfig> getConfigurationClass()
- Description copied from interface:
CacheLoader
- This method is used by the configuration parser to get a hold of the CacheLoader implementation's corresponding
CacheLoaderConfig
type. This is usually done by instantiating the CacheLoader
and then calling this method. This may result in 2 instances being created, however, since the instance
created to get a hold of the configuration type is then discarded and another instance is created for actual
use as a CacheLoader when the cache starts.
Since Infinispan 4.1, you can also annotate your CacheLoader implementation with CacheLoaderMetadata
and provide this information via the annotation, which will prevent unnecessary instances being created.
- Returns:
- the type of the
CacheLoaderConfig
bean used to configure this
implementation of CacheLoader
.
start
public void start()
throws CacheLoaderException
- Specified by:
start
in interface CacheLoader
- Overrides:
start
in class LockSupportCacheStore<Integer>
- Throws:
CacheLoaderException
stop
public void stop()
throws CacheLoaderException
- Specified by:
stop
in interface CacheLoader
- Overrides:
stop
in class AbstractCacheStore
- Throws:
CacheLoaderException
loadBucketContainingKey
public Bucket loadBucketContainingKey(String key)
throws CacheLoaderException
- Throws:
CacheLoaderException
Copyright © 2011 JBoss, a division of Red Hat. All Rights Reserved.