Skip to content

Commit affc62b

Browse files
author
Ashutosh Gupta
committed
YARN-9425. Make initialDelay configurable for FederationStateStoreService#scheduledExecutorService
1 parent 133e8aa commit affc62b

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3920,6 +3920,13 @@ public static boolean isAclEnabled(Configuration conf) {
39203920
public static final String DEFAULT_FEDERATION_REGISTRY_BASE_KEY =
39213921
"yarnfederation/";
39223922

3923+
public static final String FEDERATION_STATESTORE_HEARTBEAT_INITIAL_DELAY_SECS =
3924+
FEDERATION_PREFIX + "state-store.heartbeat.initial-delay-secs";
3925+
3926+
// 30 secs
3927+
public static final int
3928+
DEFAULT_FEDERATION_STATESTORE_HEARTBEAT_INITIAL_DELAY_SECS = 30;
3929+
39233930
public static final String FEDERATION_STATESTORE_HEARTBEAT_INTERVAL_SECS =
39243931
FEDERATION_PREFIX + "state-store.heartbeat-interval-secs";
39253932

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3624,6 +3624,13 @@
36243624
<name>yarn.federation.enabled</name>
36253625
<value>false</value>
36263626
</property>
3627+
<property>
3628+
<description>
3629+
Initial delay for federation state-store heartbeat service.
3630+
</description>
3631+
<name>yarn.federation.state-store.heartbeat.initial-delay-secs</name>
3632+
<value>30</value>
3633+
</property>
36273634
<property>
36283635
<description>
36293636
Machine list file to be loaded by the FederationSubCluster Resolver

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/federation/FederationStateStoreService.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public class FederationStateStoreService extends AbstractService
8686
private FederationStateStore stateStoreClient = null;
8787
private SubClusterId subClusterId;
8888
private long heartbeatInterval;
89+
private long heartbeatInitialDelay;
8990
private RMContext rmContext;
9091

9192
public FederationStateStoreService(RMContext rmContext) {
@@ -120,6 +121,14 @@ protected void serviceInit(Configuration conf) throws Exception {
120121
heartbeatInterval =
121122
YarnConfiguration.DEFAULT_FEDERATION_STATESTORE_HEARTBEAT_INTERVAL_SECS;
122123
}
124+
125+
heartbeatInitialDelay = conf.getLong(
126+
YarnConfiguration.FEDERATION_STATESTORE_HEARTBEAT_INITIAL_DELAY_SECS,
127+
YarnConfiguration.DEFAULT_FEDERATION_STATESTORE_HEARTBEAT_INITIAL_DELAY_SECS);
128+
if (heartbeatInitialDelay <= 0) {
129+
heartbeatInitialDelay =
130+
YarnConfiguration.DEFAULT_FEDERATION_STATESTORE_HEARTBEAT_INITIAL_DELAY_SECS;
131+
}
123132
LOG.info("Initialized federation membership service.");
124133

125134
super.serviceInit(conf);
@@ -196,7 +205,7 @@ private void registerAndInitializeHeartbeat() {
196205
scheduledExecutorService =
197206
HadoopExecutors.newSingleThreadScheduledExecutor();
198207
scheduledExecutorService.scheduleWithFixedDelay(stateStoreHeartbeat,
199-
heartbeatInterval, heartbeatInterval, TimeUnit.SECONDS);
208+
heartbeatInitialDelay, heartbeatInterval, TimeUnit.SECONDS);
200209
LOG.info("Started federation membership heartbeat with interval: {}",
201210
heartbeatInterval);
202211
}

0 commit comments

Comments
 (0)