You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by djm132 <do...@gmail.com> on 2016/05/12 17:33:07 UTC
Graceful shutdown
Hi,
I've implemented grid task workers and what to shutdown them gracefully
(after finishing all active tasks). I see there is ignite.close() method
which can be broadcasted to remote nodes.
One of solution I've got from another thread looks now like this:
static class PoisonPill implements IgniteRunnable {
@IgniteInstanceResource
private transient Ignite ignite;
@Override
public void run() {
new Thread() {
@Override public void run() {
ignite.close();
}
}.start();
}
}
// Called from http API
public static void shutdownCluster() {
// Stop remote servers if connected
ClusterGroup remotes = instance.ignite.cluster().forRemotes();
if (remotes.nodes().size() > 0) {
instance.ignite.compute(remotes).broadcast(new PoisonPill());
}
// Close this instance
instance.ignite.close();
}
This code works fine, but I only if there is no active tasks on node. If
there is some task executing, I am receiving this:
2016/05/12 20:45:35.959 [http-2] WARN Will cancel unfinished tasks due to
stopping of the grid [cnt=1]
[20:45:35] (err) Failed to notify listener:
dmp.grid.Engine$$Lambda$3/31794917@347cb6e2class
org.apache.ignite.compute.ComputeTaskCancelledException: Task cancelled due
to stopping of the grid....
May be there is a way to correctly write tasks and checking for termination
?
Thanks.
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Graceful-shutdown-tp4911.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: Graceful shutdown
Posted by djm132 <do...@gmail.com>.
Thanks, now it waits for task completion. I've also implemented shutdown
check during the tasks to allow correct termination.
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Graceful-shutdown-tp4911p5088.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: Graceful shutdown
Posted by vkulichenko <va...@gmail.com>.
Hi,
Yes, ignite.close() cancels all currently running tasks. You can replace
this call with the following:
Ignition.stop(ignite.name(), false)
The second parameter means that the stopping node should not cancel tasks
and will wait for their completion.
Hope this helps.
-Val
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Graceful-shutdown-tp4911p4920.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.