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 Map<String,DataRegion>` `dataRegionMap`
`protected DataRegion` `dfltDataRegion`
`protected Map<String,CacheFreeListImpl>` `freeListMap`
`protected Map<String,DataRegionMetrics>` `memMetricsMap`
`static String` `SYSTEM_DATA_REGION_NAME` DataRegionConfiguration name reserved for internal caches.

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

`cctx, diagnosticLog, log`

### Constructor Summary

Constructors
Constructor and Description
`IgniteCacheDatabaseSharedManager()`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected void` `addDataRegion(DataStorageConfiguration dataStorageCfg, DataRegionConfiguration dataRegionCfg, boolean trackable)`
`void` `beforeExchange(GridDhtPartitionsExchangeFuture discoEvt)`
`protected File` `buildAllocPath(DataRegionConfiguration plc)` Builds allocation path for memory mapped file to be used with PageMemory.
`protected File` `buildPath(String path, String consId)`
`protected void` `checkPageSize(DataStorageConfiguration memCfg)`
`boolean` `checkpointLockIsHeldByThread()`
`void` `checkpointReadLock()` No-op for non-persistent storage.
`void` `checkpointReadUnlock()` No-op for non-persistent storage.
`protected void` `checkRegionEvictionProperties(DataRegionConfiguration regCfg, DataStorageConfiguration dbCfg)`
`protected PageEvictionTracker` `createPageEvictionTracker(DataRegionConfiguration plc, PageMemory pageMem)`
`protected PageMemory` `createPageMemory(DirectMemoryProvider memProvider, DataStorageConfiguration memCfg, DataRegionConfiguration memPlcCfg, DataRegionMetricsImpl memMetrics, boolean trackable)` Creates PageMemory with given size and memory provider.
`DataRegion` `dataRegion(String memPlcName)`
`Collection<DataRegion>` `dataRegions()`
`void` `dumpStatistics(IgniteLogger log)`
`void` `ensureFreeSpace(DataRegion memPlc)` See `GridCacheMapEntry.ensureFreeSpace()`
`CheckpointFuture` `forceCheckpoint(String reason)` Allows to wait checkpoint finished.
`FreeList` `freeList(String memPlcName)`
`protected IgniteOutClosure<Long>` `freeSpaceProvider(DataRegionConfiguration dataRegCfg)` Closure that can be used to compute fill factor for provided data region.
`IgniteInternalFuture` `indexRebuildFuture(int cacheId)`
`protected void` `initDataRegions(DataStorageConfiguration memCfg)`
`protected void` `initPageMemoryDataStructures(DataStorageConfiguration dbCfg)`
`void` `lock()`
`Collection<DataRegionMetrics>` `memoryMetrics()`
`DataRegionMetrics` `memoryMetrics(String memPlcName)`
`MetaStorage` `metaStorage()`
`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()`
`DataStorageMetrics` `persistentStoreMetrics()`
`void` `prepareCachesStop()` Needed action before any cache will stop
`void` `readCheckpointAndRestoreMemory(List<DynamicCacheDescriptor> cachesToStart)`
`void` `rebuildIndexesIfNeeded(GridDhtPartitionsExchangeFuture fut)`
`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` `systemDateRegionName()`
`void` `unLock()`
`void` `waitForCheckpoint(String reason)` Waits until current state is checkpointed.
`IgniteInternalFuture` `wakeupForCheckpoint(String reason)`
`boolean` `walEnabled(int grpId, boolean local)`
`void` `walEnabled(int grpId, boolean enabled, boolean local)` Marks cache group as with disabled WAL.
`protected DirectMemoryProvider` `wrapMetricsMemoryProvider(DirectMemoryProvider memoryProvider0, DataRegionMetricsImpl memMetrics)`

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

