org.apache.hadoop.hbase.snapshot
Class SnapshotReferenceUtil

java.lang.Object
  extended by org.apache.hadoop.hbase.snapshot.SnapshotReferenceUtil

@InterfaceAudience.Private
public final class SnapshotReferenceUtil
extends Object

Utility methods for interacting with the snapshot referenced files.


Nested Class Summary
static interface SnapshotReferenceUtil.FileVisitor
           
 
Method Summary
static Set<String> getHFileNames(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path snapshotDir)
          Returns the store file names in the snapshot.
static Set<String> getHLogNames(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path snapshotDir)
          Returns the log file names available in the snapshot.
static org.apache.hadoop.fs.Path getLogsDir(org.apache.hadoop.fs.Path snapshotDir, String serverName)
          Get log directory for a server in a snapshot.
static org.apache.hadoop.fs.Path getRecoveredEdits(org.apache.hadoop.fs.Path snapshotDir, String regionName, String logfile)
          Get the snapshot recovered.edits file
static org.apache.hadoop.fs.Path getRecoveredEditsDir(org.apache.hadoop.fs.Path snapshotDir, String regionName)
          Get the snapshotted recovered.edits dir for the specified region.
static Map<String,List<String>> getRegionHFileReferences(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path snapshotRegionDir)
          Get the list of hfiles for the specified snapshot region.
static Set<String> getSnapshotRegionNames(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path snapshotDir)
          Returns the set of region names available in the snapshot.
static void verifySnapshot(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path snapshotDir, HBaseProtos.SnapshotDescription snapshotDesc)
          Verify the validity of the snapshot
static void visitLogFiles(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path snapshotDir, FSVisitor.LogFileVisitor visitor)
          Iterate over the snapshot log files
static void visitRecoveredEdits(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path snapshotDir, FSVisitor.RecoveredEditsVisitor visitor)
          Iterate over the snapshot recovered.edits
static void visitReferencedFiles(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path snapshotDir, SnapshotReferenceUtil.FileVisitor visitor)
          Iterate over the snapshot store files, restored.edits and logs
static void visitRegionStoreFiles(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path regionDir, FSVisitor.StoreFileVisitor visitor)
          Iterate over the snapshot store files in the specified region
static void visitTableStoreFiles(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path snapshotDir, FSVisitor.StoreFileVisitor visitor)
          Iterate over the snapshot store files
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLogsDir

public static org.apache.hadoop.fs.Path getLogsDir(org.apache.hadoop.fs.Path snapshotDir,
                                                   String serverName)
Get log directory for a server in a snapshot.

Parameters:
snapshotDir - directory where the specific snapshot is stored
serverName - name of the parent regionserver for the log files
Returns:
path to the log home directory for the archive files.

getRecoveredEditsDir

public static org.apache.hadoop.fs.Path getRecoveredEditsDir(org.apache.hadoop.fs.Path snapshotDir,
                                                             String regionName)
Get the snapshotted recovered.edits dir for the specified region.

Parameters:
snapshotDir - directory where the specific snapshot is stored
regionName - name of the region
Returns:
path to the recovered.edits directory for the specified region files.

getRecoveredEdits

public static org.apache.hadoop.fs.Path getRecoveredEdits(org.apache.hadoop.fs.Path snapshotDir,
                                                          String regionName,
                                                          String logfile)
Get the snapshot recovered.edits file

Parameters:
snapshotDir - directory where the specific snapshot is stored
regionName - name of the region
logfile - name of the edit file
Returns:
full path of the log file for the specified region files.

visitReferencedFiles

public static void visitReferencedFiles(org.apache.hadoop.fs.FileSystem fs,
                                        org.apache.hadoop.fs.Path snapshotDir,
                                        SnapshotReferenceUtil.FileVisitor visitor)
                                 throws IOException
Iterate over the snapshot store files, restored.edits and logs

Parameters:
fs - FileSystem
snapshotDir - Path to the Snapshot directory
visitor - callback object to get the referenced files
Throws:
IOException - if an error occurred while scanning the directory

visitTableStoreFiles

public static void visitTableStoreFiles(org.apache.hadoop.fs.FileSystem fs,
                                        org.apache.hadoop.fs.Path snapshotDir,
                                        FSVisitor.StoreFileVisitor visitor)
                                 throws IOException
Iterate over the snapshot store files

