Package org.apache.bookkeeper.proto

Examples of org.apache.bookkeeper.proto.BookieServer


        // for the zkServers input parameter when constructing the BookieServer.
        ServerConfiguration conf = new ServerConfiguration();
        conf.setZkServers(null).setBookiePort(port)
            .setJournalDirName(tmpDir.getPath())
            .setLedgerDirNames(new String[] { tmpDir.getPath() });
        bs = new BookieServer(conf);
        bs.start();
        channelFactory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors
                .newCachedThreadPool());
        executor = new OrderedSafeExecutor(2);
    }
View Full Code Here


    }
   
    public void tearDownOneBookieServer() throws Exception {
        Random r = new Random();
        int bi = r.nextInt(bookiesList.size());
        BookieServer bs = bookiesList.get(bi);
        bs.shutdown();
        bookiesList.remove(bi);
        bkConfsList.remove(bi);
    }
View Full Code Here

     * @param conf
     *            Server Configuration Object
     *
     */
    private BookieServer startBookie(ServerConfiguration conf) throws Exception {
        BookieServer server = new TestBookieServer(conf);
        server.start();

        int port = conf.getBookiePort();
        while(zk.exists("/ledgers/available/" + InetAddress.getLocalHost().getHostAddress() + ":" + port, false) == null) {
            Thread.sleep(500);
        }
View Full Code Here

        super(0);
    }

    @Test
    public void testBookieServerZKExpireBehaviour() throws Exception {
        BookieServer server = null;
        try {
            File f = File.createTempFile("bookieserver", "test");
            f.delete();
            f.mkdir();

            HashSet<Thread> threadset = new HashSet<Thread>();
            int threadCount = Thread.activeCount();
            Thread threads[] = new Thread[threadCount*2];
            threadCount = Thread.enumerate(threads);
            for(int i = 0; i < threadCount; i++) {
                if (threads[i].getName().indexOf("SendThread") != -1) {
                    threadset.add(threads[i]);
                }
            }

            ServerConfiguration conf = newServerConfiguration(initialPort + 1,
                                                              zkUtil.getZooKeeperConnectString(), f, new File[] { f });
            server = new BookieServer(conf);
            server.start();

            Thread.sleep(10);
            Thread sendthread = null;
            threadCount = Thread.activeCount();
            threads = new Thread[threadCount*2];
            threadCount = Thread.enumerate(threads);
            for(int i = 0; i < threadCount; i++) {
                if (threads[i].getName().indexOf("SendThread") != -1
                        && !threadset.contains(threads[i])) {
                    sendthread = threads[i];
                    break;
                }
            }
            assertNotNull("Send thread not found", sendthread);

            sendthread.suspend();
            Thread.sleep(2*10000);
            sendthread.resume();

            // allow watcher thread to run
            Thread.sleep(3000);
            assertFalse("Bookie should have shutdown on losing zk session", server.isBookieRunning());
            assertFalse("Nio Server should have shutdown on losing zk session", server.isNioServerRunning());
            assertFalse("Bookie Server should have shutdown on losing zk session", server.isRunning());
        } finally {
            server.shutdown();
        }
    }
View Full Code Here

            byte[] data = (""+i).getBytes();
            lh.addEntry(data);
        }

        bs.get(3).shutdown();
        BookieServer server = new BookieServer(bsConfs.get(3));
        server.start();
        bs.set(3, server);

        assertEquals(numEntries - 1 , lh.getLastAddConfirmed());
        Enumeration<LedgerEntry> entries = lh.readEntries(0, lh.getLastAddConfirmed());
View Full Code Here

            bsConfs[i].setZkServers(InetAddress.getLocalHost().getHostAddress() + ":"
                                  + ZooKeeperDefaultPort);
            bsConfs[i].setJournalDirName(tmpDirs[i].getPath());
            bsConfs[i].setLedgerDirNames(new String[] { tmpDirs[i].getPath() });

            bs[i] = new BookieServer(bsConfs[i]);
            bs[i].start();
        }
    }
View Full Code Here

            byte[] data = (""+i).getBytes();
            lh.addEntry(data);
        }

        bs.get(3).shutdown();
        BookieServer server = new BookieServer(bsConfs.get(3));
        server.start();
        bs.set(3, server);

        assertEquals(numEntries - 1 , lh.getLastAddConfirmed());
        Enumeration<LedgerEntry> entries = lh.readEntries(0, lh.getLastAddConfirmed());
View Full Code Here

     *            Socket Address
     * @return the configuration of killed bookie
     * @throws InterruptedException
     */
    public ServerConfiguration killBookie(InetSocketAddress addr) throws InterruptedException {
        BookieServer toRemove = null;
        int toRemoveIndex = 0;
        for (BookieServer server : bs) {
            if (server.getLocalAddress().equals(addr)) {
                server.shutdown();
                toRemove = server;
View Full Code Here

     */
    public ServerConfiguration killBookie(int index) throws InterruptedException, IOException {
        if (index >= bs.size()) {
            throw new IOException("Bookie does not exist");
        }
        BookieServer server = bs.get(index);
        server.shutdown();
        stopAutoRecoveryService(server);
        bs.remove(server);
        return bsConfs.remove(index);
    }
View Full Code Here

     *
     */
    protected BookieServer startBookie(ServerConfiguration conf)
            throws IOException, InterruptedException, KeeperException,
            BookieException, UnavailableException, CompatibilityException {
        BookieServer server = new BookieServer(conf);
        server.start();

        int port = conf.getBookiePort();
        while(bkc.getZkHandle().exists("/ledgers/available/" + InetAddress.getLocalHost().getHostAddress() + ":" + port, false) == null) {
            Thread.sleep(500);
        }
View Full Code Here

TOP

Related Classes of org.apache.bookkeeper.proto.BookieServer

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.