org.apache.ignite.internal.processors.cache

## Class GridCacheProcessor

- java.lang.Object
- - org.apache.ignite.internal.processors.GridProcessorAdapter
  - - org.apache.ignite.internal.processors.cache.GridCacheProcessor

All Implemented Interfaces:
  GridComponent, GridProcessor

    public class GridCacheProcessor
    extends GridProcessorAdapter

Cache processor.

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent

`GridComponent.DiscoveryDataExchangeType`

### Field Summary

### Fields inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`ctx, log`

### Constructor Summary

Constructors
Constructor and Description
`GridCacheProcessor(GridKernalContext ctx)`

### Method Summary

Methods
`void` `addCacheConfiguration(CacheConfiguration cacheCfg)`
`<K,V> IgniteInternalCache<K,V>` `atomicsCache()` Gets utility cache for atomic data structures.
`void` `awaitStarted()`
`void` `blockGateway(DynamicCacheChangeRequest req)`
`void` `blockGateways()` Blocks all available gateways
`<K,V> IgniteInternalCache<K,V>` `cache()`
`<K,V> IgniteInternalCache<K,V>` `cache(String name)`
`CacheConfiguration` `cacheConfiguration(String name)` Get configuration for the given cache.
`CacheMode` `cacheMode(String cacheName)` Gets cache mode.
`Collection<String>` `cacheNames()` Gets a collection of currently started caches.
`Collection<IgniteInternalCache<?,?>>` `caches()`
`void` `cancelUserOperations()` Cancel all user operations.
`Serializable` `collectDiscoveryData(UUID nodeId)` Gets discovery data object that will be sent to new node during discovery process.
`void` `completeStartFuture(DynamicCacheChangeRequest req)`
`<K,V> GridCacheSharedContext<K,V>` `context()`
`IgniteInternalFuture<?>` `createFromTemplate(String cacheName)` Dynamically starts cache using template configuration.
`GridComponent.DiscoveryDataExchangeType` `discoveryDataType()` Gets unique component type to distinguish components providing discovery data.
`boolean` `dynamicCacheRegistered(DynamicCacheChangeRequest req)`
`IgniteInternalFuture<?>` `dynamicStartCache(CacheConfiguration ccfg, String cacheName, NearCacheConfiguration nearCfg, boolean failIfExists)` Dynamically starts cache.
`IgniteInternalFuture<?>` `dynamicStartCache(CacheConfiguration ccfg, String cacheName, NearCacheConfiguration nearCfg, CacheType cacheType, boolean failIfExists)` Dynamically starts cache.
`IgniteInternalFuture<?>` `dynamicStopCache(String cacheName)`
`IgniteInternalFuture<?>` `getOrCreateFromTemplate(String cacheName)` Dynamically starts cache using template configuration.
`<K,V> IgniteInternalCache<K,V>` `getOrStartCache(String name)`
`Collection<org.apache.ignite.internal.processors.cache.GridCacheProcessor.DynamicCacheStartFuture>` `initiateCacheChanges(Collection<DynamicCacheChangeRequest> reqs)`
`<K,V> GridCacheAdapter<K,V>` `internalCache()`
`<K,V> GridCacheAdapter<K,V>` `internalCache(String name)`
`Collection<GridCacheAdapter<?,?>>` `internalCaches()`
`<K,V> IgniteCacheProxy<K,V>` `jcache(String name)`
`Collection<IgniteCacheProxy<?,?>>` `jcaches()`
`long` `lastDataVersion()`
`GridCacheAdapter<Integer,String>` `marshallerCache()`
`void` `onDiscoveryDataReceived(UUID joiningNodeId, UUID rmtNodeId, Serializable data)` Receives discovery data object from remote nodes (called on new node during discovery process).
`void` `onEvictFromSwap(String spaceName, byte[] keyBytes, byte[] valBytes)`
`void` `onExchangeDone(AffinityTopologyVersion topVer, Collection<DynamicCacheChangeRequest> reqs, Throwable err)` Callback invoked when first exchange future for dynamic cache is completed.
`void` `onKernalStart()` Callback that notifies that kernal has successfully started, including all managers and processors.
`void` `onKernalStop(boolean cancel)` Callback to notify that kernal is about to stop.
`void` `onUndeployed(ClassLoader ldr)` Callback invoked by deployment manager for whenever a class loader gets undeployed.
`IgniteInternalFuture<?>` `orderedPreloadFuture(int order)` Gets preload finish future for preload-ordered cache with given order.
`void` `prepareCachesStart(Collection<DynamicCacheChangeRequest> reqs, AffinityTopologyVersion topVer)`
`void` `prepareCacheStop(DynamicCacheChangeRequest req)`
`void` `printMemoryStats()` Prints memory statistics (sizes of internal structures, etc.).
`<K,V> IgniteInternalCache<K,V>` `publicCache(String name)`
`Collection<IgniteCacheProxy<?,?>>` `publicCaches()`
`<K,V> IgniteCache<K,V>` `publicJCache(String cacheName)`
`<K,V> IgniteCache<K,V>` `publicJCache(String cacheName, boolean failIfNotStarted)`
`void` `start()` Starts grid component.
`void` `stop(boolean cancel)` Stops grid component.
`boolean` `systemCache(String name)`
`IgniteTransactionsEx` `transactions()`
`<K,V> GridCacheAdapter<K,V>` `utilityCache()` Gets utility cache.
`IgniteNodeValidationResult` `validateNode(ClusterNode node)` Validates that new node can join grid topology, this method is called on coordinator node before new node joins topology.

