Commit 00c3f6ab by huangfusuper

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

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