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.LearnerType |
static class |
QuorumPeer.QuorumServer |
static class |
QuorumPeer.ServerState |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ACCEPTED_EPOCH_FILENAME |
static java.lang.String |
CURRENT_EPOCH_FILENAME |
long |
end_fle |
Follower |
follower |
protected int |
initLimit
The number of ticks that the initial synchronization phase can take
|
Leader |
leader |
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 boolean |
quorumListenOnAllIPs
Whether or not to listen on all IPs for the two quorum ports
(broadcast and fast leader election).
|
protected java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> |
quorumPeers
The servers that make up the cluster
|
long |
start_fle |
static java.lang.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 int |
tick
The current tick
|
protected int |
tickTime
The number of milliseconds of each tick
|
static java.lang.String |
UPDATING_EPOCH_FILENAME |
FOLLOWING_STATE, LEADING_STATE, LOOKING_STATE, OBSERVING_STATE, UNKNOWN_STATE
Constructor and Description |
---|
QuorumPeer() |
QuorumPeer(java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> quorumPeers,
java.io.File snapDir,
java.io.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(java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> quorumPeers,
java.io.File snapDir,
java.io.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(java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> quorumPeers,
java.io.File dataDir,
java.io.File dataLogDir,
int electionType,
long myid,
int tickTime,
int initLimit,
int syncLimit,
boolean quorumListenOnAllIPs,
ServerCnxnFactory cnxnFactory,
QuorumVerifier quorumConfig) |
QuorumPeer(java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> quorumPeers,
java.io.File dataDir,
java.io.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 |
---|---|
protected static int |
countParticipants(java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> peers)
Count the number of nodes in the map that could be followers.
|
protected Election |
createElectionAlgorithm(int electionAlgorithm) |
long |
getAcceptedEpoch() |
ZooKeeperServer |
getActiveServer() |
int |
getClientPort() |
ServerCnxnFactory |
getCnxnFactory() |
long |
getCurrentEpoch() |
Vote |
getCurrentVote() |
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
|
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
|
long |
getMyid()
get the id of this quorum peer.
|
java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> |
getObservingView()
Returns only observers, no followers.
|
QuorumPeer.ServerState |
getPeerState() |
java.net.InetSocketAddress |
getQuorumAddress() |
QuorumCnxManager |
getQuorumCnxManager()
get reference to QuorumCnxManager
|
boolean |
getQuorumListenOnAllIPs() |
java.lang.String[] |
getQuorumPeers()
Only used by QuorumStats at the moment
|
int |
getQuorumSize() |
QuorumVerifier |
getQuorumVerifier()
Return QuorumVerifier object
|
java.lang.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() |
java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> |
getView()
A 'view' is a node's current opinion of the membership of the entire
ensemble.
|
java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> |
getVotingView()
Observers are not contained in this view, only nodes with
PeerType=PARTICIPANT.
|
boolean |
isRunning() |
protected Follower |
makeFollower(FileTxnSnapLog logFactory) |
protected Leader |
makeLeader(FileTxnSnapLog logFactory) |
protected Election |
makeLEStrategy() |
protected Observer |
makeObserver(FileTxnSnapLog logFactory) |
void |
run() |
void |
setAcceptedEpoch(long e) |
void |
setClientPortAddress(java.net.InetSocketAddress addr) |
void |
setCnxnFactory(ServerCnxnFactory cnxnFactory) |
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
|
protected void |
setLeader(Leader newLeader) |
void |
setLearnerType(QuorumPeer.LearnerType p)
Sets the LearnerType both in the QuorumPeer and in the peerMap
|
void |
setMaxSessionTimeout(int max)
minimum 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) |
void |
setQuorumPeers(java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> quorumPeers) |
void |
setQuorumVerifier(QuorumVerifier quorumConfig) |
void |
setRunning(boolean running) |
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 |
setZKDatabase(ZKDatabase database)
set zk database for this node
|
void |
shutdown() |
void |
start() |
void |
startLeaderElection() |
void |
stopLeaderElection() |
protected void |
updateElectionVote(long newEpoch)
Updates leader election info to avoid inconsistencies when
a new server tries to join the ensemble.
|
boolean |
viewContains(java.lang.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
protected java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> quorumPeers
protected int tickTime
protected int minSessionTimeout
protected int maxSessionTimeout
protected int initLimit
protected int syncLimit
protected boolean syncEnabled
protected volatile int tick
protected boolean quorumListenOnAllIPs
public Follower follower
public Leader leader
public Observer observer
public static final java.lang.String SYNC_ENABLED
public static final java.lang.String CURRENT_EPOCH_FILENAME
public static final java.lang.String ACCEPTED_EPOCH_FILENAME
public static final java.lang.String UPDATING_EPOCH_FILENAME
public QuorumPeer()
public QuorumPeer(java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> quorumPeers, java.io.File dataDir, java.io.File dataLogDir, int electionType, long myid, int tickTime, int initLimit, int syncLimit, ServerCnxnFactory cnxnFactory) throws java.io.IOException
java.io.IOException
public QuorumPeer(java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> quorumPeers, java.io.File dataDir, java.io.File dataLogDir, int electionType, long myid, int tickTime, int initLimit, int syncLimit, boolean quorumListenOnAllIPs, ServerCnxnFactory cnxnFactory, QuorumVerifier quorumConfig) throws java.io.IOException
java.io.IOException
public QuorumPeer(java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> quorumPeers, java.io.File snapDir, java.io.File logDir, int clientPort, int electionAlg, long myid, int tickTime, int initLimit, int syncLimit) throws java.io.IOException
java.io.IOException
public QuorumPeer(java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> quorumPeers, java.io.File snapDir, java.io.File logDir, int clientPort, int electionAlg, long myid, int tickTime, int initLimit, int syncLimit, QuorumVerifier quorumConfig) throws java.io.IOException
java.io.IOException
public QuorumPeer.LearnerType getLearnerType()
public void setLearnerType(QuorumPeer.LearnerType p)
public int getQuorumSize()
public long getId()
getId
in class java.lang.Thread
public Vote getCurrentVote()
public void setCurrentVote(Vote v)
public void setPeerState(QuorumPeer.ServerState newState)
public QuorumPeer.ServerState getPeerState()
public java.net.InetSocketAddress getQuorumAddress()
public void start()
start
in class java.lang.Thread
public void stopLeaderElection()
public void startLeaderElection()
protected static int countParticipants(java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> peers)
peers
- public long getLastLoggedZxid()
protected Follower makeFollower(FileTxnSnapLog logFactory) throws java.io.IOException
java.io.IOException
protected Leader makeLeader(FileTxnSnapLog logFactory) throws java.io.IOException
java.io.IOException
protected Observer makeObserver(FileTxnSnapLog logFactory) throws java.io.IOException
java.io.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 run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void shutdown()
public java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> getView()
public java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> getVotingView()
public java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> getObservingView()
public boolean viewContains(java.lang.Long sid)
public java.lang.String[] getQuorumPeers()
getQuorumPeers
in interface QuorumStats.Provider
public java.lang.String getServerState()
getServerState
in interface QuorumStats.Provider
public long getMyid()
public void setMyid(long myid)
public int getTickTime()
public void setTickTime(int tickTime)
public int getMaxClientCnxnsPerHost()
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 getQuorumVerifier()
public void setQuorumVerifier(QuorumVerifier quorumConfig)
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 ServerCnxnFactory getCnxnFactory()
public void setCnxnFactory(ServerCnxnFactory cnxnFactory)
public void setQuorumPeers(java.util.Map<java.lang.Long,QuorumPeer.QuorumServer> quorumPeers)
public int getClientPort()
public void setClientPortAddress(java.net.InetSocketAddress addr)
public void setTxnFactory(FileTxnSnapLog factory)
public FileTxnSnapLog getTxnFactory()
public void setZKDatabase(ZKDatabase database)
database
- public void setRunning(boolean running)
public boolean isRunning()
public QuorumCnxManager getQuorumCnxManager()
public long getCurrentEpoch() throws java.io.IOException
java.io.IOException
public long getAcceptedEpoch() throws java.io.IOException
java.io.IOException
public void setCurrentEpoch(long e) throws java.io.IOException
java.io.IOException
public void setAcceptedEpoch(long e) throws java.io.IOException
java.io.IOException
protected void updateElectionVote(long newEpoch)
Copyright © 2016 The Apache Software Foundation