diff --git a/buildSrc/src/main/resources/checkstyle_suppressions.xml b/buildSrc/src/main/resources/checkstyle_suppressions.xml
index 2aa72f0fa7a1c..609a7cf2ea66f 100644
--- a/buildSrc/src/main/resources/checkstyle_suppressions.xml
+++ b/buildSrc/src/main/resources/checkstyle_suppressions.xml
@@ -535,7 +535,6 @@
-
diff --git a/server/src/test/java/org/elasticsearch/index/IndexServiceTests.java b/server/src/test/java/org/elasticsearch/index/IndexServiceTests.java
index 4dc6a859a5c5a..28fa440d96ac2 100644
--- a/server/src/test/java/org/elasticsearch/index/IndexServiceTests.java
+++ b/server/src/test/java/org/elasticsearch/index/IndexServiceTests.java
@@ -21,7 +21,6 @@
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.TopDocs;
-import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.settings.Settings;
@@ -131,16 +130,16 @@ public void testRefreshTaskIsUpdated() throws IOException {
assertTrue(indexService.getRefreshTask().mustReschedule());
// now disable
- IndexMetaData metaData = IndexMetaData.builder(indexService.getMetaData()).settings(Settings.builder().put(indexService.getMetaData().getSettings()).put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), -1)).build();
- indexService.updateMetaData(metaData);
+ client().admin().indices().prepareUpdateSettings("test")
+ .setSettings(Settings.builder().put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), -1)).get();
assertNotSame(refreshTask, indexService.getRefreshTask());
assertTrue(refreshTask.isClosed());
assertFalse(refreshTask.isScheduled());
assertFalse(indexService.getRefreshTask().mustReschedule());
// set it to 100ms
- metaData = IndexMetaData.builder(indexService.getMetaData()).settings(Settings.builder().put(indexService.getMetaData().getSettings()).put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "100ms")).build();
- indexService.updateMetaData(metaData);
+ client().admin().indices().prepareUpdateSettings("test")
+ .setSettings(Settings.builder().put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "100ms")).get();
assertNotSame(refreshTask, indexService.getRefreshTask());
assertTrue(refreshTask.isClosed());
@@ -150,8 +149,8 @@ public void testRefreshTaskIsUpdated() throws IOException {
assertEquals(100, refreshTask.getInterval().millis());
// set it to 200ms
- metaData = IndexMetaData.builder(indexService.getMetaData()).settings(Settings.builder().put(indexService.getMetaData().getSettings()).put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "200ms")).build();
- indexService.updateMetaData(metaData);
+ client().admin().indices().prepareUpdateSettings("test")
+ .setSettings(Settings.builder().put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "200ms")).get();
assertNotSame(refreshTask, indexService.getRefreshTask());
assertTrue(refreshTask.isClosed());
@@ -161,8 +160,8 @@ public void testRefreshTaskIsUpdated() throws IOException {
assertEquals(200, refreshTask.getInterval().millis());
// set it to 200ms again
- metaData = IndexMetaData.builder(indexService.getMetaData()).settings(Settings.builder().put(indexService.getMetaData().getSettings()).put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "200ms")).build();
- indexService.updateMetaData(metaData);
+ client().admin().indices().prepareUpdateSettings("test")
+ .setSettings(Settings.builder().put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "200ms")).get();
assertSame(refreshTask, indexService.getRefreshTask());
assertTrue(indexService.getRefreshTask().mustReschedule());
assertTrue(refreshTask.isScheduled());
@@ -174,7 +173,9 @@ public void testRefreshTaskIsUpdated() throws IOException {
}
public void testFsyncTaskIsRunning() throws IOException {
- IndexService indexService = createIndex("test", Settings.builder().put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), Translog.Durability.ASYNC).build());
+ Settings settings = Settings.builder()
+ .put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), Translog.Durability.ASYNC).build();
+ IndexService indexService = createIndex("test", settings);
IndexService.AsyncTranslogFSync fsyncTask = indexService.getFsyncTask();
assertNotNull(fsyncTask);
assertEquals(5000, fsyncTask.getInterval().millis());
@@ -198,12 +199,10 @@ public void testRefreshActuallyWorks() throws Exception {
IndexShard shard = indexService.getShard(0);
client().prepareIndex("test", "test", "0").setSource("{\"foo\": \"bar\"}", XContentType.JSON).get();
// now disable the refresh
- IndexMetaData metaData = IndexMetaData.builder(indexService.getMetaData())
- .settings(Settings.builder().put(indexService.getMetaData().getSettings())
- .put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), -1)).build();
+ client().admin().indices().prepareUpdateSettings("test")
+ .setSettings(Settings.builder().put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), -1)).get();
// when we update we reschedule the existing task AND fire off an async refresh to make sure we make everything visible
// before that this is why we need to wait for the refresh task to be unscheduled and the first doc to be visible
- indexService.updateMetaData(metaData);
assertTrue(refreshTask.isClosed());
refreshTask = indexService.getRefreshTask();
assertBusy(() -> {
@@ -217,10 +216,8 @@ public void testRefreshActuallyWorks() throws Exception {
assertFalse(refreshTask.isClosed());
// refresh every millisecond
client().prepareIndex("test", "test", "1").setSource("{\"foo\": \"bar\"}", XContentType.JSON).get();
- metaData = IndexMetaData.builder(indexService.getMetaData())
- .settings(Settings.builder().put(indexService.getMetaData().getSettings())
- .put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "1ms")).build();
- indexService.updateMetaData(metaData);
+ client().admin().indices().prepareUpdateSettings("test")
+ .setSettings(Settings.builder().put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "1ms")).get();
assertTrue(refreshTask.isClosed());
assertBusy(() -> {
// this one becomes visible due to the force refresh we are running on updateMetaData if the interval changes
@@ -303,13 +300,11 @@ public void testAsyncTranslogTrimActuallyWorks() throws Exception {
assertTrue(indexService.getRefreshTask().mustReschedule());
client().prepareIndex("test", "test", "1").setSource("{\"foo\": \"bar\"}", XContentType.JSON).get();
client().admin().indices().prepareFlush("test").get();
- IndexMetaData metaData = IndexMetaData.builder(indexService.getMetaData()).settings(Settings.builder()
- .put(indexService.getMetaData().getSettings())
- .put(IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.getKey(), -1)
- .put(IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.getKey(), -1))
- .build();
- indexService.updateMetaData(metaData);
-
+ client().admin().indices().prepareUpdateSettings("test")
+ .setSettings(Settings.builder()
+ .put(IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.getKey(), -1)
+ .put(IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.getKey(), -1))
+ .get();
IndexShard shard = indexService.getShard(0);
assertBusy(() -> assertThat(shard.estimateTranslogOperationsFromMinSeq(0L), equalTo(0)));
}