本文整理匯總了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);
}
}
示例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);
}
示例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);
}
}
示例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();
}
}
}
}
}
示例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);
}
}