You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2015/04/17 18:43:04 UTC

[25/28] zest-qi4j git commit: QI-415 Fix intermittent failures of ElasticSearch indexing on startup

QI-415 Fix intermittent failures of ElasticSearch indexing on startup


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/298397eb
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/298397eb
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/298397eb

Branch: refs/heads/develop
Commit: 298397eba6ee21e2abfa6464a4a5faf28d6ffadc
Parents: 3d6fa6a
Author: Paul Merlin <pa...@nosphere.org>
Authored: Fri Mar 27 11:33:12 2015 +0100
Committer: Paul Merlin <pa...@nosphere.org>
Committed: Fri Mar 27 11:38:18 2015 +0100

----------------------------------------------------------------------
 .../internal/AbstractElasticSearchSupport.java           | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/298397eb/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/internal/AbstractElasticSearchSupport.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/internal/AbstractElasticSearchSupport.java b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/internal/AbstractElasticSearchSupport.java
index c0d5fc2..9d0833c 100644
--- a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/internal/AbstractElasticSearchSupport.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/internal/AbstractElasticSearchSupport.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012 Paul Merlin.
+ * Copyright 2012-2015 Paul Merlin.
  *
  * Licensed  under the  Apache License,  Version 2.0  (the "License");
  * you may not use  this file  except in  compliance with the License.
@@ -48,9 +48,6 @@ public abstract class AbstractElasticSearchSupport
     {
         activateElasticSearch();
 
-        // Wait for yellow status: the primary shard is allocated but replicas are not
-        client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();
-
         if ( !client.admin().indices().prepareExists( index ).setIndices( index ).execute().actionGet().isExists() ) {
             // Create empty index
             LOGGER.info( "Will create '{}' index as it does not exists.", index );
@@ -75,6 +72,12 @@ public abstract class AbstractElasticSearchSupport
             LOGGER.info( "Index '{}' created.", index );
         }
 
+        // Ensure index is fresh
+        client.admin().indices().prepareRefresh( index ).execute().actionGet();
+
+        // Wait for yellow status: the primary shard is allocated but replicas may not be yet
+        client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();
+
         LOGGER.info( "Index/Query connected to Elastic Search" );
     }