Skip to content

Commit

Permalink
HDFS-16411 RBF: RouterId is NULL when set dfs.federation.router.rpc.e…
Browse files Browse the repository at this point in the history
…nable=false; checkstyle
  • Loading branch information
yulongz committed Jan 19, 2022
1 parent 54130c8 commit 4a01abb
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ protected void serviceInit(Configuration configuration) throws Exception {
addService(this.rpcServer);
this.setRpcServerAddress(rpcServer.getRpcAddress());
}

checkRouterId();

if (conf.getBoolean(
RBFConfigKeys.DFS_ROUTER_ADMIN_ENABLE,
RBFConfigKeys.DFS_ROUTER_ADMIN_ENABLE_DEFAULT)) {
Expand Down Expand Up @@ -308,19 +310,18 @@ protected void serviceInit(Configuration configuration) throws Exception {
}
}

/**
* Set the router id if not set to prevent RouterHeartbeatService
* update state store with a null router id
*/
private void checkRouterId() {
if (this.routerId == null) {
try {
String hostname = InetAddress.getLocalHost().getHostName();
InetSocketAddress confRpcAddress = conf.getSocketAddr(
RBFConfigKeys.DFS_ROUTER_RPC_BIND_HOST_KEY,
RBFConfigKeys.DFS_ROUTER_RPC_ADDRESS_KEY,
RBFConfigKeys.DFS_ROUTER_RPC_ADDRESS_DEFAULT,
RBFConfigKeys.DFS_ROUTER_RPC_PORT_DEFAULT);
setRouterId(hostname + ":" + confRpcAddress.getPort());
} catch (UnknownHostException ex) {
LOG.error("Cannot set unique router ID, address not resolvable");
}
InetSocketAddress rpcAddress = conf.getSocketAddr(
RBFConfigKeys.DFS_ROUTER_RPC_BIND_HOST_KEY,
RBFConfigKeys.DFS_ROUTER_RPC_ADDRESS_KEY,
RBFConfigKeys.DFS_ROUTER_RPC_ADDRESS_DEFAULT,
RBFConfigKeys.DFS_ROUTER_RPC_PORT_DEFAULT);
setRpcServerAddress(rpcAddress);
}
}

Expand Down

0 comments on commit 4a01abb

Please sign in to comment.