There are zillions of invocation dispatchers registered with a multitude

of codes. Currently the unit dump that is done once every 15 minutes is
chock-full of one-off units. Let us report the short class name of
the dispatcher, rather than the code with which an instance is registered.

Also: Thou shalt always iterate over the entrySet of a Map if thou planneth
to utilize both the key and the value.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3694 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2005-09-05 05:38:58 +00:00
parent c3f418d1ac
commit 92e4e9cfaf
2 changed files with 27 additions and 9 deletions
@@ -151,6 +151,19 @@ public class InvocationManager
} }
} }
/**
* Get the class that is being used to dispatch the specified
* invocation code, for informational purposes.
*
* @return the Class, or null if no dispatcher is registered with
* the specified code.
*/
public Class getDispatcherClass (int invCode)
{
Object dispatcher = _dispatchers.get(invCode);
return (dispatcher == null) ? null : dispatcher.getClass();
}
public void objectAvailable (DObject object) public void objectAvailable (DObject object)
{ {
// this must be our invocation object // this must be our invocation object
@@ -25,6 +25,7 @@ import java.lang.reflect.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import sun.misc.Perf; import sun.misc.Perf;
@@ -309,8 +310,11 @@ public class PresentsDObjectMgr
cname = StringUtil.shortClassName(cname); cname = StringUtil.shortClassName(cname);
} else if (unit instanceof InvocationRequestEvent) { } else if (unit instanceof InvocationRequestEvent) {
InvocationRequestEvent ire = (InvocationRequestEvent)unit; InvocationRequestEvent ire = (InvocationRequestEvent)unit;
cname = "dobj.InvocationRequestEvent:" + Class c = PresentsServer.invmgr.getDispatcherClass(
ire.getInvCode() + ":" + ire.getMethodId(); ire.getInvCode());
cname = (c == null)
? "dobj.InvocationRequestEvent:(no longer registered)"
: StringUtil.shortClassName(c) + ":" + ire.getMethodId();
} else { } else {
cname = StringUtil.shortClassName(unit); cname = StringUtil.shortClassName(unit);
} }
@@ -467,10 +471,10 @@ public class PresentsDObjectMgr
*/ */
public void dumpUnitProfiles () public void dumpUnitProfiles ()
{ {
Iterator iter = _profiles.keySet().iterator(); for (Iterator itr = _profiles.entrySet().iterator(); itr.hasNext(); ) {
while (iter.hasNext()) { Map.Entry entry = (Map.Entry) itr.next();
String cname = (String)iter.next(); String cname = (String) entry.getKey();
UnitProfile uprof = (UnitProfile)_profiles.get(cname); UnitProfile uprof = (UnitProfile) entry.getValue();
Log.info("P: " + cname + " => " + uprof); Log.info("P: " + cname + " => " + uprof);
} }
} }
@@ -732,9 +736,10 @@ public class PresentsDObjectMgr
report.append("- Unit profiles: ").append(_profiles.size()); report.append("- Unit profiles: ").append(_profiles.size());
report.append("\n"); report.append("\n");
for (Iterator iter = _profiles.keySet().iterator(); iter.hasNext(); ) { for (Iterator itr = _profiles.entrySet().iterator(); itr.hasNext(); ) {
String cname = (String)iter.next(); Map.Entry entry = (Map.Entry) itr.next();
UnitProfile uprof = (UnitProfile)_profiles.get(cname); String cname = (String) entry.getKey();
UnitProfile uprof = (UnitProfile) entry.getValue();
report.append(" ").append(cname).append(" ").append(uprof); report.append(" ").append(cname).append(" ").append(uprof);
report.append("\n"); report.append("\n");
} }