Package com.sun.sgs.kernel.schedule

Examples of com.sun.sgs.kernel.schedule.SchedulerQueue


        SchedulerQueue queue = getQueueInstance();
        queue.addTask(new ScheduledTaskImpl(testTask, 100));
    }

    @Test public void addTasks() throws Exception {
        SchedulerQueue queue = getQueueInstance();
        queue.addTask(testTask);
        queue.addTask(testTask);
        queue.addTask(testTask);
        queue.addTask(testTask);
        queue.addTask(testTask);
        queue.addTask(testTask);
    }
View Full Code Here


        queue.addTask(testTask);
        queue.addTask(testTask);
    }

    @Test public void addTasksDelayed() throws Exception {
        SchedulerQueue queue = getQueueInstance();
        ScheduledTask delayedTask = new ScheduledTaskImpl(testTask, 100);
        queue.addTask(delayedTask);
        queue.addTask(delayedTask);
        queue.addTask(delayedTask);
        queue.addTask(delayedTask);
        queue.addTask(delayedTask);
        queue.addTask(delayedTask);
    }
View Full Code Here

        queue.addTask(delayedTask);
    }

    @Test (expected=NullPointerException.class)
        public void addTaskNull() throws Exception {
        SchedulerQueue queue = getQueueInstance();
        queue.addTask(null);
    }
View Full Code Here

    /**
     * Add and consume correctness tests.
     */

    @Test public void addAndConsumeTask() throws Exception {
        SchedulerQueue queue = getQueueInstance();
        ScheduledTask task = new ScheduledTaskImpl();
        queue.addTask(task);
        assertEquals(task, queue.getNextTask(false));
    }
View Full Code Here

        assertEquals(task, queue.getNextTask(false));
    }

    @Test (timeout=100)
        public void addAndConsumeTaskWaiting() throws Exception {
        SchedulerQueue queue = getQueueInstance();
        queue.addTask(new ScheduledTaskImpl());
        queue.getNextTask(true);
    }
View Full Code Here

        queue.addTask(new ScheduledTaskImpl());
        queue.getNextTask(true);
    }

    @Test public void addAndConsumeTasks() throws Exception {
        SchedulerQueue queue = getQueueInstance();
        queue.addTask(new ScheduledTaskImpl());
        queue.addTask(new ScheduledTaskImpl());
        queue.addTask(new ScheduledTaskImpl());
        assertNotNull(queue.getNextTask(false));
        assertNotNull(queue.getNextTask(false));
        assertNotNull(queue.getNextTask(false));
        assertNull(queue.getNextTask(false));

        queue.addTask(new ScheduledTaskImpl());
        queue.addTask(new ScheduledTaskImpl());
        queue.addTask(new ScheduledTaskImpl());
        queue.addTask(new ScheduledTaskImpl());
        queue.addTask(new ScheduledTaskImpl());
        queue.addTask(new ScheduledTaskImpl());
        LinkedList<ScheduledTask> tasks = new LinkedList<ScheduledTask>();
        assertEquals(6, queue.getNextTasks(tasks, 10));
    }
View Full Code Here

        assertEquals(6, queue.getNextTasks(tasks, 10));
    }

    @Test (timeout=300)
        public void reserveAndConsumeTasks() throws Exception {
        SchedulerQueue queue = getQueueInstance();
        TaskReservation reservation =queue.reserveTask(new ScheduledTaskImpl());
        reservation.use();
        reservation = queue.reserveTask(new ScheduledTaskImpl());
        reservation.cancel();
        reservation = queue.reserveTask(new ScheduledTaskImpl(100));
        reservation.use();
        reservation = queue.reserveTask(new ScheduledTaskImpl(120));
        reservation.cancel();
        reservation = queue.reserveTask(new ScheduledTaskImpl(140));
        reservation.use();
        assertNotNull(queue.getNextTask(false));
        assertNull(queue.getNextTask(false));
        assertNotNull(queue.getNextTask(true));
        assertNotNull(queue.getNextTask(true));
        assertNull(queue.getNextTask(false));
    }
View Full Code Here

        assertNotNull(queue.getNextTask(true));
        assertNull(queue.getNextTask(false));
    }

    @Test public void addAndConsumeTaskDelayed() throws Exception {
        SchedulerQueue queue = getQueueInstance();
        ScheduledTask task = new ScheduledTaskImpl(100);
        queue.addTask(task);
        assertNull(queue.getNextTask(false));
        Thread.sleep(200);
        assertEquals(task, queue.getNextTask(false));
    }
View Full Code Here

        assertEquals(task, queue.getNextTask(false));
    }

    @Test (timeout=200)
        public void addAndConsumeTaskDelayedWaiting() throws Exception {
        SchedulerQueue queue = getQueueInstance();
        queue.addTask(new ScheduledTaskImpl(100));
        queue.getNextTask(true);
    }
View Full Code Here

        queue.addTask(new ScheduledTaskImpl(100));
        queue.getNextTask(true);
    }

    @Test public void addAndConsumeTasksDelayed() throws Exception {
        SchedulerQueue queue = getQueueInstance();
        queue.addTask(new ScheduledTaskImpl(100));
        queue.addTask(new ScheduledTaskImpl(100));
        queue.addTask(new ScheduledTaskImpl(120));
        queue.addTask(new ScheduledTaskImpl(110));
        Thread.sleep(200);
        assertNotNull(queue.getNextTask(false));
        assertNotNull(queue.getNextTask(false));
        assertNotNull(queue.getNextTask(false));
        assertNotNull(queue.getNextTask(false));
        assertNull(queue.getNextTask(false));

        queue.addTask(new ScheduledTaskImpl(100));
        queue.addTask(new ScheduledTaskImpl(100));
        queue.addTask(new ScheduledTaskImpl(120));
        queue.addTask(new ScheduledTaskImpl(110));
        queue.addTask(new ScheduledTaskImpl(150));
        LinkedList<ScheduledTask> tasks = new LinkedList<ScheduledTask>();
        assertEquals(0, queue.getNextTasks(tasks, 5));
        Thread.sleep(200);
        assertEquals(3, queue.getNextTasks(tasks, 3));
        assertEquals(2, queue.getNextTasks(tasks, 3));
    }
View Full Code Here

TOP

Related Classes of com.sun.sgs.kernel.schedule.SchedulerQueue

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.