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:
@@ -109,6 +109,12 @@ public class PeerManager
|
|||||||
public void apply (NodeObject nodeobj);
|
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
|
* 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}.
|
* 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.
|
* Returns true if the supplied peer credentials match our shared secret.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user