|
|
@@ -8,6 +8,7 @@ import cn.com.yusys.manager.util.ParseInstanceClient;
|
|
|
import cn.com.yusys.manager.common.PortPool;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -17,6 +18,7 @@ import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.ThreadLocalRandom;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -56,6 +58,12 @@ public class InstanceMonitorService {
|
|
|
@Resource
|
|
|
private TaskRecordService taskRecordService;
|
|
|
|
|
|
+ @Value("${parser.filePath.source}")
|
|
|
+ private String sourcePath;
|
|
|
+
|
|
|
+ @Value("${parser.filePath.target}")
|
|
|
+ private String targetPath;
|
|
|
+
|
|
|
@PostConstruct
|
|
|
public void initParseInstance(){
|
|
|
log.info("开始初始化解析实例...");
|
|
|
@@ -329,7 +337,8 @@ public class InstanceMonitorService {
|
|
|
public ExecuteResponse processMultimodalTask(Task task) {
|
|
|
Map<String, InstanceStatus> activeInstancePool = instancestatusRegistry.getActiveInstancePool();
|
|
|
String taskId = task.getTaskId();
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
try {
|
|
|
TaskRecordRequest taskRecordRequest=new TaskRecordRequest();
|
|
|
taskRecordRequest.setTaskId(taskId);
|
|
|
@@ -403,9 +412,9 @@ public class InstanceMonitorService {
|
|
|
|
|
|
// 记录任务完成日志
|
|
|
if (response.getCode() == 200) {
|
|
|
- taskLogService.logTaskComplete(taskId, response.getMessage());
|
|
|
+ taskLogService.logTaskComplete(taskId, response.getMsg()+"执行结果"+response.getData());
|
|
|
} else {
|
|
|
- taskLogService.logTaskFailure(taskId,response.getMessage());
|
|
|
+ taskLogService.logTaskFailure(taskId,response.getMsg());
|
|
|
}
|
|
|
|
|
|
return response;
|
|
|
@@ -426,12 +435,12 @@ public class InstanceMonitorService {
|
|
|
* 查找空闲的解析实例
|
|
|
*/
|
|
|
private InstanceStatus findIdleInstance(Map<String, InstanceStatus> activeInstancePool) {
|
|
|
- return activeInstancePool.values().stream()
|
|
|
- .filter(status -> status.getStatus() == 0) // 状态为0表示空闲
|
|
|
- .findFirst()
|
|
|
- .orElse(null);
|
|
|
- }
|
|
|
+ List<InstanceStatus> idleList = activeInstancePool.values().stream()
|
|
|
+ .filter(status -> status.getStatus() == 0)
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
+ return idleList.isEmpty() ? null : idleList.get(ThreadLocalRandom.current().nextInt(idleList.size()));
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 执行任务
|
|
|
@@ -446,9 +455,9 @@ public class InstanceMonitorService {
|
|
|
|
|
|
// 调用解析器执行任务
|
|
|
ExecuteResponse response = callParser(instance, task);
|
|
|
-
|
|
|
+ log.info("任务执行结束,实例:{},响应:{}", instanceId, response);
|
|
|
if (response != null && response.getCode() == 200) {
|
|
|
- log.info("任务执行成功,实例:{},响应:{}", instanceId, response.getMessage());
|
|
|
+ log.info("任务执行成功,实例:{},响应:{}", instanceId, response.getMsg());
|
|
|
return response;
|
|
|
} else {
|
|
|
log.warn("任务执行失败,实例:{},响应:{}", instanceId, response);
|
|
|
@@ -474,8 +483,15 @@ public class InstanceMonitorService {
|
|
|
instance.getPort(),
|
|
|
task);
|
|
|
|
|
|
- if (response == null || response.getCode() != 200) {
|
|
|
- log.warn("调用解析器返回失败,实例:{},响应:{}", instance.getInstanceId(), response);
|
|
|
+ if (response == null || response.getCode() != 200 ) {
|
|
|
+ log.error("调用解析器返回失败,实例:{},响应:{}", instance.getInstanceId(), response);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+ String data=(String) response.getData();
|
|
|
+ if(data.startsWith("解析失败")){
|
|
|
+ log.error("解析器执行任务失败,实例:{},响应:{}", instance.getInstanceId(), response);
|
|
|
+ response.setCode(500);
|
|
|
+ response.setMsg("解析器执行任务失败");
|
|
|
}
|
|
|
return response;
|
|
|
} catch (Exception e) {
|