public QuorumPeer(Map<Long, QuorumServer> quorumPeers, File dataDir, File dataLogDir, int electionType, long myid, int tickTime, int initLimit, int syncLimit, boolean quorumListenOnAllIPs, ServerCnxnFactory cnxnFactory, QuorumVerifier quorumConfig) throws IOException { this(); this.cnxnFactory = cnxnFactory; this.quorumPeers = quorumPeers; this.electionType = electionType; this.myid = myid; this.tickTime = tickTime; this.initLimit = initLimit; this.syncLimit = syncLimit; this.quorumListenOnAllIPs = quorumListenOnAllIPs; this.logFactory = new FileTxnSnapLog(dataLogDir, dataDir); this.zkDb = new ZKDatabase(this.logFactory); if(quorumConfig == null) this.quorumConfig = new QuorumMaj(countParticipants(quorumPeers)); else this.quorumConfig = quorumConfig; }
private QuorumPeer createQuorumPeer(File tmpDir) throws IOException, FileNotFoundException { QuorumPeer peer = new QuorumPeer(); peer.syncLimit = SYNC_LIMIT; peer.initLimit = 2; peer.tickTime = 2000; peer.quorumPeers = new HashMap<Long, QuorumServer>(); peer.quorumPeers.put(1L, new QuorumServer(0, "0.0.0.0", 33221, 0, null)); peer.quorumPeers.put(1L, new QuorumServer(1, "0.0.0.0", 33223, 0, null)); peer.setQuorumVerifier(new QuorumMaj(3)); peer.setCnxnFactory(new NullServerCnxnFactory()); File version2 = new File(tmpDir, "version-2"); version2.mkdir(); FileOutputStream fos; fos = new FileOutputStream(new File(version2, "currentEpoch")); fos.write("0\n".getBytes()); fos.close(); fos = new FileOutputStream(new File(version2, "acceptedEpoch")); fos.write("0\n".getBytes()); fos.close(); return peer; }
public QuorumPeer(Map<Long, QuorumServer> quorumPeers, File dataDir, File dataLogDir, int electionType, long myid, int tickTime, int initLimit, int syncLimit, ServerCnxnFactory cnxnFactory, QuorumVerifier quorumConfig) throws IOException { this(); this.cnxnFactory = cnxnFactory; this.quorumPeers = quorumPeers; this.electionType = electionType; this.myid = myid; this.tickTime = tickTime; this.initLimit = initLimit; this.syncLimit = syncLimit; this.logFactory = new FileTxnSnapLog(dataLogDir, dataDir); this.zkDb = new ZKDatabase(this.logFactory); if(quorumConfig == null) this.quorumConfig = new QuorumMaj(countParticipants(quorumPeers)); else this.quorumConfig = quorumConfig; }
private QuorumPeer createQuorumPeer(File tmpDir) throws IOException, FileNotFoundException { QuorumPeer peer = new QuorumPeer(); peer.syncLimit = 2; peer.initLimit = 2; peer.tickTime = 2000; peer.quorumPeers = new HashMap<Long, QuorumServer>(); peer.quorumPeers.put(1L, new QuorumServer(0, new InetSocketAddress(33221))); peer.quorumPeers.put(1L, new QuorumServer(1, new InetSocketAddress(33223))); peer.setQuorumVerifier(new QuorumMaj(3)); peer.setCnxnFactory(new NullServerCnxnFactory()); File version2 = new File(tmpDir, "version-2"); version2.mkdir(); new FileOutputStream(new File(version2, "currentEpoch")).write("0\n".getBytes()); new FileOutputStream(new File(version2, "acceptedEpoch")).write("0\n".getBytes()); return peer; }
private QuorumPeer createQuorumPeer(File tmpDir) throws IOException, FileNotFoundException { QuorumPeer peer = new QuorumPeer(); peer.syncLimit = SYNC_LIMIT; peer.initLimit = 2; peer.tickTime = 2000; peer.quorumPeers = new HashMap<Long, QuorumServer>(); peer.quorumPeers.put(1L, new QuorumServer(0, new InetSocketAddress(33221))); peer.quorumPeers.put(1L, new QuorumServer(1, new InetSocketAddress(33223))); peer.setQuorumVerifier(new QuorumMaj(3)); peer.setCnxnFactory(new NullServerCnxnFactory()); File version2 = new File(tmpDir, "version-2"); version2.mkdir(); FileOutputStream fos; fos = new FileOutputStream(new File(version2, "currentEpoch")); fos.write("0\n".getBytes()); fos.close(); fos = new FileOutputStream(new File(version2, "acceptedEpoch")); fos.write("0\n".getBytes()); fos.close(); return peer; }
private void processConfigData(byte[] data) throws Exception { Properties properties = new Properties(); properties.load(new ByteArrayInputStream(data)); log.info("New config event received: {}", properties); if (!properties.isEmpty()) { QuorumMaj newConfig = new QuorumMaj(properties); String connectionString = configToConnectionString(newConfig); if (connectionString.trim().length() > 0) { currentConfig.set(newConfig); ensembleProvider.setConnectionString(connectionString); } else { log.error("Invalid config event received: {}", properties); } } else { log.debug("Ignoring new config as it is empty"); } }
public QuorumPeer(Map<Long, QuorumServer> quorumPeers, File dataDir, File dataLogDir, int electionType, long myid, int tickTime, int initLimit, int syncLimit, NIOServerCnxn.Factory cnxnFactory, QuorumVerifier quorumConfig) throws IOException { this(); this.cnxnFactory = cnxnFactory; this.quorumPeers = quorumPeers; this.electionType = electionType; this.myid = myid; this.tickTime = tickTime; this.initLimit = initLimit; this.syncLimit = syncLimit; this.logFactory = new FileTxnSnapLog(dataLogDir, dataDir); this.zkDb = new ZKDatabase(this.logFactory); if(quorumConfig == null) this.quorumConfig = new QuorumMaj(countParticipants(quorumPeers)); else this.quorumConfig = quorumConfig; }
/** * For backward compatibility purposes, we instantiate QuorumMaj by default. */ public QuorumPeer(Map<Long, QuorumServer> quorumPeers, File dataDir, File dataLogDir, int electionType, long myid, int tickTime, int initLimit, int syncLimit, ServerCnxnFactory cnxnFactory) throws IOException { this(quorumPeers, dataDir, dataLogDir, electionType, myid, tickTime, initLimit, syncLimit, false, cnxnFactory, new QuorumMaj(countParticipants(quorumPeers))); }
/** * This constructor is only used by the existing unit test code. * It defaults to FileLogProvider persistence provider. */ public QuorumPeer(Map<Long,QuorumServer> quorumPeers, File snapDir, File logDir, int clientPort, int electionAlg, long myid, int tickTime, int initLimit, int syncLimit) throws IOException { this(quorumPeers, snapDir, logDir, electionAlg, myid,tickTime, initLimit,syncLimit, false, ServerCnxnFactory.createFactory(new InetSocketAddress(clientPort), -1), new QuorumMaj(countParticipants(quorumPeers))); }
public MockQuorumPeer(Map<Long,QuorumServer> quorumPeers, File snapDir, File logDir, int clientPort, int electionAlg, long myid, int tickTime, int initLimit, int syncLimit) throws IOException { super(quorumPeers, snapDir, logDir, electionAlg, myid,tickTime, initLimit,syncLimit, false, ServerCnxnFactory.createFactory(clientPort, -1), new QuorumMaj(countParticipants(quorumPeers))); }
/** * For backward compatibility purposes, we instantiate QuorumMaj by default. */ public QuorumPeer(Map<Long, QuorumServer> quorumPeers, File dataDir, File dataLogDir, int electionType, long myid, int tickTime, int initLimit, int syncLimit, ServerCnxnFactory cnxnFactory) throws IOException { this(quorumPeers, dataDir, dataLogDir, electionType, myid, tickTime, initLimit, syncLimit, false, cnxnFactory, new QuorumMaj(quorumPeers)); }
/** * This constructor is only used by the existing unit test code. * It defaults to FileLogProvider persistence provider. */ public QuorumPeer(Map<Long,QuorumServer> quorumPeers, File snapDir, File logDir, int clientPort, int electionAlg, long myid, int tickTime, int initLimit, int syncLimit) throws IOException { this(quorumPeers, snapDir, logDir, electionAlg, myid, tickTime, initLimit, syncLimit, false, ServerCnxnFactory.createFactory(getClientAddress(quorumPeers, myid, clientPort), -1), new QuorumMaj(quorumPeers)); }
private static QuorumVerifier createQuorumVerifier(Properties dynamicConfigProp, boolean isHierarchical) throws ConfigException{ if(isHierarchical){ return new QuorumHierarchical(dynamicConfigProp); } else { /* * The default QuorumVerifier is QuorumMaj */ //LOG.info("Defaulting to majority quorums"); return new QuorumMaj(dynamicConfigProp); } }
/** * For backward compatibility purposes, we instantiate QuorumMaj by default. */ public QuorumPeer(Map<Long, QuorumServer> quorumPeers, File dataDir, File dataLogDir, int electionType, long myid, int tickTime, int initLimit, int syncLimit, ServerCnxnFactory cnxnFactory) throws IOException { this(quorumPeers, dataDir, dataLogDir, electionType, myid, tickTime, initLimit, syncLimit, cnxnFactory, new QuorumMaj(countParticipants(quorumPeers))); }
/** * This constructor is only used by the existing unit test code. * It defaults to FileLogProvider persistence provider. */ public QuorumPeer(Map<Long,QuorumServer> quorumPeers, File snapDir, File logDir, int clientPort, int electionAlg, long myid, int tickTime, int initLimit, int syncLimit) throws IOException { this(quorumPeers, snapDir, logDir, electionAlg, myid,tickTime, initLimit,syncLimit, ServerCnxnFactory.createFactory(new InetSocketAddress(clientPort), -1), new QuorumMaj(countParticipants(quorumPeers))); }
public MockQuorumPeer(Map<Long,QuorumServer> quorumPeers, File snapDir, File logDir, int clientPort, int electionAlg, long myid, int tickTime, int initLimit, int syncLimit) throws IOException { super(quorumPeers, snapDir, logDir, electionAlg, myid,tickTime, initLimit,syncLimit, ServerCnxnFactory.createFactory(clientPort, -1), new QuorumMaj(countParticipants(quorumPeers))); }