Public Member Functions | Static Public Attributes | Protected Member Functions | Properties | List of all members
GridGain.Cache.Store.CacheParallelLoadStoreAdapter Class Referenceabstract

Cache storage adapter with parallel loading in LoadAll method. More...

Inherits GridGain.Cache.Store.ICacheStore.

Public Member Functions

virtual void LoadCache (Action< object, object > act, params object[] args)
 Loads all values from underlying persistent storage. Note that keys are not passed, so it is up to implementation to figure out what to load. This method is called whenever ICache<K,V>.LocalLoadCache method is invoked which is usually to preload the cache from persistent storage. More...
 
virtual object Load (object key)
 Loads an object. Application developers should implement this method to customize the loading of a value for a cache entry. This method is called by a cache when a requested entry is not in the cache. If the object can't be loaded More...
 
virtual IDictionary LoadAll (ICollection keys)
 Loads multiple objects. Application developers should implement this method to customize the loading of cache entries. This method is called when the requested object is not in the cache. If an object can't be loaded, it is not returned in the resulting map. More...
 
virtual void Write (object key, object val)
 Write the specified value under the specified key to the external resource. More...
 
virtual void WriteAll (IDictionary entries)
 Write the specified entries to the external resource. This method is intended to support both insert and update. More...
 
virtual void Delete (object key)
 Delete the cache entry from the external resource. More...
 
virtual void DeleteAll (ICollection keys)
 Remove data and keys from the external resource for the given collection of keys, if present. More...
 
virtual void SessionEnd (bool commit)
 Tells store to commit or rollback a transaction depending on the value of the commit parameter. More...
 

Static Public Attributes

static readonly int DFLT_THREADS_CNT = Environment.ProcessorCount
 Default number of working threads (equal to the number of available processors). More...
 

Protected Member Functions

 CacheParallelLoadStoreAdapter ()
 Constructor. More...
 
abstract IEnumerable GetInputData ()
 Gets the input data sequence to be used in LoadCache. More...
 
abstract KeyValuePair< object, object > Parse (object inputRecord, params object[] args)
 This method should transform raw data records from GetInputData into valid key-value pairs to be stored into cache. More...
 

Properties

int MaxDegreeOfParallelism [get, set]
 Gets or sets the maximum degree of parallelism to use in LoadCache. Must be either positive or -1 for unlimited amount of threads. More...
 

Detailed Description

LoadCache calls GetInputData() and iterates over it in parallel. GetInputData().GetEnumerator() result will be disposed if it implements IDisposable. Any additional post-LoadCache steps can be performed by overriding LoadCache method.

Constructor & Destructor Documentation

GridGain.Cache.Store.CacheParallelLoadStoreAdapter.CacheParallelLoadStoreAdapter ( )
protected

Member Function Documentation

virtual void GridGain.Cache.Store.CacheParallelLoadStoreAdapter.Delete ( object  key)
virtual

Expiry of a cache entry is not a delete hence will not cause this method to be invoked.

This method is invoked even if no mapping for the key exists.

Parameters
keyThe key that is used for the delete operation.

Implements GridGain.Cache.Store.ICacheStore.

virtual void GridGain.Cache.Store.CacheParallelLoadStoreAdapter.DeleteAll ( ICollection  keys)
virtual

The order that individual deletes occur is undefined.

If this operation fails (by throwing an exception) after a partial success, the writer must remove any successfully written entries from the entries collection so that the caching implementation knows what succeeded and can mutate the cache.

Expiry of a cache entry is not a delete hence will not cause this method to be invoked.

This method may include keys even if there is no mapping for that key, in which case the data represented by that key should be removed from the underlying resource.

Parameters
keysa mutable collection of keys for entries to delete. Upon invocation, it contains the keys to delete for write-through. Upon return the collection must only contain the keys that were not successfully deleted.

Implements GridGain.Cache.Store.ICacheStore.

abstract IEnumerable GridGain.Cache.Store.CacheParallelLoadStoreAdapter.GetInputData ( )
protectedpure virtual
virtual object GridGain.Cache.Store.CacheParallelLoadStoreAdapter.Load ( object  key)
virtual

null should be returned.

Parameters
keyThe key identifying the object being loaded.
Returns
The value for the entry that is to be stored in the cache or
null
if the object can't be loaded

Implements GridGain.Cache.Store.ICacheStore.

virtual IDictionary GridGain.Cache.Store.CacheParallelLoadStoreAdapter.LoadAll ( ICollection  keys)
virtual
Parameters
keysKeys identifying the values to be loaded.
Returns
A map of key, values to be stored in the cache.

Implements GridGain.Cache.Store.ICacheStore.

virtual void GridGain.Cache.Store.CacheParallelLoadStoreAdapter.LoadCache ( Action< object, object >  act,
params object[]  args 
)
virtual

This method is optional, and cache implementation does not depend on this method to do anything.

For every loaded value method provided action should be called. The action will then make sure that the loaded value is stored in cache.

Parameters
actAction for loaded values.
argsOptional arguemnts passed to ICache<K,V>.LocalLoadCache method.
Exceptions
CacheStoreException

Implements GridGain.Cache.Store.ICacheStore.

abstract KeyValuePair<object, object> GridGain.Cache.Store.CacheParallelLoadStoreAdapter.Parse ( object  inputRecord,
params object[]  args 
)
protectedpure virtual
virtual void GridGain.Cache.Store.CacheParallelLoadStoreAdapter.SessionEnd ( bool  commit)
virtual
Parameters
commitTrue if transaction should commit, false for rollback.

Implements GridGain.Cache.Store.ICacheStore.

virtual void GridGain.Cache.Store.CacheParallelLoadStoreAdapter.Write ( object  key,
object  val 
)
virtual

This method is intended to support both key/value creation and value update.

Parameters
keyKey to write.
valValue to write.

Implements GridGain.Cache.Store.ICacheStore.

virtual void GridGain.Cache.Store.CacheParallelLoadStoreAdapter.WriteAll ( IDictionary  entries)
virtual

The order that individual writes occur is undefined.

If this operation fails (by throwing an exception) after a partial success, the writer must remove any successfully written entries from the entries collection so that the caching implementation knows what succeeded and can mutate the cache.

Parameters
entriesa mutable collection to write. Upon invocation, it contains the entries to write for write-through. Upon return the collection must only contain entries that were not successfully written. (see partial success above).

Implements GridGain.Cache.Store.ICacheStore.

Member Data Documentation

readonly int GridGain.Cache.Store.CacheParallelLoadStoreAdapter.DFLT_THREADS_CNT = Environment.ProcessorCount
static

Property Documentation

int GridGain.Cache.Store.CacheParallelLoadStoreAdapter.MaxDegreeOfParallelism
getset

Defaults to DFLT_THREADS_CNT.