Class ControlledWorkerScheduler<T>
java.lang.Object
org.eclipse.rdf4j.federated.evaluation.concurrent.ControlledWorkerScheduler<T>
- All Implemented Interfaces:
 Scheduler<T>, TaskWrapperAware
ControlledWorkerScheduler is a task scheduler that uses a FIFO queue for managing its process. Each instance has a
pool with a fixed number of worker threads. Once notified a worker picks the next task from the queue and executes
it. The results is then returned to the controlling instance retrieved from the task.
- Author:
 - Andreas Schwarte
 - See Also:
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classStructure to maintain the status for a given control instance. - 
Constructor Summary
ConstructorsConstructorDescriptionControlledWorkerScheduler(int nWorkers, String name) Construct a new instance with the specified number of workers and the given name. - 
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Abort the execution of running and queued tasks.protected BlockingQueue<Runnable> Create theBlockingQueueused for the thread pool.protected ExecutorServicecreateExecutorService(int nWorkers, String name) Create theExecutorServicewhich is managing the individualParallelTasks in a thread pool.voiddone()Inform the scheduler that a certain task is done.intDeprecated, for removal: This API element is subject to removal in a future version.intvoidhandleResult(CloseableIteration<T> res) Callback to handle the result.voidInform the scheduler that no more tasks will be scheduled.voidinformFinish(ParallelExecutor<T> control) Inform this scheduler that the specified control instance will no longer submit tasks.booleanDetermine if the scheduler has unfinished tasks.booleanisRunning(ParallelExecutor<T> control) Determine if there are still task running or queued for the specified control.voidschedule(ParallelTask<T> task) Schedule the specified parallel task.voidscheduleAll(List<ParallelTask<T>> tasks, ParallelExecutor<T> control) Schedule the given tasks and inform about finish using the same lock, i.e. all tasks are scheduled one after the other.voidsetTaskWrapper(TaskWrapper taskWrapper) Set theTaskWrapperto the respective instancevoidshutdown()voidToss an exception to the scheduler. 
- 
Constructor Details
- 
ControlledWorkerScheduler
Construct a new instance with the specified number of workers and the given name.- Parameters:
 nWorkers-name-
 
 - 
 - 
Method Details
- 
schedule
Schedule the specified parallel task. - 
scheduleAll
Schedule the given tasks and inform about finish using the same lock, i.e. all tasks are scheduled one after the other.- Parameters:
 tasks-control-
 - 
getTotalNumberOfWorkers
public int getTotalNumberOfWorkers() - 
getNumberOfTasks
Deprecated, for removal: This API element is subject to removal in a future version. - 
createBlockingQueue
Create theBlockingQueueused for the thread pool. The default implementation creates aLinkedBlockingQueue.- Returns:
 
 - 
createExecutorService
Create theExecutorServicewhich is managing the individualParallelTasks in a thread pool. The default implementation creates a thread pool with aLinkedBlockingQueue. The thread pool should be configured to terminate idle threads after a period of time (default: 60s)- Parameters:
 nWorkers- the number of workers in the thread poolname- the base name for threads in the pool- Returns:
 
 - 
abort
 - 
done
 - 
handleResult
Description copied from interface:SchedulerCallback to handle the result.- Specified by:
 handleResultin interfaceScheduler<T>- Parameters:
 res-
 - 
informFinish
public void informFinish()Description copied from interface:SchedulerInform the scheduler that no more tasks will be scheduled.- Specified by:
 informFinishin interfaceScheduler<T>
 - 
informFinish
Inform this scheduler that the specified control instance will no longer submit tasks.- Parameters:
 control-
 - 
isRunning
 - 
isRunning
Determine if there are still task running or queued for the specified control.- Parameters:
 control-- Returns:
 - true, if there are unfinished tasks, false otherwise
 
 - 
toss
 - 
shutdown
 - 
setTaskWrapper
Description copied from interface:TaskWrapperAwareSet theTaskWrapperto the respective instance- Specified by:
 setTaskWrapperin interfaceTaskWrapperAware- Parameters:
 taskWrapper-
 
 -