|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.infinispan.loaders.AbstractCacheLoader
org.infinispan.loaders.AbstractCacheStore
org.infinispan.loaders.bdbje.BdbjeCacheStore
public class BdbjeCacheStore
An Oracle SleepyCat JE implementation of a CacheStore
.
name
stored entries
are stored here, keyed on
CacheEntry.getKey()
name
_class_catalog/{location}/je.properties is optional and will
override any parameters to the internal SleepyCat JE EnvironmentConfig
.
BdbjeCacheStoreConfig.getLockAcquistionTimeout()
.
Calls to CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean)
will attempt
to resolve deadlocks, retrying up to BdbjeCacheStoreConfig.getMaxTxRetries()
attempts.
Unlike the C version of SleepyCat, JE does not support MVCC or READ_COMMITTED isolation. In other words, readers
will block on any data held by a pending transaction. As such, it is best practice to keep the duration between
prepare
and commit
as short as possible.
Field Summary |
---|
Fields inherited from class org.infinispan.loaders.AbstractCacheStore |
---|
cache, marshaller, multiThreadedPurge, purgerService |
Constructor Summary | |
---|---|
BdbjeCacheStore()
|
Method Summary | |
---|---|
protected void |
applyModifications(List<? extends Modification> mods)
Perform the mods atomically by creating a worker and invoking
them in TransactionRunner.run(com.sleepycat.collections.TransactionWorker) . |
void |
clear()
Clears all entries in the store |
void |
commit(GlobalTransaction tx)
Commits a transaction that has been previously prepared. |
protected void |
completeTransaction(GlobalTransaction tx,
boolean commit)
Looks up the SleepyCat transaction associated with the parameter tx . |
void |
fromStream(ObjectInput ois)
Writes contents of the stream to the store. |
Class<? extends CacheLoaderConfig> |
getConfigurationClass()
|
void |
init(CacheLoaderConfig config,
Cache cache,
Marshaller m)
Used to initialize a cache loader. |
InternalCacheEntry |
load(Object key)
Loads an entry mapped to by a given key. |
Set<InternalCacheEntry> |
loadAll()
Loads all entries in the loader. |
protected void |
prepare(List<? extends Modification> mods,
GlobalTransaction tx)
Looks up the SleepyCat transaction associated with tx . |
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 |
printLicense()
prints terms of use for Berkeley DB JE |
protected void |
purgeInternal()
Iterate through StoredMap.entrySet() and remove, if expired. |
boolean |
remove(Object key)
Removes an entry in the store. |
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) . |
void |
start()
Validates configuration, configures and opens the Environment , then opens the databases . |
void |
stop()
Stops transaction and purge processing and closes the SleepyCat environment. |
void |
store(InternalCacheEntry ed)
Stores an entry |
void |
toStream(ObjectOutput oos)
Writes the current count of cachestore entries followed by a pair of byte[]s corresponding to the SleepyCat binary representation of key value . |
Methods inherited from class org.infinispan.loaders.AbstractCacheStore |
---|
getCacheStoreConfig, getConcurrencyLevel, getMarshaller, purgeExpired, removeAll, safeClose, safeClose, 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 |
Constructor Detail |
---|
public BdbjeCacheStore()
Method Detail |
---|
public void init(CacheLoaderConfig config, Cache cache, Marshaller m) throws CacheLoaderException
CacheLoaderManager
when setting up cache loaders. This implementation expects config to be an instance of BdbjeCacheStoreConfig
note
that the m
is not currently used as SleepyCat has its own efficient solution.
init
in interface CacheLoader
init
in class AbstractCacheStore
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.
CacheLoaderException
BdbjeCacheStoreConfig
public Class<? extends CacheLoaderConfig> getConfigurationClass()
BdbjeCacheStoreConfig
public void start() throws CacheLoaderException
Environment
, then opens the databases
. When this is
finished, transactional and purging services are instantiated.
start
in interface CacheLoader
start
in class AbstractCacheStore
CacheLoaderException
public void stop() throws CacheLoaderException
stop
in interface CacheLoader
stop
in class AbstractCacheStore
CacheLoaderException
public void prepare(List<? extends Modification> mods, GlobalTransaction tx, boolean isOnePhase) throws CacheLoaderException
applyModifications(java.util.List)
, if isOnePhase
.
Otherwise, delegates to prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction)
prepare
in interface CacheStore
prepare
in class AbstractCacheStore
mods
- modifications to be appliedtx
- transaction identifierisOnePhase
- if true, there will not be a commit or rollback phase and changes should be flushed
immediately
CacheLoaderException
- in the event of problems writing to the storeprotected void applyModifications(List<? extends Modification> mods) throws CacheLoaderException
mods
atomically by creating a worker
and invoking
them in TransactionRunner.run(com.sleepycat.collections.TransactionWorker)
.
applyModifications
in class AbstractCacheStore
mods
- actions to perform atomically
CacheLoaderException
- on problems during the transactionprotected void prepare(List<? extends Modification> mods, GlobalTransaction tx) throws CacheLoaderException
SleepyCat transaction
associated with tx
. Creates a ModificationsTransactionWorker
instance from mods
. Then prepares the
transaction via PreparableTransactionRunner.prepare(com.sleepycat.collections.TransactionWorker)
. Finally,
it invalidates CurrentTransaction.getTransaction()
so that no other thread can
accidentally commit this.
mods
- modifications to be appliedtx
- transaction identifier
CacheLoaderException
- in the event of problems writing to the storepublic void rollback(GlobalTransaction tx)
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, ThreadLocal
s should not be relied upon to maintain transaction context.
This implementation calls completeTransaction(org.infinispan.transaction.xa.GlobalTransaction, boolean)
completeTransaction} with an argument of false.
rollback
in interface CacheStore
rollback
in class AbstractCacheStore
tx
- tx to roll backpublic void commit(GlobalTransaction tx) throws CacheLoaderException
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, ThreadLocal
s should not be relied upon to maintain transaction context.
This implementation calls completeTransaction(org.infinispan.transaction.xa.GlobalTransaction, boolean)
completeTransaction} with an argument of true.
commit
in interface CacheStore
commit
in class AbstractCacheStore
tx
- tx to commit
CacheLoaderException
- in the event of problems writing to the storeprotected void completeTransaction(GlobalTransaction tx, boolean commit) throws CacheLoaderException
tx
. If there is no associated
sleepycat transaction, an error is logged.
tx
- java transaction used to lookup a SleepyCat transactioncommit
- true to commit false to abort
CacheLoaderException
- if there are problems committing or aborting the transactionpublic boolean remove(Object key) throws CacheLoaderException
StoredMap.remove(Object)
key
- key to remove
CacheLoaderException
- in the event of problems writing to the storepublic InternalCacheEntry load(Object key) throws CacheLoaderException
StoredMap.get(Object)
. If the object is expired, it will
not be returned.
key
- key
CacheLoaderException
- in the event of problems reading from sourcepublic void store(InternalCacheEntry ed) throws CacheLoaderException
StoredMap.put(Object, Object)
ed
- entry to store
CacheLoaderException
- in the event of problems writing to the storepublic void clear() throws CacheLoaderException
StoredContainer.clear()
CacheLoaderException
- in the event of problems writing to the storepublic Set<InternalCacheEntry> loadAll() throws CacheLoaderException
StoredMap.values()
CacheLoaderException
- in the event of problems reading from sourcepublic void fromStream(ObjectInput ois) throws CacheLoaderException
CacheStore.toStream(java.io.ObjectOutput)
. While not a
requirement, it is recommended that implementations make use of the Marshaller
when dealing with the stream to make use of efficient marshalling.
It is imperative that implementations do not close the stream after finishing with it.
It is also recommended that implementations use their own start and end markers on the stream since
other processes may write additional data to the stream after the cache store has written to it. As such, either
markers or some other mechanism to prevent the store from reading too much information should be employed when
writing to the stream in CacheStore.fromStream(java.io.ObjectInput)
to prevent data corruption.
It can be assumed that the stream passed in already performs buffering such that the cache store implementation
doesn't have to.
This implementation reads the number of entries to load from the stream, then begins a transaction.
During that transaction, the cachestore is cleared and replaced with entries from the stream. If there are any
errors during the process, the entire transaction is rolled back. Deadlock handling is not addressed, as there is
no means to rollback reads from the input stream.
ois
- stream to read from
CacheLoaderException
- in the event of problems writing to the storetoStream(java.io.ObjectOutput)
public void toStream(ObjectOutput oos) throws CacheLoaderException
key
value
.
This implementation holds a transaction open to ensure that we see no new records added while iterating.
oos
- stream to write to
CacheLoaderException
- in the event of problems reading from the storeprotected void purgeInternal() throws CacheLoaderException
StoredMap.entrySet()
and remove, if expired.
purgeInternal
in class AbstractCacheStore
CacheLoaderException
public void printLicense()
|
Google Analytics | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |