@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.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription, org.apache.hadoop.fs.Path, org.apache.hadoop.fs.Path, org.apache.hadoop.fs.FileSystem)
, 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
|
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 |
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.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot,
org.apache.hadoop.fs.Path rootdir,
org.apache.hadoop.fs.Path workingDir,
org.apache.hadoop.fs.FileSystem fs)
Move the finished snapshot to its final, publicly visible directory - this marks the snapshot
as 'complete'.
|
private static org.apache.hadoop.fs.Path |
getCompletedSnapshotDir(org.apache.hadoop.fs.Path snapshotsDir,
String snapshotName)
Get the directory to store the snapshot instance
|
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.
|
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) |
static org.apache.hadoop.fs.Path |
getWorkingSnapshotDir(org.apache.hadoop.fs.Path rootDir)
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)
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)
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 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 long NO_SNAPSHOT_START_TIME_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)
rootDir
- root directory of the HBase installationpublic static org.apache.hadoop.fs.Path getWorkingSnapshotDir(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot, org.apache.hadoop.fs.Path rootDir)
snapshot
- snapshot that will be builtrootDir
- root directory of the hbase installationPath
where one can build a snapshotpublic static org.apache.hadoop.fs.Path getWorkingSnapshotDir(String snapshotName, org.apache.hadoop.fs.Path rootDir)
snapshotName
- name of the snapshotrootDir
- root directory of the hbase installationPath
where one can build a snapshotprivate static final org.apache.hadoop.fs.Path getCompletedSnapshotDir(org.apache.hadoop.fs.Path snapshotsDir, String snapshotName)
snapshotsDir
- hbase-global directory for storing all snapshotssnapshotName
- 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 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.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot, org.apache.hadoop.fs.Path rootdir, org.apache.hadoop.fs.Path workingDir, org.apache.hadoop.fs.FileSystem fs) throws SnapshotCreationException, IOException
snapshot
- description of the snapshot being tabkenrootdir
- root directory of the hbase installationworkingDir
- directory where the in progress snapshot was builtfs
- FileSystem
where the snapshot was builtSnapshotCreationException
- 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–2019 The Apache Software Foundation. All rights reserved.