Updated some comments, added some sanity checks to registerDispatcher() and
clearDispatcher() as I saw some craziness in the wild. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5314 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -129,6 +129,8 @@ public class InvocationManager
|
|||||||
public <T extends InvocationMarshaller> T registerDispatcher (
|
public <T extends InvocationMarshaller> T registerDispatcher (
|
||||||
InvocationDispatcher<T> dispatcher, String group)
|
InvocationDispatcher<T> dispatcher, String group)
|
||||||
{
|
{
|
||||||
|
_omgr.requireEventThread(); // sanity check
|
||||||
|
|
||||||
// get the next invocation code
|
// get the next invocation code
|
||||||
int invCode = nextInvCode();
|
int invCode = nextInvCode();
|
||||||
|
|
||||||
@@ -155,12 +157,13 @@ public class InvocationManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears out a dispatcher registration. This should be called to free
|
* Clears out a dispatcher registration. This should be called to free up resources when an
|
||||||
* up resources when an invocation service is no longer going to be
|
* invocation service is no longer going to be used.
|
||||||
* used.
|
|
||||||
*/
|
*/
|
||||||
public void clearDispatcher (InvocationMarshaller marsh)
|
public void clearDispatcher (InvocationMarshaller marsh)
|
||||||
{
|
{
|
||||||
|
_omgr.requireEventThread(); // sanity check
|
||||||
|
|
||||||
if (marsh == null) {
|
if (marsh == null) {
|
||||||
log.warning("Refusing to unregister null marshaller.");
|
log.warning("Refusing to unregister null marshaller.");
|
||||||
Thread.dumpStack();
|
Thread.dumpStack();
|
||||||
@@ -190,8 +193,8 @@ public class InvocationManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the class that is being used to dispatch the specified
|
* Get the class that is being used to dispatch the specified invocation code, for
|
||||||
* invocation code, for informational purposes.
|
* informational purposes.
|
||||||
*
|
*
|
||||||
* @return the Class, or null if no dispatcher is registered with
|
* @return the Class, or null if no dispatcher is registered with
|
||||||
* the specified code.
|
* the specified code.
|
||||||
@@ -215,9 +218,8 @@ public class InvocationManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when we receive an invocation request message. Dispatches
|
* Called when we receive an invocation request message. Dispatches the request to the
|
||||||
* the request to the appropriate invocation provider via the
|
* appropriate invocation provider via the registered invocation dispatcher.
|
||||||
* registered invocation dispatcher.
|
|
||||||
*/
|
*/
|
||||||
protected void dispatchRequest (
|
protected void dispatchRequest (
|
||||||
int clientOid, int invCode, int methodId, Object[] args, Transport transport)
|
int clientOid, int invCode, int methodId, Object[] args, Transport transport)
|
||||||
@@ -243,8 +245,7 @@ public class InvocationManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// scan the args, initializing any listeners and keeping track of
|
// scan the args, initializing any listeners and keeping track of the "primary" listener
|
||||||
// the "primary" listener
|
|
||||||
ListenerMarshaller rlist = null;
|
ListenerMarshaller rlist = null;
|
||||||
int acount = args.length;
|
int acount = args.length;
|
||||||
for (int ii = 0; ii < acount; ii++) {
|
for (int ii = 0; ii < acount; ii++) {
|
||||||
@@ -291,8 +292,7 @@ public class InvocationManager
|
|||||||
", caller=" + source.who() + ", methId=" + methodId +
|
", caller=" + source.who() + ", methId=" + methodId +
|
||||||
", args=" + StringUtil.toString(args) + "].", t);
|
", args=" + StringUtil.toString(args) + "].", t);
|
||||||
|
|
||||||
// avoid logging an error when the listener notices that it's
|
// avoid logging an error when the listener notices that it's been ignored.
|
||||||
// been ignored.
|
|
||||||
if (rlist != null) {
|
if (rlist != null) {
|
||||||
rlist.setNoResponse();
|
rlist.setNoResponse();
|
||||||
}
|
}
|
||||||
@@ -322,9 +322,9 @@ public class InvocationManager
|
|||||||
/** Maps bootstrap group to lists of services to be provided to clients at boot time. */
|
/** Maps bootstrap group to lists of services to be provided to clients at boot time. */
|
||||||
protected Map<String, List<InvocationMarshaller>> _bootlists = Maps.newHashMap();
|
protected Map<String, List<InvocationMarshaller>> _bootlists = Maps.newHashMap();
|
||||||
|
|
||||||
// debugging action...
|
/** Tracks recently registered services so that we can complain informatively if a request
|
||||||
protected final Map<Integer, String> _recentRegServices =
|
* comes in on a service we don't know about. */
|
||||||
new LRUHashMap<Integer, String>(10000);
|
protected final Map<Integer, String> _recentRegServices = new LRUHashMap<Integer, String>(10000);
|
||||||
|
|
||||||
/** The text appended to the procedure name when generating a failure response. */
|
/** The text appended to the procedure name when generating a failure response. */
|
||||||
protected static final String FAILED_SUFFIX = "Failed";
|
protected static final String FAILED_SUFFIX = "Failed";
|
||||||
|
|||||||
Reference in New Issue
Block a user