private void loadHealthyServices ( ) { try { String serviceName = doneQueue . poll ( ) ; while ( serviceName != null ) { final String serviceNameToFetch = serviceName ; /* Don't load the service if it is already being loaded. */ if ( ! serviceNamesBeingLoaded . contains ( serviceNameToFetch ) ) { serviceNamesBeingLoaded . add ( serviceNameToFetch ) ; executorService . submit ( ( ) -> { /* Loading a service pool might take a while so the actual load operation happens in its own thread. */ doLoadHealthServices ( serviceNameToFetch ) ; } ) ; } serviceName = doneQueue . poll ( ) ; } } catch ( Exception ex ) { ex . printStackTrace ( ) ; } }
Iterate through the health service queue and load the services .