From f5e51270ba0187a2fdc9de2470a951b237ce227f Mon Sep 17 00:00:00 2001 From: "Jain, Nihal" Date: Fri, 7 Jul 2023 13:05:48 +0530 Subject: [PATCH] WIP: TEST patch for HBASE-27966 --- .../apache/hadoop/hbase/io/hfile/HFile.java | 11 -------- .../hadoop/hbase/io/hfile/HFileUtil.java | 25 +++++++++++++++++++ .../hbase/regionserver/HRegionServer.java | 2 +- 3 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileUtil.java diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java index 73346e8ae4..2686a793dc 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java @@ -646,17 +646,6 @@ public final class HFile { } } - public static void checkHFileVersion(final Configuration c) { - int version = c.getInt(FORMAT_VERSION_KEY, MAX_FORMAT_VERSION); - if (version < MAX_FORMAT_VERSION || version > MAX_FORMAT_VERSION) { - throw new IllegalArgumentException( - "The setting for " + FORMAT_VERSION_KEY + " (in your hbase-*.xml files) is " + version - + " which does not match " + MAX_FORMAT_VERSION - + "; are you running with a configuration from an older or newer hbase install (an " - + "incompatible hbase-default.xml or hbase-site.xml on your CLASSPATH)?"); - } - } - public static void main(String[] args) throws Exception { // delegate to preserve old behavior HFilePrettyPrinter.main(args); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileUtil.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileUtil.java new file mode 100644 index 0000000000..6d83c48379 --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileUtil.java @@ -0,0 +1,25 @@ +package org.apache.hadoop.hbase.io.hfile; + +import org.apache.hadoop.conf.Configuration; +import org.apache.yetus.audience.InterfaceAudience; + +@InterfaceAudience.Private +public class HFileUtil { + + public static final int MIN_FORMAT_VERSION = 2; + public static final String FORMAT_VERSION_KEY = "hfile.format.version"; + /** + * Maximum supported HFile format version + */ + public static final int MAX_FORMAT_VERSION = 3; + public static void checkHFileVersion(final Configuration c) { + int version = c.getInt(FORMAT_VERSION_KEY, MAX_FORMAT_VERSION); + if (version < MAX_FORMAT_VERSION || version > MAX_FORMAT_VERSION) { + throw new IllegalArgumentException( + "The setting for " + FORMAT_VERSION_KEY + " (in your hbase-*.xml files) is " + version + + " which does not match " + MAX_FORMAT_VERSION + + "; are you running with a configuration from an older or newer hbase install (an " + + "incompatible hbase-default.xml or hbase-site.xml on your CLASSPATH)?"); + } + } +} diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index e547a462f9..e109ada623 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -605,7 +605,7 @@ public class HRegionServer extends Thread this.masterless = conf.getBoolean(MASTERLESS_CONFIG_NAME, false); this.eventLoopGroupConfig = setupNetty(this.conf); MemorySizeUtil.checkForClusterFreeHeapMemoryLimit(this.conf); - HFile.checkHFileVersion(this.conf); + org.apache.hadoop.hbase.io.hfile.HFileUtil.checkHFileVersion(this.conf); checkCodecs(this.conf); this.userProvider = UserProvider.instantiate(conf); FSUtils.setupShortCircuitRead(this.conf);