### Methods inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`assertParameter, toString`

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

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

### Constructor Detail

#### GridCacheProcessor

    public GridCacheProcessor(GridKernalContext ctx)

Parameters:
  `ctx` - Kernal context.

### Method Detail

#### start

    public void start()
               throws IgniteCheckedException

Starts grid component.

Specified by:
  `start` in interface `GridComponent`
Overrides:
  `start` in class `GridProcessorAdapter`
Throws:
  `IgniteCheckedException` - Throws in case of any errors.

#### onKernalStart

    public void onKernalStart()
                       throws IgniteCheckedException

Callback that notifies that kernal has successfully started, including all managers and processors.

Specified by:
  `onKernalStart` in interface `GridComponent`
Overrides:
  `onKernalStart` in class `GridProcessorAdapter`
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### stop

    public void stop(boolean cancel)
              throws IgniteCheckedException

Stops grid component.

Specified by:
  `stop` in interface `GridComponent`
Overrides:
  `stop` in class `GridProcessorAdapter`
Parameters:
  `cancel` - If `true`, then all ongoing tasks or jobs for relevant components need to be cancelled.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### blockGateways

    public void blockGateways()

Blocks all available gateways

#### onKernalStop

    public void onKernalStop(boolean cancel)

Callback to notify that kernal is about to stop.

Specified by:
  `onKernalStop` in interface `GridComponent`
Overrides:
  `onKernalStop` in class `GridProcessorAdapter`
Parameters:
  `cancel` - Flag indicating whether jobs should be canceled.

#### awaitStarted

    public void awaitStarted()
                      throws IgniteCheckedException

Throws:
  `IgniteCheckedException` - If failed to wait.

#### cacheNames

    public Collection<String> cacheNames()

Gets a collection of currently started caches.

Returns:
  Collection of started cache names.

#### cacheMode

    public CacheMode cacheMode(String cacheName)

Gets cache mode.

Parameters:
  `cacheName` - Cache name to check.
Returns:
  Cache mode.

#### dynamicCacheRegistered

    public boolean dynamicCacheRegistered(DynamicCacheChangeRequest req)

Parameters:
  `req` - Request to check.
Returns:
  `True` if change request was registered to apply.

#### prepareCachesStart

    public void prepareCachesStart(Collection<DynamicCacheChangeRequest> reqs,
                          AffinityTopologyVersion topVer)
                            throws IgniteCheckedException

Parameters:
  `reqs` - Requests to start.
  `topVer` - Topology version.
Throws:
  `IgniteCheckedException` - If failed to start cache.

#### blockGateway

    public void blockGateway(DynamicCacheChangeRequest req)

Parameters:
  `req` - Stop request.

#### prepareCacheStop

    public void prepareCacheStop(DynamicCacheChangeRequest req)

Parameters:
  `req` - Stop request.

#### onExchangeDone

    public void onExchangeDone(AffinityTopologyVersion topVer,
                      Collection<DynamicCacheChangeRequest> reqs,
                      Throwable err)

Callback invoked when first exchange future for dynamic cache is completed.

Parameters:
  `topVer` - Completed topology version.
  `reqs` - Change requests.
  `err` - Error.

#### completeStartFuture

    public void completeStartFuture(DynamicCacheChangeRequest req)

Parameters:
  `req` - Request to complete future for.

#### discoveryDataType

    @Nullable
    public GridComponent.DiscoveryDataExchangeType discoveryDataType()

Gets unique component type to distinguish components providing discovery data. Must return non-null value if component implements method `GridComponent.collectDiscoveryData(UUID)`.

Specified by:
  `discoveryDataType` in interface `GridComponent`
Overrides:
  `discoveryDataType` in class `GridProcessorAdapter`
Returns:
  Unique component type for discovery data exchange.

