Package org.apache.hadoop.hbase.snapshot
Class SnapshotInfo
java.lang.Object
org.apache.hadoop.hbase.util.AbstractHBaseTool
org.apache.hadoop.hbase.snapshot.SnapshotInfo
- All Implemented Interfaces:
org.apache.hadoop.conf.Configurable
,org.apache.hadoop.util.Tool
Tool for dumping snapshot information.
- Table Descriptor
- Snapshot creation time, type, format version, ...
- List of hfiles and wals
- Stats about hfiles and logs sizes, percentage of shared with the source table, ...
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static final class
static class
Statistics about the snapshot How many store files and logs are in the archive How many store files and logs are shared with the table Total store files and logs size and shared amountNested classes/interfaces inherited from class org.apache.hadoop.hbase.util.AbstractHBaseTool
AbstractHBaseTool.OptionsOrderComparator
-
Field Summary
Modifier and TypeFieldDescriptionprivate org.apache.hadoop.fs.FileSystem
private boolean
private static final org.slf4j.Logger
private boolean
private org.apache.hadoop.fs.Path
private org.apache.hadoop.fs.Path
private boolean
private boolean
private boolean
private SnapshotManifest
private String
Fields inherited from class org.apache.hadoop.hbase.util.AbstractHBaseTool
cmdLineArgs, conf, EXIT_FAILURE, EXIT_SUCCESS, LONG_HELP_OPTION, options, SHORT_HELP_OPTION
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Override this to add command-line options usingAbstractHBaseTool.addOptWithArg(java.lang.String, java.lang.String)
and similar methods.int
doWork()
The "main function" of the toolprivate String
fileSizeToString
(long size) private static void
getSnapshotFilesMap
(org.apache.hadoop.conf.Configuration conf, SnapshotDescription snapshot, ExecutorService exec, ConcurrentHashMap<org.apache.hadoop.fs.Path, Integer> filesMap, AtomicLong uniqueHFilesArchiveSize, AtomicLong uniqueHFilesSize, AtomicLong uniqueHFilesMobSize) Gets the store files map for snapshotstatic List<SnapshotDescription>
getSnapshotList
(org.apache.hadoop.conf.Configuration conf) Returns the list of available snapshots in the specified locationgetSnapshotsFilesMap
(org.apache.hadoop.conf.Configuration conf, AtomicLong uniqueHFilesArchiveSize, AtomicLong uniqueHFilesSize, AtomicLong uniqueHFilesMobSize) Returns the map of store files based on path for all snapshotsstatic SnapshotInfo.SnapshotStats
getSnapshotStats
(org.apache.hadoop.conf.Configuration conf, SnapshotDescription snapshot) Returns the snapshot statsstatic SnapshotInfo.SnapshotStats
getSnapshotStats
(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshotDesc, Map<org.apache.hadoop.fs.Path, Integer> filesMap) Returns the snapshot statsprivate boolean
loadSnapshotInfo
(String snapshotName) Load snapshot info and table descriptor for the specified snapshotstatic void
protected org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLineParser
Create the parser to use for parsing and validating the command line.private void
printFiles
(boolean showFiles, boolean showStats) Collect the hfiles and logs statistics of the snapshot and dump the file list if requested and the collected information.private void
Dump theSnapshotDescription
private void
Dump theTableDescriptor
protected void
protected void
processOptions
(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmd) This method is called to process the options after they have been parsed.Methods inherited from class org.apache.hadoop.hbase.util.AbstractHBaseTool
addOption, addOptNoArg, addOptNoArg, addOptWithArg, addOptWithArg, addRequiredOption, addRequiredOptWithArg, addRequiredOptWithArg, doStaticMain, getConf, getOptionAsDouble, getOptionAsInt, getOptionAsInt, getOptionAsLong, getOptionAsLong, parseArgs, parseInt, parseLong, printUsage, processOldArgs, run, setConf
-
Field Details
-
LOG
-
fs
-
rootDir
-
snapshotManifest
-
listSnapshots
-
snapshotName
-
remoteDir
-
showSchema
-
showFiles
-
showStats
-
printSizeInBytes
-
-
Constructor Details
-
SnapshotInfo
public SnapshotInfo()
-
-
Method Details
-
doWork
Description copied from class:AbstractHBaseTool
The "main function" of the tool- Specified by:
doWork
in classAbstractHBaseTool
- Throws:
IOException
InterruptedException
-
loadSnapshotInfo
Load snapshot info and table descriptor for the specified snapshot- Parameters:
snapshotName
- name of the snapshot to load- Returns:
- false if snapshot is not found
- Throws:
IOException
-
printInfo
Dump theSnapshotDescription
-
printSchema
Dump theTableDescriptor
-
printFiles
Collect the hfiles and logs statistics of the snapshot and dump the file list if requested and the collected information.- Throws:
IOException
-
fileSizeToString
-
addOptions
Description copied from class:AbstractHBaseTool
Override this to add command-line options usingAbstractHBaseTool.addOptWithArg(java.lang.String, java.lang.String)
and similar methods.- Specified by:
addOptions
in classAbstractHBaseTool
-
newParser
Description copied from class:AbstractHBaseTool
Create the parser to use for parsing and validating the command line. Since commons-cli lacks the capability to validate arbitrary combination of options, it may be helpful to bake custom logic into a specialized parser implementation. See LoadTestTool for examples.- Overrides:
newParser
in classAbstractHBaseTool
- Returns:
- a new parser specific to the current tool
-
processOptions
Description copied from class:AbstractHBaseTool
This method is called to process the options after they have been parsed.- Specified by:
processOptions
in classAbstractHBaseTool
-
printUsage
- Overrides:
printUsage
in classAbstractHBaseTool
-
getSnapshotStats
public static SnapshotInfo.SnapshotStats getSnapshotStats(org.apache.hadoop.conf.Configuration conf, SnapshotDescription snapshot) throws IOException Returns the snapshot stats- Parameters:
conf
- theConfiguration
to usesnapshot
-SnapshotDescription
to get stats from- Returns:
- the snapshot stats
- Throws:
IOException
-
getSnapshotStats
public static SnapshotInfo.SnapshotStats getSnapshotStats(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshotDesc, Map<org.apache.hadoop.fs.Path, Integer> filesMap) throws IOExceptionReturns the snapshot stats- Parameters:
conf
- theConfiguration
to usesnapshotDesc
- HBaseProtos.SnapshotDescription to get stats fromfilesMap
-Map
store files map for all snapshots, it may be null- Returns:
- the snapshot stats
- Throws:
IOException
-
getSnapshotList
public static List<SnapshotDescription> getSnapshotList(org.apache.hadoop.conf.Configuration conf) throws IOException Returns the list of available snapshots in the specified location- Parameters:
conf
- theConfiguration
to use- Returns:
- the list of snapshots
- Throws:
IOException
-
getSnapshotFilesMap
private static void getSnapshotFilesMap(org.apache.hadoop.conf.Configuration conf, SnapshotDescription snapshot, ExecutorService exec, ConcurrentHashMap<org.apache.hadoop.fs.Path, Integer> filesMap, AtomicLong uniqueHFilesArchiveSize, AtomicLong uniqueHFilesSize, AtomicLong uniqueHFilesMobSize) throws IOExceptionGets the store files map for snapshot- Parameters:
conf
- theConfiguration
to usesnapshot
-SnapshotDescription
to get stats fromexec
- theExecutorService
to usefilesMap
-Map
the map to put the mapping entriesuniqueHFilesArchiveSize
-AtomicLong
the accumulated store file size in archiveuniqueHFilesSize
-AtomicLong
the accumulated store file size shareduniqueHFilesMobSize
-AtomicLong
the accumulated mob store file size shared- Throws:
IOException
-
getSnapshotsFilesMap
public static Map<org.apache.hadoop.fs.Path,Integer> getSnapshotsFilesMap(org.apache.hadoop.conf.Configuration conf, AtomicLong uniqueHFilesArchiveSize, AtomicLong uniqueHFilesSize, AtomicLong uniqueHFilesMobSize) throws IOException Returns the map of store files based on path for all snapshots- Parameters:
conf
- theConfiguration
to useuniqueHFilesArchiveSize
- pass out the size for store files in archiveuniqueHFilesSize
- pass out the size for store files shareduniqueHFilesMobSize
- pass out the size for mob store files shared- Returns:
- the map of store files
- Throws:
IOException
-
main
-