private StoragePort assignPortBasedOnUsage(List<StoragePort> matchingTargetPorts,Map<StoragePort,Integer> portUsage){
  StoragePort foundPort=null;
  for (  StoragePort matchedPort : matchingTargetPorts) {
    if (portUsage.get(matchedPort) == null) {
      portUsage.put(matchedPort,0);
    }
    if (foundPort == null) {
      foundPort=matchedPort;
    }
 else {
      if (portUsage.get(matchedPort) < portUsage.get(foundPort)) {
        foundPort=matchedPort;
      }
    }
  }
  if (foundPort != null) {
    portUsage.put(foundPort,portUsage.get(foundPort) + 1);
  }
  return foundPort;
}

private StoragePort assignPortBasedOnUsage ( List < StoragePort > matchingTargetPorts , Map < StoragePort , Integer > portUsage ) { StoragePort foundPort = null ; for ( StoragePort matchedPort : matchingTargetPorts ) { if ( portUsage . get ( matchedPort ) == null ) { portUsage . put ( matchedPort , 0 ) ; } if ( foundPort == null ) { foundPort = matchedPort ; } else { if ( portUsage . get ( matchedPort ) < portUsage . get ( foundPort ) ) { foundPort = matchedPort ; } } } if ( foundPort != null ) { portUsage . put ( foundPort , portUsage . get ( foundPort ) + 1 ) ; } return foundPort ; }
doing the best possible assignment . matched target ports should be assigned at least to one initiator .
