You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by sh...@apache.org on 2016/09/13 16:20:47 UTC

incubator-unomi git commit: Improve startup sequence to avoid starting services before ElasticSearch has properly started.

Repository: incubator-unomi
Updated Branches:
  refs/heads/UNOMI-28-ES-2-X-UPGRADE 131a06aa7 -> 3ebc65be1


Improve startup sequence to avoid starting services before ElasticSearch has properly started.


Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/3ebc65be
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/3ebc65be
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/3ebc65be

Branch: refs/heads/UNOMI-28-ES-2-X-UPGRADE
Commit: 3ebc65be1a0f7ccb562c9d649846fabe759c651a
Parents: 131a06a
Author: Serge Huber <sh...@apache.org>
Authored: Tue Sep 13 18:20:36 2016 +0200
Committer: Serge Huber <sh...@apache.org>
Committed: Tue Sep 13 18:20:36 2016 +0200

----------------------------------------------------------------------
 .../ElasticSearchPersistenceServiceImpl.java          | 14 ++++++++++++++
 pom.xml                                               |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/3ebc65be/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
----------------------------------------------------------------------
diff --git a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
index 743def9..f2242b4 100644
--- a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
+++ b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
@@ -297,10 +297,20 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
 
                 node = nodeBuilder().settings(settingsBuilder).node();
                 client = node.client();
+                logger.info("Waiting for ElasticSearch to start...");
+
+                client.admin().cluster().prepareHealth()
+                        .setWaitForGreenStatus()
+                        .get();
+
+                logger.info("Cluster status is GREEN");
+
                 // @todo is there a better way to detect index existence than to wait for it to startup ?
                 boolean indexExists = false;
                 int tries = 0;
+
                 while (!indexExists && tries < 20) {
+
                     IndicesExistsResponse indicesExistsResponse = client.admin().indices().prepareExists(indexName).execute().actionGet();
                     indexExists = indicesExistsResponse.isExists();
                     tries++;
@@ -320,6 +330,8 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
                     }
 
                     internalCreateIndex(indexName, indexMappings);
+                } else {
+                    logger.info("Found index {}, ElasticSearch started successfully.", indexName);
                 }
 
                 client.admin().indices().preparePutTemplate(indexName + "_monthlyindex")
@@ -365,6 +377,8 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
                 }
             }
         }, 10000L, 24L * 60L * 60L * 1000L);
+
+        logger.info(this.getClass().getName() + " service started successfully.");
     }
 
     public void stop() {

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/3ebc65be/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a94c0a0..0a5301b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -69,7 +69,7 @@
         <version.jackson.jaxb>2.6.6</version.jackson.jaxb> <!-- version used by CXF -->
         <version.karaf>3.0.2</version.karaf>
         <version.pax.exam>4.9.1</version.pax.exam>
-        <elasticsearch.version>2.3.4</elasticsearch.version>
+        <elasticsearch.version>2.4.0</elasticsearch.version>
 
         <maven.compiler.source>1.7</maven.compiler.source>
         <maven.compiler.target>1.7</maven.compiler.target>