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.fs.Path;
25 import org.apache.hadoop.hbase.HRegionInfo;
26 import org.apache.hadoop.hbase.RemoteExceptionHandler;
27 import org.apache.hadoop.hbase.TableNotDisabledException;
28 import org.apache.hadoop.hbase.ipc.HRegionInterface;
29 import org.apache.hadoop.hbase.regionserver.HRegion;
30 import org.apache.hadoop.hbase.util.Bytes;
31
32 import java.io.IOException;
33
34
35
36
37 class TableDelete extends TableOperation {
38 private final Log LOG = LogFactory.getLog(this.getClass());
39
40 TableDelete(final HMaster master, final byte [] tableName) throws IOException {
41 super(master, tableName);
42 }
43
44 @Override
45 protected void processScanItem(String serverName,
46 final HRegionInfo info) throws IOException {
47 if (isEnabled(info)) {
48 LOG.debug("Region still enabled: " + info.toString());
49 throw new TableNotDisabledException(tableName);
50 }
51 }
52
53 @Override
54 protected void postProcessMeta(MetaRegion m, HRegionInterface server)
55 throws IOException {
56 for (HRegionInfo i: unservedRegions) {
57 if (!Bytes.equals(this.tableName, i.getTableDesc().getName())) {
58
59 continue;
60 }
61
62 try {
63 HRegion.removeRegionFromMETA(server, m.getRegionName(), i.getRegionName());
64 HRegion.deleteRegion(this.master.getFileSystem(),
65 this.master.getRootDir(), i);
66
67 } catch (IOException e) {
68 LOG.error("failed to delete region " + Bytes.toString(i.getRegionName()),
69 RemoteExceptionHandler.checkIOException(e));
70 }
71 }
72
73
74 this.master.getFileSystem().delete(new Path(this.master.getRootDir(),
75 Bytes.toString(this.tableName)), true);
76 }
77 }