@InterfaceAudience.Private public class RestoreSnapshotHelper extends Object
The helper assumes that a table is already created, and by calling restore() the content present in the snapshot will be restored as the new content of the table.
Clone from Snapshot: If the target table is empty, the restore operation is just a "clone operation", where the only operations are:
Restore from Snapshot:
Modifier and Type | Class and Description |
---|---|
static class |
RestoreSnapshotHelper.RestoreMetaChanges
Describe the set of operations needed to update hbase:meta after restore.
|
Modifier and Type | Field and Description |
---|---|
private org.apache.hadoop.conf.Configuration |
conf |
private boolean |
createBackRefs |
private org.apache.hadoop.fs.FileSystem |
fs |
private static org.apache.commons.logging.Log |
LOG |
private ForeignExceptionDispatcher |
monitor |
private Map<String,Pair<String,String>> |
parentsMap |
private Map<byte[],byte[]> |
regionsMap |
private org.apache.hadoop.fs.Path |
rootDir |
private org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription |
snapshotDesc |
private SnapshotManifest |
snapshotManifest |
private TableName |
snapshotTable |
private MonitoredTask |
status |
private HTableDescriptor |
tableDesc |
private org.apache.hadoop.fs.Path |
tableDir |
Constructor and Description |
---|
RestoreSnapshotHelper(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
SnapshotManifest manifest,
HTableDescriptor tableDescriptor,
org.apache.hadoop.fs.Path rootDir,
ForeignExceptionDispatcher monitor,
MonitoredTask status) |
RestoreSnapshotHelper(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
SnapshotManifest manifest,
HTableDescriptor tableDescriptor,
org.apache.hadoop.fs.Path rootDir,
ForeignExceptionDispatcher monitor,
MonitoredTask status,
boolean createBackRefs) |
Modifier and Type | Method and Description |
---|---|
private HRegionInfo[] |
cloneHdfsRegions(ThreadPoolExecutor exec,
Map<String,org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest> regionManifests,
List<HRegionInfo> regions)
Clone specified regions.
|
private void |
cloneRegion(HRegion region,
HRegionInfo snapshotRegionInfo,
org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest manifest)
Clone region directory content from the snapshot info.
|
HRegionInfo |
cloneRegionInfo(HRegionInfo snapshotRegionInfo)
Create a new
HRegionInfo from the snapshot region info. |
static HRegionInfo |
cloneRegionInfo(TableName tableName,
HRegionInfo snapshotRegionInfo) |
static RestoreSnapshotHelper.RestoreMetaChanges |
copySnapshotForScanner(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootDir,
org.apache.hadoop.fs.Path restoreDir,
String snapshotName)
Copy the snapshot files for a snapshot scanner, discards meta changes.
|
private Map<String,List<org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest.StoreFile>> |
getRegionHFileReferences(org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest manifest) |
private Set<String> |
getTableRegionFamilyFiles(org.apache.hadoop.fs.Path familyDir) |
private List<HRegionInfo> |
getTableRegions() |
private void |
removeHdfsRegions(ThreadPoolExecutor exec,
List<HRegionInfo> regions)
Remove specified regions from the file-system, using the archiver.
|
RestoreSnapshotHelper.RestoreMetaChanges |
restoreHdfsRegions()
Restore the on-disk table to a specified snapshot state.
|
private RestoreSnapshotHelper.RestoreMetaChanges |
restoreHdfsRegions(ThreadPoolExecutor exec) |
private void |
restoreHdfsRegions(ThreadPoolExecutor exec,
Map<String,org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest> regionManifests,
List<HRegionInfo> regions)
Restore specified regions by restoring content to the snapshot state.
|
private void |
restoreReferenceFile(org.apache.hadoop.fs.Path familyDir,
HRegionInfo regionInfo,
org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest.StoreFile storeFile)
Create a new
Reference as copy of the source one. |
private void |
restoreRegion(HRegionInfo regionInfo,
org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest regionManifest)
Restore region by removing files not in the snapshot
and adding the missing ones from the snapshot.
|
private void |
restoreStoreFile(org.apache.hadoop.fs.Path familyDir,
HRegionInfo regionInfo,
org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest.StoreFile storeFile,
boolean createBackRef)
Create a new
HFileLink to reference the store file. |
private static final org.apache.commons.logging.Log LOG
private final Map<byte[],byte[]> regionsMap
private final ForeignExceptionDispatcher monitor
private final MonitoredTask status
private final SnapshotManifest snapshotManifest
private final org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription snapshotDesc
private final TableName snapshotTable
private final HTableDescriptor tableDesc
private final org.apache.hadoop.fs.Path rootDir
private final org.apache.hadoop.fs.Path tableDir
private final org.apache.hadoop.conf.Configuration conf
private final org.apache.hadoop.fs.FileSystem fs
private final boolean createBackRefs
public RestoreSnapshotHelper(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, SnapshotManifest manifest, HTableDescriptor tableDescriptor, org.apache.hadoop.fs.Path rootDir, ForeignExceptionDispatcher monitor, MonitoredTask status)
public RestoreSnapshotHelper(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, SnapshotManifest manifest, HTableDescriptor tableDescriptor, org.apache.hadoop.fs.Path rootDir, ForeignExceptionDispatcher monitor, MonitoredTask status, boolean createBackRefs)
public RestoreSnapshotHelper.RestoreMetaChanges restoreHdfsRegions() throws IOException
IOException
private RestoreSnapshotHelper.RestoreMetaChanges restoreHdfsRegions(ThreadPoolExecutor exec) throws IOException
IOException
private void removeHdfsRegions(ThreadPoolExecutor exec, List<HRegionInfo> regions) throws IOException
IOException
private void restoreHdfsRegions(ThreadPoolExecutor exec, Map<String,org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest> regionManifests, List<HRegionInfo> regions) throws IOException
IOException
private Map<String,List<org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest.StoreFile>> getRegionHFileReferences(org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest manifest)
private void restoreRegion(HRegionInfo regionInfo, org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest regionManifest) throws IOException
IOException
private Set<String> getTableRegionFamilyFiles(org.apache.hadoop.fs.Path familyDir) throws IOException
IOException
private HRegionInfo[] cloneHdfsRegions(ThreadPoolExecutor exec, Map<String,org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest> regionManifests, List<HRegionInfo> regions) throws IOException
IOException
private void cloneRegion(HRegion region, HRegionInfo snapshotRegionInfo, org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest manifest) throws IOException
region
- HRegion
clonedsnapshotRegionInfo
- IOException
private void restoreStoreFile(org.apache.hadoop.fs.Path familyDir, HRegionInfo regionInfo, org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest.StoreFile storeFile, boolean createBackRef) throws IOException
HFileLink
to reference the store file.
The store file in the snapshot can be a simple hfile, an HFileLink or a reference.
familyDir
- destination directory for the store fileregionInfo
- destination region info for the tablestoreFile
- store file name (can be a Reference, HFileLink or simple HFile)createBackRef
- - Whether back reference should be created. Defaults to true.IOException
private void restoreReferenceFile(org.apache.hadoop.fs.Path familyDir, HRegionInfo regionInfo, org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest.StoreFile storeFile) throws IOException
Reference
as copy of the source one.
The source table looks like: 1234/abc (original file) 5678/abc.1234 (reference file) After the clone operation looks like: wxyz/table=1234-abc stuv/table=1234-abc.wxyz NOTE that the region name in the clone changes (md5 of regioninfo) and the reference should reflect that change.
familyDir
- destination directory for the store fileregionInfo
- destination region info for the tablehfileName
- reference file nameIOException
public HRegionInfo cloneRegionInfo(HRegionInfo snapshotRegionInfo)
HRegionInfo
from the snapshot region info.
Keep the same startKey, endKey, regionId and split information but change
the table name.snapshotRegionInfo
- Info for region to clone.public static HRegionInfo cloneRegionInfo(TableName tableName, HRegionInfo snapshotRegionInfo)
private List<HRegionInfo> getTableRegions() throws IOException
IOException
public static RestoreSnapshotHelper.RestoreMetaChanges copySnapshotForScanner(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.Path restoreDir, String snapshotName) throws IOException
conf
- fs
- rootDir
- restoreDir
- snapshotName
- IOException
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.