`context, isStopping, kernalStartInfo, kernalStopInfo, log, onDisconnected, onKernalStop, onKernalStop0, onReconnected, 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

#### SYSTEM_DATA_REGION_NAME

    public static final String SYSTEM_DATA_REGION_NAME

DataRegionConfiguration name reserved for internal caches.

See Also:
  Constant Field Values

#### dataRegionMap

    protected volatile Map<String,DataRegion> dataRegionMap

#### memMetricsMap

    protected Map<String,DataRegionMetrics> memMetricsMap

#### dfltDataRegion

    protected DataRegion dfltDataRegion

#### freeListMap

    protected Map<String,CacheFreeListImpl> freeListMap

### 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(DataStorageConfiguration dbCfg)
                                         throws IgniteCheckedException

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

#### pageSize

    public int pageSize()

Returns:
  Size of page used for PageMemory regions.

#### initDataRegions

    protected void initDataRegions(DataStorageConfiguration memCfg)
                            throws IgniteCheckedException

Parameters:
  `memCfg` - Database config.
Throws:
  `IgniteCheckedException` - If failed to initialize swap path.

#### addDataRegion

    protected void addDataRegion(DataStorageConfiguration dataStorageCfg,
                                 DataRegionConfiguration dataRegionCfg,
                                 boolean trackable)
                          throws IgniteCheckedException

Parameters:
  `dataStorageCfg` - Database config.
  `dataRegionCfg` - Data region config.
Throws:
  `IgniteCheckedException` - If failed to initialize swap path.

#### freeSpaceProvider

    protected IgniteOutClosure<Long> freeSpaceProvider(DataRegionConfiguration dataRegCfg)

Closure that can be used to compute fill factor for provided data region.

Parameters:
  `dataRegCfg` - Data region configuration.
Returns:
  Closure.

#### checkPageSize

    protected void checkPageSize(DataStorageConfiguration memCfg)

Parameters:
  `memCfg` - Memory config.

#### checkRegionEvictionProperties

    protected void checkRegionEvictionProperties(DataRegionConfiguration regCfg,
                                                 DataStorageConfiguration dbCfg)
                                          throws IgniteCheckedException

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

#### dumpStatistics

    public void dumpStatistics(IgniteLogger log)

Parameters:
  `log` - Logger.

#### dataRegions

    public Collection<DataRegion> dataRegions()

Returns:
  collection of all configured `policies`.

#### memoryMetrics

    public Collection<DataRegionMetrics> memoryMetrics()

Returns:
  DataRegionMetrics for all MemoryPolicies configured in Ignite instance.

#### persistentStoreMetrics

    public DataStorageMetrics persistentStoreMetrics()

Returns:
  DataStorageMetrics 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 DataRegionMetrics memoryMetrics(String memPlcName)

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

#### dataRegion

    public DataRegion dataRegion(String memPlcName)
                          throws IgniteCheckedException

Parameters:
  `memPlcName` - data region name.
Returns:
  `DataRegion` instance associated with a given `DataRegionConfiguration`.
Throws:
  `IgniteCheckedException` - in case of request for unknown DataRegion.

#### freeList

    public FreeList freeList(String memPlcName)

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

#### reuseList

    public ReuseList reuseList(String memPlcName)

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

#### stop0

    protected void stop0(boolean cancel)

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

#### 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)

#### forceCheckpoint

    @Nullable
    public CheckpointFuture forceCheckpoint(String reason)

Allows to wait checkpoint finished.

Parameters:
  `reason` - 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`

#### rebuildIndexesIfNeeded

    public void rebuildIndexesIfNeeded(GridDhtPartitionsExchangeFuture fut)

Parameters:
  `fut` - Partition exchange future.

#### 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(DataRegion memPlc)
                         throws IgniteCheckedException

See `GridCacheMapEntry.ensureFreeSpace()`

Parameters:
  `memPlc` - data region.
Throws:
  `IgniteCheckedException`

#### createPageEvictionTracker

    protected PageEvictionTracker createPageEvictionTracker(DataRegionConfiguration plc,
                                                            PageMemory pageMem)

Parameters:
  `plc` - data region Configuration.
  `pageMem` - Page memory.

#### buildAllocPath

    @Nullable
    protected File buildAllocPath(DataRegionConfiguration plc)
                                     throws IgniteCheckedException

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

Parameters:
  `plc` - DataRegionConfiguration.
Throws:
  `IgniteCheckedException` - If resolving swap directory fails.

#### createPageMemory

    protected PageMemory createPageMemory(DirectMemoryProvider memProvider,
                                          DataStorageConfiguration memCfg,
                                          DataRegionConfiguration memPlcCfg,
                                          DataRegionMetricsImpl memMetrics,
                                          boolean trackable)

Creates PageMemory with given size and memory provider.

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

#### wrapMetricsMemoryProvider

    protected DirectMemoryProvider wrapMetricsMemoryProvider(DirectMemoryProvider memoryProvider0,
                                                             DataRegionMetricsImpl memMetrics)

Parameters:
  `memoryProvider0` - Memory provider.
  `memMetrics` - Memory metrics.
Returns:
  Wrapped memory provider.

#### buildPath

    protected File buildPath(String path,
                             String consId)
                      throws IgniteCheckedException

Parameters:
  `path` - Path to the working directory.
  `consId` - Consistent ID of the local node.
Returns:
  DB storage path.
Throws:
  `IgniteCheckedException` - If resolving swap directory fails.

#### 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.

#### systemDateRegionName

    public String systemDateRegionName()

Returns:
  Name of DataRegionConfiguration 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

#### metaStorage

    public MetaStorage metaStorage()

Returns:
  MetaStorage

#### walEnabled

    public boolean walEnabled(int grpId,
                              boolean local)

Parameters:
  `grpId` - Group ID.
Returns:
  WAL enabled flag.

#### walEnabled

    public void walEnabled(int grpId,
                           boolean enabled,
                           boolean local)

Marks cache group as with disabled WAL.

Parameters:
  `grpId` - Group id.
  `enabled` - flag.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.6.0
Release Date | : July 10 2018