org.apache.ignite.internal.processors.cache.persistence

## Class IgniteCacheDatabaseSharedManager

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter
  - - org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager

All Implemented Interfaces:
  GridCacheSharedManager, CheckpointLockStateChecker, IgniteChangeGlobalStateSupport

Direct Known Subclasses:
  GridCacheDatabaseSharedManager

    public class IgniteCacheDatabaseSharedManager
    extends GridCacheSharedManagerAdapter
    implements IgniteChangeGlobalStateSupport, CheckpointLockStateChecker

### Field Summary

Fields
`protected MemoryPolicy` `dfltMemPlc`
`protected Map<String,MemoryMetrics>` `memMetricsMap`
`protected Map<String,MemoryPolicy>` `memPlcMap`

### Fields inherited from class org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter

`cctx, diagnosticLog, log`

### Constructor Summary

Constructors
Constructor and Description
`IgniteCacheDatabaseSharedManager()`

### Method Summary

Methods
`void` `beforeExchange(GridDhtPartitionsExchangeFuture discoEvt)`
`protected File` `buildAllocPath(MemoryPolicyConfiguration plc)` Builds allocation path for memory mapped file to be used with PageMemory.
`protected File` `buildPath(String path, String consId)`
`boolean` `checkpointLockIsHeldByThread()`
`void` `checkpointReadLock()` No-op for non-persistent storage.
`void` `checkpointReadUnlock()` No-op for non-persistent storage.
`protected void` `checkPolicyEvictionProperties(MemoryPolicyConfiguration plcCfg, MemoryConfiguration dbCfg)`
`protected PageMemory` `createPageMemory(DirectMemoryProvider memProvider, MemoryConfiguration memCfg, MemoryPolicyConfiguration memPlcCfg, MemoryMetricsImpl memMetrics)` Creates PageMemory with given size and memory provider.
`void` `dumpStatistics(IgniteLogger log)`
`void` `ensureFreeSpace(MemoryPolicy memPlc)` See `GridCacheMapEntry.ensureFreeSpace()`
`FreeList` `freeList(String memPlcName)`
`IgniteInternalFuture` `indexRebuildFuture(int cacheId)`
`protected void` `initPageMemoryDataStructures(MemoryConfiguration dbCfg)`
`protected void` `initPageMemoryPolicies(MemoryConfiguration memCfg)`
`void` `lock()`
`Collection<MemoryMetrics>` `memoryMetrics()`
`MemoryMetrics` `memoryMetrics(String memPlcName)`
`Collection<MemoryPolicy>` `memoryPolicies()`
`MemoryPolicy` `memoryPolicy(String memPlcName)`
`void` `onActivate(GridKernalContext kctx)` Called when cluster performing activation.
`void` `onCacheGroupsStopped(Collection<IgniteBiTuple<CacheGroupContext,Boolean>> stoppedGrps)`
`void` `onDeActivate(GridKernalContext kctx)` Called when cluster performing deactivation.
`int` `pageSize()`
`boolean` `persistenceEnabled()`
`PersistenceMetrics` `persistentStoreMetrics()`
`void` `prepareCachesStop()` Needed action before any cache will stop
`void` `readCheckpointAndRestoreMemory(List<DynamicCacheDescriptor> cachesToStart)`
`void` `releaseHistoryForExchange()` Release reserved update history.
`void` `releaseHistoryForPreloading()` Release reserved update history.
`Map<Integer,Map<Integer,Long>>` `reserveHistoryForExchange()` Reserve update history for exchange.
`boolean` `reserveHistoryForPreloading(int grpId, int partId, long cntr)` Reserve update history for preloading.
`ReuseList` `reuseList(String memPlcName)`
`protected void` `setPageSize(int pageSize)` Method for fake (standalone) context initialization.
`protected void` `start0()`
`protected void` `stop0(boolean cancel)`
`String` `systemMemoryPolicyName()`
`void` `unLock()`
`void` `waitForCheckpoint(String reason)` Waits until current state is checkpointed.
`IgniteInternalFuture` `wakeupForCheckpoint(String reason)`

### Methods inherited from class org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter

`context, isStopping, kernalStartInfo, kernalStopInfo, log, onDisconnected, onKernalStop, onKernalStop0, printMemoryStats, start, startInfo, stop, stopInfo, toString`

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

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

