Top Description Fields Constructors Methods
net.sf.ehcache.transaction.local

public Class LocalTransactionStore

extends AbstractTransactionStore
Class Inheritance
Imports
net.sf.ehcache.CacheEntry, .CacheException, .Ehcache, .Element, .TransactionController, net.sf.ehcache.store.ElementValueComparator, .Store, net.sf.ehcache.transaction.AbstractTransactionStore, .DeadLockException, .SoftLock, .SoftLockID, .SoftLockManager, .TransactionException, .TransactionID, .TransactionIDFactory, .TransactionInterruptedException, .TransactionTimeoutException, net.sf.ehcache.util.LargeSet, .SetAsList, net.sf.ehcache.writer.CacheWriterManager, org.slf4j.Logger, .LoggerFactory, java.util.HashSet, .Iterator, .List, .Set

A Store implementation with support for local transactions
Author
Ludovic Orban

Field Summary

Modifier and TypeField and Description
private final Ehcache
private final String
private final ElementValueComparator
private static final Logger
private final SoftLockManager
private final TransactionController
private final TransactionIDFactory
Inherited from net.sf.ehcache.transaction.AbstractTransactionStore:
underlyingStore

Constructor Summary

AccessConstructor and Description
public
LocalTransactionStore(TransactionController
the TransactionController
transactionController
,
TransactionIDFactory transactionIdFactory, SoftLockManager
the SoftLockManager
softLockManager
,
Ehcache
the cache
cache
,
Store
the underlying store
store
,
ElementValueComparator
the element value comparator
comparator
)

Create a new LocalTransactionStore instance

Method Summary

Modifier and TypeMethod and Description
private void
private boolean
cleanupExpiredSoftLock(Element oldElement, SoftLockID softLockId)

pack-priv void
commit(List<SoftLock>
the soft locks to commit
softLocks
,
TransactionID
the transaction ID to commit
transactionId
)

Commit work of the specified soft locks

public boolean
containsKey(Object
The Element key
key
)

Implements net.sf.ehcache.store.Store.containsKey.

A check to see if a key is in the Store.
private Element
createElement(Object key, SoftLockID softLockId)

public void
public Element
get(Object key)

Implements net.sf.ehcache.store.Store.get.

Gets an item from the cache.
pack-priv Ehcache

Returns:

the cache using this store
getCache
()

Get the cache using this store

private LocalTransactionContext
public List<E>
getKeys()

Implements net.sf.ehcache.store.Store.getKeys.

Gets an Array of the keys for all elements in the disk store.
public Element
getQuiet(Object key)

Implements net.sf.ehcache.store.Store.getQuiet.

Gets an Element from the Store, without updating statistics
public int
getSize()

Implements net.sf.ehcache.store.Store.getSize.

Returns the current local store size
public int
getTerracottaClusteredSize()

Implements net.sf.ehcache.store.Store.getTerracottaClusteredSize.

Returns the current Terracotta clustered store size
public boolean
put(Element element)

Implements net.sf.ehcache.store.Store.put.

Puts an item into the store.
public Element
putIfAbsent(Element
element to be added
element
)

Implements net.sf.ehcache.store.Store.putIfAbsent.

Put an element in the store if no element is currently mapped to the elements key.
public boolean
putWithWriter(final Element element, final CacheWriterManager writerManager)

Implements net.sf.ehcache.store.Store.putWithWriter.

Puts an item into the store and the cache writer manager in an atomic operation
public Set<TransactionID>

Returns:

a set of transaction IDs that were recovered
recover
()

Recover and resolve all known soft locks

public Element
remove(Object key)

Implements net.sf.ehcache.store.Store.remove.

Removes an item from the cache.
public void
removeAll()

Implements net.sf.ehcache.store.Store.removeAll.

Remove all of the elements from the store.
public Element
removeElement(Element
Element to be removed
element
,
ElementValueComparator
ElementValueComparator to use to compare elements
comparator
)

Implements net.sf.ehcache.store.Store.removeElement.

Remove the Element mapped to the key for the supplied element if the value of the supplied Element is equal to the value of the cached Element.
public Element
removeWithWriter(final Object key, final CacheWriterManager writerManager)

Implements net.sf.ehcache.store.Store.removeWithWriter.

Removes an item from the store and the cache writer manager in an atomic operation.
public boolean
replace(Element
Element to be test against
old
,
Element
Element to be cached
element
,
ElementValueComparator
ElementValueComparator to use to compare elements
comparator
)

Implements net.sf.ehcache.store.Store.replace.

Replace the cached element only if the value of the current Element is equal to the value of the supplied old Element.
public Element
replace(Element
Element to be cached
element
)

