Skip to content

Commit 63c3696

Browse files
author
slfan1989
committed
YARN-11235. Fix CheckStyle.
1 parent aeea18b commit 63c3696

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
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/AbstractRouterPolicy.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ public SubClusterId getHomeSubcluster(ApplicationSubmissionContext appContext,
161161
public SubClusterId getReservationHomeSubcluster(ReservationSubmissionRequest request)
162162
throws YarnException {
163163
if (request == null) {
164-
throw new FederationPolicyException(
165-
"The ReservationSubmissionRequest cannot be null.");
164+
throw new FederationPolicyException("The ReservationSubmissionRequest cannot be null.");
166165
}
167166

168167
if (request.getQueue() == null) {

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,14 @@ public SubClusterId getHomeSubcluster(
133133
targetId = resolver.getSubClusterForNode(rr.getResourceName());
134134
nodeRequest = rr;
135135
} catch (YarnException e) {
136-
LOG.error("Cannot resolve node.", e);
136+
LOG.error("Cannot resolve node.");
137137
}
138138
// Handle "rack" requests
139139
try {
140140
resolver.getSubClustersForRack(rr.getResourceName());
141141
rackRequest = rr;
142142
} catch (YarnException e) {
143-
LOG.error("Cannot resolve rack.", e);
143+
LOG.error("Cannot resolve rack.");
144144
}
145145
// Handle "ANY" requests
146146
if (ResourceRequest.isAnyLocation(rr.getResourceName())) {

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void reinitialize(FederationPolicyInitializationContext policyContext)
6363
@Override
6464
protected SubClusterId chooseSubCluster(
6565
String queue, Map<SubClusterId, SubClusterInfo> preSelectSubClusters) throws YarnException {
66-
if(preSelectSubClusters == null || preSelectSubClusters.size() == 0) {
66+
if (preSelectSubClusters == null || preSelectSubClusters.isEmpty()) {
6767
throw new FederationPolicyException("No available sub-cluster to choose from.");
6868
}
6969
List<SubClusterId> list = new ArrayList<>(preSelectSubClusters.keySet());

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: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,21 @@ protected SubClusterId chooseSubCluster(
4343
// changes dynamically (and this would unfairly spread the load to
4444
// sub-clusters adjacent to an inactive one), hence we need to count/scan
4545
// the list and based on weight pick the next sub-cluster.
46-
Map<SubClusterIdInfo, Float> weights =
47-
getPolicyInfo().getRouterPolicyWeights();
46+
Map<SubClusterIdInfo, Float> weights = getPolicyInfo().getRouterPolicyWeights();
4847

4948
ArrayList<Float> weightList = new ArrayList<>();
5049
ArrayList<SubClusterId> scIdList = new ArrayList<>();
5150
for (Map.Entry<SubClusterIdInfo, Float> entry : weights.entrySet()) {
52-
if (entry.getKey() != null && preSelectSubClusters.containsKey(entry.getKey().toId())) {
51+
SubClusterIdInfo key = entry.getKey();
52+
if (key != null && preSelectSubClusters.containsKey(key.toId())) {
5353
weightList.add(entry.getValue());
54-
scIdList.add(entry.getKey().toId());
54+
scIdList.add(key.toId());
5555
}
5656
}
5757

5858
int pickedIndex = FederationPolicyUtils.getWeightedRandom(weightList);
5959
if (pickedIndex == -1) {
60-
throw new FederationPolicyException(
61-
"No positive weight found on active subClusters.");
60+
throw new FederationPolicyException("No positive weight found on active subclusters");
6261
}
6362
return scIdList.get(pickedIndex);
6463
}

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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.apache.hadoop.yarn.server.federation.policies;
2020

2121
import static org.mockito.Mockito.mock;
22-
import static org.mockito.Mockito.when;
2322

2423
import java.nio.ByteBuffer;
2524
import java.util.HashMap;
@@ -40,7 +39,12 @@
4039
import org.apache.hadoop.yarn.server.federation.policies.router.FederationRouterPolicy;
4140
import org.apache.hadoop.yarn.server.federation.store.FederationStateStore;
4241
import org.apache.hadoop.yarn.server.federation.store.impl.MemoryFederationStateStore;
43-
import org.apache.hadoop.yarn.server.federation.store.records.*;
42+
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterId;
43+
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterIdInfo;
44+
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterInfo;
45+
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterPolicyConfiguration;
46+
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterState;
47+
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterRegisterRequest;
4448
import org.apache.hadoop.yarn.server.federation.utils.FederationPoliciesTestUtil;
4549
import org.apache.hadoop.yarn.server.federation.utils.FederationStateStoreFacade;
4650
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/BaseRouterPoliciesTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.junit.Assert;
3838
import org.junit.Test;
3939

40-
import static org.mockito.Mockito.when;
4140

4241
/**
4342
* Base class for router policies tests, tests for null input cases.

0 commit comments

Comments
 (0)