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

## Class GridCacheDatabaseSharedManager

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

All Implemented Interfaces:
  GridCacheSharedManager, CheckpointLockStateChecker, CheckpointWriteProgressSupplier, IgniteChangeGlobalStateSupport

    public class GridCacheDatabaseSharedManager
    extends IgniteCacheDatabaseSharedManager
    implements CheckpointWriteProgressSupplier

### Nested Class Summary

Nested Classes
`class` `GridCacheDatabaseSharedManager.Checkpointer` Checkpointer object is used for notification on checkpoint begin, predicate is `GridCacheDatabaseSharedManager.Checkpointer.scheduledCp``.nextCpTs - now > 0` .
`class` `GridCacheDatabaseSharedManager.CheckpointHistory` Checkpoint history.
`static class` `GridCacheDatabaseSharedManager.FileLockHolder`

### Field Summary

Fields
`static Long` `DFLT_MAX_CHECKPOINTING_PAGE_BUFFER_SIZE` Default minimum checkpointing page buffer size (may be adjusted by Ignite).
`static Long` `DFLT_MIN_CHECKPOINTING_PAGE_BUFFER_SIZE` Minimum checkpointing page buffer size (may be adjusted by Ignite).
`static String` `IGNITE_PDS_CHECKPOINT_TEST_SKIP_SYNC`

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

`dataRegionMap, dfltDataRegion, freeListMap, memMetricsMap, SYSTEM_DATA_REGION_NAME`

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

`cctx, diagnosticLog, log`

### Constructor Summary

Constructors
Constructor and Description
`GridCacheDatabaseSharedManager(GridKernalContext ctx)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `addCheckpointListener(DbCheckpointListener lsnr)`
`void` `applyUpdatesOnRecovery(WALIterator it, IgnitePredicate<IgniteBiTuple<WALPointer,WALRecord>> recPredicate, IgnitePredicate<DataEntry> entryPredicate, Map<T2<Integer,Integer>,T2<Integer,Long>> partStates)` Apply update from some iterator and with specific filters.
`void` `beforeExchange(GridDhtPartitionsExchangeFuture fut)`
`void` `cancelOrWaitPartitionDestroy(int grpId, int partId)` Cancels or wait for partition destroy.
`protected void` `checkPageSize(DataStorageConfiguration memCfg)`
`static long` `checkpointBufferSize(DataRegionConfiguration regCfg)` Get checkpoint buffer size for the given configuration.
`File` `checkpointDirectory()`
`GridCacheDatabaseSharedManager.CheckpointHistory` `checkpointHistory()`
`boolean` `checkpointLockIsHeldByThread()`
`void` `checkpointReadLock()` Gets the checkpoint read lock.
`void` `checkpointReadUnlock()` Releases the checkpoint read lock.
`protected void` `checkRegionEvictionProperties(DataRegionConfiguration regCfg, DataStorageConfiguration dbCfg)`
`protected PageMemory` `createPageMemory(DirectMemoryProvider memProvider, DataStorageConfiguration memCfg, DataRegionConfiguration plcCfg, DataRegionMetricsImpl memMetrics, boolean trackable)` Creates PageMemory with given size and memory provider.
`int` `currentCheckpointPagesCount()`
`IgniteInternalFuture<Void>` `enableCheckpoints(boolean enable)` For test use only.
`AtomicInteger` `evictedPagesCntr()`
`CheckpointFuture` `forceCheckpoint(String reason)` Allows to wait checkpoint finished.
`protected IgniteOutClosure<Long>` `freeSpaceProvider(DataRegionConfiguration dataRegCfg)` Closure that can be used to compute fill factor for provided data region.
`GridCacheDatabaseSharedManager.Checkpointer` `getCheckpointer()`
`IgniteInternalFuture` `indexRebuildFuture(int cacheId)`
`protected void` `initDataRegions(DataStorageConfiguration memCfg)`
`void` `lock()`
`MetaStorage` `metaStorage()`
`List<T2<Long,WALPointer>>` `nodeStartedPointers()`
`void` `onActivate(GridKernalContext ctx)` Called when cluster performing activation.
`void` `onCacheGroupsStopped(Collection<IgniteBiTuple<CacheGroupContext,Boolean>> stoppedGrps)`
`void` `onDeActivate(GridKernalContext kctx)` Called when cluster performing deactivation.
`protected void` `onKernalStop0(boolean cancel)`
`void` `onWalTruncated(WALPointer highBound)` Wal truncate callBack.
`DataStorageMetrics` `persistentStoreMetrics()`
`DataStorageMetricsImpl` `persistentStoreMetricsImpl()`
`void` `readCheckpointAndRestoreMemory(List<DynamicCacheDescriptor> cachesToStart)`
`void` `rebuildIndexesIfNeeded(GridDhtPartitionsExchangeFuture fut)`
`void` `releaseHistoryForExchange()` Release reserved update history.
`void` `releaseHistoryForPreloading()` Release reserved update history.
`void` `removeCheckpointListener(DbCheckpointListener lsnr)`
`Map<T2<Integer,Integer>,T2<Long,WALPointer>>` `reservedForPreloading()` For debugging only.
`Map<Integer,Map<Integer,Long>>` `reserveHistoryForExchange()` Reserve update history for exchange.
`boolean` `reserveHistoryForPreloading(int grpId, int partId, long cntr)` Reserve update history for preloading.
`void` `schedulePartitionDestroy(int grpId, int partId)` Adds given partition to checkpointer destroy queue.
`WALPointer` `searchPartitionCounter(int grpId, int part, Long partCntrSince)` Tries to search for a WAL pointer for the given partition counter start.
`void` `setThreadBuf(ThreadLocal<ByteBuffer> threadBuf)` Replace thread local with buffers.
`protected void` `start0()`
`AtomicInteger` `syncedPagesCounter()`
`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.
`AtomicInteger` `writtenPagesCounter()` Counter for written checkpoint pages.

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