Implements net.sf.ehcache.store.Store.replace.

Replace the cached element only if an Element is currently cached for this key
pack-priv void
rollback(List<SoftLock>
the soft locks to rollback
softLocks
,
TransactionID
the transaction ID to rollback
transactionId
)

Rollback work of the specified soft locks

private long
Inherited from net.sf.ehcache.transaction.AbstractTransactionStore:
bufferFullcontainsKeyInMemorycontainsKeyOffHeapcontainsKeyOnDiskcreateWriteBehindexecuteQueryexpireElementsflushgetInMemoryEvictionPolicygetInMemorySizegetInMemorySizeInBytesgetInternalContextgetLocalKeysgetMBeangetOffHeapSizegetOffHeapSizeInBytesgetOldElementgetOnDiskSizegetOnDiskSizeInBytesgetSearchAttributegetSearchAttributesgetStatusgetTransactionalModehasAbortedSizeOfisCacheCoherentisClusterCoherentisNodeCoherentnotifyCacheEventListenersChangedquickClearquickSizesetAttributeExtractorssetInMemoryEvictionPolicysetNodeCoherentunsafeGetwaitUntilClusterCoherent

Field Detail

cacheback to summary
private final Ehcache cache
cacheNameback to summary
private final String cacheName

Hides net.sf.ehcache.store.AbstractStore.cacheName.

comparatorback to summary
private final ElementValueComparator comparator
LOGback to summary
private static final Logger LOG
softLockManagerback to summary
private final SoftLockManager softLockManager
transactionControllerback to summary
private final TransactionController transactionController
transactionIdFactoryback to summary
private final TransactionIDFactory transactionIdFactory

Constructor Detail

LocalTransactionStoreback to summary
public LocalTransactionStore(TransactionController transactionController, TransactionIDFactory transactionIdFactory, SoftLockManager softLockManager, Ehcache cache, Store store, ElementValueComparator comparator)

Create a new LocalTransactionStore instance

Parameters
transactionController:TransactionController

the TransactionController

softLockManager:SoftLockManager

the SoftLockManager

cache:Ehcache

the cache

store:Store

the underlying store

comparator:ElementValueComparator

the element value comparator

Method Detail

assertNotTimedOutback to summary
private void assertNotTimedOut()
cleanupExpiredSoftLockback to summary
private boolean cleanupExpiredSoftLock(Element oldElement, SoftLockID softLockId)
commitback to summary
pack-priv void commit(List<SoftLock> softLocks, TransactionID transactionId)

Commit work of the specified soft locks

Parameters
softLocks:List<SoftLock>

the soft locks to commit

transactionId:TransactionID

the transaction ID to commit

containsKeyback to summary
public boolean containsKey(Object key)

Implements net.sf.ehcache.store.Store.containsKey.

Doc from net.sf.ehcache.store.Store.containsKey.

A check to see if a key is in the Store.

Parameters
key:Object

The Element key

Returns:boolean

true if found. No check is made to see if the Element is expired. 1.2

createElementback to summary
private Element createElement(Object key, SoftLockID softLockId)
disposeback to summary
public void dispose()

Overrides net.sf.ehcache.transaction.AbstractTransactionStore.dispose.

Implements net.sf.ehcache.store.Store.dispose.

Doc from net.sf.ehcache.transaction.AbstractTransactionStore.dispose.

Prepares for shutdown.

Annotations
@Override
getback to summary
public Element get(Object key)

Implements net.sf.ehcache.store.Store.get.

Doc from net.sf.ehcache.store.Store.get.

Gets an item from the cache.

getCacheback to summary
pack-priv Ehcache getCache()

Get the cache using this store

Returns:Ehcache

the cache using this store

getCurrentTransactionContextback to summary
private LocalTransactionContext getCurrentTransactionContext()
getKeysback to summary
public List<E> getKeys()

Implements net.sf.ehcache.store.Store.getKeys.

Doc from net.sf.ehcache.store.Store.getKeys.

Gets an Array of the keys for all elements in the disk store.

Returns:List<E>

An List of java.io.Serializable keys

getQuietback to summary
public Element getQuiet(Object key)

Implements net.sf.ehcache.store.Store.getQuiet.

Doc from net.sf.ehcache.store.Store.getQuiet.

Gets an Element from the Store, without updating statistics

Returns:Element

The element

getSizeback to summary
public int getSize()

Implements net.sf.ehcache.store.Store.getSize.

Doc from net.sf.ehcache.store.Store.getSize.

Returns the current local store size

Returns:int

