Skip to content

Commit

Permalink
Setting
Browse files Browse the repository at this point in the history
  • Loading branch information
jasontedor committed Sep 21, 2017
1 parent cb9373b commit 7e6d1bf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 24 deletions.
18 changes: 11 additions & 7 deletions core/src/main/java/org/elasticsearch/index/IndexService.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.lease.Releasable;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.BigArrays;
Expand Down Expand Up @@ -927,7 +929,14 @@ public String toString() {
}
}

private static final TimeValue GLOBAL_CHECKPOINT_SYNC_INTERVAL = TimeValue.timeValueSeconds(30);
// this setting is intentionally not registered, it is only used in tests
public static final Setting<TimeValue> GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING =
Setting.timeSetting(
"index.global_checkpoint_sync.interval",
new TimeValue(30, TimeUnit.SECONDS),
new TimeValue(0, TimeUnit.MILLISECONDS),
Property.Dynamic,
Property.IndexScope);

/**
* Background task that syncs the global checkpoint to replicas.
Expand All @@ -936,12 +945,7 @@ final class AsyncGlobalCheckpointTask extends BaseAsyncTask {

AsyncGlobalCheckpointTask(final IndexService indexService) {
// index.global_checkpoint_sync_interval is not a real setting, it is only registered in tests
super(
indexService,
indexService
.getIndexSettings()
.getSettings()
.getAsTime("index.global_checkpoint_sync.interval", GLOBAL_CHECKPOINT_SYNC_INTERVAL));
super(indexService, GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.get(indexService.getIndexSettings().getSettings()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@

public class IndexServiceIT extends ESIntegTestCase {

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singletonList(InternalSettingsPlugin.class);
}

public void testGlobalCheckpointSync() throws Exception {
internalCluster().startNode();
final int numberOfDocuments = randomIntBetween(1, 128);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
import java.util.stream.Stream;

import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.test.InternalSettingsPlugin.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
Expand Down Expand Up @@ -309,7 +308,7 @@ public void testRelocationWhileRefreshing() throws Exception {
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", numberOfReplicas)
.put("index.refresh_interval", -1) // we want to control refreshes c
.put(GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms"))
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms"))
.get();

for (int i = 1; i < numberOfNodes; i++) {
Expand Down Expand Up @@ -487,7 +486,7 @@ public void testIndexAndRelocateConcurrently() throws ExecutionException, Interr
.put("index.routing.allocation.exclude.color", "blue")
.put(indexSettings())
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, randomInt(halfNodes - 1))
.put(GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms");
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms");
assertAcked(prepareCreate("test", settings));
assertAllShardsOnNodes("test", redNodes);
int numDocs = randomIntBetween(100, 150);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.plugins.Plugin;

import java.util.Arrays;
Expand All @@ -42,14 +43,6 @@ public final class InternalSettingsPlugin extends Plugin {
Setting.timeSetting("index.translog.retention.check_interval", new TimeValue(10, TimeUnit.MINUTES),
new TimeValue(-1, TimeUnit.MILLISECONDS), Property.Dynamic, Property.IndexScope);

public static final Setting<TimeValue> GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING =
Setting.timeSetting(
"index.global_checkpoint_sync.interval",
new TimeValue(30, TimeUnit.SECONDS),
new TimeValue(0, TimeUnit.MILLISECONDS),
Property.Dynamic,
Property.IndexScope);

@Override
public List<Setting<?>> getSettings() {
return Arrays.asList(
Expand All @@ -58,6 +51,6 @@ public List<Setting<?>> getSettings() {
INDEX_CREATION_DATE_SETTING,
PROVIDED_NAME_SETTING,
TRANSLOG_RETENTION_CHECK_INTERVAL_SETTING,
GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING);
IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING);
}
}

0 comments on commit 7e6d1bf

Please sign in to comment.