private void resetClients ( boolean shutdown ) { // Only agent clients need to be reconfigured. // Make fresh snapshots of the CLIENTS, as we don't want to reconfigure them while holding the lock. final List < HttpAgentClient > clients ; synchronized ( this ) { // Get the snapshot. clients = new ArrayList <> ( this . agentClients ) ; // Remove the clients, new ones will be created if necessary. this . agentClients . clear ( ) ; } // Now reconfigure all the CLIENTS. for ( HttpAgentClient client : clients ) { try { final ReconfigurableClient < ? > reconfigurable = client . getReconfigurableClient ( ) ; if ( shutdown ) reconfigurable . closeConnection ( ) ; else reconfigurable . switchMessagingType ( HttpConstants . FACTORY_HTTP ) ; } catch ( Throwable t ) { // Warn but continue to reconfigure the next CLIENTS! this . logger . warning ( "A client has thrown an exception on reconfiguration: " + client ) ; Utils . logException ( this . logger , new RuntimeException ( t ) ) ; } } }
Closes messaging clients or requests a replacement to the reconfigurable client .