Package org.jgroups.util

Examples of org.jgroups.util.Queue


            diag_handler=new DiagnosticsHandler();
            diag_handler.start();
        }

        if(use_incoming_packet_handler && !use_concurrent_stack) {
            incoming_packet_queue=new Queue();
            incoming_packet_handler=new IncomingPacketHandler();
            incoming_packet_handler.start();
        }


        // ========================================== OOB thread pool ==============================
        // create a ThreadPoolExecutor for the unmarshaller thread pool
        if(oob_thread_pool == null) { // only create if not yet set (e.g. by a user)
            if(oob_thread_pool_enabled) {
                if(oob_thread_pool_queue_enabled)
                    oob_thread_pool_queue=new LinkedBlockingQueue<Runnable>(oob_thread_pool_queue_max_size);
                else
                    oob_thread_pool_queue=new SynchronousQueue<Runnable>();
                oob_thread_pool=createThreadPool(oob_thread_pool_min_threads, oob_thread_pool_max_threads, oob_thread_pool_keep_alive_time,
                                                 oob_thread_pool_rejection_policy, oob_thread_pool_queue, "OOB");
            }
            else { // otherwise use the caller's thread to unmarshal the byte buffer into a message
                oob_thread_pool=new DirectExecutor();
            }
        }


        // ====================================== Regular thread pool ===========================
        // create a ThreadPoolExecutor for the unmarshaller thread pool
        if(thread_pool == null) { // only create if not yet set (e.g.by a user)
            if(thread_pool_enabled) {
                if(thread_pool_queue_enabled)
                    thread_pool_queue=new LinkedBlockingQueue<Runnable>(thread_pool_queue_max_size);
                else
                    thread_pool_queue=new SynchronousQueue<Runnable>();
                thread_pool=createThreadPool(thread_pool_min_threads, thread_pool_max_threads, thread_pool_keep_alive_time,
                                             thread_pool_rejection_policy, thread_pool_queue, "Incoming");
            }
            else { // otherwise use the caller's thread to unmarshal the byte buffer into a message
                thread_pool=new DirectExecutor();
            }
        }


        if(loopback && !use_concurrent_stack) {
            incoming_msg_queue=new Queue();
            incoming_msg_handler=new IncomingMessageHandler();
            incoming_msg_handler.start();
        }

        if(enable_bundling) {
View Full Code Here





    public static void testRemoveElementNoElement() {
        final Queue queue=new Queue();
        String s1="Q1";

        try {
            queue.removeElement(s1);
            assert !(queue.closed());
            assert queue.size() == 0;
        }
        catch(QueueClosedException ex) {
            assert false : ex.toString();
        }
    }
View Full Code Here

    }



    public static void testRemoveElementOneElement() {
        final Queue queue=new Queue();
        String s1="Q1";

        try {
            queue.add(s1);
            queue.removeElement(s1);
            assert queue.size() == 0;
            assert queue.getFirst() == null;
            assert queue.getLast() == null;
        }
        catch(QueueClosedException ex) {
            assert false : ex.toString();
        }
    }
View Full Code Here

    }


    public static void testRemoveElementTwoElementsFirstFound() {
        String s1="Q1", s2="Q2";
        final Queue queue=new Queue();

        try {
            queue.add(s1);
            queue.add(s2);
            queue.removeElement(s1);
            assert queue.size() == 1;
            assert queue.getFirst().equals(s2);
            assert queue.getLast().equals(s2);
            assert queue.getFirst().equals(queue.getLast());
        }
        catch(QueueClosedException ex) {
            assert false : ex.toString();
        }
    }
View Full Code Here

    }


    public static void testRemoveElementTwoElementsSecondFound() {
        String s1="Q1", s2="Q2";
        final Queue queue=new Queue();

        try {
            queue.add(s1);
            queue.add(s2);
            queue.removeElement(s2);
            assert queue.size() == 1;
            assert queue.getFirst().equals(s1);
            assert queue.getLast().equals(s1);
            assert queue.getFirst().equals(queue.getLast());
        }
        catch(QueueClosedException ex) {
            assert false : ex.toString();
        }
    }
View Full Code Here

    }


    public static void testRemoveElementThreeElementsFirstFound() {
        String s1="Q1", s2="Q2", s3="Q3";
        final Queue queue=new Queue();

        try {
            queue.add(s1);
            queue.add(s2);
            queue.add(s3);
            queue.removeElement(s1);
            assert queue.size() == 2;
            assert queue.getFirst().equals(s2);
            assert queue.getLast().equals(s3);
        }
        catch(QueueClosedException ex) {
            assert false : ex.toString();
        }
    }
View Full Code Here

    }


    public static void testRemoveElementThreeElementsSecondFound() {
        String s1="Q1", s2="Q2", s3="Q3";
        final Queue queue=new Queue();

        try {
            queue.add(s1);
            queue.add(s2);
            queue.add(s3);
            queue.removeElement(s2);
            assert queue.size() == 2;
            assert queue.getFirst().equals(s1);
            assert queue.getLast().equals(s3);
        }
        catch(QueueClosedException ex) {
            assert false : ex.toString();
        }
    }
View Full Code Here

    }


    public static void testRemoveElementThreeElementsThirdFound() {
        String s1="Q1", s2="Q2", s3="Q3";
        final Queue queue=new Queue();

        try {
            queue.add(s1);
            queue.add(s2);
            queue.add(s3);
            queue.removeElement(s3);
            assert queue.size() == 2;
            assert queue.getFirst().equals(s1);
            assert queue.getLast().equals(s2);
        }
        catch(QueueClosedException ex) {
            assert false : ex.toString();
        }
    }
View Full Code Here

    }


    @Test(expectedExceptions=QueueClosedException.class)
    public static void testRemoveAndClose() throws QueueClosedException {
        final Queue queue=new Queue();
        new Thread() {
            public void run() {
                Util.sleep(1000);
                queue.close(true); // close gracefully
            }
        }.start();
        queue.remove();
    }
View Full Code Here

    }


    @Test(expectedExceptions=QueueClosedException.class)
    public static void testRemoveAndCloseWithTimeout() throws QueueClosedException, TimeoutException {
        final Queue queue=new Queue();
        new Thread() {
            public void run() {
                Util.sleep(1000);
                queue.close(true); // close gracefully
            }
        }.start();

        queue.remove(5000);
    }
View Full Code Here

TOP

Related Classes of org.jgroups.util.Queue

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.