summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-11-29 11:26:30 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-11-29 11:26:30 +0100
commit5b86386e9d32a39e1f4c2877098e854ad237c57b (patch)
treef910b01b963103fad6e62a1b01d08c4da3492412 /server
parent8b8d781cf04e0ac85aa8b851c56d46ca372a386f (diff)
downloadsonarqube-5b86386e9d32a39e1f4c2877098e854ad237c57b.tar.gz
sonarqube-5b86386e9d32a39e1f4c2877098e854ad237c57b.zip
CI error investigations - add verifications when creating index
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/es/IndexCreator.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/IndexCreator.java b/server/sonar-server/src/main/java/org/sonar/server/es/IndexCreator.java
index 3a8c980d5df..6f9a01c63f3 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/es/IndexCreator.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/es/IndexCreator.java
@@ -20,6 +20,9 @@
package org.sonar.server.es;
import org.apache.commons.lang.StringUtils;
+import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
+import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
+import org.elasticsearch.common.Priority;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.picocontainer.Startable;
import org.slf4j.Logger;
@@ -75,19 +78,26 @@ public class IndexCreator implements ServerComponent, Startable {
ImmutableSettings.Builder settings = ImmutableSettings.builder();
settings.put(index.getSettings());
settings.put(SETTING_HASH, new IndexHash().of(index));
- client
+ CreateIndexResponse indexResponse = client
.prepareCreate(index.getName())
.setSettings(settings)
.get();
+ if (!indexResponse.isAcknowledged()) {
+ throw new IllegalStateException("Failed to create index " + index.getName());
+ }
+ client.prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
// create types
for (Map.Entry<String, IndexRegistry.IndexType> entry : index.getTypes().entrySet()) {
LOGGER.info(String.format("Create type %s/%s", index.getName(), entry.getKey()));
- client.preparePutMapping(index.getName())
+ PutMappingResponse mappingResponse = client.preparePutMapping(index.getName())
.setType(entry.getKey())
.setIgnoreConflicts(false)
.setSource(entry.getValue().getAttributes())
.get();
+ if (!mappingResponse.isAcknowledged()) {
+ throw new IllegalStateException("Failed to create type " + entry.getKey());
+ }
}
}