Skip to content

Commit cbe71ea

Browse files
committed
HDFS-15238. RBF: NamenodeHeartbeatService caused memory to grow rapidly. Contributed by xuzq.
1 parent eaaaba1 commit cbe71ea

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/NamenodeHeartbeatService.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ public class NamenodeHeartbeatService extends PeriodicService {
7979

8080
/** Namenode HA target. */
8181
private NNHAServiceTarget localTarget;
82+
/** Cache HA protocol. */
83+
private HAServiceProtocol localTargetHAProtocol;
8284
/** RPC address for the namenode. */
8385
private String rpcAddress;
8486
/** Service RPC address for the namenode. */
@@ -293,8 +295,10 @@ protected NamenodeStatusReport getNamenodeStatusReport() {
293295
try {
294296
// Determine if NN is active
295297
// TODO: dynamic timeout
296-
HAServiceProtocol haProtocol = localTarget.getProxy(conf, 30*1000);
297-
HAServiceStatus status = haProtocol.getServiceStatus();
298+
if (localTargetHAProtocol == null) {
299+
localTargetHAProtocol = localTarget.getProxy(conf, 30*1000);
300+
}
301+
HAServiceStatus status = localTargetHAProtocol.getServiceStatus();
298302
report.setHAServiceState(status.getState());
299303
} catch (Throwable e) {
300304
if (e.getMessage().startsWith("HA for namenode is not enabled")) {
@@ -305,6 +309,7 @@ protected NamenodeStatusReport getNamenodeStatusReport() {
305309
LOG.error("Cannot fetch HA status for {}: {}",
306310
getNamenodeDesc(), e.getMessage(), e);
307311
}
312+
localTargetHAProtocol = null;
308313
}
309314
}
310315
} catch(IOException e) {

0 commit comments

Comments
 (0)