feature(yarn-query): 适配 yarn 队列的子队列
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.lanyuanxiaoyao.service.yarn.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
@@ -11,6 +12,7 @@ import com.lanyuanxiaoyao.service.yarn.response.QueueListResponse;
|
||||
import com.lanyuanxiaoyao.service.yarn.service.QueueService;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.eclipse.collections.api.list.MutableList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
@@ -44,7 +46,17 @@ 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 response.getScheduler().getSchedulerInfo().getQueues().getQueue().tap(q -> q.setCluster(yarnConfiguration.getCluster()));
|
||||
return response.getScheduler().getSchedulerInfo().getQueues().getQueue()
|
||||
.flatCollect(q -> {
|
||||
MutableList<YarnQueue> queues = Lists.mutable.of(q);
|
||||
if (ObjectUtil.isNotNull(q.getQueues())) {
|
||||
q.getQueues().getQueue()
|
||||
.tap(q1 -> q1.setQueueName(StrUtil.format("{}.{}", q.getQueueName(), q1.getQueueName())))
|
||||
.forEach(queues::add);
|
||||
}
|
||||
return queues;
|
||||
})
|
||||
.tap(q -> q.setCluster(yarnConfiguration.getCluster()));
|
||||
}
|
||||
|
||||
@Cacheable(value = "queue-detail", sync = true, key = "#name")
|
||||
|
||||
Reference in New Issue
Block a user