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 2014/08/28 21:39:33 UTC

[1/4] git commit: uuid fixes, adding serialization fixes

Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o 9c47aee00 -> efdc08d7c


uuid fixes, adding serialization fixes


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

Branch: refs/heads/two-dot-o
Commit: 64ad13d5a1ec3fe9d158e39ac4a6d80df3aedcfe
Parents: 9c47aee
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Aug 26 12:50:54 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Aug 28 09:30:04 2014 -0600

----------------------------------------------------------------------
 stack/core/pom.xml                              | 20 +++++++-
 .../corepersistence/CpEntityManager.java        | 49 +++++++++++---------
 .../corepersistence/CpRelationManager.java      | 10 ++--
 .../java/org/apache/usergrid/mq/Message.java    | 13 +++---
 .../apache/usergrid/persistence/EntityRef.java  |  3 ++
 .../apache/usergrid/persistence/PathQuery.java  |  8 ++--
 .../usergrid/persistence/SimpleEntityRef.java   | 36 +++++++-------
 .../usergrid/persistence/PathQueryIT.java       |  4 +-
 .../persistence/core/util/ValidationUtils.java  |  2 +-
 .../usergrid/persistence/index/query/Query.java |  4 +-
 10 files changed, 93 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/64ad13d5/stack/core/pom.xml
----------------------------------------------------------------------
diff --git a/stack/core/pom.xml b/stack/core/pom.xml
index 0972a89..41c7244 100644
--- a/stack/core/pom.xml
+++ b/stack/core/pom.xml
@@ -576,6 +576,24 @@
             <version>${rx.version}</version>
         </dependency>
 
