question: public void testFailoverQueriesBeforeRetryMaster ( ) throws Exception { Properties props = new Properties ( ) ; props . setProperty ( "retriesAllDown" , "2" ) ; for ( boolean setQueriesBeforeRetryMaster : new boolean [ ] { true , false } ) { if ( setQueriesBeforeRetryMaster ) { props . setProperty ( "queriesBeforeRetryMaster" , "10" ) ; } else { props . remove ( "queriesBeforeRetryMaster" ) ; } Connection testConn = getUnreliableFailoverConnection ( new String [ ] { HOST_1 , HOST_2 , HOST_3 } , props ) ; Statement testStmt = null ; try { testConn . setAutoCommit ( false ) ; assertEquals ( HOST_1_OK , UnreliableSocketFactory . getHostFromLastConnection ( ) ) ; testStmt = testConn . createStatement ( ) ; assertSingleValueQuery ( testStmt , "SELECT 1" , 1L ) ; UnreliableSocketFactory . downHost ( HOST_1 ) ; UnreliableSocketFactory . downHost ( HOST_2 ) ; assertEquals ( HOST_1_OK , UnreliableSocketFactory . getHostFromLastConnection ( ) ) ; assertSQLException ( testStmt , "SELECT 1" , COMM_LINK_ERR_PATTERN ) ; assertEquals ( HOST_3_OK , UnreliableSocketFactory . getHostFromLastConnection ( ) ) ; testStmt = testConn . createStatement ( ) ; for ( int i = 0 ; i < 10 ; i ++ ) { assertSingleValueQuery ( testStmt , "SELECT 1" , 1L ) ; assertEquals ( HOST_3_OK , UnreliableSocketFactory . getHostFromLastConnection ( ) ) ; } UnreliableSocketFactory . dontDownHost ( HOST_1 ) ; UnreliableSocketFactory . dontDownHost ( HOST_2 ) ; UnreliableSocketFactory . downHost ( HOST_3 ) ; assertEquals ( HOST_3_OK , UnreliableSocketFactory . getHostFromLastConnection ( ) ) ; if ( setQueriesBeforeRetryMaster ) { assertSQLException ( testStmt , "SELECT 1" , COMM_LINK_ERR_PATTERN ) ; assertEquals ( HOST_1_OK , UnreliableSocketFactory . getHostFromLastConnection ( ) ) ; assertConnectionsHistory ( HOST_1_OK , HOST_2_FAIL , HOST_3_OK , HOST_1_OK ) ; } else { assertSQLException ( testStmt , "SELECT 1" , COMM_LINK_ERR_PATTERN ) ; assertEquals ( HOST_2_OK , UnreliableSocketFactory . getHostFromLastConnection ( ) ) ; assertConnectionsHistory ( HOST_1_OK , HOST_2_FAIL , HOST_3_OK , HOST_2_OK ) ; } } finally { if ( testStmt != null ) { testStmt . close ( ) ; } if ( testConn != null ) { testConn . close ( ) ; } } } }
target:  Tests the property 'queriesBeforeRetryMaster' in a failover connection using three hosts and the following sequence of events: - [/HOST_1 : /HOST_2 : /HOST_3] --> HOST_1 - [\HOST_1 : \HOST_2 : /HOST_3] --> HOST_3 - [/HOST_1 : /HOST_2 : \HOST_3] --> HOST_1 vs HOST_2 [Legend: "/HOST_n" --> HOST_n up; "\HOST_n" --> HOST_n down]