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 |
Thread.State, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
static String |
ACCEPTED_EPOCH_FILENAME |
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 |
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)
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,
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,
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,
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() |
Set<Long> |
getCurrentAndNextConfigVoters() |
long |
getCurrentEpoch() |
Vote |
getCurrentVote() |
InetSocketAddress |
getElectionAddress() |
Election |
getElectionAlg()
Get an instance of LeaderElection
|
int |
getElectionType()
Gets the election type
|
long |
getId()
get the id of this quorum peer.
|
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.
|
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
|
String |
getNextDynamicConfigFilename() |
Map<Long,QuorumPeer.QuorumServer> |
getObservingView()
Returns only observers, no followers.
|
QuorumPeer.ServerState |
getPeerState() |
InetSocketAddress |
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() |
boolean |
getSyncEnabled()
Return syncEnabled.
|
int |
getSyncLimit()
Get the synclimit
|
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.
|
protected ZKDatabase |
getZkDb() |
void |
initConfigInZKDatabase() |
void |
initialize() |
boolean |
isLocalSessionsUpgradingEnabled()
Whether local sessions are allowed to upgrade to global sessions
|
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 |
setCnxnFactory(ServerCnxnFactory cnxnFactory) |
protected void |
setConfigFileName(String s) |
void |
setCurrentEpoch(long e) |
void |
setCurrentVote(Vote v) |
void |
setElectionType(int electionType)
Sets the election type
|
protected void |
setFollower(Follower newFollower) |
void |
setInitLimit(int initLimit)
Set the number of ticks that the initial synchronization phase can take
|
void |
setLastSeenQuorumVerifier(QuorumVerifier qv,
boolean writeToDisk) |
protected void |
setLeader(Leader newLeader) |
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 |
setMyid(long myid)
set the id of this quorum peer.
|
protected void |
setObserver(Observer newObserver) |
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 |
setTickTime(int tickTime)
Set the number of milliseconds of each tick
|
void |
setTxnFactory(FileTxnSnapLog factory) |
void |
setUsePortUnification(boolean shouldUsePortUnification) |
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 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 initLimit
protected int syncLimit
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 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, 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, 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) 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, QuorumVerifier quorumConfig) throws IOException
IOException
public QuorumPeer.LearnerType getLearnerType()
public void setLearnerType(QuorumPeer.LearnerType p)
protected void setConfigFileName(String s)
public int getQuorumSize()
public boolean isSslQuorum()
public boolean shouldUsePortUnification()
public Vote getCurrentVote()
public void setCurrentVote(Vote v)
public void setPeerState(QuorumPeer.ServerState newState)
public void reconfigFlagSet()
public void reconfigFlagClear()
public boolean isReconfigStateChange()
public QuorumPeer.ServerState getPeerState()
public void recreateSocketAddresses(long id)
public InetSocketAddress getQuorumAddress()
public InetSocketAddress 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 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 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 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)
https://issues.apache.org/jira/browse/ZOOKEEPER-1732
public QuorumCnxManager createCnxnManager()
Copyright © 2008–2019 The Apache Software Foundation. All rights reserved.