private void reconnect ( Exception reconnectEx ) { // Log the exception as a warning. m_logger . warn ( "Reconnecting to Cassandra due to error" , reconnectEx ) ; // Reconnect up to the configured number of times, waiting a little between each attempt. boolean bSuccess = false ; for ( int attempt = 1 ; ! bSuccess ; attempt ++ ) { try { close ( ) ; m_dbService . connectDBConn ( this ) ; m_logger . debug ( "Reconnect successful" ) ; bSuccess = true ; } catch ( Exception ex ) { // Abort if all retries failed. if ( attempt >= m_max_reconnect_attempts ) { m_logger . error ( "All reconnect attempts failed; abandoning reconnect" , ex ) ; throw new DBNotAvailableException ( "All reconnect attempts failed" , ex ) ; } m_logger . warn ( "Reconnect attempt #" + attempt + " failed" , ex ) ; try { Thread . sleep ( m_retry_wait_millis * attempt ) ; } catch ( InterruptedException e ) { // Ignore } } } }
an DBNotAvailableException and leave the Thrift connection null .