diff --git a/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/YarnClusterService.java b/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/YarnClusterService.java index 6cc04c9..dade157 100644 --- a/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/YarnClusterService.java +++ b/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/YarnClusterService.java @@ -1,6 +1,5 @@ package com.lanyuanxiaoyao.service.forest.service; -import cn.hutool.core.lang.Pair; import cn.hutool.core.util.ObjectUtil; import com.eshore.odcp.hudi.connector.Constants; import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnApplication; @@ -13,11 +12,9 @@ import java.util.function.Function; import javax.annotation.Nullable; import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.factory.Maps; -import org.eclipse.collections.api.factory.Sets; import org.eclipse.collections.api.list.ImmutableList; import org.eclipse.collections.api.map.ImmutableMap; import org.eclipse.collections.api.map.MutableMap; -import org.eclipse.collections.api.set.ImmutableSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -60,8 +57,8 @@ public class YarnClusterService { return servicesMap.valuesView().toList().toImmutable(); } - public ImmutableList services(ImmutableSet clusters) { - return clusters.toList().collect(this::service).toImmutable(); + public ImmutableList services(ImmutableList clusters) { + return clusters.collect(this::service); } public ImmutableMap servicesMap() { @@ -73,30 +70,30 @@ public class YarnClusterService { } public ImmutableList jobList(String cluster) { - return jobList(Sets.immutable.of(cluster)); + return jobList(Lists.immutable.of(cluster)); } - public ImmutableList jobList(ImmutableSet clusters) { + public ImmutableList jobList(ImmutableList clusters) { return list(clusters, YarnService::jobList); } public ImmutableList jobListEquals(String cluster, String name) { - return jobListEquals(Sets.immutable.of(cluster), name); + return jobListEquals(Lists.immutable.of(cluster), name); } - public ImmutableList jobListEquals(ImmutableSet clusters, String name) { + public ImmutableList jobListEquals(ImmutableList clusters, String name) { return list(clusters, yarnService -> yarnService.jobListEquals(name)); } public ImmutableList jobListLike(String cluster, String text) { - return jobListLike(Sets.immutable.of(cluster), text); + return jobListLike(Lists.immutable.of(cluster), text); } - public ImmutableList jobListLike(ImmutableSet clusters, String text) { + public ImmutableList jobListLike(ImmutableList clusters, String text) { return list(clusters, yarnService -> yarnService.jobListLike(text)); } - private ImmutableList list(ImmutableSet clusters, Function> getter) { + private ImmutableList list(ImmutableList clusters, Function> getter) { if (ObjectUtil.isEmpty(clusters)) { return Lists.immutable.empty(); } @@ -119,7 +116,7 @@ public class YarnClusterService { return servicesMap.containsKey(cluster) ? service(cluster).queueList() : Lists.immutable.empty(); } - public ImmutableList queueList(ImmutableSet clusters) { + public ImmutableList queueList(ImmutableList clusters) { //noinspection DataFlowIssue return clusters.toList() .select(servicesMap::containsKey) @@ -134,7 +131,7 @@ public class YarnClusterService { return servicesMap.containsKey(cluster) ? service(cluster).queueDetail(name) : null; } - public ImmutableList queueDetail(ImmutableSet clusters, String name) { + public ImmutableList queueDetail(ImmutableList clusters, String name) { //noinspection DataFlowIssue return clusters.toList() .select(servicesMap::containsKey) @@ -149,7 +146,7 @@ public class YarnClusterService { return servicesMap.containsKey(cluster) ? service(cluster).cluster() : null; } - public ImmutableList cluster(ImmutableSet clusters) { + public ImmutableList cluster(ImmutableList clusters) { //noinspection DataFlowIssue return clusters.toList() .select(servicesMap::containsKey) diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/YarnController.java b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/YarnController.java index 223dddf..168b10a 100644 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/YarnController.java +++ b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/YarnController.java @@ -19,7 +19,6 @@ import java.util.concurrent.Executors; import java.util.function.Function; import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.factory.Maps; -import org.eclipse.collections.api.factory.Sets; import org.eclipse.collections.api.list.ImmutableList; import org.eclipse.collections.api.map.ImmutableMap; import org.slf4j.Logger; @@ -70,7 +69,7 @@ public class YarnController extends BaseController { boolean isSearchId = StrUtil.isNotBlank(searchId); boolean isSearchName = StrUtil.isNotBlank(searchName); Comparator comparator = ComparatorUtil.longComparator(order, direction, SORT_MAP); - ImmutableList applications = yarnClusterService.jobList(Sets.immutable.ofAll(clusters)) + ImmutableList applications = yarnClusterService.jobList(Lists.immutable.ofAll(clusters)) .asParallel(EXECUTOR, 1) .select(app -> !isFilterState || ObjectUtil.contains(filterState, app.getState())) .select(app -> !isFilterFinalStatus || ObjectUtil.contains(filterFinalStatus, app.getFinalStatus())) @@ -91,7 +90,7 @@ public class YarnController extends BaseController { @GetMapping("job_current") public AmisResponse jobCurrent(@RequestParam("clusters") List clusters, @RequestParam("name") String name) { - Optional currentApp = yarnClusterService.jobListEquals(Sets.immutable.ofAll(clusters), name) + Optional currentApp = yarnClusterService.jobListEquals(Lists.immutable.ofAll(clusters), name) .asParallel(EXECUTOR, 1) .select(app -> ObjectUtil.equals(app.getState(), "RUNNING")) .toSortedList(ComparatorUtil.longComparator("startedTime", ComparatorUtil.DESC, SORT_MAP)) @@ -109,7 +108,7 @@ public class YarnController extends BaseController { public AmisResponse queueList(@RequestParam("clusters") List clusters, @RequestParam(value = "names", defaultValue = "") String names) { boolean isFilterNames = StrUtil.isNotBlank(names); ImmutableList filterNames = Lists.immutable.of(names.split(",")); - ImmutableList results = yarnClusterService.services(Sets.immutable.ofAll(clusters)) + ImmutableList results = yarnClusterService.services(Lists.immutable.ofAll(clusters)) .asParallel(EXECUTOR, 1) .collect(yarnService -> { YarnRootQueue cluster = yarnService.cluster(); @@ -123,11 +122,11 @@ public class YarnController extends BaseController { @GetMapping("queue_names") public AmisResponse queueNames(@RequestParam("clusters") List clusters) { - return responseData(MapUtil.of("queueNames", yarnClusterService.queueList(Sets.immutable.ofAll(clusters)).collect(YarnQueue::getQueueName))); + return responseData(MapUtil.of("queueNames", yarnClusterService.queueList(Lists.immutable.ofAll(clusters)).collect(YarnQueue::getQueueName))); } @GetMapping("clusters") public AmisResponse clusters(@RequestParam("clusters") List clusters) { - return responseData(MapUtil.of("cluster", yarnClusterService.cluster(Sets.immutable.ofAll(clusters)))); + return responseData(MapUtil.of("cluster", yarnClusterService.cluster(Lists.immutable.ofAll(clusters)))); } }