TransactionSchedulerImpl implements TransactionScheduler, PriorityScheduler, ProfileListener { void runUnboundedTask(KernelRunnable task, Identity owner) throws Exception { if (isShutdown) { throw new IllegalStateException("Scheduler is shutdown"); } if (ContextResolver.isCurrentTransaction()) { throw new IllegalStateException("Cannot be called from within " + "an active transaction"); } ScheduledTaskImpl scheduledTask = new ScheduledTaskImpl.Builder( task, owner, defaultPriority). timeout(ScheduledTask.UNBOUNDED). build(); waitForTask(scheduledTask); } 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 (expected=NullPointerException.class) public void runUnboundedTaskNullTask() throws Exception { txnScheduler.runUnboundedTask(null, taskOwner); }
@Test (expected=NullPointerException.class) public void runUnboundedTaskNullOwner() throws Exception { txnScheduler.runUnboundedTask(new TestAbstractKernelRunnable() { public void run() { } }, null); }
@Test public void runUnboundedTaskSingleTask() throws Exception { RunCountTestRunner runner = new RunCountTestRunner(1); txnScheduler.runUnboundedTask(runner, taskOwner); assertEquals(0, runner.getRunCount()); }
@Test(timeout=2000) public void runUnboundedTaskLongTransaction() throws Exception { LongTransactionRunner runner = new LongTransactionRunner(1000L); txnScheduler.runUnboundedTask(runner, taskOwner); assertTrue(runner.isFinished()); }