Configure Plugin through Cluster Settings API - Listen for updates

Hello there,

I am writing a plugin and would like to configure it through the cluster settings API.

I have overwritten getSettings, and so far so good. I can also update my dynamic settings through the cluster settings API.

However, the change never gets propagated to the plugin. I imagine that the plugin, or the setting, would have to register a listener to react to the update.

Can anyone provide guidance on this?

May be you need to send somehow a get cluster settings call from your plugin?

Plugin#getComponents receives a ClusterService, and ClusterService#getClusterSettings yields a ClusterSettings, which has methods such as initializeAndWatch and addSettingsUpdateConsumer which allow you to register a listener for changes to particular cluster settings.


Thank you!

public Collection<Object> createComponents(... ClusterService clusterService ...) {
		settings -> updateMyDynamicSettings(settings), getSettings());
	return Collections.emptyList();

works. When I PUT host:9200/_cluster/settings my update method is called.

(I'm getting some additional update events with unexpected setting values and I haven't figured out where they come from, but that must be a different problem.)

getSettings would return some non-dynamic settings. Apparently, that seems to irritate the update logic. The spurious update events disappeared when I restricted the list of settings passed into addSettingsUpdateConsumer to only dynamic settings.

When I have time, I'll look at this some more, perhaps I'm mistaken. But my problem is solved. Thanks again.

w00t! Thanks a lot @DavidTurner :slight_smile:

1 Like

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