use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse in project elasticsearch by elastic.
the class AckClusterUpdateSettingsIT method testClusterUpdateSettingsNoAcknowledgement.
public void testClusterUpdateSettingsNoAcknowledgement() {
client().admin().indices().prepareCreate("test").setSettings(Settings.builder().put("number_of_shards", between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS)).put("number_of_replicas", 0)).get();
ensureGreen();
// now that the cluster is stable, remove timeout
removePublishTimeout();
NodesInfoResponse nodesInfo = client().admin().cluster().prepareNodesInfo().get();
String excludedNodeId = null;
for (NodeInfo nodeInfo : nodesInfo.getNodes()) {
if (nodeInfo.getNode().isDataNode()) {
excludedNodeId = nodeInfo.getNode().getId();
break;
}
}
assertNotNull(excludedNodeId);
ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin().cluster().prepareUpdateSettings().setTimeout("0s").setTransientSettings(Settings.builder().put("cluster.routing.allocation.exclude._id", excludedNodeId)).get();
assertThat(clusterUpdateSettingsResponse.isAcknowledged(), equalTo(false));
assertThat(clusterUpdateSettingsResponse.getTransientSettings().get("cluster.routing.allocation.exclude._id"), equalTo(excludedNodeId));
}
use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse in project elasticsearch by elastic.
the class AckClusterUpdateSettingsIT method testClusterUpdateSettingsAcknowledgement.
public void testClusterUpdateSettingsAcknowledgement() {
createIndex("test");
ensureGreen();
// now that the cluster is stable, remove timeout
removePublishTimeout();
NodesInfoResponse nodesInfo = client().admin().cluster().prepareNodesInfo().get();
String excludedNodeId = null;
for (NodeInfo nodeInfo : nodesInfo.getNodes()) {
if (nodeInfo.getNode().isDataNode()) {
excludedNodeId = nodeInfo.getNode().getId();
break;
}
}
assertNotNull(excludedNodeId);
ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put("cluster.routing.allocation.exclude._id", excludedNodeId)).get();
assertAcked(clusterUpdateSettingsResponse);
assertThat(clusterUpdateSettingsResponse.getTransientSettings().get("cluster.routing.allocation.exclude._id"), equalTo(excludedNodeId));
for (Client client : clients()) {
ClusterState clusterState = getLocalClusterState(client);
assertThat(clusterState.metaData().transientSettings().get("cluster.routing.allocation.exclude._id"), equalTo(excludedNodeId));
for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) {
for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) {
for (ShardRouting shardRouting : indexShardRoutingTable) {
assert clusterState.nodes() != null;
if (shardRouting.unassigned() == false && clusterState.nodes().get(shardRouting.currentNodeId()).getId().equals(excludedNodeId)) {
//if the shard is still there it must be relocating and all nodes need to know, since the request was acknowledged
//reroute happens as part of the update settings and we made sure no throttling comes into the picture via settings
assertThat(shardRouting.relocating(), equalTo(true));
}
}
}
}
}
}
use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse in project elasticsearch by elastic.
the class ClusterSettingsIT method testUpdateDiscoveryPublishTimeout.
public void testUpdateDiscoveryPublishTimeout() {
DiscoverySettings discoverySettings = getDiscoverySettings();
assertThat(discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
ClusterUpdateSettingsResponse response = client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s").build()).get();
assertAcked(response);
assertThat(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s"));
assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
try {
client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "whatever").build()).get();
fail("bogus value");
} catch (IllegalArgumentException ex) {
assertEquals(ex.getMessage(), "failed to parse setting [discovery.zen.publish_timeout] with value [whatever] as a time value: unit is missing or unrecognized");
}
assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
try {
client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), -1).build()).get();
fail("bogus value");
} catch (IllegalArgumentException ex) {
assertEquals(ex.getMessage(), "Failed to parse value [-1] for setting [discovery.zen.publish_timeout] must be >= 0s");
}
assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
}
use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse in project elasticsearch by elastic.
the class ClusterSettingsIT method testResetClusterSetting.
public void testResetClusterSetting() {
DiscoverySettings discoverySettings = getDiscoverySettings();
assertThat(discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
assertThat(discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));
ClusterUpdateSettingsResponse response = client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s").build()).get();
assertAcked(response);
assertThat(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s"));
assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
assertThat(discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));
response = client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().putNull(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey())).get();
assertAcked(response);
assertNull(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()));
assertThat(discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
assertThat(discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));
response = client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s").put(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), false).build()).get();
assertAcked(response);
assertThat(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s"));
assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
assertFalse(discoverySettings.getPublishDiff());
response = client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().putNull((randomBoolean() ? "discovery.zen.*" : "*"))).get();
assertNull(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()));
assertNull(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey()));
assertThat(discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
assertThat(discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));
// now persistent
response = client().admin().cluster().prepareUpdateSettings().setPersistentSettings(Settings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s").build()).get();
assertAcked(response);
assertThat(response.getPersistentSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s"));
assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
assertThat(discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));
response = client().admin().cluster().prepareUpdateSettings().setPersistentSettings(Settings.builder().putNull((DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()))).get();
assertAcked(response);
assertNull(response.getPersistentSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()));
assertThat(discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
assertThat(discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));
response = client().admin().cluster().prepareUpdateSettings().setPersistentSettings(Settings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s").put(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), false).build()).get();
assertAcked(response);
assertThat(response.getPersistentSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s"));
assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
assertFalse(discoverySettings.getPublishDiff());
response = client().admin().cluster().prepareUpdateSettings().setPersistentSettings(Settings.builder().putNull((randomBoolean() ? "discovery.zen.*" : "*"))).get();
assertNull(response.getPersistentSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()));
assertNull(response.getPersistentSettings().getAsMap().get(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey()));
assertThat(discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
assertThat(discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));
}
use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse in project elasticsearch by elastic.
the class ClusterSettingsIT method testClusterSettingsUpdateResponse.
public void testClusterSettingsUpdateResponse() {
String key1 = RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey();
int value1 = 10;
String key2 = EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey();
String value2 = EnableAllocationDecider.Allocation.NONE.name();
Settings transientSettings1 = Settings.builder().put(key1, value1, ByteSizeUnit.BYTES).build();
Settings persistentSettings1 = Settings.builder().put(key2, value2).build();
ClusterUpdateSettingsResponse response1 = client().admin().cluster().prepareUpdateSettings().setTransientSettings(transientSettings1).setPersistentSettings(persistentSettings1).execute().actionGet();
assertAcked(response1);
assertThat(response1.getTransientSettings().get(key1), notNullValue());
assertThat(response1.getTransientSettings().get(key2), nullValue());
assertThat(response1.getPersistentSettings().get(key1), nullValue());
assertThat(response1.getPersistentSettings().get(key2), notNullValue());
Settings transientSettings2 = Settings.builder().put(key1, value1, ByteSizeUnit.BYTES).put(key2, value2).build();
Settings persistentSettings2 = Settings.EMPTY;
ClusterUpdateSettingsResponse response2 = client().admin().cluster().prepareUpdateSettings().setTransientSettings(transientSettings2).setPersistentSettings(persistentSettings2).execute().actionGet();
assertAcked(response2);
assertThat(response2.getTransientSettings().get(key1), notNullValue());
assertThat(response2.getTransientSettings().get(key2), notNullValue());
assertThat(response2.getPersistentSettings().get(key1), nullValue());
assertThat(response2.getPersistentSettings().get(key2), nullValue());
Settings transientSettings3 = Settings.EMPTY;
Settings persistentSettings3 = Settings.builder().put(key1, value1, ByteSizeUnit.BYTES).put(key2, value2).build();
ClusterUpdateSettingsResponse response3 = client().admin().cluster().prepareUpdateSettings().setTransientSettings(transientSettings3).setPersistentSettings(persistentSettings3).execute().actionGet();
assertAcked(response3);
assertThat(response3.getTransientSettings().get(key1), nullValue());
assertThat(response3.getTransientSettings().get(key2), nullValue());
assertThat(response3.getPersistentSettings().get(key1), notNullValue());
assertThat(response3.getPersistentSettings().get(key2), notNullValue());
}
Aggregations