public class QuorumPeer extends ZooKeeperThread implements QuorumStats.Provider
int xid; long myid; long leader_id; long leader_zxid;The request for the current leader will consist solely of an xid: int xid;
Modifier and Type | Class and Description |
---|---|
static class |
QuorumPeer.AddressTuple |
static class |
QuorumPeer.LearnerType |
static class |
QuorumPeer.QuorumServer |
static class |
QuorumPeer.ServerState |
static class |
QuorumPeer.SyncMode
(Used for monitoring) When peer is in synchronization phase, this shows
which synchronization mechanism is being used
|
static class |
QuorumPeer.ZabState
(Used for monitoring) shows the current phase of
Zab protocol that peer is running.
|
Thread.State, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
static String |
ACCEPTED_EPOCH_FILENAME |
protected int |
clientPortListenBacklog
The ZooKeeper server's socket backlog length.
|
static String |
CONFIG_DEFAULT_MULTI_ADDRESS_ENABLED |
static String |
CONFIG_KEY_MULTI_ADDRESS_ENABLED |
static String |
CONFIG_KEY_MULTI_ADDRESS_REACHABILITY_CHECK_ENABLED |
static String |
CONFIG_KEY_MULTI_ADDRESS_REACHABILITY_CHECK_TIMEOUT_MS |
protected int |
connectToLearnerMasterLimit
The number of ticks that can pass before retrying to connect to learner master
|
static String |
CURRENT_EPOCH_FILENAME |
long |
end_fle |
static String |
FLE_TIME_UNIT |
Follower |
follower |
protected int |
initLimit
The number of ticks that the initial synchronization phase can take
|
Leader |
leader |
protected boolean |
localSessionsEnabled
Whether learners in this quorum should create new sessions as local.
|
protected boolean |
localSessionsUpgradingEnabled
Whether learners in this quorum should upgrade local sessions to
global.
|
protected int |
maxSessionTimeout
Maximum number of milliseconds to allow for session timeout.
|
protected int |
minSessionTimeout
Minimum number of milliseconds to allow for session timeout.
|
Observer |
observer |
static String |
QUORUM_CNXN_TIMEOUT_MS |
protected int |
quorumCnxnThreadsSize
The maximum number of threads to allow in the connectionExecutors thread
pool which will be used to initiate quorum server connections.
|
protected String |
quorumLearnerLoginContext
Quorum learner login context name in jaas-conf file to read the kerberos
security details.
|
protected boolean |
quorumLearnerSaslAuthRequired
If this is false, quorum peer learner will talk to quorum peer server
without authentication.
|
protected boolean |
quorumListenOnAllIPs
Whether or not to listen on all IPs for the two quorum ports
(broadcast and fast leader election).
|
protected boolean |
quorumSaslEnableAuth
Enable/Disables quorum authentication using sasl.
|
protected String |
quorumServerLoginContext
Quorum server login context name in jaas-conf file to read the kerberos
security details.
|
protected boolean |
quorumServerSaslAuthRequired
If this is false, quorum peer server will accept another quorum peer client
connection even if the authentication did not succeed.
|
protected String |
quorumServicePrincipal
Kerberos quorum service principal.
|
long |
start_fle |
static String |
SYNC_ENABLED
The syncEnabled can also be set via a system property.
|
protected boolean |
syncEnabled
Enables/Disables sync request processor.
|
protected int |
syncLimit
The number of ticks that can pass between sending a request and getting
an acknowledgment
|
protected AtomicInteger |
tick
The current tick
|
protected int |
tickTime
The number of milliseconds of each tick
|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
FOLLOWING_STATE, LEADING_STATE, LOOKING_STATE, OBSERVING_STATE, UNKNOWN_STATE
Constructor and 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,
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.
|
Modifier and Type | Method and Description |
---|---|
boolean |
areLocalSessionsEnabled()
Whether local sessions are enabled
|
void |
closeAllConnections() |
QuorumVerifier |
configFromString(String s) |
protected static int |
countParticipants(Map<Long,QuorumPeer.QuorumServer> peers)
Count the number of nodes in the map that could be followers.
|
QuorumCnxManager |
createCnxnManager() |
protected Election |
createElectionAlgorithm(int electionAlgorithm) |
void |
enableLocalSessions(boolean flag)
Whether to enable local sessions
|
void |
enableLocalSessionsUpgrading(boolean flag)
Whether to allow local sessions to upgrade to global sessions
|
long |
getAcceptedEpoch() |
ZooKeeperServer |
getActiveServer() |
InetSocketAddress |
getClientAddress() |
int |
getClientPort() |
int |
getClientPortListenBacklog()
The server socket's listen backlog length
|
int |
getConnectToLearnerMasterLimit()
Get the connectToLearnerMasterLimit
|
Set<Long> |
getCurrentAndNextConfigVoters() |
long |
getCurrentEpoch() |
Vote |
getCurrentVote() |
String |
getDetailedPeerState() |
MultipleAddresses |
getElectionAddress() |
Election |
getElectionAlg()
Get an instance of LeaderElection
|
int |
getElectionType()
Gets the election type
|
long |
getId()
get the id of this quorum peer.
|
String |
getInitialConfig() |
int |
getInitLimit()
Get the number of ticks that the initial synchronization phase can take
|
long |
getLastLoggedZxid()
returns the highest zxid that this host has seen
|
QuorumVerifier |
getLastSeenQuorumVerifier()
Return QuorumVerifier object for the last proposed configuration.
|
String |
getLeaderAddress() |
long |
getLeaderId() |
QuorumPeer.LearnerType |
getLearnerType() |
int |
getMaxClientCnxnsPerHost()
Maximum number of connections allowed from particular host (ip)
|
int |
getMaxSessionTimeout()
maximum session timeout in milliseconds
|
int |
getMinSessionTimeout()
minimum session timeout in milliseconds
|
int |
getMultiAddressReachabilityCheckTimeoutMs() |
String |
getNextDynamicConfigFilename() |
int |
getObserverMasterPort() |
Map<Long,QuorumPeer.QuorumServer> |
getObservingView()
Returns only observers, no followers.
|
QuorumPeer.ServerState |
getPeerState() |
MultipleAddresses |
getQuorumAddress() |
QuorumCnxManager |
getQuorumCnxManager()
get reference to QuorumCnxManager
|
boolean |
getQuorumListenOnAllIPs() |
String[] |
getQuorumPeers()
Only used by QuorumStats at the moment
|
int |
getQuorumSize() |
QuorumVerifier |
getQuorumVerifier()
Return QuorumVerifier object for the last committed configuration.
|
String |
getServerState() |
Integer |
getSynced_observers_metric() |
boolean |
getSyncEnabled()
Return syncEnabled.
|
int |
getSyncLimit()
Get the synclimit
|
QuorumPeer.SyncMode |
getSyncMode() |
int |
getTick()
Get the current tick
|
int |
getTickTime()
Get the number of milliseconds of each tick
|
FileTxnSnapLog |
getTxnFactory() |
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.ZabState |
getZabState() |
protected ZKDatabase |
getZkDb() |
void |
initConfigInZKDatabase() |
void |
initialize() |
boolean |
isLocalSessionsUpgradingEnabled()
Whether local sessions are allowed to upgrade to global sessions
|
boolean |
isMultiAddressEnabled() |
boolean |
isMultiAddressReachabilityCheckEnabled() |
boolean |
isReconfigStateChange() |
boolean |
isRunning() |
boolean |
isSslQuorum() |
protected Follower |
makeFollower(FileTxnSnapLog logFactory) |
protected Leader |
makeLeader(FileTxnSnapLog logFactory) |
protected Election |
makeLEStrategy() |
protected Observer |
makeObserver(FileTxnSnapLog logFactory) |
boolean |
processReconfig(QuorumVerifier qv,
Long suggestedLeaderId,
Long zxid,
boolean restartLE) |
void |
reconfigFlagClear() |
void |
reconfigFlagSet() |
void |
recreateSocketAddresses(long id)
Resolves hostname for a given server ID.
|
void |
restartLeaderElection(QuorumVerifier qvOLD,
QuorumVerifier qvNEW) |
void |
run() |
void |
setAcceptedEpoch(long e) |
void |
setClientPortListenBacklog(int backlog)
Sets the server socket's listen backlog length.
|
void |
setCnxnFactory(ServerCnxnFactory cnxnFactory) |
protected void |
setConfigFileName(String s) |
void |
setConnectToLearnerMasterLimit(int connectToLearnerMasterLimit)
Set the connectToLearnerMasterLimit
|
void |
setCurrentEpoch(long e) |
void |
setCurrentVote(Vote v) |
void |
setElectionType(int electionType)
Sets the election type
|
protected void |
setFollower(Follower newFollower) |
void |
setInitialConfig(String initialConfig) |
void |
setInitLimit(int initLimit)
Set the number of ticks that the initial synchronization phase can take
|
void |
setJvmPauseMonitor(JvmPauseMonitor jvmPauseMonitor) |
void |
setLastSeenQuorumVerifier(QuorumVerifier qv,
boolean writeToDisk) |
protected void |
setLeader(Leader newLeader) |
void |
setLeaderAddressAndId(MultipleAddresses addr,
long newId) |
void |
setLearnerType(QuorumPeer.LearnerType p)
Sets the LearnerType
|
void |
setMaxSessionTimeout(int max)
maximum session timeout in milliseconds
|
void |
setMinSessionTimeout(int min)
minimum session timeout in milliseconds
|
void |
setMultiAddressEnabled(boolean multiAddressEnabled) |
void |
setMultiAddressReachabilityCheckEnabled(boolean multiAddressReachabilityCheckEnabled) |
void |
setMultiAddressReachabilityCheckTimeoutMs(int multiAddressReachabilityCheckTimeoutMs) |
void |
setMyid(long myid)
set the id of this quorum peer.
|
protected void |
setObserver(Observer newObserver) |
void |
setObserverMasterPort(int observerMasterPort) |
void |
setPeerState(QuorumPeer.ServerState newState) |
void |
setQuorumListenOnAllIPs(boolean quorumListenOnAllIPs) |
QuorumVerifier |
setQuorumVerifier(QuorumVerifier qv,
boolean writeToDisk) |
void |
setSecureCnxnFactory(ServerCnxnFactory secureCnxnFactory) |
void |
setSslQuorum(boolean sslQuorum) |
void |
setSyncEnabled(boolean syncEnabled)
Set syncEnabled.
|
void |
setSyncLimit(int syncLimit)
Set the synclimit
|
void |
setSyncMode(QuorumPeer.SyncMode syncMode) |
void |
setTickTime(int tickTime)
Set the number of milliseconds of each tick
|
void |
setTxnFactory(FileTxnSnapLog factory) |
void |
setUsePortUnification(boolean shouldUsePortUnification) |
void |
setZabState(QuorumPeer.ZabState zabState) |
void |
setZKDatabase(ZKDatabase database)
set zk database for this node
|
void |
setZooKeeperServer(ZooKeeperServer zks) |
boolean |
shouldUsePortUnification() |
void |
shutdown() |
void |
start() |
void |
startLeaderElection() |
void |
stopLeaderElection() |
static QuorumPeer |
testingQuorumPeer() |
protected void |
updateElectionVote(long newEpoch)
Updates leader election info to avoid inconsistencies when
a new server tries to join the ensemble.
|
boolean |
viewContains(Long sid)
Check if a node is in the current view.
|
handleException
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, 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
public static final String CONFIG_KEY_MULTI_ADDRESS_ENABLED
public static final String CONFIG_DEFAULT_MULTI_ADDRESS_ENABLED
public static final String CONFIG_KEY_MULTI_ADDRESS_REACHABILITY_CHECK_TIMEOUT_MS
public static final String CONFIG_KEY_MULTI_ADDRESS_REACHABILITY_CHECK_ENABLED
public long start_fle
public long end_fle
public static final String FLE_TIME_UNIT
protected int tickTime
protected boolean localSessionsEnabled
protected boolean localSessionsUpgradingEnabled
protected int minSessionTimeout
protected int maxSessionTimeout
protected int clientPortListenBacklog
protected volatile int initLimit
protected volatile int syncLimit
protected volatile int connectToLearnerMasterLimit
protected boolean syncEnabled
protected AtomicInteger tick
protected boolean quorumListenOnAllIPs
protected boolean quorumSaslEnableAuth
protected boolean quorumServerSaslAuthRequired
protected boolean quorumLearnerSaslAuthRequired
protected String quorumServicePrincipal
protected String quorumLearnerLoginContext
protected String quorumServerLoginContext
protected int quorumCnxnThreadsSize
public static final String QUORUM_CNXN_TIMEOUT_MS
public Follower follower
public Leader leader
public Observer observer
public static final String SYNC_ENABLED
public static final String CURRENT_EPOCH_FILENAME
public static final String ACCEPTED_EPOCH_FILENAME
public QuorumPeer() throws SaslException
SaslException
public 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
IOException
public 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
IOException
public 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
IOException
public 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
IOException
public int getObserverMasterPort()
public void setObserverMasterPort(int observerMasterPort)
public boolean isMultiAddressEnabled()
public void setMultiAddressEnabled(boolean multiAddressEnabled)
public int getMultiAddressReachabilityCheckTimeoutMs()
public void setMultiAddressReachabilityCheckTimeoutMs(int multiAddressReachabilityCheckTimeoutMs)
public boolean isMultiAddressReachabilityCheckEnabled()
public void setMultiAddressReachabilityCheckEnabled(boolean multiAddressReachabilityCheckEnabled)
public QuorumPeer.LearnerType getLearnerType()
public void setLearnerType(QuorumPeer.LearnerType p)
protected void setConfigFileName(String s)
public int getQuorumSize()
public void setJvmPauseMonitor(JvmPauseMonitor jvmPauseMonitor)
public boolean isSslQuorum()
public boolean shouldUsePortUnification()
public Vote getCurrentVote()
public void setCurrentVote(Vote v)
public void setPeerState(QuorumPeer.ServerState newState)
public void setZabState(QuorumPeer.ZabState zabState)
public void setSyncMode(QuorumPeer.SyncMode syncMode)
public QuorumPeer.ZabState getZabState()
public QuorumPeer.SyncMode getSyncMode()
public void setLeaderAddressAndId(MultipleAddresses addr, long newId)
public String getLeaderAddress()
public long getLeaderId()
public String getDetailedPeerState()
public void reconfigFlagSet()
public void reconfigFlagClear()
public boolean isReconfigStateChange()
public QuorumPeer.ServerState getPeerState()
public void recreateSocketAddresses(long id)
public MultipleAddresses getQuorumAddress()
public MultipleAddresses getElectionAddress()
public InetSocketAddress getClientAddress()
public static QuorumPeer testingQuorumPeer() throws SaslException
SaslException
public void initialize() throws SaslException
SaslException
public void stopLeaderElection()
public void startLeaderElection()
protected static int countParticipants(Map<Long,QuorumPeer.QuorumServer> peers)
peers
- public long getLastLoggedZxid()
protected Follower makeFollower(FileTxnSnapLog logFactory) throws IOException
IOException
protected Leader makeLeader(FileTxnSnapLog logFactory) throws IOException, X509Exception
IOException
X509Exception
protected Observer makeObserver(FileTxnSnapLog logFactory) throws IOException
IOException
protected Election createElectionAlgorithm(int electionAlgorithm)
protected Election makeLEStrategy()
protected void setLeader(Leader newLeader)
protected void setFollower(Follower newFollower)
protected void setObserver(Observer newObserver)
public ZooKeeperServer getActiveServer()
public void shutdown()
public Map<Long,QuorumPeer.QuorumServer> getView()
public Map<Long,QuorumPeer.QuorumServer> getVotingView()
public Map<Long,QuorumPeer.QuorumServer> getObservingView()
public boolean viewContains(Long sid)
public String[] getQuorumPeers()
getQuorumPeers
in interface QuorumStats.Provider
public String getServerState()
getServerState
in interface QuorumStats.Provider
public void setMyid(long myid)
public void setInitialConfig(String initialConfig)
public String getInitialConfig()
public int getTickTime()
public void setTickTime(int tickTime)
public int getMaxClientCnxnsPerHost()
public boolean areLocalSessionsEnabled()
public void enableLocalSessions(boolean flag)
public boolean isLocalSessionsUpgradingEnabled()
public void enableLocalSessionsUpgrading(boolean flag)
public int getMinSessionTimeout()
public void setMinSessionTimeout(int min)
public int getMaxSessionTimeout()
public void setMaxSessionTimeout(int max)
public int getClientPortListenBacklog()
public void setClientPortListenBacklog(int backlog)
public int getInitLimit()
public void setInitLimit(int initLimit)
public int getTick()
public QuorumVerifier configFromString(String s) throws IOException, QuorumPeerConfig.ConfigException
public QuorumVerifier getQuorumVerifier()
public QuorumVerifier getLastSeenQuorumVerifier()
public void restartLeaderElection(QuorumVerifier qvOLD, QuorumVerifier qvNEW)
public String getNextDynamicConfigFilename()
public void setLastSeenQuorumVerifier(QuorumVerifier qv, boolean writeToDisk)
public QuorumVerifier setQuorumVerifier(QuorumVerifier qv, boolean writeToDisk)
public Election getElectionAlg()
public int getSyncLimit()
public void setSyncLimit(int syncLimit)
public int getConnectToLearnerMasterLimit()
public void setConnectToLearnerMasterLimit(int connectToLearnerMasterLimit)
public boolean getSyncEnabled()
public void setSyncEnabled(boolean syncEnabled)
syncEnabled
- public int getElectionType()
public void setElectionType(int electionType)
public boolean getQuorumListenOnAllIPs()
public void setQuorumListenOnAllIPs(boolean quorumListenOnAllIPs)
public void setCnxnFactory(ServerCnxnFactory cnxnFactory)
public void setSecureCnxnFactory(ServerCnxnFactory secureCnxnFactory)
public void setSslQuorum(boolean sslQuorum)
public void setUsePortUnification(boolean shouldUsePortUnification)
public void setZooKeeperServer(ZooKeeperServer zks)
public void closeAllConnections()
public int getClientPort()
public void setTxnFactory(FileTxnSnapLog factory)
public FileTxnSnapLog getTxnFactory()
public void setZKDatabase(ZKDatabase database)
database
- protected ZKDatabase getZkDb()
public void initConfigInZKDatabase()
public boolean isRunning()
public QuorumCnxManager getQuorumCnxManager()
public long getCurrentEpoch() throws IOException
IOException
public long getAcceptedEpoch() throws IOException
IOException
public void setCurrentEpoch(long e) throws IOException
IOException
public void setAcceptedEpoch(long e) throws IOException
IOException
public boolean processReconfig(QuorumVerifier qv, Long suggestedLeaderId, Long zxid, boolean restartLE)
protected void updateElectionVote(long newEpoch)
public QuorumCnxManager createCnxnManager()
@InterfaceAudience.Private public Integer getSynced_observers_metric()
Copyright © 2008–2020 The Apache Software Foundation. All rights reserved.