当前位置: 首页>>代码示例>>Java>>正文


Java ServerConfiguration类代码示例

本文整理汇总了Java中org.apache.bookkeeper.conf.ServerConfiguration的典型用法代码示例。如果您正苦于以下问题:Java ServerConfiguration类的具体用法?Java ServerConfiguration怎么用?Java ServerConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServerConfiguration类属于org.apache.bookkeeper.conf包,在下文中一共展示了ServerConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newBookie

import org.apache.bookkeeper.conf.ServerConfiguration; //导入依赖的package包/类
BookieServer newBookie() throws Exception {
  int port = nextPort++;
  ServerConfiguration bookieConf = new ServerConfiguration();
  bookieConf.setBookiePort(port);
  File tmpdir = File.createTempFile("bookie" + Integer.toString(port) + "_",
                                    "test");
  tmpdir.delete();
  tmpdir.mkdir();

  bookieConf.setZkServers(zkEnsemble);
  bookieConf.setJournalDirName(tmpdir.getPath());
  bookieConf.setLedgerDirNames(new String[] { tmpdir.getPath() });

  BookieServer b = new BookieServer(bookieConf);
  b.start();
  for (int i = 0; i < 10 && !b.isRunning(); i++) {
    Thread.sleep(10000);
  }
  if (!b.isRunning()) {
    throw new IOException("Bookie would not start");
  }
  return b;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:BKJMUtil.java

示例2: startBookie

import org.apache.bookkeeper.conf.ServerConfiguration; //导入依赖的package包/类
public void startBookie() throws Exception {
        ServerConfiguration conf = new ServerConfiguration();
        conf.setBookiePort(5621);
        conf.setUseHostNameAsBookieID(true);

        Path targetDir = path.resolve("bookie_data");
        conf.setZkServers("localhost:1282");
        conf.setLedgerDirNames(new String[]{targetDir.toAbsolutePath().toString()});
        conf.setJournalDirName(targetDir.toAbsolutePath().toString());        
        conf.setFlushInterval(10000);
        conf.setGcWaitTime(5);
        conf.setJournalFlushWhenQueueEmpty(true);
//        conf.setJournalBufferedEntriesThreshold(1);
        conf.setAutoRecoveryDaemonEnabled(false);
        conf.setEnableLocalTransport(true);

        conf.setAllowLoopback(true);
        conf.setProperty("journalMaxGroupWaitMSec", 10); // default 200ms            

        ClientConfiguration adminConf = new ClientConfiguration(conf);
        BookKeeperAdmin.format(adminConf, false, true);
        this.bookie = new BookieServer(conf);
        this.bookie.start();
    }
 
开发者ID:diennea,项目名称:herddb,代码行数:25,代码来源:ZKTestEnv.java

示例3: start

import org.apache.bookkeeper.conf.ServerConfiguration; //导入依赖的package包/类
public void start() throws Exception {
    LOG.debug("Local ZK/BK starting ...");
    ServerConfiguration conf = new ServerConfiguration();
    conf.setLedgerManagerFactoryClassName("org.apache.bookkeeper.meta.HierarchicalLedgerManagerFactory");
    // Use minimal configuration requiring less memory for unit tests
    conf.setLedgerStorageClass(DbLedgerStorage.class.getName());
    conf.setProperty("dbStorage_writeCacheMaxSizeMb", 2);
    conf.setProperty("dbStorage_readAheadCacheMaxSizeMb", 1);
    conf.setProperty("dbStorage_rocksDB_writeBufferSizeMB", 1);
    conf.setProperty("dbStorage_rocksDB_blockCacheSize", 1024 * 1024);
    conf.setFlushInterval(60000);
    conf.setProperty("journalMaxGroupWaitMSec", 0L);

    runZookeeper(1000);
    initializeZookeper();
    runBookies(conf);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:18,代码来源:LocalBookkeeperEnsemble.java

示例4: newServerConfiguration

import org.apache.bookkeeper.conf.ServerConfiguration; //导入依赖的package包/类
protected ServerConfiguration newServerConfiguration(int port, String zkServers, File journalDir,
        File[] ledgerDirs) {
    ServerConfiguration conf = new ServerConfiguration(baseConf);
    conf.setBookiePort(port);
    conf.setZkServers(zkServers);
    conf.setJournalDirName(journalDir.getPath());
    conf.setAllowLoopback(true);
    conf.setFlushInterval(60 * 1000);
    conf.setGcWaitTime(60 * 1000);
    String[] ledgerDirNames = new String[ledgerDirs.length];
    for (int i = 0; i < ledgerDirs.length; i++) {
        ledgerDirNames[i] = ledgerDirs[i].getPath();
    }
    conf.setLedgerDirNames(ledgerDirNames);
    conf.setLedgerStorageClass("org.apache.bookkeeper.bookie.storage.ldb.DbLedgerStorage");
    return conf;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:18,代码来源:BookKeeperClusterTestCase.java

示例5: killBookie

import org.apache.bookkeeper.conf.ServerConfiguration; //导入依赖的package包/类
/**
 * Kill a bookie by its socket address. Also, stops the autorecovery process for the corresponding bookie server, if
 * isAutoRecoveryEnabled is true.
 *
 * @param addr
 *            Socket Address
 * @return the configuration of killed bookie
 * @throws InterruptedException
 */
public ServerConfiguration killBookie(InetSocketAddress addr) throws Exception {
    BookieServer toRemove = null;
    int toRemoveIndex = 0;
    for (BookieServer server : bs) {
        if (server.getLocalAddress().equals(addr)) {
            server.shutdown();
            toRemove = server;
            break;
        }
        ++toRemoveIndex;
    }
    if (toRemove != null) {
        stopAutoRecoveryService(toRemove);
        bs.remove(toRemove);
        return bsConfs.remove(toRemoveIndex);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:28,代码来源:BookKeeperClusterTestCase.java

示例6: restartBookies

import org.apache.bookkeeper.conf.ServerConfiguration; //导入依赖的package包/类
/**
 * Restart bookie servers using new configuration settings. Also restart the respective auto recovery process, if
 * isAutoRecoveryEnabled is true.
 *
 * @param newConf
 *            New Configuration Settings
 * @throws InterruptedException
 * @throws IOException
 * @throws KeeperException
 * @throws BookieException
 */
public void restartBookies(ServerConfiguration newConf) throws Exception {
    // shut down bookie server
    for (BookieServer server : bs) {
        server.shutdown();
        stopAutoRecoveryService(server);
    }
    bs.clear();
    Thread.sleep(1000);
    // restart them to ensure we can't

    List<ServerConfiguration> bsConfsCopy = new ArrayList<ServerConfiguration>(bsConfs);
    bsConfs.clear();
    for (ServerConfiguration conf : bsConfsCopy) {
        if (null != newConf) {
            conf.loadConf(newConf);
        }
        startBookie(conf);
    }
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:31,代码来源:BookKeeperClusterTestCase.java

示例7: startBookie

import org.apache.bookkeeper.conf.ServerConfiguration; //导入依赖的package包/类
/**
 * Helper method to startup a bookie server using a configuration object. Also, starts the auto recovery process if
 * isAutoRecoveryEnabled is true.
 *
 * @param conf
 *            Server Configuration Object
 *
 */
protected BookieServer startBookie(ServerConfiguration conf) throws Exception {
    BookieServer server = new BookieServer(conf);
    bsConfs.add(conf);
    bs.add(server);

    server.start();

    if (bkc == null) {
        bkc = new BookKeeperTestClient(baseClientConf);
    }

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

    bkc.readBookiesBlocking();
    LOG.info("New bookie on port " + port + " has been created.");

    return server;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:31,代码来源:BookKeeperClusterTestCase.java

示例8: LocalDLMEmulator

import org.apache.bookkeeper.conf.ServerConfiguration; //导入依赖的package包/类
private LocalDLMEmulator(final int numBookies, final boolean shouldStartZK, final String zkHost, final int zkPort, final int initialBookiePort, final int zkTimeoutSec, final ServerConfiguration serverConf) throws Exception {
    this.numBookies = numBookies;
    this.zkHost = zkHost;
    this.zkPort = zkPort;
    this.zkEnsemble = zkHost + ":" + zkPort;
    this.uri = URI.create("distributedlog://" + zkEnsemble + DLOG_NAMESPACE);
    this.zkTimeoutSec = zkTimeoutSec;
    this.bkStartupThread = new Thread() {
        public void run() {
            try {
                LOG.info("Starting {} bookies : allowLoopback = {}", numBookies, serverConf.getAllowLoopback());
                LocalBookKeeper.startLocalBookies(zkHost, zkPort, numBookies, shouldStartZK, initialBookiePort, serverConf);
                LOG.info("{} bookies are started.");
            } catch (InterruptedException e) {
                // go away quietly
            } catch (Exception e) {
                LOG.error("Error starting local bk", e);
            }
        }
    };
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:22,代码来源:LocalDLMEmulator.java

示例9: EmbeddedBookie

import org.apache.bookkeeper.conf.ServerConfiguration; //导入依赖的package包/类
/**
 * Create an empty data directory for the Bookie server and configure
 * the Bookie server.
 * @param baseConf  Base Bookie server configuration
 * @param zkConnect ZooKeeper quorum specification (e.g., "host:port" or a
 *                  list of "host:port" pairs)
 * @param bookieId Unique identifier for this bookie
 * @throws IOException If unable to create the data directory.
 */
EmbeddedBookie(ServerConfiguration baseConf, String zkConnect, int bookieId)
    throws IOException {
  this.bookieId = bookieId;
  File bkTmpDir = new File(TEST_DIR) ;
  bkTmpDir.mkdirs();
  tmpDir = new File(BK_BOOKIE_DATA_DIR_PREFIX + bookieId);
  FileUtil.fullyDelete(tmpDir);
  if (!tmpDir.mkdirs()) {
    throw new IOException("Unable to create bookie dir " + tmpDir);
  }
  bookieConf = new ServerConfiguration(baseConf);
  bookieConf.setBookiePort(MiniDFSCluster.getFreePort());
  bookieConf.setZkServers(zkConnect);
  bookieConf.setJournalDirName(tmpDir.getPath());
  bookieConf.setLedgerDirNames(new String[] { tmpDir.getPath() });
  bookieConf.setLogger(LogFactory.getLog(this.getClass().toString()));
  bookieRef = new AtomicReference<BookieServer>(null);
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:28,代码来源:MiniBookKeeperCluster.java

示例10: startBookie

import org.apache.bookkeeper.conf.ServerConfiguration; //导入依赖的package包/类
public void startBookie() throws Exception {
        ServerConfiguration conf = new ServerConfiguration();
        conf.setBookiePort(5621);
        conf.setUseHostNameAsBookieID(true);

        Path targetDir = path.resolve("bookie_data");
        conf.setZkServers("localhost:1282");
        conf.setLedgerDirNames(new String[]{targetDir.toAbsolutePath().toString()});
        conf.setJournalDirName(targetDir.toAbsolutePath().toString());
        conf.setFlushInterval(1000);
        conf.setJournalFlushWhenQueueEmpty(true);
        conf.setGcWaitTime(10);
        conf.setAutoRecoveryDaemonEnabled(false);
        
        // in unit tests we do not need real network for bookies
        conf.setEnableLocalTransport(true);
//        conf.setDisableServerSocketBind(true);

        conf.setAllowLoopback(true);

        ClientConfiguration adminConf = new ClientConfiguration(conf);
        BookKeeperAdmin.format(adminConf, false, true);
        this.bookie = new BookieServer(conf);
        this.bookie.start();
    }
 
开发者ID:diennea,项目名称:majordodo,代码行数:26,代码来源:ZKTestEnv.java

示例11: startBookie

import org.apache.bookkeeper.conf.ServerConfiguration; //导入依赖的package包/类
public void startBookie() throws Exception {
    ServerConfiguration conf = new ServerConfiguration();
    conf.setBookiePort(5621);
    conf.setUseHostNameAsBookieID(true);

    Path targetDir = path.resolve("bookie_data");
    conf.setZkServers("localhost:1282");
    conf.setLedgerDirNames(new String[]{targetDir.toAbsolutePath().toString()});
    conf.setJournalDirName(targetDir.toAbsolutePath().toString());
    conf.setFlushInterval(1000);
    conf.setAutoRecoveryDaemonEnabled(false);

    conf.setAllowLoopback(true);

    ClientConfiguration adminConf = new ClientConfiguration(conf);
    BookKeeperAdmin.format(adminConf, false, true);
    this.bookie = new BookieServer(conf);
    this.bookie.start();
}
 
开发者ID:diennea,项目名称:majordodo,代码行数:20,代码来源:ZKTestEnv.java

示例12: startBookie

import org.apache.bookkeeper.conf.ServerConfiguration; //导入依赖的package包/类
public void startBookie(boolean format) throws Exception {
        if (bookie != null) {
            throw new Exception("bookie already started");
        }
        ServerConfiguration conf = new ServerConfiguration();
        conf.setBookiePort(5621);
        conf.setUseHostNameAsBookieID(true);

        Path targetDir = path.resolve("bookie_data");
        conf.setZkServers("localhost:1282");
        conf.setLedgerDirNames(new String[]{targetDir.toAbsolutePath().toString()});
        conf.setJournalDirName(targetDir.toAbsolutePath().toString());
        conf.setFlushInterval(10000);
        conf.setGcWaitTime(5);
        conf.setJournalFlushWhenQueueEmpty(true);
//        conf.setJournalBufferedEntriesThreshold(1);
        conf.setAutoRecoveryDaemonEnabled(false);
        conf.setEnableLocalTransport(true);

        conf.setAllowLoopback(true);
        conf.setProperty("journalMaxGroupWaitMSec", 10); // default 200ms            

        if (format) {
            ClientConfiguration adminConf = new ClientConfiguration(conf);
            BookKeeperAdmin.format(adminConf, false, true);
        }
        this.bookie = new BookieServer(conf);
        this.bookie.start();
    }
 
开发者ID:diennea,项目名称:herddb,代码行数:30,代码来源:ZKTestEnv.java

示例13: startStandalone

import org.apache.bookkeeper.conf.ServerConfiguration; //导入依赖的package包/类
public void startStandalone() throws Exception {
    LOG.debug("Local ZK/BK starting ...");
    ServerConfiguration conf = new ServerConfiguration();
    conf.setLedgerManagerFactoryClassName("org.apache.bookkeeper.meta.HierarchicalLedgerManagerFactory");
    conf.setLedgerStorageClass(DbLedgerStorage.class.getName());
    conf.setProperty("dbStorage_writeCacheMaxSizeMb", 256);
    conf.setProperty("dbStorage_readAheadCacheMaxSizeMb", 64);
    conf.setFlushInterval(60000);
    conf.setProperty("journalMaxGroupWaitMSec", 1L);
    conf.setAdvertisedAddress("127.0.0.1");

    runZookeeper(1000);
    initializeZookeper();
    runBookies(conf);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:16,代码来源:LocalBookkeeperEnsemble.java

示例14: runBookie

import org.apache.bookkeeper.conf.ServerConfiguration; //导入依赖的package包/类
private BookieServer runBookie(int bkPort) throws Exception {
    // Attempt to reuse an existing data directory. This is useful in case of stops & restarts, when we want to perserve
    // already committed data.
    File tmpDir = this.tempDirs.getOrDefault(bkPort, null);
    if (tmpDir == null) {
        tmpDir = IOUtils.createTempDir("bookie_" + bkPort, "test");
        tmpDir.deleteOnExit();
        this.tempDirs.put(bkPort, tmpDir);
        log.info("Created " + tmpDir);
        if (!tmpDir.delete() || !tmpDir.mkdir()) {
            throw new IOException("Couldn't create bookie dir " + tmpDir);
        }
    }

    val conf = new ServerConfiguration();
    conf.setBookiePort(bkPort);
    conf.setZkServers(LOOPBACK_ADDRESS.getHostAddress() + ":" + this.zkPort);
    conf.setJournalDirName(tmpDir.getPath());
    conf.setLedgerDirNames(new String[]{tmpDir.getPath()});
    conf.setAllowLoopback(true);
    conf.setJournalAdaptiveGroupWrites(false);
    conf.setZkLedgersRootPath(ledgersPath);

    log.info("Starting Bookie at port " + bkPort);
    val bs = new BookieServer(conf);
    bs.start();
    return bs;
}
 
开发者ID:pravega,项目名称:pravega,代码行数:29,代码来源:BookKeeperServiceRunner.java

示例15: newBookie

import org.apache.bookkeeper.conf.ServerConfiguration; //导入依赖的package包/类
public BookieServer newBookie() throws Exception {
    ServerConfiguration bookieConf = new ServerConfiguration();
    bookieConf.setZkTimeout(zkTimeoutSec * 1000);
    bookieConf.setBookiePort(0);
    bookieConf.setAllowLoopback(true);
    File tmpdir = File.createTempFile("bookie" + UUID.randomUUID() + "_",
        "test");
    if (!tmpdir.delete()) {
        LOG.debug("Fail to delete tmpdir " + tmpdir);
    }
    if (!tmpdir.mkdir()) {
        throw new IOException("Fail to create tmpdir " + tmpdir);
    }
    tmpDirs.add(tmpdir);

    bookieConf.setZkServers(zkEnsemble);
    bookieConf.setJournalDirName(tmpdir.getPath());
    bookieConf.setLedgerDirNames(new String[]{tmpdir.getPath()});

    BookieServer b = new BookieServer(bookieConf);
    b.start();
    for (int i = 0; i < 10 && !b.isRunning(); i++) {
        Thread.sleep(10000);
    }
    if (!b.isRunning()) {
        throw new IOException("Bookie would not start");
    }
    return b;
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:30,代码来源:LocalDLMEmulator.java


注:本文中的org.apache.bookkeeper.conf.ServerConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。