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/05/10 12:59:37 UTC

[6/8] incubator-usergrid git commit: Fixes runtime bug with cached entities.

Fixes runtime bug with cached entities.


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

Branch: refs/heads/USERGRID-614
Commit: 9a89437b18dc3f14b3fcdea569d18e0f9fb64294
Parents: 3e2afe2
Author: Todd Nine <tn...@apigee.com>
Authored: Fri May 8 13:10:00 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Sun May 10 04:59:22 2015 -0600

----------------------------------------------------------------------
 .../EntityCollectionManagerFactoryImpl.java     |  8 ++--
 .../mvcc/stage/delete/VersionCompact.java       | 11 ++++--
 .../MvccEntitySerializationStrategyV3Impl.java  | 39 ++++----------------
 .../collection/EntityCollectionManagerIT.java   |  3 +-
 ...MvccEntitySerializationStrategyImplTest.java |  2 +-
 5 files changed, 24 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9a89437b/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 50a4bfc..6d8717e 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
@@ -92,10 +92,12 @@ public class EntityCollectionManagerFactoryImpl implements EntityCollectionManag
                                 metricsFactory, serializationFig,
                                 rxTaskScheduler, scope );
 
+//  TODO temporarily removed  If we can avoid this, that would be great
+//                            final EntityCollectionManager proxy = new CachedEntityCollectionManager(entityCacheFig, target  );
+//
+//                            return proxy;
 
-                            final EntityCollectionManager proxy = new CachedEntityCollectionManager(entityCacheFig, target  );
-
-                            return proxy;
+                            return target;
                         }
                     } );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9a89437b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/VersionCompact.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/VersionCompact.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/VersionCompact.java
index 424ec86..e20ad30 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/VersionCompact.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/VersionCompact.java
@@ -38,6 +38,7 @@ import org.apache.usergrid.persistence.model.entity.Id;
 import com.codahale.metrics.Timer;
 import com.google.inject.Inject;
 import com.netflix.astyanax.Keyspace;
+import com.netflix.astyanax.MutationBatch;
 import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
 
 import rx.Observable;
@@ -95,11 +96,15 @@ public class VersionCompact
 
 
                         //delete from our log
-                        mutationBatch.mergeShallow( logEntrySerializationStrategy.delete( scope, entityId, version ) );
+                        final MutationBatch logDelete = logEntrySerializationStrategy.delete( scope, entityId, version );
+
+                        mutationBatch.mergeShallow( logDelete );
 
                         //merge our entity delete in
-                        mutationBatch
-                            .mergeShallow( mvccEntitySerializationStrategy.delete( scope, entityId, version ) );
+
+                        final MutationBatch entityDelete =  mvccEntitySerializationStrategy.delete( scope, entityId, version );
+
+                        mutationBatch.mergeShallow( entityDelete );
 
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9a89437b/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 be08da8..6418ac7 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
@@ -107,13 +107,8 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ
         final Id entityId = entity.getId();
         final UUID version = entity.getVersion();
 
-        return doWrite( applicationScope, entityId, version, new RowOp() {
-            @Override
-            public void doOp( final ColumnListMutation<Boolean> colMutation ) {
-                colMutation.putColumn( COL_VALUE,
-                        entitySerializer.toByteBuffer( new EntityWrapper( entity.getStatus(), entity.getVersion(), entity.getEntity() ) ) );
-            }
-        } );
+        return doWrite( applicationScope, entityId, version, colMutation -> colMutation.putColumn( COL_VALUE,
+                entitySerializer.toByteBuffer( new EntityWrapper( entity.getStatus(), entity.getVersion(), entity.getEntity() ) ) ) );
     }
 
 
@@ -135,8 +130,6 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ
 
 
         final Id applicationId = applicationScope.getApplication();
-        final Id ownerId = applicationId;
-
 
         final List<ScopedRowKey<Id>> rowKeys = new ArrayList<>( entityIds.size() );
 
@@ -196,11 +189,8 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ
                             "An error occurred connecting to cassandra", e );
                     }
                 } ).subscribeOn( scheduler );
-            }, 10 )
-
-            .reduce( new EntitySetImpl( entityIds.size() ), ( entitySet, rows ) -> {
-                final Iterator<Row<ScopedRowKey<Id>, Boolean>> latestEntityColumns =
-                    rows.iterator();
+            }, 10 ).collect( () -> new EntitySetImpl( entityIds.size() ), ( ( entitySet, rows ) -> {
+                final Iterator<Row<ScopedRowKey<Id>, Boolean>> latestEntityColumns = rows.iterator();
 
                 while ( latestEntityColumns.hasNext() ) {
                     final Row<ScopedRowKey<Id>, Boolean> row = latestEntityColumns.next();
@@ -221,10 +211,7 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ
 
                     entitySet.addEntity( parsedEntity );
                 }
-
-
-                return entitySet;
-            } ).toBlocking().last();
+               } ) ).toBlocking().last();
 
 
 
@@ -275,13 +262,8 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ
         Preconditions.checkNotNull( version, "version is required" );
 
 
-        return doWrite( applicationScope, entityId, version, new RowOp() {
-            @Override
-            public void doOp( final ColumnListMutation<Boolean> colMutation ) {
-                colMutation.putColumn( COL_VALUE, entitySerializer.toByteBuffer(
-                    new EntityWrapper( MvccEntity.Status.COMPLETE, version, Optional.<Entity>absent() ) ) );
-            }
-        } );
+        return doWrite( applicationScope, entityId, version, colMutation -> colMutation.putColumn( COL_VALUE, entitySerializer.toByteBuffer(
+            new EntityWrapper( MvccEntity.Status.COMPLETE, version, Optional.<Entity>absent() ) ) ) );
     }
 
 
@@ -292,12 +274,7 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ
         Preconditions.checkNotNull( version, "version is required" );
 
 
-        return doWrite( applicationScope, entityId, version, new RowOp() {
-            @Override
-            public void doOp( final ColumnListMutation<Boolean> colMutation ) {
-                colMutation.deleteColumn( Boolean.TRUE );
-            }
-        } );
+        return doWrite( applicationScope, entityId, version, colMutation -> colMutation.deleteColumn( Boolean.TRUE ) );
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9a89437b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
index 36faf62..68a04d0 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
@@ -754,6 +754,7 @@ public class EntityCollectionManagerIT {
         //write new versions
         for ( int i = 1; i < size; i++ ) {
             final Entity newEntity = new Entity( entityId );
+            newEntity.setField( new IntegerField( "counter", i ) );
 
             final Entity returnedEntity = manager.write( newEntity ).toBlocking().last();
 
@@ -781,7 +782,7 @@ public class EntityCollectionManagerIT {
 
 
         //now get all the log versions, and delete them all we do it in 2+ batches to ensure we clean up as expected
-        manager.getVersions( entityId ).buffer( 100 ).flatMap( bufferList -> manager.delete( bufferList ) )
+        manager.getVersions( entityId ).toList().flatMap( bufferList -> manager.delete( bufferList ) )
                .toBlocking().last();
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9a89437b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
index 11575c7..f6720f9 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
@@ -190,7 +190,7 @@ public abstract class MvccEntitySerializationStrategyImplTest {
         assertEquals( version, entity.getVersion() );
 
 
-        //now delete it
+        //now delete it, should remove it from cass
         serializationStrategy.delete( context, id, version ).execute();
 
         //now get it, should be gone