You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Lukas Polacek <lu...@innovatrics.com> on 2018/12/19 12:10:01 UTC

Register listeners before joining the cluster

Hi,
is there a way to register local listeners before a node joins the cluster?

The documentation says to register local listeners through
"ignite.events().localListen(...)", however that can only be done once e.g.
"ignite = Ignition.start(cfg)" has been called. At that point the node
might have already joined the cluster, so we might have missed events in
the meantime.

I'm thinking of adding a new lifecycle event type "BEFORE_CLUSTER_JOIN"
which I would be able to process via a Lifecycle Bean. The event would be
triggered using "notifyLifecycleBeans(BEFORE_CLUSTER_JOIN)" somewhere here
in the code:
https://github.com/apache/ignite/blob/7d4e1fd118845f6e14638520ac10881deadd570c/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java#L1051-L1051

Is there a better way without modifying Ignite code? Can I postpone cluster
joining? Or can I register the listeners at an earlier stage?

Re: Register listeners before joining the cluster

Posted by aealexsandrov <ae...@gmail.com>.
Hi,

Yes, I understand. You also can contribute this new event to Ignite:

1)Create the Jira issue - https://issues.apache.org/jira
2)Prepare the patch in a separate branch named ignite-XXXXX (where XXXXX is
a number of JIRA ticket)
3)Create the pull request in GitHub to master branch -
https://github.com/apache/ignite
4)Use next tool - https://mtcga.gridgain.com/ -> inspect contribution ->
trigger build
5)When the test run will be done, check the report and if there is no issues
push comment Jira.
6)Create the new thread in the development user list
(http://apache-ignite-developers.2346864.n4.nabble.com/) and ask to review
your change and merge.

Or just file the feature request and wait until it will proceed. But it will
take some time.

BR,
Andrei



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

Re: Register listeners before joining the cluster

Posted by Lukas Polacek <lu...@innovatrics.com>.
Hi,
the suggestion to use BEFORE_NODE_START doesn't work, I'm getting
org.apache.ignite.IgniteCheckedException: Grid is in invalid state to
perform this operation. It either not started yet or has already being or
have stopped [igniteInstanceName=Ignite IDKit Server, state=STARTING]

I got it working by creating a new lifecycle event BEFORE_CLUSTER_JOIN and
calling "notifyLifecycleBeans(BEFORE_CLUSTER_JOIN)" at
https://github.com/apache/ignite/blob/7d4e1fd118845f6e14638520ac10881deadd570c/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java#L1075-L1075
(slightly further in the code than I suggested previously).

I'll try your suggestion to use PluginProvider next.

On Wed, Dec 19, 2018 at 2:38 PM aealexsandrov <ae...@gmail.com>
wrote:

> Hi,
>
> Depends on what you are going to archive:
>
> In case if you are going to just collect some information then you can use:
>
> https://apacheignite.readme.io/docs/ignite-life-cycle
>
> BEFORE_NODE_START
>
> Invoked before Ignite node startup routine is initiated.
>
> In case if you are going to make some desition about should a node be
> joined
> or not that you can use the next method (in a separate plugin):
>
>
> https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/plugin/PluginProvider.html#validateNewNode-org.apache.ignite.cluster.ClusterNode-
>
> BR,
> Andrei
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Re: Register listeners before joining the cluster

Posted by aealexsandrov <ae...@gmail.com>.
Hi,

Depends on what you are going to archive:

In case if you are going to just collect some information then you can use:

https://apacheignite.readme.io/docs/ignite-life-cycle 

BEFORE_NODE_START

Invoked before Ignite node startup routine is initiated.

In case if you are going to make some desition about should a node be joined
or not that you can use the next method (in a separate plugin):

https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/plugin/PluginProvider.html#validateNewNode-org.apache.ignite.cluster.ClusterNode-

BR,
Andrei



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