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.HTableDescriptor;
26 import org.apache.hadoop.hbase.TableExistsException;
27 import org.apache.hadoop.hbase.backup.impl.BackupSystemTable;
28 import org.apache.hadoop.hbase.coprocessor.BaseMasterAndRegionObserver;
29 import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
30 import org.apache.hadoop.hbase.coprocessor.ObserverContext;
31 import org.apache.hadoop.hbase.master.MasterServices;
32
33
34
35
36
37
38
39 public class BackupController extends BaseMasterAndRegionObserver {
40 private static final Log LOG = LogFactory.getLog(BackupController.class.getName());
41
42 @Override
43 public void postStartMaster(ObserverContext<MasterCoprocessorEnvironment> ctx)
44 throws IOException {
45
46 MasterServices master = ctx.getEnvironment().getMasterServices();
47 HTableDescriptor backupHTD = BackupSystemTable.getSystemTableDescriptor();
48 try{
49 master.createTable(backupHTD, null);
50 LOG.info("Created "+ BackupSystemTable.getTableNameAsString()+" table");
51 } catch(TableExistsException e) {
52 LOG.info("Table "+ BackupSystemTable.getTableNameAsString() +" already exists");
53 }
54 }
55 }