* 3. Remove table entries that exceed the count per host
*/
Map<String, List<ServiceResource>> table = new HashMap<String, List<ServiceResource>>();
for (ServiceResource candidate : candidates) {
InstantiatorResource ir = (InstantiatorResource)candidate.getResource();
List<ServiceResource> list = table.get(ir.getHostAddress());
if(list==null)
list = new ArrayList<ServiceResource>();
list.add(candidate);
table.put(ir.getHostAddress(), list);
}
List<String> remove = new ArrayList<String>();
for(Map.Entry<String, List<ServiceResource>> entry : table.entrySet()) {
List<ServiceResource> list = entry.getValue();
int serviceCount = 0;
for(ServiceResource sr : list) {
InstantiatorResource ir = (InstantiatorResource)sr.getResource();
serviceCount += ir.getInProcessCounter(elem) + ir.getServiceElementCount(elem);
if(serviceCount>=maxPerMachine) {
remove.add(ir.getHostAddress());
break;
}
}
}
for(String s : remove) {