• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LocalBookKeeper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setupZooKeeper

import org.apache.bookkeeper.util.LocalBookKeeper; //导入依赖的package包/类
@BeforeClass
public static void setupZooKeeper() throws Exception {
  LOG.info("Starting ZK server");
  zkTmpDir = File.createTempFile("zookeeper", "test");
  zkTmpDir.delete();
  zkTmpDir.mkdir();
  try {
    zks = new ZooKeeperServer(zkTmpDir, zkTmpDir, ZooKeeperDefaultPort);
    serverFactory = new NIOServerCnxnFactory();
    serverFactory.configure(new InetSocketAddress(ZooKeeperDefaultPort), 10);
    serverFactory.startup(zks);
  } catch (Exception e) {
    LOG.error("Exception while instantiating ZooKeeper", e);
  }
  boolean b = LocalBookKeeper.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT);
  LOG.debug("ZooKeeper server up: " + b);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestCurrentInprogress.java


示例2: setupZooKeeper

import org.apache.bookkeeper.util.LocalBookKeeper; //导入依赖的package包/类
@BeforeClass
public static void setupZooKeeper() throws Exception {
  // create a ZooKeeper server(dataDir, dataLogDir, port)
  LOG.info("Starting ZK server");
  ZkTmpDir = File.createTempFile("zookeeper", "test");
  ZkTmpDir.delete();
  ZkTmpDir.mkdir();

  try {
    zks = new ZooKeeperServer(ZkTmpDir, ZkTmpDir, ZooKeeperDefaultPort);
    serverFactory = new NIOServerCnxnFactory();
    serverFactory.configure(new InetSocketAddress(ZooKeeperDefaultPort), 10);
    serverFactory.startup(zks);
  } catch (Exception e) {
    LOG.error("Exception while instantiating ZooKeeper", e);
  }

  boolean b = LocalBookKeeper.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT);
  LOG.debug("ZooKeeper server up: " + b);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestBookKeeperConfiguration.java


示例3: BKJMUtil

import org.apache.bookkeeper.util.LocalBookKeeper; //导入依赖的package包/类
BKJMUtil(final int numBookies) throws Exception {
  this.numBookies = numBookies;

  bkthread = new Thread() {
      public void run() {
        try {
          String[] args = new String[1];
          args[0] = String.valueOf(numBookies);
          LOG.info("Starting bk");
          LocalBookKeeper.main(args);
        } catch (InterruptedException e) {
          // go away quietly
        } catch (Exception e) {
          LOG.error("Error starting local bk", e);
        }
      }
    };
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:BKJMUtil.java


示例4: LocalDLMEmulator

import org.apache.bookkeeper.util.LocalBookKeeper; //导入依赖的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


示例5: start

import org.apache.bookkeeper.util.LocalBookKeeper; //导入依赖的package包/类
void start() throws Exception {
  bkthread.start();
  if (!LocalBookKeeper.waitForServerUp(zkEnsemble, 10000)) {
    throw new Exception("Error starting zookeeper/bookkeeper");
  }
  assertEquals("Not all bookies started",
               numBookies, checkBookiesUp(numBookies, 10));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:BKJMUtil.java


示例6: start

import org.apache.bookkeeper.util.LocalBookKeeper; //导入依赖的package包/类
public void start() throws Exception {
    bkStartupThread.start();
    if (!LocalBookKeeper.waitForServerUp(zkEnsemble, zkTimeoutSec*1000)) {
        throw new Exception("Error starting zookeeper/bookkeeper");
    }
    int bookiesUp = checkBookiesUp(numBookies, zkTimeoutSec);
    assert (numBookies == bookiesUp);
    // Provision "/messaging/distributedlog" namespace
    DLMetadata.create(new BKDLConfig(zkEnsemble, "/ledgers")).create(uri);
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:11,代码来源:LocalDLMEmulator.java


示例7: runZookeeperOnAnyPort

import org.apache.bookkeeper.util.LocalBookKeeper; //导入依赖的package包/类
/**
 * Try to start zookkeeper locally on any port beginning with some base port.
 * Dump some socket info when bind fails.
 */
public static Pair<ZooKeeperServerShim, Integer> runZookeeperOnAnyPort(int basePort, File zkDir) throws Exception {

    final int MAX_RETRIES = 20;
    final int MIN_PORT = 1025;
    final int MAX_PORT = 65535;
    ZooKeeperServerShim zks = null;
    int zkPort = basePort;
    boolean success = false;
    int retries = 0;

    while (!success) {
        try {
            LOG.info("zk trying to bind to port " + zkPort);
            zks = LocalBookKeeper.runZookeeper(1000, zkPort, zkDir);
            success = true;
        } catch (BindException be) {
            retries++;
            if (retries > MAX_RETRIES) {
                throw be;
            }
            zkPort++;
            if (zkPort > MAX_PORT) {
                zkPort = MIN_PORT;
            }
        }
    }

    return Pair.of(zks, zkPort);
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:34,代码来源:LocalDLMEmulator.java


示例8: DistributedLogCluster

import org.apache.bookkeeper.util.LocalBookKeeper; //导入依赖的package包/类
private DistributedLogCluster(DistributedLogConfiguration dlConf,
                              ServerConfiguration bkConf,
                              int numBookies,
                              boolean shouldStartZK,
                              String zkServers,
                              int zkPort,
                              boolean shouldStartProxy,
                              int proxyPort) throws Exception {
    this.dlConf = dlConf;
    if (shouldStartZK) {
        File zkTmpDir = IOUtils.createTempDir("zookeeper", "distrlog");
        tmpDirs.add(zkTmpDir);
        if (0 == zkPort) {
            Pair<ZooKeeperServerShim, Integer> serverAndPort = LocalDLMEmulator.runZookeeperOnAnyPort(zkTmpDir);
            this.zks = serverAndPort.getLeft();
            zkPort = serverAndPort.getRight();
        } else {
            this.zks = LocalBookKeeper.runZookeeper(1000, zkPort, zkTmpDir);
        }
    } else {
        this.zks = null;
    }
    this.dlmEmulator = LocalDLMEmulator.newBuilder()
            .numBookies(numBookies)
            .zkHost(zkServers)
            .zkPort(zkPort)
            .serverConf(bkConf)
            .shouldStartZK(false)
            .build();
    this.shouldStartProxy = shouldStartProxy;
    this.proxyPort = proxyPort;
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:33,代码来源:DistributedLogCluster.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ObjectNode类代码示例发布时间:2022-05-22
下一篇:
Java FileCallBack类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap