1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.master.handler;
20
21 import java.io.IOException;
22 import java.util.List;
23
24 import org.apache.hadoop.classification.InterfaceAudience;
25 import org.apache.hadoop.hbase.HRegionInfo;
26 import org.apache.hadoop.hbase.HTableDescriptor;
27 import org.apache.hadoop.hbase.Server;
28 import org.apache.hadoop.hbase.executor.EventType;
29 import org.apache.hadoop.hbase.master.HMaster;
30 import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
31 import org.apache.hadoop.hbase.master.MasterServices;
32
33 @InterfaceAudience.Private
34 public class ModifyTableHandler extends TableEventHandler {
35 private final HTableDescriptor htd;
36
37 public ModifyTableHandler(final byte [] tableName,
38 final HTableDescriptor htd, final Server server,
39 final MasterServices masterServices) {
40 super(EventType.C_M_MODIFY_TABLE, tableName, server, masterServices);
41
42 this.htd = htd;
43 }
44
45 @Override
46 protected void prepareWithTableLock() throws IOException {
47 super.prepareWithTableLock();
48
49 getTableDescriptor();
50 }
51
52 @Override
53 protected void handleTableOperation(List<HRegionInfo> hris)
54 throws IOException {
55 MasterCoprocessorHost cpHost = ((HMaster) this.server)
56 .getCoprocessorHost();
57 if (cpHost != null) {
58 cpHost.preModifyTableHandler(this.tableName, this.htd);
59 }
60
61 this.masterServices.getTableDescriptors().add(this.htd);
62 if (cpHost != null) {
63 cpHost.postModifyTableHandler(this.tableName, this.htd);
64 }
65 }
66
67 @Override
68 public String toString() {
69 String name = "UnknownServerName";
70 if(server != null && server.getServerName() != null) {
71 name = server.getServerName().toString();
72 }
73 return getClass().getSimpleName() + "-" + name + "-" + getSeqid() + "-" +
74 tableNameStr;
75 }
76 }