Skip to content

Commit 40f6d99

Browse files
author
slfan1989
committed
YARN-11290. Fix CodeStyle.
1 parent 7de66bf commit 40f6d99

4 files changed

Lines changed: 21 additions & 8 deletions

File tree

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: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public GetApplicationsHomeSubClusterResponse getApplicationsHomeSubCluster(
269269
SubClusterId requestSC = request.getSubClusterId();
270270
List<ApplicationHomeSubCluster> result = applications.keySet().stream()
271271
.map(applicationId -> generateAppHomeSC(applicationId))
272-
.filter(appHomeSC -> judgeAdd(requestSC, appHomeSC.getHomeSubCluster()))
272+
.filter(appHomeSC -> filterHomeSubCluster(requestSC, appHomeSC.getHomeSubCluster()))
273273
.limit(maxAppsInStateStore)
274274
.collect(Collectors.toList());
275275

@@ -282,12 +282,21 @@ private ApplicationHomeSubCluster generateAppHomeSC(ApplicationId applicationId)
282282
return ApplicationHomeSubCluster.newInstance(applicationId, subClusterId);
283283
}
284284

285-
private boolean judgeAdd(SubClusterId filterSubCluster, SubClusterId homeSubCluster) {
285+
private boolean filterHomeSubCluster(SubClusterId filterSubCluster,
286+
SubClusterId homeSubCluster) {
287+
288+
// If the filter condition is empty,
289+
// it means that homeSubCluster needs to be added
286290
if (filterSubCluster == null) {
287291
return true;
288-
} else if (filterSubCluster.equals(homeSubCluster)) {
292+
}
293+
294+
// If the filter condition filterSubCluster is not empty,
295+
// and filterSubCluster is equal to homeSubCluster, it needs to be added
296+
if (filterSubCluster.equals(homeSubCluster)) {
289297
return true;
290298
}
299+
291300
return false;
292301
}
293302

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public GetApplicationsHomeSubClusterResponse getApplicationsHomeSubCluster(
272272
List<String> children = zkManager.getChildren(appsZNode);
273273
List<ApplicationHomeSubCluster> result =
274274
children.stream().map(child -> generateAppHomeSC(child))
275-
.filter(appHomeSC -> judgeAdd(requestSC, appHomeSC.getHomeSubCluster()))
275+
.filter(appHomeSC -> filterHomeSubCluster(requestSC, appHomeSC.getHomeSubCluster()))
276276
.limit(maxAppsInStateStore)
277277
.collect(Collectors.toList());
278278
long end = clock.getTime();
@@ -300,7 +300,8 @@ private ApplicationHomeSubCluster generateAppHomeSC(String appId) {
300300
return null;
301301
}
302302

303-
private boolean judgeAdd(SubClusterId filterSubCluster, SubClusterId homeSubCluster) {
303+
private boolean filterHomeSubCluster(SubClusterId filterSubCluster,
304+
SubClusterId homeSubCluster) {
304305
if (filterSubCluster == null) {
305306
return true;
306307
} else if (filterSubCluster.equals(homeSubCluster)) {

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationsHomeSubClusterRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.hadoop.yarn.server.federation.store.records;
1919

2020
import org.apache.hadoop.classification.InterfaceAudience;
21+
import org.apache.hadoop.classification.InterfaceAudience.Public;
2122
import org.apache.hadoop.classification.InterfaceAudience.Private;
2223
import org.apache.hadoop.classification.InterfaceStability.Unstable;
2324
import org.apache.hadoop.yarn.util.Records;
@@ -54,7 +55,7 @@ public static GetApplicationsHomeSubClusterRequest newInstance() {
5455
*
5556
* @return the subcluster identifier
5657
*/
57-
@InterfaceAudience.Public
58+
@Public
5859
@Unstable
5960
public abstract SubClusterId getSubClusterId();
6061

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/impl/FederationStateStoreBaseTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public abstract class FederationStateStoreBaseTest {
8383

8484
private static final MonotonicClock CLOCK = new MonotonicClock();
8585
private FederationStateStore stateStore;
86+
private static final int TEN_ROUNDS = 10;
87+
private static final int TWENTY_ROUNDS = 20;
8688

8789
protected abstract FederationStateStore createStateStore();
8890

@@ -426,7 +428,7 @@ public void testGetApplicationsHomeSubClusterFilter() throws Exception {
426428

427429
Set<ApplicationHomeSubCluster> appHomeSubClusters = new HashSet<>();
428430

429-
for (int i = 0; i < 10; i++) {
431+
for (int i = 0; i < TEN_ROUNDS; i++) {
430432
ApplicationId appId = ApplicationId.newInstance(now, i);
431433
SubClusterId subClusterId = SubClusterId.newInstance("SC1");
432434
addApplicationHomeSC(appId, subClusterId);
@@ -436,7 +438,7 @@ public void testGetApplicationsHomeSubClusterFilter() throws Exception {
436438
}
437439

438440
// Add ApplicationHomeSC - SC2
439-
for (int i = 10; i < 20; i++) {
441+
for (int i = TEN_ROUNDS; i < TWENTY_ROUNDS; i++) {
440442
ApplicationId appId = ApplicationId.newInstance(now, i);
441443
SubClusterId subClusterId = SubClusterId.newInstance("SC2");
442444
addApplicationHomeSC(appId, subClusterId);

0 commit comments

Comments
 (0)