|
@@ -586,6 +586,11 @@ public class QuorumPeer extends ZooKeeperThread implements QuorumStats.Provider
|
|
*/
|
|
*/
|
|
protected volatile int syncLimit;
|
|
protected volatile int syncLimit;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * The number of ticks that can pass before retrying to connect to learner master
|
|
|
|
+ */
|
|
|
|
+ protected volatile int connectToLearnerMasterLimit;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Enables/Disables sync request processor. This option is enabled
|
|
* Enables/Disables sync request processor. This option is enabled
|
|
* by default and is to be used with observers.
|
|
* by default and is to be used with observers.
|
|
@@ -899,16 +904,16 @@ public class QuorumPeer extends ZooKeeperThread implements QuorumStats.Provider
|
|
|
|
|
|
public QuorumPeer(Map<Long, QuorumServer> quorumPeers, File dataDir,
|
|
public QuorumPeer(Map<Long, QuorumServer> quorumPeers, File dataDir,
|
|
File dataLogDir, int electionType,
|
|
File dataLogDir, int electionType,
|
|
- long myid, int tickTime, int initLimit, int syncLimit,
|
|
|
|
|
|
+ long myid, int tickTime, int initLimit, int syncLimit, int connectToLearnerMasterLimit,
|
|
ServerCnxnFactory cnxnFactory) throws IOException {
|
|
ServerCnxnFactory cnxnFactory) throws IOException {
|
|
this(quorumPeers, dataDir, dataLogDir, electionType, myid, tickTime,
|
|
this(quorumPeers, dataDir, dataLogDir, electionType, myid, tickTime,
|
|
- initLimit, syncLimit, false, cnxnFactory,
|
|
|
|
|
|
+ initLimit, syncLimit, connectToLearnerMasterLimit, false, cnxnFactory,
|
|
new QuorumMaj(quorumPeers));
|
|
new QuorumMaj(quorumPeers));
|
|
}
|
|
}
|
|
|
|
|
|
public QuorumPeer(Map<Long, QuorumServer> quorumPeers, File dataDir,
|
|
public QuorumPeer(Map<Long, QuorumServer> quorumPeers, File dataDir,
|
|
File dataLogDir, int electionType,
|
|
File dataLogDir, int electionType,
|
|
- long myid, int tickTime, int initLimit, int syncLimit,
|
|
|
|
|
|
+ long myid, int tickTime, int initLimit, int syncLimit, int connectToLearnerMasterLimit,
|
|
boolean quorumListenOnAllIPs,
|
|
boolean quorumListenOnAllIPs,
|
|
ServerCnxnFactory cnxnFactory,
|
|
ServerCnxnFactory cnxnFactory,
|
|
QuorumVerifier quorumConfig) throws IOException {
|
|
QuorumVerifier quorumConfig) throws IOException {
|
|
@@ -919,6 +924,7 @@ public class QuorumPeer extends ZooKeeperThread implements QuorumStats.Provider
|
|
this.tickTime = tickTime;
|
|
this.tickTime = tickTime;
|
|
this.initLimit = initLimit;
|
|
this.initLimit = initLimit;
|
|
this.syncLimit = syncLimit;
|
|
this.syncLimit = syncLimit;
|
|
|
|
+ this.connectToLearnerMasterLimit = connectToLearnerMasterLimit;
|
|
this.quorumListenOnAllIPs = quorumListenOnAllIPs;
|
|
this.quorumListenOnAllIPs = quorumListenOnAllIPs;
|
|
this.logFactory = new FileTxnSnapLog(dataLogDir, dataDir);
|
|
this.logFactory = new FileTxnSnapLog(dataLogDir, dataDir);
|
|
this.zkDb = new ZKDatabase(this.logFactory);
|
|
this.zkDb = new ZKDatabase(this.logFactory);
|
|
@@ -1049,7 +1055,7 @@ public class QuorumPeer extends ZooKeeperThread implements QuorumStats.Provider
|
|
}
|
|
}
|
|
return count;
|
|
return count;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
|
|
|
|
* This constructor is only used by the existing unit test code.
|
|
* This constructor is only used by the existing unit test code.
|
|
@@ -1057,10 +1063,10 @@ public class QuorumPeer extends ZooKeeperThread implements QuorumStats.Provider
|
|
*/
|
|
*/
|
|
public QuorumPeer(Map<Long,QuorumServer> quorumPeers, File snapDir,
|
|
public QuorumPeer(Map<Long,QuorumServer> quorumPeers, File snapDir,
|
|
File logDir, int clientPort, int electionAlg,
|
|
File logDir, int clientPort, int electionAlg,
|
|
- long myid, int tickTime, int initLimit, int syncLimit)
|
|
|
|
|
|
+ long myid, int tickTime, int initLimit, int syncLimit, int connectToLearnerMasterLimit)
|
|
throws IOException
|
|
throws IOException
|
|
{
|
|
{
|
|
- this(quorumPeers, snapDir, logDir, electionAlg, myid, tickTime, initLimit, syncLimit, false,
|
|
|
|
|
|
+ this(quorumPeers, snapDir, logDir, electionAlg, myid, tickTime, initLimit, syncLimit, connectToLearnerMasterLimit, false,
|
|
ServerCnxnFactory.createFactory(getClientAddress(quorumPeers, myid, clientPort), -1),
|
|
ServerCnxnFactory.createFactory(getClientAddress(quorumPeers, myid, clientPort), -1),
|
|
new QuorumMaj(quorumPeers));
|
|
new QuorumMaj(quorumPeers));
|
|
}
|
|
}
|
|
@@ -1071,12 +1077,12 @@ public class QuorumPeer extends ZooKeeperThread implements QuorumStats.Provider
|
|
*/
|
|
*/
|
|
public QuorumPeer(Map<Long,QuorumServer> quorumPeers, File snapDir,
|
|
public QuorumPeer(Map<Long,QuorumServer> quorumPeers, File snapDir,
|
|
File logDir, int clientPort, int electionAlg,
|
|
File logDir, int clientPort, int electionAlg,
|
|
- long myid, int tickTime, int initLimit, int syncLimit,
|
|
|
|
|
|
+ long myid, int tickTime, int initLimit, int syncLimit, int connectToLearnerMasterLimit,
|
|
QuorumVerifier quorumConfig)
|
|
QuorumVerifier quorumConfig)
|
|
throws IOException
|
|
throws IOException
|
|
{
|
|
{
|
|
this(quorumPeers, snapDir, logDir, electionAlg,
|
|
this(quorumPeers, snapDir, logDir, electionAlg,
|
|
- myid,tickTime, initLimit,syncLimit, false,
|
|
|
|
|
|
+ myid,tickTime, initLimit,syncLimit, connectToLearnerMasterLimit, false,
|
|
ServerCnxnFactory.createFactory(getClientAddress(quorumPeers, myid, clientPort), -1),
|
|
ServerCnxnFactory.createFactory(getClientAddress(quorumPeers, myid, clientPort), -1),
|
|
quorumConfig);
|
|
quorumConfig);
|
|
}
|
|
}
|
|
@@ -1785,6 +1791,20 @@ public class QuorumPeer extends ZooKeeperThread implements QuorumStats.Provider
|
|
this.syncLimit = syncLimit;
|
|
this.syncLimit = syncLimit;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Get the connectToLearnerMasterLimit
|
|
|
|
+ */
|
|
|
|
+ public int getConnectToLearnerMasterLimit() {
|
|
|
|
+ return connectToLearnerMasterLimit;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Set the connectToLearnerMasterLimit
|
|
|
|
+ */
|
|
|
|
+ public void setConnectToLearnerMasterLimit(int connectToLearnerMasterLimit) {
|
|
|
|
+ LOG.info("connectToLearnerMasterLimit set to " + connectToLearnerMasterLimit);
|
|
|
|
+ this.connectToLearnerMasterLimit = connectToLearnerMasterLimit;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* The syncEnabled can also be set via a system property.
|
|
* The syncEnabled can also be set via a system property.
|