mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-14 06:18:16 +00:00
perf[scheduler]: 删除不必要的方法
This commit is contained in:
1 parent
d2817aaab4
commit
b31186c8d3
2 files changed
+1
-20
No files matched your search
@@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
package com.zfoo.scheduler.manager;
|
package com.zfoo.scheduler.manager;
|
||||||
|
|
||||||
import com.zfoo.protocol.collection.CollectionUtils;
|
|
||||||
import com.zfoo.scheduler.SchedulerContext;
|
import com.zfoo.scheduler.SchedulerContext;
|
||||||
import com.zfoo.scheduler.model.vo.SchedulerDefinition;
|
import com.zfoo.scheduler.model.vo.SchedulerDefinition;
|
||||||
import com.zfoo.scheduler.timeWheelUtils.Timer;
|
import com.zfoo.scheduler.timeWheelUtils.Timer;
|
||||||
@@ -22,8 +21,6 @@ import com.zfoo.scheduler.util.TimeUtils;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -98,22 +95,6 @@ public abstract class SchedulerBus {
|
|||||||
}, delay, unit);
|
}, delay, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* cron表达式执行的任务
|
|
||||||
*/
|
|
||||||
public static void scheduleCron(Runnable runnable, String cron) {
|
|
||||||
if (SchedulerContext.isStop()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SchedulerDefinition scheduler = SchedulerDefinition.valueOf(cron, runnable);
|
|
||||||
var timerTask = new TimerTask(scheduler.getTriggerTimestamp(), () -> {
|
|
||||||
scheduler.getScheduler().invoke();
|
|
||||||
refreshTask(scheduler);
|
|
||||||
});
|
|
||||||
timer.addTask(timerTask);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void refreshTask(SchedulerDefinition schedulerDefinition) {
|
public static void refreshTask(SchedulerDefinition schedulerDefinition) {
|
||||||
var timestamp = TimeUtils.currentTimeMillis();
|
var timestamp = TimeUtils.currentTimeMillis();
|
||||||
var nextTriggerTimestamp = TimeUtils.getNextTimestampByCronExpression(schedulerDefinition.getCronExpression(), timestamp);
|
var nextTriggerTimestamp = TimeUtils.getNextTimestampByCronExpression(schedulerDefinition.getCronExpression(), timestamp);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public abstract class IdUtils {
|
|||||||
private static final AtomicInteger ATOMIC_INTEGER = new AtomicInteger(0);
|
private static final AtomicInteger ATOMIC_INTEGER = new AtomicInteger(0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地int的id,如果达到最大值则重新从最小值重新计算
|
* 获取本地int的唯一id,如果达到最大值则重新从最小值重新计算,线程安全
|
||||||
*/
|
*/
|
||||||
public static int getLocalIntId() {
|
public static int getLocalIntId() {
|
||||||
return ATOMIC_INTEGER.incrementAndGet();
|
return ATOMIC_INTEGER.incrementAndGet();
|
||||||
|
|||||||
Reference in new issue
Block a user