}
return chosen;
}
protected <K> Map<Address, List<K>> keysToExecutionNodes(DistributedTaskExecutionPolicy policy, K... input) {
DistributionManager dm = cache.getDistributionManager();
Map<Address, List<K>> addressToKey = new HashMap<Address, List<K>>(input.length * 2);
boolean usingREPLMode = dm == null;
for (K key : input) {
Address ownerOfKey = null;
if (usingREPLMode) {
List<Address> members = new ArrayList<Address>(getMembers());
members = filterMembers(policy, members);
// using REPL mode https://issues.jboss.org/browse/ISPN-1886
// since keys and values are on all nodes, lets just pick randomly
Collections.shuffle(members);
ownerOfKey = members.get(0);
} else {
// DIST mode
List<Address> owners = dm.locate(key);
List<Address> filtered = filterMembers(policy, owners);
if(!filtered.isEmpty()){
ownerOfKey = filtered.get(0);
} else {
ownerOfKey = owners.get(0);