HBASE-27489 Fix several problems after HBASE-27304 (#4903)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
(cherry picked from commit 4add5250ed322628f9e783efca1b33773b98705b)
This commit is contained in:
Liangjun He 2023-01-10 14:35:55 +08:00 committed by Duo Zhang
parent 2fdefdc273
commit 26b022116b

View File

@ -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.Cache;
import org.apache.hbase.thirdparty.com.google.common.cache.CacheBuilder; 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.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.BlockingRpcChannel;
import org.apache.hbase.thirdparty.com.google.protobuf.RpcController; import org.apache.hbase.thirdparty.com.google.protobuf.RpcController;
import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException; import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException;
@ -1673,9 +1674,17 @@ public class HRegionServer extends Thread
LOG.error(msg); LOG.error(msg);
throw new IOException(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 ( if (
StringUtils.isBlank(useThisHostnameInstead) StringUtils.isBlank(useThisHostnameInstead)
&& !hostnameFromMasterPOV.equals(rpcServices.isa.getHostName()) && !hostnameFromMasterPOV.equals(isaHostName)
) { ) {
String msg = "Master passed us a different hostname to use; was=" String msg = "Master passed us a different hostname to use; was="
+ rpcServices.isa.getHostName() + ", but now=" + hostnameFromMasterPOV; + rpcServices.isa.getHostName() + ", but now=" + hostnameFromMasterPOV;