Package org.apache.activemq.leveldb.replicated

Examples of org.apache.activemq.leveldb.replicated.SlaveLevelDBStore


        // 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


        // 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));

            LOG.info("Adding messages...");
            final int TOTAL = 500;
            for (int i = 0; i < TOTAL; i++) {
                if (i % ((int) (TOTAL * 0.10)) == 0) {
                    LOG.info("" + (100 * i / TOTAL) + "% done");
                }

                if (i == 250) {
                    slave1.start();
                    slave2.stop();
                    LOG.info("Checking: "+master.getDirectory());
                    assertEquals(expected_list, getMessages(ms));
                }

                String msgid = "m:" + j + ":" + i;
View Full Code Here

        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;
        for (int i = 0; i < TOTAL; i++) {
            if (i == 8) {
                // Stop the fast slave so that we wait for the slow slave to
                // catch up..
                node3.stop();
            }

            String msgid = "m:" + ":" + i;
            addMessage(ms, msgid, playload);
            expected_list.add(msgid);
View Full Code Here

        node2.stop();
    }


    private SlaveLevelDBStore createSlave(MasterLevelDBStore master, File directory) {
        SlaveLevelDBStore slave = new SlaveLevelDBStore();
        configureSlave(slave, master, directory);
        return slave;
    }
View Full Code Here

        // 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

        // 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++) {
                if (i % ((int) (TOTAL * 0.10)) == 0) {
                    LOG.info("" + (100 * i / TOTAL) + "% done");
                }

                if (i == 250) {
                    slave1.start();
                    slave2.stop();
                }

                String msgid = "m:" + j + ":" + i;
                addMessage(ms, msgid);
                expected_list.add(msgid);
View Full Code Here

            directories.addLast(directories.removeFirst());
        }
    }

    private SlaveLevelDBStore createSlave(MasterLevelDBStore master, File directory) {
        SlaveLevelDBStore slave1 = new SlaveLevelDBStore();
        slave1.setDirectory(directory);
        slave1.setConnect("tcp://127.0.0.1:" + master.getPort());
        slave1.setSecurityToken("foo");
        slave1.setLogSize(1023 * 200);
        return slave1;
    }
View Full Code Here

        // 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

        // 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));

            LOG.info("Adding messages...");
            final int TOTAL = 500;
            for (int i = 0; i < TOTAL; i++) {
                if (i % ((int) (TOTAL * 0.10)) == 0) {
                    LOG.info("" + (100 * i / TOTAL) + "% done");
                }

                if (i == 250) {
                    slave1.start();
                    slave2.stop();
                    LOG.info("Checking: "+master.getDirectory());
                    assertEquals(expected_list, getMessages(ms));
                }

                String msgid = "m:" + j + ":" + i;
View Full Code Here

        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;
        for (int i = 0; i < TOTAL; i++) {
            if (i == 8) {
                // Stop the fast slave so that we wait for the slow slave to
                // catch up..
                node3.stop();
            }

            String msgid = "m:" + ":" + i;
            addMessage(ms, msgid, playload);
            expected_list.add(msgid);
View Full Code Here

TOP

Related Classes of org.apache.activemq.leveldb.replicated.SlaveLevelDBStore

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.