]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8798 prepare for setRefresh replaced by setRefreshPolicy
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 28 Jun 2017 09:34:02 +0000 (11:34 +0200)
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>
Wed, 9 Aug 2017 13:09:54 +0000 (15:09 +0200)
server/sonar-server/src/main/java/org/sonar/server/es/DefaultIndexSettings.java
server/sonar-server/src/main/java/org/sonar/server/es/metadata/MetadataIndex.java
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java
server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexer.java
server/sonar-server/src/main/java/org/sonar/server/permission/index/PermissionIndexer.java
server/sonar-server/src/test/java/org/sonar/server/es/EsTester.java
server/sonar-server/src/test/java/org/sonar/server/test/index/TestIndexerTest.java

index 75aa7cabcfefb46fe3755f8a29e5e46602a8dca1..7937f140eac2f4384e120c3538ae92c19e172348 100644 (file)
@@ -53,6 +53,8 @@ public class DefaultIndexSettings {
   public static final String CUSTOM = "custom";
   public static final String KEYWORD = "keyword";
   public static final String CLASSIC = "classic";
+  public static final boolean REFRESH_IMMEDIATE = true; // ES 5: replace with org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE
+  public static final boolean REFRESH_NONE = false; // ES 5: replace with org.elasticsearch.action.support.WriteRequest.RefreshPolicy.NONE
 
   public static final String TRUNCATE = "truncate";
 
index c0d8155989f5592cfaa2124db9fcdd71d3fda0ef..f2ab6d4cacd1b7b235c5f7033eaa55c55e891532 100644 (file)
@@ -26,6 +26,8 @@ import org.elasticsearch.index.get.GetField;
 import org.sonar.server.es.EsClient;
 import org.sonar.server.es.IndexType;
 
+import static org.sonar.server.es.DefaultIndexSettings.REFRESH_IMMEDIATE;
+
 public class MetadataIndex {
 
   private final EsClient esClient;
@@ -73,7 +75,7 @@ public class MetadataIndex {
     esClient.prepareIndex(MetadataIndexDefinition.INDEX_TYPE_METADATA)
       .setId(id)
       .setSource(MetadataIndexDefinition.FIELD_VALUE, hash)
-      .setRefresh(true)
+      .setRefresh(REFRESH_IMMEDIATE) // ES 5: change to setRefreshPolicy
       .get();
   }
 }
index 45d2c4708ba3f7a23f2ef557404622aab6bf21c9..20b9f08a1617f9b09cf4382916818e65ce1db0bf 100644 (file)
@@ -52,6 +52,7 @@ import org.sonar.server.permission.index.NeedAuthorizationIndexer;
 import static java.util.Collections.emptyList;
 import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
 import static org.elasticsearch.index.query.QueryBuilders.termQuery;
+import static org.sonar.server.es.DefaultIndexSettings.REFRESH_NONE;
 import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_PROJECT_UUID;
 import static org.sonar.server.issue.index.IssueIndexDefinition.INDEX_TYPE_ISSUE;
 
index fbb1cbb6822ada86627bf59a1e943ab96e684a1a..1b5378bc6aeb3e48107a03e02acdccea2a0f2ac9 100644 (file)
@@ -46,6 +46,7 @@ import org.sonar.server.es.ProjectIndexer;
 import org.sonar.server.permission.index.AuthorizationScope;
 import org.sonar.server.permission.index.NeedAuthorizationIndexer;
 
+import static org.sonar.server.es.DefaultIndexSettings.REFRESH_IMMEDIATE;
 import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.INDEX_TYPE_PROJECT_MEASURES;
 
 public class ProjectMeasuresIndexer implements ProjectIndexer, NeedAuthorizationIndexer {
index a373828c2d3a54d4f93ef36b3290631356d58276..06ab10499afc635b4f47aee123c2b3d580f9ff2b 100644 (file)
@@ -45,6 +45,7 @@ import org.sonar.server.permission.index.PermissionIndexerDao.Dto;
 import static java.util.Collections.emptyList;
 import static org.sonar.core.util.stream.MoreCollectors.toArrayList;
 import static org.sonar.core.util.stream.MoreCollectors.toSet;
+import static org.sonar.server.es.DefaultIndexSettings.REFRESH_IMMEDIATE;
 
 /**
  * Populates the types "authorization" of each index requiring project
index 9be16c06f721870ad2c19f1de03610c6bf903cad..c0a1329b5149b00818de8adc805ce33257b2997a 100644 (file)
@@ -58,6 +58,7 @@ import org.sonar.server.es.metadata.MetadataIndexDefinition;
 import static com.google.common.base.Preconditions.checkState;
 import static com.google.common.collect.Lists.newArrayList;
 import static java.util.Arrays.asList;
+import static org.sonar.server.es.DefaultIndexSettings.REFRESH_IMMEDIATE;
 
 public class EsTester extends ExternalResource {
 
@@ -111,7 +112,8 @@ public class EsTester extends ExternalResource {
 
   public void putDocuments(IndexType indexType, BaseDoc... docs) {
     try {
-      BulkRequestBuilder bulk = client.prepareBulk().setRefresh(true);
+      BulkRequestBuilder bulk = client.prepareBulk()
+        .setRefresh(REFRESH_IMMEDIATE); // ES 5: change to setRefreshPolicy
       for (BaseDoc doc : docs) {
         bulk.add(new IndexRequest(indexType.getIndex(), indexType.getType(), doc.getId())
           .parent(doc.getParent())
index 9bd4ffd8472642af09550a3508bc0f4146b2cc98..163f5d384e838d850f92a79a2c9e6407238129a4 100644 (file)
@@ -48,6 +48,7 @@ import static org.assertj.core.api.Assertions.entry;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
+import static org.sonar.server.es.DefaultIndexSettings.REFRESH_IMMEDIATE;
 import static org.sonar.server.test.index.TestIndexDefinition.FIELD_DURATION_IN_MS;
 import static org.sonar.server.test.index.TestIndexDefinition.FIELD_FILE_UUID;
 import static org.sonar.server.test.index.TestIndexDefinition.FIELD_MESSAGE;
@@ -184,7 +185,7 @@ public class TestIndexerTest {
       .setId(uuid)
       .setRouting(projectUuid)
       .setSource(IOUtils.toString(getClass().getResource(format("%s/%s_%s_%s.json", getClass().getSimpleName(), projectUuid, fileUuid, testName))))
-      .setRefresh(true)
+      .setRefresh(REFRESH_IMMEDIATE) // ES 5: change to setRefreshPolicy
       .get();
   }