Skip to content

Commit 2794fe2

Browse files
authored
YARN-8898. [Addendum] Improve NodeManager#TestFederationInterceptor Setup Code (#5732)
1 parent a409d52 commit 2794fe2

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/MemoryFederationStateStore.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier;
4141
import org.apache.hadoop.yarn.api.records.ApplicationId;
4242
import org.apache.hadoop.yarn.api.records.ReservationId;
43+
import org.apache.hadoop.yarn.api.records.Priority;
44+
import org.apache.hadoop.yarn.api.records.Resource;
4345
import org.apache.hadoop.yarn.conf.YarnConfiguration;
4446
import org.apache.hadoop.yarn.exceptions.YarnException;
4547
import org.apache.hadoop.yarn.server.federation.store.FederationStateStore;
@@ -668,4 +670,17 @@ public void setExpiredHeartbeat(SubClusterId subClusterId, long heartBearTime)
668670
SubClusterInfo subClusterInfo = membership.get(subClusterId);
669671
subClusterInfo.setLastHeartBeat(heartBearTime);
670672
}
673+
674+
@VisibleForTesting
675+
public void setApplicationContext(String subClusterId, ApplicationId applicationId,
676+
long createTime) {
677+
ApplicationSubmissionContext context =
678+
ApplicationSubmissionContext.newInstance(applicationId, "test", "default",
679+
Priority.newInstance(0), null, true, true,
680+
2, Resource.newInstance(10, 2), "test");
681+
SubClusterId homeSubClusterId = SubClusterId.newInstance(subClusterId);
682+
ApplicationHomeSubCluster applicationHomeSubCluster =
683+
ApplicationHomeSubCluster.newInstance(applicationId, createTime, homeSubClusterId, context);
684+
this.applications.put(applicationId, applicationHomeSubCluster);
685+
}
671686
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/TestFederationInterceptor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.apache.hadoop.registry.client.impl.FSRegistryOperationsService;
4040
import org.apache.hadoop.security.UserGroupInformation;
4141
import org.apache.hadoop.test.LambdaTestUtils;
42+
import org.apache.hadoop.util.Time;
4243
import org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest;
4344
import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse;
4445
import org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterRequest;
@@ -130,6 +131,8 @@ public void setUp() throws IOException {
130131

131132
testAppId = 1;
132133
attemptId = getApplicationAttemptId(testAppId);
134+
stateStore.setApplicationContext(HOME_SC_ID, attemptId.getApplicationId(), Time.now());
135+
133136
nmContext =
134137
new NMContext(null, null, null, null, nmStateStore, false, getConf());
135138
interceptor.init(new AMRMProxyApplicationContextImpl(nmContext, getConf(),

0 commit comments

Comments
 (0)