Class QuorumPeer
- java.lang.Object
- 
- java.lang.Thread
- 
- org.apache.zookeeper.server.ZooKeeperThread
- 
- org.apache.zookeeper.server.quorum.QuorumPeer
 
 
 
- 
- All Implemented Interfaces:
- Runnable,- QuorumStats.Provider
 
 public class QuorumPeer extends ZooKeeperThread implements QuorumStats.Provider This class manages the quorum protocol. There are three states this server can be in:- Leader election - each server will elect a leader (proposing itself as a leader initially).
- Follower - the server will synchronize with the leader and replicate any transactions.
- Leader - the server will process requests and forward them to followers. A majority of followers must log the request before it can be accepted.
 int xid; long myid; long leader_id; long leader_zxid; The request for the current leader will consist solely of an xid: int xid;
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classQuorumPeer.AddressTuplestatic classQuorumPeer.LearnerTypestatic classQuorumPeer.QuorumServerstatic classQuorumPeer.ServerStatestatic classQuorumPeer.SyncMode(Used for monitoring) When peer is in synchronization phase, this shows which synchronization mechanism is being usedstatic classQuorumPeer.ZabState(Used for monitoring) shows the current phase of Zab protocol that peer is running.- 
Nested classes/interfaces inherited from class java.lang.ThreadThread.State, Thread.UncaughtExceptionHandler
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static StringACCEPTED_EPOCH_FILENAMEprotected intclientPortListenBacklogThe ZooKeeper server's socket backlog length.static StringCONFIG_DEFAULT_KERBEROS_CANONICALIZE_HOST_NAMESstatic StringCONFIG_DEFAULT_MULTI_ADDRESS_ENABLEDstatic StringCONFIG_KEY_KERBEROS_CANONICALIZE_HOST_NAMESstatic StringCONFIG_KEY_MULTI_ADDRESS_ENABLEDstatic StringCONFIG_KEY_MULTI_ADDRESS_REACHABILITY_CHECK_ENABLEDstatic StringCONFIG_KEY_MULTI_ADDRESS_REACHABILITY_CHECK_TIMEOUT_MSprotected intconnectToLearnerMasterLimitThe number of ticks that can pass before retrying to connect to learner masterstatic StringCURRENT_EPOCH_FILENAMElongend_flestatic StringFLE_TIME_UNITFollowerfollowerprotected intinitLimitThe number of ticks that the initial synchronization phase can takeLeaderleaderprotected booleanlocalSessionsEnabledWhether learners in this quorum should create new sessions as local.protected booleanlocalSessionsUpgradingEnabledWhether learners in this quorum should upgrade local sessions to global.protected intmaxSessionTimeoutMaximum number of milliseconds to allow for session timeout.protected intminSessionTimeoutMinimum number of milliseconds to allow for session timeout.Observerobserverstatic StringQUORUM_CNXN_TIMEOUT_MSprotected intquorumCnxnThreadsSizeThe maximum number of threads to allow in the connectionExecutors thread pool which will be used to initiate quorum server connections.protected StringquorumLearnerLoginContextQuorum learner login context name in jaas-conf file to read the kerberos security details.protected booleanquorumLearnerSaslAuthRequiredIf this is false, quorum peer learner will talk to quorum peer server without authentication.protected booleanquorumListenOnAllIPsWhether or not to listen on all IPs for the two quorum ports (broadcast and fast leader election).protected booleanquorumSaslEnableAuthEnable/Disables quorum authentication using sasl.protected StringquorumServerLoginContextQuorum server login context name in jaas-conf file to read the kerberos security details.protected booleanquorumServerSaslAuthRequiredIf this is false, quorum peer server will accept another quorum peer client connection even if the authentication did not succeed.protected StringquorumServicePrincipalKerberos quorum service principal.longstart_flestatic StringSYNC_ENABLEDThe syncEnabled can also be set via a system property.protected booleansyncEnabledEnables/Disables sync request processor.protected intsyncLimitThe number of ticks that can pass between sending a request and getting an acknowledgmentprotected AtomicIntegertickThe current tickprotected inttickTimeThe number of milliseconds of each tick- 
Fields inherited from class java.lang.ThreadMAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 - 
Fields inherited from interface org.apache.zookeeper.server.quorum.QuorumStats.ProviderFOLLOWING_STATE, LEADING_STATE, LOOKING_STATE, OBSERVING_STATE, UNKNOWN_STATE
 
- 
 - 
