@InterfaceAudience.Private public final class SnapshotDescriptionUtils extends Object
SnapshotDesriptions
.
Snapshots are laid out on disk like this:
/hbase/.snapshots /.tmp <---- working directory /[snapshot name] <----- completed snapshotA completed snapshot named 'completed' then looks like (multiple regions, servers, files, etc. signified by '...' on the same directory depth).
/hbase/.snapshots/completed .snapshotinfo <--- Description of the snapshot .tableinfo <--- Copy of the tableinfo /.logs /[server_name] /... [log files] ... /[region name] <---- All the region's information .regioninfo <---- Copy of the HRegionInfo /[column family name] /[hfile name] <--- name of the hfile in the real region ... ... ...Utility methods in this class are useful for getting the correct locations for different parts of the snapshot, as well as moving completed snapshots into place (see
completeSnapshot(org.apache.hadoop.fs.Path, org.apache.hadoop.fs.Path, org.apache.hadoop.fs.FileSystem, org.apache.hadoop.fs.FileSystem, org.apache.hadoop.conf.Configuration)
, and writing the
SnapshotProtos.SnapshotDescription
to the working snapshot directory.Modifier and Type | Class and Description |
---|---|
static class |
SnapshotDescriptionUtils.CompletedSnaphotDirectoriesFilter
Filter that only accepts completed snapshot directories
|
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_MAX_WAIT_TIME
By default, wait 300 seconds for a snapshot to complete
|
private static org.slf4j.Logger |
LOG |
static String |
MASTER_SNAPSHOT_TIMEOUT_MILLIS |
static long |
NO_SNAPSHOT_START_TIME_SPECIFIED
Default value if no start time is specified
|
private static long |
NO_SNAPSHOT_TTL_SPECIFIED |
static int |
SNAPSHOT_LAYOUT_VERSION
Version of the fs layout for a snapshot.
|
static int |
SNAPSHOT_TIMEOUT_MILLIS_DEFAULT
Deprecated.
Use
DEFAULT_MAX_WAIT_TIME instead. |
static String |
SNAPSHOT_TIMEOUT_MILLIS_KEY
Deprecated.
Use
MASTER_SNAPSHOT_TIMEOUT_MILLIS instead. |
static String |
SNAPSHOT_TMP_DIR_NAME
Temporary directory under the snapshot directory to store in-progress snapshots
|
static String |
SNAPSHOT_WORKING_DIR
The configuration property that determines the filepath of the snapshot
base working directory
|
static String |
SNAPSHOTINFO_FILE
The file contains the snapshot basic information and it is under the directory of a snapshot.
|
Modifier | Constructor and Description |
---|---|
private |
SnapshotDescriptionUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
completeSnapshot(org.apache.hadoop.fs.Path snapshotDir,
org.apache.hadoop.fs.Path workingDir,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.FileSystem workingDirFs,
org.apache.hadoop.conf.Configuration conf)
Commits the snapshot process by moving the working snapshot
to the finalized filepath
|
static org.apache.hadoop.fs.Path |
getCompletedSnapshotDir(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot,
org.apache.hadoop.fs.Path rootDir)
Get the directory for a specified snapshot.
|
static org.apache.hadoop.fs.Path |
getCompletedSnapshotDir(String snapshotName,
org.apache.hadoop.fs.Path rootDir)
Get the directory for a completed snapshot.
|
private static org.apache.hadoop.fs.Path |
getDefaultWorkingSnapshotDir(org.apache.hadoop.fs.Path rootDir)
Get the default working directory for snapshots - where they are built, where they are
temporarily copied on export, etc.
|
static long |
getMaxMasterTimeout(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription.Type type,
long defaultMaxWaitTime) |
static org.apache.hadoop.fs.Path |
getSnapshotRootDir(org.apache.hadoop.fs.Path rootDir)
Get the snapshot root directory.
|
static org.apache.hadoop.fs.Path |
getSnapshotsDir(org.apache.hadoop.fs.Path rootDir) |
private static org.apache.hadoop.fs.Path |
getSpecifiedSnapshotDir(org.apache.hadoop.fs.Path snapshotsDir,
String snapshotName)
Get the directory within the given filepath to store the snapshot instance
|
static org.apache.hadoop.fs.Path |
getWorkingSnapshotDir(org.apache.hadoop.fs.Path rootDir,
org.apache.hadoop.conf.Configuration conf)
Get the general working directory for snapshots - where they are built, where they are
temporarily copied on export, etc.
|
static org.apache.hadoop.fs.Path |
getWorkingSnapshotDir(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot,
org.apache.hadoop.fs.Path rootDir,
org.apache.hadoop.conf.Configuration conf)
Get the directory to build a snapshot, before it is finalized
|
static org.apache.hadoop.fs.Path |
getWorkingSnapshotDir(String snapshotName,
org.apache.hadoop.fs.Path rootDir,
org.apache.hadoop.conf.Configuration conf)
Get the directory to build a snapshot, before it is finalized
|
static boolean |
isSecurityAvailable(org.apache.hadoop.conf.Configuration conf) |
static boolean |
isSnapshotOwner(SnapshotDescription snapshot,
User user)
Check if the user is this table snapshot's owner
|
static boolean |
isSubDirectoryOf(org.apache.hadoop.fs.Path workingDir,
org.apache.hadoop.fs.Path rootDir)
Determines if the given workingDir is a subdirectory of the given "root directory"
|
static boolean |
isWithinDefaultWorkingDir(org.apache.hadoop.fs.Path workingDir,
org.apache.hadoop.conf.Configuration conf)
Determines if the given workingDir is a subdirectory of the default working snapshot directory
|
static org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription |
readSnapshotInfo(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path snapshotDir)
Read in the
HBaseProtos.SnapshotDescription stored for the snapshot in the passed directory |
static org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription |
validate(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot,
org.apache.hadoop.conf.Configuration conf)
Convert the passed snapshot description into a 'full' snapshot description based on default
parameters, if none have been supplied.
|
private static org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription |
writeAclToSnapshotDescription(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot,
org.apache.hadoop.conf.Configuration conf) |
static void |
writeSnapshotInfo(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot,
org.apache.hadoop.fs.Path workingDir,
org.apache.hadoop.fs.FileSystem fs)
Write the snapshot description into the working directory of a snapshot
|
private static final org.slf4j.Logger LOG
public static final int SNAPSHOT_LAYOUT_VERSION
public static final String SNAPSHOTINFO_FILE
public static final String SNAPSHOT_TMP_DIR_NAME
public static final String SNAPSHOT_WORKING_DIR
public static final long NO_SNAPSHOT_START_TIME_SPECIFIED
private static final long NO_SNAPSHOT_TTL_SPECIFIED
public static final String MASTER_SNAPSHOT_TIMEOUT_MILLIS
public static final long DEFAULT_MAX_WAIT_TIME
@Deprecated public static final int SNAPSHOT_TIMEOUT_MILLIS_DEFAULT
DEFAULT_MAX_WAIT_TIME
instead.@Deprecated public static final String SNAPSHOT_TIMEOUT_MILLIS_KEY
MASTER_SNAPSHOT_TIMEOUT_MILLIS
instead.private SnapshotDescriptionUtils()
public static long getMaxMasterTimeout(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription.Type type, long defaultMaxWaitTime)
conf
- Configuration
from which to check for the timeouttype
- type of snapshot being takendefaultMaxWaitTime
- Default amount of time to wait, if none is in the configurationpublic static org.apache.hadoop.fs.Path getSnapshotRootDir(org.apache.hadoop.fs.Path rootDir)
rootDir
- hbase root directorypublic static org.apache.hadoop.fs.Path getCompletedSnapshotDir(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot, org.apache.hadoop.fs.Path rootDir)
snapshot
- snapshot being takenrootDir
- hbase root directorypublic static org.apache.hadoop.fs.Path getCompletedSnapshotDir(String snapshotName, org.apache.hadoop.fs.Path rootDir)
snapshotName
- name of the snapshot being takenrootDir
- hbase root directorypublic static org.apache.hadoop.fs.Path getWorkingSnapshotDir(org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.conf.Configuration conf)
rootDir
- root directory of the HBase installationconf
- Configuration of the HBase instancepublic static org.apache.hadoop.fs.Path getWorkingSnapshotDir(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.conf.Configuration conf)
snapshot
- snapshot that will be builtrootDir
- root directory of the hbase installationconf
- Configuration of the HBase instancePath
where one can build a snapshotpublic static org.apache.hadoop.fs.Path getWorkingSnapshotDir(String snapshotName, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.conf.Configuration conf)
snapshotName
- name of the snapshotrootDir
- root directory of the hbase installationconf
- Configuration of the HBase instancePath
where one can build a snapshotprivate static final org.apache.hadoop.fs.Path getSpecifiedSnapshotDir(org.apache.hadoop.fs.Path snapshotsDir, String snapshotName)
snapshotsDir
- directory to store snapshot directory withinsnapshotName
- name of the snapshot to takepublic static final org.apache.hadoop.fs.Path getSnapshotsDir(org.apache.hadoop.fs.Path rootDir)
rootDir
- hbase root directorypublic static boolean isSubDirectoryOf(org.apache.hadoop.fs.Path workingDir, org.apache.hadoop.fs.Path rootDir)
workingDir
- a directory to checkrootDir
- root directory of the HBase installationpublic static boolean isWithinDefaultWorkingDir(org.apache.hadoop.fs.Path workingDir, org.apache.hadoop.conf.Configuration conf) throws IOException
workingDir
- a directory to checkconf
- configuration for the HBase clusterIOException
- if we can't get the root dirprivate static org.apache.hadoop.fs.Path getDefaultWorkingSnapshotDir(org.apache.hadoop.fs.Path rootDir)
rootDir
- root directory of the HBase installationpublic static org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription validate(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot, org.apache.hadoop.conf.Configuration conf) throws IllegalArgumentException, IOException
snapshot
- general snapshot descriptorconf
- Configuration to read configured snapshot defaults if snapshot is not completeIllegalArgumentException
- if the SnapshotProtos.SnapshotDescription
is not a complete
SnapshotProtos.SnapshotDescription
.IOException
public static void writeSnapshotInfo(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot, org.apache.hadoop.fs.Path workingDir, org.apache.hadoop.fs.FileSystem fs) throws IOException
snapshot
- description of the snapshot being takenworkingDir
- working directory of the snapshotfs
- FileSystem
on which the snapshot should be takenIOException
- if we can't reach the filesystem and the file cannot be cleaned up on
failurepublic static org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription readSnapshotInfo(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path snapshotDir) throws CorruptedSnapshotException
HBaseProtos.SnapshotDescription
stored for the snapshot in the passed directoryfs
- filesystem where the snapshot was takensnapshotDir
- directory where the snapshot was storedCorruptedSnapshotException
- if the
snapshot cannot be readpublic static void completeSnapshot(org.apache.hadoop.fs.Path snapshotDir, org.apache.hadoop.fs.Path workingDir, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.FileSystem workingDirFs, org.apache.hadoop.conf.Configuration conf) throws SnapshotCreationException, IOException
snapshotDir
- The file path of the completed snapshotsworkingDir
- The file path of the in progress snapshotsfs
- The file system of the completed snapshotsworkingDirFs
- The file system of the in progress snapshotsconf
- ConfigurationSnapshotCreationException
- if the snapshot could not be movedIOException
- the filesystem could not be reachedpublic static boolean isSnapshotOwner(SnapshotDescription snapshot, User user)
snapshot
- the table snapshot descriptionuser
- the userpublic static boolean isSecurityAvailable(org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
private static org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription writeAclToSnapshotDescription(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot, org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.