org.apache.ignite.internal.processors.platform.dotnet

## 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.IGridCacheStore` interface 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
`protected PlatformContext` `platformCtx` Interop processor.
`protected long` `ptr` Pointer to native store.

### Constructor Summary

Constructors
Constructor and Description
`PlatformDotNetCacheStore()` Default ctor.
`PlatformDotNetCacheStore(Object nativeFactory)` Native factory ctor.

### Method Summary

Methods
`void` `delete(Object key)`
`void` `deleteAll(Collection<?> keys)`
`protected int` `doInvoke(IgniteInClosure<BinaryRawWriterEx> task, IgniteInClosure<BinaryRawReaderEx> readClo)` Perform actual invoke.
`Map<String,?>` `getProperties()` Get properties.
`String` `getTypeName()` Gets .NET class name.
`void` `initialize(GridKernalContext ctx, boolean convertBinary)` Initialize the store.
`V` `load(K key)`
`Map<K,V>` `loadAll(Iterable<? extends K> keys)`
`void` `loadCache(IgniteBiInClosure<K,V> clo, Object... args)` Loads all values from underlying persistent storage.
`void` `sessionEnd(boolean commit)` Tells store to commit or rollback a transaction depending on the value of the `'commit'` parameter.
`void` `setProperties(Map<String,?> props)` Set properties.
`void` `setTypeName(String typName)` Sets .NET class name.
`void` `start()` Starts grid component, called on grid start.
`void` `stop()` Stops grid component, called on grid shutdown.
`protected void` `write(BinaryRawWriterEx writer, boolean convertBinary)` Write store data to a stream.
`void` `write(javax.cache.Cache.Entry<? extends K,? extends V> entry)`
`void` `writeAll(Collection<javax.cache.Cache.Entry<? extends K,? extends V>> entries)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### platformCtx

    protected PlatformContext platformCtx

Interop processor.

#### ptr

    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.

#### getProperties

    public Map<String,?> getProperties()

Get properties.

Returns:
  Properties.

#### setProperties

    public void setProperties(Map<String,?> props)

Set properties.

Parameters:
  `props` - Properties.

#### load

    @Nullable
    public V load(K key)

Specified by:
  `load` in interface `javax.cache.integration.CacheLoader<K,V>`

#### loadAll

    public Map<K,V> loadAll(Iterable<? extends K> keys)

Specified by:
  `loadAll` in interface `javax.cache.integration.CacheLoader<K,V>`

#### loadCache

    public void loadCache(IgniteBiInClosure<K,V> clo,
                 @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 whenever `IgniteCache.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 `CacheStoreAdapter` does 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:
  `loadCache` in interface `CacheStore<K,V>`
Parameters:
  `clo` - Closure for loaded values.
  `args` - Arguments passes into `IgniteCache.loadCache(IgniteBiPredicate, Object...)` method.

#### write

    public void write(javax.cache.Cache.Entry<? extends K,? extends V> entry)

Specified by:
  `write` in interface `javax.cache.integration.CacheWriter<K,V>`

#### writeAll

    public void writeAll(Collection<javax.cache.Cache.Entry<? extends K,? extends V>> entries)

Specified by:
  `writeAll` in interface `javax.cache.integration.CacheWriter<K,V>`

#### delete

    public void delete(Object key)

Specified by:
  `delete` in interface `javax.cache.integration.CacheWriter<K,V>`

#### deleteAll

    public void deleteAll(Collection<?> keys)

Specified by:
  `deleteAll` in interface `javax.cache.integration.CacheWriter<K,V>`

#### sessionEnd

    public void sessionEnd(boolean commit)

Tells store to commit or rollback a transaction depending on the value of the `'commit'` parameter.

Specified by:
  `sessionEnd` in interface `CacheStore<K,V>`
Parameters:
  `commit` - `True` if transaction should commit, `false` for rollback.

#### start

    public void start()
               throws IgniteException

Starts grid component, called on grid start.

Specified by:
  `start` in interface `LifecycleAware`
Throws:
  `IgniteException` - If failed.

#### stop

    public void stop()
              throws IgniteException

Stops grid component, called on grid shutdown.

Specified by:
  `stop` in interface `LifecycleAware`
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.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.8.0
Release Date | : December 5 2016