refactor(yarn-query): 修复 yarn 查询子队列不全
This commit is contained in:
@@ -4,6 +4,8 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnQueue;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import org.eclipse.collections.api.block.function.Function;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
@@ -23,10 +25,22 @@ public interface QueueService {
|
||||
default Function<YarnQueue, Iterable<YarnQueue>> flatChildren() {
|
||||
return queue -> {
|
||||
MutableList<YarnQueue> children = Lists.mutable.of(queue);
|
||||
if (ObjectUtil.isNotNull(queue.getQueues())) {
|
||||
queue.getQueues().getQueue()
|
||||
.tap(child -> child.setQueueName(StrUtil.format("{}.{}", queue.getQueueName(), child.getQueueName())))
|
||||
.forEach(children::add);
|
||||
Queue<YarnQueue> handleQueue = new LinkedList<>();
|
||||
handleQueue.add(queue);
|
||||
|
||||
YarnQueue parent = handleQueue.poll();
|
||||
while (parent != null) {
|
||||
try {
|
||||
if (ObjectUtil.isNotNull(parent.getQueues())) {
|
||||
for (YarnQueue child : queue.getQueues().getQueue()) {
|
||||
child.setQueueName(StrUtil.format("{}.{}", parent.getQueueName(), child.getQueueName()));
|
||||
children.add(child);
|
||||
handleQueue.add(child);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
parent = handleQueue.poll();
|
||||
}
|
||||
}
|
||||
return children;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user