public RESTClient getClient ( SSLTransportParameters sslParams ) { if ( m_cellRing == null ) { throw new IllegalStateException ( "Empty pool" ) ; } Cell currentCell = m_cellRing ; StringBuilder errorMessage = new StringBuilder ( ) ; do { try { RESTClient client = new RESTClient ( sslParams , m_cellRing . m_hostName , m_port ) ; client . setCredentials ( m_credentials ) ; m_cellRing . m_hostStatus = new HostStatus ( ) ; client . setAcceptType ( m_defaultContentType ) ; client . setCompression ( m_defaultCompression ) ; return client ; } catch ( RuntimeException e ) { m_cellRing . m_hostStatus = new HostStatus ( false , e ) ; errorMessage . append ( "Couldn\'t connect to " + m_cellRing . m_hostName ) . append ( "; reason: " + e . getMessage ( ) + "\n" ) ; } finally { m_cellRing = m_cellRing . next ; } } while ( currentCell != m_cellRing ) ; throw new IllegalStateException ( "No active connections found\n" + errorMessage ) ; }
Tries to connect to the next host . If no host is available IllegalStateException will be raised .