usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [2/2] incubator-usergrid git commit: Fixed cachedEntityCollectionManager getAllEntities method. Made the getAllEntities a synced process to ensure it runs and finishes within the scope of the task. Added test that proves the issue. and that it is fixed b
Date Tue, 10 Mar 2015 21:47:49 GMT
Fixed cachedEntityCollectionManager getAllEntities method.
Made the getAllEntities a synced process to ensure it runs and finishes within the scope of
the task.
Added test that proves the issue. and that it is fixed by the new method.


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

Branch: refs/heads/USERGRID-396
Commit: acde0e4b9b032a297b0bddaa874393ebb7083709
Parents: 5411fef
Author: GERey <greyes@apigee.com>
Authored: Tue Mar 10 12:47:40 2015 -0700
Committer: GERey <greyes@apigee.com>
Committed: Tue Mar 10 12:47:40 2015 -0700

----------------------------------------------------------------------
 .../cache/CachedEntityCollectionManager.java    | 11 +----
 .../impl/EntityCollectionManagerImpl.java       |  4 +-
 .../collection/EntityCollectionManagerIT.java   | 50 +++++++++-----------
 3 files changed, 27 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/acde0e4b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
index a111f8d..d33f762 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
@@ -82,16 +82,9 @@ public class CachedEntityCollectionManager implements EntityCollectionManager
{
                                   .build();
     }
 
+    @Override
     public Observable<FieldSet> getAllEntities(final Collection<Field> fields)
{
-        return rx.Observable.just(fields).map( new Func1<Collection<Field>, FieldSet>()
{
-            @Override
-            public FieldSet call( Collection<Field> fields ) {
-
-                    final FieldSet response = new FieldSetImpl(fields.size());
-
-                    return response;
-            }
-        } );
+        return targetEntityCollectionManager.getAllEntities( fields );
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/acde0e4b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
index 5505e3f..d95183d 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
@@ -335,7 +335,7 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager
{
                     }
 
                     //fire and forget, we don't care.  We'll repair it again if we have to
-                    deleteBatch.executeAsync();
+                    deleteBatch.execute();
 
                     return response;
 
@@ -349,7 +349,7 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager
{
         } );
     }
 
-   
+
 
     @Override
     public Observable<Entity> update( final Entity entity ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/acde0e4b/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 a52a9bb..46e844d 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
@@ -20,6 +20,7 @@ package org.apache.usergrid.persistence.collection;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.UUID;
 
@@ -758,7 +759,7 @@ public class EntityCollectionManagerIT {
     }
 
     @Test
-    public void invalidNameRepair() {
+    public void invalidNameRepair() throws ConnectionException {
 
         //write an entity with a unique field
         CollectionScope context =
@@ -766,8 +767,12 @@ public class EntityCollectionManagerIT {
 
         Entity newEntity = new Entity( new SimpleId( "test" ) );
 
-        newEntity.setField( new IntegerField( "count", 5, true ) );
-        newEntity.setField( new StringField( "yes", "fred", true ) );
+        //if we add a second field we get a second entity that is the exact same. Is this
expected?
+        final IntegerField expectedInteger =  new IntegerField( "count", 5, true );
+       // final StringField expectedString = new StringField( "yes", "fred", true );
+
+        newEntity.setField( expectedInteger );
+       // newEntity.setField( expectedString );
 
         EntityCollectionManager manager = factory.createCollectionManager( context );
 
@@ -779,41 +784,32 @@ public class EntityCollectionManagerIT {
         assertNotNull( "Id was assigned", createReturned.getId() );
         assertNotNull( "Version was assigned", createReturned.getVersion() );
 
-        //load an entity by it's unique field
-        Observable<Entity> loadObservable = manager.load( createReturned.getId() );
+        FieldSet
+            fieldResults = manager.getAllEntities( Arrays.<Field>asList( expectedInteger)
).toBlocking().last();
 
-        Entity loadReturned = loadObservable.toBlocking().lastOrDefault( null );
+        assertEquals(1,fieldResults.size());
 
-        //verify the entity is correct.
-        assertEquals( "Same value", createReturned, loadReturned );
 
+        //verify the entity is correct.
+        assertEquals( "Same value", createReturned, fieldResults.getEntity( expectedInteger
).getEntity().get()); //loadReturned );
 
         //use the entity serializationStrategy to remove the entity data.
-        try {
-            entitySerializationStrategy.delete( context,loadReturned.getId(),loadReturned.getVersion()
).execute();
-        }
-        catch ( ConnectionException e ) {
-            e.printStackTrace();
-            fail("Shouldn't have had trouble deleting entity");
-        }
 
+        //do a mark as one test, and a delete as another
+        entitySerializationStrategy.delete( context,createReturned.getId(),createReturned.getVersion()
).execute();
 
-        //try to load via the unique field
-        loadObservable = manager.load( createReturned.getId() );
+        //try to load via the unique field, should have triggered repair
+        final FieldSet
+            results = manager.getAllEntities( Arrays.<Field>asList( expectedInteger)
).toBlocking().last();
 
-        loadReturned = loadObservable.toBlocking().lastOrDefault( null );
 
         //verify no entity returned
-        assertNull( loadReturned );
+        assertTrue( results.isEmpty() );
 
         //user the unique serialization to verify it's been deleted from cassandra
-        try {
-            UniqueValueSet uniqueValues = uniqueValueSerializationStrategy.load( context,
loadReturned.getFields() );
-            assertNull( uniqueValues );
-        }
-        catch ( ConnectionException e ) {
-            e.printStackTrace();
-            fail("Shouldn't have been able to load the unique entity");
-        }
+
+        UniqueValueSet uniqueValues = uniqueValueSerializationStrategy.load( context, createReturned.getFields()
);
+        assertFalse( uniqueValues.iterator().hasNext() );
+
     }
 }


Mime
View raw message