refactor(yarn-query): 优化列表的实现,减少转换

This commit is contained in:
2023-05-29 17:44:17 +08:00
parent 8e9b04acab
commit 712b19a484
3 changed files with 6 additions and 4 deletions

View File

@@ -1,6 +1,8 @@
package com.lanyuanxiaoyao.service.yarn.response;
import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnQueue;
import org.eclipse.collections.api.list.ImmutableList;
import java.util.List;
/**
@@ -54,9 +56,9 @@ public final class QueueListResponse {
}
public static final class Queues {
private List<YarnQueue> queue;
private ImmutableList<YarnQueue> queue;
public List<YarnQueue> getQueue() {
public ImmutableList<YarnQueue> getQueue() {
return queue;
}

View File

@@ -42,7 +42,7 @@ public class QueueAutoRefreshServiceImpl implements QueueService {
String queryUrl = URLUtil.completeUrl(yarnConfiguration.getWebUrl(), "/ws/v1/cluster/scheduler");
String body = HttpUtil.createGet(queryUrl).setMaxRedirectCount(10).execute().body();
QueueListResponse response = mapper.readValue(body, QueueListResponse.class);
ImmutableList<YarnQueue> queues = Lists.immutable.ofAll(response.getScheduler().getSchedulerInfo().getQueues().getQueue())
ImmutableList<YarnQueue> queues = response.getScheduler().getSchedulerInfo().getQueues().getQueue()
.tap(q -> q.setCluster(yarnConfiguration.getCluster()));
CACHE.set(queues);
}

View File

@@ -44,7 +44,7 @@ public class QueueServiceImpl implements QueueService {
String queryUrl = URLUtil.completeUrl(yarnConfiguration.getWebUrl(), "/ws/v1/cluster/scheduler");
String body = HttpUtil.createGet(queryUrl).setMaxRedirectCount(10).execute().body();
QueueListResponse response = mapper.readValue(body, QueueListResponse.class);
return Lists.immutable.ofAll(response.getScheduler().getSchedulerInfo().getQueues().getQueue()).tap(q -> q.setCluster(yarnConfiguration.getCluster()));
return response.getScheduler().getSchedulerInfo().getQueues().getQueue().tap(q -> q.setCluster(yarnConfiguration.getCluster()));
}
@Cacheable(value = "queue-detail", sync = true, key = "#name")