Skip to content

Commit b258c9a

Browse files
author
slfan1989
committed
YARN-11235. Fix CheckStyle.
1 parent 5412975 commit b258c9a

File tree

14 files changed

+32
-43
lines changed

14 files changed

+32
-43
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/router/HashBasedRouterPolicy.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public void reinitialize(
5050

5151
@Override
5252
protected SubClusterId chooseSubCluster(String queue,
53-
Map<SubClusterId, SubClusterInfo> preSelectSubClusters) throws YarnException {
54-
int chosenPosition = Math.abs(queue.hashCode() % preSelectSubClusters.size());
55-
List<SubClusterId> list = new ArrayList<>(preSelectSubClusters.keySet());
53+
Map<SubClusterId, SubClusterInfo> preSelectSubclusters) throws YarnException {
54+
int chosenPosition = Math.abs(queue.hashCode() % preSelectSubclusters.size());
55+
List<SubClusterId> list = new ArrayList<>(preSelectSubclusters.keySet());
5656
Collections.sort(list);
5757
return list.get(chosenPosition);
5858
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/router/LoadBasedRouterPolicy.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ public void reinitialize(FederationPolicyInitializationContext policyContext)
6262

6363
@Override
6464
protected SubClusterId chooseSubCluster(
65-
String queue, Map<SubClusterId, SubClusterInfo> preSelectSubClusters) throws YarnException {
65+
String queue, Map<SubClusterId, SubClusterInfo> preSelectSubclusters) throws YarnException {
6666
Map<SubClusterIdInfo, Float> weights = getPolicyInfo().getRouterPolicyWeights();
6767
SubClusterIdInfo chosen = null;
6868
long currBestMem = -1;
69-
for (Map.Entry<SubClusterId, SubClusterInfo> entry : preSelectSubClusters.entrySet()) {
69+
for (Map.Entry<SubClusterId, SubClusterInfo> entry : preSelectSubclusters.entrySet()) {
7070
SubClusterIdInfo id = new SubClusterIdInfo(entry.getKey());
7171
if (weights.containsKey(id) && weights.get(id) > 0) {
7272
long availableMemory = getAvailableMemory(entry.getValue());
@@ -78,7 +78,7 @@ protected SubClusterId chooseSubCluster(
7878
}
7979
if (chosen == null) {
8080
throw new FederationPolicyException(
81-
"Zero Active SubCluster with weight 1.");
81+
"Zero Active Subcluster with weight 1.");
8282
}
8383
return chosen.toId();
8484
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/router/LocalityRouterPolicy.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ public SubClusterId getHomeSubcluster(
132132
targetId = resolver.getSubClusterForNode(rr.getResourceName());
133133
nodeRequest = rr;
134134
} catch (YarnException e) {
135-
LOG.error("Cannot resolve node : {}.", rr.getResourceName(), e);
135+
LOG.error("Cannot resolve node : {}.", e.getMessage());
136136
}
137137
// Handle "rack" requests
138138
try {
139139
resolver.getSubClustersForRack(rr.getResourceName());
140140
rackRequest = rr;
141141
} catch (YarnException e) {
142-
LOG.error("Cannot resolve rack : {}.", rr.getResourceName(), e);
142+
LOG.error("Cannot resolve rack : {}.", e.getMessage());
143143
}
144144
// Handle "ANY" requests
145145
if (ResourceRequest.isAnyLocation(rr.getResourceName())) {
@@ -173,7 +173,7 @@ public SubClusterId getHomeSubcluster(
173173
}
174174
} catch (YarnException e) {
175175
LOG.error("Validating resource requests failed, " +
176-
"Falling back to WeightedRandomRouterPolicy placement.", e);
176+
"Falling back to WeightedRandomRouterPolicy placement : {}.", e.getMessage());
177177
// FailForward to WeightedRandomRouterPolicy
178178
// Overwrite request to use a default ANY
179179
ResourceRequest amReq = Records.newRecord(ResourceRequest.class);

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/router/RejectRouterPolicy.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717

1818
package org.apache.hadoop.yarn.server.federation.policies.router;
1919

20-
import java.util.List;
2120
import java.util.Map;
2221

23-
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
2422
import org.apache.hadoop.yarn.exceptions.YarnException;
2523
import org.apache.hadoop.yarn.server.federation.policies.FederationPolicyInitializationContext;
2624
import org.apache.hadoop.yarn.server.federation.policies.FederationPolicyInitializationContextValidator;
@@ -47,7 +45,7 @@ public void reinitialize(
4745

4846
@Override
4947
protected SubClusterId chooseSubCluster(
50-
String queue, Map<SubClusterId, SubClusterInfo> preSelectSubClusters) throws YarnException {
48+
String queue, Map<SubClusterId, SubClusterInfo> preSelectSubclusters) throws YarnException {
5149
throw new FederationPolicyException(
5250
"The policy configured for this queue (" + queue + ") "
5351
+ "reject all routing requests by construction. Application in "

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/router/UniformRandomRouterPolicy.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@
2222
import java.util.Map;
2323
import java.util.Random;
2424

25-
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
2625
import org.apache.hadoop.yarn.exceptions.YarnException;
2726
import org.apache.hadoop.yarn.server.federation.policies.FederationPolicyInitializationContext;
2827
import org.apache.hadoop.yarn.server.federation.policies.FederationPolicyInitializationContextValidator;
29-
import org.apache.hadoop.yarn.server.federation.policies.FederationPolicyUtils;
3028
import org.apache.hadoop.yarn.server.federation.policies.exceptions.FederationPolicyException;
3129
import org.apache.hadoop.yarn.server.federation.policies.exceptions.FederationPolicyInitializationException;
3230
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterId;
@@ -56,17 +54,16 @@ public void reinitialize(FederationPolicyInitializationContext policyContext)
5654
this.getClass().getCanonicalName());
5755

5856
// note: this overrides AbstractRouterPolicy and ignores the weights
59-
6057
setPolicyContext(policyContext);
6158
}
6259

6360
@Override
6461
protected SubClusterId chooseSubCluster(
65-
String queue, Map<SubClusterId, SubClusterInfo> preSelectSubClusters) throws YarnException {
66-
if (preSelectSubClusters == null || preSelectSubClusters.isEmpty()) {
67-
throw new FederationPolicyException("No available sub-cluster to choose from.");
62+
String queue, Map<SubClusterId, SubClusterInfo> preSelectSubclusters) throws YarnException {
63+
if (preSelectSubclusters == null || preSelectSubclusters.isEmpty()) {
64+
throw new FederationPolicyException("No available subcluster to choose from.");
6865
}
69-
List<SubClusterId> list = new ArrayList<>(preSelectSubClusters.keySet());
66+
List<SubClusterId> list = new ArrayList<>(preSelectSubclusters.keySet());
7067
return list.get(rand.nextInt(list.size()));
7168
}
7269
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/router/WeightedRandomRouterPolicy.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
package org.apache.hadoop.yarn.server.federation.policies.router;
2020

2121
import java.util.ArrayList;
22-
import java.util.List;
2322
import java.util.Map;
2423

25-
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
2624
import org.apache.hadoop.yarn.exceptions.YarnException;
2725
import org.apache.hadoop.yarn.server.federation.policies.FederationPolicyUtils;
2826
import org.apache.hadoop.yarn.server.federation.policies.exceptions.FederationPolicyException;
@@ -37,7 +35,7 @@
3735
public class WeightedRandomRouterPolicy extends AbstractRouterPolicy {
3836
@Override
3937
protected SubClusterId chooseSubCluster(
40-
String queue, Map<SubClusterId, SubClusterInfo> preSelectSubClusters) throws YarnException {
38+
String queue, Map<SubClusterId, SubClusterInfo> preSelectSubclusters) throws YarnException {
4139

4240
// note: we cannot pre-compute the weights, as the set of activeSubCluster
4341
// changes dynamically (and this would unfairly spread the load to
@@ -49,7 +47,7 @@ protected SubClusterId chooseSubCluster(
4947
ArrayList<SubClusterId> scIdList = new ArrayList<>();
5048
for (Map.Entry<SubClusterIdInfo, Float> entry : weights.entrySet()) {
5149
SubClusterIdInfo key = entry.getKey();
52-
if (key != null && preSelectSubClusters.containsKey(key.toId())) {
50+
if (key != null && preSelectSubclusters.containsKey(key.toId())) {
5351
weightList.add(entry.getValue());
5452
scIdList.add(key.toId());
5553
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/BaseFederationPoliciesTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ public ReservationSubmissionRequest getReservationSubmissionRequest() {
235235
return reservationSubmissionRequest;
236236
}
237237

238-
public void setReservationSubmissionRequest(ReservationSubmissionRequest reservationSubmissionRequest) {
238+
public void setReservationSubmissionRequest(
239+
ReservationSubmissionRequest reservationSubmissionRequest) {
239240
this.reservationSubmissionRequest = reservationSubmissionRequest;
240241
}
241242

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/router/BaseRouterPoliciesTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ public void testAllBlacklistSubcluster() throws YarnException {
118118
}
119119
}
120120

121-
@Test
122-
public void testNullReservationContext() throws Exception {
123-
FederationRouterPolicy policy = ((FederationRouterPolicy) getPolicy());
121+
@Test
122+
public void testNullReservationContext() throws Exception {
123+
FederationRouterPolicy policy = ((FederationRouterPolicy) getPolicy());
124124

125-
LambdaTestUtils.intercept(FederationPolicyException.class,
126-
"The ReservationSubmissionRequest cannot be null.",
125+
LambdaTestUtils.intercept(FederationPolicyException.class,
126+
"The ReservationSubmissionRequest cannot be null.",
127127
() -> policy.getReservationHomeSubcluster(null));
128-
}
128+
}
129129

130130
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/router/TestHashBasedRouterPolicy.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
2828
import org.apache.hadoop.yarn.exceptions.YarnException;
2929
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterId;
30-
import org.apache.hadoop.yarn.server.federation.utils.FederationPoliciesTestUtil;
3130
import org.junit.Assert;
3231
import org.junit.Before;
3332
import org.junit.Test;

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/router/TestLoadBasedRouterPolicy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void testIfNoSubclustersWithWeightOne() {
133133
fail();
134134
} catch (YarnException ex) {
135135
Assert.assertTrue(
136-
ex.getMessage().contains("Zero Active SubCluster with weight 1."));
136+
ex.getMessage().contains("Zero Active Subcluster with weight 1."));
137137
}
138138
}
139139
}

0 commit comments

Comments
 (0)