Skip to content

Commit fa8d7ca

Browse files
author
slfan1989
committed
YARN-11357. Fix CheckStyle.
1 parent e14c380 commit fa8d7ca

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptorRetry.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
import java.io.IOException;
2525
import java.util.ArrayList;
2626
import java.util.Arrays;
27+
import java.util.Collection;
2728
import java.util.List;
2829

30+
import org.apache.commons.lang3.StringUtils;
2931
import org.apache.hadoop.test.LambdaTestUtils;
3032
import org.apache.hadoop.yarn.MockApps;
3133
import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest;
@@ -38,6 +40,7 @@
3840
import org.apache.hadoop.yarn.api.records.Priority;
3941
import org.apache.hadoop.yarn.conf.YarnConfiguration;
4042
import org.apache.hadoop.yarn.exceptions.YarnException;
43+
import org.apache.hadoop.yarn.server.federation.policies.manager.UniformBroadcastPolicyManager;
4144
import org.apache.hadoop.yarn.server.federation.store.impl.MemoryFederationStateStore;
4245
import org.apache.hadoop.yarn.server.federation.store.records.ApplicationHomeSubCluster;
4346
import org.apache.hadoop.yarn.server.federation.store.records.GetApplicationHomeSubClusterRequest;
@@ -49,6 +52,9 @@
4952
import org.apache.hadoop.yarn.util.resource.Resources;
5053
import org.junit.Assert;
5154
import org.junit.Test;
55+
import org.junit.runner.RunWith;
56+
import org.junit.runners.Parameterized;
57+
import org.junit.runners.Parameterized.Parameters;
5258
import org.slf4j.Logger;
5359
import org.slf4j.LoggerFactory;
5460

@@ -64,14 +70,22 @@
6470
* It tests the case with SubClusters down and the Router logic of retries. We
6571
* have 1 good SubCluster and 2 bad ones for all the tests.
6672
*/
73+
@RunWith(Parameterized.class)
6774
public class TestFederationClientInterceptorRetry
6875
extends BaseRouterClientRMTest {
6976
private static final Logger LOG =
7077
LoggerFactory.getLogger(TestFederationClientInterceptorRetry.class);
7178

79+
@Parameters
80+
public static Collection<String[]> getParameters() {
81+
return Arrays.asList(new String[][] {{UniformBroadcastPolicyManager.class.getName()},
82+
{TestSequentialBroadcastPolicyManager.class.getName()}});
83+
}
84+
7285
private TestableFederationClientInterceptor interceptor;
7386
private MemoryFederationStateStore stateStore;
7487
private FederationStateStoreTestUtil stateStoreUtil;
88+
private String routerPolicyManagerName;
7589

7690
private String user = "test-user";
7791

@@ -84,6 +98,10 @@ public class TestFederationClientInterceptorRetry
8498

8599
private static List<SubClusterId> scs = new ArrayList<>();
86100

101+
public TestFederationClientInterceptorRetry(String policyManagerName) {
102+
this.routerPolicyManagerName = policyManagerName;
103+
}
104+
87105
@Override
88106
public void setUp() throws IOException {
89107
super.setUpConfig();
@@ -150,8 +168,7 @@ protected YarnConfiguration createConfiguration() {
150168
mockPassThroughInterceptorClass + "," + mockPassThroughInterceptorClass
151169
+ "," + TestableFederationClientInterceptor.class.getName());
152170

153-
conf.set(FEDERATION_POLICY_MANAGER,
154-
TestSequentialBroadcastPolicyManager.class.getName());
171+
conf.set(FEDERATION_POLICY_MANAGER, this.routerPolicyManagerName);
155172

156173
// Disable StateStoreFacade cache
157174
conf.setInt(YarnConfiguration.FEDERATION_CACHE_TIME_TO_LIVE_SECS, 0);
@@ -286,7 +303,15 @@ public void testSubmitApplicationOneBadOneGood()
286303

287304
@Test
288305
public void testSubmitApplicationTwoBadOneGood() throws Exception {
306+
289307
LOG.info("Test submitApplication with two bad, one good SC.");
308+
309+
// This test must require the TestSequentialRouterPolicy policy
310+
if (StringUtils.equals(routerPolicyManagerName,
311+
UniformBroadcastPolicyManager.class.getName())) {
312+
return;
313+
}
314+
290315
setupCluster(Arrays.asList(bad1, bad2, good));
291316
final ApplicationId appId =
292317
ApplicationId.newInstance(System.currentTimeMillis(), 1);

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestSequentialRouterPolicy.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@
3131
import java.util.List;
3232
import java.util.Map;
3333

34+
/**
35+
* This is a test strategy,
36+
* the purpose of this strategy is to return subClusters in descending order of subClusterId.
37+
*
38+
* This strategy is to verify the situation of Retry during the use of FederationClientInterceptor.
39+
* The conditions of use are as follows:
40+
* 1.We require subClusterId to be an integer.
41+
* 2.The larger the subCluster, the sooner the representative is selected.
42+
*
43+
* We have 4 subClusters, 2 normal subClusters, 2 bad subClusters.
44+
* We expect to select badSubClusters first and then goodSubClusters during testing.
45+
* We can set the subCluster like this, good1 = [0], good2 = [1], bad1 = [2], bad2 = [3].
46+
* This strategy will return [3, 2, 1, 0], The selection order of subCluster is bad2, bad1, good2, good1.
47+
*/
3448
public class TestSequentialRouterPolicy extends AbstractRouterPolicy {
3549

3650
@Override
@@ -52,7 +66,7 @@ protected SubClusterId chooseSubCluster(String queue,
5266
* Return to badCluster first.
5367
*/
5468
List<SubClusterId> subClusterIds = new ArrayList<>(preSelectSubClusters.keySet());
55-
if(subClusterIds.size() > 1){
69+
if (subClusterIds.size() > 1) {
5670
subClusterIds.sort((o1, o2) -> Integer.parseInt(o2.getId()) - Integer.parseInt(o1.getId()));
5771
}
5872
if(CollectionUtils.isNotEmpty(subClusterIds)){

0 commit comments

Comments
 (0)