Java Code Examples for org.apache.zookeeper.server.ZooKeeperServer#setTxnLogFactory()
The following examples show how to use
org.apache.zookeeper.server.ZooKeeperServer#setTxnLogFactory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MiniAvatarCluster.java From RDFS with Apache License 2.0 | 6 votes |
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); }
Example 2
Source File: EmbeddedZookeeper.java From wildfly-camel with Apache License 2.0 | 6 votes |
public EmbeddedZookeeper(int port, Path baseDir) throws Exception { this.port = port; zookeeperBaseDir = baseDir; zkServer = new ZooKeeperServer(); File dataDir = zookeeperBaseDir.resolve("log").toFile(); File snapDir = zookeeperBaseDir.resolve("data").toFile(); FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, snapDir); zkServer.setTxnLogFactory(ftxn); zkServer.setTickTime(1000); connectionFactory = new NIOServerCnxnFactory() { @Override protected void configureSaslLogin() throws IOException { // do nothing } }; connectionFactory.configure(new InetSocketAddress("localhost", port), 0); }
Example 3
Source File: ZookeeperServer.java From camel-spring-boot with Apache License 2.0 | 5 votes |
public ZookeeperServer(File root) throws IOException, InterruptedException { zkServer = new ZooKeeperServer(); File dataDir = new File(root, "log"); File snapDir = new File(root, "data"); FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, snapDir); zkServer.setTxnLogFactory(ftxn); zkServer.setTickTime(1000); connectionFactory = new NIOServerCnxnFactory(); connectionFactory.configure(new InetSocketAddress("localhost", SocketUtils.findAvailableTcpPort()), 0); connectionFactory.startup(zkServer); }
Example 4
Source File: MicroZookeeperService.java From hadoop with Apache License 2.0 | 5 votes |
/** * 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); }
Example 5
Source File: InMemoryZKServer.java From twill with Apache License 2.0 | 5 votes |
@Override protected void startUp() throws Exception { ZooKeeperServer zkServer = new ZooKeeperServer(); FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, dataDir); zkServer.setTxnLogFactory(ftxn); zkServer.setTickTime(tickTime); factory = ServerCnxnFactory.createFactory(); factory.configure(getAddress(port), -1); factory.startup(zkServer); LOG.info("In memory ZK started: " + getConnectionStr()); }
Example 6
Source File: MicroZookeeperService.java From big-c with Apache License 2.0 | 5 votes |
/** * 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); }
Example 7
Source File: EmbeddedZookeeper.java From tajo with Apache License 2.0 | 5 votes |
public EmbeddedZookeeper(int port) throws IOException { zkDataDir = Files.createTempDir(); zkServer = new ZooKeeperServer(); FileTxnSnapLog ftxn = new FileTxnSnapLog(zkDataDir, zkDataDir); zkServer.setTxnLogFactory(ftxn); cnxnFactory = new NIOServerCnxnFactory(); cnxnFactory.configure(new InetSocketAddress(port), 0); }
Example 8
Source File: EmbeddedZookeeper.java From jesos with Apache License 2.0 | 5 votes |
public EmbeddedZookeeper(final int port) throws IOException { this.port = port; zkDataDir = Files.createTempDir(); zkServer = new ZooKeeperServer(); final FileTxnSnapLog ftxn = new FileTxnSnapLog(zkDataDir, zkDataDir); zkServer.setTxnLogFactory(ftxn); cnxnFactory = new NIOServerCnxn.Factory(new InetSocketAddress(this.port), 0); }
Example 9
Source File: LocalZKServer.java From oryx with Apache License 2.0 | 4 votes |
/** * 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); }