49
49
import java .util .HashMap ;
50
50
import java .util .List ;
51
51
import java .util .Map ;
52
+ import java .util .function .BiConsumer ;
52
53
53
54
import static java .util .Collections .emptyMap ;
54
55
import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertAcked ;
@@ -75,13 +76,13 @@ public void testClusterPutSettings() throws IOException {
75
76
setRequest .persistentSettings (map );
76
77
77
78
ClusterUpdateSettingsResponse setResponse = execute (setRequest , highLevelClient ().cluster ()::putSettings ,
78
- highLevelClient ().cluster ()::putSettingsAsync );
79
+ highLevelClient ().cluster ()::putSettingsAsync );
79
80
80
81
assertAcked (setResponse );
81
82
assertThat (setResponse .getTransientSettings ().get (transientSettingKey ), notNullValue ());
82
83
assertThat (setResponse .getTransientSettings ().get (persistentSettingKey ), nullValue ());
83
84
assertThat (setResponse .getTransientSettings ().get (transientSettingKey ),
84
- equalTo (transientSettingValue + ByteSizeUnit .BYTES .getSuffix ()));
85
+ equalTo (transientSettingValue + ByteSizeUnit .BYTES .getSuffix ()));
85
86
assertThat (setResponse .getPersistentSettings ().get (transientSettingKey ), nullValue ());
86
87
assertThat (setResponse .getPersistentSettings ().get (persistentSettingKey ), notNullValue ());
87
88
assertThat (setResponse .getPersistentSettings ().get (persistentSettingKey ), equalTo (persistentSettingValue ));
@@ -97,7 +98,7 @@ public void testClusterPutSettings() throws IOException {
97
98
resetRequest .persistentSettings ("{\" " + persistentSettingKey + "\" : null }" , XContentType .JSON );
98
99
99
100
ClusterUpdateSettingsResponse resetResponse = execute (resetRequest , highLevelClient ().cluster ()::putSettings ,
100
- highLevelClient ().cluster ()::putSettingsAsync );
101
+ highLevelClient ().cluster ()::putSettingsAsync );
101
102
102
103
assertThat (resetResponse .getTransientSettings ().get (transientSettingKey ), equalTo (null ));
103
104
assertThat (resetResponse .getPersistentSettings ().get (persistentSettingKey ), equalTo (null ));
@@ -111,17 +112,28 @@ public void testClusterPutSettings() throws IOException {
111
112
assertThat (persistentResetValue , equalTo (null ));
112
113
}
113
114
114
- public void testClusterUpdateSettingNonExistent () {
115
+ public void testClusterUpdateTransientSettingNonExistent () {
116
+ testClusterUpdateSettingNonExistent ((settings , request ) -> request .transientSettings (settings ), "transient" );
117
+ }
118
+
119
+ public void testClusterUpdatePersistentSettingNonExistent () {
120
+ testClusterUpdateSettingNonExistent ((settings , request ) -> request .persistentSettings (settings ), "persistent" );
121
+ }
122
+
123
+ private void testClusterUpdateSettingNonExistent (
124
+ final BiConsumer <Settings .Builder , ClusterUpdateSettingsRequest > consumer ,
125
+ String label ) {
115
126
String setting = "no_idea_what_you_are_talking_about" ;
116
127
int value = 10 ;
117
128
ClusterUpdateSettingsRequest clusterUpdateSettingsRequest = new ClusterUpdateSettingsRequest ();
118
- clusterUpdateSettingsRequest . transientSettings (Settings .builder ().put (setting , value ). build () );
129
+ consumer . accept (Settings .builder ().put (setting , value ), clusterUpdateSettingsRequest );
119
130
120
131
ElasticsearchException exception = expectThrows (ElasticsearchException .class , () -> execute (clusterUpdateSettingsRequest ,
121
- highLevelClient ().cluster ()::putSettings , highLevelClient ().cluster ()::putSettingsAsync ));
132
+ highLevelClient ().cluster ()::putSettings , highLevelClient ().cluster ()::putSettingsAsync ));
122
133
assertThat (exception .status (), equalTo (RestStatus .BAD_REQUEST ));
123
134
assertThat (exception .getMessage (), equalTo (
124
- "Elasticsearch exception [type=illegal_argument_exception, reason=transient setting [" + setting + "], not recognized]" ));
135
+ "Elasticsearch exception [type=illegal_argument_exception, reason="
136
+ + label + " setting [" + setting + "], not recognized]" ));
125
137
}
126
138
127
139
public void testClusterGetSettings () throws IOException {
@@ -183,7 +195,7 @@ public void testClusterHealthYellowClusterLevel() throws IOException {
183
195
ClusterHealthResponse response = execute (request , highLevelClient ().cluster ()::health , highLevelClient ().cluster ()::healthAsync );
184
196
185
197
logger .info ("Shard stats\n {}" , EntityUtils .toString (
186
- client ().performRequest (new Request ("GET" , "/_cat/shards" )).getEntity ()));
198
+ client ().performRequest (new Request ("GET" , "/_cat/shards" )).getEntity ()));
187
199
assertThat (response .getIndices ().size (), equalTo (0 ));
188
200
}
189
201
@@ -204,7 +216,7 @@ public void testClusterHealthYellowIndicesLevel() throws IOException {
204
216
ClusterHealthResponse response = execute (request , highLevelClient ().cluster ()::health , highLevelClient ().cluster ()::healthAsync );
205
217
206
218
logger .info ("Shard stats\n {}" , EntityUtils .toString (
207
- client ().performRequest (new Request ("GET" , "/_cat/shards" )).getEntity ()));
219
+ client ().performRequest (new Request ("GET" , "/_cat/shards" )).getEntity ()));
208
220
assertYellowShards (response );
209
221
assertThat (response .getIndices ().size (), equalTo (2 ));
210
222
for (Map .Entry <String , ClusterIndexHealth > entry : response .getIndices ().entrySet ()) {
@@ -226,7 +238,6 @@ private static void assertYellowShards(ClusterHealthResponse response) {
226
238
assertThat (response .getUnassignedShards (), equalTo (2 ));
227
239
}
228
240
229
-
230
241
public void testClusterHealthYellowSpecificIndex () throws IOException {
231
242
createIndex ("index" , Settings .EMPTY );
232
243
createIndex ("index2" , Settings .EMPTY );
@@ -317,19 +328,19 @@ public void testRemoteInfo() throws Exception {
317
328
ClusterGetSettingsResponse settingsResponse = highLevelClient ().cluster ().getSettings (settingsRequest , RequestOptions .DEFAULT );
318
329
319
330
List <String > seeds = SniffConnectionStrategy .REMOTE_CLUSTER_SEEDS
320
- .getConcreteSettingForNamespace (clusterAlias )
321
- .get (settingsResponse .getTransientSettings ());
331
+ .getConcreteSettingForNamespace (clusterAlias )
332
+ .get (settingsResponse .getPersistentSettings ());
322
333
int connectionsPerCluster = SniffConnectionStrategy .REMOTE_CONNECTIONS_PER_CLUSTER
323
- .get (settingsResponse .getTransientSettings ());
334
+ .get (settingsResponse .getPersistentSettings ());
324
335
TimeValue initialConnectionTimeout = RemoteClusterService .REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING
325
- .get (settingsResponse .getTransientSettings ());
336
+ .get (settingsResponse .getPersistentSettings ());
326
337
boolean skipUnavailable = RemoteClusterService .REMOTE_CLUSTER_SKIP_UNAVAILABLE
327
- .getConcreteSettingForNamespace (clusterAlias )
328
- .get (settingsResponse .getTransientSettings ());
338
+ .getConcreteSettingForNamespace (clusterAlias )
339
+ .get (settingsResponse .getPersistentSettings ());
329
340
330
341
RemoteInfoRequest request = new RemoteInfoRequest ();
331
342
RemoteInfoResponse response = execute (request , highLevelClient ().cluster ()::remoteInfo ,
332
- highLevelClient ().cluster ()::remoteInfoAsync );
343
+ highLevelClient ().cluster ()::remoteInfoAsync );
333
344
334
345
assertThat (response , notNullValue ());
335
346
assertThat (response .getInfos ().size (), equalTo (1 ));
0 commit comments