本文整理汇总了Java中org.apache.zookeeper.server.quorum.QuorumPeerConfig.isDistributed方法的典型用法代码示例。如果您正苦于以下问题:Java QuorumPeerConfig.isDistributed方法的具体用法?Java QuorumPeerConfig.isDistributed怎么用?Java QuorumPeerConfig.isDistributed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.zookeeper.server.quorum.QuorumPeerConfig
的用法示例。
在下文中一共展示了QuorumPeerConfig.isDistributed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runZKServer
import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //导入方法依赖的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: runFlinkZkQuorumPeer
import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //导入方法依赖的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);
}
}
示例3: runZKServer
import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //导入方法依赖的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);
}
}