the count of the Elements in the Store on the local machine

getTerracottaClusteredSizeback to summary
public int getTerracottaClusteredSize()

Implements net.sf.ehcache.store.Store.getTerracottaClusteredSize.

Doc from net.sf.ehcache.store.Store.getTerracottaClusteredSize.

Returns the current Terracotta clustered store size

Returns:int

the count of the Elements in the Store across the cluster

putback to summary
public boolean put(Element element) throws CacheException

Implements net.sf.ehcache.store.Store.put.

Doc from net.sf.ehcache.store.Store.put.

Puts an item into the store.

Returns:boolean

true if this is a new put for the key or element is null. Returns false if it was an update.

putIfAbsentback to summary
public Element putIfAbsent(Element element) throws NullPointerException

Implements net.sf.ehcache.store.Store.putIfAbsent.

Doc from net.sf.ehcache.store.Store.putIfAbsent.

Put an element in the store if no element is currently mapped to the elements key.

Parameters
element:Element

element to be added

Returns:Element

the element previously cached for this key, or null if none.

Exceptions
NullPointerException:
if the element is null, or has a null key
putWithWriterback to summary
public boolean putWithWriter(final Element element, final CacheWriterManager writerManager) throws CacheException

Implements net.sf.ehcache.store.Store.putWithWriter.

Doc from net.sf.ehcache.store.Store.putWithWriter.

Puts an item into the store and the cache writer manager in an atomic operation

Returns:boolean

true if this is a new put for the key or element is null. Returns false if it was an update.

recoverback to summary
public Set<TransactionID> recover()

Recover and resolve all known soft locks

Returns:Set<TransactionID>

a set of transaction IDs that were recovered

removeback to summary
public Element remove(Object key)

Implements net.sf.ehcache.store.Store.remove.

Doc from net.sf.ehcache.store.Store.remove.

Removes an item from the cache.

removeAllback to summary
public void removeAll() throws CacheException

Implements net.sf.ehcache.store.Store.removeAll.

Doc from net.sf.ehcache.store.Store.removeAll.

Remove all of the elements from the store.

If there are registered CacheEventListeners they are notified of the expiry or removal of the Element as each is removed.

removeElementback to summary
public Element removeElement(Element element, ElementValueComparator comparator) throws NullPointerException

Implements net.sf.ehcache.store.Store.removeElement.

Doc from net.sf.ehcache.store.Store.removeElement.

Remove the Element mapped to the key for the supplied element if the value of the supplied Element is equal to the value of the cached Element. This is a CAS operation. It is consistent even against a distributed cache that is not coherent. If the old value is stale when this operation is attempted the remove does not take place.

Parameters
element:Element

Element to be removed

comparator:ElementValueComparator

ElementValueComparator to use to compare elements

Returns:Element

the Element removed or null if no Element was removed

Exceptions
NullPointerException:
if the element is null, or has a null key
removeWithWriterback to summary
public Element removeWithWriter(final Object key, final CacheWriterManager writerManager) throws CacheException

Implements net.sf.ehcache.store.Store.removeWithWriter.

Doc from net.sf.ehcache.store.Store.removeWithWriter.

Removes an item from the store and the cache writer manager in an atomic operation.

replaceback to summary
public boolean replace(Element old, Element element, ElementValueComparator comparator) throws NullPointerException, IllegalArgumentException

Implements net.sf.ehcache.store.Store.replace.

Doc from net.sf.ehcache.store.Store.replace.

Replace the cached element only if the value of the current Element is equal to the value of the supplied old Element.

Parameters
old:Element

Element to be test against

element:Element

Element to be cached

comparator:ElementValueComparator

ElementValueComparator to use to compare elements

Returns:boolean

true is the Element was replaced

Exceptions
NullPointerException:
if the either Element is null or has a null key
IllegalArgumentException:
if the two Element keys are non-null but not equal
replaceback to summary
public Element replace(Element element) throws NullPointerException

Implements net.sf.ehcache.store.Store.replace.

Doc from net.sf.ehcache.store.Store.replace.

Replace the cached element only if an Element is currently cached for this key

Parameters
element:Element

Element to be cached

Returns:Element

the Element previously cached for this key, or null if no Element was cached

Exceptions
NullPointerException:
if the Element is null or has a null key
rollbackback to summary
pack-priv void rollback(List<SoftLock> softLocks, TransactionID transactionId)

Rollback work of the specified soft locks

Parameters
softLocks:List<SoftLock>

the soft locks to rollback

transactionId:TransactionID

the transaction ID to rollback

timeBeforeTimeoutback to summary
private long timeBeforeTimeout()