Constructor SummaryConstructors Constructor Description QuorumPeer()QuorumPeer(Map<Long,QuorumPeer.QuorumServer> quorumPeers, File snapDir, File logDir, int clientPort, int electionAlg, long myid, int tickTime, int initLimit, int syncLimit, int connectToLearnerMasterLimit)This constructor is only used by the existing unit test code.QuorumPeer(Map<Long,QuorumPeer.QuorumServer> quorumPeers, File snapDir, File logDir, int clientPort, int electionAlg, long myid, int tickTime, int initLimit, int syncLimit, int connectToLearnerMasterLimit, String oraclePath)QuorumPeer(Map<Long,QuorumPeer.QuorumServer> quorumPeers, File snapDir, File logDir, int clientPort, int electionAlg, long myid, int tickTime, int initLimit, int syncLimit, int connectToLearnerMasterLimit, QuorumVerifier quorumConfig)This constructor is only used by the existing unit test code.QuorumPeer(Map<Long,QuorumPeer.QuorumServer> quorumPeers, File dataDir, File dataLogDir, int electionType, long myid, int tickTime, int initLimit, int syncLimit, int connectToLearnerMasterLimit, boolean quorumListenOnAllIPs, ServerCnxnFactory cnxnFactory, QuorumVerifier quorumConfig)QuorumPeer(Map<Long,QuorumPeer.QuorumServer> quorumPeers, File dataDir, File dataLogDir, int electionType, long myid, int tickTime, int initLimit, int syncLimit, int connectToLearnerMasterLimit, ServerCnxnFactory cnxnFactory)For backward compatibility purposes, we instantiate QuorumMaj by default.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanareLocalSessionsEnabled()Whether local sessions are enabledvoidcloseAllConnections()QuorumVerifierconfigFromString(String s)protected static intcountParticipants(Map<Long,QuorumPeer.QuorumServer> peers)Count the number of nodes in the map that could be followers.QuorumCnxManagercreateCnxnManager()protected ElectioncreateElectionAlgorithm(int electionAlgorithm)static QuorumPeercreateFromConfig(QuorumPeerConfig config)Create a new QuorumPeer and apply all the values per the already-parsed config.voidenableLocalSessions(boolean flag)Whether to enable local sessionsvoidenableLocalSessionsUpgrading(boolean flag)Whether to allow local sessions to upgrade to global sessionslonggetAcceptedEpoch()ZooKeeperServergetActiveServer()InetSocketAddressgetClientAddress()intgetClientPort()intgetClientPortListenBacklog()The server socket's listen backlog lengthintgetConnectToLearnerMasterLimit()Get the connectToLearnerMasterLimitSet<Long>getCurrentAndNextConfigVoters()longgetCurrentEpoch()VotegetCurrentVote()StringgetDetailedPeerState()MultipleAddressesgetElectionAddress()ElectiongetElectionAlg()Get an instance of LeaderElectionintgetElectionType()Gets the election typeStringgetInitialConfig()intgetInitLimit()Get the number of ticks that the initial synchronization phase can takelonggetLastLoggedZxid()returns the highest zxid that this host has seenQuorumVerifiergetLastSeenQuorumVerifier()Return QuorumVerifier object for the last proposed configuration.StringgetLeaderAddress()longgetLeaderId()QuorumPeer.LearnerTypegetLearnerType()intgetMaxClientCnxnsPerHost()Maximum number of connections allowed from particular host (ip)intgetMaxSessionTimeout()maximum session timeout in millisecondsintgetMinSessionTimeout()minimum session timeout in millisecondsintgetMultiAddressReachabilityCheckTimeoutMs()longgetMyId()get the id of this quorum peer.StringgetNextDynamicConfigFilename()intgetObserverMasterPort()Map<Long,QuorumPeer.QuorumServer>getObservingView()Returns only observers, no followers.QuorumPeer.ServerStategetPeerState()MultipleAddressesgetQuorumAddress()QuorumCnxManagergetQuorumCnxManager()get reference to QuorumCnxManagerbooleangetQuorumListenOnAllIPs()String[]getQuorumPeers()Only used by QuorumStats at the momentintgetQuorumSize()QuorumVerifiergetQuorumVerifier()Return QuorumVerifier object for the last committed configuration.StringgetServerState()IntegergetSynced_observers_metric()booleangetSyncEnabled()Return syncEnabled.intgetSyncLimit()Get the synclimitQuorumPeer.SyncModegetSyncMode()intgetTick()Get the current tickintgetTickTime()Get the number of milliseconds of each tickFileTxnSnapLoggetTxnFactory()Map<Long,QuorumPeer.QuorumServer>getView()A 'view' is a node's current opinion of the membership of the entire ensemble.Map<Long,QuorumPeer.QuorumServer>getVotingView()Observers are not contained in this view, only nodes with PeerType=PARTICIPANT.QuorumPeer.ZabStategetZabState()protected ZKDatabasegetZkDb()voidinitConfigInZKDatabase()voidinitialize()booleanisLocalSessionsUpgradingEnabled()Whether local sessions are allowed to upgrade to global sessionsbooleanisMultiAddressEnabled()booleanisMultiAddressReachabilityCheckEnabled()booleanisReconfigEnabled()booleanisReconfigStateChange()booleanisRunning()booleanisSslQuorum()protected FollowermakeFollower(FileTxnSnapLog logFactory)protected LeadermakeLeader(FileTxnSnapLog logFactory)protected ElectionmakeLEStrategy()protected ObservermakeObserver(FileTxnSnapLog logFactory)booleanprocessReconfig(QuorumVerifier qv, Long suggestedLeaderId, Long zxid, boolean restartLE)voidreconfigFlagClear()voidreconfigFlagSet()voidrecreateSocketAddresses(long id)Resolves hostname for a given server ID.voidrestartLeaderElection(QuorumVerifier qvOLD, QuorumVerifier qvNEW)voidrun()voidsetAcceptedEpoch(long e)voidsetClientPortListenBacklog(int backlog)Sets the server socket's listen backlog length.voidsetCnxnFactory(ServerCnxnFactory cnxnFactory)protected voidsetConfigFileName(String s)voidsetConnectToLearnerMasterLimit(int connectToLearnerMasterLimit)Set the connectToLearnerMasterLimitvoidsetCurrentEpoch(long e)voidsetCurrentVote(Vote v)voidsetElectionType(int electionType)Sets the election typeprotected voidsetFollower(Follower newFollower)voidsetInitialConfig(String initialConfig)voidsetInitLimit(int initLimit)Set the number of ticks that the initial synchronization phase can takevoidsetJvmPauseMonitor(JvmPauseMonitor jvmPauseMonitor)voidsetLastSeenQuorumVerifier(QuorumVerifier qv, boolean writeToDisk)protected voidsetLeader(Leader newLeader)voidsetLeaderAddressAndId(MultipleAddresses addr, long newId)voidsetLearnerType(QuorumPeer.LearnerType p)Sets the LearnerTypevoidsetMaxSessionTimeout(int max)maximum session timeout in millisecondsvoidsetMinSessionTimeout(int min)minimum session timeout in millisecondsvoidsetMultiAddressEnabled(boolean multiAddressEnabled)voidsetMultiAddressReachabilityCheckEnabled(boolean multiAddressReachabilityCheckEnabled)voidsetMultiAddressReachabilityCheckTimeoutMs(int multiAddressReachabilityCheckTimeoutMs)voidsetMyid(long myid)set the id of this quorum peer.protected voidsetObserver(Observer newObserver)voidsetObserverMasterPort(int observerMasterPort)voidsetPeerState(QuorumPeer.ServerState newState)voidsetQuorumListenOnAllIPs(boolean quorumListenOnAllIPs)QuorumVerifiersetQuorumVerifier(QuorumVerifier qv, boolean writeToDisk)voidsetSecureCnxnFactory(ServerCnxnFactory secureCnxnFactory)voidsetSslQuorum(boolean sslQuorum)voidsetSyncEnabled(boolean syncEnabled)Set syncEnabled.voidsetSyncLimit(int syncLimit)Set the synclimitvoidsetSyncMode(QuorumPeer.SyncMode syncMode)voidsetTickTime(int tickTime)Set the number of milliseconds of each tickvoidsetTxnFactory(FileTxnSnapLog factory)voidsetUsePortUnification(boolean shouldUsePortUnification)voidsetZabState(QuorumPeer.ZabState zabState)voidsetZKDatabase(ZKDatabase database)set zk database for this nodevoidsetZooKeeperServer(ZooKeeperServer zks)booleanshouldUsePortUnification()voidshutdown()voidstart()voidstartLeaderElection()voidstopLeaderElection()static QuorumPeertestingQuorumPeer()protected voidupdateElectionVote(long newEpoch)Updates leader election info to avoid inconsistencies when a new server tries to join the ensemble.booleanviewContains(Long sid)Check if a node is in the current view.- 
Methods inherited from class org.apache.zookeeper.server.ZooKeeperThreadhandleException
 - 
