public class IgniteSnapshotManager extends GridCacheSharedManagerAdapter implements IgniteSnapshot, PartitionsExchangeAware, MetastorageLifecycleListener, IgniteChangeGlobalStateSupport
These major actions available:
| Modifier and Type | Class and Description |
|---|---|
static class |
IgniteSnapshotManager.ClusterSnapshotFuture |
protected static class |
IgniteSnapshotManager.SnapshotHandlers
Snapshot operation handlers.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
CP_SNAPSHOT_REASON
Text Reason for checkpoint to start snapshot operation.
|
static String |
DELTA_IDX_SUFFIX
File with delta pages index suffix.
|
static String |
DELTA_SUFFIX
File with delta pages suffix.
|
static boolean |
DFLT_CHECK_ON_RESTORE
Default value of check flag.
|
static boolean |
DFLT_IGNITE_SNAPSHOT_SEQUENTIAL_WRITE
Default value of
IgniteSystemProperties.IGNITE_SNAPSHOT_SEQUENTIAL_WRITE. |
static String |
DFLT_SNAPSHOT_TMP_DIR
Default snapshot directory for loading remote snapshots.
|
static long |
DFLT_SNAPSHOT_TRANSFER_RATE_BYTES
Snapshot transfer rate is unlimited by default.
|
static String |
INC_SNP_DIR
Incremental snapshots directory name.
|
static Pattern |
INC_SNP_NAME_PATTERN
Pattern for incremental snapshot directory names.
|
static String |
INCREMENTAL_SNAPSHOT_METRICS
Incremental snapshot metrics prefix.
|
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 |
RMT_SNAPSHOT_PREFIX
Name prefix for each remote snapshot operation.
|
static int |
SNAPSHOT_LIMITED_TRANSFER_BLOCK_SIZE_BYTES
Maximum block size for limited snapshot transfer (64KB by default).
|
static String |
SNAPSHOT_METAFILE_EXT
Snapshot metafile extension.
|
static String |
SNAPSHOT_METAFILE_TMP_EXT
Snapshot temporary metafile extension.
|
static String |
SNAPSHOT_METRICS
Snapshot metrics prefix.
|
static String |
SNAPSHOT_RUNNER_THREAD_PREFIX
Prefix for snapshot threads.
|
static String |
SNAPSHOT_TRANSFER_RATE_DMS_KEY
Snapshot transfer rate distributed configuration key
|
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.
|
cctx, diagnosticLog, log| Constructor and Description |
|---|
IgniteSnapshotManager(GridKernalContext ctx) |
| Modifier and Type | Method and Description |
|---|---|
static String |
cacheChangedException(int cacheId,
String name)
Throw cache changed exception.
|
Set<UUID> |
cacheStartRequiredAliveNodes(@Nullable IgniteUuid restoreId) |
IgniteFuture<Boolean> |
cancelLocalRestoreTask(String name)
Deprecated.
Use
cancelLocalSnapshotOperations(UUID) instead. |
boolean |
cancelLocalSnapshotTask(String name) |
IgniteFuture<Void> |
cancelSnapshot(String name)
Cancel running snapshot operation.
|
IgniteFuture<Boolean> |
cancelSnapshotOperation(UUID reqId) |
IgniteFuture<Boolean> |
cancelSnapshotRestore(String name)
Cancel snapshot restore operation.
|
IgniteInternalFuture<SnapshotPartitionsVerifyTaskResult> |
checkSnapshot(String name,
@Nullable String snpPath)
Checks snapshot.
|
IgniteInternalFuture<SnapshotPartitionsVerifyTaskResult> |
checkSnapshot(String name,
@Nullable String snpPath,
@Nullable Collection<String> grps,
boolean includeCustomHandlers,
int incIdx,
boolean check)
The check snapshot procedure performs compute operation over the whole cluster to verify the snapshot
entirety and partitions consistency.
|
IgniteInternalFuture<SnapshotPartitionsVerifyTaskResult> |
checkSnapshot(String name,
@Nullable String snpPath,
int incIdx)
Checks snapshot and its increments.
|
IgniteFuture<Void> |
createIncrementalSnapshot(String name)
Create an incremental snapshot for an existing snapshot.
|
IgniteFuture<Void> |
createSnapshot(String name)
Create a consistent copy of all persistence cache groups from the whole cluster.
|
IgniteFutureImpl<Void> |
createSnapshot(String name,
@Nullable String snpPath,
boolean incremental,
boolean onlyPrimary)
Create a consistent copy of all persistence cache groups from the whole cluster.
|
StandaloneGridKernalContext |
createStandaloneKernalContext(CompressionProcessor cmpProc,
File snpDir,
String folderName) |
@Nullable SnapshotOperationRequest |
currentCreateRequest() |
void |
deleteSnapshot(File snpDir,
String folderName) |
void |
disableIncrementalSnapshotsCreation(MetaStorage metaStorage,
int grpId)
Disables creation of incremental snapshots for the given cache group.
|
void |
handleIncrementalSnapshotId(UUID id,
long topVer)
Handles received incremental snapshot ID from remote node.
|
protected IgniteSnapshotManager.SnapshotHandlers |
handlers() |
static String |
incrementalSnapshotCreationDisabledKey(int grpId)
Convert cache group ID to key for
INC_SNP_DISABLED_KEY_PREFIX metastorage records. |
@Nullable UUID |
incrementalSnapshotId() |
File |
incrementalSnapshotLocalDir(String snpName,
@Nullable String snpPath,
int incIdx)
Returns path to specific incremental snapshot.
|
File |
incrementalSnapshotsLocalRootDir(String snpName,
@Nullable String snpPath)
Returns root folder for incremental snapshot.
|
static File |
incrementalSnapshotWalsDir(File incSnpDir,
String consId) |
FileIOFactory |
ioFactory() |
void |
ioFactory(FileIOFactory ioFactory) |
boolean |
isRestoring()
Check if snapshot restore process is currently running.
|
boolean |
isRestoring(CacheConfiguration<?,?> ccfg)
Check if the cache or group with the specified name is currently being restored from the snapshot.
|
boolean |
isRestoring(String snpName)
Check if snapshot restore process is currently running.
|
boolean |
isSnapshotCreating() |
static boolean |
isSnapshotOperation(DiscoveryEvent evt) |
List<String> |
localSnapshotNames(@Nullable String snpPath) |
void |
onActivate(GridKernalContext kctx)
Called when cluster performing activation.
|
void |
onCacheGroupsStopped(List<Integer> grps) |
void |
onDeActivate(GridKernalContext kctx)
Called when cluster performing deactivation.
|
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 |
partDeltaIndexFile(File delta)
Partition delta index file.
|
GridCloseableIterator<CacheDataRow> |
partitionRowIterator(GridKernalContext ctx,
String grpName,
int partId,
FilePageStore pageStore) |
GridCloseableIterator<CacheDataRow> |
partitionRowIterator(String snpName,
String folderName,
String grpName,
int partId,
@Nullable EncryptionCacheKeyProvider encrKeyProvider) |
<T> T |
readFromFile(File smf) |
IncrementalSnapshotMetadata |
readIncrementalSnapshotMetadata(String snpName,
@Nullable String snpPath,
int incIdx) |
Collection<IncrementalSnapshotMetadata> |
readIncrementalSnapshotMetadatas(String snpName) |
SnapshotMetadata |
readSnapshotMetadata(File snpDir,
String consId) |
List<SnapshotMetadata> |
readSnapshotMetadatas(String snpName,
@Nullable String snpPath) |
IgniteInternalFuture<Void> |
requestRemoteSnapshotFiles(UUID rmtNodeId,
UUID reqId,
String snpName,
@Nullable String rmtSnpPath,
Map<Integer,Set<Integer>> parts,
BooleanSupplier stopChecker,
BiConsumer<File,Throwable> partHnd) |
static File |
resolveSnapshotWorkDirectory(IgniteConfiguration cfg) |
IgniteFuture<Void> |
restoreSnapshot(String name,
@Nullable Collection<String> grpNames)
Restore cache group(s) from the snapshot.
|
IgniteFuture<Void> |
restoreSnapshot(String name,
@Nullable Collection<String> grpNames,
int incIdx)
Restore cache group(s) from the snapshot and its increments.
|
IgniteFutureImpl<Void> |
restoreSnapshot(String name,
@Nullable String snpPath,
@Nullable Collection<String> grpNames)
Restore cache group(s) from the snapshot.
|
IgniteFutureImpl<Void> |
restoreSnapshot(String name,
@Nullable String snpPath,
@Nullable Collection<String> grpNames,
int incIdx,
boolean check)
Restore cache group(s) from the snapshot.
|
IgniteFuture<Boolean> |
restoreStatus(String snpName)
Status of the restore operation cluster-wide.
|
boolean |
sequentialWrite() |
List<File> |
snapshotCacheDirectories(String snpName,
@Nullable String snpPath,
String folderName,
Predicate<String> names) |
File |
snapshotLocalDir(String snpName) |
File |
snapshotLocalDir(String snpName,
@Nullable String snpPath) |
static String |
snapshotMetaFileName(String consId) |
File |
snapshotTmpDir() |
protected void |
start0() |
protected void |
stop0(boolean cancel) |
<M extends Serializable> |
storeSnapshotMeta(M meta,
File smf)
Stores snapshot metadata.
|
void |
streamerWarning()
Sets the streamer warning flag to current snapshot process if it is active.
|
void |
writeSnapshotDirectoryToMetastorage(File snpLocDir) |
context, isStopping, kernalStartInfo, kernalStopInfo, log, onDisconnected, onKernalStart, onKernalStart0, onKernalStop, onKernalStop0, onReconnected, printMemoryStats, start, startInfo, stop, stopInfo, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitonDoneAfterTopologyUnlock, onInitAfterTopologyLock, onInitBeforeTopologyLockpublic static final String DELTA_SUFFIX
public static final String DELTA_IDX_SUFFIX
public static final String PART_DELTA_TEMPLATE
public static final String INDEX_DELTA_NAME
public static final String CP_SNAPSHOT_REASON
public static final String RMT_SNAPSHOT_PREFIX
public static final String DFLT_SNAPSHOT_TMP_DIR
public static final String SNP_IN_PROGRESS_ERR_MSG
public static final String SNP_NODE_STOPPING_ERR_MSG
public static final String SNAPSHOT_METRICS
public static final String INCREMENTAL_SNAPSHOT_METRICS
public static final String SNAPSHOT_METAFILE_EXT
public static final String SNAPSHOT_METAFILE_TMP_EXT
public static final String SNAPSHOT_RUNNER_THREAD_PREFIX
public static final String SNAPSHOT_TRANSFER_RATE_DMS_KEY
public static final long DFLT_SNAPSHOT_TRANSFER_RATE_BYTES
public static final int SNAPSHOT_LIMITED_TRANSFER_BLOCK_SIZE_BYTES
public static final boolean DFLT_IGNITE_SNAPSHOT_SEQUENTIAL_WRITE
IgniteSystemProperties.IGNITE_SNAPSHOT_SEQUENTIAL_WRITE.public static final boolean DFLT_CHECK_ON_RESTORE
public static final String INC_SNP_DIR
public static final Pattern INC_SNP_NAME_PATTERN
public IgniteSnapshotManager(GridKernalContext ctx)
ctx - Kernal context.public static File partDeltaFile(File snapshotCacheDir, int partId)
snapshotCacheDir - Snapshot directory to store files.partId - Cache partition identifier.public static File partDeltaIndexFile(File delta)
delta - File with delta pages.public static String partDeltaFileName(int partId)
partId - Partition id.protected void start0()
throws IgniteCheckedException
start0 in class GridCacheSharedManagerAdapterIgniteCheckedException - If failed.protected void stop0(boolean cancel)
stop0 in class GridCacheSharedManagerAdaptercancel - Cancel flag.public void onActivate(GridKernalContext kctx)
onActivate in interface IgniteChangeGlobalStateSupportkctx - Kernal context.public void onDeActivate(GridKernalContext kctx)
onDeActivate in interface IgniteChangeGlobalStateSupportkctx - Kernal context.public void deleteSnapshot(File snpDir, String folderName)
snpDir - Snapshot dir.folderName - Local node folder name (see IgniteUtils.maskForFileName(java.lang.CharSequence) with consistent id).public File snapshotLocalDir(String snpName)
snpName - Snapshot name.public File snapshotLocalDir(String snpName, @Nullable @Nullable String snpPath)
snpName - Snapshot name.snpPath - Snapshot directory path.public File incrementalSnapshotLocalDir(String snpName, @Nullable @Nullable String snpPath, int incIdx)
"work/snapshots/mybackup/increments/0000000000000001".snpName - Snapshot name.snpPath - Snapshot directory path.incIdx - Increment index.public File incrementalSnapshotsLocalRootDir(String snpName, @Nullable @Nullable String snpPath)
"work/snapshots/mybackup/increments/".snpName - Snapshot name.snpPath - Snapshot directory path.public static File incrementalSnapshotWalsDir(File incSnpDir, String consId)
incSnpDir - Incremental snapshot directory.consId - Consistent ID.public File snapshotTmpDir()
public void handleIncrementalSnapshotId(UUID id, long topVer)
id - Incremental snapshot ID.topVer - Incremental snapshot topology version.public IncrementalSnapshotMetadata readIncrementalSnapshotMetadata(String snpName, @Nullable @Nullable String snpPath, int incIdx) throws IgniteCheckedException, IOException
snpName - Full snapshot name.snpPath - Optional path to snapshot, if differs from default.incIdx - Index of incremental snapshot.IgniteCheckedExceptionIOExceptionpublic <M extends Serializable> void storeSnapshotMeta(M meta, File smf)
meta - Metadata to store.smf - File to store.public boolean isSnapshotCreating()
True if snapshot operation is in progress.public void streamerWarning()
@Nullable public @Nullable SnapshotOperationRequest currentCreateRequest()
Null if there is no create snapshot operation in progress.public boolean isRestoring()
True if the snapshot restore operation is in progress.public boolean isRestoring(String snpName)
snpName - Snapshot name.True if the snapshot restore operation from the specified snapshot is in progress locally.public boolean isRestoring(CacheConfiguration<?,?> ccfg)
ccfg - Cache configuration.True if the cache or group with the specified name is being restored.public IgniteFuture<Boolean> restoreStatus(String snpName)
snpName - Snapshot name.false if the restore process with the specified snapshot name is
not running on all nodes.public boolean sequentialWrite()
True if disk writes during snapshot process should be in a sequential manner when possible.public Set<UUID> cacheStartRequiredAliveNodes(@Nullable @Nullable IgniteUuid restoreId)
restoreId - Restore process ID.public List<String> localSnapshotNames(@Nullable @Nullable String snpPath)
public IgniteFuture<Void> cancelSnapshot(String name)
cancelSnapshot in interface IgniteSnapshotname - Snapshot name to cancel.public IgniteFuture<Boolean> cancelSnapshotOperation(UUID reqId)
reqId - Snapshot operation request ID.public boolean cancelLocalSnapshotTask(String name)
name - Snapshot name to cancel operation on local node.True if the snapshot operation was canceled.public IgniteFuture<Boolean> cancelSnapshotRestore(String name)
cancelSnapshotRestore in interface IgniteSnapshotname - Snapshot name.false if the restore process with the specified snapshot name is not running at all.@Deprecated public IgniteFuture<Boolean> cancelLocalRestoreTask(String name)
cancelLocalSnapshotOperations(UUID) instead.name - Snapshot name.false if the restore process with the specified snapshot name is not running at all.public IgniteInternalFuture<SnapshotPartitionsVerifyTaskResult> checkSnapshot(String name, @Nullable @Nullable String snpPath)
name - Snapshot name.snpPath - Snapshot directory path.IdleVerifyResultV2 also contains the snapshot metadata distribution across the cluster.public IgniteInternalFuture<SnapshotPartitionsVerifyTaskResult> checkSnapshot(String name, @Nullable @Nullable String snpPath, int incIdx)
name - Snapshot name.snpPath - Snapshot directory path.incIdx - Incremental snapshot index.IdleVerifyResultV2 also contains the snapshot metadata distribution across the cluster.public IgniteInternalFuture<SnapshotPartitionsVerifyTaskResult> checkSnapshot(String name, @Nullable @Nullable String snpPath, @Nullable @Nullable Collection<String> grps, boolean includeCustomHandlers, int incIdx, boolean check)
IdleVerifyResult.name - Snapshot name.snpPath - Snapshot directory path.grps - Collection of cache group names to check.includeCustomHandlers - True to invoke all user-defined SnapshotHandlerType.RESTORE
handlers, otherwise only system consistency check will be performed.incIdx - Incremental snapshot index.check - If true check snapshot integrity.IdleVerifyResultV2 also contains the snapshot metadata distribution across the cluster.public List<File> snapshotCacheDirectories(String snpName, @Nullable @Nullable String snpPath, String folderName, Predicate<String> names)
snpName - Snapshot name.folderName - The name of a directory for the cache group.names - Cache group names to filter.public SnapshotMetadata readSnapshotMetadata(File snpDir, String consId) throws IgniteCheckedException, IOException
snpDir - The full path to the snapshot files.consId - Node consistent id to read metadata for.IgniteCheckedExceptionIOExceptionpublic <T> T readFromFile(File smf) throws IgniteCheckedException, IOException
T - Type of metadata.smf - File to read.IgniteCheckedExceptionIOExceptionpublic List<SnapshotMetadata> readSnapshotMetadatas(String snpName, @Nullable @Nullable String snpPath)
snpName - Snapshot name.snpPath - Snapshot directory path.public Collection<IncrementalSnapshotMetadata> readIncrementalSnapshotMetadatas(String snpName)
snpName - Snapshot name.public IgniteFuture<Void> createSnapshot(String name)
createSnapshot in interface IgniteSnapshotname - Snapshot unique name which satisfies the following name pattern [a-zA-Z0-9_].public IgniteFuture<Void> createIncrementalSnapshot(String name)
createIncrementalSnapshot in interface IgniteSnapshotname - Snapshot name.public IgniteFutureImpl<Void> createSnapshot(String name, @Nullable @Nullable String snpPath, boolean incremental, boolean onlyPrimary)
name - Snapshot unique name which satisfies the following name pattern [a-zA-Z0-9_].snpPath - Snapshot directory path.incremental - Incremental snapshot flag.onlyPrimary - If true snapshot only primary copies of partitions.public IgniteFuture<Void> restoreSnapshot(String name, @Nullable @Nullable Collection<String> grpNames)
NOTE: Cache groups to be restored from the snapshot must not present in the cluster, if they present,
they must be destroyed by the user (eg with IgniteCache.destroy()) before starting this operation.
restoreSnapshot in interface IgniteSnapshotname - Snapshot name.grpNames - Cache groups to be restored or null to restore all cache groups from the snapshot.public IgniteFuture<Void> restoreSnapshot(String name, @Nullable @Nullable Collection<String> grpNames, int incIdx)
1 to the specified incIdx.
NOTE: Cache groups to be restored from the snapshot must not present in the cluster, if they present,
they must be destroyed by the user (eg with IgniteCache.destroy()) before starting this operation.
restoreSnapshot in interface IgniteSnapshotname - Snapshot name.grpNames - Cache groups to be restored or null to restore all cache groups from the snapshot.incIdx - Index of incremental snapshot.public IgniteFutureImpl<Void> restoreSnapshot(String name, @Nullable @Nullable String snpPath, @Nullable @Nullable Collection<String> grpNames)
name - Snapshot name.snpPath - Snapshot directory path.grpNames - Cache groups to be restored or null to restore all cache groups from the snapshot.public IgniteFutureImpl<Void> restoreSnapshot(String name, @Nullable @Nullable String snpPath, @Nullable @Nullable Collection<String> grpNames, int incIdx, boolean check)
name - Snapshot name.snpPath - Snapshot directory path.grpNames - Cache groups to be restored or null to restore all cache groups from the snapshot.incIdx - Index of incremental snapshot.check - If true check snapshot before restore.public void onReadyForReadWrite(ReadWriteMetastorage metaStorage) throws IgniteCheckedException
onReadyForReadWrite in interface MetastorageLifecycleListenermetaStorage - Fully functional meta storage.IgniteCheckedExceptionpublic void onReadyForRead(ReadOnlyMetastorage metaStorage) throws IgniteCheckedException
onReadyForRead in interface MetastorageLifecycleListenermetaStorage - Read-only meta storage.IgniteCheckedExceptionpublic static boolean isSnapshotOperation(DiscoveryEvent evt)
evt - Discovery event to check.true if exchange started by snapshot operation.public void onDoneBeforeTopologyUnlock(GridDhtPartitionsExchangeFuture fut)
onDoneBeforeTopologyUnlock in interface PartitionsExchangeAwarefut - Partition map exchange future.public IgniteInternalFuture<Void> requestRemoteSnapshotFiles(UUID rmtNodeId, UUID reqId, String snpName, @Nullable @Nullable String rmtSnpPath, Map<Integer,Set<Integer>> parts, BooleanSupplier stopChecker, BiConsumer<File,Throwable> partHnd) throws IgniteCheckedException
rmtNodeId - The remote node to connect to.reqId - Snapshot operation request ID.snpName - Snapshot name to request.rmtSnpPath - Snapshot directory path on the remote node.parts - Collection of pairs group and appropriate cache partition to be snapshot.stopChecker - Node stop or process interrupt checker.partHnd - Received partition handler.IgniteCheckedExceptionpublic void onCacheGroupsStopped(List<Integer> grps)
grps - List of cache groups which will be destroyed.public static String snapshotMetaFileName(String consId)
consId - Consistent node id.public StandaloneGridKernalContext createStandaloneKernalContext(CompressionProcessor cmpProc, File snpDir, String folderName) throws IgniteCheckedException
snpDir - The full path to the snapshot files.folderName - The node folder name, usually it's the same as the U.maskForFileName(consistentId).IgniteCheckedException - If fails.public GridCloseableIterator<CacheDataRow> partitionRowIterator(GridKernalContext ctx, String grpName, int partId, FilePageStore pageStore) throws IgniteCheckedException
grpName - Cache group name.partId - Partition id.pageStore - File page store to iterate over.IgniteCheckedException - If and error occurs.public GridCloseableIterator<CacheDataRow> partitionRowIterator(String snpName, String folderName, String grpName, int partId, @Nullable @Nullable EncryptionCacheKeyProvider encrKeyProvider) throws IgniteCheckedException
snpName - Snapshot name.folderName - The node folder name, usually it's the same as the U.maskForFileName(consistentId).grpName - Cache group name.partId - Partition id.encrKeyProvider - Encryption keys provider to create encrypted IO. If null, no encrypted IO is used.IgniteCheckedException - If and error occurs.public void writeSnapshotDirectoryToMetastorage(File snpLocDir)
snpLocDir - Snapshot local directory.public void disableIncrementalSnapshotsCreation(MetaStorage metaStorage, int grpId)
metaStorage - External metastorage, useful if the flag is set before cluster activation.grpId - Group ID.public static String incrementalSnapshotCreationDisabledKey(int grpId)
INC_SNP_DISABLED_KEY_PREFIX metastorage records.grpId - Group ID.public void ioFactory(FileIOFactory ioFactory)
ioFactory - Factory to create IO interface over a page stores.public FileIOFactory ioFactory()
public static File resolveSnapshotWorkDirectory(IgniteConfiguration cfg)
cfg - Ignite configuration.public static String cacheChangedException(int cacheId, String name)
cacheId - Cache id.name - Cache name.protected IgniteSnapshotManager.SnapshotHandlers handlers()
@Nullable public @Nullable UUID incrementalSnapshotId()
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.15.0 Release Date : April 25 2023