當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。