Methods inherited from class java.lang.ThreadactiveCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
 
- 
 
- 
- 
- 
Field Detail- 
CONFIG_KEY_KERBEROS_CANONICALIZE_HOST_NAMESpublic static final String CONFIG_KEY_KERBEROS_CANONICALIZE_HOST_NAMES - See Also:
- Constant Field Values
 
 - 
CONFIG_DEFAULT_KERBEROS_CANONICALIZE_HOST_NAMESpublic static final String CONFIG_DEFAULT_KERBEROS_CANONICALIZE_HOST_NAMES - See Also:
- Constant Field Values
 
 - 
CONFIG_KEY_MULTI_ADDRESS_ENABLEDpublic static final String CONFIG_KEY_MULTI_ADDRESS_ENABLED - See Also:
- Constant Field Values
 
 - 
CONFIG_DEFAULT_MULTI_ADDRESS_ENABLEDpublic static final String CONFIG_DEFAULT_MULTI_ADDRESS_ENABLED - See Also:
- Constant Field Values
 
 - 
CONFIG_KEY_MULTI_ADDRESS_REACHABILITY_CHECK_TIMEOUT_MSpublic static final String CONFIG_KEY_MULTI_ADDRESS_REACHABILITY_CHECK_TIMEOUT_MS - See Also:
- Constant Field Values
 
 - 
