You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2014/09/30 22:03:48 UTC

[1/2] git commit: Added additional logging and a short circuit test

Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o 72f1beae0 -> f6a79d05a


Added additional logging and a short circuit test


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

Branch: refs/heads/two-dot-o
Commit: 87c51ae581aa5f676af0e2f2dcbd876cf8a16da1
Parents: 9ce8346
Author: Todd Nine <to...@apache.org>
Authored: Tue Sep 30 14:03:12 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Tue Sep 30 14:03:12 2014 -0600

----------------------------------------------------------------------
 .../mq/cassandra/io/AbstractSearch.java         | 42 +++++++++++++++-----
 1 file changed, 32 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/87c51ae5/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 b0b5ac7..ffda843 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
@@ -37,6 +37,8 @@ import org.apache.usergrid.persistence.exceptions.QueueException;
 import org.apache.usergrid.persistence.hector.CountingMutator;
 import org.apache.usergrid.utils.UUIDUtils;
 
+import com.fasterxml.uuid.UUIDComparator;
+
 import me.prettyprint.hector.api.Keyspace;
 import me.prettyprint.hector.api.beans.ColumnSlice;
 import me.prettyprint.hector.api.beans.HColumn;
@@ -63,6 +65,7 @@ import static org.apache.usergrid.persistence.cassandra.Serializers.be;
 import static org.apache.usergrid.persistence.cassandra.Serializers.se;
 import static org.apache.usergrid.persistence.cassandra.Serializers.ue;
 import static org.apache.usergrid.utils.NumberUtils.roundLong;
+import static org.apache.usergrid.utils.UUIDUtils.compare;
 import static org.apache.usergrid.utils.UUIDUtils.getTimestampInMillis;
 
 
@@ -181,25 +184,26 @@ public abstract class AbstractSearch implements QueueSearch {
             current_ts_shard = finish_ts_shard;
         }
 
+        final MessageIdComparator comparator = new MessageIdComparator(params.reversed);
+
 
         //should be start < finish
-        if ( !params.reversed && UUIDUtils.compare( start, finish_uuid ) > 0 ) {
+        if ( comparator.compare( start, finish_uuid ) > 0 ) {
             logger.warn( "Tried to perform a slice with start UUID {} after finish UUID {}.", start, finish_uuid );
-            throw new IllegalArgumentException( String.format("You cannot specify a start value of %s after finish value of %s", start, finish_uuid) );
+            throw new IllegalArgumentException(
+                    String.format( "You cannot specify a start value of %s after finish value of %s", start,
+                            finish_uuid ) );
         }
 
-        // should be finish < start
-        else if ( params.reversed && UUIDUtils.compare( start, finish_uuid ) < 0 ) {
-            logger.warn( "Tried to perform a slice with start UUID {} after finish UUID {}.", start, finish_uuid );
-            throw new IllegalArgumentException( String.format("You cannot specify a start value of %s after finish value of %s", start, finish_uuid) );
-        }
 
 
 
         UUID lastValue = start;
         boolean firstPage = true;
 
-        while ( ( current_ts_shard >= start_ts_shard ) && ( current_ts_shard <= finish_ts_shard ) ) {
+        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 {}", new Object[]{lastValue, finish_uuid, params.reversed });
 
 
             SliceQuery<ByteBuffer, UUID, ByteBuffer> q = createSliceQuery( ko, be, ue, be );
@@ -215,8 +219,8 @@ public abstract class AbstractSearch implements QueueSearch {
                 final UUID columnName = column.getName();
 
                 // skip the first one, we've already read it
-                if ( i == 0 && (firstPage && params.skipFirst && params.startId.equals( columnName ))
-                        || (!firstPage &&  lastValue != null && lastValue.equals(columnName)) ) {
+                if ( i == 0 && ( firstPage && params.skipFirst && params.startId.equals( columnName ) ) || ( !firstPage
+                        && lastValue != null && lastValue.equals( columnName ) ) ) {
                     continue;
                 }
 
@@ -333,4 +337,22 @@ public abstract class AbstractSearch implements QueueSearch {
             return o1Idx - o2Idx;
         }
     }
+
+
+    private static final class MessageIdComparator implements Comparator<UUID> {
+
+        private final int comparator;
+
+
+        private MessageIdComparator( final boolean reversed ) {
+
+            this.comparator = reversed ? -1 : 1;
+        }
+
+
+        @Override
+        public int compare( final UUID o1, final UUID o2 ) {
+            return UUIDUtils.compare( o1, o2 )*comparator;
+        }
+    }
 }


[2/2] git commit: Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o

Posted by to...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o


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

Branch: refs/heads/two-dot-o
Commit: f6a79d05a81c6096c13417ce48ba1a8e29ed4f90
Parents: 87c51ae 72f1bea
Author: Todd Nine <to...@apache.org>
Authored: Tue Sep 30 14:03:42 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Tue Sep 30 14:03:42 2014 -0600

----------------------------------------------------------------------
 .../apache/usergrid/services/notifications/QueueListener.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------