Bureaucracy smoke test and resulting bug fixes
* Added RegistryTester smoke test which randomly creates and destroys agents in batches * Fixed bug where correct agent id was never making it to client * Implemented Bureau.toString (+refactored summarize method) * Fixed nasty bug due to my assumption that SafeSubscriber =~ Subscriber, they are in fact completely different git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5032 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -49,8 +49,12 @@ public abstract class BureauDirector extends BasicDirector
|
||||
}
|
||||
};
|
||||
|
||||
_subscriber = new SafeSubscriber<AgentObject>(agentId, delegator);
|
||||
_subscriber.subscribe(_ctx.getDObjectManager());
|
||||
Log.info("Subscribing to object " + agentId);
|
||||
|
||||
SafeSubscriber<AgentObject> subscriber =
|
||||
new SafeSubscriber<AgentObject>(agentId, delegator);
|
||||
_subscribers.put(agentId, subscriber);
|
||||
subscriber.subscribe(_ctx.getDObjectManager());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,6 +66,7 @@ public abstract class BureauDirector extends BasicDirector
|
||||
agent = _agents.remove(agentId);
|
||||
|
||||
if (agent == null) {
|
||||
Log.warning("Lost an agent, id " + agentId);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
@@ -71,7 +76,13 @@ public abstract class BureauDirector extends BasicDirector
|
||||
Log.warning("Stopping an agent caused an exception");
|
||||
Log.logStackTrace(t);
|
||||
}
|
||||
_subscriber.unsubscribe(_ctx.getDObjectManager());
|
||||
SafeSubscriber<AgentObject> subscriber = _subscribers.remove(agentId);
|
||||
if (subscriber == null) {
|
||||
Log.warning("Lost a subscriber for agent " + agent);
|
||||
}
|
||||
else {
|
||||
subscriber.unsubscribe(_ctx.getDObjectManager());
|
||||
}
|
||||
_bureauService.agentDestroyed(_ctx.getClient(), agentId);
|
||||
}
|
||||
}
|
||||
@@ -82,6 +93,9 @@ public abstract class BureauDirector extends BasicDirector
|
||||
protected synchronized void objectAvailable (AgentObject agentObject)
|
||||
{
|
||||
int oid = agentObject.getOid();
|
||||
|
||||
Log.info("Object " + oid + " now available");
|
||||
|
||||
Agent agent;
|
||||
try {
|
||||
agent = createAgent(agentObject);
|
||||
@@ -151,5 +165,6 @@ public abstract class BureauDirector extends BasicDirector
|
||||
protected BureauContext _ctx;
|
||||
protected BureauService _bureauService;
|
||||
protected IntMap<Agent> _agents = IntMaps.newHashIntMap();
|
||||
protected SafeSubscriber<AgentObject> _subscriber;
|
||||
protected IntMap<SafeSubscriber<AgentObject>> _subscribers =
|
||||
IntMaps.newHashIntMap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user