Skip to content

Commit fc89ebe

Browse files
author
slfan1989
committed
YARN-11212. Fix CheckStyle.
1 parent 4a4e41f commit fc89ebe

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/NodeLabelsInfo.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ public NodeLabelsInfo(Set<String> nodeLabelsName) {
5656
}
5757
}
5858

59-
public NodeLabelsInfo(HashSet<NodeLabel> nodeLabels) {
59+
public NodeLabelsInfo(Collection<NodeLabel> nodeLabels) {
6060
this.nodeLabelsInfo = new ArrayList<>();
61-
for (NodeLabel label : nodeLabels) {
62-
this.nodeLabelsInfo.add(new NodeLabelInfo(label));
63-
}
61+
nodeLabels.stream().forEach(nodeLabel -> {
62+
this.nodeLabelsInfo.add(new NodeLabelInfo(nodeLabel));
63+
});
6464
}
6565

6666
public ArrayList<NodeLabelInfo> getNodeLabelsInfo() {

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/NodeToLabelsInfo.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ public NodeToLabelsInfo() {
3535
// JAXB needs this
3636
}
3737

38+
public NodeToLabelsInfo(HashMap<String, NodeLabelsInfo> nodeToLabels) {
39+
if (nodeToLabels != null) {
40+
this.nodeToLabels.putAll(nodeToLabels);
41+
}
42+
}
43+
3844
public HashMap<String, NodeLabelsInfo> getNodeToLabels() {
3945
return nodeToLabels;
4046
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,6 @@ private SubClusterInfo getNodeSubcluster(String nodeId)
951951
public NodesInfo getNodes(String states) {
952952

953953
NodesInfo nodes = new NodesInfo();
954-
955954
try {
956955
Map<SubClusterId, SubClusterInfo> subClustersActive = getActiveSubclusters();
957956
Class[] argsClasses = new Class[]{String.class};
@@ -962,13 +961,12 @@ public NodesInfo getNodes(String states) {
962961
nodesMap.values().stream().forEach(nodesInfo -> {
963962
nodes.addAll(nodesInfo.getNodes());
964963
});
965-
966964
} catch (NotFoundException e) {
967965
LOG.error("Get all active sub cluster(s) error.", e);
968966
} catch (YarnException e) {
969967
LOG.error("getNodes error.", e);
970968
} catch (IOException e) {
971-
LOG.error("getNodes error.", e);
969+
LOG.error("getNodes error with io error.", e);
972970
}
973971

974972
// Delete duplicate from all the node reports got from all the available
@@ -1398,10 +1396,9 @@ private <R> Map<SubClusterInfo, R> invokeConcurrent(Collection<SubClusterInfo> c
13981396
R ret = clazz.cast(retObj);
13991397
return ret;
14001398
} catch (Exception e) {
1401-
String msg = String.format("SubCluster %s failed to call %s method.",
1402-
info.getSubClusterId(), request.getMethodName());
1403-
LOG.error(msg, e);
1404-
throw new YarnRuntimeException(msg, e);
1399+
LOG.error("SubCluster %s failed to call %s method.",
1400+
info.getSubClusterId(), request.getMethodName(), e);
1401+
return null;
14051402
}
14061403
});
14071404
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebServiceUtil.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.Map;
3232
import java.util.Map.Entry;
3333
import java.util.Collection;
34+
import java.util.Set;
3435
import java.util.HashSet;
3536
import java.util.concurrent.TimeUnit;
3637

@@ -518,7 +519,6 @@ protected static <T> String getMediaTypeFromHttpServletRequest(
518519
public static NodeToLabelsInfo mergeNodeToLabels(
519520
Map<SubClusterInfo, NodeToLabelsInfo> nodeToLabelsInfoMap) {
520521

521-
NodeToLabelsInfo result = new NodeToLabelsInfo();
522522
HashMap<String, NodeLabelsInfo> nodeToLabels = new HashMap<>();
523523
Collection<NodeToLabelsInfo> nodeToLabelsInfos = nodeToLabelsInfoMap.values();
524524

@@ -527,7 +527,7 @@ public static NodeToLabelsInfo mergeNodeToLabels(
527527
String key = item.getKey();
528528
NodeLabelsInfo itemValue = item.getValue();
529529
NodeLabelsInfo nodeToLabelsValue = nodeToLabels.getOrDefault(item.getKey(), null);
530-
HashSet<NodeLabel> hashSet = new HashSet<>();
530+
Set<NodeLabel> hashSet = new HashSet<>();
531531
if (itemValue != null) {
532532
hashSet.addAll(itemValue.getNodeLabels());
533533
}
@@ -538,7 +538,6 @@ public static NodeToLabelsInfo mergeNodeToLabels(
538538
}
539539
});
540540

541-
result.setNodeToLabels(nodeToLabels);
542-
return result;
541+
return new NodeToLabelsInfo(nodeToLabels);
543542
}
544543
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/MockDefaultRequestInterceptorREST.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,9 @@ public NodeToLabelsInfo getNodeToLabels(HttpServletRequest hsr) throws IOExcepti
292292
NodeLabelsInfo cpuNode = new NodeLabelsInfo(Collections.singleton("CPU"));
293293
NodeLabelsInfo gpuNode = new NodeLabelsInfo(Collections.singleton("GPU"));
294294

295-
NodeToLabelsInfo info = new NodeToLabelsInfo();
296295
HashMap<String, NodeLabelsInfo> nodeLabels = new HashMap<>();
297296
nodeLabels.put("node1", cpuNode);
298297
nodeLabels.put("node2", gpuNode);
299-
info.setNodeToLabels(nodeLabels);
300-
return info;
298+
return new NodeToLabelsInfo(nodeLabels);
301299
}
302300
}

0 commit comments

Comments
 (0)