|
@@ -1,6 +1,7 @@
|
|
|
package com.css.simulation.resource.scheduler.scheduler;
|
|
|
|
|
|
import api.common.pojo.constants.DictConstants;
|
|
|
+import api.common.util.CollectionUtil;
|
|
|
import api.common.util.LinuxUtil;
|
|
|
import api.common.util.StringUtil;
|
|
|
import api.common.util.TimeUtil;
|
|
@@ -42,31 +43,26 @@ public class TickScheduler {
|
|
|
public void tick() {
|
|
|
|
|
|
ArrayList<TaskPO> executingTaskList = taskMapper.selectExecuting();
|
|
|
- if (executingTaskList != null && executingTaskList.size() > 0) {
|
|
|
+ if (CollectionUtil.isEmpty(executingTaskList)) {
|
|
|
|
|
|
|
|
|
-
|
|
|
for (TaskPO task : executingTaskList) {
|
|
|
String taskId = task.getId();
|
|
|
String projectId = task.getPId();
|
|
|
- try {
|
|
|
- String s = redisTemplate.opsForValue().get(manualProjectTopic + ":" + projectId + ":" + taskId);
|
|
|
+ String s = redisTemplate.opsForValue().get(manualProjectTopic + ":" + projectId + ":" + taskId);
|
|
|
|
|
|
- assert s != null;
|
|
|
- long tickTime = Long.parseLong(s);
|
|
|
- long timeout = 2 * 60 * 1000L;
|
|
|
- long now = TimeUtil.getNow();
|
|
|
- long difference = now - tickTime;
|
|
|
+ assert s != null;
|
|
|
+ long tickTime = Long.parseLong(s);
|
|
|
+ long timeout = 2 * 60 * 1000L;
|
|
|
+ long now = TimeUtil.getNow();
|
|
|
+ long difference = now - tickTime;
|
|
|
|
|
|
- if (difference > timeout) {
|
|
|
- log.info("------- TickScheduler 任务" + taskId + "已超时,状态修改为:" + DictConstants.TASK_ABORTED);
|
|
|
- String podName = redisTemplate.opsForValue().get("podName:" + taskId);
|
|
|
- if (podName != null) {
|
|
|
- taskService.taskState(taskId, DictConstants.TASK_ABORTED, podName);
|
|
|
- }
|
|
|
+ if (difference > timeout) {
|
|
|
+ log.info("------- TickScheduler 任务" + taskId + "已超时,状态修改为:" + DictConstants.TASK_ABORTED);
|
|
|
+ String podName = redisTemplate.opsForValue().get("podName:" + taskId);
|
|
|
+ if (podName != null) {
|
|
|
+ taskService.taskState(taskId, DictConstants.TASK_ABORTED, podName);
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- throw new RuntimeException(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
}
|