put_settings.asciidoc 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. [[java-rest-high-cluster-put-settings]]
  2. === Cluster Update Settings API
  3. The Cluster Update Settings API allows to update cluster wide settings.
  4. [[java-rest-high-cluster-put-settings-request]]
  5. ==== Cluster Update Settings Request
  6. A `ClusterUpdateSettingsRequest`:
  7. ["source","java",subs="attributes,callouts,macros"]
  8. --------------------------------------------------
  9. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-request]
  10. --------------------------------------------------
  11. ==== Cluster Settings
  12. At least one setting to be updated must be provided:
  13. ["source","java",subs="attributes,callouts,macros"]
  14. --------------------------------------------------
  15. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-request-cluster-settings]
  16. --------------------------------------------------
  17. <1> Sets the transient settings to be applied
  18. <2> Sets the persistent setting to be applied
  19. ==== Providing the Settings
  20. The settings to be applied can be provided in different ways:
  21. ["source","java",subs="attributes,callouts,macros"]
  22. --------------------------------------------------
  23. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-create-settings]
  24. --------------------------------------------------
  25. <1> Creates a transient setting as `Settings`
  26. <2> Creates a persistent setting as `Settings`
  27. ["source","java",subs="attributes,callouts,macros"]
  28. --------------------------------------------------
  29. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-settings-builder]
  30. --------------------------------------------------
  31. <1> Settings provided as `Settings.Builder`
  32. ["source","java",subs="attributes,callouts,macros"]
  33. --------------------------------------------------
  34. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-settings-source]
  35. --------------------------------------------------
  36. <1> Settings provided as `String`
  37. ["source","java",subs="attributes,callouts,macros"]
  38. --------------------------------------------------
  39. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-settings-map]
  40. --------------------------------------------------
  41. <1> Settings provided as a `Map`
  42. ==== Optional Arguments
  43. The following arguments can optionally be provided:
  44. ["source","java",subs="attributes,callouts,macros"]
  45. --------------------------------------------------
  46. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-request-timeout]
  47. --------------------------------------------------
  48. <1> Timeout to wait for the all the nodes to acknowledge the settings were applied
  49. as a `TimeValue`
  50. <2> Timeout to wait for the all the nodes to acknowledge the settings were applied
  51. as a `String`
  52. ["source","java",subs="attributes,callouts,macros"]
  53. --------------------------------------------------
  54. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-request-masterTimeout]
  55. --------------------------------------------------
  56. <1> Timeout to connect to the master node as a `TimeValue`
  57. <2> Timeout to connect to the master node as a `String`
  58. [[java-rest-high-cluster-put-settings-sync]]
  59. ==== Synchronous Execution
  60. ["source","java",subs="attributes,callouts,macros"]
  61. --------------------------------------------------
  62. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-execute]
  63. --------------------------------------------------
  64. [[java-rest-high-cluster-put-settings-async]]
  65. ==== Asynchronous Execution
  66. The asynchronous execution of a cluster update settings requires both the
  67. `ClusterUpdateSettingsRequest` instance and an `ActionListener` instance to be
  68. passed to the asynchronous method:
  69. ["source","java",subs="attributes,callouts,macros"]
  70. --------------------------------------------------
  71. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-execute-async]
  72. --------------------------------------------------
  73. <1> The `ClusterUpdateSettingsRequest` to execute and the `ActionListener`
  74. to use when the execution completes
  75. The asynchronous method does not block and returns immediately. Once it is
  76. completed the `ActionListener` is called back using the `onResponse` method
  77. if the execution successfully completed or using the `onFailure` method if
  78. it failed.
  79. A typical listener for `ClusterUpdateSettingsResponse` looks like:
  80. ["source","java",subs="attributes,callouts,macros"]
  81. --------------------------------------------------
  82. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-execute-listener]
  83. --------------------------------------------------
  84. <1> Called when the execution is successfully completed. The response is
  85. provided as an argument
  86. <2> Called in case of a failure. The raised exception is provided as an argument
  87. [[java-rest-high-cluster-put-settings-response]]
  88. ==== Cluster Update Settings Response
  89. The returned `ClusterUpdateSettings` allows to retrieve information about the
  90. executed operation as follows:
  91. ["source","java",subs="attributes,callouts,macros"]
  92. --------------------------------------------------
  93. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-response]
  94. --------------------------------------------------
  95. <1> Indicates whether all of the nodes have acknowledged the request
  96. <2> Indicates which transient settings have been applied
  97. <3> Indicates which persistent settings have been applied