applyToNodes() is superfluous now that we have getNodeObjects().

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5869 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2009-07-13 00:59:32 +00:00
parent 047dd3b871
commit 231edfa66e
3 changed files with 13 additions and 30 deletions
@@ -25,7 +25,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.google.common.base.Function;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.inject.Inject; import com.google.inject.Inject;
@@ -232,19 +231,16 @@ public abstract class ChatChannelManager
// generate a mapping from node name to an array of body ids for the participants that are // generate a mapping from node name to an array of body ids for the participants that are
// currently on the node in question // currently on the node in question
final Map<String,int[]> partMap = Maps.newHashMap(); final Map<String,int[]> partMap = Maps.newHashMap();
_peerMan.applyToNodes(new Function<NodeObject,Void>() { for (NodeObject nodeobj : _peerMan.getNodeObjects()) {
public Void apply (NodeObject nodeobj) { ArrayIntSet nodeBodyIds = new ArrayIntSet();
ArrayIntSet nodeBodyIds = new ArrayIntSet(); for (ClientInfo clinfo : nodeobj.clients) {
for (ClientInfo clinfo : nodeobj.clients) { int bodyId = getBodyId(((CrowdClientInfo)clinfo).visibleName);
int bodyId = getBodyId(((CrowdClientInfo)clinfo).visibleName); if (info.participants.contains(bodyId)) {
if (info.participants.contains(bodyId)) { nodeBodyIds.add(bodyId);
nodeBodyIds.add(bodyId);
}
} }
partMap.put(nodeobj.nodeName, nodeBodyIds.toIntArray());
return null;
} }
}); partMap.put(nodeobj.nodeName, nodeBodyIds.toIntArray());
}
for (Map.Entry<String,int[]> entry : partMap.entrySet()) { for (Map.Entry<String,int[]> entry : partMap.entrySet()) {
_peerMan.invokeNodeAction( _peerMan.invokeNodeAction(
@@ -114,15 +114,12 @@ public class EHCachePeerCoordinator extends CacheManagerPeerProviderFactory
// list the current whirled peers // list the current whirled peers
final List<CachePeer> result = Lists.newArrayList(); final List<CachePeer> result = Lists.newArrayList();
final Set<String> nodes = Sets.newHashSet(); final Set<String> nodes = Sets.newHashSet();
_peerMan.applyToNodes(new Function<NodeObject, Void>() { for (NodeObject node : _peerMan.getNodeObjects()) {
public Void apply (NodeObject node) { if (node != _peerMan.getNodeObject()) {
if (node != _peerMan.getNodeObject()) { addCachesForNode(result, node.nodeName);
addCachesForNode(result, node.nodeName); nodes.add(node.nodeName);
nodes.add(node.nodeName);
}
return null;
} }
}); }
// if any previously known peer is no longer with us, clear out the cache // if any previously known peer is no longer with us, clear out the cache
Set<Tuple<String, String>> toRemove = Sets.newHashSet(); Set<Tuple<String, String>> toRemove = Sets.newHashSet();
@@ -323,16 +323,6 @@ public abstract class PeerManager
return null; return null;
} }
/**
* Applies the supplied function to all {@link NodeObject}s. The operation should not modify
* the objects unless you really know what you're doing. More likely it will summarize
* information contained therein.
*/
public <T> Iterable<T> applyToNodes (Function<NodeObject,T> op)
{
return Iterables.transform(getNodeObjects(), op);
}
/** /**
* Invokes the supplied function on <em>all</em> node objects (except the local node). A caller * Invokes the supplied function on <em>all</em> node objects (except the local node). A caller
* that needs to call an invocation service method on a remote node should use this mechanism * that needs to call an invocation service method on a remote node should use this mechanism