@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.slf4j.Logger |
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.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription |
snapshotDesc |
private SnapshotManifest |
snapshotManifest |
private TableName |
snapshotTable |
private MonitoredTask |
status |
private TableDescriptor |
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,
TableDescriptor 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,
TableDescriptor tableDescriptor,
org.apache.hadoop.fs.Path rootDir,
ForeignExceptionDispatcher monitor,
MonitoredTask status,
boolean createBackRefs) |
Modifier and Type | Method and Description |
---|---|
private void |
cloneHdfsMobRegion(Map<String,org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest> regionManifests,
RegionInfo region)
Clone the mob region.
|
private RegionInfo[] |
cloneHdfsRegions(ThreadPoolExecutor exec,
Map<String,org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest> regionManifests,
List<RegionInfo> regions)
Clone specified regions.
|
private void |
cloneRegion(HRegion region,
RegionInfo snapshotRegionInfo,
org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest manifest)
Clone region directory content from the snapshot info.
|
private void |
cloneRegion(RegionInfo newRegionInfo,
org.apache.hadoop.fs.Path regionDir,
RegionInfo snapshotRegionInfo,
org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest manifest)
Clone region directory content from the snapshot info.
|
RegionInfo |
cloneRegionInfo(RegionInfo snapshotRegionInfo)
Create a new
RegionInfo from the snapshot region info. |
static RegionInfo |
cloneRegionInfo(TableName tableName,
RegionInfo 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.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest.StoreFile>> |
getRegionHFileReferences(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest manifest) |
private Set<String> |
getTableRegionFamilyFiles(org.apache.hadoop.fs.Path familyDir)
Returns The set of files in the specified family directory.
|
private List<RegionInfo> |
getTableRegions()
Returns the set of the regions contained in the table
|
private void |
removeHdfsRegions(ThreadPoolExecutor exec,
List<RegionInfo> regions)
Remove specified regions from the file-system, using the archiver.
|
private void |
restoreHdfsMobRegions(ThreadPoolExecutor exec,
Map<String,org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest> regionManifests,
List<RegionInfo> regions)
Restore specified mob regions by restoring content to the snapshot state.
|
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.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest> regionManifests,
List<RegionInfo> regions)
Restore specified regions by restoring content to the snapshot state.
|
private void |
restoreMobRegion(RegionInfo regionInfo,
org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest regionManifest)
Restore mob region by removing files not in the snapshot and adding the missing ones from the
snapshot.
|
private String |
restoreReferenceFile(org.apache.hadoop.fs.Path familyDir,
RegionInfo regionInfo,
org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest.StoreFile storeFile)
Create a new
Reference as copy of the source one. |
private void |
restoreRegion(RegionInfo regionInfo,
org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest regionManifest)
Restore region by removing files not in the snapshot and adding the missing ones from the
snapshot.
|
private void |
restoreRegion(RegionInfo regionInfo,
org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest regionManifest,
org.apache.hadoop.fs.Path regionDir)
Restore region by removing files not in the snapshot and adding the missing ones from the
snapshot.
|
static void |
restoreSnapshotAcl(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot,
TableName newTableName,
org.apache.hadoop.conf.Configuration conf) |
private String |
restoreStoreFile(org.apache.hadoop.fs.Path familyDir,
RegionInfo regionInfo,
org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest.StoreFile storeFile,
boolean createBackRef)
Create a new
HFileLink to reference the store file. |
private static final org.slf4j.Logger 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.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshotDesc
private final TableName snapshotTable
private final TableDescriptor 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, TableDescriptor 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, TableDescriptor 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<RegionInfo> regions) throws IOException
IOException
private void restoreHdfsRegions(ThreadPoolExecutor exec, Map<String,org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest> regionManifests, List<RegionInfo> regions) throws IOException
IOException
private void restoreHdfsMobRegions(ThreadPoolExecutor exec, Map<String,org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest> regionManifests, List<RegionInfo> regions) throws IOException
IOException
private Map<String,List<org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest.StoreFile>> getRegionHFileReferences(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest manifest)
private void restoreRegion(RegionInfo regionInfo, org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest regionManifest) throws IOException
IOException
private void restoreMobRegion(RegionInfo regionInfo, org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest regionManifest) throws IOException
IOException
private void restoreRegion(RegionInfo regionInfo, org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest regionManifest, org.apache.hadoop.fs.Path regionDir) throws IOException
IOException
private Set<String> getTableRegionFamilyFiles(org.apache.hadoop.fs.Path familyDir) throws IOException
IOException
private RegionInfo[] cloneHdfsRegions(ThreadPoolExecutor exec, Map<String,org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest> regionManifests, List<RegionInfo> regions) throws IOException
IOException
private void cloneHdfsMobRegion(Map<String,org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest> regionManifests, RegionInfo region) throws IOException
IOException
private void cloneRegion(RegionInfo newRegionInfo, org.apache.hadoop.fs.Path regionDir, RegionInfo snapshotRegionInfo, org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest manifest) throws IOException
regionDir
- Path
cloned dir nIOException
private void cloneRegion(HRegion region, RegionInfo snapshotRegionInfo, org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest manifest) throws IOException
region
- HRegion
cloned nIOException
private String restoreStoreFile(org.apache.hadoop.fs.Path familyDir, RegionInfo regionInfo, org.apache.hadoop.hbase.shaded.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 tablecreateBackRef
- - Whether back reference should be created. Defaults to true.storeFile
- store file name (can be a Reference, HFileLink or simple HFile)IOException
private String restoreReferenceFile(org.apache.hadoop.fs.Path familyDir, RegionInfo regionInfo, org.apache.hadoop.hbase.shaded.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 tablestoreFile
- reference file nameIOException
public RegionInfo cloneRegionInfo(RegionInfo snapshotRegionInfo)
RegionInfo
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 RegionInfo cloneRegionInfo(TableName tableName, RegionInfo snapshotRegionInfo)
private List<RegionInfo> 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
IOException
public static void restoreSnapshotAcl(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot, TableName newTableName, org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.