private Set < MasterWorkerInfo > selectInfoByAddress ( Set < String > addresses , Set < MasterWorkerInfo > workerInfoSet , Set < String > workerNames ) { return workerInfoSet . stream ( ) . filter ( info -> { String host = info . getWorkerAddress ( ) . getHost ( ) ; workerNames . add ( host ) ; String ip = null ; try { ip = NetworkAddressUtils . resolveIpAddress ( host ) ; workerNames . add ( ip ) ; } catch ( UnknownHostException e ) { // The host may already be an IP address } if ( addresses . contains ( host ) ) { addresses . remove ( host ) ; return true ; } if ( ip != null ) { if ( addresses . contains ( ip ) ) { addresses . remove ( ip ) ; return true ; } } return false ; } ) . collect ( Collectors . toSet ( ) ) ; }
Selects the MasterWorkerInfo from workerInfoSet whose host or related IP address exists in addresses .