You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Marasoiu Nicolae <Ni...@cegeka.com> on 2016/08/29 14:43:32 UTC

how to automatically exit JVM when the node stops?

Hi,


When the Ignite node.stop() is called (e.g. the default segmentation strategy), or when the "main" thread exists, we would like to have the JVM automatically exit as well.


We have threads from Ignite, from RxJava, Vert.x, Netty, and a "main" thread, for boot.


We understand why the JVM does not exit when the "main" thread exits or when the Ignite threads exit (due to a stop initiated on node-partitioned/segmented for instance). Simply there are lots of non-daemon threads, and for a reason: protecting any I/O they would be doing.


However this makes it that we can find running JVMs which are no longer connected in the grid (and which do not retry to connect due to say a segmentation and a stop, the default strategy). Or ones which did not correctly initialize but remain running as processes.


Do you have any advice on how to be able to have the JVM automatically exit when Ignite gives up on being part of the cluster, for instance?


One way to do it is mark all the threads with daemon, except one - we can have the main thread forever blocking after booting the application. This is risky - we can loose/corrupt data if threads are doing I/O when the JVM abruptly shuts down. Still, being a resilient system which anyway needs to deal with such anomalies, that may still be a possible solution, albeit an ugly one.


Another one, which would treat strictly the segmentation scenario is to register a handler to the Ignite events that treats segmentation-event by doing a System.exit.


However, I think we need a general solution to stop the JVM when going out of memory, or any other Error, or out of grid/network, or when the main thread throws an exception while booting (of course the main thread would not exit after a successful boot, we would do like an infinite sleep there or wait for lock we never unlock).


Which way do you suggest?



Met vriendelijke groeten/Meilleures salutations/Best regards

Nicolae Marasoiu
Agile Developer
E Nicolae.Marasoiu@cegeka.com<ma...@cegeka.com>

