refactor(web): 优化 yarn 信息的获取

This commit is contained in:
2023-05-31 21:37:57 +08:00
parent 6132f46325
commit 8bfb274dde
2 changed files with 21 additions and 49 deletions

View File

@@ -96,8 +96,8 @@ public class YarnClusterService {
return Lists.immutable.empty();
}
return clusters.collect(this::service)
.asParallel(EXECUTOR, 1)
.reject(ObjectUtil::isNull)
.asParallel(EXECUTOR, 1)
.flatCollect(getter::apply)
.toList()
.toImmutable();
@@ -113,19 +113,14 @@ public class YarnClusterService {
return servicesMap.containsKey(cluster) ? service(cluster).queueList() : Lists.immutable.empty();
}
public ImmutableMap<String, ImmutableList<YarnQueue>> queueList(ImmutableSet<String> clusters) {
public ImmutableList<YarnQueue> queueList(ImmutableSet<String> clusters) {
//noinspection DataFlowIssue
return clusters
.select(servicesMap::containsKey)
.asParallel(EXECUTOR, 1)
.collect(cluster -> {
YarnService service = service(cluster);
@SuppressWarnings("DataFlowIssue")
ImmutableList<YarnQueue> queues = service.queueList();
return new Pair<>(cluster, queues);
})
.toMap(Pair::getKey, Pair::getValue)
.flatCollect(cluster -> service(cluster).queueList())
.toList()
.toImmutable();
}
@SuppressWarnings("DataFlowIssue")
@@ -133,17 +128,13 @@ public class YarnClusterService {
return servicesMap.containsKey(cluster) ? service(cluster).queueDetail(name) : null;
}
public ImmutableMap<String, YarnQueue> queueDetail(ImmutableSet<String> clusters, String name) {
public ImmutableList<YarnQueue> queueDetail(ImmutableSet<String> clusters, String name) {
//noinspection DataFlowIssue
return clusters
.select(servicesMap::containsKey)
.asParallel(EXECUTOR, 1)
.collect(cluster -> {
YarnService service = service(cluster);
@SuppressWarnings("DataFlowIssue")
YarnQueue queue = service.queueDetail(name);
return new Pair<>(cluster, queue);
})
.toMap(Pair::getKey, Pair::getValue)
.collect(cluster -> service(cluster).queueDetail(name))
.toList()
.toImmutable();
}
@@ -152,18 +143,13 @@ public class YarnClusterService {
return servicesMap.containsKey(cluster) ? service(cluster).cluster() : null;
}
public ImmutableMap<String, YarnRootQueue> cluster(ImmutableSet<String> clusters) {
public ImmutableList<YarnRootQueue> cluster(ImmutableSet<String> clusters) {
//noinspection DataFlowIssue
return clusters
.select(servicesMap::containsKey)
.asParallel(EXECUTOR, 1)
.collect(cluster -> {
YarnService service = service(cluster);
@SuppressWarnings("DataFlowIssue")
YarnRootQueue queues = service.cluster();
return new Pair<>(cluster, queues);
})
.toMap(Pair::getKey, Pair::getValue)
.collect(cluster -> service(cluster).cluster())
.toList()
.toImmutable();
}
}