Skip to content

Commit 4add525

Browse files
authored
HBASE-27489 Fix several problems after HBASE-27304 (#4903)
Signed-off-by: Duo Zhang <[email protected]>
1 parent 3f1087f commit 4add525

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@
186186
import org.apache.hbase.thirdparty.com.google.common.cache.Cache;
187187
import org.apache.hbase.thirdparty.com.google.common.cache.CacheBuilder;
188188
import org.apache.hbase.thirdparty.com.google.common.collect.Maps;
189+
import org.apache.hbase.thirdparty.com.google.common.net.InetAddresses;
189190
import org.apache.hbase.thirdparty.com.google.protobuf.BlockingRpcChannel;
190191
import org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor;
191192
import org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.ServiceDescriptor;
@@ -1383,9 +1384,17 @@ protected void handleReportForDutyResponse(final RegionServerStartupResponse c)
13831384
LOG.error(msg);
13841385
throw new IOException(msg);
13851386
}
1387+
// if Master use-ip is enabled, RegionServer use-ip will be enabled by default even if it
1388+
// is set to disable. so we will use the ip of the RegionServer to compare with the
1389+
// hostname passed by the Master, see HBASE-27304 for details.
1390+
InetSocketAddress isa = rpcServices.getSocketAddress();
1391+
// here getActiveMaster() is definitely not null.
1392+
String isaHostName = InetAddresses.isInetAddress(getActiveMaster().get().getHostname())
1393+
? isa.getAddress().getHostAddress()
1394+
: isa.getHostName();
13861395
if (
13871396
StringUtils.isBlank(useThisHostnameInstead)
1388-
&& !hostnameFromMasterPOV.equals(rpcServices.getSocketAddress().getHostName())
1397+
&& !hostnameFromMasterPOV.equals(isaHostName)
13891398
) {
13901399
String msg = "Master passed us a different hostname to use; was="
13911400
+ rpcServices.getSocketAddress().getHostName() + ", but now=" + hostnameFromMasterPOV;

0 commit comments

Comments
 (0)