org.apache.hadoop.hbase.snapshot
Class TakeSnapshotUtils

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

public class TakeSnapshotUtils
extends Object

Utilities for useful when taking a snapshot


Method Summary
static List<org.apache.hadoop.fs.Path> getFamilySnapshotDirectories(HBaseProtos.SnapshotDescription snapshot, org.apache.hadoop.fs.Path snapshotRegionDir, org.apache.hadoop.fs.FileStatus[] families)
          Get the snapshot directory for each family to be added to the the snapshot
static TimeoutExceptionInjector getMasterTimerAndBindToMonitor(HBaseProtos.SnapshotDescription snapshot, org.apache.hadoop.conf.Configuration conf, ForeignExceptionListener monitor)
          Create a snapshot timer for the master which notifies the monitor when an error occurs
static org.apache.hadoop.fs.Path getRegionSnapshotDirectory(HBaseProtos.SnapshotDescription desc, org.apache.hadoop.fs.Path rootDir, String regionName)
          Get the per-region snapshot description location.
static org.apache.hadoop.fs.Path getSnapshotHLogsDir(org.apache.hadoop.fs.Path snapshotDir, String serverName)
          Get the log directory for a specific snapshot
static org.apache.hadoop.fs.Path getStoreSnapshotDirectory(org.apache.hadoop.fs.Path regionDir, String family)
          Get the home directory for store-level snapshot files.
static void verifyAllLogsGotReferenced(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path logsDir, Set<String> serverNames, HBaseProtos.SnapshotDescription snapshot, org.apache.hadoop.fs.Path snapshotLogDir)
          Verify that all the expected logs got referenced
static void verifyRecoveredEdits(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootDir, HRegionInfo regionInfo, HBaseProtos.SnapshotDescription snapshot)
          Verify one of a snapshot's region's recovered.edits, has been at the surface (file names, length), match the original directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getRegionSnapshotDirectory

public static org.apache.hadoop.fs.Path getRegionSnapshotDirectory(HBaseProtos.SnapshotDescription desc,
                                                                   org.apache.hadoop.fs.Path rootDir,
                                                                   String regionName)
Get the per-region snapshot description location.

Under the per-snapshot directory, specific files per-region are kept in a similar layout as per the current directory layout.

Parameters:
desc - description of the snapshot
rootDir - root directory for the hbase installation
regionName - encoded name of the region (see HRegionInfo.encodeRegionName(byte[]))
Returns:
path to the per-region directory for the snapshot

getStoreSnapshotDirectory

public static org.apache.hadoop.fs.Path getStoreSnapshotDirectory(org.apache.hadoop.fs.Path regionDir,
                                                                  String family)
Get the home directory for store-level snapshot files.

Specific files per store are kept in a similar layout as per the current directory layout.

Parameters:
regionDir - snapshot directory for the parent region, not the standard region directory. See getRegionSnapshotDirectory(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription, org.apache.hadoop.fs.Path, java.lang.String)
family - name of the store to snapshot
Returns:
path to the snapshot home directory for the store/family

getFamilySnapshotDirectories

public static List<org.apache.hadoop.fs.Path> getFamilySnapshotDirectories(HBaseProtos.SnapshotDescription snapshot,
                                                                           org.apache.hadoop.fs.Path snapshotRegionDir,
                                                                           org.apache.hadoop.fs.FileStatus[] families)
Get the snapshot directory for each family to be added to the the snapshot

Parameters:
snapshot - description of the snapshot being take
snapshotRegionDir - directory in the snapshot where the region directory information should be stored
families - families to be added (can be null)
Returns:
paths to the snapshot directory for each family, in the same order as the families passed in

getMasterTimerAndBindToMonitor

public static TimeoutExceptionInjector getMasterTimerAndBindToMonitor(HBaseProtos.SnapshotDescription snapshot,
                                                                      org.apache.hadoop.conf.Configuration conf,
                                                                      ForeignExceptionListener monitor)
Create a snapshot timer for the master which notifies the monitor when an error occurs

Parameters:
snapshot - snapshot to monitor
conf - configuration to use when getting the max snapshot life
monitor - monitor to notify when the snapshot life expires
Returns:
the timer to use update to signal the start and end of the snapshot

verifyAllLogsGotReferenced

public static void verifyAllLogsGotReferenced(org.apache.hadoop.fs.FileSystem fs,
                                              org.apache.hadoop.fs.Path logsDir,
                                              Set<String> serverNames,
                                              HBaseProtos.SnapshotDescription snapshot,
                                              org.apache.hadoop.fs.Path snapshotLogDir)
                                       throws IOException
Verify that all the expected logs got referenced

Parameters:
fs - filesystem where the logs live
logsDir - original logs directory
serverNames - names of the servers that involved in the snapshot
snapshot - description of the snapshot being taken
snapshotLogDir - directory for logs in the snapshot
Throws:
IOException

verifyRecoveredEdits

public static void verifyRecoveredEdits(org.apache.hadoop.fs.FileSystem fs,
                                        org.apache.hadoop.fs.Path rootDir,
                                        HRegionInfo regionInfo,
                                        HBaseProtos.SnapshotDescription snapshot)
                                 throws IOException
Verify one of a snapshot's region's recovered.edits, has been at the surface (file names, length), match the original directory.

Parameters:
fs - filesystem on which the snapshot had been taken
rootDir - full path to the root hbase directory
regionInfo - info for the region
snapshot - description of the snapshot that was taken
Throws:
IOException - if there is an unexpected error talking to the filesystem

getSnapshotHLogsDir

public static org.apache.hadoop.fs.Path getSnapshotHLogsDir(org.apache.hadoop.fs.Path snapshotDir,
                                                            String serverName)
Get the log directory for a specific snapshot

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


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