CONFIG_KEY_MULTI_ADDRESS_REACHABILITY_CHECK_ENABLEDpublic static final String CONFIG_KEY_MULTI_ADDRESS_REACHABILITY_CHECK_ENABLED - See Also:
- Constant Field Values
 
 - 
start_flepublic long start_fle 
 - 
end_flepublic long end_fle 
 - 
FLE_TIME_UNITpublic static final String FLE_TIME_UNIT - See Also:
- Constant Field Values
 
 - 
tickTimeprotected int tickTime The number of milliseconds of each tick
 - 
localSessionsEnabledprotected boolean localSessionsEnabled Whether learners in this quorum should create new sessions as local. False by default to preserve existing behavior.
 - 
localSessionsUpgradingEnabledprotected boolean localSessionsUpgradingEnabled Whether learners in this quorum should upgrade local sessions to global. Only matters if local sessions are enabled.
 - 
minSessionTimeoutprotected int minSessionTimeout Minimum number of milliseconds to allow for session timeout. A value of -1 indicates unset, use default.
 - 
maxSessionTimeoutprotected int maxSessionTimeout Maximum number of milliseconds to allow for session timeout. A value of -1 indicates unset, use default.
 - 
clientPortListenBacklogprotected int clientPortListenBacklog The ZooKeeper server's socket backlog length. The number of connections that will be queued to be read before new connections are dropped. A value of one indicates the default backlog will be used.
 - 
initLimitprotected volatile int initLimit The number of ticks that the initial synchronization phase can take
 - 
syncLimitprotected volatile int syncLimit The number of ticks that can pass between sending a request and getting an acknowledgment
 - 
connectToLearnerMasterLimitprotected volatile int connectToLearnerMasterLimit The number of ticks that can pass before retrying to connect to learner master
 - 
syncEnabledprotected boolean syncEnabled Enables/Disables sync request processor. This option is enabled by default and is to be used with observers.
 - 
tickprotected AtomicInteger tick The current tick
 - 
quorumListenOnAllIPsprotected boolean quorumListenOnAllIPs Whether or not to listen on all IPs for the two quorum ports (broadcast and fast leader election).
 - 
quorumSaslEnableAuthprotected boolean quorumSaslEnableAuth Enable/Disables quorum authentication using sasl. Defaulting to false.
 - 
quorumServerSaslAuthRequiredprotected boolean quorumServerSaslAuthRequired If this is false, quorum peer server will accept another quorum peer client connection even if the authentication did not succeed. This can be used while upgrading ZooKeeper server. Defaulting to false (required).
 - 
quorumLearnerSaslAuthRequiredprotected boolean quorumLearnerSaslAuthRequired If this is false, quorum peer learner will talk to quorum peer server without authentication. This can be used while upgrading ZooKeeper server. Defaulting to false (required).
 - 
quorumServicePrincipalprotected String quorumServicePrincipal Kerberos quorum service principal. Defaulting to 'zkquorum/localhost'.
 - 
quorumLearnerLoginContextprotected String quorumLearnerLoginContext Quorum learner login context name in jaas-conf file to read the kerberos security details. Defaulting to 'QuorumLearner'.
 - 
