1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.snapshot;
19
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22 import org.apache.hadoop.classification.InterfaceAudience;
23 import org.apache.hadoop.classification.InterfaceStability;
24 import org.apache.hadoop.fs.FileSystem;
25 import org.apache.hadoop.fs.Path;
26 import org.apache.hadoop.hbase.HTableDescriptor;
27 import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher;
28 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
29 import org.apache.hadoop.hbase.util.Bytes;
30 import org.apache.hadoop.hbase.util.FSTableDescriptors;
31
32
33
34
35 @InterfaceAudience.Private
36 @InterfaceStability.Evolving
37 public class TableInfoCopyTask extends SnapshotTask {
38
39 public static final Log LOG = LogFactory.getLog(TableInfoCopyTask.class);
40 private final FileSystem fs;
41 private final Path rootDir;
42
43
44
45
46
47
48
49
50 public TableInfoCopyTask(ForeignExceptionDispatcher monitor,
51 SnapshotDescription snapshot, FileSystem fs, Path rootDir) {
52 super(snapshot, monitor);
53 this.rootDir = rootDir;
54 this.fs = fs;
55 }
56
57 @Override
58 public Void call() throws Exception {
59 LOG.debug("Running table info copy.");
60 this.rethrowException();
61 LOG.debug("Attempting to copy table info for snapshot:"
62 + ClientSnapshotDescriptionUtils.toString(this.snapshot));
63
64 HTableDescriptor orig = FSTableDescriptors.getTableDescriptor(fs, rootDir,
65 Bytes.toBytes(this.snapshot.getTable()));
66 this.rethrowException();
67
68 Path snapshotDir = SnapshotDescriptionUtils.getWorkingSnapshotDir(snapshot, rootDir);
69 FSTableDescriptors.createTableDescriptorForTableDirectory(fs, snapshotDir, orig, false);
70 LOG.debug("Finished copying tableinfo.");
71 return null;
72 }
73 }