Package org.apache.bookkeeper.conf

Examples of org.apache.bookkeeper.conf.ClientConfiguration


    /*
     * Test Cookie verification with format.
     */
    @Test(timeout=60000)
    public void testVerifyCookieWithFormat() throws Exception {
        ClientConfiguration adminConf = new ClientConfiguration()
            .setZkServers(zkutil.getZooKeeperConnectString());

        adminConf.setProperty("bookkeeper.format", true);
        // Format the BK Metadata and generate INSTANCEID
        BookKeeperAdmin.format(adminConf, false, true);

        ServerConfiguration bookieConf = new ServerConfiguration()
                .setZkServers(zkutil.getZooKeeperConnectString())
View Full Code Here


        super(0);
    }

    @Test(timeout=60000)
    public void testLedgerLayout() throws Exception {
        ClientConfiguration conf = new ClientConfiguration();
        conf.setLedgerManagerFactoryClass(HierarchicalLedgerManagerFactory.class);
        String ledgerRootPath = "/testLedgerLayout";

        zkc.create(ledgerRootPath, new byte[0],
                   Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
View Full Code Here

        layout.store(zkc, ledgersRootPath);
    }

    @Test(timeout=60000)
    public void testBadVersionLedgerLayout() throws Exception {
        ClientConfiguration conf = new ClientConfiguration();
        // write bad version ledger layout
        writeLedgerLayout(conf.getZkLedgersRootPath(),
                          FlatLedgerManagerFactory.class.getName(),
                          FlatLedgerManagerFactory.CUR_VERSION,
                          LedgerLayout.LAYOUT_FORMAT_VERSION + 1);
       
        try {
            LedgerLayout.readLayout(zkc, conf.getZkLedgersRootPath());
            fail("Shouldn't reach here!");
        } catch (IOException ie) {
            assertTrue("Invalid exception", ie.getMessage().contains("version not compatible"));
        }
    }
View Full Code Here

        }
    }

    @Test(timeout=60000)
    public void testAbsentLedgerManagerLayout() throws Exception {
        ClientConfiguration conf = new ClientConfiguration();
        String ledgersLayout = conf.getZkLedgersRootPath() + "/"
                + BookKeeperConstants.LAYOUT_ZNODE;
        // write bad format ledger layout
        StringBuilder sb = new StringBuilder();
        sb.append(LedgerLayout.LAYOUT_FORMAT_VERSION).append("\n");
        zkc.create(ledgersLayout, sb.toString().getBytes(),
                                 Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

        try {
            LedgerLayout.readLayout(zkc, conf.getZkLedgersRootPath());
            fail("Shouldn't reach here!");
        } catch (IOException ie) {
            assertTrue("Invalid exception", ie.getMessage().contains("version absent from"));
        }
    }
View Full Code Here

        }
    }

    @Test(timeout=60000)
    public void testBaseLedgerManagerLayout() throws Exception {
        ClientConfiguration conf = new ClientConfiguration();
        String rootPath = conf.getZkLedgersRootPath();
        String ledgersLayout = rootPath + "/"
                + BookKeeperConstants.LAYOUT_ZNODE;
        // write bad format ledger layout
        StringBuilder sb = new StringBuilder();
        sb.append(LedgerLayout.LAYOUT_FORMAT_VERSION).append("\n")
View Full Code Here

        }
    }

    @Test(timeout=60000)
    public void testReadV1LedgerManagerLayout() throws Exception {
        ClientConfiguration conf = new ClientConfiguration();
        // write v1 ledger layout
        writeLedgerLayout(conf.getZkLedgersRootPath(),
                          FlatLedgerManagerFactory.NAME,
                          FlatLedgerManagerFactory.CUR_VERSION, 1);

        LedgerLayout layout = LedgerLayout.readLayout(zkc, conf.getZkLedgersRootPath());
        assertNotNull("Should not be null", layout);
        assertEquals(FlatLedgerManagerFactory.NAME, layout.getManagerType());
        assertEquals(FlatLedgerManagerFactory.CUR_VERSION, layout.getManagerVersion());
        assertEquals(1, layout.getLayoutFormatVersion());
    }