### Field Detail

#### memPlcMap

    protected Map<String,MemoryPolicy> memPlcMap

#### memMetricsMap

    protected Map<String,MemoryMetrics> memMetricsMap

#### dfltMemPlc

    protected MemoryPolicy dfltMemPlc

### Constructor Detail

#### IgniteCacheDatabaseSharedManager

    public IgniteCacheDatabaseSharedManager()

### Method Detail

#### start0

    protected void start0()
                   throws IgniteCheckedException

Overrides:
  `start0` in class `GridCacheSharedManagerAdapter`
Throws:
  `IgniteCheckedException` - If failed.

#### initPageMemoryDataStructures

    protected void initPageMemoryDataStructures(MemoryConfiguration dbCfg)
                                         throws IgniteCheckedException

Parameters:
  `dbCfg` - Database config.
Throws:
  `IgniteCheckedException` - If failed.

#### pageSize

    public int pageSize()

Returns:
  Size of page used for PageMemory regions.

#### initPageMemoryPolicies

    protected void initPageMemoryPolicies(MemoryConfiguration memCfg)

Parameters:
  `memCfg` - Database config.

#### checkPolicyEvictionProperties

    protected void checkPolicyEvictionProperties(MemoryPolicyConfiguration plcCfg,
                                     MemoryConfiguration dbCfg)
                                          throws IgniteCheckedException

Parameters:
  `plcCfg` - MemoryPolicyConfiguration to validate.
  `dbCfg` - Memory configuration.
Throws:
  `IgniteCheckedException` - If config is invalid.

#### dumpStatistics

    public void dumpStatistics(IgniteLogger log)

Parameters:
  `log` - Logger.

#### memoryPolicies

    public Collection<MemoryPolicy> memoryPolicies()

Returns:
  collection of all configured `policies`.

#### memoryMetrics

    public Collection<MemoryMetrics> memoryMetrics()

Returns:
  MemoryMetrics for all MemoryPolicies configured in Ignite instance.

#### persistentStoreMetrics

    public PersistenceMetrics persistentStoreMetrics()

Returns:
  PersistenceMetrics if persistence is enabled or `null` otherwise.

#### readCheckpointAndRestoreMemory

    public void readCheckpointAndRestoreMemory(List<DynamicCacheDescriptor> cachesToStart)
                                        throws IgniteCheckedException

Parameters:
  `cachesToStart` - Started caches.
Throws:
  `IgniteCheckedException` - If failed.

#### memoryMetrics

    @Nullable
    public MemoryMetrics memoryMetrics(String memPlcName)

Parameters:
  `memPlcName` - Name of `MemoryPolicy` to obtain `MemoryMetrics` for.
Returns:
  `MemoryMetrics` snapshot for specified `MemoryPolicy` or `null` if no `MemoryPolicy` is configured for specified name.

#### memoryPolicy

    public MemoryPolicy memoryPolicy(String memPlcName)
                              throws IgniteCheckedException

Parameters:
  `memPlcName` - Memory policy name.
Returns:
  `MemoryPolicy` instance associated with a given `MemoryPolicyConfiguration`.
Throws:
  `IgniteCheckedException` - in case of request for unknown MemoryPolicy.

#### freeList

    public FreeList freeList(String memPlcName)

Parameters:
  `memPlcName` - MemoryPolicyConfiguration name.
Returns:
  `FreeList` instance associated with a given `MemoryPolicyConfiguration`.

#### reuseList

    public ReuseList reuseList(String memPlcName)

Parameters:
  `memPlcName` - MemoryPolicyConfiguration name.
Returns:
  `ReuseList` instance associated with a given `MemoryPolicyConfiguration`.

#### stop0

    protected void stop0(boolean cancel)

Overrides:
  `stop0` in class `GridCacheSharedManagerAdapter`
Parameters:
  `cancel` - Cancel flag.

#### persistenceEnabled

    public boolean persistenceEnabled()

#### checkpointLockIsHeldByThread

    public boolean checkpointLockIsHeldByThread()

Specified by:
  `checkpointLockIsHeldByThread` in interface `CheckpointLockStateChecker`
Returns:
  true if checkpoint lock is held by current thread

#### lock

    public void lock()
              throws IgniteCheckedException

Throws:
  `IgniteCheckedException`

#### unLock

    public void unLock()

