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


Java QuorumPeerConfig.getDataDir方法代码示例

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


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

示例1: startFakeCluster

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //导入方法依赖的package包/类
/**
 * 启动伪集群模式
 * @param config
 * @throws IOException
 * @throws InterruptedException
 * @throws ConfigException
 */
public void startFakeCluster(QuorumPeerConfig config) throws IOException{

	ServerCnxnFactory cnxnFactory = new NIOServerCnxnFactory();
	cnxnFactory.configure(config.getClientPortAddress(), config.getMaxClientCnxns());

	QuorumPeer quorumPeer = new QuorumPeer(config.getServers(), config.getDataDir(), config.getDataLogDir(), config.getElectionAlg(), config.getServerId(), config.getTickTime(), config.getInitLimit(), config.getSyncLimit(), config.getQuorumListenOnAllIPs(), cnxnFactory, config.getQuorumVerifier());
	quorumPeer.setClientAddress(config.getClientPortAddress());
	quorumPeer.setTxnFactory(new FileTxnSnapLog(config.getDataLogDir(), config.getDataDir()));
	quorumPeer.setElectionType(config.getElectionAlg());
	quorumPeer.setMyid(config.getServerId());
	quorumPeer.setTickTime(config.getTickTime());
	quorumPeer.setMinSessionTimeout(config.getMinSessionTimeout());
	quorumPeer.setMaxSessionTimeout(config.getMaxSessionTimeout());
	quorumPeer.setInitLimit(config.getInitLimit());
	quorumPeer.setSyncLimit(config.getSyncLimit());
	quorumPeer.setQuorumVerifier(config.getQuorumVerifier(), true);
	quorumPeer.setCnxnFactory(cnxnFactory);
	quorumPeer.setZKDatabase(new ZKDatabase(quorumPeer.getTxnFactory()));
	quorumPeer.setLearnerType(config.getPeerType());
	quorumPeer.setSyncEnabled(config.getSyncEnabled());
	quorumPeer.setQuorumListenOnAllIPs(config.getQuorumListenOnAllIPs());

	quorumPeer.start();
	LOGGER.info("ZkServerCluster Started! ClientPortAddress={}", config.getClientPortAddress());
}
 
开发者ID:all4you,项目名称:redant,代码行数:33,代码来源:ZkServer.java

