/** * Low priority pool for scheduling cleanup or otherwise tasks which could be significantly * delayed. This pool will only have one thread, so tasks should complete quickly or they might * block other tasks. * * @param threadName Name to prefix to thread while tasks on this pool execute, or {@code null} * @return Single threaded pool for running or scheduling out low priority tasks */ public static PrioritySchedulerService lowPrioritySingleThreadPool(String threadName) { if (StringUtils.isNullOrEmpty(threadName)) { return SINGLE_THREADED_LOW_PRIORITY_POOL; } else { return new ThreadRenamingPriorityScheduler(SINGLE_THREADED_LOW_PRIORITY_POOL, threadName, false); } }
/** * Low priority pool for scheduling cleanup or otherwise tasks which could be significantly * delayed. This pool will only have one thread, so tasks should complete quickly or they might * block other tasks. * * @param threadName Name to prefix to thread while tasks on this pool execute, or {@code null} * @return Single threaded pool for running or scheduling out low priority tasks */ public static PrioritySchedulerService lowPrioritySingleThreadPool(String threadName) { if (StringUtils.isNullOrEmpty(threadName)) { return SINGLE_THREADED_LOW_PRIORITY_POOL; } else { return new ThreadRenamingPriorityScheduler(SINGLE_THREADED_LOW_PRIORITY_POOL, threadName, false); } }
/** * Returns the master scheduler with a default priority requested. * @param defaultPriority Default priority for tasks submitted to scheduler * @param threadName if name should be set during execution * * @return Master scheduler with the provided default priority */ private static PrioritySchedulerService masterScheduler(TaskPriority defaultPriority, String threadName, boolean replaceName) { PrioritySchedulerService result; if (defaultPriority == TaskPriority.High) { result = MASTER_SCHEDULER; } else if (defaultPriority == TaskPriority.Low) { result = LOW_PRIORITY_MASTER_SCHEDULER; } else { result = STARVABLE_PRIORITY_MASTER_SCHEDULER; } if (StringUtils.isNullOrEmpty(threadName)) { return result; } else { return new ThreadRenamingPriorityScheduler(result, threadName, replaceName); } }
/** * Returns the master scheduler with a default priority requested. * @param defaultPriority Default priority for tasks submitted to scheduler * @param threadName if name should be set during execution * * @return Master scheduler with the provided default priority */ private static PrioritySchedulerService masterScheduler(TaskPriority defaultPriority, String threadName, boolean replaceName) { PrioritySchedulerService result; if (defaultPriority == TaskPriority.High) { result = MASTER_SCHEDULER; } else if (defaultPriority == TaskPriority.Low) { result = LOW_PRIORITY_MASTER_SCHEDULER; } else { result = STARVABLE_PRIORITY_MASTER_SCHEDULER; } if (StringUtils.isNullOrEmpty(threadName)) { return result; } else { return new ThreadRenamingPriorityScheduler(result, threadName, replaceName); } }
@Override public SubmitterScheduler makeSubmitterScheduler(int poolSize, boolean prestartIfAvailable) { PriorityScheduler scheduler = schedulerFactory.makePriorityScheduler(poolSize); if (prestartIfAvailable) { scheduler.prestartAllThreads(); } return new ThreadRenamingPriorityScheduler(scheduler, THREAD_NAME, false); }