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.InetSocketAddressaddrjava.net.InetSocketAddresselectionAddrintelectionPortjava.lang.StringhostnamelongidintportQuorumPeer.LearnerTypetype
-
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.InetAddressgetReachableAddress(java.lang.String hostname, int timeout)Resolve the hostname to IP addresses, and find one reachable address.voidrecreateSocketAddresses()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.UnknownHostExceptionResolve 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
-
-