Class AuroraProtocol

    • Constructor Detail

      • AuroraProtocol

        public AuroraProtocol​(UrlParser url,
                              GlobalStateInfo globalInfo,
                              java.util.concurrent.locks.ReentrantLock lock)
    • Method Detail

      • searchProbableMaster

        private static void searchProbableMaster​(AuroraListener listener,
                                                 GlobalStateInfo globalInfo,
                                                 HostAddress probableMaster)
        Connect aurora probable master. Aurora master change in time. The only way to check that a server is a master is to asked him.
        Parameters:
        listener - aurora failover to call back if master is found
        globalInfo - server global variables information
        probableMaster - probable master host
      • loop

        public static void loop​(AuroraListener listener,
                                GlobalStateInfo globalInfo,
                                java.util.List<HostAddress> addresses,
                                SearchFilter initialSearchFilter)
                         throws java.sql.SQLException
        loop until found the failed connection.
        Parameters:
        listener - current failover
        globalInfo - server global variables information
        addresses - list of HostAddress to loop
        initialSearchFilter - search parameter
        Throws:
        java.sql.SQLException - if not found
      • resetHostList

        private static void resetHostList​(AuroraListener listener,
                                          java.util.Deque<HostAddress> loopAddresses)
        Reinitialize loopAddresses with all hosts : all servers in randomize order with cluster address. If there is an active connection, connected host are remove from list.
        Parameters:
        listener - current listener
        loopAddresses - the list to reinitialize
      • getNewProtocol

        public static AuroraProtocol getNewProtocol​(FailoverProxy proxy,
                                                    GlobalStateInfo globalInfo,
                                                    UrlParser urlParser)
        Initialize new protocol instance.
        Parameters:
        proxy - proxy
        globalInfo - server global variables information
        urlParser - connection string data's
        Returns:
        new AuroraProtocol
      • isValid

        public boolean isValid​(int timeout)
                        throws java.sql.SQLException
        Description copied from class: AbstractQueryProtocol
        Check that connection is valid. !! careful, timeout is in milliseconds, connection.isValid(timeout) is in seconds !!
        Specified by:
        isValid in interface Protocol
        Overrides:
        isValid in class AbstractQueryProtocol
        Parameters:
        timeout - timeout in milliseconds
        Returns:
        true is valid
        Throws:
        java.sql.SQLException - if any error occur
      • checkIfMaster

        public boolean checkIfMaster()
                              throws java.sql.SQLException
        Aurora best way to check if a node is a master : is not in read-only mode.
        Specified by:
        checkIfMaster in interface Protocol
        Overrides:
        checkIfMaster in class AbstractConnectProtocol
        Returns:
        indicate if master has been found
        Throws:
        java.sql.SQLException - if requesting infos for server fail.