// Get clock
reply.now = now;
reply.stamp = getStamp();
// gets state of all agents
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
try {
oos.writeObject(AgentIdStamp.stamp);
for (Enumeration e = agents.elements(); e.hasMoreElements();) {
Agent agent = (Agent) e.nextElement();
// Don't put the agent factory
if (! (agent instanceof AgentFactory)) {
oos.writeObject(agent.getId());
oos.writeObject(agent);
if (agent instanceof BagSerializer) {
((BagSerializer) agent).writeBag(oos);
}
}
}
oos.flush();
reply.agents = baos.toByteArray();
} finally {
try {
oos.close();
} catch (Exception exc) {}
}
// gets all pending messages
baos.reset();
oos = new ObjectOutputStream(baos);
try {
if (logmon.isLoggable(BasicLevel.DEBUG)) {
for (int i=0; i<qinFromExt.size(); i++) {
Message msg = (Message) qinFromExt.elementAt(i);
logmon.log(BasicLevel.DEBUG,
AgentServer.getName() + " getState() -> " + msg);
}
}
oos.writeObject(qinFromExt);
reply.messages = baos.toByteArray();
} finally {
try {
oos.close();
} catch (Exception exc) {}
}
// Get Network clock
reply.setNetworkStamp(jgroups.network.getStamp());