Esempio n. 1
0
 protected void startBookieServer() throws Exception {
   int port = PortManager.nextFreePort();
   File tmpDir =
       org.apache.hedwig.util.FileUtils.createTempDirectory(getClass().getName() + port, "test");
   org.apache.bookkeeper.conf.ServerConfiguration conf =
       newServerConfiguration(
           port, zkUtil.getZooKeeperConnectString(), tmpDir, new File[] {tmpDir});
   conf.setAllowLoopback(true);
   bks.add(startBookie(conf));
   bkConfs.add(conf);
 }
Esempio n. 2
0
    protected org.apache.bookkeeper.proto.BookieServer startBookie(
        org.apache.bookkeeper.conf.ServerConfiguration conf) throws Exception {
      org.apache.bookkeeper.proto.BookieServer server =
          new org.apache.bookkeeper.proto.BookieServer(conf);
      server.start();

      int port = conf.getBookiePort();
      while (zkUtil
              .getZooKeeperClient()
              .exists(
                  "/ledgers/available/" + InetAddress.getLocalHost().getHostAddress() + ":" + port,
                  false)
          == null) {
        Thread.sleep(500);
      }
      return server;
    }
Esempio n. 3
0
 protected org.apache.bookkeeper.conf.ServerConfiguration newServerConfiguration(
     int port, String zkServers, File journalDir, File[] ledgerDirs) {
   org.apache.bookkeeper.conf.ServerConfiguration conf =
       new org.apache.bookkeeper.conf.ServerConfiguration();
   conf.setAllowLoopback(true);
   conf.setBookiePort(port);
   conf.setZkServers(zkServers);
   conf.setJournalDirName(journalDir.getPath());
   String[] ledgerDirNames = new String[ledgerDirs.length];
   for (int i = 0; i < ledgerDirs.length; i++) {
     ledgerDirNames[i] = ledgerDirs[i].getPath();
   }
   conf.setLedgerDirNames(ledgerDirNames);
   return conf;
 }