本文整理汇总了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);
}
}