示例2: create

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //导入方法依赖的package包/类
ZookeeperLaucher create(Properties zkProperties) throws ConfigException, IOException {
  QuorumPeerConfig zkConfig = new QuorumPeerConfig();
  zkConfig.parseProperties(zkProperties);
  DatadirCleanupManager purgeMgr = new DatadirCleanupManager(
      zkConfig.getDataDir(), 
      zkConfig.getDataLogDir(), 
      zkConfig.getSnapRetainCount(), 
      zkConfig.getPurgeInterval());
  purgeMgr.start();

  if (zkConfig.getServers().size() > 0) {
    return new QuorumPeerMainExt(zkConfig);
  } else {
    logger.warn(
      "Either no config or no quorum defined in config, running in standalone mode"
    );
    // there is only server in the quorum -- run as standalone
    return new ZooKeeperServerMainExt(zkConfig) ;
  }
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:21,代码来源:ZookeeperClusterService.java

示例3: create

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //导入方法依赖的package包/类
ZookeeperLaucher create(Properties zkProperties) throws ConfigException, IOException {
  QuorumPeerConfig zkConfig = new QuorumPeerConfig();
  zkConfig.parseProperties(zkProperties);
  DatadirCleanupManager purgeMgr =
      new DatadirCleanupManager(zkConfig.getDataDir(), zkConfig.getDataLogDir(),
          zkConfig.getSnapRetainCount(), zkConfig.getPurgeInterval());
  purgeMgr.start();

  if (zkConfig.getServers().size() > 0) {
    return new QuorumPeerMainExt(zkConfig);
  } else {
    System.out
        .println("Either no config or no quorum defined in config, running in standalone mode");
    // there is only server in the quorum -- run as standalone
    return new ZooKeeperServerMainExt(zkConfig);
  }
}
 
开发者ID:DemandCube,项目名称:Scribengin,代码行数:18,代码来源:EmbededZKServer.java

示例4: readFrom

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //导入方法依赖的package包/类
/**
 * Read attributes from a QuorumPeerConfig.
 * @param config
 */
public void readFrom(QuorumPeerConfig config) {
  clientPortAddress = config.getClientPortAddress();
  dataDir = config.getDataDir();
  dataLogDir = config.getDataLogDir();
  tickTime = config.getTickTime();
  maxClientCnxns = config.getMaxClientCnxns();
  minSessionTimeout = config.getMinSessionTimeout();
  maxSessionTimeout = config.getMaxSessionTimeout();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:14,代码来源:ServerConfig.java

示例5: readFrom

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //导入方法依赖的package包/类
/**
 * Read attributes from a QuorumPeerConfig.
 * @param config
 */
public void readFrom(QuorumPeerConfig config) {
    clientPortAddress = config.getClientPortAddress();
    secureClientPortAddress = config.getSecureClientPortAddress();
    dataDir = config.getDataDir();
    dataLogDir = config.getDataLogDir();
    tickTime = config.getTickTime();
    maxClientCnxns = config.getMaxClientCnxns();
    minSessionTimeout = config.getMinSessionTimeout();
    maxSessionTimeout = config.getMaxSessionTimeout();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:15,代码来源:ServerConfig.java

示例6: start

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //导入方法依赖的package包/类
public void start() throws IOException, ConfigException, InterruptedException {
    log.info("Starting Zookeeper on port {}", port);

    Properties properties = new Properties();
    properties.setProperty("dataDir", getDataDir().getAbsolutePath());
    properties.setProperty("clientPort", Integer.toString(getPort()));

    QuorumPeerConfig quorumConfig = new QuorumPeerConfig();
    quorumConfig.parseProperties(properties);

    cleanupManager = new DatadirCleanupManager(quorumConfig.getDataDir(), quorumConfig.getDataLogDir(),
            quorumConfig.getSnapRetainCount(), quorumConfig.getPurgeInterval());
    cleanupManager.start();

    ServerConfig serverConfig = new ServerConfig();
    serverConfig.readFrom(quorumConfig);

    zkServer = new ZooKeeperServer();
    zkServer.setTickTime(serverConfig.getTickTime());
    zkServer.setMinSessionTimeout(serverConfig.getMinSessionTimeout());
    zkServer.setMaxSessionTimeout(serverConfig.getMaxSessionTimeout());

    transactionLog = new FileTxnSnapLog(new File(serverConfig.getDataLogDir().toString()),
            new File(serverConfig.getDataDir().toString()));
    zkServer.setTxnLogFactory(transactionLog);

    connectionFactory = ServerCnxnFactory.createFactory();
    connectionFactory.configure(serverConfig.getClientPortAddress(), serverConfig.getMaxClientCnxns());
    connectionFactory.startup(zkServer);
}
 
开发者ID:mosuka,项目名称:zookeeper-cli,代码行数:31,代码来源:LocalZooKeeperServer.java

示例7: start

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //导入方法依赖的package包/类
/**
 * Starts Zookeeper.
 *
 * @throws IOException if an error occurs during initialization
 * @throws InterruptedException if an error occurs during initialization
 */
public synchronized void start() throws IOException, InterruptedException {
  log.info("Starting Zookeeper on port {}", port);

  dataDir = Files.createTempDirectory(LocalZKServer.class.getSimpleName());
  dataDir.toFile().deleteOnExit();

  QuorumPeerConfig quorumConfig = new QuorumPeerConfig();
  try {
    quorumConfig.parseProperties(ConfigUtils.keyValueToProperties(
        "dataDir", dataDir.toAbsolutePath(),
        "clientPort", port
    ));
  } catch (QuorumPeerConfig.ConfigException e) {
    throw new IllegalArgumentException(e);
  }

  purgeManager =
      new DatadirCleanupManager(quorumConfig.getDataDir(),
                                quorumConfig.getDataLogDir(),
                                quorumConfig.getSnapRetainCount(),
                                quorumConfig.getPurgeInterval());
  purgeManager.start();

  ServerConfig serverConfig = new ServerConfig();
  serverConfig.readFrom(quorumConfig);

  zkServer = new ZooKeeperServer();
  zkServer.setTickTime(serverConfig.getTickTime());
  zkServer.setMinSessionTimeout(serverConfig.getMinSessionTimeout());
  zkServer.setMaxSessionTimeout(serverConfig.getMaxSessionTimeout());

  // These two ServerConfig methods returned String in 3.4.x and File in 3.5.x
  transactionLog = new FileTxnSnapLog(new File(serverConfig.getDataLogDir().toString()),
                                      new File(serverConfig.getDataDir().toString()));
  zkServer.setTxnLogFactory(transactionLog);

  connectionFactory = ServerCnxnFactory.createFactory();
  connectionFactory.configure(serverConfig.getClientPortAddress(), serverConfig.getMaxClientCnxns());
  connectionFactory.startup(zkServer);
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:47,代码来源:LocalZKServer.java


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