1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.backup.master;
20
21 import java.io.IOException;
22
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25 import org.apache.hadoop.hbase.HConstants;
26 import org.apache.hadoop.hbase.HTableDescriptor;
27 import org.apache.hadoop.hbase.TableExistsException;
28 import org.apache.hadoop.hbase.backup.impl.BackupSystemTable;
29 import org.apache.hadoop.hbase.coprocessor.BaseMasterAndRegionObserver;
30 import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
31 import org.apache.hadoop.hbase.coprocessor.ObserverContext;
32 import org.apache.hadoop.hbase.master.MasterServices;
33
34
35
36
37
38
39
40 public class BackupController extends BaseMasterAndRegionObserver {
41 private static final Log LOG = LogFactory.getLog(BackupController.class.getName());
42
43 @Override
44 public void postStartMaster(ObserverContext<MasterCoprocessorEnvironment> ctx)
45 throws IOException {
46
47 MasterServices master = ctx.getEnvironment().getMasterServices();
48 HTableDescriptor backupHTD = BackupSystemTable.getSystemTableDescriptor();
49 try{
50 master.createTable(backupHTD, null, HConstants.NO_NONCE, HConstants.NO_NONCE);
51 LOG.info("Created "+ BackupSystemTable.getTableNameAsString()+" table");
52 } catch(TableExistsException e) {
53 LOG.info("Table "+ BackupSystemTable.getTableNameAsString() +" already exists");
54 }
55 }
56 }