usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [15/50] [abbrv] git commit: Changed refresh logic to catch an issue when the Index has not yet replicated across the cluster.
Date Mon, 20 Oct 2014 13:46:43 GMT
Changed refresh logic to catch an issue when the Index has not yet replicated across the cluster.


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

Branch: refs/heads/two-dot-o-events
Commit: e5efa674bf71cda99d9958186962b0691ac4d6c2
Parents: 54b9a11
Author: Todd Nine <toddnine@apache.org>
Authored: Thu Oct 16 15:30:54 2014 -0600
Committer: Todd Nine <toddnine@apache.org>
Committed: Thu Oct 16 15:30:54 2014 -0600

----------------------------------------------------------------------
 .../index/impl/EsEntityIndexImpl.java           | 55 ++++++++++----------
 1 file changed, 27 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e5efa674/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 495b9e1..6ed9b86 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
@@ -124,34 +124,14 @@ public class EsEntityIndexImpl implements EntityIndex {
             }
             while ( response.getFailedShards() != 0 );
 
-            //now try to refresh, to ensure that it's recognized by everyone.  Occasionally
we can get a success
-            //before we can write.
-            for(int i = 0 ; i < MAX_WAITS; i++ ){
-                try{
-                    refresh();
-                    break;
-
-                }catch(Exception e){
-                   log.error( "Unable to refresh index after create. Waiting before sleeping.",
e );
-                }
+            /**
+             * Immediately refresh to ensure the entire cluster is ready to receive this
write.  Occasionally we see
+             * errors.  See this post.
+             * http://elasticsearch-users.115913.n3.nabble.com/IndexMissingException-on-create-index-followed-by-refresh-td1832793.html
+             *
+             */
+            refresh();
 
-                try {
-                    Thread.sleep( WAIT_TIME );
-                }
-                catch ( InterruptedException e ) {
-                    //swallow it
-                }
-            }
-
-            //
-            //            response.getFailedShards();
-            //
-            //            try {
-            //                // TODO: figure out what refresh above is not enough to ensure
index is ready
-            //                Thread.sleep( 500 );
-            //            }
-            //            catch ( InterruptedException ex ) {
-            //            }
         }
         catch ( IndexAlreadyExistsException expected ) {
             // this is expected to happen if index already exists, it's a no-op and swallow
@@ -290,7 +270,26 @@ public class EsEntityIndexImpl implements EntityIndex {
 
 
     public void refresh() {
-        client.admin().indices().prepareRefresh( indexName ).execute().actionGet();
+
+            //now try to refresh, to ensure that it's recognized by everyone.  Occasionally
we can get a success
+            //before we can write.
+            for(int i = 0 ; i < MAX_WAITS; i++ ){
+                try{
+                    client.admin().indices().prepareRefresh( indexName ).execute().actionGet();
+                    break;
+
+                }catch(Exception e){
+                   log.error( "Unable to refresh index after create. Waiting before sleeping.",
e );
+                }
+
+                try {
+                    Thread.sleep( WAIT_TIME );
+                }
+                catch ( InterruptedException e ) {
+                    //swallow it
+                }
+            }
+
         log.debug( "Refreshed index: " + indexName );
     }
 


Mime
View raw message