public void start ( ) { IoFutureListener < ConnectFuture > tmpConnectListener ; if ( interval > 0 ) { tmpConnectListener = new IoFutureListener < ConnectFuture > ( ) { @ Override public void operationComplete ( ConnectFuture future ) { heartbeatFilter . setServiceConnected ( future . isConnected ( ) ) ; updateConnectTimes ( future . isConnected ( ) ) ; } } ; } else { tmpConnectListener = new IoFutureListener < ConnectFuture > ( ) { @ Override public void operationComplete ( ConnectFuture future ) { updateConnectTimes ( future . isConnected ( ) ) ; } } ; } final IoFutureListener < ConnectFuture > connectListener = tmpConnectListener ; // set a connection pool with GT 0 prepared connections in every worker thread as an optimization Worker [ ] workers = tcpAcceptor . getWorkers ( ) ; assert preparedConnectionCount == 0 || preparedConnectionCount >= workers . length : "Prepared connection count must be 0, or >= number of IO threads" ; int minCountPerThread = preparedConnectionCount / workers . length ; int remainder = preparedConnectionCount % workers . length ; for ( Worker worker : workers ) { final int count = remainder -- > 0 ? minCountPerThread + 1 : minCountPerThread ; Runnable startConnectionPoolTask = ( ) -> { ConnectionPool currentPool = connectionPool . get ( ) ; if ( currentPool == null ) { // the first time the pool is started is needs to be created, subsequent times it should just be started // without re-creating. currentPool = new ConnectionPool ( serviceCtx , connectHandler , connectURI , heartbeatFilter , connectListener , count , true ) ; connectionPool . set ( currentPool ) ; } currentPool . start ( ) ; } ; worker . executeInIoThread ( startConnectionPoolTask ) ; } }
Start the connection manager so that any pre - connections are established .