GJL commented on a change in pull request #8760: [FLINK-12869] Add yarn acls
capability to flink containers
URL: https://github.com/apache/flink/pull/8760#discussion_r331455518
##########
File path:
flink-yarn-tests/src/test/java/org/apache/flink/yarn/YarnTestBase.java
##########
@@ -578,6 +579,17 @@ public static int getRunningContainers() {
return count;
}
+ public static HashMap<ContainerId, Map<ApplicationAccessType, String>>
getRunningContainersAcls() {
+ HashMap<ContainerId, Map<ApplicationAccessType, String>>
containers = new HashMap<>();
+ for (int nmId = 0; nmId < NUM_NODEMANAGERS; nmId++) {
+ NodeManager nm = yarnCluster.getNodeManager(nmId);
+ nm.getNMContext().getContainers().forEach((k, v) -> {
+ containers.put(k,
v.getLaunchContext().getApplicationACLs());
Review comment:
I think this function should go into `YARNSessionFIFOSecuredITCase`. It's
not likely that it will be used elsewhere.
Moreover, you are using a functional style (`forEach`) with side effects.
However, I think when programming in a functional style, one should just return
the result. For example:
```
private static Map<ContainerId, Map<ApplicationAccessType, String>>
getRunningContainersAcls() {
return nodeManagersStream()
.flatMap(toContainersStream())
.collect(Collectors.toMap(
Map.Entry::getKey,
entry -> getApplicationACLs(entry.getValue())));
}
private static Stream<NodeManager> nodeManagersStream() {
return IntStream
.range(0, NUM_NODEMANAGERS)
.mapToObj(i -> yarnCluster.getNodeManager(i));
}
private static Function<NodeManager, Stream<Map.Entry<ContainerId,
Container>>> toContainersStream() {
return nodeManager ->
nodeManager.getNMContext().getContainers().entrySet().stream();
}
private static Map<ApplicationAccessType, String>
getApplicationACLs(final Container container) {
return container.getLaunchContext().getApplicationACLs();
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services