From 26b022116b30dc976582d35306171668b273319c 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 (cherry picked from commit 4add5250ed322628f9e783efca1b33773b98705b) --- .../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 b7bea99dc5e..dcd5597baf5 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 @@ -218,6 +218,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.RpcController; import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException; @@ -1673,9 +1674,17 @@ public class HRegionServer extends Thread 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.isa.getHostName()) + && !hostnameFromMasterPOV.equals(isaHostName) ) { String msg = "Master passed us a different hostname to use; was=" + rpcServices.isa.getHostName() + ", but now=" + hostnameFromMasterPOV;