refactor(yarn-query): 优化列表的实现,减少转换
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package com.lanyuanxiaoyao.service.yarn.response;
|
package com.lanyuanxiaoyao.service.yarn.response;
|
||||||
|
|
||||||
import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnQueue;
|
import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnQueue;
|
||||||
|
import org.eclipse.collections.api.list.ImmutableList;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,9 +56,9 @@ public final class QueueListResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final class Queues {
|
public static final class Queues {
|
||||||
private List<YarnQueue> queue;
|
private ImmutableList<YarnQueue> queue;
|
||||||
|
|
||||||
public List<YarnQueue> getQueue() {
|
public ImmutableList<YarnQueue> getQueue() {
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class QueueAutoRefreshServiceImpl implements QueueService {
|
|||||||
String queryUrl = URLUtil.completeUrl(yarnConfiguration.getWebUrl(), "/ws/v1/cluster/scheduler");
|
String queryUrl = URLUtil.completeUrl(yarnConfiguration.getWebUrl(), "/ws/v1/cluster/scheduler");
|
||||||
String body = HttpUtil.createGet(queryUrl).setMaxRedirectCount(10).execute().body();
|
String body = HttpUtil.createGet(queryUrl).setMaxRedirectCount(10).execute().body();
|
||||||
QueueListResponse response = mapper.readValue(body, QueueListResponse.class);
|
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()));
|
.tap(q -> q.setCluster(yarnConfiguration.getCluster()));
|
||||||
CACHE.set(queues);
|
CACHE.set(queues);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class QueueServiceImpl implements QueueService {
|
|||||||
String queryUrl = URLUtil.completeUrl(yarnConfiguration.getWebUrl(), "/ws/v1/cluster/scheduler");
|
String queryUrl = URLUtil.completeUrl(yarnConfiguration.getWebUrl(), "/ws/v1/cluster/scheduler");
|
||||||
String body = HttpUtil.createGet(queryUrl).setMaxRedirectCount(10).execute().body();
|
String body = HttpUtil.createGet(queryUrl).setMaxRedirectCount(10).execute().body();
|
||||||
QueueListResponse response = mapper.readValue(body, QueueListResponse.class);
|
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")
|
@Cacheable(value = "queue-detail", sync = true, key = "#name")
|
||||||
|
|||||||
Reference in New Issue
Block a user