Added a helper method for calling an invocation service method on one or more

remote nodes.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4817 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2007-08-17 21:02:44 +00:00
parent d92f81af78
commit 52be62ddbf
@@ -109,6 +109,12 @@ public class PeerManager
public void apply (NodeObject nodeobj);
}
/** Used by {@link #invokeOnNodes}. */
public static interface Function
{
public void invoke (Client client, NodeObject nodeobj);
}
/**
* Wraps an operation that needs a shared resource lock to be acquired before it can be
* performed, and released after it completes. Used by {@link #performWithLock}.
@@ -257,6 +263,20 @@ public class PeerManager
}
}
/**
* 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
* to locate the appropriate node (or nodes) and call the desired method.
*/
public void invokeOnNodes (Function func)
{
for (PeerNode peer : _peers.values()) {
if (peer.nodeobj != null) {
func.invoke(peer.getClient(), peer.nodeobj);
}
}
}
/**
* Returns true if the supplied peer credentials match our shared secret.
*/