-    </dependencies>
+
+    <dependency>
+      <groupId>com.codahale.metrics</groupId>
+      <artifactId>metrics-core</artifactId>
+      <version>${metrics.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.codahale.metrics</groupId>
+      <artifactId>metrics-graphite</artifactId>
+      <version>${metrics.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.clearspring.analytics</groupId>
+      <artifactId>stream</artifactId>
+      <version>2.7.0</version>
+    </dependency>
+
+  </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/64ad13d5/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index 28124c2..f40bc3b 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -33,6 +33,7 @@ import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.UUID;
 
+import com.clearspring.analytics.hash.MurmurHash;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.util.Assert;
@@ -323,10 +324,10 @@ public class CpEntityManager implements EntityManager {
 
         EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
 
-        if ( !UUIDUtils.isTimeBased( id.getUuid() ) ) {
-            throw new IllegalArgumentException(
-                "Entity Id " + id.getType() + ":"+ id.getUuid() +" uuid not time based");
-        }
+//        if ( !UUIDUtils.isTimeBased( id.getUuid() ) ) {
+//            throw new IllegalArgumentException(
+//                "Entity Id " + id.getType() + ":"+ id.getUuid() +" uuid not time based");
+//        }
 
        org.apache.usergrid.persistence.model.entity.Entity cpEntity = 
                 ecm.load( id ).toBlockingObservable().last();
@@ -410,10 +411,10 @@ public class CpEntityManager implements EntityManager {
 
         EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
 
-        if ( !UUIDUtils.isTimeBased( id.getUuid() ) ) {
-            throw new IllegalArgumentException(
-                "Entity Id " + id.getType() + ":"+ id.getUuid() +" uuid not time based");
-        }
+//        if ( !UUIDUtils.isTimeBased( id.getUuid() ) ) {
+//            throw new IllegalArgumentException(
+//                "Entity Id " + id.getType() + ":"+ id.getUuid() +" uuid not time based");
+//        }
 
         org.apache.usergrid.persistence.model.entity.Entity cpEntity = 
                 ecm.load( id ).toBlockingObservable().last();
@@ -489,10 +490,10 @@ public class CpEntityManager implements EntityManager {
             } );
         }
 
-        if ( !UUIDUtils.isTimeBased( entityId.getUuid() ) ) {
-            throw new IllegalArgumentException(
-                "Entity Id " + entityId.getType() + ":"+ entityId.getUuid() +" uuid not time based");
-        }
+//        if ( !UUIDUtils.isTimeBased( entityId.getUuid() ) ) {
+//            throw new IllegalArgumentException(
+//                "Entity Id " + entityId.getType() + ":"+ entityId.getUuid() +" uuid not time based");
+//        }
 
         org.apache.usergrid.persistence.model.entity.Entity cpEntity =
                 ecm.load( entityId ).toBlockingObservable().last();
@@ -543,10 +544,10 @@ public class CpEntityManager implements EntityManager {
 
         Id entityId = new SimpleId( entityRef.getUuid(), entityRef.getType() );
 
-        if ( !UUIDUtils.isTimeBased( entityId.getUuid() ) ) {
-            throw new IllegalArgumentException(
-                "Entity Id " + entityId.getType() + ":"+ entityId.getUuid() +" uuid not time based");
-        }
+//        if ( !UUIDUtils.isTimeBased( entityId.getUuid() ) ) {
+//            throw new IllegalArgumentException(
+//                "Entity Id " + entityId.getType() + ":"+ entityId.getUuid() +" uuid not time based");
+//        }
 
         org.apache.usergrid.persistence.model.entity.Entity entity = 
                 ecm.load( entityId ).toBlockingObservable().last();
@@ -984,10 +985,10 @@ public class CpEntityManager implements EntityManager {
 
         Id entityId = new SimpleId( entityRef.getUuid(), entityRef.getType() );
 
-        if ( !UUIDUtils.isTimeBased( entityId.getUuid() ) ) {
-            throw new IllegalArgumentException(
-                "Entity Id " + entityId.getType() + ":"+entityId.getUuid() +" uuid not time based");
-        }
+//        if ( !UUIDUtils.isTimeBased( entityId.getUuid() ) ) {
+//            throw new IllegalArgumentException(
+//                "Entity Id " + entityId.getType() + ":"+entityId.getUuid() +" uuid not time based");
+//        }
 
         org.apache.usergrid.persistence.model.entity.Entity cpEntity =
                 ecm.load( entityId ).toBlockingObservable().last();
@@ -2363,7 +2364,13 @@ public class CpEntityManager implements EntityManager {
             return null;
         }
 
-        long timestamp = UUIDUtils.getTimestampInMicros( timestampUuid );
+        long timestamp = 0;
+
+        if(UUIDUtils.isTimeBased(timestampUuid)) {
+            timestamp = UUIDUtils.getTimestampInMicros(timestampUuid);
+        }else{
+            timestamp = MurmurHash.hash64(timestampUuid);
+        }
 
         UUID itemId = UUIDUtils.newTimeUUID();
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/64ad13d5/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 31d32dd..9199d19 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -28,6 +28,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
+import com.clearspring.analytics.hash.MurmurHash;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.util.Assert;
@@ -685,12 +686,13 @@ public class CpRelationManager implements RelationManager {
                 headEntity.getType(), headEntity.getUuid(), 
                 itemRef.getType(), itemRef.getUuid() });
 
+        long uuidHash = MurmurHash.hash64( memberEntity.getId().getUuid());
         // create graph edge connection from head entity to member entity
         Edge edge = new SimpleEdge(
-            cpHeadEntity.getId(), 
-            edgeType, 
-            memberEntity.getId(), 
-            memberEntity.getId().getUuid().timestamp() );
+            cpHeadEntity.getId(),
+            edgeType,
+            memberEntity.getId(),
+           uuidHash);
         GraphManager gm = managerCache.getGraphManager(applicationScope);
         gm.writeEdge(edge).toBlockingObservable().last();
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/64ad13d5/stack/core/src/main/java/org/apache/usergrid/mq/Message.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/mq/Message.java b/stack/core/src/main/java/org/apache/usergrid/mq/Message.java
index 85aea1f..b48fe74 100644
--- a/stack/core/src/main/java/org/apache/usergrid/mq/Message.java
+++ b/stack/core/src/main/java/org/apache/usergrid/mq/Message.java
@@ -30,6 +30,7 @@ import java.util.UUID;
 
 import javax.xml.bind.annotation.XmlRootElement;
 
+import com.clearspring.analytics.hash.MurmurHash;
 import org.apache.usergrid.utils.UUIDUtils;
 
 import com.fasterxml.jackson.annotation.JsonAnyGetter;
@@ -484,13 +485,13 @@ public class Message {
 
 
     public void setUuid( UUID uuid ) {
-        if ( isTimeBased( uuid ) ) {
+        //if ( isTimeBased( uuid ) ) {
             properties.put( MESSAGE_ID, uuid );
-            properties.put( MESSAGE_TIMESTAMP, getTimestampInMillis( uuid ) );
-        }
-        else {
-            throw new IllegalArgumentException( "Not a time-based UUID" );
-        }
+            properties.put( MESSAGE_TIMESTAMP, MurmurHash.hash64(uuid));
+//        }
+//        else {
+//            throw new IllegalArgumentException( "Not a time-based UUID" );
+//        }
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/64ad13d5/stack/core/src/main/java/org/apache/usergrid/persistence/EntityRef.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityRef.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityRef.java
index b9d60cb..8133840 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityRef.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityRef.java
@@ -17,8 +17,11 @@
 package org.apache.usergrid.persistence;
 
 
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+
 import java.util.UUID;
 
+@JsonTypeInfo( use= JsonTypeInfo.Id.CLASS,include= JsonTypeInfo.As.WRAPPER_OBJECT,property="@class" )
 public interface EntityRef {
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/64ad13d5/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java b/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java
index 6721fa6..c1d0360 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java
@@ -26,7 +26,7 @@ public class PathQuery<E> {
 
     private PathQuery source;
     private Query query;
-    private EntityRef head;
+    private SimpleEntityRef head;
 
 
     public PathQuery() {
@@ -38,7 +38,7 @@ public class PathQuery<E> {
      *
      * @param head the top-level entity
      */
-    public PathQuery( EntityRef head ) {
+    public PathQuery( SimpleEntityRef head ) {
         this.head = head;
         this.query = null;
     }
@@ -50,7 +50,7 @@ public class PathQuery<E> {
      * @param head the top-level entity
      * @param query the query - must have a collection or connectType value set
      */
-    public PathQuery( EntityRef head, Query query ) {
+    public PathQuery( SimpleEntityRef head, Query query ) {
         if ( query.getCollection() == null && query.getConnectionType() == null ) {
             throw new IllegalArgumentException( "Query must have a collection or connectionType value" );
         }
@@ -122,7 +122,7 @@ public class PathQuery<E> {
     }
 
 
-    public EntityRef getHead() {
+    public SimpleEntityRef getHead() {
         return head;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/64ad13d5/stack/core/src/main/java/org/apache/usergrid/persistence/SimpleEntityRef.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/SimpleEntityRef.java b/stack/core/src/main/java/org/apache/usergrid/persistence/SimpleEntityRef.java
index 3e0f413..65f093f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/SimpleEntityRef.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/SimpleEntityRef.java
@@ -17,6 +17,9 @@
 package org.apache.usergrid.persistence;
 
 
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
 import java.util.UUID;
 
 
@@ -26,24 +29,25 @@ public class SimpleEntityRef implements EntityRef {
 
     protected final String type;
 
-    protected final UUID id;
+    protected final UUID uuid;
 
 
-    public SimpleEntityRef( UUID id ) {
-        this.id = id;
+    public SimpleEntityRef( UUID uuid ) {
+        this.uuid = uuid;
         type = null;
     }
 
 
-    public SimpleEntityRef( String type, UUID id ) {
+    @JsonCreator
+    public SimpleEntityRef(@JsonProperty("type")  String type,@JsonProperty("uuid")  UUID uuid ) {
         this.type = type;
-        this.id = id;
+        this.uuid = uuid;
     }
 
 
     public SimpleEntityRef( EntityRef entityRef ) {
         type = entityRef.getType();
-        id = entityRef.getUuid();
+        uuid = entityRef.getUuid();
     }
 
 
@@ -54,7 +58,7 @@ public class SimpleEntityRef implements EntityRef {
 
     @Override
     public UUID getUuid() {
-        return id;
+        return uuid;
     }
 
 
@@ -69,8 +73,8 @@ public class SimpleEntityRef implements EntityRef {
     }
 
 
-    public static EntityRef ref( UUID entityId ) {
-        return new SimpleEntityRef( null, entityId );
+    public static EntityRef ref( UUID uuid ) {
+        return new SimpleEntityRef( null, uuid );
     }
 
 
@@ -83,7 +87,7 @@ public class SimpleEntityRef implements EntityRef {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ( ( id == null ) ? 0 : id.hashCode() );
+        result = prime * result + ( ( uuid == null ) ? 0 : uuid.hashCode() );
         result = prime * result + ( ( type == null ) ? 0 : type.hashCode() );
         return result;
     }
@@ -101,12 +105,12 @@ public class SimpleEntityRef implements EntityRef {
             return false;
         }
         SimpleEntityRef other = ( SimpleEntityRef ) obj;
-        if ( id == null ) {
-            if ( other.id != null ) {
+        if ( uuid == null ) {
+            if ( other.uuid != null ) {
                 return false;
             }
         }
-        else if ( !id.equals( other.id ) ) {
+        else if ( !uuid.equals( other.uuid ) ) {
             return false;
         }
         if ( type == null ) {
@@ -123,13 +127,13 @@ public class SimpleEntityRef implements EntityRef {
 
     @Override
     public String toString() {
-        if ( ( type == null ) && ( id == null ) ) {
+        if ( ( type == null ) && ( uuid == null ) ) {
             return "EntityRef(" + NULL_ID.toString() + ")";
         }
         if ( type == null ) {
-            return "EntityRef(" + id.toString() + ")";
+            return "EntityRef(" + uuid.toString() + ")";
         }
-        return type + "(" + id + ")";
+        return type + "(" + uuid + ")";
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/64ad13d5/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
index bdaef0a..16fae85 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
@@ -92,7 +92,7 @@ public class PathQueryIT extends AbstractCoreIT {
         deviceQuery.addFilter( "index >= 2" );
         int expectedDeviceQuerySize = 3;
 
-        PathQuery<EntityRef> usersPQ = new PathQuery<EntityRef>( em.getApplicationRef(), userQuery );
+        PathQuery<EntityRef> usersPQ = new PathQuery<EntityRef>( new SimpleEntityRef( em.getApplicationRef()), userQuery );
         PathQuery<Entity> devicesPQ = usersPQ.chain( deviceQuery );
         HashSet set = new HashSet( expectedUserQuerySize * expectedDeviceQuerySize );
         Iterator<Entity> i = devicesPQ.iterator( em );
@@ -174,7 +174,7 @@ public class PathQueryIT extends AbstractCoreIT {
         deviceQuery.addFilter( "index >= 4" );
         int expectedDeviceQuerySize = 3;
 
-        PathQuery groupsPQ = new PathQuery( em.getApplicationRef(), groupQuery );
+        PathQuery groupsPQ = new PathQuery(new SimpleEntityRef( em.getApplicationRef() ), groupQuery );
         PathQuery usersPQ = groupsPQ.chain( userQuery );
         PathQuery<Entity> devicesPQ = usersPQ.chain( deviceQuery );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/64ad13d5/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/util/ValidationUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/util/ValidationUtils.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/util/ValidationUtils.java
index 62f7ab6..141978a 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/util/ValidationUtils.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/util/ValidationUtils.java
@@ -80,7 +80,7 @@ public class ValidationUtils {
 
         Preconditions.checkNotNull( uuid, "The id uuid is required to be set" );
 
-        Preconditions.checkArgument( uuid.version() == UUID_VERSION, "The uuid must be version 1" );
+        //Preconditions.checkArgument( uuid.version() == UUID_VERSION, "The uuid must be version 1" );
 
         final String type = entityId.getType();
         Preconditions.checkNotNull( type, "The id type is required " );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/64ad13d5/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
index 9dda724..569c08d 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
@@ -28,6 +28,8 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.UUID;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
 import org.antlr.runtime.ANTLRStringStream;
 import org.antlr.runtime.ClassicToken;
 import org.antlr.runtime.CommonTokenStream;
@@ -1081,7 +1083,7 @@ public class Query {
         private final Query.SortDirection direction;
 
 
-        public SortPredicate( String propertyName, Query.SortDirection direction ) {
+        public SortPredicate(@JsonProperty("propertyName")  String propertyName, @JsonProperty("direction")  Query.SortDirection direction ) {
             if ( propertyName == null ) {
                 throw new NullPointerException( "Property name was null" );
             }


[4/4] git commit: add uuid long method

Posted by sn...@apache.org.
add uuid long method


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

Branch: refs/heads/two-dot-o
Commit: efdc08d7c177fcf4613a9135ee7d35ed8a2dfcfc
Parents: 78ce124
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Aug 28 10:23:14 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Aug 28 10:23:14 2014 -0600

----------------------------------------------------------------------
 .../core/src/main/java/org/apache/usergrid/mq/Message.java  | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/efdc08d7/stack/core/src/main/java/org/apache/usergrid/mq/Message.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/mq/Message.java b/stack/core/src/main/java/org/apache/usergrid/mq/Message.java
index b48fe74..73c8f7d 100644
--- a/stack/core/src/main/java/org/apache/usergrid/mq/Message.java
+++ b/stack/core/src/main/java/org/apache/usergrid/mq/Message.java
@@ -485,13 +485,8 @@ public class Message {
 
 
     public void setUuid( UUID uuid ) {
-        //if ( isTimeBased( uuid ) ) {
-            properties.put( MESSAGE_ID, uuid );
-            properties.put( MESSAGE_TIMESTAMP, MurmurHash.hash64(uuid));
-//        }
-//        else {
-//            throw new IllegalArgumentException( "Not a time-based UUID" );
-//        }
+        properties.put(MESSAGE_ID, uuid);
+        properties.put(MESSAGE_TIMESTAMP, UUIDUtils.getUUIDLong(uuid));
     }
 
 


[2/4] git commit: abstract uuid creation

Posted by sn...@apache.org.
abstract uuid creation


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

Branch: refs/heads/two-dot-o
Commit: 1d74ec00ea9b8052f3fce882ccf0ad7112d34c8b
Parents: 64ad13d
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Aug 26 16:36:18 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Aug 28 09:30:23 2014 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/CpEntityManager.java       | 12 +++---------
 .../usergrid/corepersistence/CpRelationManager.java     |  4 ++--
 .../main/java/org/apache/usergrid/utils/UUIDUtils.java  | 11 +++++++++++
 3 files changed, 16 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1d74ec00/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index f40bc3b..7e1f199 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -1595,7 +1595,7 @@ public class CpEntityManager implements EntityManager {
             throws Exception {
 
         UUID timestampUuid = UUIDUtils.newTimeUUID();
-        long timestamp = UUIDUtils.getTimestampInMicros( timestampUuid );
+        long timestamp = UUIDUtils.getUUIDLong(timestampUuid);
 
         Map<String, Object> properties = new TreeMap<>( CASE_INSENSITIVE_ORDER );
         properties.put( PROPERTY_TYPE, Role.ENTITY_TYPE );
@@ -2364,13 +2364,7 @@ public class CpEntityManager implements EntityManager {
             return null;
         }
 
-        long timestamp = 0;
-
-        if(UUIDUtils.isTimeBased(timestampUuid)) {
-            timestamp = UUIDUtils.getTimestampInMicros(timestampUuid);
-        }else{
-            timestamp = MurmurHash.hash64(timestampUuid);
-        }
+        long timestamp = UUIDUtils.getUUIDLong(timestampUuid);
 
         UUID itemId = UUIDUtils.newTimeUUID();
 
@@ -2623,7 +2617,7 @@ public class CpEntityManager implements EntityManager {
             boolean removeFromDictionary, UUID timestampUuid )
             throws Exception {
 
-        long timestamp = UUIDUtils.getTimestampInMicros( timestampUuid );
+        long timestamp = UUIDUtils.getUUIDLong(timestampUuid);
 
         // dictionaryName = dictionaryName.toLowerCase();
         if ( elementCoValue == null ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1d74ec00/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 9199d19..4131400 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -28,7 +28,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
-import com.clearspring.analytics.hash.MurmurHash;
+import org.apache.usergrid.utils.UUIDUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.util.Assert;
@@ -686,7 +686,7 @@ public class CpRelationManager implements RelationManager {
                 headEntity.getType(), headEntity.getUuid(), 
                 itemRef.getType(), itemRef.getUuid() });
 
-        long uuidHash = MurmurHash.hash64( memberEntity.getId().getUuid());
+        long uuidHash =   UUIDUtils.getUUIDLong( memberEntity.getId().getUuid());
         // create graph edge connection from head entity to member entity
         Edge edge = new SimpleEdge(
             cpHeadEntity.getId(),

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1d74ec00/stack/core/src/main/java/org/apache/usergrid/utils/UUIDUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/utils/UUIDUtils.java b/stack/core/src/main/java/org/apache/usergrid/utils/UUIDUtils.java
index 6d8175c..ecb1f61 100644
--- a/stack/core/src/main/java/org/apache/usergrid/utils/UUIDUtils.java
+++ b/stack/core/src/main/java/org/apache/usergrid/utils/UUIDUtils.java
@@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.ReentrantLock;
 
+import com.clearspring.analytics.hash.MurmurHash;
 import com.fasterxml.uuid.EthernetAddress;
 import com.fasterxml.uuid.UUIDComparator;
 
@@ -379,6 +380,16 @@ public class UUIDUtils {
         return tryGetUUID( s.substring( offset, offset + 36 ) );
     }
 
+    public static long getUUIDLong(UUID id){
+        long timestamp = 0;
+        if(UUIDUtils.isTimeBased(id)) {
+            timestamp = UUIDUtils.getTimestampInMicros(id);
+        }else{
+            timestamp = MurmurHash.hash64(id);
+        }
+        return timestamp;
+    }
+
 
     public static String toBase64( UUID id ) {
         if ( id == null ) {


[3/4] git commit: remove extra ref

Posted by sn...@apache.org.
remove extra ref


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

Branch: refs/heads/two-dot-o
Commit: 78ce124675b6d71deed2c73522dd0720fb39e0c3
Parents: 1d74ec0
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Aug 28 10:18:49 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Aug 28 10:18:49 2014 -0600

----------------------------------------------------------------------
 stack/core/pom.xml | 39 ++++++++++++++-------------------------
 1 file changed, 14 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/78ce1246/stack/core/pom.xml
----------------------------------------------------------------------
diff --git a/stack/core/pom.xml b/stack/core/pom.xml
index 41c7244..08c8c1c 100644
--- a/stack/core/pom.xml
+++ b/stack/core/pom.xml
@@ -550,38 +550,15 @@
             <groupId>org.apache.usergrid.chop</groupId>
             <artifactId>chop-stack</artifactId>
             <version>2.0.0-SNAPSHOT</version>
-        </dependency>-->
-
-        <dependency>
-            <groupId>com.codahale.metrics</groupId>
-            <artifactId>metrics-core</artifactId>
-            <version>${metrics.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>com.codahale.metrics</groupId>
-            <artifactId>metrics-graphite</artifactId>
-            <version>${metrics.version}</version>
         </dependency>
-
-        <dependency>
-            <groupId>com.netflix.rxjava</groupId>
-            <artifactId>rxjava-core</artifactId>
-            <version>${rx.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>com.netflix.rxjava</groupId>
-            <artifactId>rxjava-math</artifactId>
-            <version>${rx.version}</version>
-        </dependency>
-
+    -->
 
     <dependency>
       <groupId>com.codahale.metrics</groupId>
       <artifactId>metrics-core</artifactId>
       <version>${metrics.version}</version>
     </dependency>
+
     <dependency>
       <groupId>com.codahale.metrics</groupId>
       <artifactId>metrics-graphite</artifactId>
@@ -589,6 +566,18 @@
     </dependency>
 
     <dependency>
+      <groupId>com.netflix.rxjava</groupId>
+      <artifactId>rxjava-core</artifactId>
+      <version>${rx.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.netflix.rxjava</groupId>
+      <artifactId>rxjava-math</artifactId>
+      <version>${rx.version}</version>
+    </dependency>
+
+    <dependency>
       <groupId>com.clearspring.analytics</groupId>
       <artifactId>stream</artifactId>
       <version>2.7.0</version>