You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2015/02/20 03:49:27 UTC

[3/4] incubator-usergrid git commit: Removed unused synchronous interface

Removed unused synchronous interface

Removed entity repair, no longe relevant

Unique value serialization needs re-work.


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

Branch: refs/heads/USERGRID-365
Commit: 067e78e303cd35c2c0062221f58fa130ae079455
Parents: d2371f9
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Feb 19 15:35:32 2015 -0800
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Feb 19 15:35:32 2015 -0800

----------------------------------------------------------------------
 .../EntityCollectionManagerFactory.java         |   17 -
 .../collection/EntityCollectionManagerSync.java |   49 -
 .../collection/event/EntityVersionDeleted.java  |    3 +-
 .../collection/guice/CollectionModule.java      |   15 +-
 .../EntityCollectionManagerFactoryImpl.java     |   45 +-
 .../impl/EntityCollectionManagerSyncImpl.java   |   71 -
 .../impl/EntityVersionCleanupTask.java          |  135 +-
 .../collection/serialization/EntityRepair.java  |   38 -
 .../serialization/OptimisticUpdate.java         |   23 -
 .../serialization/impl/EntityRepairImpl.java    |  149 --
 .../impl/EntityVersionSerializer.java           |    2 -
 .../MvccEntitySerializationStrategyImpl.java    |   20 +-
 ...vccEntitySerializationStrategyProxyImpl.java |   15 +-
 .../MvccEntitySerializationStrategyV3Impl.java  |    9 +-
 .../impl/EntityVersionCleanupTaskTest.java      | 1445 +++++++++---------
 .../serialization/EntityRepairImplTest.java     |  146 --
 ...MvccEntitySerializationStrategyImplTest.java |   92 +-
 17 files changed, 853 insertions(+), 1421 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerFactory.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerFactory.java
