question: private Set < StoragePort > filterCandidates ( Set < StoragePort > candidates , Set < String > allocatedEntitySet , Map < String , Set < StoragePort > > contextEntityMap ) { if ( false == contextEntityMap . isEmpty ( ) ) { Map < String , Set < StoragePort > > newEntityMap = removeStoragePortSets ( allocatedEntitySet , contextEntityMap ) ; if ( newEntityMap . isEmpty ( ) == false ) { Set < StoragePort > newEngineSet = andStoragePortSets ( candidates , reduceStoragePortMap ( newEntityMap ) ) ; if ( newEngineSet . isEmpty ( ) == false ) { candidates = newEngineSet ; } } else { _log . debug ( "Used all entities: " + allocatedEntitySet . toString ( ) ) ; allocatedEntitySet . clear ( ) ; } } return candidates ; }
target:  Filter the set of candidates based on already used entities of some type. The currently entity types are engines, directors, director types, cpus, and sanSwitches. The filter is only applied if the resultant set is not empty (meaning there are still remaining ports to be selected after the filter is supplied). Once a port has been selected that represents each of the available entities, the allocatedEntitySet is cleared, which results in cycling through the entities again.