`addDataRegion, buildAllocPath, buildPath, createPageEvictionTracker, dataRegion, dataRegions, dumpStatistics, ensureFreeSpace, freeList, initPageMemoryDataStructures, memoryMetrics, memoryMetrics, pageSize, prepareCachesStop, reuseList, setPageSize, stop0, systemDateRegionName, wrapMetricsMemoryProvider`

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

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

#### IGNITE_PDS_CHECKPOINT_TEST_SKIP_SYNC

    public static final String IGNITE_PDS_CHECKPOINT_TEST_SKIP_SYNC

See Also:
  Constant Field Values

#### DFLT_MIN_CHECKPOINTING_PAGE_BUFFER_SIZE

    public static final Long DFLT_MIN_CHECKPOINTING_PAGE_BUFFER_SIZE

Minimum checkpointing page buffer size (may be adjusted by Ignite).

#### DFLT_MAX_CHECKPOINTING_PAGE_BUFFER_SIZE

    public static final Long DFLT_MAX_CHECKPOINTING_PAGE_BUFFER_SIZE

Default minimum checkpointing page buffer size (may be adjusted by Ignite).

### Constructor Detail

#### GridCacheDatabaseSharedManager

    public GridCacheDatabaseSharedManager(GridKernalContext ctx)

Parameters:
  `ctx` - Kernal context.

### Method Detail

#### getCheckpointer

    public GridCacheDatabaseSharedManager.Checkpointer getCheckpointer()

#### enableCheckpoints

    public IgniteInternalFuture<Void> enableCheckpoints(boolean enable)

For test use only.

#### initDataRegions

    protected void initDataRegions(DataStorageConfiguration memCfg)
                            throws IgniteCheckedException

Overrides:
  `initDataRegions` in class `IgniteCacheDatabaseSharedManager`
Parameters:
  `memCfg` - Database config.
Throws:
  `IgniteCheckedException` - If failed to initialize swap path.

#### start0

    protected void start0()
                   throws IgniteCheckedException

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

#### checkpointBufferSize

    public static long checkpointBufferSize(DataRegionConfiguration regCfg)

Get checkpoint buffer size for the given configuration.

Parameters:
  `regCfg` - Configuration.
Returns:
  Checkpoint buffer size.

#### onActivate

    public void onActivate(GridKernalContext ctx)
                    throws IgniteCheckedException

Called when cluster performing activation.

Specified by:
  `onActivate` in interface `IgniteChangeGlobalStateSupport`
Overrides:
  `onActivate` in class `IgniteCacheDatabaseSharedManager`
Parameters:
  `ctx` - Kernal context.
Throws:
  `IgniteCheckedException` - If failed.

#### onDeActivate

    public void onDeActivate(GridKernalContext kctx)

Called when cluster performing deactivation.

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

#### freeSpaceProvider

    protected IgniteOutClosure<Long> freeSpaceProvider(DataRegionConfiguration dataRegCfg)

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

Overrides:
  `freeSpaceProvider` in class `IgniteCacheDatabaseSharedManager`
Parameters:
  `dataRegCfg` - Data region configuration.
Returns:
  Closure.

#### readCheckpointAndRestoreMemory

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

Overrides:
  `readCheckpointAndRestoreMemory` in class `IgniteCacheDatabaseSharedManager`
Parameters:
  `cachesToStart` - Started caches.
Throws:
  `IgniteCheckedException` - If failed.

#### nodeStartedPointers

    public List<T2<Long,WALPointer>> nodeStartedPointers()
                                                  throws IgniteCheckedException

Throws:
  `IgniteCheckedException`

