Class MastersFailoverListener

    • Field Detail

      • logger

        private static final Logger logger
      • mode

        private final HaMode mode
    • Constructor Detail

      • MastersFailoverListener

        public MastersFailoverListener​(UrlParser urlParser,
                                       GlobalStateInfo globalInfo)
        Initialisation.
        Parameters:
        urlParser - url options.
        globalInfo - server global variables information
    • Method Detail

      • preExecute

        public void preExecute()
                        throws java.sql.SQLException
        Before executing query, reconnect if connection is closed, and autoReconnect option is set.
        Specified by:
        preExecute in interface Listener
        Specified by:
        preExecute in class AbstractMastersListener
        Throws:
        java.sql.SQLException - if connection has been explicitly closed.
      • getServerThreadId

        public long getServerThreadId()
      • preAbort

        public void preAbort()
      • switchReadOnlyConnection

        public void switchReadOnlyConnection​(java.lang.Boolean mustBeReadOnly)
                                      throws java.sql.SQLException
        Force session to read-only according to options.
        Specified by:
        switchReadOnlyConnection in interface Listener
        Specified by:
        switchReadOnlyConnection in class AbstractMastersListener
        Parameters:
        mustBeReadOnly - is read-only flag
        Throws:
        java.sql.SQLException - if a connection error occur
      • foundActiveMaster

        public void foundActiveMaster​(Protocol protocol)
                               throws java.sql.SQLException
        method called when a new Master connection is found after a fallback.
        Parameters:
        protocol - the new active connection
        Throws:
        java.sql.SQLException
      • reconnect

        public void reconnect()
                       throws java.sql.SQLException
        Try to reconnect connection.
        Specified by:
        reconnect in interface Listener
        Specified by:
        reconnect in class AbstractMastersListener
        Throws:
        java.sql.SQLException - if reconnect a new connection but there was an active transaction.
      • handleFailLoop

        public void handleFailLoop()
        Add listener to FailoverLoop if master connection is not active, so a reconnection will be done. (the reconnection will be done by failover or if append before by the next query/method that will use the failed connection) Remove listener from FailoverLoop is master connection is active.
        Specified by:
        handleFailLoop in class AbstractMastersListener
      • isMasterConnected

        public boolean isMasterConnected()
      • rePrepareOnSlave

        public void rePrepareOnSlave​(ServerPrepareResult oldServerPrepareResult,
                                     boolean mustExecuteOnSlave)
      • reset

        public void reset()
                   throws java.sql.SQLException
        Reset state of master connection.
        Throws:
        java.sql.SQLException - if command fail.