本文整理汇总了Java中org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException方法的典型用法代码示例。如果您正苦于以下问题:Java QuorumPeerConfig.ConfigException方法的具体用法?Java QuorumPeerConfig.ConfigException怎么用?Java QuorumPeerConfig.ConfigException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.zookeeper.server.quorum.QuorumPeerConfig
的用法示例。
在下文中一共展示了QuorumPeerConfig.ConfigException方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //导入方法依赖的package包/类
/**
* Starts Zookeeper.
*
* @throws IOException if an error occurs during initialization
* @throws InterruptedException if an error occurs during initialization
*/
public synchronized void start() throws IOException, InterruptedException {
log.info("Starting Zookeeper on port {}", port);
dataDir = Files.createTempDirectory(LocalZKServer.class.getSimpleName());
dataDir.toFile().deleteOnExit();
QuorumPeerConfig quorumConfig = new QuorumPeerConfig();
try {
quorumConfig.parseProperties(ConfigUtils.keyValueToProperties(
"dataDir", dataDir.toAbsolutePath(),
"clientPort", port
));
} catch (QuorumPeerConfig.ConfigException e) {
throw new IllegalArgumentException(e);
}
purgeManager =
new DatadirCleanupManager(quorumConfig.getDataDir(),
quorumConfig.getDataLogDir(),
quorumConfig.getSnapRetainCount(),
quorumConfig.getPurgeInterval());
purgeManager.start();
ServerConfig serverConfig = new ServerConfig();
serverConfig.readFrom(quorumConfig);
zkServer = new ZooKeeperServer();
zkServer.setTickTime(serverConfig.getTickTime());
zkServer.setMinSessionTimeout(serverConfig.getMinSessionTimeout());
zkServer.setMaxSessionTimeout(serverConfig.getMaxSessionTimeout());
// These two ServerConfig methods returned String in 3.4.x and File in 3.5.x
transactionLog = new FileTxnSnapLog(new File(serverConfig.getDataLogDir().toString()),
new File(serverConfig.getDataDir().toString()));
zkServer.setTxnLogFactory(transactionLog);
connectionFactory = ServerCnxnFactory.createFactory();
connectionFactory.configure(serverConfig.getClientPortAddress(), serverConfig.getMaxClientCnxns());
connectionFactory.startup(zkServer);
}
示例2: initializeAndRun
import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //导入方法依赖的package包/类
@Override
public void initializeAndRun(String[] args)
throws QuorumPeerConfig.ConfigException, IOException {
super.initializeAndRun(args);
}
示例3: initializeAndRun
import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //导入方法依赖的package包/类
@Override
public void initializeAndRun(String[] args) throws QuorumPeerConfig.ConfigException, IOException {
super.initializeAndRun(args);
}
示例4: getPeerConfig
import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //导入方法依赖的package包/类
private QuorumPeerConfig getPeerConfig(Properties props) throws IOException, QuorumPeerConfig.ConfigException {
QuorumPeerConfig peerConfig = new QuorumPeerConfig();
peerConfig.parseProperties(props);
LOGGER.info("Created zookeeper peer configuration: {}", peerConfig);
return peerConfig;
}
示例5: runFromConfig
import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //导入方法依赖的package包/类
@Override
public void runFromConfig(final ServerConfig config) throws IOException {
ServerConfig newServerConfig = new ServerConfig() {
public void parse(String[] args) {
config.parse(args);
}
public void parse(String path)
throws QuorumPeerConfig.ConfigException {
config.parse(path);
}
public void readFrom(QuorumPeerConfig otherConfig) {
config.readFrom(otherConfig);
}
public InetSocketAddress getClientPortAddress() {
return config.getClientPortAddress();
}
public String getDataDir() {
return config.getDataDir();
}
public String getDataLogDir() {
return config.getDataLogDir();
}
public int getTickTime() {
return config.getTickTime();
}
public int getMaxClientCnxns() {
dataDir = getDataDir();
dataLogDir = getDataLogDir();
tickTime = getTickTime();
minSessionTimeout = getMinSessionTimeout();
maxSessionTimeout = getMaxSessionTimeout();
maxClientCnxns = 0;
return 0;
}
public int getMinSessionTimeout() {
return config.getMinSessionTimeout();
}
public int getMaxSessionTimeout() {
return config.getMaxSessionTimeout();
}
};
newServerConfig.getMaxClientCnxns();
super.runFromConfig(newServerConfig);
}