Repository: incubator-usergrid Updated Branches: refs/heads/USERGRID-614 70e0e75aa -> b54d86824
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/b54d8682 Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/b54d8682 Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/b54d8682 Branch: refs/heads/USERGRID-614 Commit: b54d86824ed4568714b649f276606c2f2632a410 Parents: 70e0e75 Author: Todd Nine <[email protected]> Authored: Fri May 8 13:10:00 2015 -0600 Committer: Todd Nine <[email protected]> Committed: Fri May 8 13:10:00 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/b54d8682/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/b54d8682/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/b54d8682/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/b54d8682/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/b54d8682/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
