org.infinispan.loaders
Class AbstractCacheStore

java.lang.Object
  extended by org.infinispan.loaders.AbstractCacheLoader
      extended by org.infinispan.loaders.AbstractCacheStore
All Implemented Interfaces:
CacheLoader, CacheStore
Direct Known Subclasses:
BdbjeCacheStore, JdbcMixedCacheStore, JdbmCacheStore, LockSupportCacheStore, RemoteCacheStore

public abstract class AbstractCacheStore
extends AbstractCacheLoader
implements CacheStore

An abstract CacheStore that holds common implementations for some methods

Since:
4.0
Author:
Manik Surtani, Mircea.Markus@jboss.com

Field Summary
protected  boolean multiThreadedPurge
           
protected  ExecutorService purgerService
           
 
Fields inherited from class org.infinispan.loaders.AbstractCacheLoader
cache, marshaller
 
Constructor Summary
AbstractCacheStore()
           
 
Method Summary
protected  void applyModifications(List<? extends Modification> mods)
           
 void commit(GlobalTransaction tx)
          Commits a transaction that has been previously prepared.
 CacheStoreConfig getCacheStoreConfig()
          Returns the configuration object associated to this cache store config.
protected  int getConcurrencyLevel()
           
protected  StreamingMarshaller getMarshaller()
           
 void init(CacheLoaderConfig config, Cache<?,?> cache, StreamingMarshaller m)
          Used to initialize a cache loader.
 void prepare(List<? extends Modification> mods, GlobalTransaction tx, boolean isOnePhase)
          Issues a prepare call with a set of modifications to be applied to the cache store
 void purgeExpired()
          Purges expired entries from the store.
protected abstract  void purgeInternal()
           
 void removeAll(Set<Object> keys)
          Bulk remove operation
 void rollback(GlobalTransaction tx)
          Rolls back a transaction that has been previously prepared

This method may be invoked on a transaction for which there is no prior CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean).

protected  void safeClose(InputStream stream)
           
protected  void safeClose(OutputStream stream)
           
 void start()
           
 void stop()
           
protected  boolean 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.CacheStore
clear, fromStream, remove, store, toStream
 
Methods inherited from interface org.infinispan.loaders.CacheLoader
containsKey, getConfigurationClass, load, load, loadAll, loadAllKeys
 

Field Detail

purgerService

protected ExecutorService purgerService

multiThreadedPurge

protected boolean multiThreadedPurge
Constructor Detail

AbstractCacheStore

public AbstractCacheStore()
Method Detail

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 AbstractCacheLoader
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

getConcurrencyLevel

protected final int getConcurrencyLevel()

start

public void start()
           throws CacheLoaderException
Specified by:
start in interface CacheLoader
Throws:
CacheLoaderException

supportsMultiThreadedPurge

protected boolean supportsMultiThreadedPurge()

stop

public void stop()
          throws CacheLoaderException
Specified by:
stop in interface CacheLoader
Throws:
CacheLoaderException

purgeExpired

public void purgeExpired()
                  throws CacheLoaderException
Description copied from interface: CacheStore
Purges expired entries from the store.

Specified by:
purgeExpired in interface CacheStore
Throws:
CacheLoaderException - in the event of problems writing to the store

purgeInternal

protected abstract void purgeInternal()
                               throws CacheLoaderException
Throws:
CacheLoaderException

applyModifications

protected void applyModifications(List<? extends Modification> mods)
                           throws CacheLoaderException
Throws:
CacheLoaderException

prepare

public void prepare(List<? extends Modification> mods,
                    GlobalTransaction tx,
                    boolean isOnePhase)
             throws CacheLoaderException
Description copied from interface: CacheStore
Issues a prepare call with a set of modifications to be applied to the cache store

Specified by:
prepare in interface CacheStore
Parameters:
mods - modifications to be applied
tx - transaction identifier
isOnePhase - if true, there will not be a commit or rollback phase and changes should be flushed immediately
Throws:
CacheLoaderException - in the event of problems writing to the store

rollback

public void rollback(GlobalTransaction tx)
Description copied from interface: CacheStore
Rolls back a transaction that has been previously prepared

This method may be invoked on a transaction for which there is no prior CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean). The implementation would need to deal with this case acordingly. Typically, this would be a no-op, after ensuring any resources attached to the transaction are cleared up.

Also note that this method may be invoked on a thread which is different from the CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean) invocation. As such, ThreadLocals should not be relied upon to maintain transaction context.

Specified by:
rollback in interface CacheStore
Parameters:
tx - tx to roll back

getCacheStoreConfig

public CacheStoreConfig getCacheStoreConfig()
Description copied from interface: CacheStore
Returns the configuration object associated to this cache store config.

Specified by:
getCacheStoreConfig in interface CacheStore

commit

public void commit(GlobalTransaction tx)
            throws CacheLoaderException
Description copied from interface: CacheStore
Commits a transaction that has been previously prepared.

This method may be invoked on a transaction for which there is no prior CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean). The implementation would need to deal with this case acordingly. Typically, this would be a no-op, after ensuring any resources attached to the transaction are cleared up.

Also note that this method may be invoked on a thread which is different from the CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean) invocation. As such, ThreadLocals should not be relied upon to maintain transaction context.

Specified by:
commit in interface CacheStore
Parameters:
tx - tx to commit
Throws:
CacheLoaderException - in the event of problems writing to the store

removeAll

public void removeAll(Set<Object> keys)
               throws CacheLoaderException
Description copied from interface: CacheStore
Bulk remove operation

Specified by:
removeAll in interface CacheStore
Parameters:
keys - to remove
Throws:
CacheLoaderException - in the event of problems writing to the store

safeClose

protected final void safeClose(InputStream stream)
                        throws CacheLoaderException
Throws:
CacheLoaderException

safeClose

protected final void safeClose(OutputStream stream)
                        throws CacheLoaderException
Throws:
CacheLoaderException

getMarshaller

protected StreamingMarshaller getMarshaller()

Google Analytics

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