Package org.apache.activemq.leveldb

Examples of org.apache.activemq.leveldb.CountDownFuture


        FileSupport.toRichFile(masterDir).recursiveDelete();
        FileSupport.toRichFile(slaveDir).recursiveDelete();

        final MasterLevelDBStore master = createMaster(masterDir);
        master.setReplicas(2);
        CountDownFuture masterStartLatch = asyncStart(master);

        // Start the store should not complete since we don't have enough
        // replicas.
        assertFalse(masterStartLatch.await(2, TimeUnit.SECONDS));

        // Adding a slave should allow the master startup to complete.
        SlaveLevelDBStore slave = createSlave(master, slaveDir);
        slave.start();

        assertTrue(masterStartLatch.await(2, TimeUnit.SECONDS));

        // New updates should complete quickly now..
        MessageStore ms = master.createQueueMessageStore(new ActiveMQQueue("TEST"));
        CountDownFuture f = asyncAddMessage(ms, "m1");
        assertTrue(f.await(1, TimeUnit.SECONDS));

        // If the slave goes offline, then updates should once again
        // not complete.
        slave.stop();

        f = asyncAddMessage(ms, "m2");
        assertFalse(f.await(2, TimeUnit.SECONDS));

        // Restart and the op should complete.
        slave = createSlave(master, slaveDir);
        slave.start();
        assertTrue(f.await(2, TimeUnit.SECONDS));

        master.stop();
        slave.stop();

    }
View Full Code Here


        ArrayList<String> expected_list = new ArrayList<String>();
        // We will rotate between 3 nodes the task of being the master.
        for (int j = 0; j < 5; j++) {

            MasterLevelDBStore master = createMaster(directories.get(0));
            CountDownFuture masterStart = asyncStart(master);
            SlaveLevelDBStore slave1 = createSlave(master, directories.get(1));
            SlaveLevelDBStore slave2 = createSlave(master, directories.get(2));
            asyncStart(slave2);
            masterStart.await();

            MessageStore ms = master.createQueueMessageStore(new ActiveMQQueue("TEST"));

            LOG.info("Checking: "+master.getDirectory());
            assertEquals(expected_list, getMessages(ms));
View Full Code Here

        File node3Dir = directories.get(2);

        ArrayList<String> expected_list = new ArrayList<String>();

        MasterLevelDBStore node1 = createMaster(node1Dir);
        CountDownFuture masterStart = asyncStart(node1);

        // Lets create a 1 slow slave...
        SlaveLevelDBStore node2 = new SlaveLevelDBStore() {
            boolean hitOnce = false;
            @Override
            public TcpTransport create_transport() {
                if( hitOnce ) {
                    return super.create_transport();
                }
                hitOnce = true;
                TcpTransport transport = super.create_transport();
                transport.setMaxReadRate(64*1024);
                return transport;
            }
        };
        configureSlave(node2, node1, node2Dir);
        SlaveLevelDBStore node3 = createSlave(node1, node3Dir);

        asyncStart(node2);
        asyncStart(node3);
        masterStart.await();

        LOG.info("Adding messages...");
        String playload = createPlayload(64 * 1024);
        MessageStore ms = node1.createQueueMessageStore(new ActiveMQQueue("TEST"));
        final int TOTAL = 10;
View Full Code Here

            stores.add(store);
            pending_starts.add(asyncStart(store));
        }

        // At least one of the stores should have started.
        CountDownFuture f = waitFor(30 * 1000, pending_starts.toArray(new CountDownFuture[pending_starts.size()]));
        assertTrue(f!=null);
        pending_starts.remove(f);

        // The other stores should not start..
        LOG.info("Making sure the other stores don't start");
View Full Code Here

            stores.add(store);
            pending_starts.add(asyncStart(store));
        }

        // At least one of the stores should have started.
        CountDownFuture f = waitFor(30 * 1000, pending_starts.toArray(new CountDownFuture[pending_starts.size()]));
        assertTrue(f != null);
        pending_starts.remove(f);

        // The other stores should not start..
        LOG.info("Making sure the other stores don't start");
View Full Code Here

        FileSupport.toRichFile(masterDir).recursiveDelete();
        FileSupport.toRichFile(slaveDir).recursiveDelete();

        final MasterLevelDBStore master = createMaster(masterDir);
        master.setReplicas(2);
        CountDownFuture masterStartLatch = asyncStart(master);

        // Start the store should not complete since we don't have enough
        // replicas.
        assertFalse(masterStartLatch.await(2, TimeUnit.SECONDS));

        // Adding a slave should allow the master startup to complete.
        SlaveLevelDBStore slave = createSlave(master, slaveDir);
        slave.start();

        assertTrue(masterStartLatch.await(2, TimeUnit.SECONDS));

        // New updates should complete quickly now..
        MessageStore ms = master.createQueueMessageStore(new ActiveMQQueue("TEST"));
        CountDownFuture f = asyncAddMessage(ms, "m1");
        assertTrue(f.await(1, TimeUnit.SECONDS));

        // If the slave goes offline, then updates should once again
        // not complete.
        slave.stop();

        f = asyncAddMessage(ms, "m2");
        assertFalse(f.await(2, TimeUnit.SECONDS));

        // Restart and the op should complete.
        slave = createSlave(master, slaveDir);
        slave.start();
        assertTrue(f.await(2, TimeUnit.SECONDS));

        master.stop();
        slave.stop();

    }
View Full Code Here

        ArrayList<String> expected_list = new ArrayList<String>();
        // We will rotate between 3 nodes the task of being the master.
        for (int j = 0; j < 10; j++) {

            MasterLevelDBStore master = createMaster(directories.get(0));
            CountDownFuture masterStart = asyncStart(master);
            SlaveLevelDBStore slave1 = createSlave(master, directories.get(1));
            SlaveLevelDBStore slave2 = createSlave(master, directories.get(2));
            asyncStart(slave2);
            masterStart.await();

            LOG.info("Adding messages...");
            MessageStore ms = master.createQueueMessageStore(new ActiveMQQueue("TEST"));
            final int TOTAL = 500;
            for (int i = 0; i < TOTAL; i++) {
View Full Code Here

            stores.add(store);
            pending_starts.add(asyncStart(store));
        }

        // At least one of the stores should have started.
        CountDownFuture f = waitFor(30 * 1000, pending_starts.toArray(new CountDownFuture[pending_starts.size()]));
        assertTrue(f!=null);
        pending_starts.remove(f);

        // The other stores should not start..
        LOG.info("Making sure the other stores don't start");
View Full Code Here

            stores.add(store);
            pending_starts.add(asyncStart(store));
        }

        // At least one of the stores should have started.
        CountDownFuture f = waitFor(30 * 1000, pending_starts.toArray(new CountDownFuture[pending_starts.size()]));
        assertTrue(f != null);
        pending_starts.remove(f);

        // The other stores should not start..
        LOG.info("Making sure the other stores don't start");
View Full Code Here

            stores.add(store);
            pending_starts.add(asyncStart(store));
        }

        // At least one of the stores should have started.
        CountDownFuture f = waitFor(30 * 1000, pending_starts.toArray(new CountDownFuture[pending_starts.size()]));
        assertTrue(f!=null);
        pending_starts.remove(f);

        // The other stores should not start..
        LOG.info("Making sure the other stores don't start");
View Full Code Here

TOP

Related Classes of org.apache.activemq.leveldb.CountDownFuture

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.