mirror of
https://gitee.com/wangkang/udf.git
synced 2026-11-22 04:35:13 +00:00
调整RmsJobDisallowConcurrent处理逻辑
This commit is contained in:
+49
-49
@@ -1,49 +1,49 @@
|
||||
/**
|
||||
* ITriggerLog.java
|
||||
* Created at 2017-06-01
|
||||
* Created by Administrator
|
||||
* Copyright (C) 2016 itkk.org, All rights reserved.
|
||||
*/
|
||||
package org.itkk.udf.scheduler;
|
||||
|
||||
import org.itkk.udf.scheduler.domain.ScheduledTriggerLog;
|
||||
|
||||
/**
|
||||
* 描述 : ITriggerLog
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
public interface IListenerLog {
|
||||
|
||||
/**
|
||||
* 描述 : 记录日志
|
||||
*
|
||||
* @param log log
|
||||
*/
|
||||
void save(ScheduledTriggerLog log);
|
||||
|
||||
/**
|
||||
* 描述 : 删除记录
|
||||
*
|
||||
* @param fireInstanceId fireInstanceId
|
||||
*/
|
||||
void delete(String fireInstanceId);
|
||||
|
||||
/**
|
||||
* 描述 : 清理日志
|
||||
*/
|
||||
void clearScheduledTriggerLog();
|
||||
|
||||
/**
|
||||
* 描述 : 记录日志
|
||||
*
|
||||
* @param log log
|
||||
*/
|
||||
void save(String log);
|
||||
|
||||
/**
|
||||
* 描述 : 清理日志
|
||||
*/
|
||||
void clearScheduledLog();
|
||||
|
||||
}
|
||||
/**
|
||||
* ITriggerLog.java
|
||||
* Created at 2017-06-01
|
||||
* Created by Administrator
|
||||
* Copyright (C) 2016 itkk.org, All rights reserved.
|
||||
*/
|
||||
package org.itkk.udf.scheduler;
|
||||
|
||||
import org.itkk.udf.scheduler.domain.ScheduledTriggerLog;
|
||||
|
||||
/**
|
||||
* 描述 : ITriggerLog
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
public interface IListenerEvent {
|
||||
|
||||
/**
|
||||
* 描述 : 记录日志
|
||||
*
|
||||
* @param log log
|
||||
*/
|
||||
void save(ScheduledTriggerLog log);
|
||||
|
||||
/**
|
||||
* 描述 : 删除记录
|
||||
*
|
||||
* @param fireInstanceId fireInstanceId
|
||||
*/
|
||||
void delete(String fireInstanceId);
|
||||
|
||||
/**
|
||||
* 描述 : 清理日志
|
||||
*/
|
||||
void clearScheduledTriggerLog();
|
||||
|
||||
/**
|
||||
* 描述 : 记录日志
|
||||
*
|
||||
* @param log log
|
||||
*/
|
||||
void save(String log);
|
||||
|
||||
/**
|
||||
* 描述 : 清理日志
|
||||
*/
|
||||
void clearScheduledLog();
|
||||
|
||||
}
|
||||
+42
-42
@@ -1,42 +1,42 @@
|
||||
/**
|
||||
* IRmsJobLog.java
|
||||
* Created at 2017-06-11
|
||||
* Created by Administrator
|
||||
* Copyright (C) 2016 itkk.org, All rights reserved.
|
||||
*/
|
||||
package org.itkk.udf.scheduler;
|
||||
|
||||
import org.itkk.udf.scheduler.client.domain.RmsJobParam;
|
||||
import org.itkk.udf.scheduler.client.domain.RmsJobResult;
|
||||
|
||||
/**
|
||||
* 描述 : IRmsJobLog
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
public interface IRmsJobLog {
|
||||
|
||||
/**
|
||||
* hasRunning
|
||||
*
|
||||
* @param rmsJobParam rmsJobParam
|
||||
* @return boolean
|
||||
*/
|
||||
boolean hasRunning(RmsJobParam rmsJobParam);
|
||||
|
||||
/**
|
||||
* 描述 : save
|
||||
*
|
||||
* @param param param
|
||||
* @param result result
|
||||
*/
|
||||
void save(RmsJobParam param, RmsJobResult result);
|
||||
|
||||
/**
|
||||
* 描述 : delete
|
||||
*
|
||||
* @param fireInstanceId fireInstanceId
|
||||
*/
|
||||
void delete(String fireInstanceId);
|
||||
|
||||
}
|
||||
/**
|
||||
* IRmsJobEvent.java
|
||||
* Created at 2017-06-11
|
||||
* Created by Administrator
|
||||
* Copyright (C) 2016 itkk.org, All rights reserved.
|
||||
*/
|
||||
package org.itkk.udf.scheduler;
|
||||
|
||||
import org.itkk.udf.scheduler.client.domain.RmsJobParam;
|
||||
import org.itkk.udf.scheduler.client.domain.RmsJobResult;
|
||||
|
||||
/**
|
||||
* 描述 : IRmsJobEvent
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
public interface IRmsJobEvent {
|
||||
|
||||
/**
|
||||
* hasRunning
|
||||
*
|
||||
* @param rmsJobParam rmsJobParam
|
||||
* @return boolean
|
||||
*/
|
||||
boolean hasRunning(RmsJobParam rmsJobParam);
|
||||
|
||||
/**
|
||||
* 描述 : save
|
||||
*
|
||||
* @param param param
|
||||
* @param result result
|
||||
*/
|
||||
void save(RmsJobParam param, RmsJobResult result);
|
||||
|
||||
/**
|
||||
* 描述 : delete
|
||||
*
|
||||
* @param fireInstanceId fireInstanceId
|
||||
*/
|
||||
void delete(String fireInstanceId);
|
||||
|
||||
}
|
||||
+15
-15
@@ -12,7 +12,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.itkk.udf.core.RestResponse;
|
||||
import org.itkk.udf.rms.Rms;
|
||||
import org.itkk.udf.scheduler.IRmsJobLog;
|
||||
import org.itkk.udf.scheduler.IRmsJobEvent;
|
||||
import org.itkk.udf.scheduler.client.RmsJobStats;
|
||||
import org.itkk.udf.scheduler.client.SchException;
|
||||
import org.itkk.udf.scheduler.client.TriggerDataMapKey;
|
||||
@@ -81,7 +81,7 @@ public abstract class AbstractBaseRmsJob extends AbstractBaseJob {
|
||||
RmsJobResult result = new RmsJobResult();
|
||||
result.setId(rmsJobParam.getId());
|
||||
result.setStats(RmsJobStats.SKIP.value());
|
||||
saveRmsJobLog(rmsJobParam, result);
|
||||
saveRmsJobEvent(rmsJobParam, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public abstract class AbstractBaseRmsJob extends AbstractBaseJob {
|
||||
throw new SchException("http状态:" + result.getStatusCode().toString());
|
||||
}
|
||||
//记录
|
||||
saveRmsJobLog(rmsJobParam, result.getBody().getResult());
|
||||
saveRmsJobEvent(rmsJobParam, result.getBody().getResult());
|
||||
} catch (Exception e) {
|
||||
//定义返回值
|
||||
RmsJobResult result = new RmsJobResult();
|
||||
@@ -119,7 +119,7 @@ public abstract class AbstractBaseRmsJob extends AbstractBaseJob {
|
||||
result.setStats(RmsJobStats.ERROR.value());
|
||||
result.setErrorMsg(ExceptionUtils.getStackTrace(e));
|
||||
//记录
|
||||
saveRmsJobLog(rmsJobParam, result);
|
||||
saveRmsJobEvent(rmsJobParam, result);
|
||||
//抛出异常
|
||||
log.error("RmsJob error:", e);
|
||||
throw new JobExecutionException(e);
|
||||
@@ -133,8 +133,8 @@ public abstract class AbstractBaseRmsJob extends AbstractBaseJob {
|
||||
* @return 是否正在运行
|
||||
*/
|
||||
private boolean hasRunning(RmsJobParam rmsJobParam) {
|
||||
IRmsJobLog rmsJobLog = this.getRmsJobLog();
|
||||
return rmsJobLog != null && rmsJobLog.hasRunning(rmsJobParam);
|
||||
IRmsJobEvent rmsJobEvent = this.getRmsJobEvent();
|
||||
return rmsJobEvent != null && rmsJobEvent.hasRunning(rmsJobParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,22 +143,22 @@ public abstract class AbstractBaseRmsJob extends AbstractBaseJob {
|
||||
* @param param param
|
||||
* @param result result
|
||||
*/
|
||||
private void saveRmsJobLog(RmsJobParam param, RmsJobResult result) {
|
||||
IRmsJobLog rmsJobLog = this.getRmsJobLog();
|
||||
if (rmsJobLog != null) {
|
||||
rmsJobLog.save(param, result);
|
||||
private void saveRmsJobEvent(RmsJobParam param, RmsJobResult result) {
|
||||
IRmsJobEvent rmsJobEvent = this.getRmsJobEvent();
|
||||
if (rmsJobEvent != null) {
|
||||
rmsJobEvent.save(param, result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得RmsJobLog
|
||||
* 获得RmsJobEvent
|
||||
*
|
||||
* @return IRmsJobLog
|
||||
* @return IRmsJobEvent
|
||||
*/
|
||||
private IRmsJobLog getRmsJobLog() {
|
||||
String[] beanNames = this.getApplicationContext().getBeanNamesForType(IRmsJobLog.class);
|
||||
private IRmsJobEvent getRmsJobEvent() {
|
||||
String[] beanNames = this.getApplicationContext().getBeanNamesForType(IRmsJobEvent.class);
|
||||
if (ArrayUtils.isNotEmpty(beanNames)) {
|
||||
return this.getApplicationContext().getBean(IRmsJobLog.class);
|
||||
return this.getApplicationContext().getBean(IRmsJobEvent.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import org.quartz.DisallowConcurrentExecution;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import org.itkk.udf.scheduler.IListenerLog;
|
||||
import org.itkk.udf.scheduler.IListenerEvent;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -32,7 +32,7 @@ public class ClearScheduledLog extends AbstractBaseJob {
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext jobExecutionContext)
|
||||
throws JobExecutionException {
|
||||
IListenerLog listenerLog = this.getApplicationContext().getBean(IListenerLog.class);
|
||||
IListenerEvent listenerLog = this.getApplicationContext().getBean(IListenerEvent.class);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.clearScheduledLog();
|
||||
}
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import org.quartz.DisallowConcurrentExecution;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import org.itkk.udf.scheduler.IListenerLog;
|
||||
import org.itkk.udf.scheduler.IListenerEvent;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -32,7 +32,7 @@ public class ClearScheduledTriggerLog extends AbstractBaseJob {
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext jobExecutionContext)
|
||||
throws JobExecutionException {
|
||||
IListenerLog triggerLog = this.getApplicationContext().getBean(IListenerLog.class);
|
||||
IListenerEvent triggerLog = this.getApplicationContext().getBean(IListenerEvent.class);
|
||||
if (triggerLog != null) {
|
||||
triggerLog.clearScheduledTriggerLog();
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ package org.itkk.udf.scheduler.listener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.itkk.udf.scheduler.IListenerLog;
|
||||
import org.itkk.udf.scheduler.IListenerEvent;
|
||||
import org.quartz.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class SchListener implements SchedulerListener {
|
||||
* 描述 : listenerLog
|
||||
*/
|
||||
@Autowired(required = false)
|
||||
private IListenerLog listenerLog;
|
||||
private IListenerEvent listenerLog;
|
||||
|
||||
@Override
|
||||
public void triggerPaused(TriggerKey triggerKey) {
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@
|
||||
package org.itkk.udf.scheduler.service;
|
||||
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.itkk.udf.scheduler.IListenerLog;
|
||||
import org.itkk.udf.scheduler.IListenerEvent;
|
||||
import org.itkk.udf.scheduler.SchedulerConfig;
|
||||
import org.itkk.udf.scheduler.domain.ScheduledTriggerLog;
|
||||
import org.quartz.*;
|
||||
@@ -38,7 +38,7 @@ public class ListenerService {
|
||||
* 描述 : listenerLog
|
||||
*/
|
||||
@Autowired(required = false)
|
||||
private IListenerLog listenerLog;
|
||||
private IListenerEvent listenerLog;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
||||
+2
-2
@@ -6,12 +6,12 @@
|
||||
*/
|
||||
package org.itkk.udf.scheduler.web;
|
||||
|
||||
import org.itkk.udf.scheduler.IRmsJobEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import org.itkk.udf.core.RestResponse;
|
||||
import org.itkk.udf.scheduler.IRmsJobLog;
|
||||
import org.itkk.udf.scheduler.client.domain.RmsJobResult;
|
||||
|
||||
/**
|
||||
@@ -26,7 +26,7 @@ public class SchClientCallbackController implements ISchClientCallbackController
|
||||
* 描述 : rmsJobLog
|
||||
*/
|
||||
@Autowired(required = false)
|
||||
private IRmsJobLog rmsJobLog;
|
||||
private IRmsJobEvent rmsJobLog;
|
||||
|
||||
@Override
|
||||
public RestResponse<String> callback(@RequestBody RmsJobResult result) {
|
||||
|
||||
Reference in New Issue
Block a user