You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by gr...@apache.org on 2015/03/10 22:47:48 UTC

[1/2] incubator-usergrid git commit: Filled out test that should prove the issue.

Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-396 1bdfd108b -> acde0e4b9


Filled out test that should prove the issue.


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

Branch: refs/heads/USERGRID-396
Commit: 5411fef0e80d848639fc140e3b6e48383cb05163
Parents: 1bdfd10
Author: GERey <gr...@apigee.com>
Authored: Mon Mar 9 13:09:49 2015 -0700
Committer: GERey <gr...@apigee.com>
Committed: Mon Mar 9 13:09:49 2015 -0700

----------------------------------------------------------------------
 .../collection/EntityCollectionManagerIT.java   | 55 +++++++++++++-------
 1 file changed, 35 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5411fef0/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 f33b3d0..a52a9bb 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
@@ -25,6 +25,7 @@ import java.util.UUID;
 
 import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
 import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
+import org.apache.usergrid.persistence.collection.serialization.UniqueValueSet;
 import org.apache.usergrid.persistence.core.guice.ProxyImpl;
 import org.junit.Rule;
 import org.junit.Test;
@@ -51,6 +52,7 @@ import org.apache.usergrid.persistence.model.field.StringField;
 
 import com.fasterxml.uuid.UUIDComparator;
 import com.google.inject.Inject;
+import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
 
 import rx.Observable;
 
@@ -422,7 +424,7 @@ public class EntityCollectionManagerIT {
     @Test
     public void updateVersioning() {
 
-        // create entity 
+        // create entity
         Entity origEntity = new Entity( new SimpleId( "testUpdate" ) );
         origEntity.setField( new StringField( "testField", "value" ) );
 
@@ -431,7 +433,7 @@ public class EntityCollectionManagerIT {
         EntityCollectionManager manager = factory.createCollectionManager( context );
         Entity returned = manager.write( origEntity ).toBlocking().lastOrDefault( null );
 
-        // note its version 
+        // note its version
         UUID oldVersion = returned.getVersion();
 
         // partial update entity but with new entity that has version = null
@@ -754,16 +756,16 @@ public class EntityCollectionManagerIT {
         //override our default
         SetConfigTestBypass.setValueByPass( serializationFig, "getMaxEntitySize", currentMaxSize + "" );
     }
-    
+
     @Test
     public void invalidNameRepair() {
-        
+
         //write an entity with a unique field
-        CollectionScope context = 
+        CollectionScope context =
                 new CollectionScopeImpl( new SimpleId( "organization" ), new SimpleId( "test" ), "test" );
 
         Entity newEntity = new Entity( new SimpleId( "test" ) );
-        
+
         newEntity.setField( new IntegerField( "count", 5, true ) );
         newEntity.setField( new StringField( "yes", "fred", true ) );
 
@@ -777,28 +779,41 @@ 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() );
 
         Entity loadReturned = loadObservable.toBlocking().lastOrDefault( null );
 
-        assertEquals( "Same value", createReturned, loadReturned );
-        //load an entity by it's unique field
-        
         //verify the entity is correct.
-        
+        assertEquals( "Same value", createReturned, 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");
+        }
+
+
         //try to load via the unique field
-        
+        loadObservable = manager.load( createReturned.getId() );
+
+        loadReturned = loadObservable.toBlocking().lastOrDefault( null );
+
         //verify no entity returned
-        
-        //user the unique serialization to verify it's been deleted from cassandra
-        
+        assertNull( loadReturned );
 
-        
-                
-                
-                
+        //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");
+        }
     }
 }


[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

Posted by gr...@apache.org.
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 <gr...@apigee.com>
Authored: Tue Mar 10 12:47:40 2015 -0700
Committer: GERey <gr...@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() );
+
     }
 }