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

## Class IgniteSnapshotManager

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

All Implemented Interfaces:
  IgniteSnapshot, PartitionsExchangeAware, GridCacheSharedManager, MetastorageLifecycleListener

    public class IgniteSnapshotManager
    extends GridCacheSharedManagerAdapter
    implements IgniteSnapshot, PartitionsExchangeAware, MetastorageLifecycleListener

Internal implementation of snapshot operations over persistence caches.

These major actions available:

- Create snapshot of the whole cluster cache groups by triggering PME to achieve consistency.

### Field Summary

Fields
`static String` `CP_SNAPSHOT_REASON` Text Reason for checkpoint to start snapshot operation.
`static String` `DELTA_SUFFIX` File with delta pages suffix.
`static String` `DFLT_SNAPSHOT_TMP_DIR` Default snapshot directory for loading remote snapshots.
`static String` `INDEX_DELTA_NAME` File name template for index delta pages.
`static String` `PART_DELTA_TEMPLATE` File name template consists of delta pages.
`static String` `SNAPSHOT_METRICS` Snapshot metrics prefix.
`static String` `SNP_IN_PROGRESS_ERR_MSG` Snapshot in progress error message.
`static String` `SNP_NODE_STOPPING_ERR_MSG` Error message to finalize snapshot tasks.
`static String` `SNP_RUNNING_KEY` Metastorage key to save currently running snapshot.

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

`cctx, diagnosticLog, log`

### Constructor Summary

