get_settings.asciidoc 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. [[java-rest-high-cluster-get-settings]]
  2. === Cluster Get Settings API
  3. The Cluster Get Settings API allows to get the cluster wide settings.
  4. [[java-rest-high-cluster-get-settings-request]]
  5. ==== Cluster Get Settings Request
  6. A `ClusterGetSettingsRequest`:
  7. ["source","java",subs="attributes,callouts,macros"]
  8. --------------------------------------------------
  9. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[get-settings-request]
  10. --------------------------------------------------
  11. ==== Optional arguments
  12. The following arguments can optionally be provided:
  13. ["source","java",subs="attributes,callouts,macros"]
  14. --------------------------------------------------
  15. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[get-settings-request-includeDefaults]
  16. --------------------------------------------------
  17. <1> By default only those settings that were explicitly set are returned. Setting this to true also returns
  18. the default settings.
  19. ["source","java",subs="attributes,callouts,macros"]
  20. --------------------------------------------------
  21. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[get-settings-request-local]
  22. --------------------------------------------------
  23. <1> By default the request goes to the master of the cluster to get the latest results. If local is specified it gets
  24. the results from whichever node the request goes to.
  25. ["source","java",subs="attributes,callouts,macros"]
  26. --------------------------------------------------
  27. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[get-settings-request-masterTimeout]
  28. --------------------------------------------------
  29. <1> Timeout to connect to the master node as a `TimeValue`
  30. <2> Timeout to connect to the master node as a `String`
  31. [[java-rest-high-cluster-get-settings-sync]]
  32. ==== Synchronous Execution
  33. ["source","java",subs="attributes,callouts,macros"]
  34. --------------------------------------------------
  35. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[get-settings-execute]
  36. --------------------------------------------------
  37. <1> Execute the request and get back the response in a `ClusterGetSettingsResponse` object.
  38. [[java-rest-high-cluster-get-settings-async]]
  39. ==== Asynchronous Execution
  40. The asynchronous execution of a cluster get settings requires both the
  41. `ClusterGetSettingsRequest` instance and an `ActionListener` instance to be
  42. passed to the asynchronous method:
  43. ["source","java",subs="attributes,callouts,macros"]
  44. --------------------------------------------------
  45. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[get-settings-execute-async]
  46. --------------------------------------------------
  47. <1> The `ClusterGetSettingsRequest` to execute and the `ActionListener`
  48. to use when the execution completes
  49. The asynchronous method does not block and returns immediately. Once it is
  50. completed the `ActionListener` is called back using the `onResponse` method
  51. if the execution successfully completed or using the `onFailure` method if
  52. it failed.
  53. A typical listener for `ClusterGetSettingsResponse` looks like:
  54. ["source","java",subs="attributes,callouts,macros"]
  55. --------------------------------------------------
  56. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[get-settings-execute-listener]
  57. --------------------------------------------------
  58. <1> Called when the execution is successfully completed. The response is
  59. provided as an argument
  60. <2> Called in case of a failure. The raised exception is provided as an argument
  61. [[java-rest-high-cluster-get-settings-response]]
  62. ==== Cluster Get Settings Response
  63. The returned `ClusterGetSettingsResponse` allows to retrieve information about the
  64. executed operation as follows:
  65. ["source","java",subs="attributes,callouts,macros"]
  66. --------------------------------------------------
  67. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[get-settings-response]
  68. --------------------------------------------------
  69. <1> Get the persistent settings.
  70. <2> Get the transient settings.
  71. <3> Get the default settings (returns empty settings if `includeDefaults` was not set to `true`).
  72. <4> Get the value as a `String` for a particular setting. The order of searching is first in `persistentSettings` then in
  73. `transientSettings` and finally, if not found in either, in `defaultSettings`.