#### collectDiscoveryData

    @Nullable
    public Serializable collectDiscoveryData(UUID nodeId)

Gets discovery data object that will be sent to new node during discovery process.

Specified by:
  `collectDiscoveryData` in interface `GridComponent`
Overrides:
  `collectDiscoveryData` in class `GridProcessorAdapter`
Parameters:
  `nodeId` - ID of new node that joins topology.
Returns:
  Discovery data object or `null` if there is nothing to send for this component.

#### onDiscoveryDataReceived

    public void onDiscoveryDataReceived(UUID joiningNodeId,
                               UUID rmtNodeId,
                               Serializable data)

Receives discovery data object from remote nodes (called on new node during discovery process).

Specified by:
  `onDiscoveryDataReceived` in interface `GridComponent`
Overrides:
  `onDiscoveryDataReceived` in class `GridProcessorAdapter`
Parameters:
  `joiningNodeId` - Joining node ID.
  `rmtNodeId` - Remote node ID for which data is provided.
  `data` - Discovery data object or `null` if nothing was

#### createFromTemplate

    public IgniteInternalFuture<?> createFromTemplate(String cacheName)

Dynamically starts cache using template configuration.

Parameters:
  `cacheName` - Cache name.
Returns:
  Future that will be completed when cache is deployed.

#### getOrCreateFromTemplate

    public IgniteInternalFuture<?> getOrCreateFromTemplate(String cacheName)

Dynamically starts cache using template configuration.

Parameters:
  `cacheName` - Cache name.
Returns:
  Future that will be completed when cache is deployed.

#### dynamicStartCache

    public IgniteInternalFuture<?> dynamicStartCache(@Nullable
                                            CacheConfiguration ccfg,
                                            String cacheName,
                                            @Nullable
                                            NearCacheConfiguration nearCfg,
                                            boolean failIfExists)

Dynamically starts cache.

Parameters:
  `ccfg` - Cache configuration.
  `cacheName` - Cache name.
  `nearCfg` - Near cache configuration.
  `failIfExists` - Fail if exists flag.
Returns:
  Future that will be completed when cache is deployed.

#### dynamicStartCache

    public IgniteInternalFuture<?> dynamicStartCache(@Nullable
                                            CacheConfiguration ccfg,
                                            String cacheName,
                                            @Nullable
                                            NearCacheConfiguration nearCfg,
                                            CacheType cacheType,
                                            boolean failIfExists)

Dynamically starts cache.

Parameters:
  `ccfg` - Cache configuration.
  `cacheName` - Cache name.
  `nearCfg` - Near cache configuration.
  `failIfExists` - Fail if exists flag.
Returns:
  Future that will be completed when cache is deployed.

#### dynamicStopCache

    public IgniteInternalFuture<?> dynamicStopCache(String cacheName)

Parameters:
  `cacheName` - Cache name to stop.
Returns:
  Future that will be completed when cache is stopped.

#### initiateCacheChanges

    public Collection<org.apache.ignite.internal.processors.cache.GridCacheProcessor.DynamicCacheStartFuture> initiateCacheChanges(Collection<DynamicCacheChangeRequest> reqs)

Parameters:
  `reqs` - Requests.
Returns:
  Collection of futures.

#### validateNode

    @Nullable
    public IgniteNodeValidationResult validateNode(ClusterNode node)

Validates that new node can join grid topology, this method is called on coordinator node before new node joins topology.

Specified by:
  `validateNode` in interface `GridComponent`
Overrides:
  `validateNode` in class `GridProcessorAdapter`
Parameters:
  `node` - Joining node.
Returns:
  Validation result or `null` in case of success.

#### orderedPreloadFuture

    @Nullable
    public IgniteInternalFuture<?> orderedPreloadFuture(int order)

Gets preload finish future for preload-ordered cache with given order. I.e. will get compound preload future with maximum order less than `order`.

Parameters:
  `order` - Cache order.
Returns:
  Compound preload future or `null` if order is minimal order found.

#### onEvictFromSwap

    public void onEvictFromSwap(String spaceName,
                       byte[] keyBytes,
                       byte[] valBytes)

Parameters:
  `spaceName` - Space name.
  `keyBytes` - Key bytes.
  `valBytes` - Value bytes.

#### lastDataVersion

    public long lastDataVersion()

Returns:
  Last data version.

#### cache

    public <K,V> IgniteInternalCache<K,V> cache()

Type Parameters:
  `K` - type of keys.
  `V` - type of values.
Returns:
  Default cache.

#### cache

    public <K,V> IgniteInternalCache<K,V> cache(@Nullable
                                       String name)

Type Parameters:
  `K` - type of keys.
  `V` - type of values.
Parameters:
  `name` - Cache name.