index 9140913..16045ed 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerFactory.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerFactory.java
@@ -40,22 +40,5 @@ public interface EntityCollectionManagerFactory {
         createCollectionManager( CollectionScope collectionScope );
 
 
-
-    /**
-     * Create a new EntityCollectionManagerSync for the given context.
-     * The EntityCollectionManager can safely be used on the current thread
-     * and will shard responses.  The returned instance should not be shared
-     * among threads it will not be guaranteed to be thread safe.
-     * This implementation will be synchronous. Try to use the org.apache.usergrid.persistence.core.consistency
-     * implementation if possible
-     *
-     * @param collectionScope The collectionScope collectionScope to use when
-     * creating the collectionScope manager
-     *
-     * @return The collectionScope manager to perform operations within the provided context
-     */
-    public EntityCollectionManagerSync
-        createCollectionManagerSync( CollectionScope collectionScope );
-
     void invalidate();
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerSync.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerSync.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerSync.java
deleted file mode 100644
index cf89fb8..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerSync.java
+++ /dev/null
@@ -1,49 +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;
-
-
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.entity.Id;
-
-
-/**
- * A synchronous implementation that will block until the call is returned.
- * @author: tnine
- */
-public interface EntityCollectionManagerSync {
-
-    /**
-     * Write the entity in the entity collection.
-     *
-     * @param entity The entity to update
-     */
-    public Entity write( Entity entity );
-
-
-    /**
-     * MarkCommit the entity and remove it's indexes with the given entity id
-     */
-    public void delete( Id entityId );
-
-    /**
-     * Load the entity with the given entity Id
-     */
-    public Entity load( Id entityId );
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/event/EntityVersionDeleted.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/event/EntityVersionDeleted.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/event/EntityVersionDeleted.java
index c76be8e..179abc1 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/event/EntityVersionDeleted.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/event/EntityVersionDeleted.java
@@ -21,6 +21,7 @@ package org.apache.usergrid.persistence.collection.event;
 import java.util.List;
 import org.apache.usergrid.persistence.collection.CollectionScope;
 import org.apache.usergrid.persistence.collection.MvccEntity;
+import org.apache.usergrid.persistence.collection.MvccLogEntry;
 import org.apache.usergrid.persistence.model.entity.Id;
 
 
@@ -40,6 +41,6 @@ public interface EntityVersionDeleted {
      * @param entityVersions The versions that are to be removed
      */
     public void versionDeleted(final CollectionScope scope, final Id entityId, 
-            final List<MvccEntity> entityVersions);
+            final List<MvccLogEntry> entityVersions);
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java
index 8388cfe..8fda6ca 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java
@@ -18,31 +18,26 @@
 package org.apache.usergrid.persistence.collection.guice;
 
 
-
-import org.apache.usergrid.persistence.collection.impl.EntityCollectionManagerFactoryImpl;
 import org.safehaus.guicyfig.GuicyFigModule;
 
-import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
-import org.apache.usergrid.persistence.collection.EntityCollectionManagerSync;
 import org.apache.usergrid.persistence.collection.EntityDeletedFactory;
 import org.apache.usergrid.persistence.collection.EntityVersionCleanupFactory;
 import org.apache.usergrid.persistence.collection.EntityVersionCreatedFactory;
+import org.apache.usergrid.persistence.collection.MvccEntity;
 import org.apache.usergrid.persistence.collection.cache.EntityCacheFig;
 import org.apache.usergrid.persistence.collection.event.EntityDeleted;
+import org.apache.usergrid.persistence.collection.event.EntityVersionCreated;
 import org.apache.usergrid.persistence.collection.event.EntityVersionDeleted;
 import org.apache.usergrid.persistence.collection.impl.EntityCollectionManagerFactoryImpl;
-import org.apache.usergrid.persistence.collection.impl.EntityCollectionManagerImpl;
-import org.apache.usergrid.persistence.collection.impl.EntityCollectionManagerSyncImpl;
 import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
 import org.apache.usergrid.persistence.collection.mvcc.changelog.ChangeLogGenerator;
 import org.apache.usergrid.persistence.collection.mvcc.changelog.ChangeLogGeneratorImpl;
-import org.apache.usergrid.persistence.collection.MvccEntity;
-import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
-import org.apache.usergrid.persistence.collection.serialization.impl.UniqueValueSerializationStrategyImpl;
 import org.apache.usergrid.persistence.collection.mvcc.stage.write.WriteStart;
 import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
+import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
 import org.apache.usergrid.persistence.collection.serialization.impl.SerializationModule;
+import org.apache.usergrid.persistence.collection.serialization.impl.UniqueValueSerializationStrategyImpl;
 import org.apache.usergrid.persistence.collection.service.impl.ServiceModule;
 import org.apache.usergrid.persistence.core.task.NamedTaskExecutorImpl;
 import org.apache.usergrid.persistence.core.task.TaskExecutor;
@@ -53,8 +48,6 @@ import com.google.inject.Provides;
 import com.google.inject.Singleton;
 import com.google.inject.assistedinject.FactoryModuleBuilder;
 import com.google.inject.multibindings.Multibinder;
-import org.apache.usergrid.persistence.collection.event.EntityVersionCreated;
-import org.apache.usergrid.persistence.model.entity.Entity;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerFactoryImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerFactoryImpl.java
index 48bea3d..fa36f42 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerFactoryImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerFactoryImpl.java
@@ -20,44 +20,41 @@
  */
 package org.apache.usergrid.persistence.collection.impl;
 
-import com.google.common.base.Preconditions;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.inject.Inject;
-import com.google.inject.ProvisionException;
-import com.google.inject.Singleton;
-import com.netflix.astyanax.Keyspace;
-import org.apache.usergrid.persistence.collection.guice.CollectionTaskExecutor;
-import org.apache.usergrid.persistence.collection.guice.Write;
-import org.apache.usergrid.persistence.collection.guice.WriteUpdate;
-import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
-import org.apache.usergrid.persistence.collection.mvcc.stage.delete.MarkCommit;
-import org.apache.usergrid.persistence.collection.mvcc.stage.delete.MarkStart;
-import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
-import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
-import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy;
-import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
-import org.apache.usergrid.persistence.core.guice.ProxyImpl;
-import org.apache.usergrid.persistence.core.task.TaskExecutor;
 
 import java.util.concurrent.ExecutionException;
 
-
 import org.apache.usergrid.persistence.collection.CollectionScope;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
-import org.apache.usergrid.persistence.collection.EntityCollectionManagerSync;
 import org.apache.usergrid.persistence.collection.EntityDeletedFactory;
 import org.apache.usergrid.persistence.collection.EntityVersionCleanupFactory;
 import org.apache.usergrid.persistence.collection.EntityVersionCreatedFactory;
 import org.apache.usergrid.persistence.collection.cache.CachedEntityCollectionManager;
 import org.apache.usergrid.persistence.collection.cache.EntityCacheFig;
+import org.apache.usergrid.persistence.collection.guice.CollectionTaskExecutor;
+import org.apache.usergrid.persistence.collection.guice.Write;
+import org.apache.usergrid.persistence.collection.guice.WriteUpdate;
+import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
+import org.apache.usergrid.persistence.collection.mvcc.stage.delete.MarkCommit;
+import org.apache.usergrid.persistence.collection.mvcc.stage.delete.MarkStart;
 import org.apache.usergrid.persistence.collection.mvcc.stage.write.RollbackAction;
 import org.apache.usergrid.persistence.collection.mvcc.stage.write.WriteCommit;
 import org.apache.usergrid.persistence.collection.mvcc.stage.write.WriteOptimisticVerify;
 import org.apache.usergrid.persistence.collection.mvcc.stage.write.WriteStart;
 import org.apache.usergrid.persistence.collection.mvcc.stage.write.WriteUniqueVerify;
+import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
+import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
+import org.apache.usergrid.persistence.core.guice.ProxyImpl;
+import org.apache.usergrid.persistence.core.task.TaskExecutor;
+
+import com.google.common.base.Preconditions;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.netflix.astyanax.Keyspace;
 
 
 
@@ -156,10 +153,6 @@ public class EntityCollectionManagerFactoryImpl implements EntityCollectionManag
         }
     }
 
