I would like to read the Cluster Settings using ES Java Client. I have tried the following code but it always returns an empty settings:
`Settings settings = client.admin().cluster().prepareState().execute().actionGet().getState().getMetaData().settings();`
But if I edit a Setting value using ES Java Client and then after executing the above code, I get only that Setting
Is there a way to get all Cluster Settings using ES Java Client?
IIRC you can only access to explicit settings you defined. If you are using default settings, then this will return empty.
My requirement is to get the value of 'discovery.zen.ping.unicast.hosts'. Is there any other API which gives me this information?
So if we can't read the default settings, then is it a good idea to write a plugin which will read elasticsearch.yml and create an index for storing all the values? And from the created index, I can read the settings?
Yes, I have set it.
Now I have 1 Master Node (1), 1 Master/Data Node (2) and 1 Data Node (3). All nodes 'discovery.zen.ping.unicast.hosts' setting points to (1). Now I would like to programmatically set another master node (2). Before I set I need to know what is the existing value and then I need to update the elasticsearch.yml file and restart all the nodes.
discovery.zen.ping.unicast.hosts is a node level settings IIRC. It does not belong to the cluster level settings. So you can't set it cluster wise.
You need to change it in
config/elasticsearch.yml and restart the node I think.
Fine, thanks for the clarification. I was under assumption that it's a Cluster Settings. As you said, I need to update elasticsearch.yml file, that I already thought of.
Again coming back to same question, how can I read the settings specified in elasticsearch.yml file through ES Java API? Is the only way to implement through a Custom Plugin, which will read the file when ES Nodes starts and put it in one Index?
There's no way to read this info from the APIs at the moment, though https://github.com/elastic/elasticsearch/issues/10713 may be of interest.