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.TableName;
28 import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher;
29 import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
30 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
31 import org.apache.hadoop.hbase.util.FSTableDescriptors;
32
33
34
35
36 @InterfaceAudience.Private
37 @InterfaceStability.Evolving
38 public class TableInfoCopyTask extends SnapshotTask {
39
40 public static final Log LOG = LogFactory.getLog(TableInfoCopyTask.class);
41 private final FileSystem fs;
42 private final Path rootDir;
43
44
45
46
47
48
49
50
51 public TableInfoCopyTask(ForeignExceptionDispatcher monitor,
52 SnapshotDescription snapshot, FileSystem fs, Path rootDir) {
53 super(snapshot, monitor);
54 this.rootDir = rootDir;
55 this.fs = fs;
56 }
57
58 @Override
59 public Void call() throws Exception {
60 LOG.debug("Running table info copy.");
61 this.rethrowException();
62 LOG.debug("Attempting to copy table info for snapshot:"
63 + ClientSnapshotDescriptionUtils.toString(this.snapshot));
64
65 HTableDescriptor orig = FSTableDescriptors.getTableDescriptorFromFs(fs, rootDir,
66 TableName.valueOf(this.snapshot.getTable()));
67 this.rethrowException();
68
69 Path snapshotDir = SnapshotDescriptionUtils.getWorkingSnapshotDir(snapshot, rootDir);
70 new FSTableDescriptors(fs, rootDir)
71 .createTableDescriptorForTableDirectory(snapshotDir, orig, false);
72 LOG.debug("Finished copying tableinfo.");
73 return null;
74 }
75 }