Java Code Examples for org.apache.zookeeper.server.quorum.QuorumPeer#setTxnFactory()
The following examples show how to use
org.apache.zookeeper.server.quorum.QuorumPeer#setTxnFactory() .
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: 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 2
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 3
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); } }