#### lock

    public void lock()
              throws IgniteCheckedException

Overrides:
  `lock` in class `IgniteCacheDatabaseSharedManager`
Throws:
  `IgniteCheckedException`

#### unLock

    public void unLock()

Overrides:
  `unLock` in class `IgniteCacheDatabaseSharedManager`

#### onKernalStop0

    protected void onKernalStop0(boolean cancel)

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

#### createPageMemory

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

Creates PageMemory with given size and memory provider.

Overrides:
  `createPageMemory` in class `IgniteCacheDatabaseSharedManager`
Parameters:
  `memProvider` - Memory provider.
  `memCfg` - Memory configuartion.
  `plcCfg` - data region configuration.
  `memMetrics` - DataRegionMetrics to collect memory usage metrics.
Returns:
  PageMemory instance.

#### checkRegionEvictionProperties

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

Overrides:
  `checkRegionEvictionProperties` in class `IgniteCacheDatabaseSharedManager`
Parameters:
  `regCfg` - DataRegionConfiguration to validate.
  `dbCfg` - Memory configuration.
Throws:
  `IgniteCheckedException` - If config is invalid.

#### checkPageSize

    protected void checkPageSize(DataStorageConfiguration memCfg)

Overrides:
  `checkPageSize` in class `IgniteCacheDatabaseSharedManager`
Parameters:
  `memCfg` - Memory config.

#### beforeExchange

    public void beforeExchange(GridDhtPartitionsExchangeFuture fut)
                        throws IgniteCheckedException

Overrides:
  `beforeExchange` in class `IgniteCacheDatabaseSharedManager`
Parameters:
  `fut` - Before exchange for the given discovery event.
Throws:
  `IgniteCheckedException`

#### rebuildIndexesIfNeeded

    public void rebuildIndexesIfNeeded(GridDhtPartitionsExchangeFuture fut)

Overrides:
  `rebuildIndexesIfNeeded` in class `IgniteCacheDatabaseSharedManager`
Parameters:
  `fut` - Partition exchange future.

#### indexRebuildFuture

    @Nullable
    public IgniteInternalFuture indexRebuildFuture(int cacheId)

Overrides:
  `indexRebuildFuture` in class `IgniteCacheDatabaseSharedManager`
Returns:
  Future that will be completed when indexes for given cache are restored.

#### onCacheGroupsStopped

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

Overrides:
  `onCacheGroupsStopped` in class `IgniteCacheDatabaseSharedManager`
Parameters:
  `stoppedGrps` - A collection of tuples (cache group, destroy flag).

#### checkpointReadLock

    public void checkpointReadLock()

Gets the checkpoint read lock. While this lock is held, checkpoint thread will not acquireSnapshotWorker memory state.

Overrides:
  `checkpointReadLock` in class `IgniteCacheDatabaseSharedManager`

#### checkpointLockIsHeldByThread

    public boolean checkpointLockIsHeldByThread()

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

#### checkpointReadUnlock

    public void checkpointReadUnlock()

Releases the checkpoint read lock.

Overrides:
  `checkpointReadUnlock` in class `IgniteCacheDatabaseSharedManager`

#### reserveHistoryForExchange

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

Reserve update history for exchange.

Overrides:
  `reserveHistoryForExchange` in class `IgniteCacheDatabaseSharedManager`
Returns:
  Reserved update counters per cache and partition.

#### releaseHistoryForExchange

    public void releaseHistoryForExchange()

Release reserved update history.

Overrides:
  `releaseHistoryForExchange` in class `IgniteCacheDatabaseSharedManager`

#### reserveHistoryForPreloading

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

Reserve update history for preloading.

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

#### releaseHistoryForPreloading

    public void releaseHistoryForPreloading()

Release reserved update history.

Overrides:
  `releaseHistoryForPreloading` in class `IgniteCacheDatabaseSharedManager`

#### reservedForPreloading

    public Map<T2<Integer,Integer>,T2<Long,WALPointer>> reservedForPreloading()

For debugging only. TODO: remove.

#### wakeupForCheckpoint

    @Nullable
    public IgniteInternalFuture wakeupForCheckpoint(String reason)

Overrides:
  `wakeupForCheckpoint` in class `IgniteCacheDatabaseSharedManager`

#### waitForCheckpoint

    public void waitForCheckpoint(String reason)
                           throws IgniteCheckedException

Waits until current state is checkpointed.

Overrides:
  `waitForCheckpoint` in class `IgniteCacheDatabaseSharedManager`
Throws:
  `IgniteCheckedException` - If failed.

#### forceCheckpoint

    public CheckpointFuture forceCheckpoint(String reason)

Allows to wait checkpoint finished.

Overrides:
  `forceCheckpoint` in class `IgniteCacheDatabaseSharedManager`
