001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.master.procedure; 019 020import java.io.IOException; 021import java.util.List; 022import org.apache.hadoop.fs.Path; 023import org.apache.hadoop.hbase.TableName; 024import org.apache.hadoop.hbase.client.RegionInfo; 025import org.apache.hadoop.hbase.master.MasterFileSystem; 026import org.apache.hadoop.hbase.mob.MobConstants; 027import org.apache.hadoop.hbase.mob.MobUtils; 028import org.apache.hadoop.hbase.util.Bytes; 029import org.apache.yetus.audience.InterfaceAudience; 030import org.slf4j.Logger; 031import org.slf4j.LoggerFactory; 032 033/** 034 * Helper class for schema change procedures 035 */ 036@InterfaceAudience.Private 037public final class MasterDDLOperationHelper { 038 private static final Logger LOG = LoggerFactory.getLogger(MasterDDLOperationHelper.class); 039 040 private MasterDDLOperationHelper() { 041 } 042 043 /** 044 * Remove the column family from the file system 045 **/ 046 public static void deleteColumnFamilyFromFileSystem(final MasterProcedureEnv env, 047 final TableName tableName, final List<RegionInfo> regionInfoList, final byte[] familyName, 048 final boolean hasMob) throws IOException { 049 final MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem(); 050 if (LOG.isDebugEnabled()) { 051 LOG.debug("Removing family=" + Bytes.toString(familyName) + " from table=" + tableName); 052 } 053 for (RegionInfo hri : regionInfoList) { 054 // Delete the family directory in FS for all the regions one by one 055 mfs.deleteFamilyFromFS(hri, familyName); 056 } 057 if (hasMob) { 058 // Delete the mob region 059 Path mobRootDir = new Path(mfs.getRootDir(), MobConstants.MOB_DIR_NAME); 060 RegionInfo mobRegionInfo = MobUtils.getMobRegionInfo(tableName); 061 mfs.deleteFamilyFromFS(mobRootDir, mobRegionInfo, familyName); 062 } 063 } 064}