public String getDataLogDir() { return config.getDataLogDir(); }
private void startStandalone() throws IOException { logger.info("Starting Embedded ZooKeeper Server"); final ServerConfig config = new ServerConfig(); config.readFrom(quorumPeerConfig); try { transactionLog = new FileTxnSnapLog(new File(config.getDataLogDir()), new File(config.getDataDir())); embeddedZkServer = new ZooKeeperServer(); embeddedZkServer.setTxnLogFactory(transactionLog); embeddedZkServer.setTickTime(config.getTickTime()); embeddedZkServer.setMinSessionTimeout(config.getMinSessionTimeout()); embeddedZkServer.setMaxSessionTimeout(config.getMaxSessionTimeout()); connectionFactory = ServerCnxnFactory.createFactory(); connectionFactory.configure(config.getClientPortAddress(), config.getMaxClientCnxns()); connectionFactory.startup(embeddedZkServer); } catch (InterruptedException e) { Thread.currentThread().interrupt(); logger.warn("Embedded ZooKeeper Server interrupted", e); } catch (final IOException ioe) { throw new IOException("Failed to start embedded ZooKeeper Server", ioe); } catch (final Exception e) { throw new RuntimeException("Failed to start embedded ZooKeeper Server", e); } }
transactionLog = new FileTxnSnapLog(new File(serverConfig.getDataLogDir().toString()), new File(serverConfig.getDataDir().toString())); zkServer.setTxnLogFactory(transactionLog);
private void configure(ZooKeeperServer zooKeeperServer, ServerConfig config) throws IOException { zooKeeperServer.setTxnLogFactory( new FileTxnSnapLog(new File(config.getDataLogDir()), new File(config.getDataDir()))); zooKeeperServer.setTickTime(config.getTickTime()); zooKeeperServer.setMinSessionTimeout(config.getMinSessionTimeout()); zooKeeperServer.setMaxSessionTimeout(config.getMaxSessionTimeout()); }
public void setupFromConfig() { try { txnLog = new FileTxnSnapLog(config.getDataLogDir(), config.getDataDir()); } catch (IOException e) { e.printStackTrace(); } zkServer = new ZooKeeperServer(txnLog, config.getTickTime(), config.getMinSessionTimeout(), config.getMaxSessionTimeout(), null); }
transactionLog = new FileTxnSnapLog(new File(serverConfig.getDataLogDir().toString()), new File(serverConfig.getDataDir().toString())); zkServer.setTxnLogFactory(transactionLog);
transactionLog = new FileTxnSnapLog(new File(serverConfig.getDataLogDir().toString()), new File(serverConfig.getDataDir().toString())); zkServer.setTxnLogFactory(transactionLog);
config.getDataLogDir()), new File(config.getDataDir())); zooKeeperServer = new ZooKeeperServer(ftxn, config.getTickTime(), config.getMinSessionTimeout(), config.getMaxSessionTimeout(),
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; } }
/** * This method is coming from <code>ZooKeeperServerMain</code> but tweaked to not block and to * have access to <code>_zkServer</code> and <code>_cnxnFactory</code>. */ private void runFromConfig(ServerConfig config) throws IOException { log.info("Starting server"); try { _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 = new NIOServerCnxnFactory(); _cnxnFactory.configure(config.getClientPortAddress(), config.getMaxClientCnxns()); _cnxnFactory.startup(_zkServer); } catch(InterruptedException e) { // warn, but generally this is ok log.warn("Server interrupted", e); } }
FileTxnSnapLog ftxn = new FileTxnSnapLog(new File(serverConfig.getDataLogDir()), new File(serverConfig.getDataDir())); zkServer.setTxnLogFactory(ftxn); zkServer.setTickTime(serverConfig.getTickTime()); registration = context.registerService(ServerStats.Provider.class, server, null); startCleanupManager(serverConfig.getDataDir(), serverConfig.getDataLogDir(), props);
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(); } } }
FileTxnSnapLog ftxn = new FileTxnSnapLog(new File(serverConfig.getDataLogDir()), new File(serverConfig.getDataDir())); zkServer.setTxnLogFactory(ftxn); zkServer.setTickTime(serverConfig.getTickTime());