[http://signature.cegeka.com/mailsignature_cgk.png]
CEGEKA * 15-17 Ion Mihalache Blvd. Tower Center Building, 4th,5th,6th fl * RO-011171 Bucharest (RO) * T +40 21 336 20 65 * www.cegeka.com
Volg Cegeka: [http://signature.cegeka.com/twitter.png] <http://www.twitter.com/cegeka>  [http://signature.cegeka.com/linkedin.png] <http://www.linkedin.com/company/cegeka>  [http://signature.cegeka.com/facebook.png] <http://www.facebook.com/Cegeka>  [http://signature.cegeka.com/google-plus.png] <http://www.cegeka.be/googleplus>

Re: how to automatically exit JVM when the node stops?

Posted by luqmanahmad <lu...@gmail.com>.
See [1] for free network segmentation plugin

[1]  https://github.com/luqmanahmad/ignite-plugins
<https://github.com/luqmanahmad/ignite-plugins>  



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: how to automatically exit JVM when the node stops?

Posted by vkulichenko <va...@gmail.com>.
Hi Nicolae,

You should listen for EVT_NODE_SEGMENTED through IgniteEvents API, like with
any other events. There is no such configuration on the discovery SPI.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/how-to-automatically-exit-JVM-when-the-node-stops-tp7372p7496.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: how to automatically exit JVM when the node stops?

Posted by Marasoiu Nicolae <Ni...@cegeka.com>.
?Hi,


So I think we found it:


1. For EVT_NODE_SEGMENTED, I think it is a "discovery event" and we register a listener on the tcp discovery component of the ignite configuration.

2. For other events, Ignite offer possibility to listen to local or remote events, at Ignite (global) level or at cache level.


Met vriendelijke groeten/Meilleures salutations/Best regards

Nicolae Marasoiu
Agile Developer
E Nicolae.Marasoiu@cegeka.com<ma...@cegeka.com>

[http://signature.cegeka.com/mailsignature_cgk.png]
CEGEKA * 15-17 Ion Mihalache Blvd. Tower Center Building, 4th,5th,6th fl * RO-011171 Bucharest (RO) * T +40 21 336 20 65 * www.cegeka.com
Volg Cegeka: [http://signature.cegeka.com/twitter.png] <http://www.twitter.com/cegeka>  [http://signature.cegeka.com/linkedin.png] <http://www.linkedin.com/company/cegeka>  [http://signature.cegeka.com/facebook.png] <http://www.facebook.com/Cegeka>  [http://signature.cegeka.com/google-plus.png] <http://www.cegeka.be/googleplus>
________________________________
De la: Marasoiu Nicolae
Trimis: 2 septembrie 2016 16:20
Către: user@ignite.apache.org
Subiect: Re: how to automatically exit JVM when the node stops?


Hi Kamal,


It seems that the only events available on the lifecycle (the classes you mentioned e.g. LifecycleBean and LifecycleEventType) are those of "node started" and "node stopped".


There must other classes of events and event handlers for the case of segmentation and other events. Ignite has both messages and events, we are not sure what this would be either (message or event; local or remote).


Thank you,

Nicu


Met vriendelijke groeten/Meilleures salutations/Best regards

Nicolae Marasoiu
Agile Developer
E Nicolae.Marasoiu@cegeka.com<ma...@cegeka.com>

[http://signature.cegeka.com/mailsignature_cgk.png]
CEGEKA * 15-17 Ion Mihalache Blvd. Tower Center Building, 4th,5th,6th fl * RO-011171 Bucharest (RO) * T +40 21 336 20 65 * www.cegeka.com
Volg Cegeka: [http://signature.cegeka.com/twitter.png] <http://www.twitter.com/cegeka>  [http://signature.cegeka.com/linkedin.png] <http://www.linkedin.com/company/cegeka>  [http://signature.cegeka.com/facebook.png] <http://www.facebook.com/Cegeka>  [http://signature.cegeka.com/google-plus.png] <http://www.cegeka.be/googleplus>
________________________________
De la: Kamal C <ka...@gmail.com>
Trimis: 30 august 2016 13:35
Către: user@ignite.apache.org
Subiect: Re: how to automatically exit JVM when the node stops?

Implement the Ignite LifeCycleBean [1] and stop the JVM on receiving the event [2]

[1]: https://ignite.apache.org/releases/mobile/org/apache/ignite/lifecycle/LifecycleBean.html
[2]: https://ignite.apache.org/releases/mobile/org/apache/ignite/lifecycle/LifecycleEventType.html#AFTER_NODE_STOP

-- Kamal

On Tue, Aug 30, 2016 at 3:31 AM, vkulichenko <va...@gmail.com>> wrote:
Hi,

I don't think there is a generic solution for cases when an Ignite node is
embedded into other application. You will always need to figure out what to
do with other components of this application. You can listen to Ignite
events (e.g., EVT_NODE_SEGMENTED) and act accordingly in the listener.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/how-to-automatically-exit-JVM-when-the-node-stops-tp7372p7389.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: how to automatically exit JVM when the node stops?

Posted by Marasoiu Nicolae <Ni...@cegeka.com>.
Hi Kamal,


It seems that the only events available on the lifecycle (the classes you mentioned e.g. LifecycleBean and LifecycleEventType) are those of "node started" and "node stopped".


There must other classes of events and event handlers for the case of segmentation and other events. Ignite has both messages and events, we are not sure what this would be either (message or event; local or remote).


Thank you,

Nicu


Met vriendelijke groeten/Meilleures salutations/Best regards

Nicolae Marasoiu
Agile Developer
E Nicolae.Marasoiu@cegeka.com<ma...@cegeka.com>

[http://signature.cegeka.com/mailsignature_cgk.png]
CEGEKA * 15-17 Ion Mihalache Blvd. Tower Center Building, 4th,5th,6th fl * RO-011171 Bucharest (RO) * T +40 21 336 20 65 * www.cegeka.com
Volg Cegeka: [http://signature.cegeka.com/twitter.png] <http://www.twitter.com/cegeka>  [http://signature.cegeka.com/linkedin.png] <http://www.linkedin.com/company/cegeka>  [http://signature.cegeka.com/facebook.png] <http://www.facebook.com/Cegeka>  [http://signature.cegeka.com/google-plus.png] <http://www.cegeka.be/googleplus>
________________________________
De la: Kamal C <ka...@gmail.com>
Trimis: 30 august 2016 13:35
Către: user@ignite.apache.org
Subiect: Re: how to automatically exit JVM when the node stops?

Implement the Ignite LifeCycleBean [1] and stop the JVM on receiving the event [2]

[1]: https://ignite.apache.org/releases/mobile/org/apache/ignite/lifecycle/LifecycleBean.html
[2]: https://ignite.apache.org/releases/mobile/org/apache/ignite/lifecycle/LifecycleEventType.html#AFTER_NODE_STOP

-- Kamal

On Tue, Aug 30, 2016 at 3:31 AM, vkulichenko <va...@gmail.com>> wrote:
Hi,

I don't think there is a generic solution for cases when an Ignite node is
embedded into other application. You will always need to figure out what to
do with other components of this application. You can listen to Ignite
events (e.g., EVT_NODE_SEGMENTED) and act accordingly in the listener.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/how-to-automatically-exit-JVM-when-the-node-stops-tp7372p7389.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: how to automatically exit JVM when the node stops?

Posted by Kamal C <ka...@gmail.com>.
Implement the Ignite LifeCycleBean [1] and stop the JVM on receiving the
event [2]

[1]:
https://ignite.apache.org/releases/mobile/org/apache/ignite/lifecycle/LifecycleBean.html
[2]:
https://ignite.apache.org/releases/mobile/org/apache/ignite/lifecycle/LifecycleEventType.html#AFTER_NODE_STOP

-- Kamal

On Tue, Aug 30, 2016 at 3:31 AM, vkulichenko <va...@gmail.com>
wrote:

> Hi,
>
> I don't think there is a generic solution for cases when an Ignite node is
> embedded into other application. You will always need to figure out what to
> do with other components of this application. You can listen to Ignite
> events (e.g., EVT_NODE_SEGMENTED) and act accordingly in the listener.
>
> -Val
>
>
>
> --
> View this message in context: http://apache-ignite-users.
> 70518.x6.nabble.com/how-to-automatically-exit-JVM-when-
> the-node-stops-tp7372p7389.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Re: how to automatically exit JVM when the node stops?

Posted by vkulichenko <va...@gmail.com>.
Hi,

I don't think there is a generic solution for cases when an Ignite node is
embedded into other application. You will always need to figure out what to
do with other components of this application. You can listen to Ignite
events (e.g., EVT_NODE_SEGMENTED) and act accordingly in the listener.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/how-to-automatically-exit-JVM-when-the-node-stops-tp7372p7389.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.