We have a module which generates Executing Agent Tasks to ping a specific IP at a particular rate. What we are seeing is at seemingly random times the status (Throughput) changes from xxx exec/sec to “Idle”.
What could be the cause?
Can or should they be revived? if so, how?
Have you checked the logs for any exceptions running the task? Taken a thread dump once it goes idle to see if the tasks have blocked for some reason? Make sure there’s no code unregistering the tasks for some reason? Add logging to the task at the start and finish?
A list of workers under ExecutionManager has been created which become “idle”. I can not find a method to get a list of them with their status from com.inductiveautomation.ignition.common.execution.ExecutionManager
If you cast the ExecutionManager to com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine you can call getTasks(String) with the owner name you’re using to get a list of TaskStat. There should be one for every registered task.
You'll want to cast the ExecutionManager to a BasicExecutionEngine. This would be a Java class cast. (Feel free to Google casting in Java it if you need more details on how this works.)
What you have in your second block of code is creating an entirely new, empty BasicExecutionEngine() rather than taking the existing ExecutionEngine and casting it to a BasicExecutionEngine.
I was able to cast the manager to my engine and now see my tasks. Im trying to get the specific task “problem”. so I thought to getStatMetric() monitor the throughput for -1 then getProblem(). but its always empty.
try {
if (myTaskMetric.getThroughput() == -1 ) { // -1 means the thread is idle
logger.info("Detected an idle Thread");
logger.info(myTasks.get(i).getProblem().getMessage());
logger.info(myTasks.get(i).getProblem().getStackTrace()[0]);
//myTasks.get(i).start(); //this will trigger to run the thread again
}
} catch (Exception e) {
myTasks.get(i).getProblem().printStackTrace();
e.printStackTrace();
}
in log i see my watchDog thread “threw uncaught exception.” java.lang.NullPointerException: null
That would be a bug in your watchdog thread. You need to have your watchdog catch its own errors and log them. Then you'll have a more informative backtrace.