]> source.dussan.org Git - sonarqube.git/commitdiff
Remove unused BulkIndexer#setDisableRefresh()
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 16 Sep 2016 13:03:34 +0000 (15:03 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 16 Sep 2016 13:27:52 +0000 (15:27 +0200)
server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java
server/sonar-server/src/test/java/org/sonar/server/es/BulkIndexerTest.java

index 003ef866c8620d02219469ea8fc8d42f90fa48f8..d93cf53d157db584b50f255af7fa2139f43e7594 100644 (file)
@@ -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<String, Object> 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:
index 53fbae1bf02e0ea03cdf28a2c3b22606e89b1105..b91af14dc7430a2eaba6c985f16786f55d0276f2 100644 (file)
@@ -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)
index ff89f4a01b9aa5187e20d953604b18673a978d7a..b201fd4cb683d73977a0875507860b744244e05f 100644 (file)
@@ -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");
   }