shikeying
2022-09-22 d87613ba3ee0652fe96285ac687e0b537b42df88
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.iplatform.rectext.scheduler;
 
import com.iplatform.gather.GatherScheduler;
import com.walker.store.AbstractStore;
import com.walker.store.support.EmptyDatabaseStore;
import com.walker.store.task.GatherTask;
 
/**
 * 持续写入课程文本描述到相似数据库中,在数据库中定义任务时间周期。
 * <pre>
 *     1)该任务不会停止,每间隔2小时执行一次;
 *     2)增量拉取数据,数据先组织好写入中间表,然后调用sdk写入milvus
 * </pre>
 */
public class WriteCourseToMilvus extends GatherScheduler {
 
    private GatherTask gatherTask;
 
    public WriteCourseToMilvus(int id, String name){
        super(id, name, new EmptyDatabaseStore());
    }
 
    @Override
    protected GatherTask providerTask(AbstractStore store) {
        return null;
    }
 
    @Override
    protected void terminateGatherScheduler(int schedulerId) {
 
    }
 
    @Override
    protected Object onProcess(Object[] inputParams) throws Exception {
        if(this.gatherTask == null){
            this.gatherTask = this.providerTask(this.getStore());
            if(this.gatherTask == null){
                throw new IllegalArgumentException("未提供任务对象,调度无法执行:" + this.getName());
            }
        }
        // srcName, createTableSQL, parameter, params[]
        return this.gatherTask.run((String)inputParams[0], (String)inputParams[1], inputParams[2], (Object[])inputParams[3]);
    }
}