TransactionSchedulerImpl implements TransactionScheduler, PriorityScheduler, ProfileListener { public TaskQueue createTaskQueue() { if (isShutdown) { throw new IllegalStateException("Scheduler is shutdown"); } return new TaskQueueImpl(); } TransactionSchedulerImpl(Properties properties,
                             TransactionCoordinator transactionCoordinator,
                             ProfileCollectorHandle profileCollectorHandle,
                             AccessCoordinatorHandle accessCoordinator); TaskReservation reserveTask(KernelRunnable task, Identity owner); TaskReservation reserveTask(KernelRunnable task, Identity owner,
                                       long startTime); void scheduleTask(KernelRunnable task, Identity owner); void scheduleTask(KernelRunnable task, Identity owner,
                             long startTime); RecurringTaskHandle scheduleRecurringTask(KernelRunnable task,
                                                     Identity owner,
                                                     long startTime,
                                                     long period); TaskQueue createTaskQueue(); void runTask(KernelRunnable task, Identity owner); TaskReservation reserveTask(KernelRunnable task, Identity owner,
                                       Priority priority); void scheduleTask(KernelRunnable task, Identity owner,
                             Priority priority); void propertyChange(PropertyChangeEvent event); void report(ProfileReport profileReport); void shutdown(); static final String SCHEDULER_QUEUE_PROPERTY; static final String DEFAULT_SCHEDULER_QUEUE; static final String SCHEDULER_RETRY_PROPERTY; static final String DEFAULT_SCHEDULER_RETRY; static final String CONSUMER_THREADS_PROPERTY; static final String DEFAULT_CONSUMER_THREADS; }
@Test public void scheduleQueuedTasks() throws Exception { TaskQueue queue = txnScheduler.createTaskQueue(); AtomicInteger runCount = new AtomicInteger(0); for (int i = 0; i < 10; i++) queue.addTask(new DependentTask(runCount), taskOwner); Thread.sleep(500L); assertEquals(10, runCount.get()); }
@Test (expected=NullPointerException.class) public void scheduleQueuedTasksNull() throws Exception { TaskQueue queue = txnScheduler.createTaskQueue(); queue.addTask(null, taskOwner); }
@Test (expected=NullPointerException.class) public void scheduleQueuedTasksOwnerNull() throws Exception { TaskQueue queue = txnScheduler.createTaskQueue(); queue.addTask(new DependentTask(null), null); }