Skip to content

Commit 7e6d1bf

Browse files
committed
Setting
1 parent cb9373b commit 7e6d1bf

File tree

4 files changed

+15
-24
lines changed

4 files changed

+15
-24
lines changed

core/src/main/java/org/elasticsearch/index/IndexService.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import org.elasticsearch.common.Nullable;
3333
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
3434
import org.elasticsearch.common.lease.Releasable;
35+
import org.elasticsearch.common.settings.Setting;
36+
import org.elasticsearch.common.settings.Setting.Property;
3537
import org.elasticsearch.common.settings.Settings;
3638
import org.elasticsearch.common.unit.TimeValue;
3739
import org.elasticsearch.common.util.BigArrays;
@@ -927,7 +929,14 @@ public String toString() {
927929
}
928930
}
929931

930-
private static final TimeValue GLOBAL_CHECKPOINT_SYNC_INTERVAL = TimeValue.timeValueSeconds(30);
932+
// this setting is intentionally not registered, it is only used in tests
933+
public static final Setting<TimeValue> GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING =
934+
Setting.timeSetting(
935+
"index.global_checkpoint_sync.interval",
936+
new TimeValue(30, TimeUnit.SECONDS),
937+
new TimeValue(0, TimeUnit.MILLISECONDS),
938+
Property.Dynamic,
939+
Property.IndexScope);
931940

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

937946
AsyncGlobalCheckpointTask(final IndexService indexService) {
938947
// index.global_checkpoint_sync_interval is not a real setting, it is only registered in tests
939-
super(
940-
indexService,
941-
indexService
942-
.getIndexSettings()
943-
.getSettings()
944-
.getAsTime("index.global_checkpoint_sync.interval", GLOBAL_CHECKPOINT_SYNC_INTERVAL));
948+
super(indexService, GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.get(indexService.getIndexSettings().getSettings()));
945949
}
946950

947951
@Override

core/src/test/java/org/elasticsearch/index/IndexServiceIT.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@
3838

3939
public class IndexServiceIT extends ESIntegTestCase {
4040

41-
@Override
42-
protected Collection<Class<? extends Plugin>> nodePlugins() {
43-
return Collections.singletonList(InternalSettingsPlugin.class);
44-
}
45-
4641
public void testGlobalCheckpointSync() throws Exception {
4742
internalCluster().startNode();
4843
final int numberOfDocuments = randomIntBetween(1, 128);

core/src/test/java/org/elasticsearch/recovery/RelocationIT.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
import java.util.stream.Stream;
9191

9292
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
93-
import static org.elasticsearch.test.InternalSettingsPlugin.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING;
9493
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
9594
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
9695
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
@@ -309,7 +308,7 @@ public void testRelocationWhileRefreshing() throws Exception {
309308
.put("index.number_of_shards", 1)
310309
.put("index.number_of_replicas", numberOfReplicas)
311310
.put("index.refresh_interval", -1) // we want to control refreshes c
312-
.put(GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms"))
311+
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms"))
313312
.get();
314313

315314
for (int i = 1; i < numberOfNodes; i++) {
@@ -487,7 +486,7 @@ public void testIndexAndRelocateConcurrently() throws ExecutionException, Interr
487486
.put("index.routing.allocation.exclude.color", "blue")
488487
.put(indexSettings())
489488
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, randomInt(halfNodes - 1))
490-
.put(GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms");
489+
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms");
491490
assertAcked(prepareCreate("test", settings));
492491
assertAllShardsOnNodes("test", redNodes);
493492
int numDocs = randomIntBetween(100, 150);

test/framework/src/main/java/org/elasticsearch/test/InternalSettingsPlugin.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.elasticsearch.common.settings.Setting;
2323
import org.elasticsearch.common.settings.Setting.Property;
2424
import org.elasticsearch.common.unit.TimeValue;
25+
import org.elasticsearch.index.IndexService;
2526
import org.elasticsearch.plugins.Plugin;
2627

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

45-
public static final Setting<TimeValue> GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING =
46-
Setting.timeSetting(
47-
"index.global_checkpoint_sync.interval",
48-
new TimeValue(30, TimeUnit.SECONDS),
49-
new TimeValue(0, TimeUnit.MILLISECONDS),
50-
Property.Dynamic,
51-
Property.IndexScope);
52-
5346
@Override
5447
public List<Setting<?>> getSettings() {
5548
return Arrays.asList(
@@ -58,6 +51,6 @@ public List<Setting<?>> getSettings() {
5851
INDEX_CREATION_DATE_SETTING,
5952
PROVIDED_NAME_SETTING,
6053
TRANSLOG_RETENTION_CHECK_INTERVAL_SETTING,
61-
GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING);
54+
IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING);
6255
}
6356
}

0 commit comments

Comments
 (0)