You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2015/01/30 19:00:09 UTC

[2/2] incubator-usergrid git commit: added new entity object for serialization

added new entity object for serialization

add new guide interface names

fix compile issues in core persistence

add array field instead of list field

adding proxies to new storage


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

Branch: refs/heads/USERGRID-365
Commit: 6749ae2fad7bb26e17eb72a5867d7830e1975748
Parents: 198f479
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Jan 29 11:46:01 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Jan 30 10:59:48 2015 -0700

----------------------------------------------------------------------
 .../migration/EntityDataMigration.java          |   3 +-
 .../migration/GraphShardVersionMigration.java   |   3 +-
 .../corepersistence/migration/Versions.java     |   9 +-
 .../corepersistence/util/CpEntityMapUtils.java  |  48 ++---
 .../migration/EntityDataMigrationIT.java        |  12 +-
 .../MvccEntitySerializationStrategyProxy.java   | 153 +++++++++++++
 ...vccEntitySerializationStrategyProxyImpl.java | 162 --------------
 ...cEntitySerializationStrategyProxyV1Impl.java |  66 ++++++
 ...cEntitySerializationStrategyProxyV2Impl.java |  44 ++++
 .../MvccEntitySerializationStrategyV3Impl.java  | 212 +++++++++++++++++++
 .../serialization/impl/SerializationModule.java |  25 ++-
 ...cEntitySerializationStrategyProxyV1Test.java |  85 --------
 ...ntitySerializationStrategyProxyV1_2Test.java |  81 +++++++
 ...ntitySerializationStrategyProxyV1_3Test.java |  80 +++++++
 ...cEntitySerializationStrategyProxyV2Test.java |  51 ++---
 ...ccEntitySerializationStrategyV1ImplTest.java |   4 +-
 ...ccEntitySerializationStrategyV2ImplTest.java |   4 +-
 ...ccEntitySerializationStrategyV3ImplTest.java |  32 +++
 .../MvccEntitySerializationStrategyV3Test.java  | 108 ++++++++++
 .../persistence/core/guice/CurrentImpl.java     |  39 ++--
 .../persistence/core/guice/PreviousImpl.java    |  41 ++--
 .../usergrid/persistence/core/guice/V1Impl.java |  37 ++++
 .../persistence/core/guice/V1ProxyImpl.java     |  35 +++
 .../usergrid/persistence/core/guice/V2Impl.java |  37 ++++
 .../usergrid/persistence/core/guice/V3Impl.java |  37 ++++
 .../persistence/graph/guice/GraphModule.java    |  12 +-
 .../EdgeMetadataSerializationProxyImpl.java     |   9 +-
 .../EdgeMetaDataSerializationV1Test.java        |   4 +-
 .../EdgeMetaDataSerializationV2Test.java        |   4 +-
 .../persistence/model/entity/Entity.java        |  18 +-
 .../persistence/model/entity/EntityMap.java     |  24 +++
 .../model/entity/EntityToMapConverter.java      | 125 +++++++++++
 .../model/entity/MapToEntityConverter.java      | 195 +++++++++++++++++
 .../persistence/model/field/ListField.java      |   2 +-
 .../index/impl/EntityIndexMapUtils.java         |  52 ++---
 35 files changed, 1441 insertions(+), 412 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityDataMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityDataMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityDataMigration.java
index 767574d..847d717 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityDataMigration.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityDataMigration.java
@@ -30,8 +30,7 @@ import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 import org.apache.usergrid.persistence.collection.CollectionScope;
 import org.apache.usergrid.persistence.collection.MvccEntity;
 import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
-import org.apache.usergrid.persistence.core.guice.CurrentImpl;
-import org.apache.usergrid.persistence.core.guice.PreviousImpl;
+import org.apache.usergrid.persistence.core.guice.*;
 import org.apache.usergrid.persistence.core.migration.data.DataMigration;
 import org.apache.usergrid.persistence.core.migration.data.DataMigrationException;
 import org.apache.usergrid.persistence.model.entity.Id;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java
index 3b92570..21f945b 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java
@@ -25,13 +25,14 @@ package org.apache.usergrid.corepersistence.migration;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.usergrid.persistence.core.guice.CurrentImpl;
+import org.apache.usergrid.persistence.core.guice.V2Impl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.usergrid.corepersistence.ManagerCache;
 import org.apache.usergrid.corepersistence.rx.AllEntitiesInSystemObservable;
 import org.apache.usergrid.corepersistence.rx.EdgesFromSourceObservable;
-import org.apache.usergrid.persistence.core.guice.CurrentImpl;
 import org.apache.usergrid.persistence.core.migration.data.DataMigration;
 import org.apache.usergrid.persistence.graph.Edge;
 import org.apache.usergrid.persistence.graph.GraphManager;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/Versions.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/Versions.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/Versions.java
index 99067b7..636ff53 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/Versions.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/Versions.java
@@ -22,7 +22,9 @@
 package org.apache.usergrid.corepersistence.migration;
 
 
-import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntitySerializationStrategyProxyImpl;
+import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntitySerializationStrategyProxy;
+import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntitySerializationStrategyProxyV1Impl;
+import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntitySerializationStrategyProxyV2Impl;
 import org.apache.usergrid.persistence.graph.serialization.impl.EdgeMetadataSerializationProxyImpl;
 
 
