]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9286 Fix ES error at startup
authorEric Hartmann <hartmann.eric@gmail.com>
Thu, 18 May 2017 15:28:35 +0000 (17:28 +0200)
committerEric Hartmann <hartmann.eric@gmail.com>
Fri, 19 May 2017 15:52:15 +0000 (17:52 +0200)
server/sonar-server/src/main/java/org/sonar/server/es/IndexerStartupTask.java

index fa0e069319f403815d2c88ac39e845e29ec2dcb1..07ae9a9914b4c1ffcf497556b24fd67bef38748c 100644 (file)
@@ -88,6 +88,7 @@ public class IndexerStartupTask {
 
   private void setInitialized(IndexType indexType) {
     String index = indexType.getIndex();
+    waitForIndexGreen(index);
     closeIndex(index);
     setIndexSetting(index, getInitializedSettingName(indexType), true);
     openIndex(index);
@@ -115,6 +116,11 @@ public class IndexerStartupTask {
     ClusterHealthAction.INSTANCE.newRequestBuilder(nativeClient).setIndices(index).setWaitForYellowStatus().get(TimeValue.timeValueMinutes(10));
   }
 
+  private void waitForIndexGreen(String index) {
+    Client nativeClient = esClient.nativeClient();
+    ClusterHealthAction.INSTANCE.newRequestBuilder(nativeClient).setIndices(index).setWaitForGreenStatus().get(TimeValue.timeValueMinutes(10));
+  }
+
   private static String getInitializedSettingName(IndexType indexType) {
     return "index." + SETTING_PREFIX_INITIAL_INDEXING_FINISHED + indexType.getType();
   }