usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject usergrid git commit: add a better status code check for index overload
Date Fri, 09 Oct 2015 17:34:29 GMT
Repository: usergrid
Updated Branches:
  refs/heads/2.1-release 80324de9e -> 5b6508609


add a better status code check for index overload


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

Branch: refs/heads/2.1-release
Commit: 5b6508609c3ce1687993b4015f88126c8be6676d
Parents: 80324de
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Fri Oct 9 11:34:16 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Fri Oct 9 11:34:16 2015 -0600

----------------------------------------------------------------------
 .../persistence/index/impl/EsIndexProducerImpl.java      | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b650860/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexProducerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexProducerImpl.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexProducerImpl.java
index e778948..031556a 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexProducerImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexProducerImpl.java
@@ -27,6 +27,7 @@ import org.elasticsearch.action.bulk.BulkItemResponse;
 import org.elasticsearch.action.bulk.BulkRequestBuilder;
 import org.elasticsearch.action.bulk.BulkResponse;
 import org.elasticsearch.client.Client;
+import org.elasticsearch.rest.RestStatus;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -192,13 +193,17 @@ public class EsIndexProducerImpl implements IndexProducer {
 
         final StringBuilder errorString = new StringBuilder(  );
 
+        boolean hasTooManyRequests= false;
         for ( BulkItemResponse response : responses ) {
 
             if ( response.isFailed() ) {
                 // log error and continue processing
                 log.error( "Unable to index id={}, type={}, index={}, failureMessage={} ",
response.getId(),
-                    response.getType(), response.getIndex(), response.getFailureMessage()
);
-
+                    response.getType(), response.getIndex(),  response.getFailureMessage()
);
+                //if index is overloaded on the queue fail.
+                if(response.getFailure()!=null && response.getFailure().getStatus()
== RestStatus.TOO_MANY_REQUESTS){
+                    hasTooManyRequests =true;
+                }
                 error = true;
 
                 errorString.append( response.getFailureMessage() ).append( "\n" );
@@ -206,7 +211,7 @@ public class EsIndexProducerImpl implements IndexProducer {
         }
 
         if ( error ) {
-            if(errorString.lastIndexOf("rejected execution (queue capacity")>=0){
+            if(hasTooManyRequests){
                 try{
                     log.warn("Encountered Queue Capacity Exception from ElasticSearch slowing
by "
                         + indexFig.getSleepTimeForQueueError() );


Mime
View raw message