1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.master;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.hadoop.hbase.HConstants;
25 import org.apache.hadoop.hbase.HRegionInfo;
26 import org.apache.hadoop.hbase.HTableDescriptor;
27 import org.apache.hadoop.hbase.TableNotDisabledException;
28 import org.apache.hadoop.hbase.client.Put;
29 import org.apache.hadoop.hbase.ipc.HRegionInterface;
30 import org.apache.hadoop.hbase.util.Bytes;
31 import org.apache.hadoop.hbase.util.Writables;
32
33 import java.io.IOException;
34
35
36 class ModifyTableMeta extends TableOperation {
37
38 private static Log LOG = LogFactory.getLog(ModifyTableMeta.class);
39
40 private HTableDescriptor desc;
41
42 ModifyTableMeta(final HMaster master, final byte [] tableName,
43 HTableDescriptor desc)
44 throws IOException {
45 super(master, tableName);
46 this.desc = desc;
47 LOG.debug("modifying " + Bytes.toString(tableName) + ": " +
48 desc.toString());
49 }
50
51 protected void updateRegionInfo(HRegionInterface server, byte [] regionName,
52 HRegionInfo i)
53 throws IOException {
54 Put put = new Put(i.getRegionName());
55 put.add(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER, Writables.getBytes(i));
56 server.put(regionName, put);
57 LOG.debug("updated HTableDescriptor for region " + i.getRegionNameAsString());
58 }
59
60 @Override
61 protected void processScanItem(String serverName,
62 final HRegionInfo info) throws IOException {
63 if (isEnabled(info)) {
64 throw new TableNotDisabledException(Bytes.toString(tableName));
65 }
66 }
67
68 @Override
69 protected void postProcessMeta(MetaRegion m, HRegionInterface server)
70 throws IOException {
71 for (HRegionInfo i: unservedRegions) {
72 i.setTableDesc(desc);
73 updateRegionInfo(server, m.getRegionName(), i);
74 }
75
76 master.getRegionManager().metaScannerThread.triggerNow();
77 }
78 }