Welcome to the BEAM Forum!

We encourage you to sign in our forum and participate in the BEAM community. The forum is maintained by the BEAM project team who will most likely answer your questions within 24 hours (except during common holidays) - if not done by other community members. Collaborate, share your knowledge and learn from other users!

If you don't find what you are looking for, please also consider the following external forums:

Combination View Flat View Tree View
Threads [ Previous | Next ]
Correct approach to cancel a graph execution in GPF
toggle
Correct approach to cancel a graph execution in GPF
gpf java api beam api
9/10/14 4:59 AM
Hello BEAM dev team,

I am invoking the GPF from within a Java web application to execute various processing graph (supplied as XMLs).

Sometimes it is necessary to cancel the the execution of a graph before it completes. I could not find a straightforward way to do this from the BEAM API (version 4.11).

What is the proper method to cancel an execution which was started using GraphProcessor.executeGraph()?

Since I'm running these from a pool of Threads, my current approach is to cancel the task using Java's Future.cancel(true). This causes task execution to stop with an OperatorException. CPU monitoring shows all processing finishes within a minute or so (I guess this could vary depending on how long the running Operators take to go through a computeTile() ). It appears as if everything is working correctly. However, I'm not sure whether this is the correct approach.

thanks
Kutila
Flag Flag
RE: Correct approach to cancel a graph execution in GPF
Answer Answer (Unmark)
9/10/14 10:47 AM as a reply to Kutila Gunasekera.
Hi Kutila,

The second parameter of the GraphProcessor.executeGraph() method is a ProgressMonitor. Create your own ProgressMonitor instance (e.g. NullProgressMonitor, or derive your own) and call ProgressMonitor.setCanceled(true) to cancel the processing running in a thread different from your current thread.

 1
 2gp = new GraphProcessor();
 3pm = new NullProgressMonitor();
 4new Thread(new Runnable() {
 5    public void run() {
 6        gp.executeGraph(graph, pm);
 7    }
 8}).start();
 9...
10pm.setCanceled(true);


However, this will not immediately cancel currently running GPF threads that are busy with single tile computations. We currently have no good solution for immediate cancellation of all the threads created for a graph execution.

By looking into the code I just saw, that the cancellation of graph processing could be implemented more effective. I created a ticket to fix that.


-- Norman
Flag Flag
RE: Correct approach to cancel a graph execution in GPF
9/11/14 6:11 AM as a reply to Norman Fomferra.
Thanks! That is what I was looking for emoticon
Flag Flag