quorumServerLoginContextprotected String quorumServerLoginContext Quorum server login context name in jaas-conf file to read the kerberos security details. Defaulting to 'QuorumServer'.
 - 
quorumCnxnThreadsSizeprotected int quorumCnxnThreadsSize The maximum number of threads to allow in the connectionExecutors thread pool which will be used to initiate quorum server connections.
 - 
QUORUM_CNXN_TIMEOUT_MSpublic static final String QUORUM_CNXN_TIMEOUT_MS - See Also:
- Constant Field Values
 
 - 
followerpublic Follower follower 
 - 
leaderpublic Leader leader 
 - 
observerpublic Observer observer 
 - 
SYNC_ENABLEDpublic static final String SYNC_ENABLED The syncEnabled can also be set via a system property.- See Also:
- Constant Field Values
 
 - 
CURRENT_EPOCH_FILENAMEpublic static final String CURRENT_EPOCH_FILENAME - See Also:
- Constant Field Values
 
 - 
ACCEPTED_EPOCH_FILENAMEpublic static final String ACCEPTED_EPOCH_FILENAME - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
QuorumPeerpublic QuorumPeer() throws SaslException- Throws:
- SaslException
 
 - 
QuorumPeerpublic QuorumPeer(Map<Long,QuorumPeer.QuorumServer> quorumPeers, File dataDir, File dataLogDir, int electionType, long myid, int tickTime, int initLimit, int syncLimit, int connectToLearnerMasterLimit, ServerCnxnFactory cnxnFactory) throws IOException For backward compatibility purposes, we instantiate QuorumMaj by default.- Throws:
- IOException
 
 - 
QuorumPeerpublic QuorumPeer(Map<Long,QuorumPeer.QuorumServer> quorumPeers, File dataDir, File dataLogDir, int electionType, long myid, int tickTime, int initLimit, int syncLimit, int connectToLearnerMasterLimit, boolean quorumListenOnAllIPs, ServerCnxnFactory cnxnFactory, QuorumVerifier quorumConfig) throws IOException - Throws:
- IOException
 
 - 
QuorumPeerpublic QuorumPeer(Map<Long,QuorumPeer.QuorumServer> quorumPeers, File snapDir, File logDir, int clientPort, int electionAlg, long myid, int tickTime, int initLimit, int syncLimit, int connectToLearnerMasterLimit) throws IOException This constructor is only used by the existing unit test code. It defaults to FileLogProvider persistence provider.- Throws:
- IOException
 
 - 
QuorumPeerpublic QuorumPeer(Map<Long,QuorumPeer.QuorumServer> quorumPeers, File snapDir, File logDir, int clientPort, int electionAlg, long myid, int tickTime, int initLimit, int syncLimit, int connectToLearnerMasterLimit, String oraclePath) throws IOException - Throws:
- IOException
 
 - 
QuorumPeerpublic QuorumPeer(Map<Long,QuorumPeer.QuorumServer> quorumPeers, File snapDir, File logDir, int clientPort, int electionAlg, long myid, int tickTime, int initLimit, int syncLimit, int connectToLearnerMasterLimit, QuorumVerifier quorumConfig) throws IOException This constructor is only used by the existing unit test code. It defaults to FileLogProvider persistence provider.- Throws:
- IOException
 
 
- 
 - 
Method Detail- 
getObserverMasterPortpublic int getObserverMasterPort() 
 - 
setObserverMasterPortpublic void setObserverMasterPort(int observerMasterPort) 
 - 
isMultiAddressEnabledpublic boolean isMultiAddressEnabled() 
 - 
setMultiAddressEnabledpublic void setMultiAddressEnabled(boolean multiAddressEnabled) 
 - 
getMultiAddressReachabilityCheckTimeoutMspublic int getMultiAddressReachabilityCheckTimeoutMs() 
 - 
setMultiAddressReachabilityCheckTimeoutMspublic void setMultiAddressReachabilityCheckTimeoutMs(int multiAddressReachabilityCheckTimeoutMs) 
 - 
isMultiAddressReachabilityCheckEnabledpublic boolean isMultiAddressReachabilityCheckEnabled() 
 - 
setMultiAddressReachabilityCheckEnabledpublic void setMultiAddressReachabilityCheckEnabled(boolean multiAddressReachabilityCheckEnabled) 
 - 
getLearnerTypepublic QuorumPeer.LearnerType getLearnerType() 
 - 
setLearnerTypepublic void setLearnerType(QuorumPeer.LearnerType p) Sets the LearnerType
 - 
