Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1667,32 +1667,29 @@ protected void handleReportForDutyResponse(final RegionServerStartupResponse c)
// The hostname the master sees us as.
if (key.equals(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)) {
String hostnameFromMasterPOV = e.getValue();
this.serverName =
ServerName.valueOf(hostnameFromMasterPOV, rpcServices.isa.getPort(), this.startcode);
if (
!StringUtils.isBlank(useThisHostnameInstead)
&& !hostnameFromMasterPOV.equals(useThisHostnameInstead)
) {
String msg = "Master passed us a different hostname to use; was="
+ this.useThisHostnameInstead + ", but now=" + hostnameFromMasterPOV;
LOG.error(msg);
throw new IOException(msg);
}
this.serverName = ServerName.valueOf(hostnameFromMasterPOV,
rpcServices.getSocketAddress().getPort(), this.startcode);
String expectedHostName = rpcServices.getSocketAddress().getHostName();
// 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(isaHostName)
StringUtils.isBlank(useThisHostnameInstead) && getActiveMaster().isPresent()
&& InetAddresses.isInetAddress(getActiveMaster().get().getHostname())
) {
expectedHostName = rpcServices.getSocketAddress().getAddress().getHostAddress();
}
boolean isHostnameConsist = StringUtils.isBlank(useThisHostnameInstead)
? hostnameFromMasterPOV.equals(expectedHostName)
: hostnameFromMasterPOV.equals(useThisHostnameInstead);
if (!isHostnameConsist) {
String msg = "Master passed us a different hostname to use; was="
+ rpcServices.isa.getHostName() + ", but now=" + hostnameFromMasterPOV;
+ (StringUtils.isBlank(useThisHostnameInstead)
? rpcServices.getSocketAddress().getHostName()
: this.useThisHostnameInstead)
+ ", but now=" + hostnameFromMasterPOV;
LOG.error(msg);
throw new IOException(msg);
}
continue;
}
Expand Down