Commit 00c3f6ab by huangfusuper

【代码调整】调整扫描顺序,当扫描数据为空时!先释放资源,再睡眠!避免死锁!

parent 22d606e0
......@@ -131,8 +131,6 @@ public class JobScheduleHelper{
//在日志表里面创建一条记录
//根据 map_flow_id查询当前的版本的工作流 使用祝工作流的runId 保存到执行记录表和任务表
}else{
if("start".equals(jobTask.getNodeName()) ){
log.debug("任务:{}", jobTask);
JobTaskSchedule jobTaskSchedule = new JobTaskSchedule();
......
......@@ -75,6 +75,8 @@ public class LogScanHelper {
dateAligned(5000);
log.info("---------------------【com.byit.thread.LogScanHelper#virtualNodeScanMethod】init success------------------------");
while (!virtualNodeScanIsStop){
//是否需要睡眠
boolean isSleep = false;
Connection conn = null;
Boolean connAutoCommit = null;
PreparedStatement preparedStatement = null;
......@@ -102,7 +104,7 @@ public class LogScanHelper {
}
});
}else{
dateAligned(20000);
isSleep = true;
}
}catch (Exception e){
e.printStackTrace();
......@@ -146,6 +148,10 @@ public class LogScanHelper {
}
}
}
if(isSleep){
dateAligned(20000);
}
}
});
......@@ -162,6 +168,7 @@ public class LogScanHelper {
dateAligned(5000);
log.info("---------------------【com.byit.thread.LogScanHelper#notAlarmedNodeScanMethod】init success------------------------");
while (!notAlarmedNodeScanIsStop){
boolean isSleep = false;
Connection conn = null;
Boolean connAutoCommit = null;
PreparedStatement preparedStatement = null;
......@@ -186,11 +193,13 @@ public class LogScanHelper {
jobTaskRunLogService.updateJobTaskRunLog(endNode);
});
}else{
dateAligned(20000);
isSleep = true;
}
}catch (Exception e){
e.printStackTrace();
if(!notAlarmedNodeScanIsStop){
e.printStackTrace();
}
}finally {
if(conn != null){
try {
......@@ -230,6 +239,10 @@ public class LogScanHelper {
}
}
}
if(isSleep){
dateAligned(20000);
}
}
});
notAlarmedNodeScanThread.setName("myth-job#【LogScanHelper】#notAlarmedNodeScanThread");
......
......@@ -62,12 +62,11 @@ public class RunRecordingScanHelper {
}
public void start() {
System.out.println("------------------------");
runRecordingThread = new Thread(() -> {
dateAligned(5000);
log.info("--------------------【com.byit.thread.RunRecordingScanThread#start】init success----------------------");
while (!runRecordingThreadStop) {
dateAligned(5000);
boolean isSleep = false;
Connection conn = null;
Boolean connAutoCommit = null;
PreparedStatement preparedStatement = null;
......@@ -79,8 +78,11 @@ public class RunRecordingScanHelper {
preparedStatement.execute();
//进行操作
scanRunRec();
isSleep = true;
} catch (Exception e) {
e.printStackTrace();
if (!runRecordingThreadStop) {
e.printStackTrace();
}
} finally {
if (conn != null) {
try {
......@@ -120,6 +122,10 @@ public class RunRecordingScanHelper {
}
}
}
if(isSleep){
dateAligned(20000);
}
}
});
runRecordingThread.setDaemon(true);
......@@ -130,7 +136,6 @@ public class RunRecordingScanHelper {
private void scanRunRec() {
//查询完结且未告警的工作流信息
List<RunRecording> runRecordingByEndAndNotIsAlarm = runRecordingService.findRunRecordingByEndAndNotIsAlarm();
List<EmailAlarm> emailAlarms = new ArrayList<>(15);
if (CollectionUtil.isNotEmpty(runRecordingByEndAndNotIsAlarm)) {
runRecordingByEndAndNotIsAlarm.forEach(runRecording -> {
//如果设置为完成时告警
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment