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


Java ZooKeeperServerMain.runFromConfig方法代码示例

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


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

示例1: runZKServer

import org.apache.zookeeper.server.ZooKeeperServerMain; //导入方法依赖的package包/类
private static void runZKServer(QuorumPeerConfig zkConfig) throws UnknownHostException, IOException {
  if (zkConfig.isDistributed()) {
    QuorumPeerMain qp = new QuorumPeerMain();
    qp.runFromConfig(zkConfig);
  } else {
    ZooKeeperServerMain zk = new ZooKeeperServerMain();
    ServerConfig serverConfig = new ServerConfig();
    serverConfig.readFrom(zkConfig);
    zk.runFromConfig(serverConfig);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:HQuorumPeer.java

示例2: run

import org.apache.zookeeper.server.ZooKeeperServerMain; //导入方法依赖的package包/类
public void run() throws Exception {
    pidFileLocker.lock();

    server = new ZooKeeperServerMain();
    QuorumPeerConfig qp = new QuorumPeerConfig();
    qp.parseProperties(configuration);
    ServerConfig sc = new ServerConfig();
    sc.readFrom(qp);
    server.runFromConfig(sc);

}
 
开发者ID:diennea,项目名称:herddb,代码行数:12,代码来源:ZooKeeperMainWrapper.java

示例3: runFlinkZkQuorumPeer

import org.apache.zookeeper.server.ZooKeeperServerMain; //导入方法依赖的package包/类
/**
 * Runs a ZooKeeper {@link QuorumPeer} if further peers are configured or a single
 * {@link ZooKeeperServer} if no further peers are configured.
 *
 * @param zkConfigFile ZooKeeper config file 'zoo.cfg'
 * @param peerId       ID for the 'myid' file
 */
public static void runFlinkZkQuorumPeer(String zkConfigFile, int peerId) throws Exception {

	Properties zkProps = new Properties();

	try (InputStream inStream = new FileInputStream(new File(zkConfigFile))) {
		zkProps.load(inStream);
	}

	LOG.info("Configuration: " + zkProps);

	// Set defaults for required properties
	setRequiredProperties(zkProps);

	// Write peer id to myid file
	writeMyIdToDataDir(zkProps, peerId);

	// The myid file needs to be written before creating the instance. Otherwise, this
	// will fail.
	QuorumPeerConfig conf = new QuorumPeerConfig();
	conf.parseProperties(zkProps);

	if (conf.isDistributed()) {
		// Run quorum peer
		LOG.info("Running distributed ZooKeeper quorum peer (total peers: {}).",
				conf.getServers().size());

		QuorumPeerMain qp = new QuorumPeerMain();
		qp.runFromConfig(conf);
	}
	else {
		// Run standalone
		LOG.info("Running standalone ZooKeeper quorum peer.");

		ZooKeeperServerMain zk = new ZooKeeperServerMain();
		ServerConfig sc = new ServerConfig();
		sc.readFrom(conf);
		zk.runFromConfig(sc);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:47,代码来源:FlinkZooKeeperQuorumPeer.java

示例4: start

import org.apache.zookeeper.server.ZooKeeperServerMain; //导入方法依赖的package包/类
public void start() throws Exception {

        mainsingle = new ZooKeeperServerMain();

        thread = new Thread("zkservermainrunner") {
            @Override
            public void run() {
                try {
                    ServerConfig cc = new ServerConfig();
                    cc.readFrom(config);
                    mainsingle.runFromConfig(cc);
                    System.out.println("ZK server died");
                } catch (Throwable t) {
                    t.printStackTrace();
                }
            }
        };
        thread.start();

        this.cnxnFactory = getServerConnectionFactory();
        if (cnxnFactory != null) {
            final ZooKeeperServer zkServer = getZooKeeperServer(cnxnFactory);
            if (zkServer != null) {
                synchronized (zkServer) {
                    if (!zkServer.isRunning()) {
                        zkServer.wait();
                    }
                }
            }
        }

    }
 
开发者ID:diennea,项目名称:majordodo,代码行数:33,代码来源:TestingZookeeperServerEmbedded.java

示例5: runZKServer

import org.apache.zookeeper.server.ZooKeeperServerMain; //导入方法依赖的package包/类
private static void runZKServer(QuorumPeerConfig zkConfig)
        throws UnknownHostException, IOException {
  if (zkConfig.isDistributed()) {
    QuorumPeerMain qp = new QuorumPeerMain();
    qp.runFromConfig(zkConfig);
  } else {
    ZooKeeperServerMain zk = new ZooKeeperServerMain();
    ServerConfig serverConfig = new ServerConfig();
    serverConfig.readFrom(zkConfig);
    zk.runFromConfig(serverConfig);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:13,代码来源:HQuorumPeer.java


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