Return-Path: X-Original-To: apmail-zest-commits-archive@minotaur.apache.org Delivered-To: apmail-zest-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6ECFC1723F for ; Fri, 17 Apr 2015 16:42:41 +0000 (UTC) Received: (qmail 78495 invoked by uid 500); 17 Apr 2015 16:42:41 -0000 Delivered-To: apmail-zest-commits-archive@zest.apache.org Received: (qmail 78448 invoked by uid 500); 17 Apr 2015 16:42:41 -0000 Mailing-List: contact commits-help@zest.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zest.apache.org Delivered-To: mailing list commits@zest.apache.org Received: (qmail 78212 invoked by uid 99); 17 Apr 2015 16:42:41 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Apr 2015 16:42:41 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2CEE4E07E9; Fri, 17 Apr 2015 16:42:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: niclas@apache.org To: commits@zest.apache.org Date: Fri, 17 Apr 2015 16:43:04 -0000 Message-Id: <8d69989dcb3a4bc3a86645e5fc9c5549@git.apache.org> In-Reply-To: <544168cbf46b49cc91479151cf20f3f1@git.apache.org> References: <544168cbf46b49cc91479151cf20f3f1@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [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 Authored: Fri Mar 27 11:33:12 2015 +0100 Committer: Paul Merlin 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" ); }