本文整理匯總了Java中org.apache.zookeeper.server.ZooKeeperServer.setTxnLogFactory方法的典型用法代碼示例。如果您正苦於以下問題:Java ZooKeeperServer.setTxnLogFactory方法的具體用法?Java ZooKeeperServer.setTxnLogFactory怎麽用?Java ZooKeeperServer.setTxnLogFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.zookeeper.server.ZooKeeperServer
的用法示例。
在下文中一共展示了ZooKeeperServer.setTxnLogFactory方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: serviceStart
import org.apache.zookeeper.server.ZooKeeperServer; //導入方法依賴的package包/類
/**
* Startup: start ZK. It is only after this that
* the binding information is valid.
* @throws Exception
*/
@Override
protected void serviceStart() throws Exception {
setupSecurity();
ZooKeeperServer zkServer = new ZooKeeperServer();
FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, dataDir);
zkServer.setTxnLogFactory(ftxn);
zkServer.setTickTime(tickTime);
LOG.info("Starting Local Zookeeper service");
factory = ServerCnxnFactory.createFactory();
factory.configure(getAddress(port), -1);
factory.startup(zkServer);
String connectString = getConnectionString();
LOG.info("In memory ZK started at {}\n", connectString);
if (LOG.isDebugEnabled()) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
zkServer.dumpConf(pw);
pw.flush();
LOG.debug(sw.toString());
}
binding = new BindingInformation();
binding.ensembleProvider = new FixedEnsembleProvider(connectString);
binding.description =
getName() + " reachable at \"" + connectString + "\"";
addDiagnostics(binding.description);
// finally: set the binding information in the config
getConfig().set(KEY_REGISTRY_ZK_QUORUM, connectString);
}
示例2: start
import org.apache.zookeeper.server.ZooKeeperServer; //導入方法依賴的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);
}