goiri commented on a change in pull request #3346:
URL: https://github.com/apache/hadoop/pull/3346#discussion_r700547922
##########
File path:
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/NamenodeHeartbeatService.java
##########
@@ -113,47 +117,93 @@ public NamenodeHeartbeatService(
}
+ /**
+ * Create a new Namenode status updater.
+ *
+ * @param resolver Namenode resolver service to handle NN registration.
+ * @param nsId Identifier of the nameservice.
+ * @param nnId Identifier of the namenode in HA.
+ * @param resolvedHost resolvedHostname for this specific namenode.
+ */
+ public NamenodeHeartbeatService(
+ ActiveNamenodeResolver resolver, String nsId, String nnId, String
resolvedHost) {
+ super(getNnHeartBeatServiceName(nsId, nnId));
+
+ this.resolver = resolver;
+
+ this.nameserviceId = nsId;
+ // Concat a uniq id from original nnId and resolvedHost
+ this.namenodeId = nnId + "-" + resolvedHost;
+ this.resolvedHost = resolvedHost;
+ // Same the original nnid to get the ports from config.
+ this.originalNnId = nnId;
+
+ }
+
@Override
protected void serviceInit(Configuration configuration) throws Exception {
this.conf = DFSHAAdmin.addSecurityConfiguration(configuration);
String nnDesc = nameserviceId;
if (this.namenodeId != null && !this.namenodeId.isEmpty()) {
- this.localTarget = new NNHAServiceTarget(
- conf, nameserviceId, namenodeId);
nnDesc += "-" + namenodeId;
} else {
this.localTarget = null;
}
+ if (originalNnId == null) {
+ originalNnId = namenodeId;
+ }
+
// Get the RPC address for the clients to connect
- this.rpcAddress = getRpcAddress(conf, nameserviceId, namenodeId);
+ this.rpcAddress = getRpcAddress(conf, nameserviceId, originalNnId);
+ if (resolvedHost != null) {
+ rpcAddress = resolvedHost + ":"
+ + NetUtils.createSocketAddr(rpcAddress).getPort();
+ }
LOG.info("{} RPC address: {}", nnDesc, rpcAddress);
// Get the Service RPC address for monitoring
this.serviceAddress =
- DFSUtil.getNamenodeServiceAddr(conf, nameserviceId, namenodeId);
+ DFSUtil.getNamenodeServiceAddr(conf, nameserviceId, originalNnId);
if (this.serviceAddress == null) {
LOG.error("Cannot locate RPC service address for NN {}, " +
"using RPC address {}", nnDesc, this.rpcAddress);
this.serviceAddress = this.rpcAddress;
}
+ if (resolvedHost != null) {
Review comment:
There might be already a function to do the split and make it resilient
without having to set a socket.
Take a look at NetUtils to see if there is something.
If there is not, please create a static function that does the split and
adds some checks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]