Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -3,7 +3,7 @@ package com.sdm.common.entity.resp.pbs.hpc;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class NodeViewResp {
|
||||
public class NodeViewResp extends HpcBaseResp {
|
||||
private String systemId;
|
||||
private String systemGuid;
|
||||
private String jobTypes;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.sdm.common.entity.resp.pbs.hpc;
|
||||
package com.sdm.common.entity.resp.pbs.hpc.nodecore;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class NodeListCoreResp {
|
||||
public class NodeListCore {
|
||||
private String nodeProcessor; // 如:CARSAFECLIENT - 0
|
||||
private String state; // Idle / Running / Offline
|
||||
private String jobId; // 可能为空
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.sdm.common.entity.resp.pbs.hpc.nodecore;
|
||||
|
||||
import com.sdm.common.entity.resp.pbs.hpc.HpcBaseResp;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class NodeListCoreResp extends HpcBaseResp {
|
||||
|
||||
private List<NodeListCore> nodeCores;
|
||||
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.sdm.common.entity.resp.pbs.hpc;
|
||||
package com.sdm.common.entity.resp.pbs.hpc.nodelist;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class NodeListResp {
|
||||
public class NodeList {
|
||||
private String nodeName;
|
||||
private String state;
|
||||
private String max;
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.sdm.common.entity.resp.pbs.hpc.nodelist;
|
||||
|
||||
import com.sdm.common.entity.resp.pbs.hpc.HpcBaseResp;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class NodeListResp extends HpcBaseResp {
|
||||
private List<NodeList> nodes;
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.sdm.common.utils;
|
||||
|
||||
import com.sdm.common.entity.resp.pbs.hpc.*;
|
||||
import com.sdm.common.entity.resp.pbs.hpc.nodecore.NodeListCore;
|
||||
import com.sdm.common.entity.resp.pbs.hpc.nodelist.NodeList;
|
||||
import com.sdm.common.log.CoreLogger;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -343,13 +345,13 @@ public class HpcCommandResulParseUtil {
|
||||
|
||||
|
||||
|
||||
public static List<NodeListResp> parseNodList(String cmdOutput) {
|
||||
List<NodeListResp> result = new ArrayList<>();
|
||||
public static List<NodeList> parseNodList(String cmdOutput) {
|
||||
List<NodeList> result = new ArrayList<>();
|
||||
if (cmdOutput == null || cmdOutput.trim().isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
String[] lines = cmdOutput.split("\r?\n");
|
||||
NodeListResp current = null;
|
||||
NodeList current = null;
|
||||
for (String line : lines) {
|
||||
String trimmed = line.trim();
|
||||
// 空行 = 一个节点结束
|
||||
@@ -362,7 +364,7 @@ public class HpcCommandResulParseUtil {
|
||||
}
|
||||
// 新的 Node 记录开始
|
||||
if (trimmed.startsWith("Node Name")) {
|
||||
current = new NodeListResp();
|
||||
current = new NodeList();
|
||||
}
|
||||
if (current != null && trimmed.contains(":")) {
|
||||
String[] kv = trimmed.split(":", 2);
|
||||
@@ -387,12 +389,12 @@ public class HpcCommandResulParseUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<NodeListCoreResp> parseNodeCoreList(String cmdOutput) {
|
||||
List<NodeListCoreResp> list = new ArrayList<>();
|
||||
public static List<NodeListCore> parseNodeCoreList(String cmdOutput) {
|
||||
List<NodeListCore> list = new ArrayList<>();
|
||||
// 按空行分割每个 Core 的块
|
||||
String[] blocks = cmdOutput.split("\\n\\s*\\n");
|
||||
for (String block : blocks) {
|
||||
NodeListCoreResp resp = new NodeListCoreResp();
|
||||
NodeListCore resp = new NodeListCore();
|
||||
String[] lines = block.split("\\n");
|
||||
String lastKey = null;
|
||||
StringBuilder lastValue = new StringBuilder();
|
||||
@@ -422,7 +424,7 @@ public class HpcCommandResulParseUtil {
|
||||
}
|
||||
|
||||
// 将字段名映射到 Java 对象
|
||||
private static void applyField(NodeListCoreResp resp, String key, String value) {
|
||||
private static void applyField(NodeListCore resp, String key, String value) {
|
||||
switch (key) {
|
||||
case "Node Processor":
|
||||
resp.setNodeProcessor(value);
|
||||
@@ -444,12 +446,9 @@ public class HpcCommandResulParseUtil {
|
||||
|
||||
public static NodeViewResp parseNodeView(String cmdOutput) {
|
||||
NodeViewResp resp = new NodeViewResp();
|
||||
|
||||
String[] lines = cmdOutput.split("\\n");
|
||||
|
||||
String lastKey = null;
|
||||
StringBuilder lastValue = new StringBuilder();
|
||||
|
||||
for (String line : lines) {
|
||||
if (line.contains(":")) {
|
||||
// 保存上一对 key-value
|
||||
|
||||
Reference in New Issue
Block a user