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.