Returns:
  Cache instance for given name.

#### getOrStartCache

    public <K,V> IgniteInternalCache<K,V> getOrStartCache(@Nullable
                                                 String name)
                                             throws IgniteCheckedException

Parameters:
  `name` - Cache name.
Returns:
  Cache instance for given name.
Throws:
  `IgniteCheckedException` - If failed.

#### caches

    public Collection<IgniteInternalCache<?,?>> caches()

Returns:
  All configured cache instances.

#### jcaches

    public Collection<IgniteCacheProxy<?,?>> jcaches()

Returns:
  All configured cache instances.

#### marshallerCache

    public GridCacheAdapter<Integer,String> marshallerCache()

Returns:
  Marshaller system cache.

#### utilityCache

    public <K,V> GridCacheAdapter<K,V> utilityCache()

Gets utility cache.

Returns:
  Utility cache.

#### atomicsCache

    public <K,V> IgniteInternalCache<K,V> atomicsCache()

Gets utility cache for atomic data structures.

Returns:
  Utility cache for atomic data structures.

#### publicCache

    public <K,V> IgniteInternalCache<K,V> publicCache(@Nullable
                                             String name)

Type Parameters:
  `K` - type of keys.
  `V` - type of values.
Parameters:
  `name` - Cache name.
Returns:
  Cache instance for given name.

#### publicJCache

    public <K,V> IgniteCache<K,V> publicJCache(@Nullable
                                      String cacheName)
                                  throws IgniteCheckedException

Type Parameters:
  `K` - type of keys.
  `V` - type of values.
Parameters:
  `cacheName` - Cache name.
Returns:
  Cache instance for given name.
Throws:
  `IgniteCheckedException` - If failed.

#### publicJCache

    @Nullable
    public <K,V> IgniteCache<K,V> publicJCache(@Nullable
                                               String cacheName,
                                               boolean failIfNotStarted)
                                  throws IgniteCheckedException

Type Parameters:
  `K` - type of keys.
  `V` - type of values.
Parameters:
  `cacheName` - Cache name.
  `failIfNotStarted` - If `true` throws `IllegalArgumentException` if cache is not started, otherwise returns `null` in this case.
Returns:
  Cache instance for given name.
Throws:
  `IgniteCheckedException` - If failed.

#### cacheConfiguration

    public CacheConfiguration cacheConfiguration(String name)

Get configuration for the given cache.

Parameters:
  `name` - Cache name.
Returns:
  Cache configuration.

#### addCacheConfiguration

    public void addCacheConfiguration(CacheConfiguration cacheCfg)
                               throws IgniteCheckedException

Parameters:
  `cacheCfg` - Cache configuration template.
Throws:
  `IgniteCheckedException` - If failed.

#### jcache

    public <K,V> IgniteCacheProxy<K,V> jcache(@Nullable
                                     String name)

Parameters:
  `name` - Cache name.
Returns:
  Cache instance for given name.

#### publicCaches

    public Collection<IgniteCacheProxy<?,?>> publicCaches()

Returns:
  All configured public cache instances.

#### internalCache

    public <K,V> GridCacheAdapter<K,V> internalCache()

Type Parameters:
  `K` - type of keys.
  `V` - type of values.
Returns:
  Default cache.

#### internalCache

    public <K,V> GridCacheAdapter<K,V> internalCache(@Nullable
                                            String name)

Type Parameters:
  `K` - type of keys.
  `V` - type of values.
Parameters:
  `name` - Cache name.
Returns:
  Cache instance for given name.

#### cancelUserOperations

    public void cancelUserOperations()

Cancel all user operations.

#### internalCaches

    public Collection<GridCacheAdapter<?,?>> internalCaches()

Returns:
  All internal cache instances.

#### systemCache

    public boolean systemCache(@Nullable
                      String name)

Parameters:
  `name` - Cache name.
Returns:
  `True` if specified cache is system, `false` otherwise.

#### printMemoryStats

    public void printMemoryStats()

Prints memory statistics (sizes of internal structures, etc.). NOTE: this method is for testing and profiling purposes only.

Specified by:
  `printMemoryStats` in interface `GridComponent`
Overrides:
  `printMemoryStats` in class `GridProcessorAdapter`

#### onUndeployed

    public void onUndeployed(ClassLoader ldr)

Callback invoked by deployment manager for whenever a class loader gets undeployed.

Parameters:
  `ldr` - Class loader.

#### context

    public <K,V> GridCacheSharedContext<K,V> context()

Returns:
  Shared context.

#### transactions

    public IgniteTransactionsEx transactions()

Returns:
  Transactions interface implementation.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.1.0-incubating
Release Date | : May 20 2015