private void ensureMinimum ( ) { int belowMin = minEndpoints - endpoints . size ( ) ; if ( belowMin > 0 ) { LOGGER . debug ( logIdent ( hostname , this ) + "Service is {} below minimum, filling up." , belowMin ) ; synchronized ( epMutex ) { for ( int i = 0 ; i < belowMin ; i ++ ) { Endpoint endpoint = endpointFactory . create ( hostname , bucket , username , password , port , ctx ) ; endpoints . add ( endpoint ) ; endpointStates . register ( endpoint , endpoint ) ; endpoint . connect ( ) . subscribe ( new Subscriber < LifecycleState > ( ) { @ Override public void onCompleted ( ) { /* ignored on purpose */ } @ Override public void onError ( Throwable e ) { LOGGER . warn ( logIdent ( hostname , PooledService . this ) + "Got an error while connecting endpoint!" , e ) ; } @ Override public void onNext ( LifecycleState state ) { /* ignored on purpose */ } } ) ; } LOGGER . debug ( logIdent ( hostname , PooledService . this ) + "New number of endpoints is {}" , endpoints . size ( ) ) ; } } }
Helper method to ensure a minimum number of endpoints is enabled .