HBASE-27333 Abort RS when the hostname is different from master seen (#4732)
Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
parent
c825c960d6
commit
f5437b9ceb
@ -1375,30 +1375,27 @@ public class HRegionServer extends HBaseServerBase<RSRpcServices>
|
|||||||
String hostnameFromMasterPOV = e.getValue();
|
String hostnameFromMasterPOV = e.getValue();
|
||||||
this.serverName = ServerName.valueOf(hostnameFromMasterPOV,
|
this.serverName = ServerName.valueOf(hostnameFromMasterPOV,
|
||||||
rpcServices.getSocketAddress().getPort(), this.startcode);
|
rpcServices.getSocketAddress().getPort(), this.startcode);
|
||||||
if (
|
String expectedHostName = rpcServices.getSocketAddress().getHostName();
|
||||||
!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);
|
|
||||||
}
|
|
||||||
// if Master use-ip is enabled, RegionServer use-ip will be enabled by default even if it
|
// 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
|
// 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.
|
// 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) && getActiveMaster().isPresent()
|
||||||
&& !hostnameFromMasterPOV.equals(isaHostName)
|
&& 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="
|
String msg = "Master passed us a different hostname to use; was="
|
||||||
+ rpcServices.getSocketAddress().getHostName() + ", but now=" + hostnameFromMasterPOV;
|
+ (StringUtils.isBlank(useThisHostnameInstead)
|
||||||
|
? rpcServices.getSocketAddress().getHostName()
|
||||||
|
: this.useThisHostnameInstead)
|
||||||
|
+ ", but now=" + hostnameFromMasterPOV;
|
||||||
LOG.error(msg);
|
LOG.error(msg);
|
||||||
|
throw new IOException(msg);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user