org.apache.zookeeper.server.persistence.FileTxnSnapLog Java Examples
The following examples show how to use
org.apache.zookeeper.server.persistence.FileTxnSnapLog.
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: 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 #2
Source File: ZKServerFactoryBean.java From wildfly-camel with Apache License 2.0 | 6 votes |
public void afterPropertiesSet() throws Exception { if (purge) { deleteFilesInDir(getDataLogDir()); deleteFilesInDir(getDataDir()); } FileTxnSnapLog ftxn = new FileTxnSnapLog(getDataLogDir(), getDataDir()); zooKeeperServer.setTxnLogFactory(ftxn); zooKeeperServer.setTickTime(getTickTime()); zooKeeperServer.setMinSessionTimeout(getMinSessionTimeout()); zooKeeperServer.setMaxSessionTimeout(getMaxSessionTimeout()); connectionFactory = new NIOServerCnxnFactory() { @Override protected void configureSaslLogin() throws IOException { // do nothing } }; connectionFactory.configure(getClientPortAddress(), getMaxClientConnections()); connectionFactory.startup(zooKeeperServer); }
Example #3
Source File: ZooKeeperTestServer.java From attic-aurora with Apache License 2.0 | 6 votes |
/** * Starts zookeeper up on an ephemeral port. */ public void startNetwork() throws IOException, InterruptedException { zooKeeperServer = new ZooKeeperServer( new FileTxnSnapLog(dataDir, snapDir), new BasicDataTreeBuilder()) { // TODO(John Sirois): Introduce a builder to configure the in-process server if and when // some folks need JMX for in-process tests. @Override protected void registerJMX() { // noop } }; connectionFactory = new NIOServerCnxnFactory(); connectionFactory.configure( new InetSocketAddress(port), 60 /* Semi-arbitrary, max 60 connections is the default used by NIOServerCnxnFactory */); connectionFactory.startup(zooKeeperServer); port = zooKeeperServer.getClientPort(); }
Example #4
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 #5
Source File: ZooKeeperStateServer.java From localization_nifi with Apache License 2.0 | 5 votes |
private void startDistributed() throws IOException { logger.info("Starting Embedded ZooKeeper Peer"); try { transactionLog = new FileTxnSnapLog(new File(quorumPeerConfig.getDataLogDir()), new File(quorumPeerConfig.getDataDir())); connectionFactory = ServerCnxnFactory.createFactory(); connectionFactory.configure(quorumPeerConfig.getClientPortAddress(), quorumPeerConfig.getMaxClientCnxns()); quorumPeer = new QuorumPeer(); quorumPeer.setClientPortAddress(quorumPeerConfig.getClientPortAddress()); quorumPeer.setTxnFactory(new FileTxnSnapLog(new File(quorumPeerConfig.getDataLogDir()), new File(quorumPeerConfig.getDataDir()))); quorumPeer.setQuorumPeers(quorumPeerConfig.getServers()); quorumPeer.setElectionType(quorumPeerConfig.getElectionAlg()); quorumPeer.setMyid(quorumPeerConfig.getServerId()); quorumPeer.setTickTime(quorumPeerConfig.getTickTime()); quorumPeer.setMinSessionTimeout(quorumPeerConfig.getMinSessionTimeout()); quorumPeer.setMaxSessionTimeout(quorumPeerConfig.getMaxSessionTimeout()); quorumPeer.setInitLimit(quorumPeerConfig.getInitLimit()); quorumPeer.setSyncLimit(quorumPeerConfig.getSyncLimit()); quorumPeer.setQuorumVerifier(quorumPeerConfig.getQuorumVerifier()); quorumPeer.setCnxnFactory(connectionFactory); quorumPeer.setZKDatabase(new ZKDatabase(quorumPeer.getTxnFactory())); quorumPeer.setLearnerType(quorumPeerConfig.getPeerType()); quorumPeer.setSyncEnabled(quorumPeerConfig.getSyncEnabled()); quorumPeer.setQuorumListenOnAllIPs(quorumPeerConfig.getQuorumListenOnAllIPs()); quorumPeer.start(); } catch (final IOException ioe) { throw new IOException("Failed to start embedded ZooKeeper Peer", ioe); } catch (final Exception e) { throw new RuntimeException("Failed to start embedded ZooKeeper Peer", e); } }
Example #6
Source File: SpliceZoo.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
public SpliceZoo(QuorumPeerConfig config, int number) throws IOException { this.config = config; try { if (QuorumPeer.class.getMethod("testingQuorumPeer", null) != null) this.peer = (QuorumPeer) QuorumPeer.class.getMethod("testingQuorumPeer", null).invoke(null,null); else this.peer = QuorumPeer.class.newInstance(); } catch (Exception e) { throw new RuntimeException("Quorum Peer Signature Issue for Unit Tests"); } ServerCnxnFactory cnxnFactory = ServerCnxnFactory.createFactory(); cnxnFactory.configure(config.getClientPortAddress(),config.getMaxClientCnxns()); peer.setClientPortAddress(config.getClientPortAddress()); peer.setTxnFactory(new FileTxnSnapLog(new File(config.getDataLogDir()), new File(config.getDataDir()))); peer.setQuorumPeers(config.getServers()); peer.setElectionType(config.getElectionAlg()); peer.setMyid(config.getServerId()); peer.setTickTime(config.getTickTime()); peer.setMinSessionTimeout(config.getMinSessionTimeout()); peer.setMaxSessionTimeout(config.getMaxSessionTimeout()); peer.setInitLimit(config.getInitLimit()); peer.setSyncLimit(config.getSyncLimit()); peer.setQuorumVerifier(config.getQuorumVerifier()); peer.setCnxnFactory(cnxnFactory); peer.setZKDatabase(new ZKDatabase(peer.getTxnFactory())); peer.setLearnerType(config.getPeerType()); peer.setMyid(number); }
Example #7
Source File: ZookeeperTestServer.java From blueflood with Apache License 2.0 | 5 votes |
public void connect() throws IOException, InterruptedException { zkServer = new ZooKeeperServer(new FileTxnSnapLog(dataDir, logDir), new ZooKeeperServer.BasicDataTreeBuilder()); connectionFactory = new NIOServerCnxnFactory(); connectionFactory.configure(new InetSocketAddress(port), 10); connectionFactory.startup(zkServer); port = zkServer.getClientPort(); }
Example #8
Source File: ZooKeeperStateServer.java From nifi with Apache License 2.0 | 5 votes |
private void startDistributed() throws IOException { logger.info("Starting Embedded ZooKeeper Peer"); try { transactionLog = new FileTxnSnapLog(quorumPeerConfig.getDataLogDir(), quorumPeerConfig.getDataDir()); connectionFactory = ServerCnxnFactory.createFactory(); connectionFactory.configure(quorumPeerConfig.getClientPortAddress(), quorumPeerConfig.getMaxClientCnxns()); quorumPeer = new QuorumPeer(); quorumPeer.setTxnFactory(new FileTxnSnapLog(quorumPeerConfig.getDataLogDir(), quorumPeerConfig.getDataDir())); quorumPeer.setElectionType(quorumPeerConfig.getElectionAlg()); quorumPeer.setMyid(quorumPeerConfig.getServerId()); quorumPeer.setTickTime(quorumPeerConfig.getTickTime()); quorumPeer.setMinSessionTimeout(quorumPeerConfig.getMinSessionTimeout()); quorumPeer.setMaxSessionTimeout(quorumPeerConfig.getMaxSessionTimeout()); quorumPeer.setInitLimit(quorumPeerConfig.getInitLimit()); quorumPeer.setSyncLimit(quorumPeerConfig.getSyncLimit()); quorumPeer.setQuorumVerifier(quorumPeerConfig.getQuorumVerifier(), false); quorumPeer.setCnxnFactory(connectionFactory); quorumPeer.setZKDatabase(new ZKDatabase(quorumPeer.getTxnFactory())); quorumPeer.setLearnerType(quorumPeerConfig.getPeerType()); quorumPeer.setSyncEnabled(quorumPeerConfig.getSyncEnabled()); quorumPeer.setQuorumListenOnAllIPs(quorumPeerConfig.getQuorumListenOnAllIPs()); quorumPeer.start(); } catch (final IOException ioe) { throw new IOException("Failed to start embedded ZooKeeper Peer", ioe); } catch (final Exception e) { throw new RuntimeException("Failed to start embedded ZooKeeper Peer", e); } }
Example #9
Source File: TestingZooKeeperMain.java From curator with Apache License 2.0 | 5 votes |
public TestZooKeeperServer(FileTxnSnapLog txnLog, ServerConfig config) { this.txnLog = txnLog; this.setTxnLogFactory(txnLog); this.setMinSessionTimeout(config.getMinSessionTimeout()); this.setMaxSessionTimeout(config.getMaxSessionTimeout()); }
Example #10
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 #11
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 #12
Source File: ZooServer.java From rdf-delta with Apache License 2.0 | 5 votes |
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); }
Example #13
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 #14
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 #15
Source File: ZookeeperInstance.java From netcrusher-java with Apache License 2.0 | 5 votes |
private QuorumPeer createPeer(ServerCnxnFactory cnxnFactory, QuorumPeerConfig config) throws IOException { cnxnFactory.configure(config.getClientPortAddress(), config.getMaxClientCnxns()); QuorumPeer quorumPeer = new QuorumPeer(); quorumPeer.setClientPortAddress(config.getClientPortAddress()); quorumPeer.setTxnFactory(new FileTxnSnapLog( new File(config.getDataLogDir()), new File(config.getDataDir()))); quorumPeer.setQuorumPeers(config.getServers()); quorumPeer.setElectionType(config.getElectionAlg()); quorumPeer.setMyid(config.getServerId()); quorumPeer.setTickTime(config.getTickTime()); quorumPeer.setMinSessionTimeout(config.getMinSessionTimeout()); quorumPeer.setMaxSessionTimeout(config.getMaxSessionTimeout()); quorumPeer.setInitLimit(config.getInitLimit()); quorumPeer.setSyncLimit(config.getSyncLimit()); quorumPeer.setQuorumVerifier(config.getQuorumVerifier()); quorumPeer.setCnxnFactory(cnxnFactory); quorumPeer.setZKDatabase(new ZKDatabase(quorumPeer.getTxnFactory())); quorumPeer.setLearnerType(config.getPeerType()); quorumPeer.setSyncEnabled(config.getSyncEnabled()); quorumPeer.setQuorumListenOnAllIPs(config.getQuorumListenOnAllIPs()); quorumPeer.start(); return quorumPeer; }
Example #16
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 #17
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 #18
Source File: ZkTestServer.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * 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 { ObjectReleaseTracker.track(this); log.info("Starting server"); try { // ZooKeeper maintains a static collection of AuthenticationProviders, so // we make sure the SASL provider is loaded so that it can be used in // subsequent tests. System.setProperty("zookeeper.authProvider.1", "org.apache.zookeeper.server.auth.SASLAuthenticationProvider"); // 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 FileTxnSnapLog ftxn = new FileTxnSnapLog(config.getDataLogDir(), config.getDataDir()); zooKeeperServer = new ZooKeeperServer(ftxn, config.getTickTime(), config.getMinSessionTimeout(), config.getMaxSessionTimeout(), new TestZKDatabase(ftxn, limiter)); cnxnFactory = new TestServerCnxnFactory(limiter); cnxnFactory.configure(config.getClientPortAddress(), config.getMaxClientCnxns()); cnxnFactory.startup(zooKeeperServer); cnxnFactory.join(); if (violationReportAction != LimitViolationAction.IGNORE) { String limitViolations = limiter.reportLimitViolations(); if (!limitViolations.isEmpty()) { log.warn("Watch limit violations: {}", limitViolations); if (violationReportAction == LimitViolationAction.FAIL) { throw new AssertionError("Parallel watch limits violated"); } } } } catch (InterruptedException e) { // warn, but generally this is ok log.warn("Server interrupted", e); } }
Example #19
Source File: KafkaOperatorTestBase.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public TestZookeeperServer(FileTxnSnapLog txnLogFactory, int tickTime, DataTreeBuilder treeBuilder) throws IOException { super(txnLogFactory, tickTime, treeBuilder); // TODO Auto-generated constructor stub }
Example #20
Source File: KafkaOperatorTestBase.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public TestZookeeperServer(FileTxnSnapLog txnLogFactory, DataTreeBuilder treeBuilder) throws IOException { super(txnLogFactory, treeBuilder); // TODO Auto-generated constructor stub }
Example #21
Source File: KafkaOperatorTestBase.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public TestZookeeperServer(FileTxnSnapLog txnLogFactory, int tickTime, int minSessionTimeout, int maxSessionTimeout, DataTreeBuilder treeBuilder, ZKDatabase zkDb) { super(txnLogFactory, tickTime, minSessionTimeout, maxSessionTimeout, treeBuilder, zkDb); // TODO Auto-generated constructor stub }
Example #22
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); }
Example #23
Source File: KafkaOperatorTestBase.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public TestZookeeperServer(FileTxnSnapLog txnLogFactory, int tickTime, int minSessionTimeout, int maxSessionTimeout, DataTreeBuilder treeBuilder, ZKDatabase zkDb) { super(txnLogFactory, tickTime, minSessionTimeout, maxSessionTimeout, treeBuilder, zkDb); // TODO Auto-generated constructor stub }
Example #24
Source File: ZkTestServer.java From lucene-solr with Apache License 2.0 | 4 votes |
public TestZKDatabase(FileTxnSnapLog snapLog, WatchLimiter limiter) { super(snapLog); this.limiter = limiter; }
Example #25
Source File: KafkaOperatorTestBase.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public TestZookeeperServer(FileTxnSnapLog txnLogFactory, int tickTime, DataTreeBuilder treeBuilder) throws IOException { super(txnLogFactory, tickTime, treeBuilder); // TODO Auto-generated constructor stub }
Example #26
Source File: KafkaOperatorTestBase.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public TestZookeeperServer(FileTxnSnapLog txnLogFactory, DataTreeBuilder treeBuilder) throws IOException { super(txnLogFactory, treeBuilder); // TODO Auto-generated constructor stub }
Example #27
Source File: KafkaOperatorTestBase.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public TestZookeeperServer(FileTxnSnapLog txnLogFactory, int tickTime, int minSessionTimeout, int maxSessionTimeout, DataTreeBuilder treeBuilder, ZKDatabase zkDb) { super(txnLogFactory, tickTime, minSessionTimeout, maxSessionTimeout, treeBuilder, zkDb); // TODO Auto-generated constructor stub }
Example #28
Source File: KafkaOperatorTestBase.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public TestZookeeperServer(FileTxnSnapLog txnLogFactory, int tickTime, DataTreeBuilder treeBuilder) throws IOException { super(txnLogFactory, tickTime, treeBuilder); // TODO Auto-generated constructor stub }
Example #29
Source File: KafkaOperatorTestBase.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
public TestZookeeperServer(FileTxnSnapLog txnLogFactory, DataTreeBuilder treeBuilder) throws IOException { super(txnLogFactory, treeBuilder); // TODO Auto-generated constructor stub }