Subject: RE: [jade-develop] WakerBehavior messaging woes, and a deadlock?
From: Bellifemine Fabio (Fabio.Bellifemine@TILAB.COM)
Date: Wed Jul 31 2002 - 17:33:31 MET DST
John, I think the mistake should be just the method:
public void handleElapsedTimeout() {
a.Send(msg);
this.reset(msg.getDelay()); //reschedule me
a.addBehaviour(this);
}
everytime you execute handleElapsedTimeout you reschedule the behaviour
and you add a new behaviour, i.e. you double the number of behaviours
for that agent.
It should be sufficient just to remove the call
a.addBehaviour(this);
ciao, Fabio.
-----Original Message-----
From: John J. Mikucki [mailto:jjm7570@cs.rit.edu]
Sent: 27 July 2002 00:38
To: jade-develop@sharon.cselt.it
Subject: [jade-develop] WakerBehavior messaging woes, and a deadlock?
Hello--
I have implemented a class called IMGen which allows me to periodically
send a given ACLMessage. It operates by means of an inner class which
subclasses WakerBehaviour. The subclasses' handleTimeoutEvent sends the
given
ACLMessage and reschedules itself. For the first few message
deliveries,
everything is fine. Delays work as expected, only one message is sent
at a
time, and generally I am very happy.
As time passes, my agent accumulates unwanted WakerBehaviors (hereafter,
WBs).
Eventually (<30 min from startup), some unknown event takes place, and
the
entire JADE platform stops. No messages are sent or received,
containers
cannot be added nor removed, the GUIs will not update, and the RMA
(while
minimally responsive) is unable to kill the agent or to shutdown the
platform.
* Any ideas as to what I could be (accidentally) doing that would hang
up the
platform?
The Introspector Agent tells me that the agent accumulates many WBs
(when I
should only ever have 2). The only explanation I've come up with is
that I'm
not correctly removing WBs from the agent.
* When I call removeBehavior(b), is Behavior b removed immediately?
* Will it ever call handleElapsedTimeout again?
* What if it's a sleeping WB?
* Is there any way for my code to find out the number of behaviors
registered
with my agent?
In an attempt to prolong the useful system life (till I can fix my
code), I
override afterMove() to flush all the extra move messages from the
queue. This
seems to mitigate the seizure symptoms... but after some time, the RMA
still
experiences the mysterious event that incapacitates it. I must be doing
something wrong, but I'm not sure what.
When I receive a move message, I call cancelAll() (see below) so that no
new
messages would be generated. Yet, they seem to be... which leads me to
believe
that the WBs are not getting removed as I would like. Is there
something I'm
missing?
The code (my apologies in advance, I'm new with JADE) is as follows.
Note that
a RecurrentMessage is a subclass of ACLMessage with a delay variable.
public class IMGenerator implements Serializable {
protected BaseAgent a;
protected LinkedList blist;
class CBS extends WakerBehaviour {
protected RecurrentMessage msg;
protected long delay;
public CBS(Agent a, long delay) { super(a, delay);
System.out.println("Dummy.");
}
public CBS(Agent a, java.util.Date d) { super(a, d);
System.out.println("Dummy.");
}
public CBS(RecurrentMessage m) { super(a,m.getDelay());
msg=m; }
public void handleElapsedTimeout() {
a.Send(msg);
this.reset(msg.getDelay()); //reschedule me
a.addBehaviour(this);
}
}
public IMGenerator(BaseAgent a)
throws InvalidParameterException {
if (a == null) throw new InvalidParameterException
("Cannot create IMGenerator with null
agent.");
this.a = a;
blist = new LinkedList();
}
public CBS scheduleMsg(RecurrentMessage m)
throws InvalidParameterException{
if (m.getDelay() <= 0) throw new
InvalidParameterException
("cannot schedule message delivery with delay <=
0 ms");
CBS ms = new CBS(m);
blist.add(ms);
a.addBehaviour(ms);
return ms;
}
public void cancelAll() {
Iterator i = blist.iterator();
while (i.hasNext()) {
a.removeBehaviour((Behaviour)i.next());
}
blist.clear();
}
}
Lastly, a quick question about the Snooper agent. When I first snoop my
agent,
its 'box' is red in color. Soon after, it becomes yellow, but it
continues to
move and function normally. What does the yellow color signify?
Thanks!
John
-- Avoision, n: Avoidance, as practiced in 'Joisey. _______________________________________________ jade-develop mailing list jade-develop@sharon.cselt.it http://sharon.cselt.it/mailman/listinfo/jade-develop UNSUBSCRIBE INSTRUCTIONS AT http://jade.cselt.it/mailing.htm#unsubscribe
This archive was generated by hypermail 2a22 : Wed Jul 31 2002 - 17:35:01 MET DST