HBASE-17618 Refactor the implementation of modify table and delete column in MOB
This commit is contained in:
parent
1b041a4fc7
commit
9d5d25c88d
|
@ -39,7 +39,6 @@ import org.apache.hadoop.hbase.exceptions.DeserializationException;
|
|||
import org.apache.hadoop.hbase.fs.HFileSystem;
|
||||
import org.apache.hadoop.hbase.master.procedure.MasterProcedureConstants;
|
||||
import org.apache.hadoop.hbase.mob.MobConstants;
|
||||
import org.apache.hadoop.hbase.mob.MobUtils;
|
||||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.hbase.util.FSTableDescriptors;
|
||||
|
@ -413,10 +412,15 @@ public class MasterFileSystem {
|
|||
}
|
||||
}
|
||||
|
||||
public void deleteFamilyFromFS(HRegionInfo region, byte[] familyName, boolean hasMob)
|
||||
public void deleteFamilyFromFS(HRegionInfo region, byte[] familyName)
|
||||
throws IOException {
|
||||
deleteFamilyFromFS(rootdir, region, familyName);
|
||||
}
|
||||
|
||||
public void deleteFamilyFromFS(Path rootDir, HRegionInfo region, byte[] familyName)
|
||||
throws IOException {
|
||||
// archive family store files
|
||||
Path tableDir = FSUtils.getTableDir(rootdir, region.getTable());
|
||||
Path tableDir = FSUtils.getTableDir(rootDir, region.getTable());
|
||||
HFileArchiver.archiveFamily(fs, conf, region, tableDir, familyName);
|
||||
|
||||
// delete the family folder
|
||||
|
@ -430,24 +434,6 @@ public class MasterFileSystem {
|
|||
+ ")");
|
||||
}
|
||||
}
|
||||
|
||||
// archive and delete mob files
|
||||
if (hasMob) {
|
||||
Path mobTableDir =
|
||||
FSUtils.getTableDir(new Path(getRootDir(), MobConstants.MOB_DIR_NAME), region.getTable());
|
||||
HRegionInfo mobRegionInfo = MobUtils.getMobRegionInfo(region.getTable());
|
||||
Path mobFamilyDir =
|
||||
new Path(mobTableDir,
|
||||
new Path(mobRegionInfo.getEncodedName(), Bytes.toString(familyName)));
|
||||
// archive mob family store files
|
||||
MobUtils.archiveMobStoreFiles(conf, fs, mobRegionInfo, mobFamilyDir, familyName);
|
||||
|
||||
if (!fs.delete(mobFamilyDir, true)) {
|
||||
throw new IOException("Could not delete mob store files for family "
|
||||
+ Bytes.toString(familyName) + " from FileSystem region "
|
||||
+ mobRegionInfo.getRegionNameAsString() + "(" + mobRegionInfo.getEncodedName() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
|
|
|
@ -27,18 +27,19 @@ import java.util.TreeMap;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.HRegionLocation;
|
||||
import org.apache.hadoop.hbase.ServerName;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.TableNotDisabledException;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.client.Connection;
|
||||
import org.apache.hadoop.hbase.client.RegionLocator;
|
||||
import org.apache.hadoop.hbase.client.TableState;
|
||||
import org.apache.hadoop.hbase.master.AssignmentManager;
|
||||
import org.apache.hadoop.hbase.master.BulkReOpen;
|
||||
import org.apache.hadoop.hbase.master.MasterFileSystem;
|
||||
import org.apache.hadoop.hbase.mob.MobConstants;
|
||||
import org.apache.hadoop.hbase.mob.MobUtils;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -71,7 +72,13 @@ public final class MasterDDLOperationHelper {
|
|||
}
|
||||
for (HRegionInfo hri : regionInfoList) {
|
||||
// Delete the family directory in FS for all the regions one by one
|
||||
mfs.deleteFamilyFromFS(hri, familyName, hasMob);
|
||||
mfs.deleteFamilyFromFS(hri, familyName);
|
||||
}
|
||||
if (hasMob) {
|
||||
// Delete the mob region
|
||||
Path mobRootDir = new Path(mfs.getRootDir(), MobConstants.MOB_DIR_NAME);
|
||||
HRegionInfo mobRegionInfo = MobUtils.getMobRegionInfo(tableName);
|
||||
mfs.deleteFamilyFromFS(mobRootDir, mobRegionInfo, familyName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ import org.apache.hadoop.fs.Path;
|
|||
import org.apache.hadoop.hbase.Cell;
|
||||
import org.apache.hadoop.hbase.CellComparator;
|
||||
import org.apache.hadoop.hbase.CellUtil;
|
||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
|
@ -65,7 +64,6 @@ import org.apache.hadoop.hbase.io.hfile.HFileContext;
|
|||
import org.apache.hadoop.hbase.io.hfile.HFileContextBuilder;
|
||||
import org.apache.hadoop.hbase.master.locking.LockManager;
|
||||
import org.apache.hadoop.hbase.mob.compactions.MobCompactor;
|
||||
import org.apache.hadoop.hbase.mob.compactions.PartitionedMobCompactionRequest;
|
||||
import org.apache.hadoop.hbase.mob.compactions.PartitionedMobCompactionRequest.CompactionPartitionId;
|
||||
import org.apache.hadoop.hbase.mob.compactions.PartitionedMobCompactor;
|
||||
import org.apache.hadoop.hbase.regionserver.BloomType;
|
||||
|
@ -843,29 +841,6 @@ public final class MobUtils {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Archives mob store files
|
||||
* @param conf The current configuration.
|
||||
* @param fs The current file system.
|
||||
* @param mobRegionInfo The mob family region info.
|
||||
* @param mobFamilyDir The mob family directory.
|
||||
* @param family The name of the column family.
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void archiveMobStoreFiles(Configuration conf, FileSystem fs,
|
||||
HRegionInfo mobRegionInfo, Path mobFamilyDir, byte[] family) throws IOException {
|
||||
// disable the block cache.
|
||||
Configuration copyOfConf = HBaseConfiguration.create(conf);
|
||||
copyOfConf.setFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, 0f);
|
||||
CacheConfig cacheConfig = new CacheConfig(copyOfConf);
|
||||
FileStatus[] fileStatus = FSUtils.listStatus(fs, mobFamilyDir);
|
||||
List<StoreFile> storeFileList = new ArrayList<StoreFile>();
|
||||
for (FileStatus file : fileStatus) {
|
||||
storeFileList.add(new StoreFile(fs, file.getPath(), conf, cacheConfig, BloomType.NONE));
|
||||
}
|
||||
HFileArchiver.archiveStoreFiles(conf, fs, mobRegionInfo, mobFamilyDir, family, storeFileList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a mob ref delete marker.
|
||||
* @param cell The current delete marker.
|
||||
|
|
Loading…
Reference in New Issue