|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.zookeeper.server.quorum.Learner
public class Learner
This class is the superclass of two of the three main actors in a ZK ensemble: Followers and Observers. Both Followers and Observers share a good deal of code which is moved into Peer to avoid duplication.
| Field Summary | |
|---|---|
protected java.io.BufferedOutputStream |
bufferedOutput
|
protected org.apache.jute.InputArchive |
leaderIs
|
protected org.apache.jute.OutputArchive |
leaderOs
|
protected static org.apache.log4j.Logger |
LOG
|
protected java.net.Socket |
sock
|
| Constructor Summary | |
|---|---|
Learner()
|
|
| Method Summary | |
|---|---|
protected void |
connectToLeader(java.net.InetSocketAddress addr)
Establish a connection with the Leader found by findLeader. |
protected java.net.InetSocketAddress |
findLeader()
Returns the address of the node we think is the leader. |
int |
getPendingRevalidationsCount()
|
java.net.Socket |
getSocket()
Socket getter |
protected void |
ping(QuorumPacket qp)
|
protected long |
registerWithLeader(int pktType)
Once connected to the leader, perform the handshake protocol to establish a following / observing connection. |
protected void |
revalidate(QuorumPacket qp)
|
void |
shutdown()
Shutdown the Peer |
protected void |
syncWithLeader(long newLeaderZxid)
Finally, synchronize our history with the Leader. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.io.BufferedOutputStream bufferedOutput
protected java.net.Socket sock
protected org.apache.jute.InputArchive leaderIs
protected org.apache.jute.OutputArchive leaderOs
protected static final org.apache.log4j.Logger LOG
| Constructor Detail |
|---|
public Learner()
| Method Detail |
|---|
public java.net.Socket getSocket()
public int getPendingRevalidationsCount()
protected java.net.InetSocketAddress findLeader()
protected void connectToLeader(java.net.InetSocketAddress addr)
throws java.io.IOException,
java.net.ConnectException,
java.lang.InterruptedException
addr - - the address of the Leader to connect to.
java.io.IOException - - if the socket connection fails on the 5th attempt
java.net.ConnectException
java.lang.InterruptedException
protected long registerWithLeader(int pktType)
throws java.io.IOException
pktType -
java.io.IOException
protected void syncWithLeader(long newLeaderZxid)
throws java.io.IOException,
java.lang.InterruptedException
newLeaderZxid -
java.io.IOException
java.lang.InterruptedException
protected void revalidate(QuorumPacket qp)
throws java.io.IOException
java.io.IOException
protected void ping(QuorumPacket qp)
throws java.io.IOException
java.io.IOExceptionpublic void shutdown()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||