Package org.apache.bookkeeper.conf

Examples of org.apache.bookkeeper.conf.ClientConfiguration


        byte hello[] = "hello".getBytes();
        long ledger = Long.parseLong(args[2]);
        ClientSocketChannelFactory channelFactory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors
                .newCachedThreadPool());
        OrderedSafeExecutor executor = new OrderedSafeExecutor(1);
        BookieClient bc = new BookieClient(new ClientConfiguration(), channelFactory, executor);
        InetSocketAddress addr = new InetSocketAddress(args[0], Integer.parseInt(args[1]));

        for (int i = 0; i < 100000; i++) {
            counter.inc();
            bc.addEntry(addr, ledger, new byte[0], i, ChannelBuffers.wrappedBuffer(hello), cb, counter, 0);
View Full Code Here


        byte[] passwd = new byte[20];
        Arrays.fill(passwd, (byte) 'a');
        InetSocketAddress addr = new InetSocketAddress("127.0.0.1", port);
        ResultStruct arc = new ResultStruct();

        BookieClient bc = new BookieClient(new ClientConfiguration(), channelFactory, executor);
        ChannelBuffer bb;
        bb = createByteBuffer(1, 1, 1);
        bc.addEntry(addr, 1, passwd, 1, bb, wrcb, arc, BookieProtocol.FLAG_NONE);
        synchronized (arc) {
            arc.wait(1000);
View Full Code Here

     * @throws InterruptedException
     * @throws KeeperException
     */
    public BookKeeper(String servers) throws IOException, InterruptedException,
        KeeperException {
        this(new ClientConfiguration().setZkServers(servers));
    }
View Full Code Here

    @Test(timeout=60000)
    public void testNoLedger() throws Exception {
        ResultStruct arc = new ResultStruct();
        InetSocketAddress addr = new InetSocketAddress("127.0.0.1", port);
        BookieClient bc = new BookieClient(new ClientConfiguration(), channelFactory, executor);
        synchronized (arc) {
            bc.readEntry(addr, 2, 13, recb, arc);
            arc.wait(1000);
            assertEquals(BKException.Code.NoSuchEntryException, arc.rc);
        }
View Full Code Here

                this.notify();
        }
    }

    LoopbackClient(ClientSocketChannelFactory channelFactory, OrderedSafeExecutor executor, long begin, int limit) throws IOException {
        this.client = new BookieClient(new ClientConfiguration(), channelFactory, executor);
        this.begin = begin;
    }
View Full Code Here

        s410.stop();

        // Format the metadata using current version
        ServerCurrent currentServer = new ServerCurrent(journalDir, ledgerDir,
                port);
        BookKeeperAdmin.format(new ClientConfiguration(currentServer.conf),
                false, true);
        // start the current version server with old version cookie
        try {
            currentServer.start();
            fail("Bookie should not start with old cookie");
View Full Code Here

            underlyingPM = LocalDBPersistenceManager.instance();

        } else {
            try {
                ClientConfiguration bkConf = new ClientConfiguration();
                bkConf.addConfiguration(conf.getConf());
                bk = new BookKeeper(bkConf, zk, clientChannelFactory);
            } catch (KeeperException e) {
                logger.error("Could not instantiate bookkeeper client", e);
                throw new IOException(e);
            }
View Full Code Here

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

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

        lh.close();

        // Try to recover with bad password in conf
        // This is fine, because it only falls back to the configured
        // password if the password info is missing from the metadata
        ClientConfiguration adminConf = new ClientConfiguration();
        adminConf.setZkServers(zkUtil.getZooKeeperConnectString());
        adminConf.setBookieRecoveryDigestType(digestCorrect);
        adminConf.setBookieRecoveryPasswd(passwdBad);
        setMetastoreImplClass(adminConf);

        BookKeeperAdmin bka = new BookKeeperAdmin(adminConf);
        bka.recoverBookieData(bookieSrc, null);
        bka.close();

        lh = bkc.openLedgerNoRecovery(ledgerId, digestCorrect, passwdCorrect);
        assertTrue("Should be back to fully replication", verifyFullyReplicated(lh, 100));
        lh.close();

        bookieSrc = bs.get(0).getLocalAddress();
        bs.get(0).shutdown();
        bs.remove(0);
        startNewBookie();

        // Check that entries are missing
        lh = bkc.openLedgerNoRecovery(ledgerId, digestCorrect, passwdCorrect);
        assertFalse("Should be entries missing", verifyFullyReplicated(lh, 100));
        lh.close();

        // Try to recover with no password in conf
        adminConf = new ClientConfiguration();
        adminConf.setZkServers(zkUtil.getZooKeeperConnectString());
        setMetastoreImplClass(adminConf);

        bka = new BookKeeperAdmin(adminConf);
        bka.recoverBookieData(bookieSrc, null);
        bka.close();
View Full Code Here

        // Try to recover with bad password in conf
        // if the digest type is MAC
        // for CRC32, the password is only checked
        // when adding new entries, which recovery will
        // never do
        ClientConfiguration adminConf;
        BookKeeperAdmin bka;
        if (digestCorrect == DigestType.MAC) {
            adminConf = new ClientConfiguration();
            adminConf.setZkServers(zkUtil.getZooKeeperConnectString());
            adminConf.setLedgerManagerFactoryClassName(ledgerManagerFactory);
            adminConf.setBookieRecoveryDigestType(digestCorrect);
            adminConf.setBookieRecoveryPasswd(passwdBad);

            bka = new BookKeeperAdmin(adminConf);
            try {
                bka.recoverBookieData(bookieSrc, null);
                fail("Shouldn't be able to recover with wrong password");
            } catch (BKException bke) {
                // correct behaviour
            } finally {
                bka.close();
            }
        }

        // Try to recover with bad digest in conf
        adminConf = new ClientConfiguration();
        adminConf.setZkServers(zkUtil.getZooKeeperConnectString());
        adminConf.setLedgerManagerFactoryClassName(ledgerManagerFactory);
        adminConf.setBookieRecoveryDigestType(digestBad);
        adminConf.setBookieRecoveryPasswd(passwdCorrect);

        bka = new BookKeeperAdmin(adminConf);
        try {
            bka.recoverBookieData(bookieSrc, null);
            fail("Shouldn't be able to recover with wrong digest");
        } catch (BKException bke) {
            // correct behaviour
        } finally {
            bka.close();
        }

        // Check that entries are still missing
        lh = bkc.openLedgerNoRecovery(ledgerId, digestCorrect, passwdCorrect);
        assertFalse("Should be entries missing", verifyFullyReplicated(lh, 100));
        lh.close();

        adminConf.setBookieRecoveryDigestType(digestCorrect);
        adminConf.setBookieRecoveryPasswd(passwdCorrect);

        bka = new BookKeeperAdmin(adminConf);
        bka.recoverBookieData(bookieSrc, null);
        bka.close();
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.