Package com.sun.sgs.test.impl.service.task.TestTaskServiceImpl

Examples of com.sun.sgs.test.impl.service.task.TestTaskServiceImpl.Counter


        private static final long serialVersionUID = 1;
        public void run() throws Exception {
            TestMultiNodeTaskServiceImpl.lastNodeUsed.
                set(AppContext.getManager(NodeIdManager.class).getNodeId());
            DataManager dataManager = AppContext.getDataManager();
            Counter counter = (Counter) dataManager.getBinding("counter");
            dataManager.markForUpdate(counter);
            counter.decrement();
        }
View Full Code Here


        // add a counter for use in some of the tests, so we don't have to
        // check later if it's present
        txnSchedulerZero.runTask(
            new TestAbstractKernelRunnable() {
                public void run() throws Exception {
                    dataServiceZero.setBinding("counter", new Counter());
                }
            }, taskOwner);
    }
View Full Code Here

        long expectedNode = additionalNodes[0].getNodeId();
        DummyNodeMappingService.assignIdentity(getClass(), id, expectedNode);
        txnSchedulerZero.runTask(
            new TestAbstractKernelRunnable() {
                public void run() {
                    Counter counter = getClearedCounter();
                    taskServiceZero.scheduleTask(new TestTask());
                    counter.increment();
                }
            }, id);

        Thread.sleep(500);
        assertCounterClearXAction("An immediate task did not run");
View Full Code Here

        long expectedNode = additionalNodes[0].getNodeId();
        DummyNodeMappingService.assignIdentity(getClass(), id, expectedNode);
        txnSchedulerZero.runTask(
            new TestAbstractKernelRunnable() {
                public void run() {
                    Counter counter = getClearedCounter();
                    taskServiceZero.scheduleTask(new TestTask(), 100L);
                    counter.increment();
                }
            }, id);

        Thread.sleep(500);
        assertCounterClearXAction("A delayed task did not run");
View Full Code Here

        DummyNodeMappingService.assignIdentity(getClass(), id,
                                               serverNode.getNodeId());
        txnSchedulerZero.runTask(
            new TestAbstractKernelRunnable() {
                public void run() {
                    Counter counter = getClearedCounter();
                    taskServiceZero.scheduleTask(new TestTask(), 100L);
                    counter.increment();
                }
            }, id);

        long expectedNode = additionalNodes[0].getNodeId();
        mappingServiceZero.moveIdentity(getClass(), id, expectedNode);
View Full Code Here

        long expectedNode = serverNode.getNodeId();
        DummyNodeMappingService.assignIdentity(getClass(), id, expectedNode);
        txnSchedulerZero.runTask(
            new TestAbstractKernelRunnable() {
                public void run() {
                    Counter counter = getClearedCounter();
                    taskServiceZero.schedulePeriodicTask(new TestTask(), 0L,
                                                         500L);
                    counter.increment();
                    counter.increment();
                }
            }, id);

        Thread.sleep(250);
        assertEquals(expectedNode, lastNodeUsed.get());
View Full Code Here

        DummyNodeMappingService.assignIdentity(getClass(), id,
                                               serverNode.getNodeId());
        txnSchedulerZero.runTask(
            new TestAbstractKernelRunnable() {
                public void run() {
                    Counter counter = getClearedCounter();
                    taskServiceZero.schedulePeriodicTask(new TestTask(), 100L,
                                                         500L);
                    counter.increment();
                }
            }, id);

        long expectedNode = additionalNodes[0].getNodeId();
        mappingServiceZero.moveIdentity(getClass(), id, expectedNode);
View Full Code Here

        DummyNodeMappingService.assignIdentity(getClass(), id,
                                               serverNode.getNodeId());
        txnSchedulerZero.runTask(
            new TestAbstractKernelRunnable() {
                public void run() {
                    Counter counter = getClearedCounter();
                    PeriodicTaskHandle h =
                        taskServiceZero.schedulePeriodicTask(new TestTask(),
                                                             250L, 500L);
                    dataServiceZero.setBinding("handle", new ManagedHandle(h));
                }
View Full Code Here

                                               serverNode.getNodeId());
        assertEquals(DummyNodeMappingService.getActiveCount(id), 1);
        txnSchedulerZero.runTask(
            new TestAbstractKernelRunnable() {
                public void run() {
                    Counter counter = getClearedCounter();
                    taskServiceZero.scheduleTask(new TestTask(), 300L);
                }
            }, id);

        Thread.sleep(200);
        assertEquals(DummyNodeMappingService.getActiveCount(id), 2);

        Thread.sleep(800);
        assertEquals(DummyNodeMappingService.getActiveCount(id), 1);

        txnSchedulerZero.runTask(
            new TestAbstractKernelRunnable() {
                public void run() {
                    Counter counter = getClearedCounter();
                    for (int i = 0; i < 5; i++)
                        taskServiceZero.scheduleTask(new TestTask(), 300L);
                }
            }, id);
View Full Code Here

            additionalNodes[i] = node;
        }
    }

    private Counter getClearedCounter() {
        Counter counter = (Counter) dataServiceZero.getBinding("counter");
        dataServiceZero.markForUpdate(counter);
        counter.clear();
        return counter;
    }
View Full Code Here

TOP

Related Classes of com.sun.sgs.test.impl.service.task.TestTaskServiceImpl.Counter

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.