@@ -41,5 +43,8 @@ public class Versions {
      */
     public static final int VERSION_2 = EdgeMetadataSerializationProxyImpl.MIGRATION_VERSION;
 
-    public static final int VERSION_3 = MvccEntitySerializationStrategyProxyImpl.MIGRATION_VERSION;
+    public static final int VERSION_3 = MvccEntitySerializationStrategyProxyV1Impl.MIGRATION_VERSION;
+
+    public static final int VERSION_4 = MvccEntitySerializationStrategyProxyV2Impl.MIGRATION_VERSION;
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java
index 344bcd3..79b96a3 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java
@@ -68,7 +68,7 @@ public class CpEntityMapUtils {
         return fromMap( null, map, entityType, topLevel );
     }
 
-    public static Entity fromMap( 
+    public static Entity fromMap(
             Entity entity, Map<String, Object> map, String entityType, boolean topLevel ) {
 
         if ( entity == null ) {
@@ -89,7 +89,7 @@ public class CpEntityMapUtils {
 
             } else if ( value instanceof Boolean ) {
                 entity.setField( new BooleanField( fieldName, (Boolean)value, unique && topLevel ));
-                        
+
             } else if ( value instanceof Integer ) {
                 entity.setField( new IntegerField( fieldName, (Integer)value, unique && topLevel ));
 
@@ -98,13 +98,13 @@ public class CpEntityMapUtils {
 
 		    } else if ( value instanceof Float ) {
                 entity.setField( new FloatField( fieldName, (Float)value, unique && topLevel ));
-				
+
             } else if ( value instanceof Long ) {
                 entity.setField( new LongField( fieldName, (Long)value, unique && topLevel ));
 
             } else if ( value instanceof List) {
-                entity.setField( listToListField( fieldName, (List)value, entityType ));  
-            
+                entity.setField( listToListField( fieldName, (List)value, entityType ));
+
             } else if ( value instanceof UUID) {
                 entity.setField( new UUIDField( fieldName, (UUID)value, unique && topLevel ));
 
@@ -113,7 +113,7 @@ public class CpEntityMapUtils {
 
             } else if ( value instanceof Enum ) {
                 entity.setField( new StringField( fieldName, value.toString(), unique && topLevel ));
-	
+
 			} else if ( value != null ) {
                 byte[] valueSerialized;
                 try {
@@ -195,42 +195,42 @@ public class CpEntityMapUtils {
         }
     }
 
-    
+
     private static ListField listToListField( String fieldName, List list, String entityType ) {
 
         if (list.isEmpty()) {
-            return new ListField( fieldName );
+            return new ArrayField( fieldName );
         }
 
         Object sample = list.get(0);
 
         if ( sample instanceof Map ) {
-            return new ListField<Entity>( fieldName, processListForField( list, entityType ));
+            return new ArrayField<Entity>( fieldName, processListForField( list, entityType ));
 
         } else if ( sample instanceof List ) {
-            return new ListField<List>( fieldName, processListForField( list, entityType ));
-            
+            return new ArrayField<List>( fieldName, processListForField( list, entityType ));
+
         } else if ( sample instanceof String ) {
-            return new ListField<String>( fieldName, (List<String>)list );
-                    
+            return new ArrayField<String>( fieldName, (List<String>)list );
+
         } else if ( sample instanceof Boolean ) {
-            return new ListField<Boolean>( fieldName, (List<Boolean>)list );
-                    
+            return new ArrayField<Boolean>( fieldName, (List<Boolean>)list );
+
         } else if ( sample instanceof Integer ) {
-            return new ListField<Integer>( fieldName, (List<Integer>)list );
+            return new ArrayField<Integer>( fieldName, (List<Integer>)list );
 
         } else if ( sample instanceof Double ) {
-            return new ListField<Double>( fieldName, (List<Double>)list );
+            return new ArrayField<Double>( fieldName, (List<Double>)list );
 
         } else if ( sample instanceof Long ) {
-            return new ListField<Long>( fieldName, (List<Long>)list );
+            return new ArrayField<Long>( fieldName, (List<Long>)list );
 
         } else {
             throw new RuntimeException("Unknown type " + sample.getClass().getName());
         }
     }
 
-    
+
     private static List processListForField( List list, String entityType ) {
         if ( list.isEmpty() ) {
             return list;
@@ -246,10 +246,10 @@ public class CpEntityMapUtils {
 
         } else if ( sample instanceof List ) {
             return processListForField( list, entityType ); // recursion
-            
-        } else { 
+
+        } else {
             return list;
-        } 
+        }
     }
 
 
@@ -285,7 +285,7 @@ public class CpEntityMapUtils {
                 LocationField locField = (LocationField) f;
                 Map<String, Object> locMap = new HashMap<String, Object>();
 
-                // field names lat and lon trigger ElasticSearch geo location 
+                // field names lat and lon trigger ElasticSearch geo location
                 locMap.put("lat", locField.getValue().getLatitude());
                 locMap.put("lon", locField.getValue().getLongitude());
                 entityMap.put( field.getName(), field.getValue());
@@ -311,7 +311,7 @@ public class CpEntityMapUtils {
         return entityMap;
     }
 
-    
+
     private static Collection processCollectionForMap(Collection c) {
         if (c.isEmpty()) {
             return c;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java
index af8bbed..b677769 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityDataMigrationIT.java
@@ -24,6 +24,10 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
+import org.apache.usergrid.persistence.core.guice.CurrentImpl;
+import org.apache.usergrid.persistence.core.guice.PreviousImpl;
+import org.apache.usergrid.persistence.core.guice.V1Impl;
+import org.apache.usergrid.persistence.core.guice.V2Impl;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -41,8 +45,6 @@ import org.apache.usergrid.persistence.SimpleEntityRef;
 import org.apache.usergrid.persistence.collection.CollectionScope;
 import org.apache.usergrid.persistence.collection.MvccEntity;
 import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
-import org.apache.usergrid.persistence.core.guice.CurrentImpl;
-import org.apache.usergrid.persistence.core.guice.PreviousImpl;
 import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
 import org.apache.usergrid.persistence.core.migration.data.DataMigrationManagerImpl;
 import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
@@ -80,7 +82,7 @@ public class EntityDataMigrationIT extends AbstractCoreIT {
      * Rule to do the resets we need
      */
     @Rule
-    public MigrationTestRule migrationTestRule = 
+    public MigrationTestRule migrationTestRule =
             new MigrationTestRule( app, CpSetup.getInjector() ,EntityDataMigration.class  );
 
     @Before
@@ -218,7 +220,7 @@ public class EntityDataMigrationIT extends AbstractCoreIT {
         assertEquals( "All entities migrated", 0, savedEntities.size() );
 
 
-        //now visit all entities in the system again, and load them from the EM, 
+        //now visit all entities in the system again, and load them from the EM,
         // ensure we see everything we did in the v1 traversal
         AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000 )
             .doOnNext( new Action1<AllEntitiesInSystemObservable.ApplicationEntityGroup>() {
@@ -227,7 +229,7 @@ public class EntityDataMigrationIT extends AbstractCoreIT {
                         final AllEntitiesInSystemObservable
                                 .ApplicationEntityGroup entity ) {
 
-                    final EntityManager em = emf.getEntityManager( 
+                    final EntityManager em = emf.getEntityManager(
                             entity.applicationScope.getApplication().getUuid() );
 
                     //add all versions from history to our comparison

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxy.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxy.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxy.java
new file mode 100644
index 0000000..f52c16d
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxy.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence.collection.serialization.impl;
+
+import com.google.inject.Inject;
+import com.netflix.astyanax.Keyspace;
+import com.netflix.astyanax.MutationBatch;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.EntitySet;
+import org.apache.usergrid.persistence.collection.MvccEntity;
+import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamilyDefinition;
+import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.UUID;
+
+
+/**
+ * Version 4 implementation of entity serialization. This will proxy writes and reads so that during
+ * migration data goes to both sources and is read from the old source. After the ugprade completes,
+ * it will be available from the new source
+ */
+public abstract class MvccEntitySerializationStrategyProxy implements MvccEntitySerializationStrategy {
+
+
+    private final DataMigrationManager dataMigrationManager;
+    private final Keyspace keyspace;
+    private final MvccEntitySerializationStrategy previous;
+    private final MvccEntitySerializationStrategy current;
+
+
+    @Inject
+    public MvccEntitySerializationStrategyProxy( final DataMigrationManager dataMigrationManager,
+                                                       final Keyspace keyspace,
+                                                      final MvccEntitySerializationStrategy previous,
+                                                       final MvccEntitySerializationStrategy current) {
+        this.dataMigrationManager = dataMigrationManager;
+        this.keyspace = keyspace;
+        this.previous = previous;
+        this.current = current;
+    }
+
+
+    @Override
+    public MutationBatch write( final CollectionScope context, final MvccEntity entity ) {
+        if ( isOldVersion() ) {
+            final MutationBatch aggregateBatch = keyspace.prepareMutationBatch();
+
+            aggregateBatch.mergeShallow( previous.write( context, entity ) );
+            aggregateBatch.mergeShallow( current.write( context, entity ) );
+
+            return aggregateBatch;
+        }
+
+        return current.write( context, entity );
+    }
+
+
+    @Override
+    public EntitySet load( final CollectionScope scope, final Collection<Id> entityIds, final UUID maxVersion ) {
+        if ( isOldVersion() ) {
+            return previous.load( scope, entityIds, maxVersion );
+        }
+
+        return current.load( scope, entityIds, maxVersion );
+    }
+
+
+    @Override
+    public Iterator<MvccEntity> loadDescendingHistory( final CollectionScope context, final Id entityId,
+                                                       final UUID version, final int fetchSize ) {
+        if ( isOldVersion() ) {
+            return previous.loadDescendingHistory( context, entityId, version, fetchSize );
+        }
+
+        return current.loadDescendingHistory( context, entityId, version, fetchSize );
+    }
+
+
+    @Override
+    public Iterator<MvccEntity> loadAscendingHistory( final CollectionScope context, final Id entityId,
+                                                      final UUID version, final int fetchSize ) {
+        if ( isOldVersion() ) {
+            return previous.loadAscendingHistory( context, entityId, version, fetchSize );
+        }
+
+        return current.loadAscendingHistory( context, entityId, version, fetchSize );
+    }
+
+
+    @Override
+    public MutationBatch mark( final CollectionScope context, final Id entityId, final UUID version ) {
+        if ( isOldVersion() ) {
+            final MutationBatch aggregateBatch = keyspace.prepareMutationBatch();
+
+            aggregateBatch.mergeShallow( previous.mark( context, entityId, version ) );
+            aggregateBatch.mergeShallow( current.mark( context, entityId, version ) );
+
+            return aggregateBatch;
+        }
+
+        return current.mark( context, entityId, version );
+    }
+
+
+    @Override
+    public MutationBatch delete( final CollectionScope context, final Id entityId, final UUID version ) {
+        if ( isOldVersion() ) {
+            final MutationBatch aggregateBatch = keyspace.prepareMutationBatch();
+
+            aggregateBatch.mergeShallow( previous.delete( context, entityId, version ) );
+            aggregateBatch.mergeShallow( current.delete( context, entityId, version ) );
+
+            return aggregateBatch;
+        }
+
+        return current.delete( context, entityId, version );
+    }
+
+    public abstract int getMigrationVersion();
+
+    /**
+     * Return true if we're on an old version
+     */
+    private boolean isOldVersion() {
+        return dataMigrationManager.getCurrentVersion() < getMigrationVersion();
+    }
+
+
+    @Override
+    public Collection<MultiTennantColumnFamilyDefinition> getColumnFamilies() {
+        return Collections.emptyList();
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyImpl.java
deleted file mode 100644
index cf17812..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyImpl.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.usergrid.persistence.collection.serialization.impl;
-
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.UUID;
-
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.EntitySet;
-import org.apache.usergrid.persistence.collection.MvccEntity;
-import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
-import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamilyDefinition;
-import org.apache.usergrid.persistence.core.guice.CurrentImpl;
-import org.apache.usergrid.persistence.core.guice.PreviousImpl;
-import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
-import org.apache.usergrid.persistence.model.entity.Id;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.netflix.astyanax.Keyspace;
-import com.netflix.astyanax.MutationBatch;
-
-
-/**
- * Version 3 implementation of entity serialization. This will proxy writes and reads so that during
- * migration data goes to both sources and is read from the old source. After the ugprade completes,
- * it will be available from the new source
- */
-@Singleton
-public class MvccEntitySerializationStrategyProxyImpl implements MvccEntitySerializationStrategy {
-
-
-    public static final int MIGRATION_VERSION = 3;
-
-    private final DataMigrationManager dataMigrationManager;
-    private final Keyspace keyspace;
-    private final MvccEntitySerializationStrategy previous;
-    private final MvccEntitySerializationStrategy current;
-
-
-    @Inject
-    public MvccEntitySerializationStrategyProxyImpl( final DataMigrationManager dataMigrationManager,
-                                                     final Keyspace keyspace,
-                                                     @PreviousImpl final MvccEntitySerializationStrategy previous,
-                                                     @CurrentImpl final MvccEntitySerializationStrategy current ) {
-        this.dataMigrationManager = dataMigrationManager;
-        this.keyspace = keyspace;
-        this.previous = previous;
-        this.current = current;
-    }
-
-
-    @Override
-    public MutationBatch write( final CollectionScope context, final MvccEntity entity ) {
-        if ( isOldVersion() ) {
-            final MutationBatch aggregateBatch = keyspace.prepareMutationBatch();
-
-            aggregateBatch.mergeShallow( previous.write( context, entity ) );
-            aggregateBatch.mergeShallow( current.write( context, entity ) );
-
-            return aggregateBatch;
-        }
-
-        return current.write( context, entity );
-    }
-
-
-    @Override
-    public EntitySet load( final CollectionScope scope, final Collection<Id> entityIds, final UUID maxVersion ) {
-        if ( isOldVersion() ) {
-            return previous.load( scope, entityIds, maxVersion );
-        }
-
-        return current.load( scope, entityIds, maxVersion );
-    }
-
-
-    @Override
-    public Iterator<MvccEntity> loadDescendingHistory( final CollectionScope context, final Id entityId,
-                                                       final UUID version, final int fetchSize ) {
-        if ( isOldVersion() ) {
-            return previous.loadDescendingHistory( context, entityId, version, fetchSize );
-        }
-
-        return current.loadDescendingHistory( context, entityId, version, fetchSize );
-    }
-
-
-    @Override
-    public Iterator<MvccEntity> loadAscendingHistory( final CollectionScope context, final Id entityId,
-                                                      final UUID version, final int fetchSize ) {
-        if ( isOldVersion() ) {
-            return previous.loadAscendingHistory( context, entityId, version, fetchSize );
-        }
-
-        return current.loadAscendingHistory( context, entityId, version, fetchSize );
-    }
-
-
-    @Override
-    public MutationBatch mark( final CollectionScope context, final Id entityId, final UUID version ) {
-        if ( isOldVersion() ) {
-            final MutationBatch aggregateBatch = keyspace.prepareMutationBatch();
-
-            aggregateBatch.mergeShallow( previous.mark( context, entityId, version ) );
-            aggregateBatch.mergeShallow( current.mark( context, entityId, version ) );
-
-            return aggregateBatch;
-        }
-
-        return current.mark( context, entityId, version );
-    }
-
-
-    @Override
-    public MutationBatch delete( final CollectionScope context, final Id entityId, final UUID version ) {
-        if ( isOldVersion() ) {
-            final MutationBatch aggregateBatch = keyspace.prepareMutationBatch();
-
-            aggregateBatch.mergeShallow( previous.delete( context, entityId, version ) );
-            aggregateBatch.mergeShallow( current.delete( context, entityId, version ) );
-
-            return aggregateBatch;
-        }
-
-        return current.delete( context, entityId, version );
-    }
-
-
-    /**
-     * Return true if we're on an old version
-     */
-    private boolean isOldVersion() {
-        return dataMigrationManager.getCurrentVersion() < MIGRATION_VERSION;
-    }
-
-
-    @Override
-    public Collection<MultiTennantColumnFamilyDefinition> getColumnFamilies() {
-        return Collections.emptyList();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1Impl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1Impl.java
new file mode 100644
index 0000000..defb966
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1Impl.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.usergrid.persistence.collection.serialization.impl;
+
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.UUID;
+
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.EntitySet;
+import org.apache.usergrid.persistence.collection.MvccEntity;
+import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamilyDefinition;
+import org.apache.usergrid.persistence.core.guice.V1Impl;
+import org.apache.usergrid.persistence.core.guice.V2Impl;
+import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.netflix.astyanax.Keyspace;
+import com.netflix.astyanax.MutationBatch;
+
+
+/**
+ * Version 3 implementation of entity serialization. This will proxy writes and reads so that during
+ * migration data goes to both sources and is read from the old source. After the ugprade completes,
+ * it will be available from the new source
+ */
+@Singleton
+public class MvccEntitySerializationStrategyProxyV1Impl extends MvccEntitySerializationStrategyProxy {
+
+    public static final int MIGRATION_VERSION = 3;
+
+    @Inject
+    public MvccEntitySerializationStrategyProxyV1Impl(final DataMigrationManager dataMigrationManager,
+                                                      final Keyspace keyspace,
+                                                      @V1Impl final MvccEntitySerializationStrategy previous,
+                                                      @V2Impl final MvccEntitySerializationStrategy current) {
+        super(dataMigrationManager, keyspace, previous, current);
+    }
+
+    @Override
+    public int getMigrationVersion() {
+        return MIGRATION_VERSION;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2Impl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2Impl.java
new file mode 100644
index 0000000..eec9188
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2Impl.java
@@ -0,0 +1,44 @@
+package org.apache.usergrid.persistence.collection.serialization.impl;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.netflix.astyanax.Keyspace;
+import com.netflix.astyanax.MutationBatch;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.EntitySet;
+import org.apache.usergrid.persistence.collection.MvccEntity;
+import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamilyDefinition;
+import org.apache.usergrid.persistence.core.guice.*;
+import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.UUID;
+
+/**
+ * Version 4 implementation of entity serialization. This will proxy writes and reads so that during
+ * migration data goes to both sources and is read from the old source. After the ugprade completes,
+ * it will be available from the new source
+ */
+@Singleton
+public class MvccEntitySerializationStrategyProxyV2Impl extends MvccEntitySerializationStrategyProxy {
+
+    public static final int MIGRATION_VERSION = 4;
+
+    @Inject
+    public MvccEntitySerializationStrategyProxyV2Impl( final DataMigrationManager dataMigrationManager,
+                                                     final Keyspace keyspace,
+                                                     @V1ProxyImpl final MvccEntitySerializationStrategy previous,
+                                                     @V3Impl final MvccEntitySerializationStrategy current) {
+        super(dataMigrationManager,keyspace,previous,current);
+    }
+
+    @Override
+    public int getMigrationVersion() {
+        return MIGRATION_VERSION;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java
new file mode 100644
index 0000000..ce8dbef
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java
@@ -0,0 +1,212 @@
+package org.apache.usergrid.persistence.collection.serialization.impl;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.smile.SmileFactory;
+import com.google.common.base.Optional;
+import com.google.inject.Inject;
+import com.netflix.astyanax.Keyspace;
+import com.netflix.astyanax.MutationBatch;
+import com.netflix.astyanax.serializers.AbstractSerializer;
+import com.netflix.astyanax.serializers.UUIDSerializer;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.EntitySet;
+import org.apache.usergrid.persistence.collection.MvccEntity;
+import org.apache.usergrid.persistence.collection.exception.DataCorruptionException;
+import org.apache.usergrid.persistence.collection.exception.EntityTooLargeException;
+import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
+import org.apache.usergrid.persistence.core.astyanax.*;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.entity.EntityMap;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.field.value.EntityObject;
+
+import java.nio.ByteBuffer;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.UUID;
+
+/**
+ * Classy class class.
+ */
+public class MvccEntitySerializationStrategyV3Impl extends MvccEntitySerializationStrategyImpl {
+    private static final IdRowCompositeSerializer ID_SER = IdRowCompositeSerializer.get();
+
+
+    private static final CollectionScopedRowKeySerializer<Id> ROW_KEY_SER =
+            new CollectionScopedRowKeySerializer<>(ID_SER);
+
+
+    private static final MultiTennantColumnFamily<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> CF_ENTITY_DATA =
+            new MultiTennantColumnFamily<>("Entity_Version_Data_V2", ROW_KEY_SER, UUIDSerializer.get());
+
+    private static final FieldBufferSerializer FIELD_BUFFER_SERIALIZER = FieldBufferSerializer.get();
+
+
+    private final EntitySerializer entitySerializer;
+
+
+    @Inject
+    public MvccEntitySerializationStrategyV3Impl(final Keyspace keyspace, final SerializationFig serializationFig, final CassandraFig cassandraFig) {
+        super(keyspace, serializationFig, cassandraFig);
+        entitySerializer = new EntitySerializer(serializationFig);
+    }
+
+
+    @Override
+    protected AbstractSerializer<MvccEntitySerializationStrategyImpl.EntityWrapper> getEntitySerializer() {
+        return entitySerializer;
+    }
+
+
+    @Override
+    protected MultiTennantColumnFamily<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> getColumnFamily() {
+        return CF_ENTITY_DATA;
+    }
+
+
+    /**
+     * We should only ever create this once, since this impl is a singleton
+     */
+    public final class EntitySerializer extends AbstractSerializer<MvccEntitySerializationStrategyImpl.EntityWrapper> {
+
+
+        private final SmileFactory SMILE_FACTORY = new SmileFactory();
+
+        private final ObjectMapper MAPPER = new ObjectMapper(SMILE_FACTORY);
+
+
+        private SerializationFig serializationFig;
+
+
+        private byte STATE_COMPLETE = 0;
+        private byte STATE_DELETED = 1;
+        private byte STATE_PARTIAL = 2;
+
+        private byte VERSION = 1;
+
+
+        public EntitySerializer(final SerializationFig serializationFig) {
+            this.serializationFig = serializationFig;
+
+            //                mapper.enable(SerializationFeature.INDENT_OUTPUT); don't indent output,
+            // causes slowness
+            MAPPER.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT, "@class");
+        }
+
+
+        @Override
+        public ByteBuffer toByteBuffer(final MvccEntitySerializationStrategyImpl.EntityWrapper wrapper) {
+            if (wrapper == null) {
+                return null;
+            }
+
+            //we always have a max of 3 fields
+            FieldBufferBuilder builder = new FieldBufferBuilder(3);
+
+            builder.addByte(VERSION);
+
+            //mark this version as empty
+            if (!wrapper.entity.isPresent()) {
+                //we're empty
+                builder.addByte(STATE_DELETED);
+
+
+                return FIELD_BUFFER_SERIALIZER.toByteBuffer(builder.build());
+            }
+
+            //we have an entity
+
+            if (wrapper.status == MvccEntity.Status.COMPLETE) {
+                builder.addByte(STATE_COMPLETE);
+            } else {
+                builder.addByte(STATE_PARTIAL);
+            }
+
+
+            //Get Entity
+            final Entity entity = wrapper.entity.get();
+            //Convert to internal entity map
+            final EntityMap entityMap = new EntityMap(entity);
+            final byte[] entityBytes;
+            try {
+                entityBytes = MAPPER.writeValueAsBytes(entityMap);
+            } catch (Exception e) {
+                throw new RuntimeException("Unable to serialize entity", e);
+            }
+
+
+            final int maxEntrySize = serializationFig.getMaxEntitySize();
+
+            if (entityBytes.length > maxEntrySize) {
+                throw new EntityTooLargeException(entity, maxEntrySize, entityBytes.length,
+                        "Your entity cannot exceed " + maxEntrySize + " bytes. The entity you tried to save was "
+                                + entityBytes.length + " bytes");
+            }
+
+            builder.addBytes(entityBytes);
+
+            return FIELD_BUFFER_SERIALIZER.toByteBuffer(builder.build());
+        }
+
+
+        @Override
+        public MvccEntitySerializationStrategyImpl.EntityWrapper fromByteBuffer(final ByteBuffer byteBuffer) {
+
+            /**
+             * We intentionally turn data corruption exceptions when we're unable to de-serialize
+             * the data in cassandra.  If this occurs, we'll never be able to de-serialize it
+             * and it should be considered lost.  This is an error that is occurring due to a bug
+             * in serializing the entity.  This is a lazy recognition + repair signal for deployment with
+             * existing systems.
+             */
+
+            final FieldBuffer fieldBuffer;
+
+            try {
+                fieldBuffer = FIELD_BUFFER_SERIALIZER.fromByteBuffer(byteBuffer);
+            } catch (Exception e) {
+                throw new DataCorruptionException("Unable to de-serialze entity", e);
+            }
+
+            FieldBufferParser parser = new FieldBufferParser(fieldBuffer);
+
+
+            byte version = parser.readByte();
+
+            if (VERSION != version) {
+                throw new UnsupportedOperationException("A version of type " + version + " is unsupported");
+            }
+
+            byte state = parser.readByte();
+
+            // it's been deleted, remove it
+
+            if (STATE_DELETED == state) {
+                return new MvccEntitySerializationStrategyImpl.EntityWrapper(MvccEntity.Status.COMPLETE, Optional.<Entity>absent());
+            }
+
+            EntityMap storedEntity;
+
+            byte[] array = parser.readBytes();
+
+            try {
+                storedEntity = MAPPER.readValue(array, EntityMap.class);
+            } catch (Exception e) {
+                throw new DataCorruptionException("Unable to read entity data", e);
+            }
+
+            Entity entityObject = new Entity(storedEntity);
+
+            final Optional<Entity> entity = Optional.of(entityObject);
+
+            if (STATE_COMPLETE == state) {
+                return new MvccEntitySerializationStrategyImpl.EntityWrapper(MvccEntity.Status.COMPLETE, entity);
+            }
+
+            // it's partial by default
+            return new MvccEntitySerializationStrategyImpl.EntityWrapper(MvccEntity.Status.PARTIAL, entity);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
index 33a092d..1f5e65d 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
@@ -21,9 +21,7 @@ package org.apache.usergrid.persistence.collection.serialization.impl;
 import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
 import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
 import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
-import org.apache.usergrid.persistence.core.guice.CurrentImpl;
-import org.apache.usergrid.persistence.core.guice.PreviousImpl;
-import org.apache.usergrid.persistence.core.guice.ProxyImpl;
+import org.apache.usergrid.persistence.core.guice.*;
 import org.apache.usergrid.persistence.core.migration.schema.Migration;
 
 import com.google.inject.AbstractModule;
@@ -43,20 +41,29 @@ public class SerializationModule extends AbstractModule {
         // bind the serialization strategies
 
         //We've migrated this one, so we need to set up the previous, current, and proxy
-        bind( MvccEntitySerializationStrategy.class ).annotatedWith( PreviousImpl.class )
+        bind( MvccEntitySerializationStrategy.class ).annotatedWith( V1Impl.class )
                                                      .to( MvccEntitySerializationStrategyV1Impl.class );
+        bind( MvccEntitySerializationStrategy.class ).annotatedWith( V2Impl.class )
+                                                     .to(MvccEntitySerializationStrategyV2Impl.class);
+        bind( MvccEntitySerializationStrategy.class ).annotatedWith( V3Impl.class )
+                                                    .to(MvccEntitySerializationStrategyV3Impl.class);
+        bind( MvccEntitySerializationStrategy.class ).annotatedWith( PreviousImpl.class )
+            .to(MvccEntitySerializationStrategyProxyV2Impl.class);
         bind( MvccEntitySerializationStrategy.class ).annotatedWith( CurrentImpl.class )
-                                                     .to( MvccEntitySerializationStrategyV2Impl.class );
-        bind( MvccEntitySerializationStrategy.class ).annotatedWith( ProxyImpl.class )
-                                                     .to( MvccEntitySerializationStrategyProxyImpl.class );
+            .to(MvccEntitySerializationStrategyV3Impl.class);
+        bind(MvccEntitySerializationStrategy.class).annotatedWith( V1ProxyImpl.class )
+                                                     .to( MvccEntitySerializationStrategyProxyV1Impl.class );
 
+        bind( MvccEntitySerializationStrategy.class ).annotatedWith( ProxyImpl.class )
+                .to( MvccEntitySerializationStrategyProxyV2Impl.class );
         bind( MvccLogEntrySerializationStrategy.class ).to( MvccLogEntrySerializationStrategyImpl.class );
         bind( UniqueValueSerializationStrategy.class ).to( UniqueValueSerializationStrategyImpl.class );
 
         //do multibindings for migrations
         Multibinder<Migration> uriBinder = Multibinder.newSetBinder( binder(), Migration.class );
-        uriBinder.addBinding().to( Key.get( MvccEntitySerializationStrategy.class, PreviousImpl.class ) );
-        uriBinder.addBinding().to( Key.get( MvccEntitySerializationStrategy.class, CurrentImpl.class ) );
+        uriBinder.addBinding().to( Key.get( MvccEntitySerializationStrategy.class, V1Impl.class ) );
+        uriBinder.addBinding().to( Key.get( MvccEntitySerializationStrategy.class, V2Impl.class ) );
+        uriBinder.addBinding().to( Key.get( MvccEntitySerializationStrategy.class, V3Impl.class ) );
         uriBinder.addBinding().to( Key.get( MvccLogEntrySerializationStrategy.class ) );
         uriBinder.addBinding().to( Key.get( UniqueValueSerializationStrategy.class ) );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1Test.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1Test.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1Test.java
deleted file mode 100644
index a936d2a..0000000
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1Test.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.usergrid.persistence.collection.serialization.impl;
-
-
-import java.util.Iterator;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-
-import org.apache.usergrid.persistence.collection.MvccEntity;
-import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
-import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
-import org.apache.usergrid.persistence.core.guice.PreviousImpl;
-import org.apache.usergrid.persistence.core.guice.ProxyImpl;
-import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
-import org.apache.usergrid.persistence.core.test.ITRunner;
-import org.apache.usergrid.persistence.core.test.UseModules;
-
-import com.google.inject.Inject;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-
-@RunWith( ITRunner.class )
-@UseModules( TestCollectionModule.class )
-public class MvccEntitySerializationStrategyProxyV1Test extends MvccEntitySerializationStrategyImplTest {
-
-    @Inject
-    @ProxyImpl
-    private MvccEntitySerializationStrategy serializationStrategy;
-
-    @Override
-    protected MvccEntitySerializationStrategy getMvccEntitySerializationStrategy() {
-        return serializationStrategy;
-    }
-
-  @Inject
-    protected MigrationInfoSerialization migrationInfoSerialization;
-
-    private int existingVersion;
-
-
-    /**
-     * We need to run our migration to ensure that we are on the current version, and everything still functions
-     * correctly
-     */
-    @Before
-    public void setMigrationVersion() {
-        existingVersion = migrationInfoSerialization.getVersion();
-
-        //set our version to 0 so it uses both impls of the proxy
-        migrationInfoSerialization.setVersion( MvccEntitySerializationStrategyProxyImpl.MIGRATION_VERSION-1 );
-    }
-
-
-
-
-    @After
-    public void reSetMigrationVersion() {
-        migrationInfoSerialization.setVersion( existingVersion );
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1_2Test.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1_2Test.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1_2Test.java
new file mode 100644
index 0000000..9563258
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1_2Test.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.usergrid.persistence.collection.serialization.impl;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+
+import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
+import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.core.guice.ProxyImpl;
+import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
+import org.apache.usergrid.persistence.core.test.ITRunner;
+import org.apache.usergrid.persistence.core.test.UseModules;
+
+import com.google.inject.Inject;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+
+@RunWith( ITRunner.class )
+@UseModules( TestCollectionModule.class )
+public class MvccEntitySerializationStrategyProxyV1_2Test extends MvccEntitySerializationStrategyImplTest {
+
+    @Inject
+    @ProxyImpl
+    private MvccEntitySerializationStrategy serializationStrategy;
+
+    @Override
+    protected MvccEntitySerializationStrategy getMvccEntitySerializationStrategy() {
+        return serializationStrategy;
+    }
+
+  @Inject
+    protected MigrationInfoSerialization migrationInfoSerialization;
+
+    private int existingVersion;
+
+
+    /**
+     * We need to run our migration to ensure that we are on the current version, and everything still functions
+     * correctly
+     */
+    @Before
+    public void setMigrationVersion() {
+        existingVersion = migrationInfoSerialization.getVersion();
+
+        //set our version to 0 so it uses both impls of the proxy
+        migrationInfoSerialization.setVersion( MvccEntitySerializationStrategyProxyV1Impl.MIGRATION_VERSION-1 );
+    }
+
+
+
+
+    @After
+    public void reSetMigrationVersion() {
+        migrationInfoSerialization.setVersion( existingVersion );
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1_3Test.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1_3Test.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1_3Test.java
new file mode 100644
index 0000000..67041f3
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1_3Test.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.usergrid.persistence.collection.serialization.impl;
+
+
+import org.apache.usergrid.persistence.core.guice.V1ProxyImpl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+
+import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
+import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.core.guice.ProxyImpl;
+import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
+import org.apache.usergrid.persistence.core.test.ITRunner;
+import org.apache.usergrid.persistence.core.test.UseModules;
+
+import com.google.inject.Inject;
+
+import static org.junit.Assert.assertTrue;
+
+
+@RunWith( ITRunner.class )
+@UseModules( TestCollectionModule.class )
+public class MvccEntitySerializationStrategyProxyV1_3Test extends MvccEntitySerializationStrategyV2Test {
+
+    @Inject
+    @V1ProxyImpl
+    private MvccEntitySerializationStrategy serializationStrategy;
+
+
+    @Override
+    protected MvccEntitySerializationStrategy getMvccEntitySerializationStrategy() {
+        return serializationStrategy;
+    }
+
+
+    @Inject
+    protected MigrationInfoSerialization migrationInfoSerialization;
+
+    private int existingVersion;
+
+
+    /**
+     * We need to run our migration to ensure that we are on the current version, and everything still functions
+     * correctly
+     */
+    @Before
+    public void setMigrationVersion() {
+        existingVersion = migrationInfoSerialization.getVersion();
+
+        //set our new version, so that is will run through the new code
+        migrationInfoSerialization.setVersion( MvccEntitySerializationStrategyProxyV1Impl.MIGRATION_VERSION );
+    }
+
+
+
+
+    @After
+    public void reSetMigrationVersion() {
+        migrationInfoSerialization.setVersion( existingVersion );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2Test.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2Test.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2Test.java
index 1709cc1..2e037a2 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2Test.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2Test.java
@@ -1,48 +1,41 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
-
 package org.apache.usergrid.persistence.collection.serialization.impl;
 
-
-import java.util.Iterator;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-
-import org.apache.usergrid.persistence.collection.MvccEntity;
+import com.google.inject.Inject;
 import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
 import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
-import org.apache.usergrid.persistence.collection.util.EntityHelper;
 import org.apache.usergrid.persistence.core.guice.ProxyImpl;
+import org.apache.usergrid.persistence.core.guice.V1ProxyImpl;
 import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
 import org.apache.usergrid.persistence.core.test.ITRunner;
 import org.apache.usergrid.persistence.core.test.UseModules;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
 
-import com.google.inject.Inject;
-
-import static org.junit.Assert.assertTrue;
+/**
+ * Tests migration from 2 -> 3
+ */
 
 
 @RunWith( ITRunner.class )
 @UseModules( TestCollectionModule.class )
-public class MvccEntitySerializationStrategyProxyV2Test extends MvccEntitySerializationStrategyV2Test {
+public class MvccEntitySerializationStrategyProxyV2Test extends MvccEntitySerializationStrategyV3Test {
 
     @Inject
     @ProxyImpl
@@ -70,7 +63,7 @@ public class MvccEntitySerializationStrategyProxyV2Test extends MvccEntitySerial
         existingVersion = migrationInfoSerialization.getVersion();
 
         //set our new version, so that is will run through the new code
-        migrationInfoSerialization.setVersion( MvccEntitySerializationStrategyProxyImpl.MIGRATION_VERSION );
+        migrationInfoSerialization.setVersion( MvccEntitySerializationStrategyProxyV2Impl.MIGRATION_VERSION );
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV1ImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV1ImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV1ImplTest.java
index e59426d..c6f953e 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV1ImplTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV1ImplTest.java
@@ -27,7 +27,7 @@ import org.junit.runner.RunWith;
 import org.apache.usergrid.persistence.collection.MvccEntity;
 import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
 import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
-import org.apache.usergrid.persistence.core.guice.PreviousImpl;
+import org.apache.usergrid.persistence.core.guice.V1Impl;
 import org.apache.usergrid.persistence.core.test.ITRunner;
 import org.apache.usergrid.persistence.core.test.UseModules;
 
@@ -43,7 +43,7 @@ import static org.junit.Assert.assertTrue;
 public class MvccEntitySerializationStrategyV1ImplTest extends MvccEntitySerializationStrategyImplTest {
 
     @Inject
-    @PreviousImpl
+    @V1Impl
     private MvccEntitySerializationStrategy serializationStrategy;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2ImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2ImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2ImplTest.java
index c931904..39559af 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2ImplTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV2ImplTest.java
@@ -28,7 +28,7 @@ import org.apache.usergrid.persistence.collection.MvccEntity;
 import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
 import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
 import org.apache.usergrid.persistence.collection.util.EntityHelper;
-import org.apache.usergrid.persistence.core.guice.CurrentImpl;
+import org.apache.usergrid.persistence.core.guice.V2Impl;
 import org.apache.usergrid.persistence.core.test.ITRunner;
 import org.apache.usergrid.persistence.core.test.UseModules;
 
@@ -42,7 +42,7 @@ import static org.junit.Assert.assertTrue;
 public class MvccEntitySerializationStrategyV2ImplTest extends MvccEntitySerializationStrategyV2Test {
 
     @Inject
-    @CurrentImpl
+    @V2Impl
     private MvccEntitySerializationStrategy serializationStrategy;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3ImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3ImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3ImplTest.java
new file mode 100644
index 0000000..f5c27bc
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3ImplTest.java
@@ -0,0 +1,32 @@
+package org.apache.usergrid.persistence.collection.serialization.impl;
+
+import com.google.inject.Inject;
+import com.netflix.astyanax.Keyspace;
+import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
+import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
+import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
+import org.apache.usergrid.persistence.core.guice.V3Impl;
+import org.apache.usergrid.persistence.core.test.ITRunner;
+import org.apache.usergrid.persistence.core.test.UseModules;
+import org.junit.runner.RunWith;
+
+/**
+ * Classy class class.
+ */
+
+
+@RunWith( ITRunner.class )
+@UseModules( TestCollectionModule.class )
+public class MvccEntitySerializationStrategyV3ImplTest extends MvccEntitySerializationStrategyV3Test {
+    @Inject
+    @V3Impl
+    private MvccEntitySerializationStrategy serializationStrategy;
+
+
+    @Override
+    protected MvccEntitySerializationStrategy getMvccEntitySerializationStrategy() {
+        return serializationStrategy;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Test.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Test.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Test.java
new file mode 100644
index 0000000..795ff9a
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Test.java
@@ -0,0 +1,108 @@
+package org.apache.usergrid.persistence.collection.serialization.impl;
+
+import com.google.inject.Inject;
+import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.MvccEntity;
+import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
+import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
+import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
+import org.apache.usergrid.persistence.collection.util.EntityHelper;
+import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
+import org.apache.usergrid.persistence.core.guicyfig.SetConfigTestBypass;
+import org.apache.usergrid.persistence.core.util.ValidationUtils;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.UUID;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Classy class class.
+ */
+public abstract class MvccEntitySerializationStrategyV3Test extends MvccEntitySerializationStrategyImplTest{
+    @Inject
+    protected SerializationFig serializationFig;
+
+    @Inject
+    protected CassandraFig cassandraFig;
+
+    private int setMaxEntitySize;
+
+    @Before
+    public void setUp() {
+        setMaxEntitySize = serializationFig.getMaxEntitySize();
+    }
+
+
+    @After
+    public void tearDown() {
+        SetConfigTestBypass.setValueByPass(serializationFig, "getMaxEntitySize", setMaxEntitySize + "");
+    }
+
+    /**
+     * Tests an entity with more than  65535 bytes worth of data is successfully stored and retrieved
+     */
+    @Test
+    public void largeEntityWriteRead() throws ConnectionException {
+        final int setSize = 65535 * 2;
+
+
+        //this is the size it works out to be when serialized, we want to allow this size
+
+        SetConfigTestBypass.setValueByPass( serializationFig, "getMaxEntitySize", 65535 * 10 + "" );
+        final Entity entity = EntityHelper.generateEntity(setSize);
+
+        //now we have one massive, entity, save it and retrieve it.
+        CollectionScope context =
+                new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "parent" ), "tests" );
+
+
+        final Id id = entity.getId();
+        ValidationUtils.verifyIdentity(id);
+        final UUID version = UUIDGenerator.newTimeUUID();
+        final MvccEntity.Status status = MvccEntity.Status.COMPLETE;
+
+        final MvccEntity mvccEntity = new MvccEntityImpl( id, version, status, entity );
+
+
+        getMvccEntitySerializationStrategy().write( context, mvccEntity ).execute();
+
+        //now load it
+        final Iterator<MvccEntity> loaded =
+                getMvccEntitySerializationStrategy().loadDescendingHistory( context, id, version, 100 );
+
+
+        assertTrue( loaded.hasNext() );
+
+        final MvccEntity loadedEntity = loaded.next();
+
+        assertLargeEntity( mvccEntity, loadedEntity );
+
+
+        MvccEntity returned =
+                serializationStrategy.load( context, Collections.singleton(id), version ).getEntity( id );
+
+        assertLargeEntity( mvccEntity, returned );
+    }
+
+
+
+    protected void assertLargeEntity( final MvccEntity expected, final MvccEntity returned ) {
+
+        org.junit.Assert.assertEquals( "The loaded entity should match the stored entity", expected, returned );
+
+        EntityHelper.verifyDeepEquals( expected.getEntity().get(), returned.getEntity().get() );
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/CurrentImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/CurrentImpl.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/CurrentImpl.java
index a071edf..cb52892 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/CurrentImpl.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/CurrentImpl.java
@@ -1,42 +1,35 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
-
 package org.apache.usergrid.persistence.core.guice;
 
+import com.google.inject.BindingAnnotation;
 
 import java.lang.annotation.Retention;
 import java.lang.annotation.Target;
 
-import com.google.inject.BindingAnnotation;
-
 import static java.lang.annotation.ElementType.FIELD;
 import static java.lang.annotation.ElementType.METHOD;
 import static java.lang.annotation.ElementType.PARAMETER;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
-
 /**
- * Represents 2 versions of an impl.  Generally used for online migration.  This represents the version that is the
- * current version of the implementation.  I.E the "new" version.
+ * Classy class class.
  */
 @BindingAnnotation
 @Target({ FIELD, PARAMETER, METHOD }) @Retention(RUNTIME)
-public @interface CurrentImpl {}
+public @interface CurrentImpl {
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/PreviousImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/PreviousImpl.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/PreviousImpl.java
index 9d5e359..526eb3b 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/PreviousImpl.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/PreviousImpl.java
@@ -1,42 +1,35 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
-
 package org.apache.usergrid.persistence.core.guice;
 
+import com.google.inject.BindingAnnotation;
+
 import java.lang.annotation.Retention;
 import java.lang.annotation.Target;
 
-import com.google.inject.BindingAnnotation;
-
 import static java.lang.annotation.ElementType.FIELD;
 import static java.lang.annotation.ElementType.METHOD;
 import static java.lang.annotation.ElementType.PARAMETER;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
-
-
 /**
- * Represents 2 versions of an impl.  Generally used for online migration.  This represents the version that is the
- * previous version of the implementation.  I.E the "old" version.
+ * Classy class class.
  */
 @BindingAnnotation
 @Target({ FIELD, PARAMETER, METHOD }) @Retention(RUNTIME)
-public @interface PreviousImpl {}
+public @interface  PreviousImpl {
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/V1Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/V1Impl.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/V1Impl.java
new file mode 100644
index 0000000..4fba781
--- /dev/null
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/V1Impl.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.usergrid.persistence.core.guice;
+
+import com.google.inject.BindingAnnotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Represents 2 versions of an impl.  Generally used for online migration.  This represents the version that is the
+ * current version of the implementation.  I.E the "new" version.
+ */
+@BindingAnnotation
+@Target({ FIELD, PARAMETER, METHOD }) @Retention(RUNTIME)
+public @interface V1Impl {}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/V1ProxyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/V1ProxyImpl.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/V1ProxyImpl.java
new file mode 100644
index 0000000..d783f0a
--- /dev/null
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/V1ProxyImpl.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence.core.guice;
+
+import com.google.inject.BindingAnnotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Classy class class.
+ */
+@BindingAnnotation
+@Target({ FIELD, PARAMETER, METHOD }) @Retention(RUNTIME)
+public @interface  V1ProxyImpl {
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6749ae2f/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/V2Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/V2Impl.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/V2Impl.java
new file mode 100644
index 0000000..dd01ff5
--- /dev/null
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/V2Impl.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.usergrid.persistence.core.guice;
+
+import com.google.inject.BindingAnnotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Represents 2 versions of an impl.  Generally used for online migration.  This represents the version that is the
+ * current version of the implementation.  I.E the "new" version.
+ */
+@BindingAnnotation
+@Target({ FIELD, PARAMETER, METHOD }) @Retention(RUNTIME)
+public @interface V2Impl {}
\ No newline at end of file