usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject [17/50] usergrid git commit: Merge branch 'release-2.1.1' into usergrid-1268-akka-211
Date Thu, 14 Jul 2016 05:38:23 GMT
Merge branch 'release-2.1.1' into usergrid-1268-akka-211

Conflicts:
	stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
	stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyIT.java


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

Branch: refs/heads/master
Commit: 2d5ad05f93a23cbe36046e1019d8b29ae06fe0e3
Parents: 639b421 8242878
Author: Dave Johnson <snoopdave@apache.org>
Authored: Thu Jun 30 15:41:48 2016 -0400
Committer: Dave Johnson <snoopdave@apache.org>
Committed: Thu Jun 30 15:41:48 2016 -0400

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        | 15 ++-
 .../corepersistence/CpRelationManager.java      | 50 ++++++----
 .../usergrid/persistence/EntityManager.java     | 20 +++-
 .../apache/usergrid/persistence/PathQuery.java  |  3 +-
 .../usergrid/persistence/RelationManager.java   |  2 +
 .../impl/EntityCollectionManagerImpl.java       | 13 ++-
 .../mvcc/stage/write/WriteUniqueVerify.java     | 27 ++++--
 .../UniqueValueSerializationStrategy.java       | 25 ++++-
 .../UniqueValueSerializationStrategyImpl.java   | 97 +++++++++++---------
 ...iqueValueSerializationStrategyProxyImpl.java | 21 ++++-
 .../mvcc/stage/write/WriteUniqueVerifyIT.java   | 88 +++++++++++++++---
 ...niqueValueSerializationStrategyImplTest.java | 26 ++++--
 .../collection/users/PermissionsResourceIT.java |  4 +-
 .../services/AbstractCollectionService.java     | 59 +++++++++---
 .../services/AbstractConnectionsService.java    |  5 +-
 .../usergrid/services/ServiceInvocationIT.java  | 28 +++++-
 .../usergrid/tools/UniqueValueScanner.java      | 69 +++++++-------
 17 files changed, 392 insertions(+), 160 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/2d5ad05f/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2d5ad05f/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2d5ad05f/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2d5ad05f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2d5ad05f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