setConfigFileNameprotected void setConfigFileName(String s) 
 - 
getQuorumSizepublic int getQuorumSize() 
 - 
setJvmPauseMonitorpublic void setJvmPauseMonitor(JvmPauseMonitor jvmPauseMonitor) 
 - 
getMyIdpublic long getMyId() get the id of this quorum peer.
 - 
isSslQuorumpublic boolean isSslQuorum() 
 - 
shouldUsePortUnificationpublic boolean shouldUsePortUnification() 
 - 
getCurrentVotepublic Vote getCurrentVote() 
 - 
setCurrentVotepublic void setCurrentVote(Vote v) 
 - 
setPeerStatepublic void setPeerState(QuorumPeer.ServerState newState) 
 - 
setZabStatepublic void setZabState(QuorumPeer.ZabState zabState) 
 - 
setSyncModepublic void setSyncMode(QuorumPeer.SyncMode syncMode) 
 - 
getZabStatepublic QuorumPeer.ZabState getZabState() 
 - 
getSyncModepublic QuorumPeer.SyncMode getSyncMode() 
 - 
setLeaderAddressAndIdpublic void setLeaderAddressAndId(MultipleAddresses addr, long newId) 
 - 
getLeaderAddresspublic String getLeaderAddress() 
 - 
getLeaderIdpublic long getLeaderId() 
 - 
getDetailedPeerStatepublic String getDetailedPeerState() 
 - 
reconfigFlagSetpublic void reconfigFlagSet() 
 - 
reconfigFlagClearpublic void reconfigFlagClear() 
 - 
isReconfigStateChangepublic boolean isReconfigStateChange() 
 - 
getPeerStatepublic QuorumPeer.ServerState getPeerState() 
 - 
recreateSocketAddressespublic void recreateSocketAddresses(long id) Resolves hostname for a given server ID. This method resolves hostname for a given server ID in both quorumVerifer and lastSeenQuorumVerifier. If the server ID matches the local server ID, it also updates myAddrs.
 - 
getQuorumAddresspublic MultipleAddresses getQuorumAddress() 
 - 
getElectionAddresspublic MultipleAddresses getElectionAddress() 
 - 
getClientAddresspublic InetSocketAddress getClientAddress() 
 - 
testingQuorumPeerpublic static QuorumPeer testingQuorumPeer() throws SaslException - Throws:
- SaslException
 
 - 
initializepublic void initialize() throws SaslException- Throws:
- SaslException
 
 - 
stopLeaderElectionpublic void stopLeaderElection() 
 - 
startLeaderElectionpublic void startLeaderElection() 
 - 
countParticipantsprotected static int countParticipants(Map<Long,QuorumPeer.QuorumServer> peers) Count the number of nodes in the map that could be followers.- Parameters:
- peers-
- Returns:
- The number of followers in the map
 
 - 
getLastLoggedZxidpublic long getLastLoggedZxid() returns the highest zxid that this host has seen- Returns:
- the highest zxid for this host
 
 - 
makeFollowerprotected Follower makeFollower(FileTxnSnapLog logFactory) throws IOException - Throws:
- IOException
 
 - 
makeLeaderprotected Leader makeLeader(FileTxnSnapLog logFactory) throws IOException, X509Exception - Throws:
- IOException
- X509Exception
 
 - 
makeObserverprotected Observer makeObserver(FileTxnSnapLog logFactory) throws IOException - Throws:
- IOException
 
 - 
createElectionAlgorithmprotected Election createElectionAlgorithm(int electionAlgorithm) 
 - 
makeLEStrategyprotected Election makeLEStrategy() 
 - 
setLeaderprotected void setLeader(Leader newLeader) 
 - 
setFollowerprotected void setFollower(Follower newFollower) 
 - 
setObserverprotected void setObserver(Observer newObserver) 
 - 
getActiveServerpublic ZooKeeperServer getActiveServer() 
 - 
shutdownpublic void shutdown() 
 - 
getViewpublic Map<Long,QuorumPeer.QuorumServer> getView() A 'view' is a node's current opinion of the membership of the entire ensemble.
 - 
getVotingViewpublic Map<Long,QuorumPeer.QuorumServer> getVotingView() Observers are not contained in this view, only nodes with PeerType=PARTICIPANT.
 - 
getObservingViewpublic Map<Long,QuorumPeer.QuorumServer> getObservingView() Returns only observers, no followers.
 - 
