Package org.apache.bookkeeper.conf

Examples of org.apache.bookkeeper.conf.ClientConfiguration


       
        /*
         * Create new ledger for adding records
         */
        try{
            bk = new BookKeeper(new ClientConfiguration(), zk);
        } catch (Exception e) {
            LOG.error("Exception while initializing bookkeeper", e);
            throw new LoggerException.BKOpFailedException()
        }
       
View Full Code Here


        }
       
        LOG.info("Creating bookkeeper client");
       
        try{
            bk = new BookKeeper(new ClientConfiguration(), this.zk);   
        } catch (Exception e) {
            LOG.error("Error while creating bookkeeper object", e);
            return null;
        }
       
View Full Code Here

        baseClientConf.setBookieRecoveryPasswd("".getBytes());
        super.setUp();

        sync = new SyncObject();
        bookieRecoverCb = new BookieRecoverCallback();
        ClientConfiguration adminConf = new ClientConfiguration(baseClientConf);
        adminConf.setZkServers(HOSTPORT);
        bkAdmin = new BookKeeperAdmin(adminConf);
    }
View Full Code Here

            BookKeeper bk = null;
            try {
                barrier.await();
                while(true) {
                    try {
                        bk = new BookKeeper(new ClientConfiguration(baseClientConf), bkc.getZkHandle());
                       
                        lh = bk.openLedger(ledgerId,
                                           digestType, "".getBytes());
                        lastConfirmedEntry = lh.getLastAddConfirmed();
                        lh.close();
View Full Code Here

        this.digestType = digestType;
    }

    @Test
    public void testLedgerLayout() throws Exception {
        ClientConfiguration conf = new ClientConfiguration();
        conf.setLedgerManagerType(HierarchicalLedgerManager.NAME);
        String ledgerRootPath = "/testLedgerLayout";

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

        layout.store(zkc, ledgersRootPath);
    }

    @Test
    public void testBadVersionLedgerLayout() throws Exception {
        ClientConfiguration conf = new ClientConfiguration();
        // write bad version ledger layout
        writeLedgerLayout(conf.getZkLedgersRootPath(), FlatLedgerManager.NAME,
                FlatLedgerManager.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
    public void testAbsentLedgerManagerLayout() throws Exception {
        ClientConfiguration conf = new ClientConfiguration();
        String ledgersLayout = conf.getZkLedgersRootPath() + "/" + LedgerLayout.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
    public void testBaseLedgerManagerLayout() throws Exception {
        ClientConfiguration conf = new ClientConfiguration();
        String rootPath = conf.getZkLedgersRootPath();
        String ledgersLayout = rootPath + "/" + LedgerLayout.LAYOUT_ZNODE;
        // write bad format ledger layout
        StringBuilder sb = new StringBuilder();
        sb.append(LedgerLayout.LAYOUT_FORMAT_VERSION).append("\n")
          .append(FlatLedgerManager.NAME);
View Full Code Here

    /**
     * Test bad client configuration
     */
    @Test
    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);

        LedgerManager m = LedgerManagerFactory.newLedgerManager(conf, zkc);
        assertTrue("Ledger manager is unexpected type",
                   (m instanceof FlatLedgerManager));

        // mismatching conf
        conf.setLedgerManagerType(HierarchicalLedgerManager.NAME);
        try {
            LedgerManagerFactory.newLedgerManager(conf, zkc);
            fail("Shouldn't reach here");
        } catch (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.setLedgerManagerType("DoesNotExist");
        try {
            LedgerManagerFactory.newLedgerManager(conf, zkc);
            fail("Shouldn't reach here");
        } catch (Exception e) {
            assertTrue("Invalid exception",
View Full Code Here

    /**
     * Test bad zk configuration
     */
    @Test
    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.newLedgerManager(conf, zkc);
            fail("Shouldn't reach here");
        } catch (Exception e) {
            assertTrue("Invalid exception",
                    e.getMessage().contains("Unknown ledger manager type"));
        }

        // bad version in zookeeper
        String root1 = "/badzk1";
        zkc.create(root1, new byte[0],
                   Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        conf.setZkLedgersRootPath(root1);
       
        new LedgerLayout(FlatLedgerManager.NAME,
                         0xdeadbeef).store(zkc, root1);
       
        try {
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.