Parameters:
fs - FileSystem
snapshotDir - Path to the Snapshot directory
visitor - callback object to get the store files
Throws:
IOException - if an error occurred while scanning the directory

visitRegionStoreFiles

public static void visitRegionStoreFiles(org.apache.hadoop.fs.FileSystem fs,
                                         org.apache.hadoop.fs.Path regionDir,
                                         FSVisitor.StoreFileVisitor visitor)
                                  throws IOException
Iterate over the snapshot store files in the specified region

Parameters:
fs - FileSystem
regionDir - Path to the Snapshot region directory
visitor - callback object to get the store files
Throws:
IOException - if an error occurred while scanning the directory

visitRecoveredEdits

public static void visitRecoveredEdits(org.apache.hadoop.fs.FileSystem fs,
                                       org.apache.hadoop.fs.Path snapshotDir,
                                       FSVisitor.RecoveredEditsVisitor visitor)
                                throws IOException
Iterate over the snapshot recovered.edits

Parameters:
fs - FileSystem
snapshotDir - Path to the Snapshot directory
visitor - callback object to get the recovered.edits files
Throws:
IOException - if an error occurred while scanning the directory

visitLogFiles

public static void visitLogFiles(org.apache.hadoop.fs.FileSystem fs,
                                 org.apache.hadoop.fs.Path snapshotDir,
                                 FSVisitor.LogFileVisitor visitor)
                          throws IOException
Iterate over the snapshot log files

Parameters:
fs - FileSystem
snapshotDir - Path to the Snapshot directory
visitor - callback object to get the log files
Throws:
IOException - if an error occurred while scanning the directory

verifySnapshot

public static void verifySnapshot(org.apache.hadoop.conf.Configuration conf,
                                  org.apache.hadoop.fs.FileSystem fs,
                                  org.apache.hadoop.fs.Path snapshotDir,
                                  HBaseProtos.SnapshotDescription snapshotDesc)
                           throws IOException
Verify the validity of the snapshot

Parameters:
conf - The current Configuration instance.
fs - FileSystem
snapshotDir - Path to the Snapshot directory of the snapshot to verify
snapshotDesc - the HBaseProtos.SnapshotDescription of the snapshot to verify
Throws:
CorruptedSnapshotException - if the snapshot is corrupted
IOException - if an error occurred while scanning the directory

getSnapshotRegionNames

public static Set<String> getSnapshotRegionNames(org.apache.hadoop.fs.FileSystem fs,
                                                 org.apache.hadoop.fs.Path snapshotDir)
                                          throws IOException
Returns the set of region names available in the snapshot.

Parameters:
fs - FileSystem
snapshotDir - Path to the Snapshot directory
Returns:
the set of the regions contained in the snapshot
Throws:
IOException - if an error occurred while scanning the directory

getRegionHFileReferences

public static Map<String,List<String>> getRegionHFileReferences(org.apache.hadoop.fs.FileSystem fs,
                                                                org.apache.hadoop.fs.Path snapshotRegionDir)
                                                         throws IOException
Get the list of hfiles for the specified snapshot region. NOTE: The current implementation keeps one empty file per HFile in the region. The file name matches the one in the original table, and by reconstructing the path you can quickly jump to the referenced file.

Parameters:
fs - FileSystem
snapshotRegionDir - Path to the Snapshot region directory
Returns:
Map of hfiles per family, the key is the family name and values are hfile names
Throws:
IOException - if an error occurred while scanning the directory

getHFileNames

public static Set<String> getHFileNames(org.apache.hadoop.fs.FileSystem fs,
                                        org.apache.hadoop.fs.Path snapshotDir)
                                 throws IOException
Returns the store file names in the snapshot.

Parameters:
fs - FileSystem
snapshotDir - Path to the Snapshot directory
Returns:
the names of hfiles in the specified snaphot
Throws:
IOException - if an error occurred while scanning the directory

getHLogNames

public static Set<String> getHLogNames(org.apache.hadoop.fs.FileSystem fs,
                                       org.apache.hadoop.fs.Path snapshotDir)
                                throws IOException
Returns the log file names available in the snapshot.

Parameters:
fs - FileSystem
snapshotDir - Path to the Snapshot directory
Returns:
the names of hlogs in the specified snaphot
Throws:
IOException - if an error occurred while scanning the directory


Copyright © 2015 The Apache Software Foundation. All Rights Reserved.