Constructors
Constructor and Description
`IgniteSnapshotManager(GridKernalContext ctx)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `cancelLocalSnapshotTask(String name)`
`IgniteFuture<Void>` `cancelSnapshot(String name)` Cancel running snapshot operation.
`IgniteFuture<Void>` `createSnapshot(String name)` Create a consistent copy of all persistence cache groups from the whole cluster.
`void` `deleteSnapshot(File snpDir, String folderName)`
`boolean` `isSnapshotCreating()`
`static boolean` `isSnapshotOperation(DiscoveryEvent evt)`
`List<String>` `localSnapshotNames()`
`void` `onCacheGroupsStopped(List<Integer> grps)`
`void` `onDoneBeforeTopologyUnlock(GridDhtPartitionsExchangeFuture fut)` Callback from exchange process completion; called before topology is unlocked.
`void` `onReadyForRead(ReadOnlyMetastorage metaStorage)` Is called when metastorage is made ready for read-only operations very early on node startup phase.
`void` `onReadyForReadWrite(ReadWriteMetastorage metaStorage)` Fully functional metastore capable of performing reading and writing operations.
`static File` `partDeltaFile(File snapshotCacheDir, int partId)`
`static String` `partDeltaFileName(int partId)`
`static File` `resolveSnapshotWorkDirectory(IgniteConfiguration cfg)`
`File` `snapshotLocalDir(String snpName)`
`File` `snapshotTmpDir()`
`protected void` `start0()`
`protected void` `stop0(boolean cancel)`

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

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

### Methods inherited from interface org.apache.ignite.internal.processors.cache.distributed.dht.preloader.PartitionsExchangeAware

`onDoneAfterTopologyUnlock, onInitAfterTopologyLock, onInitBeforeTopologyLock`

### Field Detail

#### DELTA_SUFFIX

    public static final String DELTA_SUFFIX

File with delta pages suffix.

See Also:
  Constant Field Values

#### PART_DELTA_TEMPLATE

    public static final String PART_DELTA_TEMPLATE

File name template consists of delta pages.

See Also:
  Constant Field Values

#### INDEX_DELTA_NAME

    public static final String INDEX_DELTA_NAME

File name template for index delta pages.

See Also:
  Constant Field Values

#### CP_SNAPSHOT_REASON

    public static final String CP_SNAPSHOT_REASON

Text Reason for checkpoint to start snapshot operation.

See Also:
  Constant Field Values

#### DFLT_SNAPSHOT_TMP_DIR

    public static final String DFLT_SNAPSHOT_TMP_DIR

Default snapshot directory for loading remote snapshots.

See Also:
  Constant Field Values

#### SNP_IN_PROGRESS_ERR_MSG

    public static final String SNP_IN_PROGRESS_ERR_MSG

Snapshot in progress error message.

See Also:
  Constant Field Values

#### SNP_NODE_STOPPING_ERR_MSG

    public static final String SNP_NODE_STOPPING_ERR_MSG

Error message to finalize snapshot tasks.

See Also:
  Constant Field Values

#### SNP_RUNNING_KEY

    public static final String SNP_RUNNING_KEY

Metastorage key to save currently running snapshot.

See Also:
  Constant Field Values

#### SNAPSHOT_METRICS

    public static final String SNAPSHOT_METRICS

Snapshot metrics prefix.

See Also:
  Constant Field Values

### Constructor Detail

#### IgniteSnapshotManager

    public IgniteSnapshotManager(GridKernalContext ctx)

Parameters:
  `ctx` - Kernal context.

### Method Detail

#### partDeltaFile

    public static File partDeltaFile(File snapshotCacheDir,
                                     int partId)

Parameters:
  `snapshotCacheDir` - Snapshot directory to store files.
  `partId` - Cache partition identifier.
Returns:
  A file representation.

#### partDeltaFileName

    public static String partDeltaFileName(int partId)

Parameters:
  `partId` - Partition id.
Returns:
  File name of delta partition pages.

#### start0

    protected void start0()
                   throws IgniteCheckedException

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

#### stop0

    protected void stop0(boolean cancel)

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

#### deleteSnapshot

    public void deleteSnapshot(File snpDir,
                               String folderName)

Parameters:
  `snpDir` - Snapshot dir.
  `folderName` - Local node folder name (see `IgniteUtils.maskForFileName(java.lang.CharSequence)` with consistent id).

#### snapshotLocalDir

    public File snapshotLocalDir(String snpName)

Parameters:
  `snpName` - Snapshot name.
Returns:
  Local snapshot directory for snapshot with given name.

#### snapshotTmpDir

    public File snapshotTmpDir()

Returns:
  Node snapshot working directory.

#### isSnapshotCreating

    public boolean isSnapshotCreating()

Returns:
  `True` if snapshot operation is in progress.

#### localSnapshotNames

    public List<String> localSnapshotNames()

Returns:
  List of all known snapshots on the local node.

#### cancelSnapshot

    public IgniteFuture<Void> cancelSnapshot(String name)

Cancel running snapshot operation. All intermediate results of cancelled snapshot operation will be deleted. If snapshot already created this command will have no effect.

Specified by:
  `cancelSnapshot` in interface `IgniteSnapshot`
Parameters:
  `name` - Snapshot name to cancel.
Returns:
  Future which will be completed when cancel operation finished.

#### cancelLocalSnapshotTask

    public void cancelLocalSnapshotTask(String name)

Parameters:
  `name` - Snapshot name to cancel operation on local node.

#### createSnapshot

    public IgniteFuture<Void> createSnapshot(String name)

Create a consistent copy of all persistence cache groups from the whole cluster.

Specified by:
  `createSnapshot` in interface `IgniteSnapshot`
Parameters:
  `name` - Snapshot unique name which satisfies the following name pattern [a-zA-Z0-9_].
Returns:
  Future which will be completed when a process ends.

#### onReadyForReadWrite

    public void onReadyForReadWrite(ReadWriteMetastorage metaStorage)
                             throws IgniteCheckedException

Fully functional metastore capable of performing reading and writing operations. Components interested in using metastore are allowed to keep reference passed into the method in their fields.

Specified by:
  `onReadyForReadWrite` in interface `MetastorageLifecycleListener`
Parameters:
  `metaStorage` - Fully functional meta storage.
Throws:
  `IgniteCheckedException`

#### onReadyForRead

    public void onReadyForRead(ReadOnlyMetastorage metaStorage)
                        throws IgniteCheckedException

Is called when metastorage is made ready for read-only operations very early on node startup phase. Reference for read-only metastorage should be used only within this method and shouldn't be stored to any field.

Specified by:
  `onReadyForRead` in interface `MetastorageLifecycleListener`
Parameters:
  `metaStorage` - Read-only meta storage.
Throws:
  `IgniteCheckedException`

#### isSnapshotOperation

    public static boolean isSnapshotOperation(DiscoveryEvent evt)

Parameters:
  `evt` - Discovery event to check.
Returns:
  `true` if exchange started by snapshot operation.

#### onDoneBeforeTopologyUnlock

    public void onDoneBeforeTopologyUnlock(GridDhtPartitionsExchangeFuture fut)

Callback from exchange process completion; called before topology is unlocked. Guarantees that no updates were performed on local node since exchange process started.

Specified by:
  `onDoneBeforeTopologyUnlock` in interface `PartitionsExchangeAware`
Parameters:
  `fut` - Partition map exchange future.

#### onCacheGroupsStopped

    public void onCacheGroupsStopped(List<Integer> grps)

Parameters:
  `grps` - List of cache groups which will be destroyed.

#### resolveSnapshotWorkDirectory

    public static File resolveSnapshotWorkDirectory(IgniteConfiguration cfg)

Parameters:
  `cfg` - Ignite configuration.
Returns:
  Snapshot directory resolved through given configuration.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.10.0
Release Date | : March 10 2021