org.infinispan.loaders.cloud
Class CloudCacheStore

java.lang.Object
  extended by org.infinispan.loaders.AbstractCacheLoader
      extended by org.infinispan.loaders.AbstractCacheStore
          extended by org.infinispan.loaders.LockSupportCacheStore<Integer>
              extended by org.infinispan.loaders.bucket.BucketBasedCacheStore
                  extended by org.infinispan.loaders.cloud.CloudCacheStore
All Implemented Interfaces:
CacheLoader, CacheStore

public class CloudCacheStore
extends BucketBasedCacheStore

The CloudCacheStore implementation that utilizes JClouds to communicate with cloud storage providers such as Amazon's S3, Rackspace's Cloudfiles, or any other such provider supported by JClouds.

This file store stores stuff in the following format: http://{cloud-storage-provider}/{bucket}/{bucket_number}

Since:
4.0
Author:
Manik Surtani, Adrian Cole

Nested Class Summary
 
Nested classes/interfaces inherited from class org.infinispan.loaders.bucket.BucketBasedCacheStore
BucketBasedCacheStore.BucketHandler, BucketBasedCacheStore.CollectionGeneratingBucketHandler<T>
 
Field Summary
protected static String EARLIEST_EXPIRY_TIME
           
 
Fields inherited from class org.infinispan.loaders.AbstractCacheStore
multiThreadedPurge, purgerService
 
Fields inherited from class org.infinispan.loaders.AbstractCacheLoader
cache, marshaller
 
Constructor Summary
CloudCacheStore()
           
 
Method Summary
 void applyModifications(List<? extends Modification> modifications)
           
protected  void clearLockSafe()
           
protected  void fromStreamLockSafe(ObjectInput objectInput)
           
 Class<? extends CacheStoreConfig> getConfigurationClass()
          This method is used by the configuration parser to get a hold of the CacheLoader implementation's corresponding CacheLoaderConfig type.
 void init(CacheLoaderConfig cfg, Cache<?,?> cache, StreamingMarshaller m)
          Used to initialize a cache loader.
 void init(CacheLoaderConfig cfg, Cache<?,?> cache, StreamingMarshaller m, org.jclouds.blobstore.BlobStoreContext ctx, org.jclouds.blobstore.BlobStore blobStore, org.jclouds.blobstore.AsyncBlobStore asyncBlobStore, boolean constructInternalBlobstores)
           
protected  Bucket loadBucket(Integer hash)
          Loads a Bucket from the store, based on the hash code of the bucket.
protected  void loopOverBuckets(BucketBasedCacheStore.BucketHandler handler)
          A mechanism to loop over all buckets in the cache store.
protected  void purgeInternal()
           
 void start()
           
protected  boolean supportsMultiThreadedPurge()
           
protected  void toStreamLockSafe(ObjectOutput objectOutput)
           
protected  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.bucket.BucketBasedCacheStore
getLockFromKey, insertBucket, loadAllKeysLockSafe, loadAllLockSafe, loadLockSafe, loadLockSafe, removeLockSafe, storeLockSafe
 
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
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
 

Field Detail

EARLIEST_EXPIRY_TIME

protected static final String EARLIEST_EXPIRY_TIME
See Also:
Constant Field Values
Constructor Detail

CloudCacheStore

public CloudCacheStore()
Method Detail

getConfigurationClass

public Class<? extends CacheStoreConfig> 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.

supportsMultiThreadedPurge

protected boolean supportsMultiThreadedPurge()
Overrides:
supportsMultiThreadedPurge in class AbstractCacheStore

init

public void init(CacheLoaderConfig cfg,
                 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:
cfg - 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

init

public void init(CacheLoaderConfig cfg,
                 Cache<?,?> cache,
                 StreamingMarshaller m,
                 org.jclouds.blobstore.BlobStoreContext ctx,
                 org.jclouds.blobstore.BlobStore blobStore,
                 org.jclouds.blobstore.AsyncBlobStore asyncBlobStore,
                 boolean constructInternalBlobstores)
          throws CacheLoaderException
Throws:
CacheLoaderException

start

public void start()
           throws CacheLoaderException
Specified by:
start in interface CacheLoader
Overrides:
start in class LockSupportCacheStore<Integer>
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()
Specified by:
clearLockSafe in class LockSupportCacheStore<Integer>

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.

purgeInternal

protected void purgeInternal()
                      throws CacheLoaderException
Specified by:
purgeInternal in class AbstractCacheStore
Throws:
CacheLoaderException

updateBucket

protected void updateBucket(Bucket bucket)
                     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:
bucket - bucket to update.
Throws:
CacheLoaderException - in case of problems with the store.

applyModifications

public void applyModifications(List<? extends Modification> modifications)
                        throws CacheLoaderException
Overrides:
applyModifications in class AbstractCacheStore
Throws:
CacheLoaderException

-->

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