Parameters:
  `reason` - Reason.

#### searchPartitionCounter

    @Nullable
    public WALPointer searchPartitionCounter(int grpId,
                                                       int part,
                                                       @Nullable
                                                       Long partCntrSince)

Tries to search for a WAL pointer for the given partition counter start.

Parameters:
  `grpId` - Cache group ID.
  `part` - Partition ID.
  `partCntrSince` - Partition counter or `null` to search for minimal counter.
Returns:
  Checkpoint entry or `null` if failed to search.

#### checkpointHistory

    public GridCacheDatabaseSharedManager.CheckpointHistory checkpointHistory()

Returns:
  Checkpoint history. For tests only.

#### checkpointDirectory

    public File checkpointDirectory()

Returns:
  Checkpoint directory.

#### addCheckpointListener

    public void addCheckpointListener(DbCheckpointListener lsnr)

Parameters:
  `lsnr` - Listener.

#### removeCheckpointListener

    public void removeCheckpointListener(DbCheckpointListener lsnr)

Parameters:
  `lsnr` - Listener.

#### applyUpdatesOnRecovery

    public void applyUpdatesOnRecovery(@Nullable
                                       WALIterator it,
                                       IgnitePredicate<IgniteBiTuple<WALPointer,WALRecord>> recPredicate,
                                       IgnitePredicate<DataEntry> entryPredicate,
                                       Map<T2<Integer,Integer>,T2<Integer,Long>> partStates)
                                throws IgniteCheckedException

Apply update from some iterator and with specific filters.

Parameters:
  `it` - WalIterator.
  `recPredicate` - Wal record filter.
  `entryPredicate` - Entry filter.
  `partStates` - Partition to restore state.
Throws:
  `IgniteCheckedException`

#### onWalTruncated

    public void onWalTruncated(WALPointer highBound)

Wal truncate callBack.

Parameters:
  `highBound` - WALPointer.

#### writtenPagesCounter

    public AtomicInteger writtenPagesCounter()

Counter for written checkpoint pages. Not null only if checkpoint is running.

Specified by:
  `writtenPagesCounter` in interface `CheckpointWriteProgressSupplier`

#### syncedPagesCounter

    public AtomicInteger syncedPagesCounter()

Specified by:
  `syncedPagesCounter` in interface `CheckpointWriteProgressSupplier`
Returns:
  Counter for fsynced checkpoint pages. Not null only if checkpoint is running.

#### evictedPagesCntr

    public AtomicInteger evictedPagesCntr()

Specified by:
  `evictedPagesCntr` in interface `CheckpointWriteProgressSupplier`
Returns:
  Counter for evicted pages during current checkpoint. Not null only if checkpoint is running.

#### currentCheckpointPagesCount

    public int currentCheckpointPagesCount()

Specified by:
  `currentCheckpointPagesCount` in interface `CheckpointWriteProgressSupplier`
Returns:
  Number of pages in current checkpoint. If checkpoint is not running, returns 0.

#### setThreadBuf

    public void setThreadBuf(ThreadLocal<ByteBuffer> threadBuf)

Replace thread local with buffers. Thread local should provide direct buffer with one page in length.

Parameters:
  `threadBuf` - new thread-local with buffers for the checkpoint threads.

#### schedulePartitionDestroy

    public void schedulePartitionDestroy(int grpId,
                                         int partId)

Adds given partition to checkpointer destroy queue.

Parameters:
  `grpId` - Group ID.
  `partId` - Partition ID.

#### cancelOrWaitPartitionDestroy

    public void cancelOrWaitPartitionDestroy(int grpId,
                                             int partId)
                                      throws IgniteCheckedException

Cancels or wait for partition destroy.

Parameters:
  `grpId` - Group ID.
  `partId` - Partition ID.
Throws:
  `IgniteCheckedException` - If failed.

#### persistentStoreMetrics

    public DataStorageMetrics persistentStoreMetrics()

Overrides:
  `persistentStoreMetrics` in class `IgniteCacheDatabaseSharedManager`
Returns:
  DataStorageMetrics if persistence is enabled or `null` otherwise.

#### persistentStoreMetricsImpl

    public DataStorageMetricsImpl persistentStoreMetricsImpl()

#### metaStorage

    public MetaStorage metaStorage()

Overrides:
  `metaStorage` in class `IgniteCacheDatabaseSharedManager`
Returns:
  MetaStorage

#### walEnabled

    public boolean walEnabled(int grpId,
                              boolean local)

Overrides:
  `walEnabled` in class `IgniteCacheDatabaseSharedManager`
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.

Overrides:
  `walEnabled` in class `IgniteCacheDatabaseSharedManager`
Parameters:
  `grpId` - Group id.
  `enabled` - flag.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

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