adding refresh retry
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/f7e78f4a Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/f7e78f4a Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/f7e78f4a Branch: refs/heads/USERGRID-347 Commit: f7e78f4a65cca60c4f4ba064a872331a0d820843 Parents: 51a38fc Author: Shawn Feldman <[email protected]> Authored: Fri Mar 20 07:45:22 2015 -0600 Committer: Shawn Feldman <[email protected]> Committed: Fri Mar 20 07:45:22 2015 -0600 ---------------------------------------------------------------------- .../test/resources/usergrid-custom-test.properties | 1 + .../persistence/index/impl/EsEntityIndexImpl.java | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f7e78f4a/stack/core/src/test/resources/usergrid-custom-test.properties ---------------------------------------------------------------------- diff --git a/stack/core/src/test/resources/usergrid-custom-test.properties b/stack/core/src/test/resources/usergrid-custom-test.properties index 949b60e..fe528fd 100644 --- a/stack/core/src/test/resources/usergrid-custom-test.properties +++ b/stack/core/src/test/resources/usergrid-custom-test.properties @@ -24,4 +24,5 @@ cassandra.connections=1000 #This is just way more efficient for a single node and the number of shards we're creating elasticsearch.number_shards=1 elasticsearch.number_replicas=0 +elasticsearch.index_prefix=core_tests http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f7e78f4a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java index 1eb73d3..18c3d67 100644 --- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java +++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java @@ -35,6 +35,7 @@ import org.apache.usergrid.persistence.model.util.UUIDGenerator; import org.elasticsearch.action.ActionFuture; +import org.elasticsearch.action.ShardOperationFailedException; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksRequest; @@ -47,6 +48,7 @@ import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse; +import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; import org.elasticsearch.client.AdminClient; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; @@ -346,9 +348,20 @@ public class EsEntityIndexImpl implements AliasedEntityIndex { return true; } //Added For Graphite Metrics - esProvider.getClient().admin().indices().prepareRefresh( indexes ).execute().actionGet(); + RefreshResponse response = esProvider.getClient().admin().indices().prepareRefresh( indexes ).execute().actionGet(); + int failedShards = response.getFailedShards(); + int successfulShards = response.getSuccessfulShards(); + ShardOperationFailedException[] sfes = response.getShardFailures(); + if(sfes!=null) { + for (ShardOperationFailedException sfe : sfes) { + logger.error("Failed to refresh index:{} reason:{}", sfe.index(), sfe.reason()); + } + } + logger.debug("Refreshed indexes: {},success:{} failed:{} ", StringUtils.join(indexes, ", "),successfulShards,failedShards); timeRefreshIndex.stop(); - logger.debug("Refreshed indexes: {}", StringUtils.join(indexes, ", ")); + if(failedShards>0){ + throw new RuntimeException("Failed to update all shards in refresh operation"); + } return true; } catch ( IndexMissingException e ) {
