private Session createConnection ( ) { /* reorder locations */ List < String > locations = Lists . newArrayList ( split . getReplicas ( ) ) ; Collections . sort ( locations , new DeepPartitionLocationComparator ( ) ) ; Exception lastException = null ; LOG . debug ( "createConnection: " + locations ) ; for ( String location : locations ) { try { return trySessionForLocation ( location , config , false ) . left ; } catch ( Exception e ) { LOG . error ( "Could not get connection for: {}, replicas: {}" , location , locations ) ; lastException = e ; } } throw new DeepIOException ( lastException ) ; }
Creates a new connection . Reuses a cached connection if possible .