public class SnapshotUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
SnapshotUtils.ReplSnapshotCount
Snapshot count holder.
|
static class |
SnapshotUtils.SnapshotCopyMode
Specifies the mode of copy when using Snapshots for replication.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
NEW_SNAPSHOT |
static String |
OLD_SNAPSHOT |
| Constructor and Description |
|---|
SnapshotUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
allowSnapshot(org.apache.hadoop.hdfs.DistributedFileSystem dfs,
org.apache.hadoop.fs.Path snapshotPath,
HiveConf conf)
Attempts to allow snapshots on the path, with retry.
|
static void |
cleanupSnapshots(org.apache.hadoop.fs.Path dumpRoot,
String snapshotPrefix,
HiveConf conf,
SnapshotUtils.ReplSnapshotCount snapshotCount,
boolean isLoad)
Cleans up any snapshots by computing diff between the list of snapshots between two replication dumps.
|
static void |
createSnapshot(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path snapshotPath,
String snapshotName,
HiveConf conf)
Attempts creating a snapshot, with retries.
|
static boolean |
deleteSnapshotIfExists(org.apache.hadoop.hdfs.DistributedFileSystem fs,
org.apache.hadoop.fs.Path snapshotPath,
String snapshotName,
HiveConf conf)
Attempts deleting a snapshot if it exists, with retries.
|
static boolean |
deleteSnapshotSafe(org.apache.hadoop.hdfs.DistributedFileSystem dfs,
org.apache.hadoop.fs.Path snapshotPath,
String snapshotName)
Attempts deleting a snapshot, if exists.
|
static void |
disallowSnapshot(org.apache.hadoop.hdfs.DistributedFileSystem dfs,
org.apache.hadoop.fs.Path snapshotPath)
Attempts to disallow snapshot on a path, ignoring exceptions.
|
static String |
firstSnapshot(String prefix)
Gets the name of the first snapshot, combined with the prefix.
|
static org.apache.hadoop.hdfs.DistributedFileSystem |
getDFS(org.apache.hadoop.fs.Path path,
HiveConf conf)
Gets a DistributedFileSystem object if possible from a path.
|
static ArrayList<String> |
getListFromFileList(FileList fl)
Extracts the entries from FileList into an ArrayList
|
static org.apache.hadoop.fs.Path |
getSnapshotFileListPath(org.apache.hadoop.fs.Path dumpRoot)
Gets the path where the snapshotfile needs to be created.
|
static boolean |
isSnapshotAvailable(org.apache.hadoop.hdfs.DistributedFileSystem dfs,
org.apache.hadoop.fs.Path path,
String snapshotPrefix,
String snapshotName,
HiveConf conf)
Checks whether a given snapshot exists or not.
|
static void |
renameSnapshot(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path snapshotPath,
String sourceSnapshotName,
String targetSnapshotName,
HiveConf conf)
Renames a snapshot with retries.
|
static String |
secondSnapshot(String prefix)
Gets the name of the second snapshot, combined with the prefix.
|
public static final String OLD_SNAPSHOT
public static final String NEW_SNAPSHOT
public static org.apache.hadoop.hdfs.DistributedFileSystem getDFS(org.apache.hadoop.fs.Path path,
HiveConf conf)
throws IOException
path - path from which DistributedFileSystem needs to be extracted.conf - Hive Configuration.IOExceptionpublic static boolean isSnapshotAvailable(org.apache.hadoop.hdfs.DistributedFileSystem dfs,
org.apache.hadoop.fs.Path path,
String snapshotPrefix,
String snapshotName,
HiveConf conf)
throws IOException
dfs - DistributedFileSystem.path - path of snapshot.snapshotPrefix - snapshot name prefix.snapshotName - name of snapshot.conf - Hive configuration.IOException - in case of any error.public static boolean deleteSnapshotSafe(org.apache.hadoop.hdfs.DistributedFileSystem dfs,
org.apache.hadoop.fs.Path snapshotPath,
String snapshotName)
throws IOException
dfs - DistributedFileSystemsnapshotPath - path of snapshotsnapshotName - name of the snapshotIOExceptionpublic static boolean deleteSnapshotIfExists(org.apache.hadoop.hdfs.DistributedFileSystem fs,
org.apache.hadoop.fs.Path snapshotPath,
String snapshotName,
HiveConf conf)
throws IOException
fs - FileSystem object.snapshotPath - Path of the snapshot.snapshotName - Name of the snapshot.conf - Hive Configuration.IOExceptionpublic static void disallowSnapshot(org.apache.hadoop.hdfs.DistributedFileSystem dfs,
org.apache.hadoop.fs.Path snapshotPath)
dfs - DistributedFileSystemsnapshotPath - path of snapshotpublic static void allowSnapshot(org.apache.hadoop.hdfs.DistributedFileSystem dfs,
org.apache.hadoop.fs.Path snapshotPath,
HiveConf conf)
throws IOException
dfs - DistributedFileSystem.snapshotPath - path of snapshot.conf - Hive Configuration.IOExceptionpublic static void createSnapshot(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path snapshotPath,
String snapshotName,
HiveConf conf)
throws IOException
fs - FileSystem object.snapshotPath - Path of the snapshot.snapshotName - Name of the snapshot.conf - Hive Configuration.IOExceptionpublic static void renameSnapshot(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path snapshotPath,
String sourceSnapshotName,
String targetSnapshotName,
HiveConf conf)
throws IOException
fs - the filesystem.snapshotPath - the path where the snapshot lies.sourceSnapshotName - current snapshot name.targetSnapshotName - new snapshot name.conf - configuration.IOException - in case of failure.public static ArrayList<String> getListFromFileList(FileList fl)
fl - the FileListpublic static void cleanupSnapshots(org.apache.hadoop.fs.Path dumpRoot,
String snapshotPrefix,
HiveConf conf,
SnapshotUtils.ReplSnapshotCount snapshotCount,
boolean isLoad)
throws IOException,
SemanticException
dumpRoot - Root of the dumpsnapshotPrefix - prefix used by the snapshotconf - Hive Configuration.snapshotCount - the counter to store number of deleted snapshots.isLoad - If this is called for clearing up snapshots at target cluster, In case of load it renames the
snapshot file as well.IOExceptionSemanticExceptionpublic static org.apache.hadoop.fs.Path getSnapshotFileListPath(org.apache.hadoop.fs.Path dumpRoot)
dumpRoot - the dumproot.public static String firstSnapshot(String prefix)
prefix - the prefix that needs to be attached to the default hive replication first snapshot name.Copyright © 2022 The Apache Software Foundation. All rights reserved.