Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Gateway] set a default of 5m to
recover_after_time
when any to the…
… `expected*Nodes` is set The `recovery_after_time` tells the gateway to wait before starting recovery from disk. The goal here is to allow for more nodes to join the cluster and thus not start potentially unneeded replications. The `expectedNodes` setting (and friends) tells the gateway when it can start recovering even if the `recover_after_time` has not yet elapsed. However, `expectedNodes` is useless if one doesn't set `recovery_after_time`. This commit changes that by setting a sensible default of 5m for `recover_after_time` *if* a `expectedNodes` setting is present. Closes #6742
- Loading branch information
Showing
5 changed files
with
282 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/test/java/org/elasticsearch/gateway/GatewayServiceTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.gateway; | ||
|
||
import org.elasticsearch.common.settings.ImmutableSettings; | ||
import org.elasticsearch.common.unit.TimeValue; | ||
import org.elasticsearch.test.ElasticsearchTestCase; | ||
import org.elasticsearch.test.cluster.NoopClusterService; | ||
import org.hamcrest.Matchers; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
|
||
public class GatewayServiceTests extends ElasticsearchTestCase { | ||
|
||
|
||
private GatewayService createService(ImmutableSettings.Builder settings) { | ||
return new GatewayService(ImmutableSettings.builder() | ||
.put("http.enabled", "false") | ||
.put("discovery.type", "local") | ||
.put(settings.build()).build(), null, null, new NoopClusterService(), null, null); | ||
|
||
} | ||
|
||
@Test | ||
public void testDefaultRecoverAfterTime() throws IOException { | ||
|
||
// check that the default is not set | ||
GatewayService service = createService(ImmutableSettings.builder()); | ||
assertNull(service.recoverAfterTime()); | ||
|
||
// ensure default is set when setting expected_nodes | ||
service = createService(ImmutableSettings.builder().put("gateway.expected_nodes", 1)); | ||
assertThat(service.recoverAfterTime(), Matchers.equalTo(GatewayService.DEFAULT_RECOVER_AFTER_TIME_IF_EXPECTED_NODES_IS_SET)); | ||
|
||
// ensure default is set when setting expected_data_nodes | ||
service = createService(ImmutableSettings.builder().put("gateway.expected_data_nodes", 1)); | ||
assertThat(service.recoverAfterTime(), Matchers.equalTo(GatewayService.DEFAULT_RECOVER_AFTER_TIME_IF_EXPECTED_NODES_IS_SET)); | ||
|
||
// ensure default is set when setting expected_master_nodes | ||
service = createService(ImmutableSettings.builder().put("gateway.expected_master_nodes", 1)); | ||
assertThat(service.recoverAfterTime(), Matchers.equalTo(GatewayService.DEFAULT_RECOVER_AFTER_TIME_IF_EXPECTED_NODES_IS_SET)); | ||
|
||
// ensure settings override default | ||
TimeValue timeValue = TimeValue.timeValueHours(3); | ||
// ensure default is set when setting expected_nodes | ||
service = createService(ImmutableSettings.builder().put("gateway.expected_nodes", 1).put("gateway.recover_after_time", timeValue.toString())); | ||
assertThat(service.recoverAfterTime().millis(), Matchers.equalTo(timeValue.millis())); | ||
} | ||
} |
Oops, something went wrong.