本文整理汇总了Java中org.apache.zookeeper.server.ServerConfig.getDataLogDir方法的典型用法代码示例。如果您正苦于以下问题:Java ServerConfig.getDataLogDir方法的具体用法?Java ServerConfig.getDataLogDir怎么用?Java ServerConfig.getDataLogDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.zookeeper.server.ServerConfig
的用法示例。
在下文中一共展示了ServerConfig.getDataLogDir方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAndStartZooKeeper
import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
public static void createAndStartZooKeeper()
throws IOException, ConfigException, InterruptedException {
logStateChange("Creating zookeeper server");
AvatarShell.retrySleep = 1000;
ServerConfig zkConf = createZooKeeperConf();
zooKeeper = new ZooKeeperServer();
FileTxnSnapLog ftxn = new
FileTxnSnapLog(new File(zkConf.getDataLogDir()),
new File(zkConf.getDataDir()));
zooKeeper.setTxnLogFactory(ftxn);
zooKeeper.setTickTime(zkConf.getTickTime());
zooKeeper.setMinSessionTimeout(zkConf.getMinSessionTimeout());
zooKeeper.setMaxSessionTimeout(zkConf.getMaxSessionTimeout());
cnxnFactory = new NIOServerCnxnFactory();
cnxnFactory.configure(zkConf.getClientPortAddress(),
zkConf.getMaxClientCnxns());
cnxnFactory.startup(zooKeeper);
logStateChange("Creating zookeeper server - completed");
}
示例2: runFromConfig
import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
private void runFromConfig(ServerConfig config) throws IOException {
zkServer = new ZooKeeperServer();
try {
txnLog = new FileTxnSnapLog(new File(config.getDataLogDir()), new File(config.getDataDir()));
zkServer.setTxnLogFactory(txnLog);
zkServer.setTickTime(config.getTickTime());
zkServer.setMinSessionTimeout(config.getMinSessionTimeout());
zkServer.setMaxSessionTimeout(config.getMaxSessionTimeout());
cnxnFactory = ServerCnxnFactory.createFactory();
cnxnFactory.configure(config.getClientPortAddress(),
config.getMaxClientCnxns());
cnxnFactory.startup(zkServer);
} catch (InterruptedException e) {
if (zkServer.isRunning()) {
zkServer.shutdown();
}
}
}
示例3: createAndStartZooKeeper
import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
public static void createAndStartZooKeeper()
throws IOException, ConfigException, InterruptedException {
ServerConfig zkConf = createZooKeeperConf();
zooKeeper = new ZooKeeperServer();
FileTxnSnapLog ftxn = new
FileTxnSnapLog(new File(zkConf.getDataLogDir()),
new File(zkConf.getDataDir()));
zooKeeper.setTxnLogFactory(ftxn);
zooKeeper.setTickTime(zkConf.getTickTime());
zooKeeper.setMinSessionTimeout(zkConf.getMinSessionTimeout());
zooKeeper.setMaxSessionTimeout(zkConf.getMaxSessionTimeout());
cnxnFactory =
new NIOServerCnxn.Factory(zkConf.getClientPortAddress(),
zkConf.getMaxClientCnxns());
cnxnFactory.startup(zooKeeper);
}
示例4: runFromConfig
import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
/**
* Run from a ServerConfig.
* @param config ServerConfig to use.
* @throws IOException on any error
*/
public void runFromConfig(ServerConfig config) throws IOException {
LOG.info(">>>>> Starting Test ZooKeep Server...");
FileTxnSnapLog txnLog = null;
try {
// Note that this thread isn't going to be doing anything else,
// so rather than spawning another thread, we will just call
// run() in this thread.
// create a file logger url from the command line args
zkServer = new ZooKeeperServer();
txnLog = new FileTxnSnapLog(new File(config.getDataLogDir()), new File(
config.getDataDir()));
zkServer.setTxnLogFactory(txnLog);
zkServer.setTickTime(config.getTickTime());
zkServer.setMinSessionTimeout(config.getMinSessionTimeout());
zkServer.setMaxSessionTimeout(config.getMaxSessionTimeout());
cnxnFactory = ServerCnxnFactory.createFactory();
cnxnFactory.configure(config.getClientPortAddress(),
config.getMaxClientCnxns());
cnxnFactory.startup(zkServer);
LOG.info("<<<<< Test ZooKeep Server Started.");
// cnxnFactory.join();
// if (zkServer.isRunning()) {
// zkServer.shutdown();
// }
} catch (InterruptedException e) {
// warn, but generally this is ok
LOG.warn("Server interrupted", e);
} finally {
// if (txnLog != null) {
// txnLog.close();
// }
}
}
示例5: runFromConfig
import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
/**
* Run from a ServerConfig.
* @param config ServerConfig to use.
* @throws IOException If there is a low-level I/O error.
*/
public void runFromConfig(ServerConfig config) throws IOException {
log.info("Starting server");
try {
// Note that this thread isn't going to be doing anything else,
// so rather than spawning another thread, we will just call
// run() in this thread.
// create a file logger url from the command line args
zooKeeperServer = new ZooKeeperServer();
FileTxnSnapLog ftxn = new FileTxnSnapLog(new File(
config.getDataLogDir()), new File(config.getDataDir()));
zooKeeperServer.setTxnLogFactory(ftxn);
zooKeeperServer.setTickTime(config.getTickTime());
zooKeeperServer.setMinSessionTimeout(config.getMinSessionTimeout());
zooKeeperServer.setMaxSessionTimeout(config.getMaxSessionTimeout());
cnxnFactory = ServerCnxnFactory.createFactory();
cnxnFactory.configure(config.getClientPortAddress(),
config.getMaxClientCnxns());
cnxnFactory.startup(zooKeeperServer);
cnxnFactory.join();
// if (zooKeeperServer.isRunning()) {
zkServer.shutdown();
// }
} catch (InterruptedException e) {
// warn, but generally this is ok
log.warn("Server interrupted", e);
}
}
示例6: ZooKeeperServerFactory
import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
public ZooKeeperServerFactory(QuorumPeerConfig config) throws IOException, InterruptedException {
LOGGER.info("Creating zookeeper server with: {}", config);
ServerConfig serverConfig = getServerConfig(config);
ZooKeeperServer zkServer = new ZooKeeperServer();
FileTxnSnapLog ftxn = new FileTxnSnapLog(new File(serverConfig.getDataLogDir()), new File(serverConfig.getDataDir()));
zkServer.setTxnLogFactory(ftxn);
zkServer.setTickTime(serverConfig.getTickTime());
zkServer.setMinSessionTimeout(serverConfig.getMinSessionTimeout());
zkServer.setMaxSessionTimeout(serverConfig.getMaxSessionTimeout());
NIOServerCnxnFactory cnxnFactory = new NIOServerCnxnFactory() {
protected void configureSaslLogin() throws IOException {
}
};
InetSocketAddress clientPortAddress = serverConfig.getClientPortAddress();
cnxnFactory.configure(clientPortAddress, serverConfig.getMaxClientCnxns());
updateZooKeeperURL(cnxnFactory.getLocalAddress(), cnxnFactory.getLocalPort());
try {
LOGGER.debug("Starting ZooKeeper server on address %s", serverConfig.getClientPortAddress());
cnxnFactory.startup(zkServer);
LOGGER.debug("Started ZooKeeper server");
} catch (Exception e) {
LOGGER.warn(String.format("Failed to start ZooKeeper server, reason : %s", e));
cnxnFactory.shutdown();
throw e;
}
}
示例7: start
import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
/**
* Starts the test ZooKeeper server
*/
public void start() {
if (started) {
LOG.debug("Already started");
return;
}
try {
LOG.debug("Starting...");
ServerConfig config = new ServerConfig();
config.parse(new String[] { port.toString(), ZK_DIR.getCanonicalPath(), ticktime.toString() });
zkServer = new ZooKeeperServer();
FileTxnSnapLog ftxn = new FileTxnSnapLog(new File(config.getDataLogDir()), new File(config.getDataDir()));
zkServer.setTxnLogFactory(ftxn);
zkServer.setTickTime(config.getTickTime());
zkServer.setMinSessionTimeout(config.getMinSessionTimeout());
zkServer.setMaxSessionTimeout(config.getMaxSessionTimeout());
cnxnFactory = ServerCnxnFactory.createFactory();
cnxnFactory.configure(config.getClientPortAddress(), config.getMaxClientCnxns());
cnxnFactory.startup(zkServer);
started = true;
LOG.info("Started, {}", getConnectString());
} catch (Exception e) {
LOG.error("Failed to start: " + e.getMessage(), e);
}
}
示例8: runFromConfig
import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
/**
* Run from a ServerConfig.
* @param config ServerConfig to use.
* @throws IOException If there is a low-level I/O error.
*/
public void runFromConfig(ServerConfig config) throws IOException {
log.info("Starting server");
try {
// Note that this thread isn't going to be doing anything else,
// so rather than spawning another thread, we will just call
// run() in this thread.
// create a file logger url from the command line args
zooKeeperServer = new ZooKeeperServer();
FileTxnSnapLog ftxn = new FileTxnSnapLog(new File(
config.getDataLogDir()), new File(config.getDataDir()));
zooKeeperServer.setTxnLogFactory(ftxn);
zooKeeperServer.setTickTime(config.getTickTime());
zooKeeperServer.setMinSessionTimeout(config.getMinSessionTimeout());
zooKeeperServer.setMaxSessionTimeout(config.getMaxSessionTimeout());
cnxnFactory = ServerCnxnFactory.createFactory();
cnxnFactory.configure(config.getClientPortAddress(),
config.getMaxClientCnxns());
cnxnFactory.startup(zooKeeperServer);
cnxnFactory.join();
if (zooKeeperServer.isRunning()) {
zkServer.shutdown();
}
} catch (InterruptedException e) {
// warn, but generally this is ok
log.warn("Server interrupted", e);
}
}
示例9: clearZooKeeperData
import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的package包/类
public static boolean clearZooKeeperData() throws Exception {
ServerConfig zkConf = getZooKeeperConf();
File dataLogDir = new File(zkConf.getDataLogDir());
File dataDir = new File(zkConf.getDataDir());
return (FileUtil.fullyDelete(dataLogDir) && FileUtil.fullyDelete(dataDir));
}
示例10: runFromConfig
import org.apache.zookeeper.server.ServerConfig; //导入方法依赖的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);
}