index 89431a7,0ebb6a1..f159096
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
@@@ -166,11 -121,12 +166,10 @@@ public class WriteUniqueVerify implemen
  
              try {
  
--                // loading will retrieve the oldest unique value entry for the field
-                 UniqueValueSet set = uniqueValueStrat.load(
-                     scope, written.getEntityId().getType(), Collections.singletonList(written.getField()));
- 
+                 // don't use read repair on this pre-write check
+                 UniqueValueSet set = uniqueValueStrat.load(scope, written.getEntityId().getType(),
+                     Collections.singletonList(written.getField()), false);
  
 -
                  set.forEach(uniqueValue -> {
  
                      if(!uniqueValue.getEntityId().getUuid().equals(written.getEntityId().getUuid())){

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2d5ad05f/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyIT.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyIT.java
index ccae9be,3d411a4..703d6c2
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyIT.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyIT.java
@@@ -18,21 -18,22 +18,17 @@@
  package org.apache.usergrid.persistence.collection.mvcc.stage.write;
  
  
 -import org.apache.usergrid.persistence.collection.FieldSet;
 -import org.apache.usergrid.persistence.collection.MvccEntity;
 -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;
 -import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 -import org.junit.Rule;
 -import org.junit.Test;
 -import org.junit.runner.RunWith;
 -
 -import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 -import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
++import com.google.inject.Inject;
 +import org.apache.usergrid.persistence.actorsystem.ActorSystemManager;
- import org.apache.usergrid.persistence.collection.AbstractUniqueValueTest;
- import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValueActor;
- import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValuesService;
- import org.junit.Before;
- import org.junit.Rule;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- 
- import org.apache.usergrid.persistence.collection.EntityCollectionManager;
- import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
++import org.apache.usergrid.persistence.collection.*;
  import org.apache.usergrid.persistence.collection.exception.WriteUniqueVerifyException;
  import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
  import org.apache.usergrid.persistence.collection.mvcc.stage.TestEntityGenerator;
  import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
++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;
++import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValuesService;
  import org.apache.usergrid.persistence.core.guice.MigrationManagerRule;
  import org.apache.usergrid.persistence.core.scope.ApplicationScope;
  import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
@@@ -43,12 -44,11 +39,15 @@@ import org.apache.usergrid.persistence.
  import org.apache.usergrid.persistence.model.entity.SimpleId;
  import org.apache.usergrid.persistence.model.field.IntegerField;
  import org.apache.usergrid.persistence.model.field.StringField;
 -
 -import com.google.inject.Inject;
++import org.apache.usergrid.persistence.model.util.UUIDGenerator;
++import org.junit.Before;
++import org.junit.Rule;
++import org.junit.Test;
++import org.junit.runner.RunWith;
  
- import com.google.inject.Inject;
- 
- import java.util.concurrent.atomic.AtomicBoolean;
+ import java.util.Collections;
  
 +import static junit.framework.TestCase.assertTrue;
  import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.fail;
  
@@@ -71,22 -68,11 +70,25 @@@ public class WriteUniqueVerifyIT extend
      public MigrationManagerRule migrationManagerRule;
  
      @Inject
+     public UniqueValueSerializationStrategy uniqueValueSerializationStrategy;
+ 
+     @Inject
      public EntityCollectionManagerFactory cmf;
  
 +    @Inject
 +    ActorSystemManager actorSystemManager;
 +
 +    @Inject
 +    UniqueValuesService uniqueValuesService;
 +
 +
 +    @Before
 +    public void initAkka() {
 +        // each test class needs unique port number
 +        initAkka( 2551, actorSystemManager, uniqueValuesService );
 +    }
 +
 +
      @Test
      public void testConflict() {
  
@@@ -160,9 -148,69 +162,69 @@@
          entity.setField(new StringField("name", "Alfa Romeo 8C Competizione", true));
          entity.setField(new StringField("identifier", "ar8c", true));
          entity.setField(new IntegerField("top_speed_mph", 182));
 -        entityManager.write( entity ).toBlocking().last();
 +        entityManager.write( entity, null ).toBlocking().last();
  
          entity.setField( new StringField("foo", "bar"));
 -        entityManager.write( entity ).toBlocking().last();
 +        entityManager.write( entity, null ).toBlocking().last();
      }
+ 
+     @Test
+     public void testConflictReadRepair() throws Exception {
+ 
+         final Id appId = new SimpleId("testNoConflict");
+ 
+ 
+ 
+         final ApplicationScope scope = new ApplicationScopeImpl( appId);
+ 
+         final EntityCollectionManager entityManager = cmf.createCollectionManager( scope
);
+ 
+         final Entity entity = TestEntityGenerator.generateEntity();
+         entity.setField(new StringField("name", "Porsche 911 GT3", true));
+         entity.setField(new StringField("identifier", "911gt3", true));
+         entity.setField(new IntegerField("top_speed_mph", 194));
 -        entityManager.write( entity ).toBlocking().last();
++        entityManager.write( entity, null ).toBlocking().last();
+ 
+ 
+         FieldSet fieldSet =
+             entityManager.getEntitiesFromFields("test", Collections.singletonList(entity.getField("name")),
true)
+             .toBlocking().last();
+ 
+         MvccEntity entityFetched = fieldSet.getEntity( entity.getField("name") );
+ 
+ 
+         final Entity entityDuplicate = TestEntityGenerator.generateEntity();
+         UniqueValue uniqueValue = new UniqueValueImpl(new StringField("name", "Porsche 911
GT3", true),
+             entityDuplicate.getId(), UUIDGenerator.newTimeUUID());
+ 
+         // manually insert a record to simulate a 'duplicate' trying to be inserted
+         uniqueValueSerializationStrategy.
+             write(scope, uniqueValue).execute();
+ 
+ 
+ 
+         FieldSet fieldSetAgain =
+             entityManager.getEntitiesFromFields("test", Collections.singletonList(entity.getField("name")),
true)
+                 .toBlocking().last();
+ 
+         MvccEntity entityFetchedAgain = fieldSetAgain.getEntity( entity.getField("name")
);
+ 
+         assertEquals(entityFetched, entityFetchedAgain);
+ 
+ 
+         // now test writing the original entity again ( simulates a PUT )
+         // this should read repair and work
 -        entityManager.write( entity ).toBlocking().last();
++        entityManager.write( entity, null ).toBlocking().last();
+ 
+         FieldSet fieldSetAgainAgain =
+             entityManager.getEntitiesFromFields("test", Collections.singletonList(entity.getField("name")),
true)
+                 .toBlocking().last();
+ 
+         MvccEntity entityFetchedAgainAgain = fieldSetAgainAgain.getEntity( entity.getField("name")
);
+ 
+         assertEquals(entityFetched, entityFetchedAgainAgain);
+ 
+ 
+ 
+     }
  }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2d5ad05f/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2d5ad05f/stack/services/src/main/java/org/apache/usergrid/services/AbstractConnectionsService.java
----------------------------------------------------------------------


Mime
View raw message