Class AuroraProtocol

All Implemented Interfaces:
Closeable, AutoCloseable, Protocol

public class AuroraProtocol extends MastersSlavesProtocol
  • Constructor Details

  • Method Details

    • 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, List<HostAddress> addresses, SearchFilter initialSearchFilter) throws 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:
      SQLException - if not found
    • resetHostList

      private static void resetHostList(AuroraListener listener, 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
    • isMasterConnection

      public boolean isMasterConnection()
      Description copied from class: AbstractConnectProtocol
      Indicate if current protocol is a master protocol.
      Specified by:
      isMasterConnection in interface Protocol
      Overrides:
      isMasterConnection in class AbstractConnectProtocol
      Returns:
      is master flag
    • readPipelineCheckMaster

      public void readPipelineCheckMaster() throws SQLException
      Overrides:
      readPipelineCheckMaster in class AbstractConnectProtocol
      Throws:
      SQLException
    • isValid

      public boolean isValid(int timeout) throws 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:
      SQLException - if any error occur
    • checkIfMaster

      public boolean checkIfMaster() throws 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:
      SQLException - if requesting infos for server fail.