|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
org.apache.zookeeper.server.quorum.QuorumPeer
public class QuorumPeer
This class manages the quorum protocol. There are three states this server can be in:
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 Summary | |
---|---|
static interface |
QuorumPeer.Factory
Create an instance of a quorum peer |
static class |
QuorumPeer.QuorumServer
|
static class |
QuorumPeer.ServerState
|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
Follower |
follower
|
Leader |
leader
|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Fields inherited from interface org.apache.zookeeper.server.quorum.QuorumStats.Provider |
---|
FOLLOWING_STATE, LEADING_STATE, LOOKING_STATE, UNKNOWN_STATE |
Constructor Summary | |
---|---|
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,
NIOServerCnxn.Factory cnxnFactory)
For backward compatibility purposes, we instantiate QuorumMaj by default. |
|
QuorumPeer(Map<Long,QuorumPeer.QuorumServer> quorumPeers,
File dataDir,
File dataLogDir,
int electionType,
long myid,
int tickTime,
int initLimit,
int syncLimit,
NIOServerCnxn.Factory cnxnFactory,
QuorumVerifier quorumConfig)
|
Method Summary | |
---|---|
ZooKeeperServer |
getActiveServer()
|
int |
getClientPort()
|
NIOServerCnxn.Factory |
getCnxnFactory()
|
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 |
long |
getMyid()
get the id of this quorum peer. |
QuorumPeer.ServerState |
getPeerState()
|
InetSocketAddress |
getQuorumAddress()
|
String[] |
getQuorumPeers()
|
int |
getQuorumSize()
|
QuorumVerifier |
getQuorumVerifier()
Return QuorumVerifier object |
String |
getServerState()
|
int |
getSyncLimit()
Get the number of ticks that can pass between sending a request and getting an acknowledgement |
int |
getTick()
Get the current tick |
int |
getTickTime()
Get the number of milliseconds of each tick |
FileTxnSnapLog |
getTxnFactory()
|
protected Follower |
makeFollower(FileTxnSnapLog logFactory)
|
protected Leader |
makeLeader(FileTxnSnapLog logFactory)
|
protected Election |
makeLEStrategy()
|
void |
run()
|
void |
setClientPort(int clientPort)
|
void |
setCnxnFactory(NIOServerCnxn.Factory cnxnFactory)
|
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 |
setMyid(long myid)
set the id of this quorum peer. |
void |
setPeerState(QuorumPeer.ServerState newState)
|
void |
setQuorumPeers(Map<Long,QuorumPeer.QuorumServer> quorumPeers)
|
void |
setQuorumVerifier(QuorumVerifier quorumConfig)
|
void |
setSyncLimit(int syncLimit)
Set the number of ticks that can pass between sending a request and getting an acknowledgement |
void |
setTickTime(int tickTime)
Set the number of milliseconds of each tick |
void |
setTxnFactory(FileTxnSnapLog factory)
|
void |
shutdown()
|
void |
start()
|
void |
startLeaderElection()
|
void |
stopLeaderElection()
|
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, 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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public Follower follower
public Leader leader
Constructor Detail |
---|
public QuorumPeer()
public QuorumPeer(Map<Long,QuorumPeer.QuorumServer> quorumPeers, File dataDir, File dataLogDir, int electionType, long myid, int tickTime, int initLimit, int syncLimit, NIOServerCnxn.Factory 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, NIOServerCnxn.Factory 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
Method Detail |
---|
public int getQuorumSize()
public long getId()
getId
in class Thread
public Vote getCurrentVote()
public void setCurrentVote(Vote v)
public void setPeerState(QuorumPeer.ServerState newState)
public QuorumPeer.ServerState getPeerState()
public InetSocketAddress getQuorumAddress()
public void start()
start
in class Thread
public void stopLeaderElection()
public void startLeaderElection()
public long getLastLoggedZxid()
protected Follower makeFollower(FileTxnSnapLog logFactory) throws IOException
IOException
protected Leader makeLeader(FileTxnSnapLog logFactory) throws IOException
IOException
protected Election makeLEStrategy()
protected void setLeader(Leader newLeader)
protected void setFollower(Follower newFollower)
public ZooKeeperServer getActiveServer()
public void run()
run
in interface Runnable
run
in class Thread
public void shutdown()
public String[] getQuorumPeers()
getQuorumPeers
in interface QuorumStats.Provider
public 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 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 int getElectionType()
public void setElectionType(int electionType)
public NIOServerCnxn.Factory getCnxnFactory()
public void setCnxnFactory(NIOServerCnxn.Factory cnxnFactory)
public void setQuorumPeers(Map<Long,QuorumPeer.QuorumServer> quorumPeers)
public int getClientPort()
public void setClientPort(int clientPort)
public void setTxnFactory(FileTxnSnapLog factory)
public FileTxnSnapLog getTxnFactory()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |