#
vincentlu
2025-03-17 15cbe9c08401f51e4ad739c48b2743993c966602
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/KernelScheduler.java
@@ -15,10 +15,11 @@
import com.zy.acs.manager.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.util.ArrayList;
import java.util.Collections;
@@ -35,7 +36,10 @@
@Component
public class KernelScheduler {
    public static int CORE_SCAN_FREQUENCY_MILLISECOND = 15;
    private static final int LOCK_TIMEOUT = 5;
    private final ReentrantLock lock = new ReentrantLock(Boolean.TRUE);
    private Thread trafficCalcThread;
@@ -101,14 +105,15 @@
        this.lock.unlock();
    }
    @PostConstruct
//    @PostConstruct
    @EventListener(ApplicationReadyEvent.class)
    public void init() {
        try { Thread.sleep(1200); } catch (InterruptedException ignore) {}
        // traffic calculate
        this.trafficCalcThread = new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                try {
                    Thread.sleep(100);
                    Thread.sleep(CORE_SCAN_FREQUENCY_MILLISECOND);
                    List<Segment> segments = segmentService.list(new LambdaQueryWrapper<Segment>()
                            .eq(Segment::getState, SegmentStateType.WAITING.toString())
@@ -129,13 +134,11 @@
        this.actionPublicThread = new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                try {
                    Thread.sleep(100);
                    Thread.sleep(CORE_SCAN_FREQUENCY_MILLISECOND);
                    List<String> actionGroupIds = actionService.selectPrepareGroup();
                    List<String> actionGroupIds = actionService.selectGroupNo(ActionStsType.PREPARE);
                    for (String actionGroupId : actionGroupIds) {
                        long startTime = System.currentTimeMillis();
                        mainService.publishAction(actionGroupId);
                        log.info("publish action calculation spend {} ms", System.currentTimeMillis() - startTime);
                    }
                } catch (Exception e) {