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


Java ClientConfiguration.setReadEntryTimeout方法代码示例

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


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

示例1: BookKeeperJournalManager

import org.apache.bookkeeper.conf.ClientConfiguration; //导入方法依赖的package包/类
/**
 * Construct a Bookkeeper journal manager.
 */
public BookKeeperJournalManager(Configuration conf, URI uri,
    NamespaceInfo nsInfo) throws IOException {
  this.conf = conf;
  this.nsInfo = nsInfo;

  String zkConnect = uri.getAuthority().replace(";", ",");
  basePath = uri.getPath();
  ensembleSize = conf.getInt(BKJM_BOOKKEEPER_ENSEMBLE_SIZE,
                             BKJM_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT);
  quorumSize = conf.getInt(BKJM_BOOKKEEPER_QUORUM_SIZE,
                           BKJM_BOOKKEEPER_QUORUM_SIZE_DEFAULT);
  ackQuorumSize = conf.getInt(BKJM_BOOKKEEPER_ACK_QUORUM_SIZE, quorumSize);
  addEntryTimeout = conf.getInt(BKJM_BOOKKEEPER_ADD_ENTRY_TIMEOUT_SEC,
                           BKJM_BOOKKEEPER_ADD_ENTRY_TIMEOUT_DEFAULT);
  speculativeReadTimeout = conf.getInt(
                           BKJM_BOOKKEEPER_SPECULATIVE_READ_TIMEOUT_MS,
                           BKJM_BOOKKEEPER_SPECULATIVE_READ_TIMEOUT_DEFAULT);
  readEntryTimeout = conf.getInt(BKJM_BOOKKEEPER_READ_ENTRY_TIMEOUT_SEC,
                           BKJM_BOOKKEEPER_READ_ENTRY_TIMEOUT_DEFAULT);

  ledgerPath = basePath + "/ledgers";
  String maxTxIdPath = basePath + "/maxtxid";
  String currentInprogressNodePath = basePath + "/CurrentInprogress";
  versionPath = basePath + "/version";
  digestpw = conf.get(BKJM_BOOKKEEPER_DIGEST_PW,
                      BKJM_BOOKKEEPER_DIGEST_PW_DEFAULT);

  try {
    zkConnectLatch = new CountDownLatch(1);
    int bkjmZKSessionTimeout = conf.getInt(BKJM_ZK_SESSION_TIMEOUT,
        BKJM_ZK_SESSION_TIMEOUT_DEFAULT);
    zkc = new ZooKeeper(zkConnect, bkjmZKSessionTimeout,
        new ZkConnectionWatcher());
    // Configured zk session timeout + some extra grace period (here
    // BKJM_ZK_SESSION_TIMEOUT_DEFAULT used as grace period)
    int zkConnectionLatchTimeout = bkjmZKSessionTimeout
        + BKJM_ZK_SESSION_TIMEOUT_DEFAULT;
    if (!zkConnectLatch
        .await(zkConnectionLatchTimeout, TimeUnit.MILLISECONDS)) {
      throw new IOException("Error connecting to zookeeper");
    }

    prepareBookKeeperEnv();
    ClientConfiguration clientConf = new ClientConfiguration();
    clientConf.setSpeculativeReadTimeout(speculativeReadTimeout);
    clientConf.setReadEntryTimeout(readEntryTimeout);
    clientConf.setAddEntryTimeout(addEntryTimeout);
    bkc = new BookKeeper(clientConf, zkc);
  } catch (KeeperException e) {
    throw new IOException("Error initializing zk", e);
  } catch (InterruptedException ie) {
    Thread.currentThread().interrupt();
    throw new IOException("Interrupted while initializing bk journal manager",
                          ie);
  }

  ci = new CurrentInprogress(zkc, currentInprogressNodePath);
  maxTxId = new MaxTxId(zkc, maxTxIdPath);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:63,代码来源:BookKeeperJournalManager.java

示例2: create

import org.apache.bookkeeper.conf.ClientConfiguration; //导入方法依赖的package包/类
@Override
public BookKeeper create(ServiceConfiguration conf, ZooKeeper zkClient) throws IOException {
    ClientConfiguration bkConf = new ClientConfiguration();

    if (conf.getBookkeeperClientAuthenticationPlugin() != null
            && conf.getBookkeeperClientAuthenticationPlugin().trim().length() > 0) {
        bkConf.setClientAuthProviderFactoryClass(conf.getBookkeeperClientAuthenticationPlugin());
        bkConf.setProperty(conf.getBookkeeperClientAuthenticationParametersName(),
                conf.getBookkeeperClientAuthenticationParameters());
    }

    bkConf.setThrottleValue(0);
    bkConf.setAddEntryTimeout((int) conf.getBookkeeperClientTimeoutInSeconds());
    bkConf.setReadEntryTimeout((int) conf.getBookkeeperClientTimeoutInSeconds());
    bkConf.setSpeculativeReadTimeout(conf.getBookkeeperClientSpeculativeReadTimeoutInMillis());
    bkConf.setNumChannelsPerBookie(16);
    bkConf.setUseV2WireProtocol(true);
    bkConf.setLedgerManagerFactoryClassName(HierarchicalLedgerManagerFactory.class.getName());
    if (conf.isBookkeeperClientHealthCheckEnabled()) {
        bkConf.enableBookieHealthCheck();
        bkConf.setBookieHealthCheckInterval(conf.getBookkeeperHealthCheckIntervalSec(), TimeUnit.SECONDS);
        bkConf.setBookieErrorThresholdPerInterval(conf.getBookkeeperClientHealthCheckErrorThresholdPerInterval());
        bkConf.setBookieQuarantineTime((int) conf.getBookkeeperClientHealthCheckQuarantineTimeInSeconds(),
                TimeUnit.SECONDS);
    }

    if (conf.isBookkeeperClientRackawarePolicyEnabled()) {
        bkConf.setEnsemblePlacementPolicy(RackawareEnsemblePlacementPolicy.class);
        bkConf.setProperty(RackawareEnsemblePlacementPolicy.REPP_DNS_RESOLVER_CLASS,
                ZkBookieRackAffinityMapping.class.getName());
        this.rackawarePolicyZkCache = new ZooKeeperCache(zkClient) {
        };
        bkConf.setProperty(ZooKeeperCache.ZK_CACHE_INSTANCE, this.rackawarePolicyZkCache);
    }

    if (conf.getBookkeeperClientIsolationGroups() != null && !conf.getBookkeeperClientIsolationGroups().isEmpty()) {
        bkConf.setEnsemblePlacementPolicy(ZkIsolatedBookieEnsemblePlacementPolicy.class);
        bkConf.setProperty(ZkIsolatedBookieEnsemblePlacementPolicy.ISOLATION_BOOKIE_GROUPS,
                conf.getBookkeeperClientIsolationGroups());
        if (bkConf.getProperty(ZooKeeperCache.ZK_CACHE_INSTANCE) == null) {
            this.clientIsolationZkCache = new ZooKeeperCache(zkClient) {
            };
            bkConf.setProperty(ZooKeeperCache.ZK_CACHE_INSTANCE, this.clientIsolationZkCache);
        }
    }

    try {
        return new BookKeeper(bkConf, zkClient);
    } catch (InterruptedException | KeeperException e) {
        throw new IOException(e);
    }
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:53,代码来源:BookKeeperClientFactoryImpl.java


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