Class QuorumPeer.QuorumServer

  • Enclosing class:
    QuorumPeer

    public static class QuorumPeer.QuorumServer
    extends java.lang.Object
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
    • 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 host
        timeout - the time, in milliseconds, before InetAddress.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