viewContainspublic boolean viewContains(Long sid) Check if a node is in the current view. With static membership, the result of this check will never change; only when dynamic membership is introduced will this be more useful.
 - 
getQuorumPeerspublic String[] getQuorumPeers() Only used by QuorumStats at the moment- Specified by:
- getQuorumPeersin interface- QuorumStats.Provider
 
 - 
getServerStatepublic String getServerState() - Specified by:
- getServerStatein interface- QuorumStats.Provider
 
 - 
setMyidpublic void setMyid(long myid) set the id of this quorum peer.
 - 
setInitialConfigpublic void setInitialConfig(String initialConfig) 
 - 
getInitialConfigpublic String getInitialConfig() 
 - 
getTickTimepublic int getTickTime() Get the number of milliseconds of each tick
 - 
setTickTimepublic void setTickTime(int tickTime) Set the number of milliseconds of each tick
 - 
getMaxClientCnxnsPerHostpublic int getMaxClientCnxnsPerHost() Maximum number of connections allowed from particular host (ip)
 - 
areLocalSessionsEnabledpublic boolean areLocalSessionsEnabled() Whether local sessions are enabled
 - 
enableLocalSessionspublic void enableLocalSessions(boolean flag) Whether to enable local sessions
 - 
isLocalSessionsUpgradingEnabledpublic boolean isLocalSessionsUpgradingEnabled() Whether local sessions are allowed to upgrade to global sessions
 - 
enableLocalSessionsUpgradingpublic void enableLocalSessionsUpgrading(boolean flag) Whether to allow local sessions to upgrade to global sessions
 - 
getMinSessionTimeoutpublic int getMinSessionTimeout() minimum session timeout in milliseconds
 - 
setMinSessionTimeoutpublic void setMinSessionTimeout(int min) minimum session timeout in milliseconds
 - 
getMaxSessionTimeoutpublic int getMaxSessionTimeout() maximum session timeout in milliseconds
 - 
setMaxSessionTimeoutpublic void setMaxSessionTimeout(int max) maximum session timeout in milliseconds
 - 
getClientPortListenBacklogpublic int getClientPortListenBacklog() The server socket's listen backlog length
 - 
setClientPortListenBacklogpublic void setClientPortListenBacklog(int backlog) Sets the server socket's listen backlog length.
 - 
getInitLimitpublic int getInitLimit() Get the number of ticks that the initial synchronization phase can take
 - 
setInitLimitpublic void setInitLimit(int initLimit) Set the number of ticks that the initial synchronization phase can take
 - 
getTickpublic int getTick() Get the current tick
 - 
configFromStringpublic QuorumVerifier configFromString(String s) throws IOException, QuorumPeerConfig.ConfigException 
 - 
getQuorumVerifierpublic QuorumVerifier getQuorumVerifier() Return QuorumVerifier object for the last committed configuration.
 - 
getLastSeenQuorumVerifierpublic QuorumVerifier getLastSeenQuorumVerifier() Return QuorumVerifier object for the last proposed configuration.
 - 
restartLeaderElectionpublic void restartLeaderElection(QuorumVerifier qvOLD, QuorumVerifier qvNEW) 
 - 
getNextDynamicConfigFilenamepublic String getNextDynamicConfigFilename() 
 - 
setLastSeenQuorumVerifierpublic void setLastSeenQuorumVerifier(QuorumVerifier qv, boolean writeToDisk) 
 - 
setQuorumVerifierpublic QuorumVerifier setQuorumVerifier(QuorumVerifier qv, boolean writeToDisk) 
 - 
getElectionAlgpublic Election getElectionAlg() Get an instance of LeaderElection
 - 
getSyncLimitpublic int getSyncLimit() Get the synclimit
 - 
setSyncLimitpublic void setSyncLimit(int syncLimit) Set the synclimit
 - 
getConnectToLearnerMasterLimitpublic int getConnectToLearnerMasterLimit() Get the connectToLearnerMasterLimit
 - 
setConnectToLearnerMasterLimitpublic void setConnectToLearnerMasterLimit(int connectToLearnerMasterLimit) Set the connectToLearnerMasterLimit
 - 
getSyncEnabledpublic boolean getSyncEnabled() Return syncEnabled.
 - 
setSyncEnabledpublic void setSyncEnabled(boolean syncEnabled) Set syncEnabled.- Parameters:
- syncEnabled-
 
 - 
getElectionTypepublic int getElectionType() Gets the election type
 - 
setElectionTypepublic void setElectionType(int electionType) Sets the election type
 - 
