aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorEric Hartmann <hartmann.eric@gmail.com>2017-05-18 17:28:35 +0200
committerEric Hartmann <hartmann.eric@gmail.com>2017-05-19 17:52:15 +0200
commitea9258c5f831b549a152b608e3cb1afc6afa7af3 (patch)
treee2e3b236deed771211c2af179ec3e4f8b4dfd34b /server
parentf89e8102eb8c01a417a9a3fa2a046dcaba18f7d2 (diff)
downloadsonarqube-ea9258c5f831b549a152b608e3cb1afc6afa7af3.tar.gz
sonarqube-ea9258c5f831b549a152b608e3cb1afc6afa7af3.zip
SONAR-9286 Fix ES error at startup
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/es/IndexerStartupTask.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/IndexerStartupTask.java b/server/sonar-server/src/main/java/org/sonar/server/es/IndexerStartupTask.java
index fa0e069319f..07ae9a9914b 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/es/IndexerStartupTask.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/es/IndexerStartupTask.java
@@ -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();
}