From 6a4bfd93d55a08e4068f2813a6b6c6fa26e211f3 Mon Sep 17 00:00:00 2001 From: QilinCao Date: Fri, 15 Dec 2017 16:11:25 +0800 Subject: [PATCH] HBASE-19521 HBase mob compaction need to check hfile version --- .../apache/hadoop/hbase/master/MasterRpcServices.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java index ce85b66..84139c4 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java @@ -50,6 +50,7 @@ import org.apache.hadoop.hbase.client.replication.ReplicationPeerConfigUtil; import org.apache.hadoop.hbase.coprocessor.MasterCoprocessor; import org.apache.hadoop.hbase.errorhandling.ForeignException; import org.apache.hadoop.hbase.exceptions.UnknownProtocolException; +import org.apache.hadoop.hbase.io.hfile.HFile; import org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils; import org.apache.hadoop.hbase.ipc.PriorityFunction; import org.apache.hadoop.hbase.ipc.QosPriority; @@ -1601,6 +1602,7 @@ public class MasterRpcServices extends RSRpcServices TableName tableName = RegionInfo.getTable(regionName); // if the region is a mob region, do the mob file compaction. if (MobUtils.isMobRegionName(tableName, regionName)) { + checkHFileFormatVersionForMob(); return compactMob(request, tableName); } else { return super.compactRegion(controller, request); @@ -1610,6 +1612,20 @@ public class MasterRpcServices extends RSRpcServices } } + /** + * check configured hfile format version before to do compaction + * @throws IOException throw IOException + */ + private void checkHFileFormatVersionForMob() throws IOException { + if (HFile.getFormatVersion(master.getConfiguration()) < HFile.MIN_FORMAT_VERSION_WITH_TAGS) { + LOG.error("A minimum HFile version of " + HFile.MIN_FORMAT_VERSION_WITH_TAGS + + " is required for MOB compaction. Compaction will not run."); + throw new IOException("A minimum HFile version of " + HFile.MIN_FORMAT_VERSION_WITH_TAGS + + " is required for MOB feature. Consider setting " + HFile.FORMAT_VERSION_KEY + + " accordingly."); + } + } + @Override @QosPriority(priority=HConstants.ADMIN_QOS) public GetRegionInfoResponse getRegionInfo(final RpcController controller, -- 1.9.1