org.infinispan.loaders.file
Class FileCacheStore

java.lang.Object
  extended by org.infinispan.loaders.AbstractCacheLoader
      extended by org.infinispan.loaders.AbstractCacheStore
          extended by org.infinispan.loaders.LockSupportCacheStore
              extended by org.infinispan.loaders.bucket.BucketBasedCacheStore
                  extended by 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

Field Summary
 
Fields inherited from class org.infinispan.loaders.AbstractCacheStore
cache, marshaller, multiThreadedPurge, purgerService
 
Constructor Summary
FileCacheStore()
           
 
Method Summary
protected  void clearLockSafe()
           
protected  void fromStreamLockSafe(ObjectInput objectInput)
           
 Class<? extends CacheLoaderConfig> getConfigurationClass()
           
 File getRoot()
           
 void init(CacheLoaderConfig config, Cache cache, Marshaller m)
          Used to initialize a cache loader.
protected  void insertBucket(Bucket bucket)
          Inserts a new Bucket in the storage system.
protected  Set<InternalCacheEntry> loadAllLockSafe()
           
protected  Bucket loadBucket(File bucketFile)
           
protected  Bucket loadBucket(String bucketName)
          Loads a Bucket from the store, based on the hash code of the bucket.
 Bucket loadBucketContainingKey(String key)
           
protected  void purgeInternal()
           
 void start()
           
protected  boolean supportsMultiThreadedPurge()
           
protected  void toStreamLockSafe(ObjectOutput objectOutput)
           
 void updateBucket(Bucket b)
          Updates a bucket in the store with the Bucket passed in to the method.
 
Methods inherited from class org.infinispan.loaders.bucket.BucketBasedCacheStore
getLockFromKey, loadLockSafe, removeLockSafe, storeLockSafe
 
Methods inherited from class org.infinispan.loaders.LockSupportCacheStore
acquireGlobalLock, clear, fromStream, getTotalLockCount, immediateLockForWriting, load, loadAll, 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, stop
 
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
 

Constructor Detail

FileCacheStore

public FileCacheStore()
Method Detail

getRoot

public File getRoot()
Returns:
root directory where all files for this CacheStore are written.

init

public void init(CacheLoaderConfig config,
                 Cache cache,
                 Marshaller 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
Parameters:
config - the cache loader configuration bean
cache - 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

loadAllLockSafe

protected Set<InternalCacheEntry> loadAllLockSafe()
                                           throws CacheLoaderException
Specified by:
loadAllLockSafe in class LockSupportCacheStore
Throws:
CacheLoaderException

fromStreamLockSafe

protected void fromStreamLockSafe(ObjectInput objectInput)
                           throws CacheLoaderException
Specified by:
fromStreamLockSafe in class LockSupportCacheStore
Throws:
CacheLoaderException

toStreamLockSafe

protected void toStreamLockSafe(ObjectOutput objectOutput)
                         throws CacheLoaderException
Specified by:
toStreamLockSafe in class LockSupportCacheStore
Throws:
CacheLoaderException

clearLockSafe

protected void clearLockSafe()
                      throws CacheLoaderException
Specified by:
clearLockSafe in class LockSupportCacheStore
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(String bucketName)
                     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:
bucketName - String representation of 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
Throws:
CacheLoaderException

insertBucket

protected void insertBucket(Bucket bucket)
                     throws CacheLoaderException
Description copied from class: BucketBasedCacheStore
Inserts a new Bucket in the storage system. If the bucket already exists, this method should simply update the store with the contents of the bucket - i.e., behave the same as BucketBasedCacheStore.updateBucket(Bucket).

Specified by:
insertBucket in class BucketBasedCacheStore
Parameters:
bucket - bucket to insert
Throws:
CacheLoaderException - in case of problems with the store.

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.

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()
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
Throws:
CacheLoaderException

loadBucketContainingKey

public Bucket loadBucketContainingKey(String key)
                               throws CacheLoaderException
Throws:
CacheLoaderException

Google Analytics

Copyright © 2010 JBoss, a division of Red Hat. All Rights Reserved.