Package org.apache.bookkeeper.conf

Examples of org.apache.bookkeeper.conf.ServerConfiguration


                bookie.isAlive());
    }

    private void startNewBookieWithMultipleLedgerDirs(int numOfLedgerDirs)
            throws Exception {
        ServerConfiguration conf = bsConfs.get(1);
        killBookie(1);

        File[] ledgerDirs = new File[numOfLedgerDirs];
        for (int i = 0; i < numOfLedgerDirs; i++) {
            File dir = File.createTempFile("bookie", "test");
            tmpDirs.add(dir);
            dir.delete();
            dir.mkdir();
            ledgerDirs[i] = dir;
        }

        ServerConfiguration newConf = newServerConfiguration(
                conf.getBookiePort() + 1, zkUtil.getZooKeeperConnectString(),
                ledgerDirs[0], ledgerDirs);
        bsConfs.add(newConf);
        bs.add(startBookie(newConf));
    }
View Full Code Here


        createVersion2File(d);
        return d;
    }

    private static void testUpgradeProceedure(String zkServers, String journalDir, String ledgerDir) throws Exception {
        ServerConfiguration conf = new ServerConfiguration()
            .setAllowLoopback(true)
            .setZkServers(zkServers)
            .setJournalDirName(journalDir)
            .setLedgerDirNames(new String[] { ledgerDir })
            .setBookiePort(bookiePort);
View Full Code Here

     * @throws IOException
     * @throws InterruptedException
     */
    public static void main(String[] args)
            throws IOException, InterruptedException, BookieException, KeeperException {
        Bookie b = new Bookie(new ServerConfiguration());
        b.start();
        CounterCallback cb = new CounterCallback();
        long start = MathUtils.now();
        for (int i = 0; i < 100000; i++) {
            ByteBuffer buff = ByteBuffer.allocate(1024);
View Full Code Here

    @Before
    public void setupZooKeeper() throws Exception {
        zkUtil = new ZooKeeperUtil();
        zkUtil.startServer();

        conf = new ServerConfiguration()
            .setAllowLoopback(true)
            .setZkServers(zkUtil.getZooKeeperConnectString());

        executor = Executors.newCachedThreadPool();
View Full Code Here

    };

    @Test(timeout=60000)
    public void testProblemProcessor() throws Exception {
        ServerConfiguration conf = new ServerConfiguration();
        conf.setAllowLoopback(true);
        int port = PortManager.nextFreePort();
        conf.setBookiePort(port);
        NIOServerFactory factory = new NIOServerFactory(conf, problemProcessor);
        factory.start();
        Socket s = new Socket("127.0.0.1", port);
        s.setSoTimeout(5000);
        try {
View Full Code Here

        // kill first bookie server to start a fake one to simulate a slow bookie
        // and failed to add entry on crash
        // until write succeed
        InetSocketAddress host = beforelh.getLedgerMetadata().currentEnsemble.get(slowBookieIdx);
        ServerConfiguration conf = killBookie(host);

        Bookie fakeBookie = new Bookie(conf) {
            @Override
            public void addEntry(ByteBuffer entry, WriteCallback cb, Object ctx, byte[] masterKey)
                    throws IOException, BookieException {
View Full Code Here

        for (int i = 0; i < (numBookies*3)+1; i++) {
            lhbefore.addEntry("data".getBytes());
        }

        // Add a dead bookie to the cluster
        ServerConfiguration conf = newServerConfiguration();
        Bookie deadBookie1 = new Bookie(conf) {
            @Override
            public void recoveryAddEntry(ByteBuffer entry, WriteCallback cb, Object ctx, byte[] masterKey)
                    throws IOException, BookieException {
                // drop request to simulate a slow and failed bookie
                throw new IOException("Couldn't write for some reason");
            }
        };
        bsConfs.add(conf);
        bs.add(startBookie(conf, deadBookie1));

        // kill first bookie server
        InetSocketAddress bookie1 = lhbefore.getLedgerMetadata().currentEnsemble.get(0);
        ServerConfiguration conf1 = killBookie(bookie1);

        // Try to recover and fence the ledger after killing one bookie in the
        // ensemble in the ensemble, and another bookie is available in zk, but not writtable
        try {
            bkc.openLedger(lhbefore.getId(), digestType, "".getBytes());
            fail("Shouldn't be able to open ledger, there should be entries missing");
        } catch (BKException.BKLedgerRecoveryException e) {
            // expected
        }

        // restart the first server, kill the second
        bsConfs.add(conf1);
        bs.add(startBookie(conf1));
        InetSocketAddress bookie2 = lhbefore.getLedgerMetadata().currentEnsemble.get(1);
        ServerConfiguration conf2 = killBookie(bookie2);

        // using async, because this could trigger an assertion
        final AtomicInteger returnCode = new AtomicInteger(0);
        final CountDownLatch openLatch = new CountDownLatch(1);
        bkc.asyncOpenLedger(lhbefore.getId(), digestType, "".getBytes(),
View Full Code Here

        for (int i = 0; i < (numBookies*3)+1; i++) {
            lhbefore.addEntry("data".getBytes());
        }

        // Add a dead bookie to the cluster
        ServerConfiguration conf = newServerConfiguration();
        Bookie deadBookie1 = new Bookie(conf) {
            @Override
            public void recoveryAddEntry(ByteBuffer entry, WriteCallback cb, Object ctx, byte[] masterKey)
                    throws IOException, BookieException {
                // drop request to simulate a slow and failed bookie
                throw new IOException("Couldn't write for some reason");
            }
        };
        bsConfs.add(conf);
        bs.add(startBookie(conf, deadBookie1));

        // kill first bookie server
        InetSocketAddress bookie1 = lhbefore.getLedgerMetadata().currentEnsemble.get(0);
        ServerConfiguration conf1 = killBookie(bookie1);

        // Try to recover and fence the ledger after killing one bookie in the
        // ensemble in the ensemble, and another bookie is available in zk but not writtable
        try {
            bkc.openLedger(lhbefore.getId(), digestType, "".getBytes());
View Full Code Here

        if (numPendingAdds.get() > 0) {
            fail("Failed to add " + numEntries + " to ledger handle " + lh.getId());
        }
        // kill first 2 bookies to replace bookies
        InetSocketAddress bookie1 = lh.getLedgerMetadata().currentEnsemble.get(0);
        ServerConfiguration conf1 = killBookie(bookie1);
        InetSocketAddress bookie2 = lh.getLedgerMetadata().currentEnsemble.get(1);
        ServerConfiguration conf2 = killBookie(bookie2);

        // replace these two bookies
        startDeadBookie(conf1);
        startDeadBookie(conf2);
        // kick in two brand new bookies
View Full Code Here

    @Before
    @Override
    public void setUp() throws Exception {
        super.setUp();

        ServerConfiguration conf = new ServerConfiguration(bsConfs.get(0));
        conf.setAllowLoopback(true);
        conf.setAuditorPeriodicBookieCheckInterval(CHECK_INTERVAL);
        String addr = StringUtils.addrToString(bs.get(0).getLocalAddress());

        ZooKeeperWatcherBase w = new ZooKeeperWatcherBase(10000);
        auditorZookeeper = ZkUtils.createConnectedZookeeperClient(
                zkUtil.getZooKeeperConnectString(), w);
View Full Code Here

TOP

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

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.