Executing Agent Task Idle Status

Hi,

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?

Thank you in advance


including: @mgross

Do you mean that your module registers tasks with the ExecutionManager from GatewayContext? Or are you talking about something else?

I apologize if I was not clear. That correct, module registers tasks and the task runs are a particular rate. then the throughput turns idle.

Here’s some things you can try:

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

How can i get the status of each worker?

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.

Please excuse my lack of Java skills, I cant get this to work, following return an empty list:

in Startup() I have

				watchDogClass watchDog = new watchDogClass();
				context.getExecutionManager().register("Testing", "connection monitor", watchDog, 500);
				
				

then in watchDog() I have:

			BasicExecutionEngine myExecutionEngine = new BasicExecutionEngine();
			List<TaskStats> myTasks = myExecutionEngine.getTasks("Testing");
			logger.info(myTasks);

//			for(int i = 0; i < myTasks.size(); i++) {
//				logger.info(i);
//	            logger.info(myTasks.get(i).getTaskName());
//	            logger.info(myTasks.get(i).isRunning());
//	            logger.info(myTasks.get(i).getProblem());
//	        }

I also tried the following method but i wouldn’t be able to call getTasks() :

ExecutionManager myExecutionEngine2 = new BasicExecutionEngine();

Cant find any example codes

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.)

The basic code would be something like this:

BasicExecutionEngine myExecutionEngine = (BasicExecutionEngine) context.getExecutionManager()

Then calling .getTasks(“Testing”) should work.

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.

Thanks Kevin,

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

any ideas?

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.

1 Like