Plugin development - Node Client has not been initialized exception

Hello,
i'm developing a plugin for elasticsearch 7.8.0 and i'm using the NodeClient to get all the mappings from the cluster on start-up, in order to find indices with "dense_vector" field types.
I am overriding the createComponents() method of the Plugin class since it is the only one that offers me the Client (node client) instance in its signature, but when i make a GetMapping request it throws an exception that "Node Client has not been initialized" and that is to be expected.

my question is if there is a flag like Cluster Health request i.e. "wait_for_status=true" for this kind of requests? for now i run in a while loop and catch the exceptions until it succeeds. (also note that calling Cluster Health fails with the same exception...)

thanks in advance,
-- Tom Elias.

A couple of possibilities off the top of my head:

  1. If your plugin implements LifecycleComponent then its start() method is called once the client is initialised.

  2. If you want to watch the cluster state for the mappings, you can use ClusterService#addListener

Hi David, Thanks for your reply.
following up, does the start() method happen after all the shards have been initialized? (and the cluster status is >= yellow?)
i am also trying to figure out the timing of onIndexModule() method, because i want to add IndexOperationListeners to specific indices according to their mapping (if they include a dense_vector or not)

Thanks,
-- Tom Elias.

No, definitely not, components like plugins are started well before a master is elected, which in turn is well before any shards are started.

That happens much later too, but before shards are initialised.

ok, so the way i see it, i would have to create a class extending a Listener during createComponents() and have it store a reference to the NodeClient, and install that listener on the ClusterService to run when the Cluster status becomes yellow.
because, even though i am able to get the mapping before the NodeClient starts or the shards are initialized (during onIndexModule, by using reflection), i still need to scroll over those indices that i've found.

Thanks,
-- Tom Elias.

I can't comment on whether this you have found absolutely the best approach, but certainly the intention of passing all that junk to createComponents() is so that you can capture it and use it later.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.