shikeying
2022-09-27 26f5dd8ef80e5671cda8fc0e6c0d0298c4e678ff
recommend-video/src/main/java/com/iplatform/recvideo/api/DemoDebug.java
@@ -1,12 +1,19 @@
package com.iplatform.recvideo.api;
import com.iplatform.core.BeanContextAware;
import com.iplatform.recvideo.config.VideoSimilarProperties;
import com.iplatform.recvideo.scheduler.VideoSearchScheduler;
import com.iplatform.recvideo.service.VideoExecutorServiceImpl;
import com.iplatform.recvideo.support.DefaultSimilarExecutor;
import com.walker.scheduler.ScheduleEngine;
import com.walker.scheduler.util.OptionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("/debug/video")
@@ -15,6 +22,8 @@
    private RestTemplate restTemplate;
    private VideoSimilarProperties videoSimilarProperties;
    private VideoExecutorServiceImpl videoExecutorService;
    private VideoSearchScheduler videoSearchScheduler = null;
    private DefaultSimilarExecutor similarExecutor = null;
@@ -27,6 +36,25 @@
        this.videoExecutorService = videoExecutorService;
    }
    @RequestMapping("/start_scheduler_1")
    public String testStartVideoSearchScheduler(){
        if(this.videoSearchScheduler != null){
            this.videoSearchScheduler.stop();
            this.videoSearchScheduler = null;
        }
        List<Integer[]> timeRanges = new ArrayList<Integer[]>(1);
        timeRanges.add(new Integer[]{10,11});
        timeRanges.add(new Integer[]{12,12});
        this.videoSearchScheduler = new VideoSearchScheduler(100, "视频相似度分析调度任务");
        this.videoSearchScheduler.setOption(OptionUtils.combineEveryDayHourRange(timeRanges));
        this.videoSearchScheduler.setScheduleEngine(BeanContextAware.getBeanByType(ScheduleEngine.class));
        this.videoSearchScheduler.setMaxFailedTimes(10);
        this.videoSearchScheduler.start();
        return this.videoSearchScheduler.getName() + " 启动";
    }
    /**
     * 该测试用于模拟调度任务,每次调用一次执行器方法,批量处理一张图片数据。<p></p>
     * 最终完成一批多个视频的相似度检索并写入数据库中。