You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2015/10/15 16:18:27 UTC
[37/50] [abbrv] usergrid git commit: add a better status code check
for index overload
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/usergrid-1007-shiro-cache
Commit: 5b6508609c3ce1687993b4015f88126c8be6676d
Parents: 80324de
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Oct 9 11:34:16 2015 -0600
Committer: Shawn Feldman <sf...@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() );