View Full Code Here

    /**
     * Test bad client configuration
     */
    @Test(timeout=60000)
    public void testBadConf() throws Exception {
        ClientConfiguration conf = new ClientConfiguration();
       
        // success case
        String root0 = "/goodconf0";
        zkc.create(root0, new byte[0],
                   Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        conf.setZkLedgersRootPath(root0);

        LedgerManagerFactory m = LedgerManagerFactory.newLedgerManagerFactory(conf, zkc);
        assertTrue("Ledger manager is unexpected type",
                   (m instanceof FlatLedgerManagerFactory));
        m.uninitialize();

        // mismatching conf
        conf.setLedgerManagerFactoryClass(HierarchicalLedgerManagerFactory.class);
        try {
            LedgerManagerFactory.newLedgerManagerFactory(conf, zkc);
            fail("Shouldn't reach here");
        } catch (Exception e) {
            LOG.error("Received exception", e);
            assertTrue("Invalid exception",
                       e.getMessage().contains("does not match existing layout"));
        }

        // invalid ledger manager
        String root1 = "/badconf1";
        zkc.create(root1, new byte[0],
                   Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        conf.setZkLedgersRootPath(root1);

        conf.setLedgerManagerFactoryClassName("DoesNotExist");
        try {
            LedgerManagerFactory f = LedgerManagerFactory.newLedgerManagerFactory(conf, zkc);
            fail("Shouldn't reach here");
        } catch (Exception e) {
            LOG.error("Received exception", e);
View Full Code Here

    /**
     * Test bad client configuration
     */
    @Test(timeout=60000)
    public void testBadConfV1() throws Exception {
        ClientConfiguration conf = new ClientConfiguration();

        String root0 = "/goodconf0";
        zkc.create(root0, new byte[0],
                   Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        conf.setZkLedgersRootPath(root0);
        // write v1 layout
        writeLedgerLayout(root0, FlatLedgerManagerFactory.NAME,
                          FlatLedgerManagerFactory.CUR_VERSION, 1);

        conf.setLedgerManagerFactoryClass(FlatLedgerManagerFactory.class);

        LedgerManagerFactory m = LedgerManagerFactory.newLedgerManagerFactory(conf, zkc);
        assertTrue("Ledger manager is unexpected type",
                   (m instanceof FlatLedgerManagerFactory));
        m.uninitialize();

        // v2 setting doesn't effect v1
        conf.setLedgerManagerFactoryClass(HierarchicalLedgerManagerFactory.class);
        m = LedgerManagerFactory.newLedgerManagerFactory(conf, zkc);
        assertTrue("Ledger manager is unexpected type",
                   (m instanceof FlatLedgerManagerFactory));
        m.uninitialize();

        // mismatching conf
        conf.setLedgerManagerType(HierarchicalLedgerManagerFactory.NAME);
        try {
            LedgerManagerFactory.newLedgerManagerFactory(conf, zkc);
            fail("Shouldn't reach here");
        } catch (Exception e) {
            LOG.error("Received exception", e);
View Full Code Here

    /**
     * Test bad zk configuration
     */
    @Test(timeout=60000)
    public void testBadZkContents() throws Exception {
        ClientConfiguration conf = new ClientConfiguration();
       
        // bad type in zookeeper
        String root0 = "/badzk0";
        zkc.create(root0, new byte[0],
                   Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        conf.setZkLedgersRootPath(root0);
       
        new LedgerLayout("DoesNotExist",
                         0xdeadbeef).store(zkc, root0);
       
        try {
            LedgerManagerFactory.newLedgerManagerFactory(conf, zkc);
            fail("Shouldn't reach here");
        } catch (Exception e) {
            LOG.error("Received exception", e);
            assertTrue("Invalid exception",
                    e.getMessage().contains("Failed to instantiate ledger manager factory"));
        }

        // bad version in zookeeper
        String root1 = "/badzk1";
        zkc.create(root1, new byte[0],
                   Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        conf.setZkLedgersRootPath(root1);
       
        new LedgerLayout(FlatLedgerManagerFactory.class.getName(),
                         0xdeadbeef).store(zkc, root1);
       
        try {
View Full Code Here

                });
            latch.await();
        }

        public void run() {
            ClientConfiguration conf = new ClientConfiguration();
            conf.setLedgerManagerFactoryClassName(factoryCls);

            try {
                barrier.await();
                LedgerManagerFactory factory =
                    LedgerManagerFactory.newLedgerManagerFactory(conf, zkc);
View Full Code Here

TOP

Related Classes of org.apache.bookkeeper.conf.ClientConfiguration

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.