public 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.protobuf.generated.HBaseProtos.SnapshotDescription, Path, Path, FileSystem)
, and writing the
HBaseProtos.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
|
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 and Type | Method and Description |
---|---|
static void |
completeSnapshot(HBaseProtos.SnapshotDescription snapshot,
Path rootdir,
Path workingDir,
FileSystem fs)
Move the finished snapshot to its final, publicly visible directory - this marks the snapshot
as 'complete'.
|
static Path |
getCompletedSnapshotDir(HBaseProtos.SnapshotDescription snapshot,
Path rootDir)
Get the directory for a specified snapshot.
|
static Path |
getCompletedSnapshotDir(String snapshotName,
Path rootDir)
Get the directory for a completed snapshot.
|
static long |
getMaxMasterTimeout(Configuration conf,
HBaseProtos.SnapshotDescription.Type type,
long defaultMaxWaitTime) |
static Path |
getSnapshotRootDir(Path rootDir)
Get the snapshot root directory.
|
static Path |
getSnapshotsDir(Path rootDir) |
static Path |
getWorkingSnapshotDir(HBaseProtos.SnapshotDescription snapshot,
Path rootDir)
Get the directory to build a snapshot, before it is finalized
|
static Path |
getWorkingSnapshotDir(Path rootDir)
Get the general working directory for snapshots - where they are built, where they are
temporarily copied on export, etc.
|
static Path |
getWorkingSnapshotDir(String snapshotName,
Path rootDir)
Get the directory to build a snapshot, before it is finalized
|
static boolean |
isSnapshotOwner(HBaseProtos.SnapshotDescription snapshot,
User user)
Check if the user is this table snapshot's owner
|
static HBaseProtos.SnapshotDescription |
readSnapshotInfo(FileSystem fs,
Path snapshotDir)
Read in the
HBaseProtos.SnapshotDescription stored for the snapshot in the passed directory |
static HBaseProtos.SnapshotDescription |
validate(HBaseProtos.SnapshotDescription snapshot,
Configuration conf)
Convert the passed snapshot description into a 'full' snapshot description based on default
parameters, if none have been supplied.
|
static void |
writeSnapshotInfo(HBaseProtos.SnapshotDescription snapshot,
Path workingDir,
FileSystem fs)
Write the snapshot description into the working directory of a snapshot
|
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.public static long getMaxMasterTimeout(Configuration conf, HBaseProtos.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 Path getSnapshotRootDir(Path rootDir)
rootDir
- hbase root directorypublic static Path getCompletedSnapshotDir(HBaseProtos.SnapshotDescription snapshot, Path rootDir)
snapshot
- snapshot being takenrootDir
- hbase root directorypublic static Path getCompletedSnapshotDir(String snapshotName, Path rootDir)
snapshotName
- name of the snapshot being takenrootDir
- hbase root directorypublic static Path getWorkingSnapshotDir(Path rootDir)
rootDir
- root directory of the HBase installationpublic static Path getWorkingSnapshotDir(HBaseProtos.SnapshotDescription snapshot, Path rootDir)
snapshot
- snapshot that will be builtrootDir
- root directory of the hbase installationPath
where one can build a snapshotpublic static Path getWorkingSnapshotDir(String snapshotName, Path rootDir)
snapshotName
- name of the snapshotrootDir
- root directory of the hbase installationPath
where one can build a snapshotpublic static final Path getSnapshotsDir(Path rootDir)
rootDir
- hbase root directorypublic static HBaseProtos.SnapshotDescription validate(HBaseProtos.SnapshotDescription snapshot, Configuration conf) throws IllegalArgumentException
snapshot
- general snapshot descriptorconf
- Configuration to read configured snapshot defaults if snapshot is not completeIllegalArgumentException
- if the HBaseProtos.SnapshotDescription
is not a complete
HBaseProtos.SnapshotDescription
.public static void writeSnapshotInfo(HBaseProtos.SnapshotDescription snapshot, Path workingDir, 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 HBaseProtos.SnapshotDescription readSnapshotInfo(FileSystem 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(HBaseProtos.SnapshotDescription snapshot, Path rootdir, Path workingDir, 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(HBaseProtos.SnapshotDescription snapshot, User user)
snapshot
- the table snapshot descriptionuser
- the user