You are not logged in.
Pages: 1
Hi,
I'm trying to reduce the number of agent on my MadKit applications.
When my launcher recieve a message, he update the number of living agents.
When he tries to delete some agents I got this error message
[MadkitKernel-0] SEVERE : ********************** KERNEL PROBLEM, please bug report Kill failed: Robot-5 (ACTIVATED)
** java.util.concurrent.ExecutionException: java.lang.NullPointerException
at madkit.kernel.MadkitKernel.killAgent(Unknown Source)
at Lanceur.delAgent(Lanceur.java:49)
at Lanceur.live(Lanceur.java:91)
Caused by: java.lang.NullPointerException
at madkit.kernel.MadkitKernel.killThreadedAgent(Unknown Source)
at madkit.kernel.MadkitKernel.killingAgent(Unknown Source)
at madkit.kernel.MadkitKernel.access$500(Unknown Source)
at madkit.kernel.MadkitKernel$13.call(Unknown Source)
at madkit.kernel.MadkitKernel$13.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
I'm not able to see what can cause this error. Especially since the delete part (which cause the bug) is a copy of the one in the Bee example.
Any idea of what can cause that ?
Portion of the code used
private ArrayList<AbstractAgent> robotsList = new ArrayList<>(5);
@Override
protected void live()
{
while (true)
{
if(! isMessageBoxEmpty() )
{
Message m = purgeMailbox();
@SuppressWarnings("unchecked")
Integer nbAgentWanted = ((ObjectMessage<Integer>)m).getContent();
int diff = nbAgentWanted - numberOfAgent;
if (diff > 0)
{
addAgent(diff);
}
else if (diff < 0)
{
delAgent(-1*diff);
}
numberOfAgent = nbAgentWanted;
}
}
}
synchronized private void delAgent(int nb)
{
int j = 0;
for(final Iterator<AbstractAgent> i = robotsList.iterator();i.hasNext() && j < nb;j++)
{
if (j % 100 == 0) {
Thread.yield();
}
final AbstractAgent a = i.next();
if(a != null)
{
i.remove();
killAgent(a,0);
}
else
{
break;
}
}
}
Last edited by elnabo (2013-11-21 14:20:07)
Offline
Hi,
Hard to say something now. Could you please send me a zip of your project so that I can check it ?
Offline
You can get a small version of it here
https://www.dropbox.com/s/13964p07fve5i … illing.zip
The bugged part is the deletion of agent with the slider.
Thanks for your time.
Last edited by elnabo (2013-11-21 19:25:11)
Offline
Hi,
Just make the Robot class inherit from the AbstractAgent class and your issue will be solved : public class Robot extends AbstractAgent.
In fact the bucket launch is supposed to be used for launching a lot of agents, and thus they were supposed to be AbstractAgent (not threaded), "simulation mode agent".
This is unchecked for now so that your launched threaded agents were not initialized correctly, making the kill failed.
I am working on a fix.
Offline
Thanks a lot for that.
Offline
Pages: 1