You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by mr...@apache.org on 2016/03/23 22:17:49 UTC

usergrid git commit: Fix legacy column parser for edge shards.

Repository: usergrid
Updated Branches:
  refs/heads/release-2.1.1 b9e808841 -> 879cdeffc


Fix legacy column parser for edge shards.


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

Branch: refs/heads/release-2.1.1
Commit: 879cdeffcbd7e8cdab8c25fa61e606b6ea6a1bbe
Parents: b9e8088
Author: Michael Russo <mr...@apigee.com>
Authored: Wed Mar 23 14:17:28 2016 -0700
Committer: Michael Russo <mr...@apigee.com>
Committed: Wed Mar 23 14:17:28 2016 -0700

----------------------------------------------------------------------
 .../shard/impl/EdgeShardSerializationImpl.java  | 13 ++++----
 .../shard/impl/serialize/ShardSerializer.java   | 33 ++++++--------------
 2 files changed, 16 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/879cdeff/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeShardSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeShardSerializationImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeShardSerializationImpl.java
index 76a0922..13ca68f 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeShardSerializationImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeShardSerializationImpl.java
@@ -24,6 +24,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 
+import com.google.common.util.concurrent.ExecutionError;
 import org.apache.cassandra.db.marshal.BytesType;
 
 import org.apache.usergrid.persistence.core.astyanax.CassandraConfig;
@@ -217,17 +218,15 @@ public class EdgeShardSerializationImpl implements EdgeShardSerialization {
             // every item in the shard. If the legacy value is seen, we return a shard with Long.MIN for index and
             // createdTime so it can be identified later and handled.
 
+            try {
 
-            Shard shard =  column.getValue(SHARD_SERIALIZER);
+                return column.getValue(SHARD_SERIALIZER);
 
-            if (shard.getShardIndex() == Long.MIN_VALUE && shard.getCreatedTime() == Long.MIN_VALUE){
+            } catch ( Exception e) {
 
-                // this was deserialized as a legacy column format, use the column name and timestamp for the shard
-                return new Shard(column.getName(), column.getTimestamp(), shard.isCompacted());
+                // unable to parse the new format so return the old format
+                return new Shard(column.getName(), column.getTimestamp(), column.getBooleanValue());
 
-            } else {
-
-                return shard;
             }
 
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/879cdeff/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/serialize/ShardSerializer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/serialize/ShardSerializer.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/serialize/ShardSerializer.java
index 58276fe..8ab6288 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/serialize/ShardSerializer.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/serialize/ShardSerializer.java
@@ -65,34 +65,21 @@ public class ShardSerializer extends AbstractSerializer<Shard> {
 
     @Override
     public Shard fromByteBuffer( final ByteBuffer byteBuffer ) {
-        DynamicComposite composite = DynamicComposite.fromByteBuffer( byteBuffer );
-
-        Preconditions.checkArgument( composite.size() == 1 || composite.size() == 5,
-            "Composite should have 1 or 5 elements" );
-
-        // this is the legacy column format, return a shard with identifiable values so the column name and timestamp
-        // can be used
-        if( composite.size() == 1){
 
-            final boolean isCompacted = composite.get( 0, BOOLEAN_SERIALIZER);
-            return new Shard(Long.MIN_VALUE, Long.MIN_VALUE, isCompacted);
+        DynamicComposite composite = DynamicComposite.fromByteBuffer( byteBuffer );
+        Preconditions.checkArgument( composite.size() == 5, "Composite should 5 elements" );
 
-        }
-        // This is the new format which contains all the information about a Shard.  Include a byte version of 2 if it's
-        // needed later for any reason.
-        else{
 
-            final byte version = composite.get(0, BYTE_SERIALIZER);
-            final long shardIndex = composite.get( 1, LONG_SERIALIZER );
-            final long shardCreated = composite.get( 2, LONG_SERIALIZER );
-            final DirectedEdge shardEnd = composite.get( 3, EDGE_SERIALIZER);
-            final boolean isCompacted = composite.get( 4, BOOLEAN_SERIALIZER);
+        final byte version = composite.get(0, BYTE_SERIALIZER);
+        final long shardIndex = composite.get( 1, LONG_SERIALIZER );
+        final long shardCreated = composite.get( 2, LONG_SERIALIZER );
+        final DirectedEdge shardEnd = composite.get( 3, EDGE_SERIALIZER);
+        final boolean isCompacted = composite.get( 4, BOOLEAN_SERIALIZER);
 
 
-            final Shard shard = new Shard(shardIndex, shardCreated, isCompacted);
-            shard.setShardEnd(Optional.fromNullable(shardEnd));
-            return shard;
-        }
+        final Shard shard = new Shard(shardIndex, shardCreated, isCompacted);
+        shard.setShardEnd(Optional.fromNullable(shardEnd));
+        return shard;
 
     }