mirror of
https://gitee.com/wangkang/udf.git
synced 2026-10-30 11:43:47 +00:00
更新
This commit is contained in:
+14
-1
@@ -14,7 +14,7 @@ import com.egridcloud.udf.scheduler.domain.ScheduledTriggerLog;
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
public interface ITriggerLog {
|
||||
public interface IListenerLog {
|
||||
|
||||
/**
|
||||
* 描述 : 记录日志
|
||||
@@ -36,4 +36,17 @@ public interface ITriggerLog {
|
||||
*/
|
||||
public void clearScheduledTriggerLog();
|
||||
|
||||
/**
|
||||
* 描述 : 记录日志
|
||||
*
|
||||
* @param log log
|
||||
*/
|
||||
public void save(String log);
|
||||
|
||||
/**
|
||||
* 描述 : 清理日志
|
||||
*
|
||||
*/
|
||||
public void clearScheduledLog();
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/**
|
||||
* ISchedulerLog.java
|
||||
* Created at 2017-06-01
|
||||
* Created by Administrator
|
||||
* Copyright (C) 2016 egridcloud.com, All rights reserved.
|
||||
*/
|
||||
package com.egridcloud.udf.scheduler;
|
||||
|
||||
/**
|
||||
* 描述 : ISchedulerLog
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
public interface ISchedulerLog {
|
||||
|
||||
/**
|
||||
* 描述 : 记录日志
|
||||
*
|
||||
* @param log log
|
||||
*/
|
||||
public void save(String log);
|
||||
|
||||
/**
|
||||
* 描述 : 清理日志
|
||||
*
|
||||
*/
|
||||
public void clearScheduledLog();
|
||||
|
||||
}
|
||||
+4
-4
@@ -10,7 +10,7 @@ import org.quartz.DisallowConcurrentExecution;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import com.egridcloud.udf.scheduler.ISchedulerLog;
|
||||
import com.egridcloud.udf.scheduler.IListenerLog;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -32,9 +32,9 @@ public class ClearScheduledLog extends AbstractBaseJob {
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext jobExecutionContext)
|
||||
throws JobExecutionException {
|
||||
ISchedulerLog schedulerLog = this.getApplicationContext().getBean(ISchedulerLog.class);
|
||||
if (schedulerLog != null) {
|
||||
schedulerLog.clearScheduledLog();
|
||||
IListenerLog listenerLog = this.getApplicationContext().getBean(IListenerLog.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 com.egridcloud.udf.scheduler.ITriggerLog;
|
||||
import com.egridcloud.udf.scheduler.IListenerLog;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -32,7 +32,7 @@ public class ClearScheduledTriggerLog extends AbstractBaseJob {
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext jobExecutionContext)
|
||||
throws JobExecutionException {
|
||||
ITriggerLog triggerLog = this.getApplicationContext().getBean(ITriggerLog.class);
|
||||
IListenerLog triggerLog = this.getApplicationContext().getBean(IListenerLog.class);
|
||||
if (triggerLog != null) {
|
||||
triggerLog.clearScheduledTriggerLog();
|
||||
}
|
||||
|
||||
+6
-6
@@ -14,7 +14,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.egridcloud.udf.scheduler.service.TriggerListenerService;
|
||||
import com.egridcloud.udf.scheduler.service.ListenerService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -38,10 +38,10 @@ public class JobDetailListener implements JobListener {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(JobDetailListener.class);
|
||||
|
||||
/**
|
||||
* 描述 : triggerListenerService
|
||||
* 描述 : listenerService
|
||||
*/
|
||||
@Autowired
|
||||
private TriggerListenerService triggerListenerService;
|
||||
private ListenerService listenerService;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
@@ -51,7 +51,7 @@ public class JobDetailListener implements JobListener {
|
||||
@Override
|
||||
public void jobToBeExecuted(JobExecutionContext context) { // 4
|
||||
try {
|
||||
this.triggerListenerService.saveJobToBeExecuted(context);
|
||||
this.listenerService.saveJobToBeExecuted(context);
|
||||
} catch (SchedulerException e) {
|
||||
LOGGER.error("jobToBeExecuted:", e);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class JobDetailListener implements JobListener {
|
||||
@Override
|
||||
public void jobExecutionVetoed(JobExecutionContext context) { // 5
|
||||
try {
|
||||
this.triggerListenerService.saveJobExecutionVetoed(context);
|
||||
this.listenerService.saveJobExecutionVetoed(context);
|
||||
} catch (SchedulerException e) {
|
||||
LOGGER.error("jobExecutionVetoed:", e);
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public class JobDetailListener implements JobListener {
|
||||
@Override
|
||||
public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) { // 6
|
||||
try {
|
||||
this.triggerListenerService.saveJobWasExecuted(context, jobException);
|
||||
this.listenerService.saveJobWasExecuted(context, jobException);
|
||||
} catch (SchedulerException e) {
|
||||
LOGGER.error("jobWasExecuted:", e);
|
||||
}
|
||||
|
||||
+51
-51
@@ -18,7 +18,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.egridcloud.udf.scheduler.ISchedulerLog;
|
||||
import com.egridcloud.udf.scheduler.IListenerLog;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -56,17 +56,17 @@ public class SchListener implements SchedulerListener {
|
||||
private static final String ZHUOYE = "作业";
|
||||
|
||||
/**
|
||||
* 描述 : schedulerLogService
|
||||
* 描述 : listenerLog
|
||||
*/
|
||||
@Autowired(required = false)
|
||||
private ISchedulerLog schedulerLogService;
|
||||
private IListenerLog listenerLog;
|
||||
|
||||
@Override
|
||||
public void triggerPaused(TriggerKey triggerKey) {
|
||||
String log = "(triggerPaused)" + triggerKey.getName() + "/" + triggerKey.getGroup() + "被暂停了";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ public class SchListener implements SchedulerListener {
|
||||
String log =
|
||||
"(triggerResumed)" + triggerKey.getName() + CHAR_1 + triggerKey.getGroup() + "被恢复了";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,8 +86,8 @@ public class SchListener implements SchedulerListener {
|
||||
+ trigger.getJobKey().getGroup() + "被触发器" + trigger.getKey().getName() + CHAR_1
|
||||
+ trigger.getKey().getGroup() + "触发了";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ public class SchListener implements SchedulerListener {
|
||||
String log =
|
||||
"(jobUnscheduled)" + triggerKey.getName() + CHAR_1 + triggerKey.getGroup() + "被移除了";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,8 +107,8 @@ public class SchListener implements SchedulerListener {
|
||||
+ trigger.getJobKey().getGroup() + ",触发器" + trigger.getKey().getName() + CHAR_1
|
||||
+ trigger.getKey().getGroup() + "已经执行完成,后续将不会继续触发";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,14 +117,14 @@ public class SchListener implements SchedulerListener {
|
||||
if (StringUtils.isEmpty(triggerGroup)) {
|
||||
String log = "(triggersPaused)" + "触发器组全部被暂停了";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
} else {
|
||||
String log = "(triggersPaused)" + "触发器组" + triggerGroup + "被暂停了";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,14 +135,14 @@ public class SchListener implements SchedulerListener {
|
||||
if (StringUtils.isEmpty(triggerGroup)) {
|
||||
String log = "(triggersResumed)" + "触发器组全部被恢复了";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
} else {
|
||||
String log = "(triggersResumed)" + "触发器组" + triggerGroup + "被恢复了";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,8 +152,8 @@ public class SchListener implements SchedulerListener {
|
||||
String log = "(jobAdded)" + ZHUOYE + jobDetail.getKey().getName() + CHAR_1
|
||||
+ jobDetail.getKey().getGroup() + "被添加了";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,8 +161,8 @@ public class SchListener implements SchedulerListener {
|
||||
public void jobDeleted(JobKey jobKey) {
|
||||
String log = "(jobDeleted)" + ZHUOYE + jobKey.getName() + CHAR_1 + jobKey.getGroup() + "被删除了";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,8 +170,8 @@ public class SchListener implements SchedulerListener {
|
||||
public void jobPaused(JobKey jobKey) {
|
||||
String log = "(jobPaused)" + ZHUOYE + jobKey.getName() + CHAR_1 + jobKey.getGroup() + "被暂停了";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,14 +180,14 @@ public class SchListener implements SchedulerListener {
|
||||
if (StringUtils.isEmpty(jobGroup)) {
|
||||
String log = "(jobsPaused)" + "作业全部被暂停了";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
} else {
|
||||
String log = "(jobsPaused)" + "作业组" + jobGroup + "被暂停了";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,8 +197,8 @@ public class SchListener implements SchedulerListener {
|
||||
public void jobResumed(JobKey jobKey) {
|
||||
String log = "(jobResumed)" + ZHUOYE + jobKey.getName() + CHAR_1 + jobKey.getGroup() + "被恢复了";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,14 +207,14 @@ public class SchListener implements SchedulerListener {
|
||||
if (StringUtils.isEmpty(jobGroup)) {
|
||||
String log = "(jobsResumed)" + "作业全部被恢复了";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
} else {
|
||||
String log = "(jobsResumed)" + "作业组" + jobGroup + "被恢复了";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,8 +225,8 @@ public class SchListener implements SchedulerListener {
|
||||
String exceptionDetail = ExceptionUtils.getStackTrace(cause);
|
||||
String log = "(schedulerError)" + "计划任务出错:" + msg + "\n" + exceptionDetail;
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,8 +234,8 @@ public class SchListener implements SchedulerListener {
|
||||
public void schedulerInStandbyMode() {
|
||||
String log = "(schedulerInStandbyMode)" + "计划任务为待机状态";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,8 +243,8 @@ public class SchListener implements SchedulerListener {
|
||||
public void schedulerStarted() {
|
||||
String log = "(schedulerStarted)" + "计划任务已经启动";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,8 +252,8 @@ public class SchListener implements SchedulerListener {
|
||||
public void schedulerStarting() {
|
||||
String log = "(schedulerStarting)" + "计划任务正在启动中";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,8 +261,8 @@ public class SchListener implements SchedulerListener {
|
||||
public void schedulerShutdown() {
|
||||
String log = "(schedulerShutdown)" + "计划任务已关闭";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,8 +270,8 @@ public class SchListener implements SchedulerListener {
|
||||
public void schedulerShuttingdown() {
|
||||
String log = "(schedulerShuttingdown)" + "计划任务正在关闭中";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,8 +279,8 @@ public class SchListener implements SchedulerListener {
|
||||
public void schedulingDataCleared() {
|
||||
String log = "(schedulingDataCleared)" + "计划任务数据被清除";
|
||||
LOGGER.info(log);
|
||||
if (schedulerLogService != null) {
|
||||
schedulerLogService.save(log);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -15,7 +15,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.egridcloud.udf.scheduler.service.TriggerListenerService;
|
||||
import com.egridcloud.udf.scheduler.service.ListenerService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -39,10 +39,10 @@ public class TriggerDetailListener implements TriggerListener {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TriggerDetailListener.class);
|
||||
|
||||
/**
|
||||
* 描述 : triggerListenerService
|
||||
* 描述 : listenerService
|
||||
*/
|
||||
@Autowired
|
||||
private TriggerListenerService triggerListenerService;
|
||||
private ListenerService listenerService;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
@@ -52,7 +52,7 @@ public class TriggerDetailListener implements TriggerListener {
|
||||
@Override
|
||||
public void triggerFired(Trigger trigger, JobExecutionContext context) { // 2
|
||||
try {
|
||||
this.triggerListenerService.saveTriggerFired(context);
|
||||
this.listenerService.saveTriggerFired(context);
|
||||
} catch (SchedulerException e) {
|
||||
LOGGER.error("triggerFired error:", e);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class TriggerDetailListener implements TriggerListener {
|
||||
public boolean vetoJobExecution(Trigger trigger, JobExecutionContext context) { // 3
|
||||
boolean vetoed = false;
|
||||
try {
|
||||
vetoed = this.triggerListenerService.saveVetoJobExecution(context);
|
||||
vetoed = this.listenerService.saveVetoJobExecution(context);
|
||||
} catch (SchedulerException e) {
|
||||
LOGGER.error("vetoJobExecution error:", e);
|
||||
}
|
||||
@@ -71,14 +71,14 @@ public class TriggerDetailListener implements TriggerListener {
|
||||
|
||||
@Override
|
||||
public void triggerMisfired(Trigger trigger) { // 1
|
||||
this.triggerListenerService.saveTriggerMisfired(trigger);
|
||||
this.listenerService.saveTriggerMisfired(trigger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void triggerComplete(Trigger trigger, JobExecutionContext context,
|
||||
CompletedExecutionInstruction triggerInstructionCode) { // 7
|
||||
try {
|
||||
this.triggerListenerService.saveTriggerComplete(context, triggerInstructionCode);
|
||||
this.listenerService.saveTriggerComplete(context, triggerInstructionCode);
|
||||
} catch (SchedulerException e) {
|
||||
LOGGER.error("triggerComplete error:", e);
|
||||
}
|
||||
|
||||
+11
-11
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* TriggerListenerService.java
|
||||
* ListenerService.java
|
||||
* Created at 2017-06-01
|
||||
* Created by Administrator
|
||||
* Copyright (C) 2016 egridcloud.com, All rights reserved.
|
||||
@@ -22,18 +22,18 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.egridcloud.udf.core.exception.SystemException;
|
||||
import com.egridcloud.udf.scheduler.ITriggerLog;
|
||||
import com.egridcloud.udf.scheduler.IListenerLog;
|
||||
import com.egridcloud.udf.scheduler.SchedulerConfig;
|
||||
import com.egridcloud.udf.scheduler.domain.ScheduledTriggerLog;
|
||||
|
||||
/**
|
||||
* 描述 : TriggerListenerService
|
||||
* 描述 : ListenerService
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class TriggerListenerService {
|
||||
public class ListenerService {
|
||||
|
||||
/**
|
||||
* 描述 : schedulerConfig
|
||||
@@ -42,10 +42,10 @@ public class TriggerListenerService {
|
||||
private SchedulerConfig schedulerConfig;
|
||||
|
||||
/**
|
||||
* 描述 : triggerLog
|
||||
* 描述 : listenerLog
|
||||
*/
|
||||
@Autowired(required = false)
|
||||
private ITriggerLog triggerLog;
|
||||
private IListenerLog listenerLog;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -76,8 +76,8 @@ public class TriggerListenerService {
|
||||
tstl.setScheduledId(null);
|
||||
tstl.setScheduledName(null);
|
||||
tstl.setCreateDate(new Date());
|
||||
if (triggerLog != null) {
|
||||
triggerLog.save(tstl);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.save(tstl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,9 +250,9 @@ public class TriggerListenerService {
|
||||
tstl.setScheduledId(s.getSchedulerInstanceId());
|
||||
tstl.setScheduledName(s.getSchedulerName());
|
||||
tstl.setCreateDate(new Date());
|
||||
if (triggerLog != null) {
|
||||
triggerLog.delete(context.getFireInstanceId());
|
||||
triggerLog.save(tstl);
|
||||
if (listenerLog != null) {
|
||||
listenerLog.delete(context.getFireInstanceId());
|
||||
listenerLog.save(tstl);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user