getQuorumListenOnAllIPspublic boolean getQuorumListenOnAllIPs() 
 - 
setQuorumListenOnAllIPspublic void setQuorumListenOnAllIPs(boolean quorumListenOnAllIPs) 
 - 
setCnxnFactorypublic void setCnxnFactory(ServerCnxnFactory cnxnFactory) 
 - 
setSecureCnxnFactorypublic void setSecureCnxnFactory(ServerCnxnFactory secureCnxnFactory) 
 - 
setSslQuorumpublic void setSslQuorum(boolean sslQuorum) 
 - 
setUsePortUnificationpublic void setUsePortUnification(boolean shouldUsePortUnification) 
 - 
setZooKeeperServerpublic void setZooKeeperServer(ZooKeeperServer zks) 
 - 
closeAllConnectionspublic void closeAllConnections() 
 - 
getClientPortpublic int getClientPort() 
 - 
setTxnFactorypublic void setTxnFactory(FileTxnSnapLog factory) 
 - 
getTxnFactorypublic FileTxnSnapLog getTxnFactory() 
 - 
setZKDatabasepublic void setZKDatabase(ZKDatabase database) set zk database for this node- Parameters:
- database-
 
 - 
getZkDbprotected ZKDatabase getZkDb() 
 - 
initConfigInZKDatabasepublic void initConfigInZKDatabase() 
 - 
isRunningpublic boolean isRunning() 
 - 
getQuorumCnxManagerpublic QuorumCnxManager getQuorumCnxManager() get reference to QuorumCnxManager
 - 
getCurrentEpochpublic long getCurrentEpoch() throws IOException- Throws:
- IOException
 
 - 
getAcceptedEpochpublic long getAcceptedEpoch() throws IOException- Throws:
- IOException
 
 - 
setCurrentEpochpublic void setCurrentEpoch(long e) throws IOException- Throws:
- IOException
 
 - 
setAcceptedEpochpublic void setAcceptedEpoch(long e) throws IOException- Throws:
- IOException
 
 - 
processReconfigpublic boolean processReconfig(QuorumVerifier qv, Long suggestedLeaderId, Long zxid, boolean restartLE) 
 - 
updateElectionVoteprotected void updateElectionVote(long newEpoch) Updates leader election info to avoid inconsistencies when a new server tries to join the ensemble. Here is the inconsistency scenario we try to solve by updating the peer epoch after following leader: Let's say we have an ensemble with 3 servers z1, z2 and z3. 1. z1, z2 were following z3 with peerEpoch to be 0xb8, the new epoch is 0xb9, aka current accepted epoch on disk. 2. z2 get restarted, which will use 0xb9 as it's peer epoch when loading the current accept epoch from disk. 3. z2 received notification from z1 and z3, which is following z3 with epoch 0xb8, so it started following z3 again with peer epoch 0xb8. 4. before z2 successfully connected to z3, z3 get restarted with new epoch 0xb9. 5. z2 will retry around a few round (default 5s) before giving up, meanwhile it will report z3 as leader. 6. z1 restarted, and looking with peer epoch 0xb9. 7. z1 voted z3, and z3 was elected as leader again with peer epoch 0xb9. 8. z2 successfully connected to z3 before giving up, but with peer epoch 0xb8. 9. z1 get restarted, looking for leader with peer epoch 0xba, but cannot join, because z2 is reporting peer epoch 0xb8, while z3 is reporting 0xb9. By updating the election vote after actually following leader, we can avoid this kind of stuck happened. Btw, the zxid and electionEpoch could be inconsistent because of the same reason, it's better to update these as well after syncing with leader, but that required protocol change which is non trivial. This problem is worked around by skipping comparing the zxid and electionEpoch when counting for votes for out of election servers during looking for leader. See https://issues.apache.org/jira/browse/ZOOKEEPER-1732
 - 
createCnxnManagerpublic QuorumCnxManager createCnxnManager() 
 - 
isReconfigEnabledpublic boolean isReconfigEnabled() 
 - 
getSynced_observers_metric@Private public Integer getSynced_observers_metric() 
 - 
createFromConfigpublic static QuorumPeer createFromConfig(QuorumPeerConfig config) throws IOException Create a new QuorumPeer and apply all the values per the already-parsed config.- Parameters:
- config- The appertained quorum peer config.
- Returns:
- A QuorumPeer instantiated with specified peer config. Note this peer is not fully initialized; caller should finish initialization through additional configurations (connection factory settings, etc).
- Throws:
- IOException
 
 
- 
 
-