From 88591239560c1b90f40c56ec322462a7eaaea173 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Fri, 16 Sep 2016 15:03:34 +0200 Subject: [PATCH] Remove unused BulkIndexer#setDisableRefresh() --- .../java/org/sonar/server/es/BulkIndexer.java | 15 +-------------- .../sonar/server/issue/index/IssueIndexer.java | 1 - .../java/org/sonar/server/es/BulkIndexerTest.java | 15 --------------- 3 files changed, 1 insertion(+), 30 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java index 003ef866c86..d93cf53d157 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java @@ -68,7 +68,6 @@ public class BulkIndexer implements Startable { private final String indexName; private boolean large = false; private long flushByteSize = FLUSH_BYTE_SIZE; - private boolean disableRefresh = false; private BulkRequestBuilder bulkRequest = null; private Map largeInitialSettings = null; private final AtomicLong counter = new AtomicLong(0L); @@ -101,15 +100,6 @@ public class BulkIndexer implements Startable { return this; } - /** - * By default refresh of index is executed in method {@link #stop()}. Set to true - * to disable refresh. - */ - public BulkIndexer setDisableRefresh(boolean b) { - this.disableRefresh = b; - return this; - } - @Override public void start() { Preconditions.checkState(bulkRequest == null, ALREADY_STARTED_MESSAGE); @@ -204,10 +194,7 @@ public class BulkIndexer implements Startable { throw new IllegalStateException("Elasticsearch bulk requests still being executed after 10 minutes", e); } progress.stop(); - - if (!disableRefresh) { - client.prepareRefresh(indexName).get(); - } + client.prepareRefresh(indexName).get(); if (large) { // optimize lucene segments and revert index settings // Optimization must be done before re-applying replicas: diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java index 53fbae1bf02..b91af14dc74 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java @@ -97,7 +97,6 @@ public class IssueIndexer extends BaseIndexer { public void deleteProject(String uuid) { BulkIndexer bulk = new BulkIndexer(esClient, INDEX); - bulk.setDisableRefresh(false); bulk.start(); SearchRequestBuilder search = esClient.prepareSearch(INDEX) .setTypes(TYPE_ISSUE, TYPE_AUTHORIZATION) diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/BulkIndexerTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/BulkIndexerTest.java index ff89f4a01b9..b201fd4cb68 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/es/BulkIndexerTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/es/BulkIndexerTest.java @@ -102,21 +102,6 @@ public class BulkIndexerTest { assertThat(count()).isEqualTo(removeFrom); } - @Test - public void disable_refresh() { - BulkIndexer indexer = new BulkIndexer(esTester.client(), FakeIndexDefinition.INDEX) - .setDisableRefresh(true); - indexer.start(); - indexer.add(newIndexRequest(42)); - indexer.add(newIndexRequest(78)); - indexer.stop(); - - assertThat(count()).isEqualTo(0); - - esTester.client().prepareRefresh(FakeIndexDefinition.INDEX).get(); - assertThat(count()).isEqualTo(2); - } - private long count() { return esTester.countDocuments("fakes", "fake"); } -- 2.39.5