From 4add5250ed322628f9e783efca1b33773b98705b Mon Sep 17 00:00:00 2001 From: Liangjun He Date: Tue, 10 Jan 2023 14:35:55 +0800 Subject: [PATCH] HBASE-27489 Fix several problems after HBASE-27304 (#4903) Signed-off-by: Duo Zhang --- .../hadoop/hbase/regionserver/HRegionServer.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 02a3ba9beb4..5240df5c62a 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 @@ -186,6 +186,7 @@ import org.apache.hbase.thirdparty.com.google.common.base.Throwables; import org.apache.hbase.thirdparty.com.google.common.cache.Cache; import org.apache.hbase.thirdparty.com.google.common.cache.CacheBuilder; import org.apache.hbase.thirdparty.com.google.common.collect.Maps; +import org.apache.hbase.thirdparty.com.google.common.net.InetAddresses; import org.apache.hbase.thirdparty.com.google.protobuf.BlockingRpcChannel; import org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor; import org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.ServiceDescriptor; @@ -1383,9 +1384,17 @@ public class HRegionServer extends HBaseServerBase LOG.error(msg); throw new IOException(msg); } + // if Master use-ip is enabled, RegionServer use-ip will be enabled by default even if it + // is set to disable. so we will use the ip of the RegionServer to compare with the + // hostname passed by the Master, see HBASE-27304 for details. + InetSocketAddress isa = rpcServices.getSocketAddress(); + // here getActiveMaster() is definitely not null. + String isaHostName = InetAddresses.isInetAddress(getActiveMaster().get().getHostname()) + ? isa.getAddress().getHostAddress() + : isa.getHostName(); if ( StringUtils.isBlank(useThisHostnameInstead) - && !hostnameFromMasterPOV.equals(rpcServices.getSocketAddress().getHostName()) + && !hostnameFromMasterPOV.equals(isaHostName) ) { String msg = "Master passed us a different hostname to use; was=" + rpcServices.getSocketAddress().getHostName() + ", but now=" + hostnameFromMasterPOV;