Class PlatformDotNetCacheStore<K,V>
- java.lang.Object
-
- org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetCacheStore<K,V>
-
- All Implemented Interfaces:
javax.cache.integration.CacheLoader<K,V>,javax.cache.integration.CacheWriter<K,V>,CacheStore<K,V>,PlatformCacheStore,LifecycleAware
public class PlatformDotNetCacheStore<K,V> extends Object implements CacheStore<K,V>, PlatformCacheStore, LifecycleAware
Wrapper for .NET cache store implementations.This wrapper should be used if you have an implementation of
GridGain.Cache.IGridCacheStoreinterface in .NET and would like to configure it a persistence storage for your cache. If properly configured, this wrapper will instantiate an instance of your cache store in .NET and delegate all calls to that instance. To create an instance, assembly name and class name are passed to System.Activator.CreateInstance(String, String) method in .NET during node startup. Refer to its documentation for details.
-
-
Field Summary
Fields Modifier and Type Field Description protected PlatformContextplatformCtxInterop processor.protected longptrPointer to native store.
-
Constructor Summary
Constructors Constructor Description PlatformDotNetCacheStore()Default ctor.PlatformDotNetCacheStore(Object nativeFactory)Native factory ctor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete(Object key)voiddeleteAll(Collection<?> keys)protected intdoInvoke(IgniteInClosure<BinaryRawWriterEx> task, IgniteInClosure<BinaryRawReaderEx> readClo)Perform actual invoke.Map<String,?>getProperties()Get properties.StringgetTypeName()Gets .NET class name.voidinitialize(GridKernalContext ctx, boolean convertBinary)Initialize the store.Vload(K key)Map<K,V>loadAll(Iterable<? extends K> keys)voidloadCache(IgniteBiInClosure<K,V> clo, @Nullable Object... args)Loads all values from underlying persistent storage.voidsessionEnd(boolean commit)Tells store to commit or rollback a transaction depending on the value of the'commit'parameter.voidsetProperties(Map<String,?> props)Set properties.voidsetTypeName(String typName)Sets .NET class name.voidstart()Starts grid component, called on grid start.voidstop()Stops grid component, called on grid shutdown.StringtoString()voidwrite(javax.cache.Cache.Entry<? extends K,? extends V> entry)protected voidwrite(BinaryRawWriterEx writer, boolean convertBinary)Write store data to a stream.voidwriteAll(Collection<javax.cache.Cache.Entry<? extends K,? extends V>> entries)
-
-
-
Field Detail
-
platformCtx
@GridToStringExclude protected PlatformContext platformCtx
Interop processor.
-
ptr
@GridToStringExclude protected long ptr
Pointer to native store.
-
-
Constructor Detail
-
PlatformDotNetCacheStore
public PlatformDotNetCacheStore()
Default ctor.
-
PlatformDotNetCacheStore
public PlatformDotNetCacheStore(Object nativeFactory)
Native factory ctor.
-
-
Method Detail
-
getTypeName
public String getTypeName()
Gets .NET class name.- Returns:
- .NET class name.
-
setTypeName
public void setTypeName(String typName)
Sets .NET class name.- Parameters:
typName- .NET class name.
-
setProperties
public void setProperties(Map<String,?> props)
Set properties.- Parameters:
props- Properties.
-
loadCache
public void loadCache(IgniteBiInClosure<K,V> clo, @Nullable @Nullable 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 wheneverIgniteCache.loadCache(IgniteBiPredicate, Object...)method is invoked which is usually to preload the cache from persistent storage.This method is optional, and cache implementation does not depend on this method to do anything. Default implementation of this method in
CacheStoreAdapterdoes nothing.For every loaded value method
IgniteBiInClosure.apply(Object, Object)should be called on the passed in closure. The closure will then make sure that the loaded value is stored in cache.- Specified by:
loadCachein interfaceCacheStore<K,V>- Parameters:
clo- Closure for loaded values.args- Arguments passes intoIgniteCache.loadCache(IgniteBiPredicate, Object...)method.
-
writeAll
public void writeAll(Collection<javax.cache.Cache.Entry<? extends K,? extends V>> entries)
-
delete
public void delete(Object key)
-
deleteAll
public void deleteAll(Collection<?> keys)
-
sessionEnd
public void sessionEnd(boolean commit)
Tells store to commit or rollback a transaction depending on the value of the'commit'parameter.- Specified by:
sessionEndin interfaceCacheStore<K,V>- Parameters:
commit-Trueif transaction should commit,falsefor rollback.
-
start
public void start() throws IgniteExceptionStarts grid component, called on grid start.- Specified by:
startin interfaceLifecycleAware- Throws:
IgniteException- If failed.
-
stop
public void stop() throws IgniteExceptionStops grid component, called on grid shutdown.- Specified by:
stopin interfaceLifecycleAware- Throws:
IgniteException- If failed.
-
initialize
public void initialize(GridKernalContext ctx, boolean convertBinary) throws IgniteCheckedException
Initialize the store.- Parameters:
ctx- Context.convertBinary- Convert binary flag.- Throws:
IgniteCheckedException
-
write
protected void write(BinaryRawWriterEx writer, boolean convertBinary)
Write store data to a stream.- Parameters:
writer- Writer.convertBinary- Convert binary flag.
-
doInvoke
protected int doInvoke(IgniteInClosure<BinaryRawWriterEx> task, IgniteInClosure<BinaryRawReaderEx> readClo) throws IgniteCheckedException
Perform actual invoke.- Parameters:
task- Task.readClo- Reader.- Returns:
- Result.
- Throws:
IgniteCheckedException- If failed.
-
-