HDFS-15238. RBF: NamenodeHeartbeatService caused memory to grow rapidly. Contributed by xuzq.

This commit is contained in:
Ayush Saxena 2020-03-27 13:42:06 +05:30
parent eaaaba12b1
commit cbe71eaddf

View File

@ -79,6 +79,8 @@ public class NamenodeHeartbeatService extends PeriodicService {
/** Namenode HA target. */
private NNHAServiceTarget localTarget;
/** Cache HA protocol. */
private HAServiceProtocol localTargetHAProtocol;
/** RPC address for the namenode. */
private String rpcAddress;
/** Service RPC address for the namenode. */
@ -293,8 +295,10 @@ protected NamenodeStatusReport getNamenodeStatusReport() {
try {
// Determine if NN is active
// TODO: dynamic timeout
HAServiceProtocol haProtocol = localTarget.getProxy(conf, 30*1000);
HAServiceStatus status = haProtocol.getServiceStatus();
if (localTargetHAProtocol == null) {
localTargetHAProtocol = localTarget.getProxy(conf, 30*1000);
}
HAServiceStatus status = localTargetHAProtocol.getServiceStatus();
report.setHAServiceState(status.getState());
} catch (Throwable e) {
if (e.getMessage().startsWith("HA for namenode is not enabled")) {
@ -305,6 +309,7 @@ protected NamenodeStatusReport getNamenodeStatusReport() {
LOG.error("Cannot fetch HA status for {}: {}",
getNamenodeDesc(), e.getMessage(), e);
}
localTargetHAProtocol = null;
}
}
} catch(IOException e) {