Class QuorumPeer.QuorumServer
- java.lang.Object
-
- org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer
-
- Enclosing class:
- QuorumPeer
public static class QuorumPeer.QuorumServer extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description java.net.InetSocketAddress
addr
java.net.InetSocketAddress
electionAddr
int
electionPort
java.lang.String
hostname
long
id
int
port
QuorumPeer.LearnerType
type
-
Constructor Summary
Constructors Constructor Description QuorumServer(long id, java.lang.String hostname, java.lang.Integer port, java.lang.Integer electionPort, QuorumPeer.LearnerType type)
QuorumServer(long id, java.net.InetSocketAddress addr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.net.InetAddress
getReachableAddress(java.lang.String hostname, int timeout)
Resolve the hostname to IP addresses, and find one reachable address.void
recreateSocketAddresses()
Performs a DNS lookup of hostname and (re)creates the this.addr and this.electionAddr InetSocketAddress objects as appropriate If the DNS lookup fails, this.addr and electionAddr remain unmodified, unless they were never set.
-
-
-
Field Detail
-
addr
public java.net.InetSocketAddress addr
-
electionAddr
public java.net.InetSocketAddress electionAddr
-
hostname
public java.lang.String hostname
-
port
public int port
-
electionPort
public int electionPort
-
id
public long id
-
type
public QuorumPeer.LearnerType type
-
-
Constructor Detail
-
QuorumServer
public QuorumServer(long id, java.net.InetSocketAddress addr)
-
QuorumServer
public QuorumServer(long id, java.lang.String hostname, java.lang.Integer port, java.lang.Integer electionPort, QuorumPeer.LearnerType type)
-
-
Method Detail
-
recreateSocketAddresses
public void recreateSocketAddresses()
Performs a DNS lookup of hostname and (re)creates the this.addr and this.electionAddr InetSocketAddress objects as appropriate If the DNS lookup fails, this.addr and electionAddr remain unmodified, unless they were never set. If this.addr is null, then it is set with an unresolved InetSocketAddress object. this.electionAddr is handled similarly.
-
getReachableAddress
public java.net.InetAddress getReachableAddress(java.lang.String hostname, int timeout) throws java.net.UnknownHostException
Resolve the hostname to IP addresses, and find one reachable address.- Parameters:
hostname
- the name of the hosttimeout
- the time, in milliseconds, beforeInetAddress.isReachable(int)
aborts- Returns:
- a reachable IP address. If no such IP address can be found, just return the first IP address of the hostname.
- Throws:
java.net.UnknownHostException
-
-