1 /**
2 * Copyright 2010 The Apache Software Foundation
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20 package org.apache.hadoop.hbase.master;
21
22 import org.apache.hadoop.fs.Path;
23 import org.apache.hadoop.hbase.HRegionInfo;
24 import org.apache.hadoop.hbase.ipc.HRegionInterface;
25 import org.apache.hadoop.hbase.regionserver.Store;
26
27 import java.io.IOException;
28
29 /** Instantiated to remove a column family from a table */
30 class DeleteColumn extends ColumnOperation {
31 private final byte [] columnName;
32
33 DeleteColumn(final HMaster master, final byte [] tableName,
34 final byte [] columnName)
35 throws IOException {
36 super(master, tableName);
37 this.columnName = columnName;
38 }
39
40 @Override
41 protected void postProcessMeta(MetaRegion m, HRegionInterface server)
42 throws IOException {
43 for (HRegionInfo i: unservedRegions) {
44 i.getTableDesc().removeFamily(columnName);
45 updateRegionInfo(server, m.getRegionName(), i);
46 // Delete the directories used by the column
47 Path tabledir =
48 new Path(this.master.getRootDir(), i.getTableDesc().getNameAsString());
49 this.master.getFileSystem().
50 delete(Store.getStoreHomedir(tabledir, i.getEncodedName(),
51 this.columnName), true);
52 }
53 }
54 }