-    @Override
-    public EntityCollectionManagerSync createCollectionManagerSync(CollectionScope collectionScope) {
-        return new EntityCollectionManagerSyncImpl(this,collectionScope);
-    }
 
     @Override
     public void invalidate() {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerSyncImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerSyncImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerSyncImpl.java
deleted file mode 100644
index 16b1356..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerSyncImpl.java
+++ /dev/null
@@ -1,71 +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.impl;
-
-
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.EntityCollectionManager;
-import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
-import org.apache.usergrid.persistence.collection.EntityCollectionManagerSync;
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.entity.Id;
-
-import com.google.common.base.Preconditions;
-import com.google.inject.Inject;
-import com.google.inject.assistedinject.Assisted;
-
-
-/**
- * A synchronous implementation that will block until the call is returned.
- */
-public class EntityCollectionManagerSyncImpl implements EntityCollectionManagerSync {
-
-
-    private final EntityCollectionManager em;
-
-
-    @Inject
-    public EntityCollectionManagerSyncImpl( final EntityCollectionManagerFactory emf,
-                                            @Assisted final CollectionScope scope ) {
-
-        //this feels a bit hacky, and I franky don't like it.  However, this is the only
-        //way to get this to work I can find with guice, without having to manually implement the factory
-        Preconditions.checkNotNull( emf, "entityCollectionManagerFactory is required" );
-        Preconditions.checkNotNull( scope, "scope is required" );
-        this.em = emf.createCollectionManager( scope );
-    }
-
-
-    @Override
-    public Entity write( final Entity entity ) {
-        return em.write( entity ).toBlocking().single();
-    }
-
-
-    @Override
-    public void delete( final Id entityId ) {
-        em.delete( entityId ).toBlocking().last();
-    }
-
-
-    @Override
-    public Entity load( final Id entityId ) {
-        return em.load( entityId ).toBlocking().lastOrDefault( null );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTask.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTask.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTask.java
index 518daa4..f19459f 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTask.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTask.java
@@ -25,6 +25,7 @@ import java.util.UUID;
 import com.google.inject.Inject;
 import com.google.inject.assistedinject.Assisted;
 import org.apache.usergrid.persistence.collection.MvccEntity;
+import org.apache.usergrid.persistence.collection.MvccLogEntry;
 import org.apache.usergrid.persistence.collection.serialization.UniqueValue;
 import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
 import org.apache.usergrid.persistence.collection.serialization.impl.UniqueValueImpl;
@@ -49,6 +50,7 @@ import java.util.Set;
 import org.apache.usergrid.persistence.core.guice.ProxyImpl;
 
 import rx.Observable;
+import rx.Subscriber;
 import rx.functions.Action1;
 import rx.functions.Func1;
 import rx.schedulers.Schedulers;
@@ -126,75 +128,84 @@ public class EntityVersionCleanupTask implements Task<Void> {
     public Void call() throws Exception {
         //TODO Refactor this logic into a a class that can be invoked from anywhere
         //load every entity we have history of
-        Observable<List<MvccEntity>> deleteFieldsObservable =
-            Observable.create(new ObservableIterator<MvccEntity>("deleteColumns") {
-                @Override
-                protected Iterator<MvccEntity> getIterator() {
-                    Iterator<MvccEntity> entities =  entitySerializationStrategy.loadDescendingHistory(
-                        scope, entityId, version, 1000); // TODO: what fetchsize should we use here?
-                    return entities;
-                }
-            })
+        Observable<List<MvccLogEntry>> deleteFieldsObservable =
+
+                Observable.create( new Observable.OnSubscribe<MvccLogEntry>() {
+
+                    @Override
+                    public void call( final Subscriber<? super MvccLogEntry> subscriber ) {
+
+                        //TODO, make this a collector so it iterates on itself (if possible)
+//                        List<MvccLogEntry> entities = logEntrySerializationStrategy.load( scope, entityId, version, 1000 );
+//                        do {
+//
+//                            List<MvccLogEntry> entities = logEntrySerializationStrategy.load( scope, entityId, version, 1000 );
+//                        }while()
+
+
+                    }
+                } )
+//            Observable.create(new ObservableIterator<MvccEntity>("deleteColumns") {
+//                @Override
+//                protected Iterator<MvccEntity> getIterator() {
+//
+//                }
+//            })
             //buffer them for efficiency
-            .skip(1)
-            .buffer(serializationFig.getBufferSize()).doOnNext(
-            new Action1<List<MvccEntity>>() {
-                @Override
-                public void call(final List<MvccEntity> mvccEntities) {
-                    final MutationBatch batch = keyspace.prepareMutationBatch();
-                    final MutationBatch entityBatch = keyspace.prepareMutationBatch();
-                    final MutationBatch logBatch = keyspace.prepareMutationBatch();
-
-                    for (MvccEntity mvccEntity : mvccEntities) {
-                        if (!mvccEntity.getEntity().isPresent()) {
-                            continue;
+            .skip( 1 )
+            .buffer(serializationFig.getBufferSize()).doOnNext( new Action1<List<MvccLogEntry>>() {
+                    @Override
+                    public void call( final List<MvccLogEntry> mvccEntities ) {
+                        final MutationBatch batch = keyspace.prepareMutationBatch();
+                        final MutationBatch logBatch = keyspace.prepareMutationBatch();
+
+                        for ( MvccLogEntry logEntry : mvccEntities ) {
+
+                            final UUID entityVersion = logEntry.getVersion();
+                            final Id entityId = logEntry.getEntityId();
+
+                            throw new UnsupportedOperationException(
+                                    "This needs to delete unique fields differently.  Think about this a bit "
+                                            + "more" );
+                            //remove all unique fields from the index
+                            //                        for (final Field field : entity.getFields()) {
+                            //                            if (!field.isUnique()) {
+                            //                                continue;
+                            //                            }
+                            //                            final UniqueValue unique = new UniqueValueImpl(
+                            // field, entityId, entityVersion);
+                            //                            final MutationBatch deleteMutation =
+                            //                                    uniqueValueSerializationStrategy.delete
+                            // (scope,unique);
+                            //                            batch.mergeShallow(deleteMutation);
+                            //                        }
+                            //
+                            //                                    final MutationBatch logDelete =
+                            //                                            logEntrySerializationStrategy.delete(
+                            // scope, entityId, version );
+                            //                                    logBatch.mergeShallow( logDelete );
                         }
 
-                        final UUID entityVersion = mvccEntity.getVersion();
-                        final Entity entity = mvccEntity.getEntity().get();
-
-                        //remove all unique fields from the index
-                        for (final Field field : entity.getFields()) {
-                            if (!field.isUnique()) {
-                                continue;
-                            }
-                            final UniqueValue unique = new UniqueValueImpl( field, entityId, entityVersion);
-                            final MutationBatch deleteMutation =
-                                    uniqueValueSerializationStrategy.delete(scope,unique);
-                            batch.mergeShallow(deleteMutation);
+                        try {
+                            batch.execute();
+                        }
+                        catch ( ConnectionException e1 ) {
+                            throw new RuntimeException( "Unable to execute " +
+                                    "unique value " +
+                                    "delete", e1 );
                         }
 
-                        final MutationBatch entityDelete = entitySerializationStrategy
-                                .delete(scope, entityId, mvccEntity.getVersion());
-                        entityBatch.mergeShallow(entityDelete);
-                        final MutationBatch logDelete = logEntrySerializationStrategy
-                                .delete(scope, entityId, version);
-                        logBatch.mergeShallow(logDelete);
-                    }
+                        fireEvents( mvccEntities );
 
-                    try {
-                        batch.execute();
-                    } catch (ConnectionException e1) {
-                        throw new RuntimeException("Unable to execute " +
-                                "unique value " +
-                                "delete", e1);
-                    }
-                    fireEvents(mvccEntities);
-                    try {
-                        entityBatch.execute();
-                    } catch (ConnectionException e) {
-                        throw new RuntimeException("Unable to delete entities in cleanup", e);
-                    }
 
-                    try {
-                        logBatch.execute();
-                    } catch (ConnectionException e) {
-                        throw new RuntimeException("Unable to delete entities from the log", e);
+                        try {
+                            logBatch.execute();
+                        }
+                        catch ( ConnectionException e ) {
+                            throw new RuntimeException( "Unable to delete entities from the log", e );
+                        }
                     }
-
-                }
-            }
-        );
+                } );
 
         final int removedCount = deleteFieldsObservable.count().toBlocking().last();
 
@@ -204,7 +215,7 @@ public class EntityVersionCleanupTask implements Task<Void> {
     }
 
 
-    private void fireEvents( final List<MvccEntity> versions ) {
+    private void fireEvents( final List<MvccLogEntry> versions ) {
 
         final int listenerSize = listeners.size();
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/EntityRepair.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/EntityRepair.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/EntityRepair.java
deleted file mode 100644
index b2be289..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/EntityRepair.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.apache.usergrid.persistence.collection.serialization;/*
- * 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.
- */
-
-
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.MvccEntity;
-
-
-/**
- * Interface for entity repair operations
- */
-public interface EntityRepair {
-
-    /**
-     * Run the repair task for this entity.  If the entity does not need repaired, it will just be returned
-     *
-     * @param collectionScope The scope of the entity to possibly repair
-     * @param targetEntity The entity to check and repair
-     * @return  The source entity or the repaired entity
-     */
-    public MvccEntity maybeRepair(CollectionScope collectionScope, MvccEntity targetEntity);
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/OptimisticUpdate.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/OptimisticUpdate.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/OptimisticUpdate.java
deleted file mode 100644
index 40bde16..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/OptimisticUpdate.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.apache.usergrid.persistence.collection.serialization;
-
-
-import java.util.UUID;
-
-import org.apache.usergrid.persistence.collection.MvccEntity;
-
-
-/**
- * Interface to define how optimistic updates should be performed
- */
-public interface OptimisticUpdate {
-
-    /**
-     * WriteUniqueVerify the entity we're trying to write in our current context has the correct most current version
-     *
-     * @param context The mvcc context
-     * @param optimisticVersion The optimistic version the caller provider as the most up to date
-     *
-     * @return True if the optimisticVersion is the most current >= Comitted stage, false otherwise
-     */
-    public boolean verifyCurrent( MvccEntity context, UUID optimisticVersion );
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/EntityRepairImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/EntityRepairImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/EntityRepairImpl.java
deleted file mode 100644
index 6daf4ef..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/EntityRepairImpl.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package org.apache.usergrid.persistence.collection.serialization.impl;/*
- * 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.
- */
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.mvcc.changelog.ChangeLog;
-import org.apache.usergrid.persistence.collection.mvcc.changelog.ChangeLogGenerator;
-import org.apache.usergrid.persistence.collection.mvcc.changelog.ChangeLogGeneratorImpl;
-import org.apache.usergrid.persistence.collection.MvccEntity;
-import org.apache.usergrid.persistence.collection.serialization.EntityRepair;
-import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy;
-import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.field.Field;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.netflix.astyanax.MutationBatch;
-
-
-@Singleton
-public class EntityRepairImpl implements EntityRepair {
-
-
-    private static final ChangeLogGenerator CHANGE_LOG_GENERATOR = new ChangeLogGeneratorImpl();
-
-    private final MvccEntitySerializationStrategy mvccEntitySerializationStrategy;
-    private final SerializationFig serializationFig;
-
-
-    @Inject
-    public EntityRepairImpl( final MvccEntitySerializationStrategy mvccEntitySerializationStrategy,
-                             final SerializationFig serializationFig ) {
-        this.mvccEntitySerializationStrategy = mvccEntitySerializationStrategy;
-        this.serializationFig = serializationFig;
-    }
-
-
-    @Override
-    public MvccEntity maybeRepair( final CollectionScope collectionScope, final MvccEntity targetEntity ) {
-        if ( !needsRepaired( targetEntity ) ) {
-            return targetEntity;
-        }
-
-
-        final List<MvccEntity> partialEntities = new ArrayList<>( serializationFig.getBufferSize() );
-
-        partialEntities.add( targetEntity );
-
-        final Iterator<MvccEntity> results = mvccEntitySerializationStrategy
-                .loadDescendingHistory( collectionScope, targetEntity.getId(), targetEntity.getVersion(),
-                        serializationFig.getBufferSize() );
-
-
-
-        //discard the one that's equal to the version we were passed in
-        if(results.hasNext() ){
-            results.next();
-        }
-
-
-//        MvccEntity oldestCompleteEntity;
-
-
-        while ( results.hasNext() ) {
-            final MvccEntity mvccEntity = results.next();
-            partialEntities.add( mvccEntity );
-
-
-            if ( !needsRepaired( mvccEntity ) ) {
-                break;
-            }
-        }
-
-        Collections.reverse( partialEntities );
-
-        final ChangeLog changeLog =
-                CHANGE_LOG_GENERATOR.getChangeLog( partialEntities );
-
-
-        //repair
-        final MvccEntity mergedEntity = entityRepair( changeLog, targetEntity );
-
-        try {
-            final MutationBatch batch = mvccEntitySerializationStrategy.write( collectionScope, mergedEntity );
-
-            batch.execute();
-        }
-        catch ( Exception e ) {
-            throw new RuntimeException( "Couldn't rewrite repaired entity", e );
-        }
-
-        return mergedEntity;
-
-    }
-
-
-    /**
-     * Appies changes to the entity log, oldest to newest version
-     */
-    private MvccEntity entityRepair( final ChangeLog changeLog, final MvccEntity targetEntity ) {
-
-        //TODO review this, why do we care other than just replaying the changelog?
-
-        final Entity entity = targetEntity.getEntity().get();
-
-        for(final String removedField: changeLog.getDeletes()){
-            entity.removeField( removedField );
-        }
-
-        for(final Field newField : changeLog.getWrites()){
-            entity.setField( newField );
-        }
-
-        return targetEntity;
-    }
-
-
-    /**
-     * Returns true if the entity needs repaired
-     */
-    private boolean needsRepaired( final MvccEntity headEntity ) {
-
-        final MvccEntity.Status status = headEntity.getStatus();
-
-        return !(status == MvccEntity.Status.COMPLETE || status == MvccEntity.Status.DELETED || !headEntity.getEntity().isPresent());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/EntityVersionSerializer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/EntityVersionSerializer.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/EntityVersionSerializer.java
index ce6512f..4fd3b33 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/EntityVersionSerializer.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/EntityVersionSerializer.java
@@ -40,8 +40,6 @@ import com.netflix.astyanax.serializers.UUIDSerializer;
  */
 public class EntityVersionSerializer extends AbstractSerializer<EntityVersion> {
 
-    private static final Logger LOG = LoggerFactory.getLogger( EntityVersionSerializer.class );
-
     @Override
     public ByteBuffer toByteBuffer(final EntityVersion ev) {
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
index 25b501c..67cc3e6 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
@@ -23,6 +23,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 import java.util.UUID;
 
 import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy;
@@ -39,17 +40,16 @@ import org.apache.usergrid.persistence.collection.MvccEntity;
 import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeException;
 import org.apache.usergrid.persistence.collection.exception.DataCorruptionException;
 import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
-import org.apache.usergrid.persistence.collection.serialization.EntityRepair;
 import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
 import org.apache.usergrid.persistence.collection.util.EntityUtils;
 import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
-import org.apache.usergrid.persistence.core.astyanax.ColumnNameIterator;
 import org.apache.usergrid.persistence.core.astyanax.ColumnParser;
 import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamily;
 import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamilyDefinition;
 import org.apache.usergrid.persistence.core.astyanax.ScopedRowKey;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
@@ -83,7 +83,6 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
     protected final Keyspace keyspace;
     protected final SerializationFig serializationFig;
     protected final CassandraFig cassandraFig;
-    protected final EntityRepair repair;
     private final MultiTennantColumnFamily<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID>  columnFamily;
 
 
@@ -93,8 +92,7 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
         this.keyspace = keyspace;
         this.serializationFig = serializationFig;
         this.cassandraFig = cassandraFig;
-        this.repair = new EntityRepairImpl( this, serializationFig );
-        this.columnFamily = getColumnFamily();
+         this.columnFamily = getColumnFamily();
     }
 
 
@@ -241,10 +239,7 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
                                    final MvccEntity parsedEntity =
                                            new MvccColumnParser( entityId, getEntitySerializer() ).parseColumn( column );
 
-                                   //we *might* need to repair, it's not clear so check before loading into result sets
-                                   final MvccEntity maybeRepaired = repair.maybeRepair( collectionScope, parsedEntity );
-
-                                entitySet.addEntity( maybeRepaired );
+                                    entitySet.addEntity( parsedEntity );
                                }
 
 
@@ -259,6 +254,13 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
     }
 
 
+    @Override
+    public MvccEntity load( final CollectionScope scope, final Id entityId ) {
+        final EntitySet results = load( scope, Collections.singleton( entityId ), UUIDGenerator.newTimeUUID() );
+
+        return results.getEntity( entityId );
+    }
+
 
     @Override
     public MutationBatch mark( final CollectionScope collectionScope, final Id entityId, final UUID version ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/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
index d78001a..5c4d59d 100644
--- 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
@@ -77,13 +77,22 @@ public abstract class MvccEntitySerializationStrategyProxyImpl implements MvccEn
     @Override
     public EntitySet load( final CollectionScope scope, final Collection<Id> entityIds, final UUID maxVersion ) {
         if ( isOldVersion() ) {
-            return previous.load( scope, entityIds, maxVersion );
-        }
+                    return previous.load( scope, entityIds, maxVersion );
+                }
 
-        return current.load( scope, entityIds, maxVersion );
+                return current.load( scope, entityIds, maxVersion );
     }
 
 
+    @Override
+    public MvccEntity load( final CollectionScope scope, final Id entityId ) {
+        if ( isOldVersion() ) {
+            return previous.load( scope, entityId );
+        }
+
+        return current.load( scope, entityId );
+    }
+
 
     @Override
     public MutationBatch mark( final CollectionScope context, final Id entityId, final UUID version ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/067e78e3/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
index dd5c9c7..0f2962c 100644
--- 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
@@ -23,7 +23,6 @@ import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeExc
 import org.apache.usergrid.persistence.collection.exception.DataCorruptionException;
 import org.apache.usergrid.persistence.collection.exception.EntityTooLargeException;
 import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
-import org.apache.usergrid.persistence.collection.serialization.EntityRepair;
 import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy;
 import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
 import org.apache.usergrid.persistence.collection.util.EntityUtils;
@@ -92,7 +91,6 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ
     protected final Keyspace keyspace;
     protected final SerializationFig serializationFig;
     protected final CassandraFig cassandraFig;
-    protected final EntityRepair repair;
 
 
     @Inject
@@ -101,7 +99,6 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ
         this.keyspace = keyspace;
         this.serializationFig = serializationFig;
         this.cassandraFig = cassandraFig;
-        this.repair = new EntityRepairImpl( this, serializationFig );
         this.entitySerializer = new EntitySerializer( serializationFig );
     }
 
@@ -256,12 +253,8 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ
                                     final MvccEntity parsedEntity =
                                             new MvccColumnParser( entityId, entitySerializer ).parseColumn( column );
 
-                                    //we *might* need to repair, it's not clear so check before loading into result
-                                    // sets
-                                    final MvccEntity maybeRepaired =
-                                            repair.maybeRepair( collectionScope, parsedEntity );
 
-                                    entitySet.addEntity( maybeRepaired );
+                                    entitySet.addEntity( parsedEntity );
                                 }