private List < String > getCurrentEndpointIdentifiers ( Protocol protocol ) throws SQLException { List < String > endpoints = new ArrayList <> ( ) ; try { proxy . lock . lock ( ) ; try { // Deleted instance may remain in db for 24 hours so ignoring instances that have had no change // for 3 minutes Results results = new Results ( ) ; protocol . executeQuery ( false , results , "select server_id, session_id from information_schema.replica_host_status " + "where last_update_timestamp > now() - INTERVAL 3 MINUTE" ) ; results . commandEnd ( ) ; ResultSet resultSet = results . getResultSet ( ) ; while ( resultSet . next ( ) ) { endpoints . add ( resultSet . getString ( 1 ) + "." + clusterDnsSuffix ) ; } //randomize order for distributed load-balancing Collections . shuffle ( endpoints ) ; } finally { proxy . lock . unlock ( ) ; } } catch ( SQLException qe ) { logger . warning ( "SQL exception occurred: " + qe . getMessage ( ) ) ; if ( protocol . getProxy ( ) . hasToHandleFailover ( qe ) ) { if ( masterProtocol == null || masterProtocol . equals ( protocol ) ) { setMasterHostFail ( ) ; } else if ( secondaryProtocol . equals ( protocol ) ) { setSecondaryHostFail ( ) ; } addToBlacklist ( protocol . getHostAddress ( ) ) ; reconnectFailedConnection ( new SearchFilter ( isMasterHostFail ( ) , isSecondaryHostFail ( ) ) ) ; } } return endpoints ; }
Retrieves all endpoints of a cluster from the appropriate database table .