usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [03/18] usergrid git commit: Use current region if no authoritative region specified for type.
Date Mon, 02 May 2016 21:42:15 GMT
Use current region if no authoritative region specified for type.


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

Branch: refs/heads/usergrid-1268-akka-211
Commit: 5352494cd42b1dc0fec2a8bec7a3c204010d2b94
Parents: eeb8a60
Author: Dave Johnson <snoopdave@apache.org>
Authored: Wed Apr 13 17:08:09 2016 -0400
Committer: Dave Johnson <snoopdave@apache.org>
Committed: Mon Apr 25 14:34:58 2016 -0400

----------------------------------------------------------------------
 .../uniquevalues/UniqueValuesServiceImpl.java   | 21 ++++++++++----------
 1 file changed, 10 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/5352494c/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
index 45909b8..bd357ae 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
@@ -471,8 +471,7 @@ public class UniqueValuesServiceImpl implements UniqueValuesService {
     private void reserveUniqueField(
         ApplicationScope scope, Entity entity, UUID version, Field field ) throws UniqueValueException
{
 
-        String region = getRegionsByType().get( entity.getId().getType() );
-        ActorRef requestActor = getRequestActorsByRegion().get(region);
+        ActorRef requestActor = lookupRequestActorForType( entity.getId().getType() );
 
         if ( requestActor == null ) {
             throw new RuntimeException( "No request actor for type, cannot verify unique
fields!" );
@@ -489,15 +488,14 @@ public class UniqueValuesServiceImpl implements UniqueValuesService
{
             throw new UniqueValueException( "Error property not unique (cache)", field);
         }
 
-        sendUniqueValueRequest( scope, entity, field, requestActor, request );
+        sendUniqueValueRequest(  entity, requestActor, request );
     }
 
 
     private void confirmUniqueField(
         ApplicationScope scope, Entity entity, UUID version, Field field ) throws UniqueValueException
{
 
-        String region = getRegionsByType().get( entity.getId().getType() );
-        ActorRef requestActor = getRequestActorsByRegion().get(region);
+        ActorRef requestActor = lookupRequestActorForType( entity.getId().getType() );
 
         if ( requestActor == null ) {
             throw new RuntimeException( "No request actor for type, cannot verify unique
fields!" );
@@ -506,11 +504,12 @@ public class UniqueValuesServiceImpl implements UniqueValuesService
{
         UniqueValueActor.Confirmation request = new UniqueValueActor.Confirmation(
             scope, entity.getId(), version, field );
 
-        sendUniqueValueRequest( scope, entity, field, requestActor, request );
+        sendUniqueValueRequest( entity, requestActor, request );
     }
 
 
-    private void cancelUniqueField( ApplicationScope scope, Entity entity, UUID version,
Field field ) throws UniqueValueException {
+    private void cancelUniqueField(
+        ApplicationScope scope, Entity entity, UUID version, Field field ) throws UniqueValueException
{
 
         ActorRef requestActor = lookupRequestActorForType( entity.getId().getType() );
 
@@ -528,7 +527,7 @@ public class UniqueValuesServiceImpl implements UniqueValuesService {
     private ActorRef lookupRequestActorForType( String type ) {
         String region = getRegionsByType().get( type );
         if ( region == null ) {
-            throw new RuntimeException( "No region specified for type: " + type );
+            region = currentRegion;
         }
         ActorRef requestActor = getRequestActorsByRegion().get(region);
         if ( requestActor == null ) {
@@ -538,8 +537,8 @@ public class UniqueValuesServiceImpl implements UniqueValuesService {
     }
 
 
-    private void sendUniqueValueRequest( ApplicationScope scope, Entity entity, Field field,
-        ActorRef requestActor, UniqueValueActor.Request request) throws UniqueValueException
{
+    private void sendUniqueValueRequest(
+        Entity entity, ActorRef requestActor, UniqueValueActor.Request request) throws UniqueValueException
{
 
         int maxRetries = 5;
         int retries = 0;
@@ -588,7 +587,7 @@ public class UniqueValuesServiceImpl implements UniqueValuesService {
         if ( response.getStatus().equals( UniqueValueActor.Response.Status.NOT_UNIQUE ))
{
 
             // should result in an HTTP 409 (conflict)
-            throw new UniqueValueException( "Error property not unique", field );
+            throw new UniqueValueException( "Error property not unique", request.getField()
);
         }
     }
 }


Mime
View raw message