Package com.sun.sgs.kernel

Examples of com.sun.sgs.kernel.RecurringTaskHandle


                                                     long period)
    {
        ScheduledTaskImpl scheduledTask =
            new ScheduledTaskImpl(task, owner, defaultPriority, startTime,
                                  period);
        RecurringTaskHandle handle =
            backingQueue.createRecurringTaskHandle(scheduledTask);
        scheduledTask.setRecurringTaskHandle(handle);
        return handle;
    }
View Full Code Here


        PendingTask ptask =
                (PendingTask) (dataService.createReferenceForId(objId).
                getForUpdate());
        ptask.setRunningNode(nodeId);

        RecurringTaskHandle handle =
            transactionScheduler.scheduleRecurringTask(runner, owner,
                                                       startTime, period);
        ctxFactory.joinTransaction().addRecurringTask(objId, handle, owner);
        return new PeriodicTaskHandleImpl(generateObjName(owner, objId));
    }
View Full Code Here

            // mark the task as running on this node so that it doesn't
            // also run somewhere else
            dataService.markForUpdate(ptask);
            ptask.setRunningNode(nodeId);

            RecurringTaskHandle handle =
                transactionScheduler.scheduleRecurringTask(runner, identity,
                                                           start, period);
            ctxFactory.joinTransaction().
                addRecurringTask(objId, handle, identity);
        }
View Full Code Here

        PendingTask ptask =
                (PendingTask) (dataService.createReferenceForId(objId).
                getForUpdate());
        ptask.setRunningNode(nodeId);

        RecurringTaskHandle handle =
            transactionScheduler.scheduleRecurringTask(
                runner, owner,
                watchdogService.getSystemTimeMillis(appStartTime), period);
        ctxFactory.joinTransaction().addRecurringTask(objId, handle, owner);
        return new PeriodicTaskHandleImpl(generateObjName(owner, objId));
View Full Code Here

            // mark the task as running on this node so that it doesn't
            // also run somewhere else
            dataService.markForUpdate(ptask);
            ptask.setRunningNode(nodeId);

            RecurringTaskHandle handle =
                transactionScheduler.scheduleRecurringTask(
                    runner, identity,
                    watchdogService.getSystemTimeMillis(restartTime),
                    ptask.getPeriod());
            ctxFactory.joinTransaction().
View Full Code Here

        taskScheduler.scheduleRecurringTask(testTask, taskOwner,
                                            System.currentTimeMillis(), -1);
    }

    @Test public void cancelAfterStartRecurringTask() throws Exception {
        RecurringTaskHandle handle =
            taskScheduler.scheduleRecurringTask(new IncrementRunner(),
                                                taskOwner,
                                                System.currentTimeMillis() + 50,
                                                50);
        handle.start();
        handle.cancel();
        Thread.sleep(200L);
        assertEquals(0, taskCount);
    }
View Full Code Here

        Thread.sleep(200L);
        assertEquals(0, taskCount);
    }

    @Test public void startSleepAndCancelRecurringTask() throws Exception {
        RecurringTaskHandle handle =
            taskScheduler.scheduleRecurringTask(new IncrementRunner(),
                                                taskOwner,
                                                System.currentTimeMillis(),
                                                200);
        handle.start();
        Thread.sleep(300L);
        assertEquals(2, taskCount);
        handle.cancel();
        Thread.sleep(200L);
        assertEquals(2, taskCount);
    }
View Full Code Here

        Thread.sleep(200L);
        assertEquals(2, taskCount);
    }

    @Test public void cancelRecurringTask() throws Exception {
        RecurringTaskHandle handle =
            taskScheduler.scheduleRecurringTask(new IncrementRunner(),
                                                taskOwner,
                                                System.currentTimeMillis(),
                                                50);
        handle.cancel();
        Thread.sleep(100L);
        assertEquals(0, taskCount);
    }
View Full Code Here

        assertEquals(0, taskCount);
    }

    @Test (expected=IllegalStateException.class)
        public void restartRecurringTask() throws Exception {
        RecurringTaskHandle handle =
            taskScheduler.scheduleRecurringTask(testTask, taskOwner,
                                                System.currentTimeMillis(),
                                                100);
        handle.start();
        try {
            handle.start();
        } finally {
            handle.cancel();
        }
    }
View Full Code Here

        }
    }

    @Test (expected=IllegalStateException.class)
        public void recancelRecurringTask() throws Exception {
        RecurringTaskHandle handle =
            taskScheduler.scheduleRecurringTask(testTask, taskOwner,
                                                System.currentTimeMillis(),
                                                100);
        handle.cancel();
        handle.cancel();
    }
View Full Code Here

TOP

Related Classes of com.sun.sgs.kernel.RecurringTaskHandle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.