Search in sources :

Example 1 with JobSubmitDealer

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;
}
Also used : JobClientComparator(com.dtstack.taier.common.queue.comparator.JobClientComparator) JobPartitioner(com.dtstack.taier.scheduler.server.JobPartitioner) EnvironmentContext(com.dtstack.taier.common.env.EnvironmentContext) CustomThreadFactory(com.dtstack.taier.pluginapi.CustomThreadFactory) EngineJobCacheService(com.dtstack.taier.scheduler.service.EngineJobCacheService) WorkerOperator(com.dtstack.taier.scheduler.WorkerOperator) JobSubmitDealer(com.dtstack.taier.scheduler.jobdealer.JobSubmitDealer)

Aggregations

EnvironmentContext (com.dtstack.taier.common.env.EnvironmentContext)1 JobClientComparator (com.dtstack.taier.common.queue.comparator.JobClientComparator)1 CustomThreadFactory (com.dtstack.taier.pluginapi.CustomThreadFactory)1 WorkerOperator (com.dtstack.taier.scheduler.WorkerOperator)1 JobSubmitDealer (com.dtstack.taier.scheduler.jobdealer.JobSubmitDealer)1 JobPartitioner (com.dtstack.taier.scheduler.server.JobPartitioner)1 EngineJobCacheService (com.dtstack.taier.scheduler.service.EngineJobCacheService)1