use of com.dtstack.taier.scheduler.jobdealer.JobSubmitDealer in project Taier by DTStack.
the class GroupPriorityQueue method build.
/**
* 每个GroupPriorityQueue中增加独立线程,以定时调度方式从数据库中获取任务。(数据库查询以id和优先级为条件)
*/
public GroupPriorityQueue build() {
this.environmentContext = applicationContext.getBean(EnvironmentContext.class);
this.engineJobCacheService = applicationContext.getBean(EngineJobCacheService.class);
this.jobPartitioner = applicationContext.getBean(JobPartitioner.class);
this.workerOperator = applicationContext.getBean(WorkerOperator.class);
this.queueSizeLimited = environmentContext.getQueueSize();
checkParams();
this.queue = new PriorityBlockingQueue<>(queueSizeLimited * 2, new JobClientComparator());
this.jobSubmitDealer = new JobSubmitDealer(environmentContext.getLocalAddress(), this, applicationContext);
ScheduledExecutorService scheduledService = new ScheduledThreadPoolExecutor(1, new CustomThreadFactory(this.getClass().getSimpleName() + "_" + jobResource + "_AcquireJob"));
scheduledService.scheduleWithFixedDelay(new AcquireGroupQueueJob(), WAIT_INTERVAL * 10L, WAIT_INTERVAL, TimeUnit.MILLISECONDS);
ExecutorService jobSubmitService = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), new CustomThreadFactory(this.getClass().getSimpleName() + "_" + jobResource + "_JobSubmit"));
jobSubmitService.submit(jobSubmitDealer);
return this;
}
Aggregations