feat(1.1.2.0-beta3):
1、修复定时、重试日志清除BUG 2、删除定时、重试保留最近24小时日志数据判断
This commit is contained in:
parent
d17500bdd4
commit
e5223b7e5b
@ -41,8 +41,6 @@ import java.util.List;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class JobClearLogSchedule extends AbstractSchedule implements Lifecycle {
|
public class JobClearLogSchedule extends AbstractSchedule implements Lifecycle {
|
||||||
|
|
||||||
// last clean log time
|
|
||||||
private static Long lastCleanLogTime = 0L;
|
|
||||||
private final SystemProperties systemProperties;
|
private final SystemProperties systemProperties;
|
||||||
private final JobTaskBatchMapper jobTaskBatchMapper;
|
private final JobTaskBatchMapper jobTaskBatchMapper;
|
||||||
private final JobTaskMapper jobTaskMapper;
|
private final JobTaskMapper jobTaskMapper;
|
||||||
@ -68,7 +66,7 @@ public class JobClearLogSchedule extends AbstractSchedule implements Lifecycle {
|
|||||||
protected void doExecute() {
|
protected void doExecute() {
|
||||||
try {
|
try {
|
||||||
// 清除日志默认保存天数大于零、最少保留最近一天的日志数据
|
// 清除日志默认保存天数大于零、最少保留最近一天的日志数据
|
||||||
if (systemProperties.getLogStorage() <= 1 && System.currentTimeMillis() - lastCleanLogTime < 24 * 60 * 60 * 1000) {
|
if (systemProperties.getLogStorage() <= 1) {
|
||||||
SnailJobLog.LOCAL.error("job clear log storage error", systemProperties.getLogStorage());
|
SnailJobLog.LOCAL.error("job clear log storage error", systemProperties.getLogStorage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -79,8 +77,6 @@ public class JobClearLogSchedule extends AbstractSchedule implements Lifecycle {
|
|||||||
this::processJobLogPartitionTasks, 0);
|
this::processJobLogPartitionTasks, 0);
|
||||||
|
|
||||||
SnailJobLog.LOCAL.debug("Job clear success total:[{}]", total);
|
SnailJobLog.LOCAL.debug("Job clear success total:[{}]", total);
|
||||||
// update clean time
|
|
||||||
lastCleanLogTime = System.currentTimeMillis();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SnailJobLog.LOCAL.error("job clear log error", e);
|
SnailJobLog.LOCAL.error("job clear log error", e);
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,6 @@ public class JobLogMergeSchedule extends AbstractSchedule implements Lifecycle {
|
|||||||
private final JobLogMessageMapper jobLogMessageMapper;
|
private final JobLogMessageMapper jobLogMessageMapper;
|
||||||
private final TransactionTemplate transactionTemplate;
|
private final TransactionTemplate transactionTemplate;
|
||||||
|
|
||||||
// last merge log time
|
|
||||||
private static Long lastMergeLogTime = 0L;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String lockName() {
|
public String lockName() {
|
||||||
@ -74,10 +72,6 @@ public class JobLogMergeSchedule extends AbstractSchedule implements Lifecycle {
|
|||||||
@Override
|
@Override
|
||||||
protected void doExecute() {
|
protected void doExecute() {
|
||||||
try {
|
try {
|
||||||
// 合并日志数据最少保留最近一天的日志数据
|
|
||||||
if (System.currentTimeMillis() - lastMergeLogTime < 24 * 60 * 60 * 1000) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// merge job log
|
// merge job log
|
||||||
long total;
|
long total;
|
||||||
LocalDateTime endTime = LocalDateTime.now().minusDays(systemProperties.getMergeLogDays());
|
LocalDateTime endTime = LocalDateTime.now().minusDays(systemProperties.getMergeLogDays());
|
||||||
@ -87,9 +81,6 @@ public class JobLogMergeSchedule extends AbstractSchedule implements Lifecycle {
|
|||||||
SnailJobLog.LOCAL.debug("job merge success total:[{}]", total);
|
SnailJobLog.LOCAL.debug("job merge success total:[{}]", total);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SnailJobLog.LOCAL.error("job merge log error", e);
|
SnailJobLog.LOCAL.error("job merge log error", e);
|
||||||
} finally {
|
|
||||||
// update merge time
|
|
||||||
lastMergeLogTime = System.currentTimeMillis();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +183,7 @@ public class JobLogMergeSchedule extends AbstractSchedule implements Lifecycle {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
taskScheduler.scheduleAtFixedRate(this::execute, Duration.parse("PT1H"));
|
taskScheduler.scheduleAtFixedRate(this::execute, Duration.parse("PT1M"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,8 +38,6 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class ClearLogSchedule extends AbstractSchedule implements Lifecycle {
|
public class ClearLogSchedule extends AbstractSchedule implements Lifecycle {
|
||||||
|
|
||||||
// last clean log time
|
|
||||||
private static Long lastCleanLogTime = 0L;
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RetryTaskLogMapper retryTaskLogMapper;
|
private RetryTaskLogMapper retryTaskLogMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -68,7 +66,7 @@ public class ClearLogSchedule extends AbstractSchedule implements Lifecycle {
|
|||||||
protected void doExecute() {
|
protected void doExecute() {
|
||||||
try {
|
try {
|
||||||
// 清除日志默认保存天数大于零、最少保留最近一天的日志数据
|
// 清除日志默认保存天数大于零、最少保留最近一天的日志数据
|
||||||
if (systemProperties.getLogStorage() <= 1 && System.currentTimeMillis() - lastCleanLogTime < 24 * 60 * 60 * 1000) {
|
if (systemProperties.getLogStorage() <= 1) {
|
||||||
SnailJobLog.LOCAL.error("retry clear log storage error", systemProperties.getLogStorage());
|
SnailJobLog.LOCAL.error("retry clear log storage error", systemProperties.getLogStorage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -78,8 +76,6 @@ public class ClearLogSchedule extends AbstractSchedule implements Lifecycle {
|
|||||||
this::processRetryLogPartitionTasks, 0);
|
this::processRetryLogPartitionTasks, 0);
|
||||||
|
|
||||||
SnailJobLog.LOCAL.debug("Retry clear success total:[{}]", total);
|
SnailJobLog.LOCAL.debug("Retry clear success total:[{}]", total);
|
||||||
// update clean time
|
|
||||||
lastCleanLogTime = System.currentTimeMillis();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SnailJobLog.LOCAL.error("clear log error", e);
|
SnailJobLog.LOCAL.error("clear log error", e);
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,6 @@ import static java.util.stream.Collectors.toList;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class RetryLogMergeSchedule extends AbstractSchedule implements Lifecycle {
|
public class RetryLogMergeSchedule extends AbstractSchedule implements Lifecycle {
|
||||||
|
|
||||||
// last merge log time
|
|
||||||
private static Long lastMergeLogTime = 0L;
|
|
||||||
private final SystemProperties systemProperties;
|
private final SystemProperties systemProperties;
|
||||||
private final RetryTaskLogMapper retryTaskLogMapper;
|
private final RetryTaskLogMapper retryTaskLogMapper;
|
||||||
private final RetryTaskLogMessageMapper retryTaskLogMessageMapper;
|
private final RetryTaskLogMessageMapper retryTaskLogMessageMapper;
|
||||||
@ -74,10 +72,6 @@ public class RetryLogMergeSchedule extends AbstractSchedule implements Lifecycle
|
|||||||
@Override
|
@Override
|
||||||
protected void doExecute() {
|
protected void doExecute() {
|
||||||
try {
|
try {
|
||||||
// 合并日志数据最少保留最近一天的日志数据
|
|
||||||
if (System.currentTimeMillis() - lastMergeLogTime < 24 * 60 * 60 * 1000) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// merge job log
|
// merge job log
|
||||||
long total;
|
long total;
|
||||||
LocalDateTime endTime = LocalDateTime.now().minusDays(systemProperties.getMergeLogDays());
|
LocalDateTime endTime = LocalDateTime.now().minusDays(systemProperties.getMergeLogDays());
|
||||||
@ -87,9 +81,6 @@ public class RetryLogMergeSchedule extends AbstractSchedule implements Lifecycle
|
|||||||
SnailJobLog.LOCAL.debug("job merge success total:[{}]", total);
|
SnailJobLog.LOCAL.debug("job merge success total:[{}]", total);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SnailJobLog.LOCAL.error("job merge log error", e);
|
SnailJobLog.LOCAL.error("job merge log error", e);
|
||||||
} finally {
|
|
||||||
// update merge time
|
|
||||||
lastMergeLogTime = System.currentTimeMillis();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user