Package org.apache.bookkeeper.proto

Examples of org.apache.bookkeeper.proto.BookieServer$DeathWatcher


        f.delete();
        f.mkdir();

        ServerConfiguration conf = newServerConfiguration(port, HOSTPORT, f, new File[] { f });

        BookieServer server = new BookieServer(conf);
        server.start();
        bs.add(server);

        while(bkc.getZkHandle().exists("/ledgers/available/" + InetAddress.getLocalHost().getHostAddress() + ":" + port, false) == null) {
            Thread.sleep(500);
        }
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

    }
   
    public void tearDownOneBookieServer() throws Exception {
        Random r = new Random();
        int bi = r.nextInt(bookiesList.size());
        BookieServer bs = bookiesList.get(bi);
        try {
            bs.shutdown();
        } catch (InterruptedException e) {
            LOG.error("Error tearing down", e);
        }
        bookiesList.remove(bi);
    }
View Full Code Here

    public void startUpNewBookieServer() throws Exception {
        File tmpDir = FileUtils.createTempDirectory(
                PREFIX + (nextPort - initialPort), SUFFIX);
        ServerConfiguration conf = newServerConfiguration(
                nextPort++, hostPort, tmpDir, new File[] { tmpDir });
        BookieServer bs = new BookieServer(conf);
        bs.start();
        bookiesList.add(bs);
    }
View Full Code Here

                ServerConfiguration conf = newServerConfiguration(
                    initialPort + i, HOSTPORT, f, new File[] { f });
                bsConfs.add(conf);

                BookieServer server = new BookieServer(conf);
                server.start();
                bs.add(server);
            }

            baseClientConf.setZkServers("127.0.0.1");
            if (numBookies > 0) {
View Full Code Here

            throw e;
        }
    }

    public void killBookie(InetSocketAddress addr) throws InterruptedException {
        BookieServer toRemove = null;
        for (BookieServer server : bs) {
            if (server.getLocalAddress().equals(addr)) {
                server.shutdown();
                toRemove = server;
            }
View Full Code Here

        for (File f : tmpDirs) {
            ServerConfiguration conf = bsConfs.get(j);
            if (null != newConf) {
                conf.loadConf(newConf);
            }
            BookieServer server = new BookieServer(conf);
            server.start();
            bs.add(server);
            j++;
        }
    }
View Full Code Here

        super(0);
    }

    @Test
    public void runBookieServerZKExpireBehaviourTest() 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, HOSTPORT, 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

        // 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

TOP

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

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.