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
Nested ClassesModifier and TypeClassDescription(package private) static final classstatic classStatistics 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
FieldsModifier and TypeFieldDescriptionprivate org.apache.hadoop.fs.FileSystemprivate booleanprivate static final org.slf4j.Loggerprivate booleanprivate org.apache.hadoop.fs.Pathprivate org.apache.hadoop.fs.Pathprivate booleanprivate booleanprivate booleanprivate SnapshotManifestprivate StringFields inherited from class org.apache.hadoop.hbase.util.AbstractHBaseTool
cmdLineArgs, conf, EXIT_FAILURE, EXIT_SUCCESS, LONG_HELP_OPTION, options, SHORT_HELP_OPTION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidOverride this to add command-line options usingAbstractHBaseTool.addOptWithArg(java.lang.String, java.lang.String)and similar methods.intdoWork()The "main function" of the toolprivate StringfileSizeToString(long size) private static voidgetSnapshotFilesMap(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.SnapshotStatsgetSnapshotStats(org.apache.hadoop.conf.Configuration conf, SnapshotDescription snapshot) Returns the snapshot statsstatic SnapshotInfo.SnapshotStatsgetSnapshotStats(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 booleanloadSnapshotInfo(String snapshotName) Load snapshot info and table descriptor for the specified snapshotstatic voidprotected org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLineParserCreate the parser to use for parsing and validating the command line.private voidprintFiles(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 voidDump theSnapshotDescriptionprivate voidDump theTableDescriptorprotected voidprotected voidprocessOptions(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:AbstractHBaseToolThe "main function" of the tool- Specified by:
doWorkin classAbstractHBaseTool- Throws:
IOExceptionInterruptedException
-
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:AbstractHBaseToolOverride this to add command-line options usingAbstractHBaseTool.addOptWithArg(java.lang.String, java.lang.String)and similar methods.- Specified by:
addOptionsin classAbstractHBaseTool
-
newParser
Description copied from class:AbstractHBaseToolCreate 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:
newParserin classAbstractHBaseTool- Returns:
- a new parser specific to the current tool
-
processOptions
Description copied from class:AbstractHBaseToolThis method is called to process the options after they have been parsed.- Specified by:
processOptionsin classAbstractHBaseTool
-
printUsage
- Overrides:
printUsagein classAbstractHBaseTool
-
getSnapshotStats
public static SnapshotInfo.SnapshotStats getSnapshotStats(org.apache.hadoop.conf.Configuration conf, SnapshotDescription snapshot) throws IOException Returns the snapshot stats- Parameters:
conf- theConfigurationto usesnapshot-SnapshotDescriptionto 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- theConfigurationto usesnapshotDesc- HBaseProtos.SnapshotDescription to get stats fromfilesMap-Mapstore 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- theConfigurationto 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- theConfigurationto usesnapshot-SnapshotDescriptionto get stats fromexec- theExecutorServiceto usefilesMap-Mapthe map to put the mapping entriesuniqueHFilesArchiveSize-AtomicLongthe accumulated store file size in archiveuniqueHFilesSize-AtomicLongthe accumulated store file size shareduniqueHFilesMobSize-AtomicLongthe 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- theConfigurationto 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
-