#### checkpointReadLock

    public void checkpointReadLock()

No-op for non-persistent storage.

#### checkpointReadUnlock

    public void checkpointReadUnlock()

No-op for non-persistent storage.

#### wakeupForCheckpoint

    @Nullable
    public IgniteInternalFuture wakeupForCheckpoint(String reason)

#### waitForCheckpoint

    public void waitForCheckpoint(String reason)
                           throws IgniteCheckedException

Waits until current state is checkpointed.

Throws:
  `IgniteCheckedException` - If failed.

#### beforeExchange

    public void beforeExchange(GridDhtPartitionsExchangeFuture discoEvt)
                        throws IgniteCheckedException

Parameters:
  `discoEvt` - Before exchange for the given discovery event.
Throws:
  `IgniteCheckedException`

#### prepareCachesStop

    public void prepareCachesStop()

Needed action before any cache will stop

#### onCacheGroupsStopped

    public void onCacheGroupsStopped(Collection<IgniteBiTuple<CacheGroupContext,Boolean>> stoppedGrps)

Parameters:
  `stoppedGrps` - A collection of tuples (cache group, destroy flag).

#### indexRebuildFuture

    @Nullable
    public IgniteInternalFuture indexRebuildFuture(int cacheId)

Returns:
  Future that will be completed when indexes for given cache are restored.

#### reserveHistoryForExchange

    public Map<Integer,Map<Integer,Long>> reserveHistoryForExchange()

Reserve update history for exchange.

Returns:
  Reserved update counters per cache and partition.

#### releaseHistoryForExchange

    public void releaseHistoryForExchange()

Release reserved update history.

#### reserveHistoryForPreloading

    public boolean reserveHistoryForPreloading(int grpId,
                                      int partId,
                                      long cntr)

Reserve update history for preloading.

Parameters:
  `grpId` - Cache group ID.
  `partId` - Partition Id.
  `cntr` - Update counter.
Returns:
  True if successfully reserved.

#### releaseHistoryForPreloading

    public void releaseHistoryForPreloading()

Release reserved update history.

#### ensureFreeSpace

    public void ensureFreeSpace(MemoryPolicy memPlc)
                         throws IgniteCheckedException

See `GridCacheMapEntry.ensureFreeSpace()`

Parameters:
  `memPlc` - Memory policy.
Throws:
  `IgniteCheckedException`

#### buildAllocPath

    @Nullable
    protected File buildAllocPath(MemoryPolicyConfiguration plc)

Builds allocation path for memory mapped file to be used with PageMemory.

Parameters:
  `plc` - MemoryPolicyConfiguration.

#### createPageMemory

    protected PageMemory createPageMemory(DirectMemoryProvider memProvider,
                              MemoryConfiguration memCfg,
                              MemoryPolicyConfiguration memPlcCfg,
                              MemoryMetricsImpl memMetrics)

Creates PageMemory with given size and memory provider.

Parameters:
  `memProvider` - Memory provider.
  `memCfg` - Memory configuartion.
  `memPlcCfg` - Memory policy configuration.
  `memMetrics` - MemoryMetrics to collect memory usage metrics.
Returns:
  PageMemory instance.

#### buildPath

    protected File buildPath(String path,
                 String consId)

Parameters:
  `path` - Path to the working directory.
  `consId` - Consistent ID of the local node.
Returns:
  DB storage path.

#### onActivate

    public void onActivate(GridKernalContext kctx)
                    throws IgniteCheckedException

Called when cluster performing activation.

Specified by:
  `onActivate` in interface `IgniteChangeGlobalStateSupport`
Parameters:
  `kctx` - Kernal context.
Throws:
  `IgniteCheckedException` - If failed.

#### onDeActivate

    public void onDeActivate(GridKernalContext kctx)

Called when cluster performing deactivation.

Specified by:
  `onDeActivate` in interface `IgniteChangeGlobalStateSupport`
Parameters:
  `kctx` - Kernal context.

#### systemMemoryPolicyName

    public String systemMemoryPolicyName()

Returns:
  Name of MemoryPolicyConfiguration for internal caches.

#### setPageSize

    protected void setPageSize(int pageSize)

Method for fake (standalone) context initialization. Not to be called in production code

Parameters:
  `pageSize` - configured page size

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.2.0
Release Date | : September 15 2017