From 415f87dd0e503436ea192a3b421a3fc87bf33541 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 4 Mar 2015 16:32:33 +0100 Subject: [PATCH] Remove unused BulkIndexer#setRefresh(boolean) --- .../main/java/org/sonar/server/es/BulkIndexer.java | 11 +---------- .../server/issue/index/IssueIndexDefinition.java | 3 +++ .../java/org/sonar/server/es/BulkIndexerTest.java | 3 +-- 3 files changed, 5 insertions(+), 12 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 28384f0f074..fd6f3fec50c 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 @@ -57,7 +57,6 @@ public class BulkIndexer implements Startable { private final EsClient client; private final String indexName; private boolean large = false; - private boolean refresh = true; private long flushByteSize = FLUSH_BYTE_SIZE; private BulkRequestBuilder bulkRequest = null; private Map largeInitialSettings = null; @@ -83,12 +82,6 @@ public class BulkIndexer implements Startable { return this; } - public BulkIndexer setRefresh(boolean b) { - Preconditions.checkState(bulkRequest == null, ALREADY_STARTED_MESSAGE); - this.refresh = b; - return this; - } - /** * Default value is {@link org.sonar.server.es.BulkIndexer#FLUSH_BYTE_SIZE} * @see org.elasticsearch.common.unit.ByteSizeValue @@ -144,9 +137,7 @@ public class BulkIndexer implements Startable { progress.stop(); } - if (refresh) { - 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/IssueIndexDefinition.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java index f705776bed4..68292b43a93 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java @@ -93,6 +93,9 @@ public class IssueIndexDefinition implements IndexDefinition { public void define(IndexDefinitionContext context) { NewIndex index = context.create(INDEX); + // refresh is handled by IssueIndexer + index.getSettings().put("index.refresh_interval", "-1"); + // shards boolean clusterMode = settings.getBoolean(ProcessConstants.CLUSTER_ACTIVATE); if (clusterMode) { 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 bd4be80943d..7f4e4e6a16f 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 @@ -48,8 +48,7 @@ public class BulkIndexerTest { @Test public void index_documents() throws Exception { - BulkIndexer indexer = new BulkIndexer(esTester.client(), FakeIndexDefinition.INDEX) - .setRefresh(true); + BulkIndexer indexer = new BulkIndexer(esTester.client(), FakeIndexDefinition.INDEX); indexer.start(); indexer.add(newIndexRequest(42)); indexer.add(newIndexRequest(78)); -- 2.39.5