usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject [2/3] usergrid git commit: Enhance the SQS polling timeout and clean up some log statements.
Date Fri, 19 Aug 2016 23:17:22 GMT
Enhance the SQS polling timeout and clean up some log statements.


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

Branch: refs/heads/master
Commit: b5ed32acc89f3a31d29f08b46afc16ddc01e87a2
Parents: 6a54d0d
Author: Michael Russo <mrusso@apigee.com>
Authored: Fri Aug 19 13:45:24 2016 -0700
Committer: Michael Russo <mrusso@apigee.com>
Committed: Fri Aug 19 13:45:24 2016 -0700

----------------------------------------------------------------------
 .../usergrid/mq/cassandra/io/AbstractSearch.java      |  8 +++++---
 .../apache/usergrid/persistence/queue/QueueFig.java   |  8 ++++----
 .../persistence/queue/impl/SNSQueueManagerImpl.java   | 14 +++++++++++---
 .../usergrid/rest/applications/ServiceResource.java   |  7 ++++++-
 4 files changed, 26 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/b5ed32ac/stack/core/src/main/java/org/apache/usergrid/mq/cassandra/io/AbstractSearch.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/mq/cassandra/io/AbstractSearch.java
b/stack/core/src/main/java/org/apache/usergrid/mq/cassandra/io/AbstractSearch.java
index a1d36a9..4e23923 100644
--- a/stack/core/src/main/java/org/apache/usergrid/mq/cassandra/io/AbstractSearch.java
+++ b/stack/core/src/main/java/org/apache/usergrid/mq/cassandra/io/AbstractSearch.java
@@ -151,7 +151,7 @@ public abstract class AbstractSearch implements QueueSearch {
 
         if ( bounds == null ) {
             logger.error( "Necessary queue bounds not found" );
-            throw new QueueException( "Neccessary queue bounds not found" );
+            throw new QueueException( "Necessary queue bounds not found" );
         }
 
         UUID finish_uuid = params.reversed ? bounds.getOldest() : bounds.getNewest();
@@ -202,8 +202,10 @@ public abstract class AbstractSearch implements QueueSearch {
         while ( ( current_ts_shard >= start_ts_shard ) && ( current_ts_shard <=
finish_ts_shard )
                 && comparator.compare( start, finish_uuid ) < 1 ) {
 
-            logger.info( "Starting search with start UUID {}, finish UUID {}, and reversed
{}",
-                    lastValue, finish_uuid, params.reversed );
+            if( logger.isDebugEnabled() ) {
+                logger.debug("Starting search with start UUID {}, finish UUID {}, and reversed
{}",
+                    lastValue, finish_uuid, params.reversed);
+            }
 
 
             SliceQuery<ByteBuffer, UUID, ByteBuffer> q = createSliceQuery( ko, be,
ue, be );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b5ed32ac/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java
b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java
index 6265a33..74912ae 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java
@@ -92,12 +92,12 @@ public interface QueueFig extends GuicyFig {
     int getQueueClientConnectionTimeout();
 
     @Key( "usergrid.queue.client.socket.timeout")
-    @Default( "20000" ) // 20 seconds
+    @Default( "50000" ) // 50 seconds
     int getQueueClientSocketTimeout();
 
-    @Key( "usergrid.queue.poll.timeshift")
-    @Default( "3000" ) // 3 seconds
-    int getQueuePollTimeshift();
+    @Key( "usergrid.queue.poll.timeout")
+    @Default( "10000" ) // 10 seconds
+    int getQueuePollTimeout();
 
     @Key( "usergrid.queue.quorum.fallback")
     @Default("false") // 30 seconds

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b5ed32ac/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java
b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java
index 0be5bd0..51c6fbf 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java
@@ -437,9 +437,17 @@ public class SNSQueueManagerImpl implements QueueManager {
         receiveMessageRequest.setVisibilityTimeout(
             Math.max( MIN_VISIBILITY_TIMEOUT, fig.getVisibilityTimeout() / 1000 ) );
 
-        // set SQS long polling to 3 secs < the client socket timeout (network delays)
with min of 0 (no long poll)
-        receiveMessageRequest.setWaitTimeSeconds(
-            Math.max(0, ( fig.getQueueClientSocketTimeout() - fig.getQueuePollTimeshift()
) / 1000 ) );
+
+        int longPollTimeout = Math.min(20000, fig.getQueuePollTimeout()); // 20000 is the
SQS maximum
+
+        // ensure the client's socket timeout is not less than the configure long poll timeout
+        if( fig.getQueueClientSocketTimeout() < longPollTimeout){
+
+            longPollTimeout = Math.max(0, fig.getQueueClientSocketTimeout() - 1000);
+
+        }
+
+        receiveMessageRequest.setWaitTimeSeconds( longPollTimeout / 1000 ); // convert to
seconds
 
         try {
             ReceiveMessageResult result = sqs.receiveMessage( receiveMessageRequest );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b5ed32ac/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
index 05b4aa7..91c7db9 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
@@ -944,7 +944,12 @@ public class ServiceResource extends AbstractContextResource {
                 return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
             }
             catch(AmazonServiceException ase){
-                logger.error(ase.getMessage());
+
+                if( ase.getStatusCode() > 499 ){
+                    logger.error(ase.getMessage());
+                }else if(logger.isDebugEnabled()){
+                    logger.debug(ase.getMessage());
+                }
                 return Response.status(ase.getStatusCode()).build();
             }
             catch(RuntimeException re){


Mime
View raw message