You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by md...@apache.org on 2015/09/26 03:42:06 UTC

[01/44] usergrid git commit: Fix push notification delivery expiration.

Repository: usergrid
Updated Branches:
  refs/heads/USERGRID-933 c035fb4c5 -> a5185f2e7


Fix push notification delivery expiration.


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

Branch: refs/heads/USERGRID-933
Commit: 1efd176325a147c82077c694bccda5af917fa23b
Parents: 3bd059c
Author: Michael Russo <mi...@gmail.com>
Authored: Thu Sep 10 15:44:08 2015 -0700
Committer: Michael Russo <mi...@gmail.com>
Committed: Thu Sep 10 15:44:08 2015 -0700

----------------------------------------------------------------------
 .../usergrid/persistence/entities/Notification.java    | 12 ++++++++----
 .../services/notifications/apns/APNsNotification.java  |  8 ++++----
 .../services/notifications/gcm/GCMAdapter.java         |  9 +++++----
 .../services/notifications/wns/WNSAdapter.java         | 13 ++++++++++---
 .../notifications/apns/NotificationsServiceIT.java     |  1 +
 .../notifications/gcm/NotificationsServiceIT.java      |  1 +
 6 files changed, 29 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/1efd1763/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
index 88b2f33..d1101a5 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
@@ -230,12 +230,16 @@ public class Notification extends TypedEntity {
         return State.CREATED;
     }
 
+    @JsonIgnore
+    public long getExpireTimeMillis() {
+        long expireAtMillis = getExpire() != null ? getExpire() * 1000 : 0;
+        return expireAtMillis;
+    }
 
     @JsonIgnore
-    public int getExpireTimeInSeconds() {
-        long expirySeconds = getExpire() != null ? getExpire() * 1000 : 0;
-        return (expirySeconds > Integer.MAX_VALUE) ? Integer.MAX_VALUE
-                : (int) expirySeconds;
+    public long getExpireTTLSeconds() {
+        Long ttlSeconds = (getExpireTimeMillis() - new Date().getTime()) / 1000;
+        return ttlSeconds > 0 ? ttlSeconds : 0;
     }
 
     @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1efd1763/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsNotification.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsNotification.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsNotification.java
index b580410..ff00e4c 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsNotification.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsNotification.java
@@ -24,7 +24,6 @@ import com.relayrides.pushy.apns.util.TokenUtil;
 import org.apache.usergrid.persistence.entities.Notification;
 import org.apache.usergrid.services.notifications.TaskTracker;
 
-import java.util.Calendar;
 import java.util.Date;
 /**
  * Standard apigee notificatton
@@ -44,12 +43,13 @@ public class APNsNotification extends SimpleApnsPushNotification {
      */
     public static APNsNotification create(String providerId, String payload, Notification notification, TaskTracker tracker) throws RuntimeException {
 
-        Calendar date  = Calendar.getInstance();
-        date.add(Calendar.SECOND, notification.getExpireTimeInSeconds());
+        // create Date object using milliseconds value
+        Date expiryDate = new Date(notification.getExpireTimeMillis());
+
       try {
           final byte[] token = TokenUtil.tokenStringToByteArray(providerId);
 
-          return new APNsNotification(tracker, date.getTime(), token, payload, notification);
+          return new APNsNotification(tracker, expiryDate, token, payload, notification);
       }catch(MalformedTokenStringException mtse){
           throw new RuntimeException("Exception converting token",mtse);
       }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1efd1763/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
index 5580ea8..df1b580 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
@@ -36,7 +36,6 @@ import org.apache.usergrid.services.notifications.TaskTracker;
 import java.io.IOException;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
 
 public class GCMAdapter implements ProviderAdapter {
 
@@ -71,9 +70,11 @@ public class GCMAdapter implements ProviderAdapter {
         Map<String,Object> map = (Map<String, Object>) payload;
         final String expiresKey = "time_to_live";
         if(!map.containsKey(expiresKey) && notification.getExpire() != null){
-            int expireSeconds = notification.getExpireTimeInSeconds();
-            expireSeconds = expireSeconds <= 2419200 ? expireSeconds : 2419200; //send the max gcm value documented here http://developer.android.com/google/gcm/adv.html#ttl
-            map.put(expiresKey, expireSeconds);
+            // ttl provided to GCM is in seconds.  calculate the difference from now
+            Long ttlSeconds = notification.getExpireTTLSeconds();
+            // max ttl for gcm is 4 weeks - https://developers.google.com/cloud-messaging/http-server-ref
+            ttlSeconds = ttlSeconds <= 2419200 ? ttlSeconds : 2419200;
+            map.put(expiresKey, ttlSeconds);
         }
         Batch batch = getBatch( map);
         batch.add(providerId, tracker);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1efd1763/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
index 1fe8f72..3ad3d35 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/wns/WNSAdapter.java
@@ -74,10 +74,15 @@ public class WNSAdapter implements ProviderAdapter {
         try {
             List<TranslatedNotification> translatedNotifications = ( List<TranslatedNotification>) payload;
             for(TranslatedNotification translatedNotification : translatedNotifications) {
+
+                // set the optional TTL value used when pushing notifications
+                WnsNotificationRequestOptional opt = new WnsNotificationRequestOptional();
+                opt.ttl = String.valueOf(notification.getExpireTTLSeconds());
+
                 switch (translatedNotification.getType()) {
                     case "toast":
                         WnsToast toast = new WnsToastBuilder().bindingTemplateToastText01(translatedNotification.getMessage().toString()).build();
-                        service.pushToast(providerId, toast);
+                        service.pushToast(providerId, opt, toast);
                         break;
                     case "badge":
                         WnsBadge badge;
@@ -86,15 +91,17 @@ public class WNSAdapter implements ProviderAdapter {
                         } else {
                             badge = new WnsBadgeBuilder().value(translatedNotification.getMessage().toString()).build();
                         }
-                        service.pushBadge(providerId, badge);
+                        service.pushBadge(providerId, opt, badge);
                         break;
                     case "raw":
                         Object message = translatedNotification.getMessage();
                         if(message instanceof String) {
                             WnsRaw raw = new WnsRawBuilder().stream(((String) message).getBytes()).build();
-                            WnsNotificationRequestOptional opt = new WnsNotificationRequestOptional();
+
+                            // set additional optional parameter for raw notifications
                             opt.cachePolicy = "cache";
                             opt.requestForStatus = "true";
+
                             WnsNotificationResponse response = service.pushRaw(providerId, opt, raw);
                             if (!response.notificationStatus.equals("received")) { // https://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx#pncodes_x_wns_notification
                                 throw new Exception(String.format("Notification failed status:%s, devicesStatus:%s, description:%s, debug flag:%s", response.notificationStatus, response.deviceConnectionStatus, response.errorDescription, response.debugTrace));

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1efd1763/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
index fc80fdf..bd248a5 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
@@ -153,6 +153,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
         app.put("payloads", payloads);
         app.put("queued", System.currentTimeMillis());
         app.put("debug",true);
+        app.put("expire", (System.currentTimeMillis() / 1000) + 300); // add 5 minutes to current time
 
         // post notification to service manager
         Entity e = app.testRequest(ServiceAction.POST, 1,"devices",device1.getUuid(), "notifications").getEntity();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1efd1763/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
index 63869ca..38a6f2e 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
@@ -153,6 +153,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
         app.put("payloads", payloads);
         app.put("queued", System.currentTimeMillis());
         app.put("debug",true);
+        app.put("expire", (System.currentTimeMillis() / 1000) + 300); // add 5 minutes to current time
 
         Entity e = app.testRequest(ServiceAction.POST, 1, "devices",device1.getUuid(),"notifications").getEntity();
         app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid());


[34/44] usergrid git commit: Fixes incorrect name issue

Posted by md...@apache.org.
Fixes incorrect name issue


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

Branch: refs/heads/USERGRID-933
Commit: 901d7c6f76fa8143c3d19d5810ca925c0cf1d5b7
Parents: 2689a01
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Sep 17 16:41:08 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Sep 17 16:41:08 2015 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/migration/CoreMigrationPlugin.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/901d7c6f/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
index b69451a..b7529f8 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
@@ -36,7 +36,7 @@ import com.google.inject.Singleton;
 @Singleton
 public class CoreMigrationPlugin extends AbstractMigrationPlugin {
 
-    public static final String PLUGIN_NAME = "collections-entity-data";
+    public static final String PLUGIN_NAME = "core-data";
 
 
 


[37/44] usergrid git commit: Changes implementation to update a connection to have the timestamp it was last POSTed.

Posted by md...@apache.org.
Changes implementation to update a connection to have the timestamp it was last POSTed.


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

Branch: refs/heads/USERGRID-933
Commit: 079ba9760f3e8d72dbf08610360d089b9ff62d47
Parents: 0c12abb
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Sep 22 16:59:25 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Sep 22 16:59:25 2015 -0600

----------------------------------------------------------------------
 .../corepersistence/CpRelationManager.java      | 34 ++++++++++++--------
 .../service/ConnectionServiceImpl.java          |  5 +--
 .../service/ConnectionServiceImplTest.java      |  4 +--
 3 files changed, 26 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/079ba976/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 1da6f75..21a2ee7 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -31,7 +31,6 @@ import org.slf4j.LoggerFactory;
 import org.springframework.util.Assert;
 
 import org.apache.usergrid.corepersistence.asyncevents.AsyncEventService;
-import org.apache.usergrid.corepersistence.pipeline.builder.PipelineBuilderFactory;
 import org.apache.usergrid.corepersistence.pipeline.read.ResultsPage;
 import org.apache.usergrid.corepersistence.results.ConnectionRefQueryExecutor;
 import org.apache.usergrid.corepersistence.results.EntityQueryExecutor;
@@ -62,7 +61,6 @@ import org.apache.usergrid.persistence.graph.Edge;
 import org.apache.usergrid.persistence.graph.GraphManager;
 import org.apache.usergrid.persistence.graph.SearchByEdge;
 import org.apache.usergrid.persistence.graph.SearchByEdgeType;
-import org.apache.usergrid.persistence.graph.impl.SimpleEdge;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchEdgeType;
@@ -697,25 +695,35 @@ public class CpRelationManager implements RelationManager {
         final GraphManager gm = managerCache.getGraphManager( applicationScope );
 
 
-        //check if the edge exists
+        //write new edge
 
+        gm.writeEdge( edge ).subscribe();
 
-        final SearchByEdge searchByEdge = new SimpleSearchByEdge(edge.getSourceNode(), edge.getType(), edge.getTargetNode(), Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, Optional.absent()  );
+        indexService.queueNewEdge( applicationScope, targetEntity, edge );
 
 
-        //only take 1 and count it.  If we don't have anything, create the edge
-        final int count = gm.loadEdgeVersions( searchByEdge ).take( 1 ).count().toBlocking().last();
+        //now read all older versions of an edge, and remove them.  Finally calling delete
+        final SearchByEdge searchByEdge =
+            new SimpleSearchByEdge( edge.getSourceNode(), edge.getType(), edge.getTargetNode(), Long.MAX_VALUE,
+                SearchByEdgeType.Order.DESCENDING, Optional.absent() );
 
-        if(count == 0) {
-            if(logger.isDebugEnabled()) {
-                logger.debug( "No edge exists between {} and {} of type {}.  Creating",
-                    new Object[] { edge.getSourceNode(), edge.getTargetNode(), edge.getType() } );
+
+        //load our versions, only retain the most recent one
+        gm.loadEdgeVersions( searchByEdge ).skip( 1 ).flatMap( edgeToDelete -> {
+            if ( logger.isDebugEnabled() ) {
+                logger.debug( "Marking edge {} for deletion", edgeToDelete );
+            }
+            return gm.markEdge( edge );
+        } ).lastOrDefault( null ).doOnNext( lastEdge -> {
+            //no op if we hit our default
+            if(lastEdge == null){
+                return;
             }
 
-            gm.writeEdge( edge ).toBlocking().last();
+            //queue up async processing
+            indexService.queueDeleteEdge( applicationScope, lastEdge );
+        }).subscribe();
 
-            indexService.queueNewEdge( applicationScope, targetEntity, edge );
-        }
 
         return connection;
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/079ba976/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
index 1b36321..927d292 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
@@ -181,9 +181,10 @@ public class ConnectionServiceImpl implements ConnectionService {
 
                     logger.debug( "Found edge {}, searching for multiple versions of edge", edge );
 
+                    //keep only the most recent
                     final SearchByEdge searchByEdge =
-                        new SimpleSearchByEdge( edge.getSourceNode(), edge.getType(), edge.getTargetNode(), 0,
-                            SearchByEdgeType.Order.ASCENDING, Optional.absent() );
+                        new SimpleSearchByEdge( edge.getSourceNode(), edge.getType(), edge.getTargetNode(), Long.MAX_VALUE,
+                            SearchByEdgeType.Order.DESCENDING, Optional.absent() );
                     return gm.loadEdgeVersions( searchByEdge )
                         //skip the first version since it's the one we want to retain
                         .skip( 1 )

http://git-wip-us.apache.org/repos/asf/usergrid/blob/079ba976/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
index a2c18b1..326e128 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
@@ -196,7 +196,7 @@ public class ConnectionServiceImplTest {
         //check our oldest was deleted first
         assertEdgeData( written2, deletedConnections.get( 0 ).getEdge() );
 
-        assertEdgeData( written3, deletedConnections.get( 1 ).getEdge() );
+        assertEdgeData( written1, deletedConnections.get( 1 ).getEdge() );
 
         assertEquals( "2 edges deleted", 2, deletedConnections.size() );
 
@@ -213,7 +213,7 @@ public class ConnectionServiceImplTest {
 
         assertEquals( 1, edges.size() );
 
-        assertEquals( written1, edges.get( 0 ) );
+        assertEquals( written3, edges.get( 0 ) );
     }
 
 


[08/44] usergrid git commit: Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into two-dot-o-dev

Posted by md...@apache.org.
Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into two-dot-o-dev


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

Branch: refs/heads/USERGRID-933
Commit: c3c71c91472045789f06e525d1028061240e0613
Parents: 98e76ae f24e7e4
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Sep 11 17:11:07 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Sep 11 17:11:07 2015 -0600

----------------------------------------------------------------------
 .../asyncevents/AmazonAsyncEventService.java       |  6 +++---
 stack/scripts/migrate_entity_data.py               | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------



[07/44] usergrid git commit: removing noop exceptions, removing failures due to bad location fields

Posted by md...@apache.org.
removing noop exceptions, removing failures due to bad location fields


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

Branch: refs/heads/USERGRID-933
Commit: 98e76ae897484fe8eae2cd0e215b365d23c4916a
Parents: cf6cf83
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Sep 11 17:10:59 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Sep 11 17:10:59 2015 -0600

----------------------------------------------------------------------
 .../model/entity/MapToEntityConverter.java      | 39 ++++++++------------
 .../exceptions/AbstractExceptionMapper.java     | 13 +++++--
 2 files changed, 25 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/98e76ae8/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
index 09cf1f2..e6744c4 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
@@ -163,14 +163,11 @@ public class MapToEntityConverter{
     }
 
 
-    private  void processMapValue(
-            Object value, String fieldName, Entity entity) {
+    private  void processMapValue( Object value, String fieldName, Entity entity) {
 
         // is the map really a location element?
         if ("location" .equals(fieldName.toString().toLowerCase()) ) {
             processLocationField((Map<String, Object>) value, fieldName, entity);
-
-
         } else {
             // not a location element, process it as map
             entity.setField(new EntityObjectField(fieldName,
@@ -187,48 +184,44 @@ public class MapToEntityConverter{
         Map<String, Object> m = new HashMap<String, Object>();
 
         // Tests expect us to treat "Longitude" the same as "longitude"
-        for ( String key : origMap.keySet() ) {
-            m.put( key.toLowerCase(), origMap.get(key) );
+        for (String key : origMap.keySet()) {
+            m.put(key.toLowerCase(), origMap.get(key));
         }
 
-        // Expect at least two fields in a Location object
-        if (m.size() >= 2) {
+        // Expect at least two fields in a Location object and must have lat lon
+        if (m.size() >= 2 && (
+            (m.containsKey("latitude")  && m.containsKey("longitude") )
+                || (m.containsKey("lat") && m.containsKey("lon") )
+        )) {
 
-            Double lat = null;
-            Double lon = null;
+            Double lat, lon;
 
             // check the properties to make sure they are set and are doubles
-            if (m.get("latitude") != null && m.get("longitude") != null) {
+            if (m.containsKey("latitude")  && m.containsKey("longitude")) {
                 try {
                     lat = Double.parseDouble(m.get("latitude").toString());
                     lon = Double.parseDouble(m.get("longitude").toString());
 
                 } catch (NumberFormatException ignored) {
                     throw new IllegalArgumentException(
-                            "Latitude and longitude must be doubles (e.g. 32.1234).");
+                        "Latitude and longitude must be doubles (e.g. 32.1234).");
                 }
-            } else if (m.get("lat") != null && m.get("lon") != null) {
+            } else if (m.containsKey("lat") && m.containsKey("lon")) {
                 try {
                     lat = Double.parseDouble(m.get("lat").toString());
                     lon = Double.parseDouble(m.get("lon").toString());
                 } catch (NumberFormatException ignored) {
                     throw new IllegalArgumentException(""
-                            + "Latitude and longitude must be doubles (e.g. 32.1234).");
+                        + "Latitude and longitude must be doubles (e.g. 32.1234).");
                 }
             } else {
                 throw new IllegalArgumentException("Location properties require two fields - "
-                        + "latitude and longitude, or lat and lon");
+                    + "latitude and longitude, or lat and lon");
             }
 
-            if (lat != null && lon != null) {
-                entity.setField( new LocationField(fieldName, new Location(lat, lon)));
-            } else {
-                throw new IllegalArgumentException( "Unable to parse location field properties "
-                        + "- make sure they conform - lat and lon, and should be doubles.");
-            }
+            entity.setField(new LocationField(fieldName, new Location(lat, lon)));
         } else {
-            throw new IllegalArgumentException("Location properties requires two fields - "
-                    + "latitude and longitude, or lat and lon.");
+            entity.setField(new EntityObjectField(fieldName,fromMap( value, false))); // recursion
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/98e76ae8/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/AbstractExceptionMapper.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/AbstractExceptionMapper.java b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/AbstractExceptionMapper.java
index 77760e0..1dbffbd 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/AbstractExceptionMapper.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/AbstractExceptionMapper.java
@@ -49,7 +49,7 @@ public abstract class AbstractExceptionMapper<E extends java.lang.Throwable> imp
 
 
     public boolean isJSONP() {
-        return isJavascript( hh.getAcceptableMediaTypes() );
+        return isJavascript(hh.getAcceptableMediaTypes());
     }
 
 
@@ -71,13 +71,18 @@ public abstract class AbstractExceptionMapper<E extends java.lang.Throwable> imp
             // only log real errors as errors
             logger.error( e.getClass().getCanonicalName() + " Server Error (" + status + ")", e );
 
-        } else if ( logger.isDebugEnabled() ) {
-            logger.debug( e.getClass().getCanonicalName() + " Server Error (" + status + ")", e );
+        } else {
+            if (logger.isDebugEnabled()) {
+                logger.debug(e.getClass().getCanonicalName() + " Server Error (" + status + ")", e);
+            }
+            switch (status){
+                case 200 : logger.info("Uncaught Exception", e); break;
+                default: logger.error("Uncaught Exception", e);
+            }
         }
 
         ApiResponse response = new ApiResponse();
 
-        logger.error("Uncaught Exception", e);
 
         AuthErrorInfo authError = AuthErrorInfo.getForException( e );
 


[06/44] usergrid git commit: Updating EdgeDeleteEvent

Posted by md...@apache.org.
Updating EdgeDeleteEvent


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

Branch: refs/heads/USERGRID-933
Commit: f24e7e40cbd4f55154f4585d795a793d870c528f
Parents: 66ba6b4
Author: Michael Russo <mi...@gmail.com>
Authored: Fri Sep 11 13:35:51 2015 -0700
Committer: Michael Russo <mi...@gmail.com>
Committed: Fri Sep 11 13:35:51 2015 -0700

----------------------------------------------------------------------
 .../corepersistence/asyncevents/AmazonAsyncEventService.java   | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/f24e7e40/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AmazonAsyncEventService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AmazonAsyncEventService.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AmazonAsyncEventService.java
index 71834c3..fcb93c9 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AmazonAsyncEventService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AmazonAsyncEventService.java
@@ -354,10 +354,10 @@ public class AmazonAsyncEventService implements AsyncEventService {
         Preconditions.checkArgument(event instanceof EdgeDeleteEvent, String.format("Event Type for handleEdgeDelete must be EDGE_DELETE, got %s", event.getClass()));
 
 
-        final EdgeIndexEvent edgeIndexEvent = ( EdgeIndexEvent ) event;
+        final EdgeDeleteEvent edgeDeleteEvent = ( EdgeDeleteEvent ) event;
 
-        final ApplicationScope applicationScope = edgeIndexEvent.getApplicationScope();
-        final Edge edge = edgeIndexEvent.getEdge();
+        final ApplicationScope applicationScope = edgeDeleteEvent.getApplicationScope();
+        final Edge edge = edgeDeleteEvent.getEdge();
 
         if (logger.isDebugEnabled()) logger.debug("Deleting in app scope {} with edge {}", applicationScope, edge);
 


[14/44] usergrid git commit: handle errors

Posted by md...@apache.org.
handle errors


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

Branch: refs/heads/USERGRID-933
Commit: 001a7e385f3e96d9d6a43b99344aa128c64f87c0
Parents: 5680173
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Sep 14 13:34:04 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Sep 14 13:34:04 2015 -0600

----------------------------------------------------------------------
 .../rx/impl/AllApplicationsObservableImpl.java  | 36 +++-----
 .../migration/MvccEntityDataMigrationImpl.java  | 94 +++++++++++---------
 .../model/entity/MapToEntityConverter.java      |  4 +-
 3 files changed, 66 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/001a7e38/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/AllApplicationsObservableImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/AllApplicationsObservableImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/AllApplicationsObservableImpl.java
index 9c766a8..e54da0c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/AllApplicationsObservableImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/AllApplicationsObservableImpl.java
@@ -93,37 +93,27 @@ public class AllApplicationsObservableImpl implements AllApplicationsObservable
         //we have app infos.  For each of these app infos, we have to load the application itself
         Observable<ApplicationScope> appIds = gm.loadEdgesFromSource(
             new SimpleSearchByEdgeType( rootAppId, edgeType, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING,
-                Optional.absent() ) ).flatMap( new Func1<Edge, Observable<ApplicationScope>>() {
-            @Override
-            public Observable<ApplicationScope> call( final Edge edge ) {
-
-                //get the app info and load it
-                final Id appInfo = edge.getTargetNode();
-
-                return collectionManager.load( appInfo )
-                    //filter out null entities
-                    .filter( new Func1<Entity, Boolean>() {
-                        @Override
-                        public Boolean call( final Entity entity ) {
+                Optional.absent() ) ).flatMap(edge -> {
+
+                    //get the app info and load it
+                    final Id appInfo = edge.getTargetNode();
+
+                    return collectionManager.load( appInfo )
+                        //filter out null entities
+                        .filter(entity -> {
                             if ( entity == null ) {
                                 logger.warn( "Encountered a null application info for id {}", appInfo );
                                 return false;
                             }
 
                             return true;
-                        }
-                    } )
-                        //get the id from the entity
-                    .map( new Func1<Entity, ApplicationScope>() {
-
-                        @Override
-                        public ApplicationScope call( final Entity entity ) {
+                        })
+                            //get the id from the entity
+                        .map(entity -> {
                             final UUID uuid =entity.getId().getUuid();
                             return getApplicationScope( uuid );
-                        }
-                    } );
-            }
-        } );
+                        });
+                });
 
         return Observable.merge( systemIds, appIds );
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/001a7e38/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
index e825bbc..86fd701 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
@@ -142,9 +142,13 @@ public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope>
                         EntityToSaveMessage> subscriber ) {
 
                         while ( allVersions.hasNext() ) {
-                            final EntityToSaveMessage message =
-                                new EntityToSaveMessage( currentScope, allVersions.next() );
-                            subscriber.onNext( message );
+                            try {
+                                final EntityToSaveMessage message =
+                                    new EntityToSaveMessage(currentScope, allVersions.next());
+                                subscriber.onNext(message);
+                            }catch (Exception e){
+                                LOGGER.error("Failed to load entity " +entityIdScope.getId(),e);
+                            }
                         }
 
                         subscriber.onCompleted();
@@ -159,62 +163,66 @@ public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope>
 
 
                         for ( EntityToSaveMessage message : entities ) {
-                            final MutationBatch entityRewrite = migration.to.write( message.scope, message.entity );
+                            try {
+                                final MutationBatch entityRewrite = migration.to.write(message.scope, message.entity);
 
-                            //add to
-                            // the
-                            // total
-                            // batch
-                            totalBatch.mergeShallow( entityRewrite );
+                                //add to
+                                // the
+                                // total
+                                // batch
+                                totalBatch.mergeShallow(entityRewrite);
 
-                            //write
-                            // the
-                            // unique values
+                                //write
+                                // the
+                                // unique values
 
-                            if ( !message.entity.getEntity().isPresent() ) {
-                                return;
-                            }
+                                if (!message.entity.getEntity().isPresent()) {
+                                    return;
+                                }
 
-                            final Entity entity = message.entity.getEntity().get();
+                                final Entity entity = message.entity.getEntity().get();
 
-                            final Id entityId = entity.getId();
+                                final Id entityId = entity.getId();
 
-                            final UUID version = message.entity.getVersion();
+                                final UUID version = message.entity.getVersion();
 
 
-                            toSaveIds.add( entityId );
+                                toSaveIds.add(entityId);
 
-                            // re-write the unique
-                            // values
-                            // but this
-                            // time with
-                            // no TTL so that cleanup can clean up
-                            // older values
-                            for (final Field field : EntityUtils.getUniqueFields( message.entity.getEntity().get() ) ) {
+                                // re-write the unique
+                                // values
+                                // but this
+                                // time with
+                                // no TTL so that cleanup can clean up
+                                // older values
+                                for (final Field field : EntityUtils.getUniqueFields(message.entity.getEntity().get())) {
 
-                                final UniqueValue written = new UniqueValueImpl( field, entityId, version );
+                                    final UniqueValue written = new UniqueValueImpl(field, entityId, version);
 
-                                final MutationBatch mb = uniqueValueSerializationStrategy.write( message.scope, written );
+                                    final MutationBatch mb = uniqueValueSerializationStrategy.write(message.scope, written);
 
 
-                                // merge into our
-                                // existing mutation
-                                // batch
-                                totalBatch.mergeShallow( mb );
-                            }
+                                    // merge into our
+                                    // existing mutation
+                                    // batch
+                                    totalBatch.mergeShallow(mb);
+                                }
 
 
-                            //add all our log entries
-                            final List<MvccLogEntry> logEntries = mvccLogEntrySerializationStrategy.load( message.scope,
-                                message.entity.getId(), version, 1000 );
+                                //add all our log entries
+                                final List<MvccLogEntry> logEntries = mvccLogEntrySerializationStrategy.load(message.scope,
+                                    message.entity.getId(), version, 1000);
 
-                            /**
-                             * Migrate the log entry to the new format
-                             */
-                            for(final MvccLogEntry entry: logEntries){
-                                final MutationBatch mb = mvccLogEntrySerializationStrategy.write( message.scope, entry );
+                                /**
+                                 * Migrate the log entry to the new format
+                                 */
+                                for (final MvccLogEntry entry : logEntries) {
+                                    final MutationBatch mb = mvccLogEntrySerializationStrategy.write(message.scope, entry);
 
-                                totalBatch.mergeShallow( mb );
+                                    totalBatch.mergeShallow(mb);
+                                }
+                            }catch (Exception e){
+                                LOGGER.error("Failed to migrate entity "+ message.entity.getId().getUuid()+ " :: " + message.entity.getId().getType(),e);
                             }
 
 
@@ -232,7 +240,7 @@ public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope>
 
 
                         }
-                    } ).subscribeOn( Schedulers.io() );
+                    } ).subscribeOn(Schedulers.io());
 
             }, 10) );
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/001a7e38/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
index dbd1b2a..c0db81b 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
@@ -238,9 +238,9 @@ public class MapToEntityConverter{
         } else {
             //can't process non enties
             logger.warn(
-                "entity cannot process location values that don't have valid location{latitude,longitude} values"
+                "entity cannot process location values that don't have valid location{latitude,longitude} values, changing to generic object"
             );
-           // entity.setField(new EntityObjectField(fieldName,fromMap( value, false))); // recursion
+            entity.setField(new EntityObjectField(fieldName,fromMap( value, false))); // recursion
         }
     }
 }


[13/44] usergrid git commit: Add note that notification expiration timestamp is specified in seconds.

Posted by md...@apache.org.
Add note that notification expiration timestamp is specified in seconds.


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

Branch: refs/heads/USERGRID-933
Commit: 2faa805672721bc2d56eaa3b9e2d28fb7f1a6bec
Parents: 7eb997b
Author: Dave Johnson <sn...@apache.org>
Authored: Mon Sep 14 09:31:11 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Mon Sep 14 09:31:11 2015 -0400

----------------------------------------------------------------------
 docs/push-notifications/creating-and-managing-notifications.md | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/2faa8056/docs/push-notifications/creating-and-managing-notifications.md
----------------------------------------------------------------------
diff --git a/docs/push-notifications/creating-and-managing-notifications.md b/docs/push-notifications/creating-and-managing-notifications.md
index 72a2021..501dbee 100644
--- a/docs/push-notifications/creating-and-managing-notifications.md
+++ b/docs/push-notifications/creating-and-managing-notifications.md
@@ -189,6 +189,8 @@ Please note that if the expire property is not set and Apple APNS or Google GCM
 Request body syntax
 
     '{"expire":<unix_timestamp>,"payloads":{"<notifier_name>":"<message>"}}'
+    
+NOTE: The timestamp is a UNIX timestamp and is specified in seconds.
 
 
 ## Getting notifications


[33/44] usergrid git commit: Removes obsolete plugins.

Posted by md...@apache.org.
Removes obsolete plugins.

Adds tests and implements entity-data plugin.


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

Branch: refs/heads/USERGRID-933
Commit: 2689a015938e6b05ceb6f6cc2c228f61cb5e3b17
Parents: acbf3a1
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Sep 17 16:17:43 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Sep 17 16:17:43 2015 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/CoreModule.java    |  53 +++++--
 .../migration/CoreMigration.java                |  45 ++----
 .../migration/CoreMigrationPlugin.java          |  31 ++--
 .../migration/DeDupConnectionDataMigration.java |  93 ++++++++++++
 .../migration/EntityTypeMappingMigration.java   | 104 --------------
 .../corepersistence/migration/Versions.java     |  31 ----
 .../DeDupConnectionDataMigrationTest.java       | 144 +++++++++++++++++++
 .../migration/EntityTypeMappingMigrationIT.java | 125 ----------------
 .../migration/data/TestProgressObserver.java    |  10 +-
 9 files changed, 314 insertions(+), 322 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
index 7ed95e2..11707be 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
@@ -16,22 +16,43 @@
 package org.apache.usergrid.corepersistence;
 
 
-import com.google.inject.AbstractModule;
-import com.google.inject.TypeLiteral;
-import com.google.inject.assistedinject.FactoryModuleBuilder;
-import com.google.inject.multibindings.Multibinder;
+import org.safehaus.guicyfig.GuicyFigModule;
+
 import org.apache.usergrid.corepersistence.asyncevents.AsyncEventService;
 import org.apache.usergrid.corepersistence.asyncevents.AsyncIndexProvider;
 import org.apache.usergrid.corepersistence.asyncevents.EventBuilder;
 import org.apache.usergrid.corepersistence.asyncevents.EventBuilderImpl;
-import org.apache.usergrid.corepersistence.index.*;
+import org.apache.usergrid.corepersistence.index.ApplicationIndexBucketLocator;
+import org.apache.usergrid.corepersistence.index.CoreIndexFig;
+import org.apache.usergrid.corepersistence.index.IndexLocationStrategyFactory;
+import org.apache.usergrid.corepersistence.index.IndexLocationStrategyFactoryImpl;
+import org.apache.usergrid.corepersistence.index.IndexProcessorFig;
+import org.apache.usergrid.corepersistence.index.IndexService;
+import org.apache.usergrid.corepersistence.index.IndexServiceImpl;
+import org.apache.usergrid.corepersistence.index.ReIndexService;
+import org.apache.usergrid.corepersistence.index.ReIndexServiceImpl;
 import org.apache.usergrid.corepersistence.migration.CoreMigration;
 import org.apache.usergrid.corepersistence.migration.CoreMigrationPlugin;
-import org.apache.usergrid.corepersistence.migration.EntityTypeMappingMigration;
+import org.apache.usergrid.corepersistence.migration.DeDupConnectionDataMigration;
 import org.apache.usergrid.corepersistence.migration.MigrationModuleVersionPlugin;
 import org.apache.usergrid.corepersistence.pipeline.PipelineModule;
-import org.apache.usergrid.corepersistence.rx.impl.*;
-import org.apache.usergrid.corepersistence.service.*;
+import org.apache.usergrid.corepersistence.rx.impl.AllApplicationsObservable;
+import org.apache.usergrid.corepersistence.rx.impl.AllApplicationsObservableImpl;
+import org.apache.usergrid.corepersistence.rx.impl.AllEntitiesInSystemImpl;
+import org.apache.usergrid.corepersistence.rx.impl.AllEntityIdsObservable;
+import org.apache.usergrid.corepersistence.rx.impl.AllEntityIdsObservableImpl;
+import org.apache.usergrid.corepersistence.rx.impl.AllNodesInGraphImpl;
+import org.apache.usergrid.corepersistence.service.AggregationService;
+import org.apache.usergrid.corepersistence.service.AggregationServiceFactory;
+import org.apache.usergrid.corepersistence.service.AggregationServiceImpl;
+import org.apache.usergrid.corepersistence.service.ApplicationService;
+import org.apache.usergrid.corepersistence.service.ApplicationServiceImpl;
+import org.apache.usergrid.corepersistence.service.CollectionService;
+import org.apache.usergrid.corepersistence.service.CollectionServiceImpl;
+import org.apache.usergrid.corepersistence.service.ConnectionService;
+import org.apache.usergrid.corepersistence.service.ConnectionServiceImpl;
+import org.apache.usergrid.corepersistence.service.StatusService;
+import org.apache.usergrid.corepersistence.service.StatusServiceImpl;
 import org.apache.usergrid.persistence.collection.guice.CollectionModule;
 import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
 import org.apache.usergrid.persistence.core.guice.CommonModule;
@@ -42,7 +63,11 @@ import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.graph.guice.GraphModule;
 import org.apache.usergrid.persistence.graph.serialization.impl.migration.GraphNode;
 import org.apache.usergrid.persistence.index.guice.IndexModule;
-import org.safehaus.guicyfig.GuicyFigModule;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.TypeLiteral;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+import com.google.inject.multibindings.Multibinder;
 
 
 /**
@@ -105,7 +130,7 @@ public class CoreModule  extends AbstractModule {
                         new TypeLiteral<DataMigration>() {}, CoreMigration.class );
 
 
-        dataMigrationMultibinder.addBinding().to( EntityTypeMappingMigration.class );
+        dataMigrationMultibinder.addBinding().to( DeDupConnectionDataMigration.class );
 
 
         //wire up the collection migration plugin
@@ -164,6 +189,14 @@ public class CoreModule  extends AbstractModule {
         bind( ApplicationService.class ).to( ApplicationServiceImpl.class );
 
         bind( StatusService.class ).to( StatusServiceImpl.class );
+
+        /**
+         * Install migration services
+         */
+
+          //migrations
+        //we want to make sure our generics are retained, so we use a typeliteral
+
     }
 
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigration.java
index 4df32da..b491e1f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigration.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigration.java
@@ -1,40 +1,21 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
-package org.apache.usergrid.corepersistence.migration;/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
+package org.apache.usergrid.corepersistence.migration;
 
 
 import java.lang.annotation.Retention;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
index 810f9fb..b69451a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
@@ -1,20 +1,18 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 package org.apache.usergrid.corepersistence.migration;
@@ -22,9 +20,10 @@ package org.apache.usergrid.corepersistence.migration;
 
 import java.util.Set;
 
-import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
+import org.apache.usergrid.persistence.collection.serialization.impl.migration.CollectionMigration;
 import org.apache.usergrid.persistence.core.migration.data.AbstractMigrationPlugin;
 import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
 import org.apache.usergrid.persistence.core.migration.data.PluginPhase;
 
 import com.google.inject.Inject;
@@ -37,7 +36,7 @@ import com.google.inject.Singleton;
 @Singleton
 public class CoreMigrationPlugin extends AbstractMigrationPlugin {
 
-    public static final String PLUGIN_NAME = "core-data";
+    public static final String PLUGIN_NAME = "collections-entity-data";
 
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java
new file mode 100644
index 0000000..f65864a
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.corepersistence.migration;
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.usergrid.corepersistence.rx.impl.AllApplicationsObservable;
+import org.apache.usergrid.corepersistence.service.ConnectionService;
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+import org.apache.usergrid.persistence.core.migration.data.ProgressObserver;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+
+@Singleton
+public class DeDupConnectionDataMigration implements DataMigration {
+
+    private static final Logger logger = LoggerFactory.getLogger(DeDupConnectionDataMigration.class);
+
+    private static final long UPDATE_COUNT = 1000;
+
+    private final ConnectionService connectionService;
+    private final AllApplicationsObservable allApplicationsObservable;
+
+
+    @Inject
+    public DeDupConnectionDataMigration( final ConnectionService connectionService,
+                                         final AllApplicationsObservable allApplicationsObservable ) {
+        this.connectionService = connectionService;
+        this.allApplicationsObservable = allApplicationsObservable;
+    }
+
+
+    @Override
+    public int migrate( final int currentVersion, final ProgressObserver observer ) {
+
+        final int migrationVersion = getMaxVersion();
+
+        observer.start();
+
+        connectionService.deDupeConnections( allApplicationsObservable.getData() ).reduce( 0l, (count, deDuped) ->{
+
+            final long newCount = count+1;
+
+            /**
+             * Update our progress observer
+             */
+            if(newCount % UPDATE_COUNT == 0){
+                logger.info( "De duped {} edges", newCount );
+                observer.update( migrationVersion, String.format("De duped %d edges", newCount) );
+            }
+
+            return newCount;
+
+        }).doOnNext( total -> {
+            logger.info("Completed de-duping {} edges", total );
+            observer.complete();;
+        }).subscribe();
+
+        return migrationVersion;
+
+    }
+
+
+    @Override
+    public boolean supports( final int currentVersion ) {
+        return currentVersion == getMaxVersion() - 1;
+    }
+
+
+    @Override
+    public int getMaxVersion() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
deleted file mode 100644
index ef65ff2..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.usergrid.corepersistence.migration;
-
-
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.apache.usergrid.corepersistence.ManagerCache;
-import org.apache.usergrid.corepersistence.util.CpNamingUtils;
-import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
-import org.apache.usergrid.persistence.core.migration.data.DataMigration;
-import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
-import org.apache.usergrid.persistence.core.migration.data.ProgressObserver;
-import org.apache.usergrid.persistence.map.MapManager;
-import org.apache.usergrid.persistence.map.MapScope;
-
-import com.google.inject.Inject;
-
-import rx.Observable;
-import rx.schedulers.Schedulers;
-
-
-/**
- * Migration to ensure that our entity id is written into our map data
- */
-public class EntityTypeMappingMigration implements DataMigration {
-
-    private final ManagerCache managerCache;
-    private final MigrationDataProvider<EntityIdScope> allEntitiesInSystemObservable;
-
-
-    @Inject
-    public EntityTypeMappingMigration( final ManagerCache managerCache,
-                                       final MigrationDataProvider<EntityIdScope> allEntitiesInSystemObservable ) {
-        this.managerCache = managerCache;
-        this.allEntitiesInSystemObservable = allEntitiesInSystemObservable;
-    }
-
-
-    @Override
-    public int migrate( final int currentVersion,
-                        final ProgressObserver observer ) {
-
-        final AtomicLong atomicLong = new AtomicLong();
-
-
-        //migrate up to 100 types simultaneously
-        allEntitiesInSystemObservable.getData().flatMap( entityIdScope -> {
-            return Observable.just( entityIdScope ).doOnNext( entityIdScopeObservable -> {
-                final MapScope ms = CpNamingUtils
-                                                 .getEntityTypeMapScope( entityIdScope.getApplicationScope().getApplication() );
-
-                                             final MapManager mapManager = managerCache.getMapManager( ms );
-
-                                             final UUID entityUuid = entityIdScope.getId().getUuid();
-                                             final String entityType = entityIdScope.getId().getType();
-
-                                             mapManager.putString( entityUuid.toString(), entityType );
-
-                                             if ( atomicLong.incrementAndGet() % 100 == 0 ) {
-                                                 observer.update( getMaxVersion(),
-                                                     String.format( "Updated %d entities", atomicLong.get() ) );
-                                             }
-
-            } ).subscribeOn( Schedulers.io() );
-        }, 100 ).count().toBlocking().last();
-
-
-        return getMaxVersion();
-
-
-    }
-
-
-    @Override
-    public boolean supports( final int currentVersion ) {
-        //we move from the migration version fix to the current version
-        return CoreDataVersions.INITIAL.getVersion() == currentVersion;
-    }
-
-
-    @Override
-    public int getMaxVersion() {
-        return CoreDataVersions.ID_MAP_FIX.getVersion();
-    }
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/Versions.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/Versions.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/Versions.java
deleted file mode 100644
index d921353..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/Versions.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *
- */
-
-package org.apache.usergrid.corepersistence.migration;
-
-
-/**
- * Simple class to hold the constants of all versions
- */
-public class Versions {
-
-
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java
new file mode 100644
index 0000000..c84ad2b
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.corepersistence.migration;
+
+
+import java.util.List;
+
+import org.junit.Test;
+
+import org.apache.usergrid.corepersistence.rx.impl.AllApplicationsObservable;
+import org.apache.usergrid.corepersistence.service.ConnectionScope;
+import org.apache.usergrid.corepersistence.service.ConnectionService;
+import org.apache.usergrid.corepersistence.util.CpNamingUtils;
+import org.apache.usergrid.persistence.core.migration.data.TestProgressObserver;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
+import org.apache.usergrid.persistence.graph.Edge;
+
+import rx.Observable;
+import rx.Subscriber;
+
+import static org.apache.usergrid.persistence.core.util.IdGenerator.createId;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+
+public class DeDupConnectionDataMigrationTest {
+
+    @Test
+    public void testVersion() {
+
+        //mock up an initial system state
+        final int version = 0;
+
+        final ConnectionService connectionService = mock( ConnectionService.class );
+
+        final AllApplicationsObservable allApplicationsObservable = mock( AllApplicationsObservable.class );
+
+
+        final DeDupConnectionDataMigration plugin =
+            new DeDupConnectionDataMigration( connectionService, allApplicationsObservable );
+
+
+        assertTrue( plugin.supports( version ) );
+
+        assertFalse( plugin.supports( plugin.getMaxVersion() ) );
+    }
+
+
+    /**
+     * Test
+     */
+    @Test
+    public void testEmitEdges() {
+
+        //mock up an initial system state
+        final int version = 0;
+
+        final ConnectionService connectionService = mock( ConnectionService.class );
+
+
+        final AllApplicationsObservable allApplicationsObservable = mock( AllApplicationsObservable.class );
+
+
+        final int count = 3000;
+
+        final Observable<ConnectionScope> edgeEmitter = Observable.create( new DupConnectionEmitter( count ) );
+
+        when( connectionService.deDupeConnections( any( Observable.class ) ) ).thenReturn( edgeEmitter );
+
+
+        final DeDupConnectionDataMigration plugin =
+            new DeDupConnectionDataMigration( connectionService, allApplicationsObservable );
+
+
+        final TestProgressObserver testProgressObserver = new TestProgressObserver();
+
+
+        plugin.migrate( version, testProgressObserver );
+
+        final List<String> updates = testProgressObserver.getUpdates();
+
+        assertEquals( "Expected 3 updates", 3, updates.size() );
+
+
+        assertEquals( "De duped 1000 edges", updates.get( 0 ) );
+        assertEquals( "De duped 2000 edges", updates.get( 1 ) );
+        assertEquals( "De duped 3000 edges", updates.get( 2 ) );
+
+
+        assertTrue( "Should complete", testProgressObserver.isComplete() );
+        assertTrue( "Should start", testProgressObserver.isStarted() );
+        assertFalse( "Should not fail", testProgressObserver.isFailed() );
+    }
+
+
+    private final class DupConnectionEmitter implements Observable.OnSubscribe<ConnectionScope> {
+
+
+        private final int count;
+
+
+        private DupConnectionEmitter( final int count ) {this.count = count;}
+
+
+        @Override
+        public void call( final Subscriber<? super ConnectionScope> subscriber ) {
+
+            final ApplicationScope applicationScope = new ApplicationScopeImpl( createId( "application" ) );
+            final Edge edge = CpNamingUtils.createConnectionEdge( createId( "source" ), "test", createId( "target" ) );
+
+
+            final ConnectionScope scope = new ConnectionScope( applicationScope, edge );
+
+
+            subscriber.onStart();
+
+            for ( int i = 0; i < count; i++ ) {
+                subscriber.onNext( scope );
+            }
+
+            subscriber.onCompleted();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
deleted file mode 100644
index 7d22abe..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.usergrid.corepersistence.migration;
-
-
-import org.junit.Test;
-
-import org.apache.usergrid.AbstractCoreIT;
-import org.apache.usergrid.corepersistence.ManagerCache;
-import org.apache.usergrid.corepersistence.util.CpNamingUtils;
-import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
-import org.apache.usergrid.persistence.core.migration.data.TestMigrationDataProvider;
-import org.apache.usergrid.persistence.core.migration.data.TestProgressObserver;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
-import org.apache.usergrid.persistence.map.MapManager;
-import org.apache.usergrid.persistence.map.MapScope;
-import org.apache.usergrid.persistence.map.impl.MapScopeImpl;
-import org.apache.usergrid.persistence.model.entity.Id;
-
-import rx.Observable;
-
-import static org.apache.usergrid.persistence.core.util.IdGenerator.createId;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-
-/**
- * Test for our entity type mapping
- */
-public class EntityTypeMappingMigrationIT  {
-
-
-    @Test
-    public void testIdMapping() throws Throwable {
-
-        final Id applicationId = createId("application");
-
-        final ApplicationScope scope1 = new ApplicationScopeImpl( applicationId );
-
-        final Id entityId1 = createId("thing");
-
-        final EntityIdScope idScope1 = new EntityIdScope(scope1, entityId1 );
-
-        final MapScope mapScope1 = new MapScopeImpl(applicationId, CpNamingUtils.TYPES_BY_UUID_MAP );
-
-
-
-        final ApplicationScope scope2 = new ApplicationScopeImpl( applicationId);
-
-        final Id entityId2 = createId("foo");
-
-        final EntityIdScope idScope2 = new EntityIdScope( scope2, entityId2 );
-
-        final MapScope mapScope2 = new MapScopeImpl(applicationId, CpNamingUtils.TYPES_BY_UUID_MAP );
-
-
-        final Observable<EntityIdScope> scopes = Observable.just(idScope1, idScope2);
-
-        final TestMigrationDataProvider<EntityIdScope> migrationDataProvider = new TestMigrationDataProvider<>();
-
-        //set our scopes
-        migrationDataProvider.setObservable( scopes );
-
-
-
-
-        //mock up returning our map manager
-        final MapManager mapManager = mock(MapManager.class);
-        final ManagerCache managerCache = mock(ManagerCache.class);
-
-        when(managerCache.getMapManager( eq( mapScope1 ) )).thenReturn( mapManager );
-
-        when(managerCache.getMapManager( eq( mapScope2 ) )).thenReturn( mapManager );
-
-        final TestProgressObserver progressObserver = new TestProgressObserver();
-
-
-        //wire it up
-        final EntityTypeMappingMigration migration = new EntityTypeMappingMigration( managerCache, migrationDataProvider );
-
-        //run it
-
-        final int returnedVersion = migration.migrate(CoreDataVersions.INITIAL.getVersion(), progressObserver );
-
-
-        assertEquals(CoreDataVersions.ID_MAP_FIX.getVersion(), returnedVersion);
-
-        //verify we saved it
-
-        verify(mapManager).putString(entityId1.getUuid().toString(), entityId1.getType()  );
-
-        verify(mapManager).putString(entityId2.getUuid().toString(), entityId2.getType()  );
-
-
-
-
-
-
-
-
-
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/migration/data/TestProgressObserver.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/migration/data/TestProgressObserver.java b/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/migration/data/TestProgressObserver.java
index 7f59151..21d6013 100644
--- a/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/migration/data/TestProgressObserver.java
+++ b/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/migration/data/TestProgressObserver.java
@@ -30,19 +30,21 @@ public class TestProgressObserver implements ProgressObserver {
 
     private boolean started = false;
 
+    private boolean complete = false;
+
 
     private List<String> updates = new ArrayList<>( 100 );
 
 
     @Override
     public void start() {
-         started = true;
+        started = true;
     }
 
 
     @Override
     public void complete() {
-        started = false;
+        complete = true;
     }
 
 
@@ -66,7 +68,6 @@ public class TestProgressObserver implements ProgressObserver {
 
     /**
      * Get if we failed
-     * @return
      */
     public boolean isFailed() {
         return failed;
@@ -78,10 +79,11 @@ public class TestProgressObserver implements ProgressObserver {
     }
 
 
+    public boolean isComplete() { return complete;}
+
 
     /**
      * Get update messages
-     * @return
      */
     public List<String> getUpdates() {
         return updates;


[27/44] usergrid git commit: Fixing weird formatting in license headers, no code changes. This closes #385.

Posted by md...@apache.org.
Fixing weird formatting in license headers, no code changes. This closes #385.


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

Branch: refs/heads/USERGRID-933
Commit: 65d2608e8fd18ecec1edfce4d41cf2296bf3cc1a
Parents: a562079
Author: Dave Johnson <sn...@apache.org>
Authored: Wed Sep 16 10:45:12 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Wed Sep 16 10:45:12 2015 -0400

----------------------------------------------------------------------
 .../persistence/index/CandidateResult.java      | 32 ++++++++---------
 .../persistence/index/CandidateResults.java     | 34 ++++++++----------
 .../SearchRequestBuilderStrategyV2.java         | 30 ++++++++--------
 .../usergrid/persistence/index/IndexEdge.java   | 36 ++++++++++----------
 .../index/IndexLocationStrategy.java            | 30 ++++++++--------
 .../persistence/index/IndexRefreshCommand.java  | 30 ++++++++--------
 .../usergrid/persistence/index/SearchType.java  | 30 ++++++++--------
 .../usergrid/persistence/index/SearchTypes.java | 32 ++++++++---------
 .../persistence/index/SelectFieldMapping.java   | 36 ++++++++++----------
 .../persistence/index/impl/EntityField.java     | 32 ++++++++---------
 .../index/impl/EntityMappingParser.java         | 35 +++++++++----------
 .../index/impl/EsEntityIndexFactoryImpl.java    | 29 ++++++++--------
 .../index/impl/EsIndexBufferConsumerImpl.java   | 28 +++++++--------
 .../index/impl/EsIndexCacheImpl.java            | 29 ++++++++--------
 .../persistence/index/impl/FailureMonitor.java  | 30 ++++++++--------
 .../index/impl/FailureMonitorImpl.java          | 32 ++++++++---------
 .../persistence/index/impl/FieldParser.java     | 36 ++++++++++----------
 .../persistence/index/impl/GeoSortFields.java   | 36 ++++++++++----------
 .../index/impl/IndexBufferConsumer.java         | 28 +++++++--------
 .../persistence/index/impl/IndexCache.java      | 30 ++++++++--------
 .../persistence/index/impl/IndexEdgeImpl.java   | 36 ++++++++++----------
 .../index/impl/IndexIdentifierv2Impl.java       | 30 ++++++++--------
 .../index/impl/IndexRefreshCommandImpl.java     | 30 ++++++++--------
 .../index/impl/NoOpFilterBuilder.java           | 32 ++++++++---------
 .../index/impl/NoOpQueryBuilder.java            | 32 ++++++++---------
 .../impl/SearchRequestBuilderStrategy.java      | 30 ++++++++--------
 .../persistence/index/impl/SortBuilder.java     | 36 ++++++++++----------
 .../EsIndexMappingMigrationPlugin.java          | 28 +++++++--------
 .../index/migration/IndexDataVersions.java      | 30 ++++++++--------
 .../persistence/index/query/ParsedQuery.java    | 36 ++++++++++----------
 .../index/query/ParsedQueryBuilder.java         | 36 ++++++++++----------
 .../persistence/index/query/SortPredicate.java  | 36 ++++++++++----------
 .../index/impl/EntityToMapConverterTest.java    | 36 ++++++++++----------
 .../impl/EsIndexMappingMigrationPluginTest.java | 30 ++++++++--------
 .../persistence/index/impl/EsRunner.java        | 32 ++++++++---------
 .../persistence/index/impl/GeoPagingTest.java   | 36 ++++++++++----------
 .../index/impl/TestIndexIdentifier.java         | 30 ++++++++--------
 37 files changed, 579 insertions(+), 612 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResult.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResult.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResult.java
index 27d5620..2375509 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResult.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResult.java
@@ -1,24 +1,20 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 
 package org.apache.usergrid.persistence.index;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java
index 9de263f..b8f87b6 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java
@@ -1,24 +1,20 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 
 package org.apache.usergrid.persistence.index;
@@ -49,7 +45,7 @@ public class CandidateResults implements Iterable<CandidateResult> {
         offset = Optional.absent();
     }
 
-    
+
     public void initializeOffset( int offset ){
         this.offset = Optional.of(offset);
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ElasticSearchQueryBuilder/SearchRequestBuilderStrategyV2.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ElasticSearchQueryBuilder/SearchRequestBuilderStrategyV2.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ElasticSearchQueryBuilder/SearchRequestBuilderStrategyV2.java
index 4d18cef..732bec1 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ElasticSearchQueryBuilder/SearchRequestBuilderStrategyV2.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ElasticSearchQueryBuilder/SearchRequestBuilderStrategyV2.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  The ASF licenses this file to You
- *  * under the Apache License, Version 2.0 (the "License"); you may not
- *  * use this file except in compliance with the License.
- *  * You may obtain a copy of the License at
- *  *
- *  *     http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing, software
- *  * distributed under the License is distributed on an "AS IS" BASIS,
- *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  * See the License for the specific language governing permissions and
- *  * limitations under the License.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index.ElasticSearchQueryBuilder;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexEdge.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexEdge.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexEdge.java
index 36aa240..49a1b87 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexEdge.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexEdge.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
  *
  */
 package org.apache.usergrid.persistence.index;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexLocationStrategy.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexLocationStrategy.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexLocationStrategy.java
index e5c8f8f..8039610 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexLocationStrategy.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexLocationStrategy.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  The ASF licenses this file to You
- *  * under the Apache License, Version 2.0 (the "License"); you may not
- *  * use this file except in compliance with the License.
- *  * You may obtain a copy of the License at
- *  *
- *  *     http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing, software
- *  * distributed under the License is distributed on an "AS IS" BASIS,
- *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  * See the License for the specific language governing permissions and
- *  * limitations under the License.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexRefreshCommand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexRefreshCommand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexRefreshCommand.java
index 435a94a..2226d89 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexRefreshCommand.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexRefreshCommand.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  The ASF licenses this file to You
- *  * under the Apache License, Version 2.0 (the "License"); you may not
- *  * use this file except in compliance with the License.
- *  * You may obtain a copy of the License at
- *  *
- *  *     http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing, software
- *  * distributed under the License is distributed on an "AS IS" BASIS,
- *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  * See the License for the specific language governing permissions and
- *  * limitations under the License.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchType.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchType.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchType.java
index 786219a..7a353c7 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchType.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchType.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  The ASF licenses this file to You
- *  * under the Apache License, Version 2.0 (the "License"); you may not
- *  * use this file except in compliance with the License.
- *  * You may obtain a copy of the License at
- *  *
- *  *     http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing, software
- *  * distributed under the License is distributed on an "AS IS" BASIS,
- *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  * See the License for the specific language governing permissions and
- *  * limitations under the License.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchTypes.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchTypes.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchTypes.java
index 0fce4c8..5ed2d6d 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchTypes.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchTypes.java
@@ -1,21 +1,21 @@
 package org.apache.usergrid.persistence.index;/*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SelectFieldMapping.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SelectFieldMapping.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SelectFieldMapping.java
index 8d0816a..5a92655 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SelectFieldMapping.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SelectFieldMapping.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityField.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityField.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityField.java
index a1eec91..39f0287 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityField.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityField.java
@@ -1,24 +1,20 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 
 package org.apache.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
index e328d29..63cef04 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
@@ -1,24 +1,20 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 
 package org.apache.usergrid.persistence.index.impl;
@@ -111,7 +107,8 @@ public class EntityMappingParser implements FieldParser {
 
         //we don't support indexing 2 dimensional arrays.  Short circuit with a warning so we can track operationally
         if(!lastCollection.isEmpty() && lastCollection.peek() instanceof Collection){
-            log.warn( "Encountered 2 collections consecutively.  N+1 dimensional arrays are unsupported, only arrays of depth 1 are supported" );
+            log.warn( "Encountered 2 collections consecutively.  " +
+                "N+1 dimensional arrays are unsupported, only arrays of depth 1 are supported" );
             return;
         }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
index 5f6b4fd..869d079 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
@@ -1,21 +1,20 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  The ASF licenses this file to You
- *  * under the Apache License, Version 2.0 (the "License"); you may not
- *  * use this file except in compliance with the License.
- *  * You may obtain a copy of the License at
- *  *
- *  *     http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing, software
- *  * distributed under the License is distributed on an "AS IS" BASIS,
- *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  * See the License for the specific language governing permissions and
- *  * limitations under the License.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package org.apache.usergrid.persistence.index.impl;
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
index 2c7122b..14f2b6f 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
@@ -1,21 +1,19 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  The ASF licenses this file to You
- *  * under the Apache License, Version 2.0 (the "License"); you may not
- *  * use this file except in compliance with the License.
- *  * You may obtain a copy of the License at
- *  *
- *  *     http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing, software
- *  * distributed under the License is distributed on an "AS IS" BASIS,
- *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  * See the License for the specific language governing permissions and
- *  * limitations under the License.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  */
 package org.apache.usergrid.persistence.index.impl;
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCacheImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCacheImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCacheImpl.java
index 7bc92a8..a2e3743 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCacheImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCacheImpl.java
@@ -1,21 +1,20 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  The ASF licenses this file to You
- *  * under the Apache License, Version 2.0 (the "License"); you may not
- *  * use this file except in compliance with the License.
- *  * You may obtain a copy of the License at
- *  *
- *  *     http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing, software
- *  * distributed under the License is distributed on an "AS IS" BASIS,
- *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  * See the License for the specific language governing permissions and
- *  * limitations under the License.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 
 package org.apache.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitor.java
index b351699..ed9eeff 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitor.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitor.java
@@ -1,22 +1,20 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 
 package org.apache.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitorImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitorImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitorImpl.java
index fed9a50..7de3a7c 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitorImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitorImpl.java
@@ -1,21 +1,21 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FieldParser.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FieldParser.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FieldParser.java
index 663d2a5..b0a16a6 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FieldParser.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FieldParser.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/GeoSortFields.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/GeoSortFields.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/GeoSortFields.java
index fcafcd2..2ed57a0 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/GeoSortFields.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/GeoSortFields.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
index 2906570..e769455 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
@@ -1,21 +1,19 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  The ASF licenses this file to You
- *  * under the Apache License, Version 2.0 (the "License"); you may not
- *  * use this file except in compliance with the License.
- *  * You may obtain a copy of the License at
- *  *
- *  *     http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing, software
- *  * distributed under the License is distributed on an "AS IS" BASIS,
- *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  * See the License for the specific language governing permissions and
- *  * limitations under the License.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  */
 package org.apache.usergrid.persistence.index.impl;
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexCache.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexCache.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexCache.java
index cbcb413..a19216e 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexCache.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexCache.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  The ASF licenses this file to You
- *  * under the Apache License, Version 2.0 (the "License"); you may not
- *  * use this file except in compliance with the License.
- *  * You may obtain a copy of the License at
- *  *
- *  *     http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing, software
- *  * distributed under the License is distributed on an "AS IS" BASIS,
- *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  * See the License for the specific language governing permissions and
- *  * limitations under the License.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexEdgeImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexEdgeImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexEdgeImpl.java
index c3e7c9d..5b525cb 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexEdgeImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexEdgeImpl.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexIdentifierv2Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexIdentifierv2Impl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexIdentifierv2Impl.java
index b36eac5..8bbc2ae 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexIdentifierv2Impl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexIdentifierv2Impl.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  The ASF licenses this file to You
- *  * under the Apache License, Version 2.0 (the "License"); you may not
- *  * use this file except in compliance with the License.
- *  * You may obtain a copy of the License at
- *  *
- *  *     http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing, software
- *  * distributed under the License is distributed on an "AS IS" BASIS,
- *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  * See the License for the specific language governing permissions and
- *  * limitations under the License.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
index 9a2f2dc..70220d0 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  The ASF licenses this file to You
- *  * under the Apache License, Version 2.0 (the "License"); you may not
- *  * use this file except in compliance with the License.
- *  * You may obtain a copy of the License at
- *  *
- *  *     http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing, software
- *  * distributed under the License is distributed on an "AS IS" BASIS,
- *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  * See the License for the specific language governing permissions and
- *  * limitations under the License.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpFilterBuilder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpFilterBuilder.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpFilterBuilder.java
index 9d3c95c..9eca433 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpFilterBuilder.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpFilterBuilder.java
@@ -1,24 +1,20 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 
 package org.apache.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpQueryBuilder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpQueryBuilder.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpQueryBuilder.java
index acad20c..2498812 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpQueryBuilder.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpQueryBuilder.java
@@ -1,24 +1,20 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 
 package org.apache.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SearchRequestBuilderStrategy.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SearchRequestBuilderStrategy.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SearchRequestBuilderStrategy.java
index 506ba2b..a5c1af3 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SearchRequestBuilderStrategy.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SearchRequestBuilderStrategy.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  The ASF licenses this file to You
- *  * under the Apache License, Version 2.0 (the "License"); you may not
- *  * use this file except in compliance with the License.
- *  * You may obtain a copy of the License at
- *  *
- *  *     http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing, software
- *  * distributed under the License is distributed on an "AS IS" BASIS,
- *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  * See the License for the specific language governing permissions and
- *  * limitations under the License.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SortBuilder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SortBuilder.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SortBuilder.java
index 5a3123a..ad78be7 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SortBuilder.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SortBuilder.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java
index 10acc46..6d46beb 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java
@@ -1,21 +1,19 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  The ASF licenses this file to You
- *  * under the Apache License, Version 2.0 (the "License"); you may not
- *  * use this file except in compliance with the License.
- *  * You may obtain a copy of the License at
- *  *
- *  *     http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing, software
- *  * distributed under the License is distributed on an "AS IS" BASIS,
- *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  * See the License for the specific language governing permissions and
- *  * limitations under the License.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  */
 package org.apache.usergrid.persistence.index.migration;
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/IndexDataVersions.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/IndexDataVersions.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/IndexDataVersions.java
index 6558339..230d53b 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/IndexDataVersions.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/IndexDataVersions.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  The ASF licenses this file to You
- *  * under the Apache License, Version 2.0 (the "License"); you may not
- *  * use this file except in compliance with the License.
- *  * You may obtain a copy of the License at
- *  *
- *  *     http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing, software
- *  * distributed under the License is distributed on an "AS IS" BASIS,
- *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  * See the License for the specific language governing permissions and
- *  * limitations under the License.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQuery.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQuery.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQuery.java
index 7172447..bb87dcc 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQuery.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQuery.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQueryBuilder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQueryBuilder.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQueryBuilder.java
index aa279fc..bb79e37 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQueryBuilder.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQueryBuilder.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/SortPredicate.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/SortPredicate.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/SortPredicate.java
index 92636fb..c350a92 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/SortPredicate.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/SortPredicate.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
index 5ebe14e..c412cf4 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
  *
  */
 


[15/44] usergrid git commit: change location to entity field

Posted by md...@apache.org.
change location to entity field


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

Branch: refs/heads/USERGRID-933
Commit: 6f0bf9eccbeb2052e1bce4992edb182a97fd3c2a
Parents: 001a7e3
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Sep 14 14:04:18 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Sep 14 14:04:18 2015 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityMapUtilsTest.java   |  4 +-
 .../org/apache/usergrid/persistence/GeoIT.java  | 52 +++++++++++++++++++-
 .../model/entity/MapToEntityConverter.java      |  4 --
 3 files changed, 53 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/6f0bf9ec/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
index 325e51f..b53f7ae 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
@@ -133,14 +133,14 @@ public class CpEntityMapUtilsTest {
 
         cpEntity = CpEntityMapUtils.fromMap(properties, "loc", true);
 
-        assertNull(cpEntity.getFieldMap().get("location"));
+        assertTrue(cpEntity.getFieldMap().get("location") instanceof EntityObjectField);
 
         properties = new LinkedHashMap<String, Object>();
         properties.put("location", "denver");
 
         cpEntity = CpEntityMapUtils.fromMap(properties, "loc", true);
 
-        assertNull(cpEntity.getFieldMap().get("location") );
+        assertTrue(cpEntity.getFieldMap().get("location") instanceof StringField);
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6f0bf9ec/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
index 8d71826..230f9be 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
@@ -33,7 +33,7 @@ import org.apache.usergrid.utils.MapUtils;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-
+import static org.junit.Assert.assertTrue;
 
 
 public class GeoIT extends AbstractCoreIT {
@@ -252,6 +252,56 @@ public class GeoIT extends AbstractCoreIT {
     }
 
     @Test
+    public void testNonGeolocationEntities() throws Exception {
+        //1. load test entities
+        EntityManager em = app.getEntityManager();
+        assertNotNull(em);
+
+         List<Map<String, Object>> locations =
+            new ArrayList<Map<String, Object>>();
+
+
+        locations.add(new LinkedHashMap<String, Object>() {{
+                put("name", "norwest");
+                put("location", "texas");
+            }});
+        locations.add(new LinkedHashMap<String, Object>() {{
+                put("type", "store");
+                put("name", "ashfield");
+                put("location", "new jersey");
+            }});
+
+        //2. load test entities
+        for (Map<String, Object> location : locations) {
+            Entity entity = em.create("store", location);
+            assertNotNull(entity);
+            LOG.debug("Entity {} created", entity.getProperty("name"));
+        }
+        app.refreshIndex();
+        //2. validate the size of the result
+        Query query = new Query();
+        Results listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
+        assertEquals("total number of 'stores'", locations.size(), listResults.size());
+        //3. verify each entity has geo data
+        for (Entity entity : listResults.entities) {
+            Object location = entity.getProperty("location");
+            assertNotNull(location);
+            assertTrue(location instanceof String);
+        }
+
+        query = Query.fromQL("select * where location='texas'");
+        listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
+        assertEquals("total number of 'stores'", 1, listResults.size());
+        //3. verify each entity has geo data
+        for (Entity entity : listResults.entities) {
+            Object location = entity.getProperty("location");
+            assertNotNull(location);
+            assertTrue(location instanceof String);
+        }
+
+    }
+
+    @Test
     /**
      * Load entities with location data and query them from a far away location
      * 1. create entities with geo

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6f0bf9ec/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
index c0db81b..2357a57 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
@@ -56,10 +56,6 @@ public class MapToEntityConverter{
             Object value = map.get( fieldName );
             boolean unique = schemaManager == null ? topLevel :  topLevel && schemaManager.isPropertyUnique(entityType, fieldName);
             //cannot store fields that aren't locations
-            if(fieldName.toLowerCase().equals(locationKey) && !(value instanceof Map)) {
-                logger.warn("can't map entity with location field");
-                continue;
-            }
 
             if ( value instanceof String ) {
                 String stringValue =(String)value;


[16/44] usergrid git commit: Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into two-dot-o-dev

Posted by md...@apache.org.
Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into two-dot-o-dev


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

Branch: refs/heads/USERGRID-933
Commit: 723ee3ab115fb4785b5a8556e564460034cb0a4f
Parents: 6f0bf9e 2faa805
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Sep 14 16:40:13 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Sep 14 16:40:13 2015 -0600

----------------------------------------------------------------------
 .../creating-and-managing-notifications.md                   | 2 ++
 portal/bower.json                                            | 2 +-
 portal/js/libs/usergrid.sdk.js                               | 8 +++++---
 portal/package.json                                          | 2 +-
 .../apache/usergrid/persistence/entities/Notification.java   | 7 +++----
 .../usergrid/services/notifications/gcm/GCMAdapter.java      | 2 +-
 .../services/notifications/apns/NotificationsServiceIT.java  | 2 +-
 .../services/notifications/gcm/NotificationsServiceIT.java   | 2 +-
 8 files changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------



[19/44] usergrid git commit: Added test to prove issue in graph. Need to fix version load.

Posted by md...@apache.org.
Added test to prove issue in graph.  Need to fix version load.


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

Branch: refs/heads/USERGRID-933
Commit: 13d2594196bd6315af4305e95e8314cbb600ee3e
Parents: 85e1e7c
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Sep 15 13:34:34 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Sep 15 13:35:21 2015 -0600

----------------------------------------------------------------------
 .../service/ConnectionServiceImpl.java          | 26 ++++---
 .../service/ConnectionServiceImplTest.java      | 36 ++++++++--
 stack/core/src/test/resources/log4j.properties  |  3 +-
 .../migration/schema/MigrationManagerFig.java   |  1 +
 .../impl/stage/EdgeDeleteListenerImpl.java      |  4 +-
 .../graph/impl/stage/EdgeDeleteRepairImpl.java  | 61 +++++-----------
 .../persistence/graph/GraphManagerIT.java       | 73 +++++++++++++++++++-
 7 files changed, 136 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/13d25941/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
index 41e6f80..d60426c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
@@ -147,18 +147,18 @@ public class ConnectionServiceImpl implements ConnectionService {
         final Observable<ApplicationScope> applicationScopeObservable ) {
 
 
-        final Observable<EntityIdScope> entityIds =allEntityIdsObservable.getEntities( applicationScopeObservable );
+        final Observable<EntityIdScope> entityIds = allEntityIdsObservable.getEntities( applicationScopeObservable );
         //now we have an observable of entityIds.  Walk each connection type
 
         //get all edge types for connections
-       return  entityIds.flatMap( entityIdScope -> {
+        return entityIds.flatMap( entityIdScope -> {
 
             final ApplicationScope applicationScope = entityIdScope.getApplicationScope();
             final Id entityId = entityIdScope.getId();
 
-            final GraphManager gm = graphManagerFactory.createEdgeManager(applicationScope );
+            final GraphManager gm = graphManagerFactory.createEdgeManager( applicationScope );
 
-           logger.debug( "Checking connections of id {} in application {}", entityId, applicationScope );
+            logger.debug( "Checking connections of id {} in application {}", entityId, applicationScope );
 
             return gm.getEdgeTypesFromSource(
                 new SimpleSearchEdgeType( entityId, CpNamingUtils.EDGE_CONN_PREFIX, Optional.absent() ) )
@@ -176,7 +176,7 @@ public class ConnectionServiceImpl implements ConnectionService {
                     return gm.loadEdgesFromSource( searchByEdge );
                 } )
 
-                //now that we have a stream of edges, stream all versions
+                    //now that we have a stream of edges, stream all versions
                 .flatMap( edge -> {
 
                     logger.debug( "Found edge {}, searching for multiple versions of edge", edge );
@@ -187,19 +187,17 @@ public class ConnectionServiceImpl implements ConnectionService {
                     return gm.loadEdgeVersions( searchByEdge );
                 } )
 
-            //skip the first version since it's the one we want to retain
-            // validate there is only 1 version of it, delete anything > than the min
-                .skip( 1 )
-                .flatMap( edgeToDelete -> {
+                    //skip the first version since it's the one we want to retain
+                    // validate there is only 1 version of it, delete anything > than the min
+                .skip( 1 ).flatMap( edgeToDelete -> {
 
                     logger.debug( "Deleting edge {}", edgeToDelete );
 
                     //mark the edge and ignore the cleanup result
                     return gm.markEdge( edgeToDelete )
-                             //delete the edge
-                             .flatMap( edge -> gm.deleteEdge( edgeToDelete ));
-                } )
-                .map( deletedEdge -> new ConnectionScope( applicationScope, deletedEdge ) ) ;
-        });
+                        //delete the edge
+                        .flatMap( edge -> gm.deleteEdge( edgeToDelete ) );
+                } ).map( deletedEdge -> new ConnectionScope( applicationScope, deletedEdge ) );
+        } );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/13d25941/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
index e03a9b3..152721a 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
@@ -23,6 +23,8 @@ import java.util.List;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.usergrid.corepersistence.TestCoreModule;
 import org.apache.usergrid.corepersistence.util.CpNamingUtils;
@@ -53,6 +55,9 @@ import static org.junit.Assert.assertNotNull;
 @UseModules( TestCoreModule.class )
 public class ConnectionServiceImplTest {
 
+
+    private static final Logger logger = LoggerFactory.getLogger(ConnectionServiceImplTest.class);
+
     @Inject
     private GraphManagerFactory graphManagerFactory;
 
@@ -158,19 +163,23 @@ public class ConnectionServiceImplTest {
 
         final Edge written1 = gm.writeEdge( connection1 ).toBlocking().last();
 
+        logger.info( "Wrote edge 1 with edge {}", written1 );
+
 
         //write the second
         final Edge connection2 = CpNamingUtils.createConnectionEdge( source, connectionType, target );
 
         final Edge written2 = gm.writeEdge( connection2 ).toBlocking().last();
 
+        logger.info( "Wrote edge 2 with edge {}", written2 );
+
 
         //write the 3rd
         final Edge connection3 = CpNamingUtils.createConnectionEdge( source, connectionType, target );
 
         final Edge written3 = gm.writeEdge( connection3 ).toBlocking().last();
 
-
+        logger.info( "Wrote edge 3 with edge {}", written3 );
 
 
         //now run the cleanup
@@ -178,13 +187,16 @@ public class ConnectionServiceImplTest {
         final List<ConnectionScope> deletedConnections =
             connectionService.deDupeConnections( Observable.just( applicationScope ) ).toList().toBlocking().last();
 
-        assertEquals( "2 edges deleted", 2, deletedConnections.size() );
+//        assertEquals( "2 edges deleted", 2, deletedConnections.size() );
 
         //check our oldest was deleted first
 
-        assertEquals(written2, deletedConnections.get( 0 ));
 
-        assertEquals(written3, deletedConnections.get( 1 ));
+        assertEdgeData( written2, deletedConnections.get( 0 ).getEdge() );
+
+        assertEdgeData( written3, deletedConnections.get( 1 ).getEdge() );
+
+        assertEquals( "2 edges deleted", 2, deletedConnections.size() );
 
 
 
@@ -201,4 +213,20 @@ public class ConnectionServiceImplTest {
 
         assertEquals( written1, edges.get( 0 ) );
     }
+
+
+    /**
+     * Compares edges based on their sourceId, type, targetId and timestamp. It ignores the deleted flag
+     * @param expected
+     * @param asserted
+     */
+    private void assertEdgeData(final Edge expected, final Edge asserted){
+        assertEquals("SourceId the same", expected.getSourceNode(), expected.getTargetNode());
+        assertEquals("TargetId the same", expected.getTargetNode(), expected.getTargetNode());
+
+        assertEquals("Type the same", expected.getType(), expected.getType());
+
+        assertEquals("Timestamp the same", expected.getTimestamp(), expected.getTimestamp());
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/13d25941/stack/core/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/core/src/test/resources/log4j.properties b/stack/core/src/test/resources/log4j.properties
index dd29671..93951fe 100644
--- a/stack/core/src/test/resources/log4j.properties
+++ b/stack/core/src/test/resources/log4j.properties
@@ -47,7 +47,8 @@ log4j.logger.org.apache.usergrid.persistence.PerformanceEntityRebuildIndexTest=D
 log4j.logger.org.apache.usergrid.corepersistence.migration=WARN
 
 #Debug our queries
-log4j.logger.org.apache.usergrid.persistence.index.impl.EsApplicationEntityIndexImpl=DEBUG
+#log4j.logger.org.apache.usergrid.persistence.index.impl.EsApplicationEntityIndexImpl=DEBUG
+log4j.logger.org.apache.usergrid.corepersistence.service.ConnectionServiceImpl=DEBUG
 
 #log4j.logger.org.apache.usergrid.persistence.index.impl=DEBUG
 #log4j.logger.org.apache.usergrid.corepersistence.CpSetup=INFO

http://git-wip-us.apache.org/repos/asf/usergrid/blob/13d25941/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java
index b95338a..d8f3d1f 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java
@@ -35,6 +35,7 @@ public interface MigrationManagerFig extends GuicyFig {
     String getStrategyClass();
 
     @Key( "collections.keyspace.strategy.options" )
+    @Default("replication_factor:1")
     String getStrategyOptions();
 
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/13d25941/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteListenerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteListenerImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteListenerImpl.java
index 22a5ad0..fa289bd 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteListenerImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteListenerImpl.java
@@ -30,6 +30,7 @@ import com.google.inject.Singleton;
 import rx.Observable;
 import rx.functions.Func1;
 import rx.functions.Func2;
+import rx.observables.MathObservable;
 
 
 /**
@@ -69,8 +70,7 @@ public class EdgeDeleteListenerImpl implements EdgeDeleteListener {
                                    Observable<Integer> targetDelete = edgeMetaRepair
                                            .repairTargets( scope, edge.getTargetNode(), edge.getType(), maxTimestamp );
 
-                                   return Observable.zip( sourceDelete, targetDelete,
-                                       ( sourceCount, targetCount ) -> sourceCount + targetCount );
+                                   return MathObservable.sumInteger( Observable.merge( sourceDelete, targetDelete ) );
                                } );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/13d25941/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java
index 9b84978..643dcc1 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java
@@ -79,52 +79,25 @@ public class EdgeDeleteRepairImpl implements EdgeDeleteRepair {
 
 
         //merge source and target then deal with the distinct values
-        return Observable.just( edge ).flatMap( new Func1<MarkedEdge, Observable<? extends MarkedEdge>>() {
-            @Override
-            public Observable<? extends MarkedEdge> call( final MarkedEdge edge ) {
-
-                return getEdgeVersions( scope, edge, storageSerialization ).take( 1 )
-                        .doOnNext( new Action1<MarkedEdge>() {
-                            @Override
-                            public void call( final MarkedEdge markedEdge ) {
-                                //it's still in the same state as it was when we queued it. Remove it
-                                if ( edge.equals( markedEdge ) ) {
-                                    LOG.info( "Removing edge {} ", edge );
-
-                                    //remove from the commit log
-
-
-                                    //remove from storage
-                                    try {
-                                        storageSerialization.deleteEdge( scope, edge, timestamp ).execute();
-                                    }
-                                    catch ( ConnectionException e ) {
-                                        throw new RuntimeException( "Unable to connect to casandra", e );
-                                    }
-                                }
-                            }
-                        } );
-            }
-        } );
+        return Observable.just( edge )
+                .doOnNext( markedEdge -> {
+                    //it's still in the same state as it was when we queued it. Remove it
+                        LOG.info( "Removing edge {} ", markedEdge );
+
+                        //remove from the commit log
+
+
+                        //remove from storage
+                        try {
+                            storageSerialization.deleteEdge( scope, markedEdge, timestamp ).execute();
+                        }
+                        catch ( ConnectionException e ) {
+                            throw new RuntimeException( "Unable to connect to casandra", e );
+                        }
+                    }
+              );
     }
 
 
-    /**
-     * Get all edge versions <= the specified max from the source
-     */
-    private Observable<MarkedEdge> getEdgeVersions( final ApplicationScope scope, final Edge edge,
-                                                    final EdgeSerialization serialization ) {
 
-        return Observable.create( new ObservableIterator<MarkedEdge>( "edgeVersions" ) {
-            @Override
-            protected Iterator<MarkedEdge> getIterator() {
-
-                final SimpleSearchByEdge search =
-                        new SimpleSearchByEdge( edge.getSourceNode(), edge.getType(), edge.getTargetNode(),
-                                edge.getTimestamp(), SearchByEdgeType.Order.DESCENDING, Optional.<Edge>absent() );
-
-                return serialization.getEdgeVersions( scope, search );
-            }
-        } );
-    }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/13d25941/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
index d416b1d..4b2ffc8 100644
--- a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
+++ b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
@@ -20,9 +20,9 @@ package org.apache.usergrid.persistence.graph;
 
 
 import java.util.Iterator;
+import java.util.List;
 import java.util.concurrent.TimeoutException;
 
-import com.google.common.base.Optional;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -35,11 +35,14 @@ import org.apache.usergrid.persistence.core.test.ITRunner;
 import org.apache.usergrid.persistence.core.test.UseModules;
 import org.apache.usergrid.persistence.core.util.IdGenerator;
 import org.apache.usergrid.persistence.graph.guice.TestGraphModule;
+import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge;
+import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchEdgeType;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchIdType;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 
+import com.google.common.base.Optional;
 import com.google.inject.Inject;
 
 import rx.Observable;
@@ -836,7 +839,7 @@ public class GraphManagerIT {
         //now load the next page
 
         //tests that even if a prefix is specified, the last takes precedence
-        edgeTypes = new SimpleSearchEdgeType( testTargetEdge.getSourceNode(), null, Optional.fromNullable("test") );
+        edgeTypes = new SimpleSearchEdgeType( testTargetEdge.getSourceNode(), null, Optional.fromNullable( "test" ) );
 
         edges = gm.getEdgeTypesFromSource( edgeTypes );
 
@@ -914,7 +917,7 @@ public class GraphManagerIT {
 
         //now load the next page
 
-        edgeTypes = new SimpleSearchEdgeType( testTargetEdge2.getTargetNode(), null,  Optional.fromNullable("test") );
+        edgeTypes = new SimpleSearchEdgeType( testTargetEdge2.getTargetNode(), null, Optional.fromNullable( "test" ) );
 
         edges = gm.getEdgeTypesToTarget( edgeTypes );
 
@@ -2321,6 +2324,70 @@ public class GraphManagerIT {
 
         em.markEdge( null );
     }
+
+
+    @Test
+    public void testReadMultipleVersionOrder() {
+
+        GraphManager gm = emf.createEdgeManager( scope );
+
+        final Id sourceId = createId( "source" );
+
+        final Id target = createId( "target" );
+
+
+        //write 3 edges with 3 different timestamp
+        final Edge edge1 = createEdge( sourceId, "test", target, 1, false );
+
+        gm.writeEdge( edge1 ).toBlocking().last();
+
+        final Edge edge2 = createEdge( sourceId, "test", target, 2, false );
+
+        gm.writeEdge( edge2 ).toBlocking().last();
+
+        final Edge edge3 = createEdge( sourceId, "test", target, 3, false );
+
+        gm.writeEdge( edge3 ).toBlocking().last();
+
+        //now test retrieving it
+
+
+        final SearchByEdge searchDescending =
+            new SimpleSearchByEdge( edge1.getSourceNode(), edge1.getType(), edge1.getTargetNode(),Long.MAX_VALUE,
+                SearchByEdgeType.Order.DESCENDING, Optional.<Edge>absent()   );
+
+        final Observable<Edge> edgesDescending = gm.loadEdgeVersions( searchDescending );
+
+        //search descending
+        final List<Edge> descending = edgesDescending.toList().toBlocking().single();
+
+        assertEquals( "Correct size returned", 3, descending.size() );
+
+        assertEquals( "Correct edges returned", edge3, descending.get( 0 ) );
+
+        assertEquals( "Correct edges returned", edge2, descending.get( 1 ) );
+
+        assertEquals( "Correct edges returned", edge1, descending.get( 2 ) );
+
+
+        //now search ascending
+
+        final SearchByEdge searchAscending =
+                    new SimpleSearchByEdge( edge1.getSourceNode(), edge1.getType(), edge1.getTargetNode(),Long.MAX_VALUE,
+                        SearchByEdgeType.Order.ASCENDING, Optional.<Edge>absent()   );
+
+        Observable<Edge> edgesAscending = gm.loadEdgeVersions( searchAscending );
+
+        List<Edge> ascending = edgesAscending.toList().toBlocking().single();
+
+        assertEquals( "Correct size returned", 3, ascending.size() );
+
+        assertEquals( "Correct edges returned", edge1, ascending.get( 0 ) );
+
+        assertEquals( "Correct edges returned", edge2, ascending.get( 1 ) );
+
+        assertEquals( "Correct edges returned", edge3, ascending.get( 2 ) );
+    }
 }
 
 


[32/44] usergrid git commit: Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into 2.1-release

Posted by md...@apache.org.
Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into 2.1-release


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

Branch: refs/heads/USERGRID-933
Commit: 61dd5595a820ad5120e99523414050673e3d2cc4
Parents: fad32aa 9294af7
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Sep 17 11:54:17 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Sep 17 11:54:17 2015 -0600

----------------------------------------------------------------------
 .../management/AppInfoMigrationPlugin.java      | 234 +++++++++----------
 1 file changed, 116 insertions(+), 118 deletions(-)
----------------------------------------------------------------------



[42/44] usergrid git commit: Updated plugin to also take into account core data version

Posted by md...@apache.org.
Updated plugin to also take into account core data version


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

Branch: refs/heads/USERGRID-933
Commit: 0b243c4d516e0f6ae58421c63787421b8b806052
Parents: 29c1a12
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Sep 24 14:02:40 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Sep 24 14:02:40 2015 -0600

----------------------------------------------------------------------
 stack/scripts/migrate_entity_data.py | 66 ++++++++++++++++++++++---------
 1 file changed, 48 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/0b243c4d/stack/scripts/migrate_entity_data.py
----------------------------------------------------------------------
diff --git a/stack/scripts/migrate_entity_data.py b/stack/scripts/migrate_entity_data.py
index 4258a71..36f73c0 100644
--- a/stack/scripts/migrate_entity_data.py
+++ b/stack/scripts/migrate_entity_data.py
@@ -51,9 +51,11 @@ import json
 
 
 # Version expected in status response post-migration for entity and app-info data
-TARGET_VERSION = 2
+TARGET_APPINFO_VERSION=2
+TARGET_ENTITY_DATA_VERSION=2
+TARGET_CORE_DATA_VERSION=2
 TARGET_MIGRATION_SYSTEM_VERSION = 1
-TARGET_INDEX_MAPPING_VERSION = 1
+TARGET_INDEX_MAPPING_VERSION = 2
 
 # Set an interval (in seconds) for checking if re-index and/or migration has finished
 STATUS_INTERVAL_SECONDS = 2
@@ -63,6 +65,7 @@ PLUGIN_MIGRATION_SYSTEM = 'migration-system'
 PLUGIN_APPINFO = 'appinfo-migration'
 PLUGIN_ENTITYDATA = 'collections-entity-data'
 PLUGIN_INDEX_MAPPING = 'index_mapping_migration'
+PLUGIN_CORE_DATA = 'core-data'
 
 
 
@@ -144,9 +147,21 @@ class Migrate:
                     if migration_system_updated:
                         break
 
+            index_mapping_updated = self.is_index_mapping_updated()
+
+            if not index_mapping_updated:
+                self.logger.info('Index Mapping needs to be updated.  Updating index mapping..')
+                self.start_index_mapping_migration()
+                while not index_mapping_updated:
+                    time.sleep(STATUS_INTERVAL_SECONDS)
+                    index_mapping_updated = self.is_index_mapping_updated()
+                    if index_mapping_updated:
+                        break
+
             # Run AppInfo migration only when both appinfos and collection entity data have not been migrated
             if not self.is_data_migrated():
 
+                #Migrate app info
                 if self.is_appinfo_migrated():
                     self.logger.info('AppInfo already migrated. Resetting version for re-migration.')
                     self.reset_appinfo_migration()
@@ -164,20 +179,14 @@ class Migrate:
                         self.metrics['appinfo_migration_end'] = get_current_time()
                         break
                 self.logger.info('AppInfo Migration Ended.')
+
+
             else:
                 self.logger.info('Full Data Migration previously ran... skipping AppInfo migration.')
 
-            # We need to check and roll index mapping version to 1 if not already there
-            index_mapping_updated = self.is_index_mapping_updated()
 
-            if not index_mapping_updated:
-                self.logger.info('Index Mapping needs to be updated.  Updating index mapping..')
-                self.start_index_mapping_migration()
-                while not index_mapping_updated:
-                    time.sleep(STATUS_INTERVAL_SECONDS)
-                    index_mapping_updated = self.is_index_mapping_updated()
-                    if index_mapping_updated:
-                        break
+
+            # We need to check and roll index mapping version to 1 if not already there
 
             # Perform system re-index (it will grab date from input if provided)
             job = self.start_reindex()
@@ -202,7 +211,9 @@ class Migrate:
                 time.sleep(STATUS_INTERVAL_SECONDS)
                 self.is_data_migrated()
 
+                # self.start_core_data_migration()
                 self.start_fulldata_migration()
+
                 self.metrics['full_data_migration_start'] = get_current_time()
                 self.logger.info("Full Data Migration Started")
                 is_migrated = False
@@ -242,6 +253,21 @@ class Migrate:
         url = self.endpoint + '/system/index/rebuild'
         return url
 
+    def get_management_reindex_url(self):
+          url = self.get_reindex_url() + "/management"
+          return url
+
+
+    def start_core_data_migration(self):
+           try:
+               r = requests.put(url=self.get_migration_url(), auth=(self.admin_user, self.admin_pass))
+               response = r.json()
+               return response
+           except requests.exceptions.RequestException as e:
+               self.logger.error('Failed to start migration, %s', e)
+               exit_on_error(str(e))
+
+
     def start_fulldata_migration(self):
         try:
             r = requests.put(url=self.get_migration_url(), auth=(self.admin_user, self.admin_pass))
@@ -253,6 +279,7 @@ class Migrate:
 
     def start_migration_system_update(self):
         try:
+            #TODO fix this URL
             migrateUrl = self.get_migration_url() + '/' + PLUGIN_MIGRATION_SYSTEM
             r = requests.put(url=migrateUrl, auth=(self.admin_user, self.admin_pass))
             response = r.json()
@@ -293,7 +320,7 @@ class Migrate:
             exit_on_error(str(e))
 
     def reset_data_migration(self):
-        version = TARGET_VERSION - 1
+        version = TARGET_ENTITY_DATA_VERSION - 1
         body = json.dumps({PLUGIN_ENTITYDATA: version, PLUGIN_APPINFO: version})
         try:
             r = requests.put(url=self.get_reset_migration_url(), data=body, auth=(self.admin_user, self.admin_pass))
@@ -306,7 +333,7 @@ class Migrate:
             exit_on_error(str(e))
 
     def reset_appinfo_migration(self):
-        version = TARGET_VERSION - 1
+        version = TARGET_APPINFO_VERSION - 1
         body = json.dumps({PLUGIN_APPINFO: version})
         try:
             r = requests.put(url=self.get_reset_migration_url(), data=body, auth=(self.admin_user, self.admin_pass))
@@ -322,14 +349,17 @@ class Migrate:
         if status is not None:
             entity_version = status['data'][PLUGIN_ENTITYDATA]
             appinfo_version = status['data'][PLUGIN_APPINFO]
+            core_data_version = status['data'][PLUGIN_CORE_DATA]
 
-            if entity_version == TARGET_VERSION and appinfo_version == TARGET_VERSION:
+            if entity_version == TARGET_ENTITY_DATA_VERSION and appinfo_version == TARGET_APPINFO_VERSION and core_data_version == TARGET_CORE_DATA_VERSION:
                 self.logger.info('Full Data Migration status=[COMPLETE], %s=[%s], '
-                                 '%s=[%s]',
+                                 '%s=[%s], %s=%s',
                                  PLUGIN_ENTITYDATA,
                                  entity_version,
                                  PLUGIN_APPINFO,
-                                 appinfo_version)
+                                 appinfo_version,
+                                 PLUGIN_CORE_DATA,
+                                 core_data_version)
                 return True
             else:
                 self.logger.info('Full Data Migration status=[NOTSTARTED/INPROGRESS]')
@@ -340,7 +370,7 @@ class Migrate:
         if status is not None:
             appinfo_version = status['data'][PLUGIN_APPINFO]
 
-            if appinfo_version == TARGET_VERSION:
+            if appinfo_version == TARGET_APPINFO_VERSION:
                 self.logger.info('AppInfo Migration status=[COMPLETE],'
                                  '%s=[%s]',
                                  PLUGIN_APPINFO,


[17/44] usergrid git commit: Initial testing with guice wiring for test

Posted by md...@apache.org.
Initial testing with guice wiring for test


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

Branch: refs/heads/USERGRID-933
Commit: b625ed24a68d9c71fc30694c5dbeda26f1afb4d7
Parents: 2faa805
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Sep 14 17:33:38 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Sep 14 18:14:00 2015 -0600

----------------------------------------------------------------------
 .../corepersistence/CpRelationManager.java      |  23 ++-
 .../asyncevents/AsyncEventService.java          |   2 +
 .../builder/PipelineBuilderFactory.java         |   3 +
 .../service/ConnectionScope.java                |  53 +++++
 .../service/ConnectionService.java              |  10 +
 .../service/ConnectionServiceImpl.java          |  65 +++++-
 .../corepersistence/util/CpNamingUtils.java     |  13 +-
 .../corepersistence/TestCoreModule.java         |  34 ++++
 .../service/ConnectionServiceImplTest.java      | 198 +++++++++++++++++++
 stack/core/src/test/resources/log4j.properties  |   3 +-
 .../impl/TargetIdObservableImpl.java            |  13 +-
 11 files changed, 397 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 0c3b927..1da6f75 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -63,6 +63,7 @@ import org.apache.usergrid.persistence.graph.GraphManager;
 import org.apache.usergrid.persistence.graph.SearchByEdge;
 import org.apache.usergrid.persistence.graph.SearchByEdgeType;
 import org.apache.usergrid.persistence.graph.impl.SimpleEdge;
+import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchEdgeType;
 import org.apache.usergrid.persistence.index.EntityIndex;
@@ -694,9 +695,27 @@ public class CpRelationManager implements RelationManager {
         final Edge edge = createConnectionEdge( cpHeadEntity.getId(), connectionType, targetEntity.getId() );
 
         final GraphManager gm = managerCache.getGraphManager( applicationScope );
-        gm.writeEdge( edge ).toBlocking().last();
 
-        indexService.queueNewEdge( applicationScope, targetEntity, edge );
+
+        //check if the edge exists
+
+
+        final SearchByEdge searchByEdge = new SimpleSearchByEdge(edge.getSourceNode(), edge.getType(), edge.getTargetNode(), Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, Optional.absent()  );
+
+
+        //only take 1 and count it.  If we don't have anything, create the edge
+        final int count = gm.loadEdgeVersions( searchByEdge ).take( 1 ).count().toBlocking().last();
+
+        if(count == 0) {
+            if(logger.isDebugEnabled()) {
+                logger.debug( "No edge exists between {} and {} of type {}.  Creating",
+                    new Object[] { edge.getSourceNode(), edge.getTargetNode(), edge.getType() } );
+            }
+
+            gm.writeEdge( edge ).toBlocking().last();
+
+            indexService.queueNewEdge( applicationScope, targetEntity, edge );
+        }
 
         return connection;
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventService.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventService.java
index 6d51679..ae5688c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventService.java
@@ -54,6 +54,8 @@ public interface AsyncEventService extends ReIndexAction {
     /**
      * Fired when a new edge is added to an entity. Such as initial entity creation, adding to a collection, or creating a connection
      *
+     * TODO: We shouldn't take an entity here, only the id.  It doesn't make sense in a distributed context to pass the entity
+     *
      * @param applicationScope
      * @param entity
      * @param newEdge

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/PipelineBuilderFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/PipelineBuilderFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/PipelineBuilderFactory.java
index 6cb515b..ada1779 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/PipelineBuilderFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/PipelineBuilderFactory.java
@@ -23,6 +23,9 @@ package org.apache.usergrid.corepersistence.pipeline.builder;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 
 
+/**
+ * Factory interface for creating our pipeline builders
+ */
 public interface PipelineBuilderFactory {
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionScope.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionScope.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionScope.java
new file mode 100644
index 0000000..3cc9ae5
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionScope.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.corepersistence.service;
+
+
+import java.io.Serializable;
+
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.graph.Edge;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+
+/**
+ * Tuple containing our application scope, and an edge within that applications' graph
+ */
+public class ConnectionScope implements Serializable {
+    private final Edge edge;
+    private final ApplicationScope applicationScope;
+
+
+
+
+    public ConnectionScope( ApplicationScope applicationScope, final Edge edge ) {
+        this.edge = edge;
+        this.applicationScope = applicationScope;
+    }
+
+
+    public Edge getEdge() {
+        return edge;
+    }
+
+
+    public ApplicationScope getApplicationScope() {
+        return applicationScope;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionService.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionService.java
index 71a25c9..539c881 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionService.java
@@ -20,6 +20,7 @@ package org.apache.usergrid.corepersistence.service;
 
 import org.apache.usergrid.corepersistence.pipeline.read.ResultsPage;
 import org.apache.usergrid.persistence.ConnectionRef;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.Id;
 
@@ -46,4 +47,13 @@ public interface ConnectionService {
      * @return
      */
     Observable<ResultsPage<ConnectionRef>> searchConnectionAsRefs( final ConnectionSearch search );
+
+
+    /**
+     * An observable that will remove duplicate edges from the graph that represent connections.  All emitted scopes are scopes that have been deleted.
+     *
+     * @param applicationScopeObservable
+     * @return
+     */
+    Observable<ConnectionScope> deDupeConnections(final Observable<ApplicationScope> applicationScopeObservable);
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
index c7e0fee..82c1038 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
@@ -22,7 +22,18 @@ import org.apache.usergrid.corepersistence.pipeline.builder.EntityBuilder;
 import org.apache.usergrid.corepersistence.pipeline.builder.IdBuilder;
 import org.apache.usergrid.corepersistence.pipeline.builder.PipelineBuilderFactory;
 import org.apache.usergrid.corepersistence.pipeline.read.ResultsPage;
+import org.apache.usergrid.corepersistence.rx.impl.AllEntityIdsObservable;
+import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 import org.apache.usergrid.persistence.ConnectionRef;
+import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.graph.GraphManager;
+import org.apache.usergrid.persistence.graph.GraphManagerFactory;
+import org.apache.usergrid.persistence.graph.SearchByEdge;
+import org.apache.usergrid.persistence.graph.SearchByEdgeType;
+import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge;
+import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
+import org.apache.usergrid.persistence.graph.impl.SimpleSearchEdgeType;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.Id;
 
@@ -37,11 +48,17 @@ import rx.Observable;
 public class ConnectionServiceImpl implements ConnectionService {
 
     private final PipelineBuilderFactory pipelineBuilderFactory;
+    private final AllEntityIdsObservable allEntityIdsObservable;
+    private final GraphManagerFactory graphManagerFactory;
 
 
     @Inject
-    public ConnectionServiceImpl( final PipelineBuilderFactory pipelineBuilderFactory ) {
+    public ConnectionServiceImpl( final PipelineBuilderFactory pipelineBuilderFactory,
+                                  final AllEntityIdsObservable allEntityIdsObservable,
+                                  final GraphManagerFactory graphManagerFactory ) {
         this.pipelineBuilderFactory = pipelineBuilderFactory;
+        this.allEntityIdsObservable = allEntityIdsObservable;
+        this.graphManagerFactory = graphManagerFactory;
     }
 
 
@@ -117,4 +134,50 @@ public class ConnectionServiceImpl implements ConnectionService {
 
         return results;
     }
+
+
+    @Override
+    public Observable<ConnectionScope> deDupeConnections(
+        final Observable<ApplicationScope> applicationScopeObservable ) {
+
+
+        final Observable<EntityIdScope> entityIds =allEntityIdsObservable.getEntities( applicationScopeObservable );
+        //now we have an observable of entityIds.  Walk each connection type
+
+        //get all edge types for connections
+       return  entityIds.flatMap( entityIdScope -> {
+
+            final ApplicationScope applicationScope = entityIdScope.getApplicationScope();
+            final Id entityId = entityIdScope.getId();
+
+            final GraphManager gm = graphManagerFactory.createEdgeManager(applicationScope );
+
+            return gm.getEdgeTypesFromSource(
+                new SimpleSearchEdgeType( entityId, CpNamingUtils.EDGE_CONN_PREFIX, Optional.absent() ) )
+
+                //now load all edges from this node of this type
+                .flatMap( edgeType -> {
+                    final SearchByEdgeType searchByEdge =
+                        new SimpleSearchByEdgeType( entityId, edgeType, Long.MAX_VALUE,
+                            SearchByEdgeType.Order.ASCENDING, Optional.absent() );
+
+                    //load edges from the source the with type specified
+                    return gm.loadEdgesFromSource( searchByEdge );
+                } )
+
+                //now that we have a stream of edges, stream all versions
+                .flatMap( edge -> {
+                    final SearchByEdge searchByEdge =
+                        new SimpleSearchByEdge( edge.getSourceNode(), edge.getType(), edge.getTargetNode(),
+                            Long.MAX_VALUE, SearchByEdgeType.Order.ASCENDING, Optional.absent() );
+                    return gm.loadEdgeVersions( searchByEdge );
+                } )
+
+            //skip the first version since it's the one we want to retain
+            // validate there is only 1 version of it, delete anything > than the min
+                .skip( 1 )
+                .flatMap( edgeToDelete -> gm.deleteEdge( edgeToDelete ) )
+                .map(deletedEdge ->  new ConnectionScope( applicationScope, deletedEdge ) ) ;
+        });
+    }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
index f32e9d7..55bc49a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
@@ -21,8 +21,6 @@ package org.apache.usergrid.corepersistence.util;
 
 import java.util.UUID;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
 import org.apache.usergrid.persistence.entities.Application;
@@ -42,7 +40,8 @@ import org.apache.usergrid.persistence.map.impl.MapScopeImpl;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.apache.usergrid.utils.UUIDUtils;
+
+import com.google.common.base.Optional;
 
 
 /**
@@ -257,6 +256,7 @@ public class CpNamingUtils {
     }
 
 
+
     /**
      * Get the application scope from the given uuid
      *
@@ -309,6 +309,8 @@ public class CpNamingUtils {
     }
 
 
+
+
     private static boolean isCollectionEdgeType( String type ) {
         return type.startsWith( EDGE_COLL_PREFIX );
     }
@@ -326,8 +328,5 @@ public class CpNamingUtils {
     }
 
 
-    public static boolean isApplication(Id id) {
-        Preconditions.checkNotNull(id);
-        return id.getType().equals("application");
-    }
+
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestCoreModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestCoreModule.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestCoreModule.java
new file mode 100644
index 0000000..32b9845
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestCoreModule.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.corepersistence;
+
+
+import org.apache.usergrid.persistence.core.guice.TestModule;
+
+
+/**
+ * Test guice module for our core guice configuration
+ */
+public class TestCoreModule extends TestModule {
+
+    @Override
+    protected void configure() {
+
+        install( new CoreModule() );
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
new file mode 100644
index 0000000..0a29286
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.corepersistence.service;
+
+
+import java.util.List;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.apache.usergrid.corepersistence.TestCoreModule;
+import org.apache.usergrid.corepersistence.util.CpNamingUtils;
+import org.apache.usergrid.persistence.core.guice.MigrationManagerRule;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
+import org.apache.usergrid.persistence.core.test.ITRunner;
+import org.apache.usergrid.persistence.core.test.UseModules;
+import org.apache.usergrid.persistence.graph.Edge;
+import org.apache.usergrid.persistence.graph.GraphManager;
+import org.apache.usergrid.persistence.graph.GraphManagerFactory;
+import org.apache.usergrid.persistence.graph.SearchByEdge;
+import org.apache.usergrid.persistence.graph.SearchByEdgeType;
+import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+
+import com.google.common.base.Optional;
+import com.google.inject.Inject;
+
+import rx.Observable;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+
+@RunWith( ITRunner.class )
+@UseModules( TestCoreModule.class )
+public class ConnectionServiceImplTest {
+
+    @Inject
+    private GraphManagerFactory graphManagerFactory;
+
+    @Inject
+    private ConnectionService connectionService;
+
+    @Inject
+    @Rule
+    public MigrationManagerRule migrationManagerRule;
+
+
+    @Test
+    public void testSingleConnection() {
+
+        final ApplicationScope applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) );
+
+
+        final GraphManager gm = graphManagerFactory.createEdgeManager( applicationScope );
+
+        //now write a single connection
+
+        final Id source = new SimpleId( "source" );
+
+
+        //add to a collection
+
+        final String collectionName = "testCollection";
+
+        final Edge collectionEdge = CpNamingUtils.createCollectionEdge( applicationScope.getApplication(), collectionName, source );
+
+        final Edge writtenCollection = gm.writeEdge( collectionEdge ).toBlocking().last();
+
+        assertNotNull("Collection edge written", writtenCollection);
+
+
+
+
+        final Id target = new SimpleId( "target" );
+
+        final String connectionType = "testConnection";
+
+        final Edge connectionEdge = CpNamingUtils.createConnectionEdge( source, connectionType, target );
+
+        final Edge writtenConnection = gm.writeEdge( connectionEdge ).toBlocking().last();
+
+
+        //now run the cleanup
+
+        final int count =
+            connectionService.deDupeConnections( Observable.just( applicationScope ) ).count().toBlocking().last();
+
+        assertEquals( "No edges deleted", 0, count );
+
+        //now ensure we can read the edge.
+
+        final SearchByEdge simpleSearchByEdge =
+            new SimpleSearchByEdge( source, connectionEdge.getType(), target, Long.MAX_VALUE,
+                SearchByEdgeType.Order.DESCENDING, Optional.absent() );
+
+        final List<Edge> edges = gm.loadEdgeVersions( simpleSearchByEdge ).toList().toBlocking().last();
+
+        assertEquals( 1, edges.size() );
+
+        assertEquals( writtenConnection, edges.get( 0 ) );
+    }
+
+
+    @Test
+    public void testDuplicateConnections() {
+
+        final ApplicationScope applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) );
+
+
+        final GraphManager gm = graphManagerFactory.createEdgeManager( applicationScope );
+
+        //now write a single connection
+
+        final Id source = new SimpleId( "source" );
+
+        final Id target = new SimpleId( "target" );
+
+        final String connectionType = "testConnection";
+
+
+          //add to a collection
+
+        final String collectionName = "testCollection";
+
+        final Edge collectionEdge = CpNamingUtils.createCollectionEdge( applicationScope.getApplication(), collectionName, source );
+
+        final Edge writtenCollection = gm.writeEdge( collectionEdge ).toBlocking().last();
+
+        assertNotNull("Collection edge written", writtenCollection);
+
+        //write our first connection
+        final Edge connection1 = CpNamingUtils.createConnectionEdge( source, connectionType, target );
+
+        final Edge written1 = gm.writeEdge( connection1 ).toBlocking().last();
+
+
+        //write the second
+        final Edge connection2 = CpNamingUtils.createConnectionEdge( source, connectionType, target );
+
+        final Edge written2 = gm.writeEdge( connection2 ).toBlocking().last();
+
+
+        //write the 3rd
+        final Edge connection3 = CpNamingUtils.createConnectionEdge( source, connectionType, target );
+
+        final Edge written3 = gm.writeEdge( connection3 ).toBlocking().last();
+
+
+
+
+        //now run the cleanup
+
+        final List<ConnectionScope> deletedConnections =
+            connectionService.deDupeConnections( Observable.just( applicationScope ) ).toList().toBlocking().last();
+
+        assertEquals( "2 edges deleted", 2, deletedConnections.size() );
+
+        //check our oldest was deleted first
+
+        assertEquals(written2, deletedConnections.get( 0 ));
+
+        assertEquals(written3, deletedConnections.get( 1 ));
+
+
+
+        //now ensure we can read the edge.
+
+        final SearchByEdge simpleSearchByEdge =
+            new SimpleSearchByEdge( source, connection1.getType(), target, Long.MAX_VALUE,
+                SearchByEdgeType.Order.DESCENDING, Optional.absent() );
+
+        //check only 1 exists
+        final List<Edge> edges = gm.loadEdgeVersions( simpleSearchByEdge ).toList().toBlocking().last();
+
+        assertEquals( 1, edges.size() );
+
+        assertEquals( written1, edges.get( 0 ) );
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/core/src/test/resources/log4j.properties b/stack/core/src/test/resources/log4j.properties
index dfcb260..dd29671 100644
--- a/stack/core/src/test/resources/log4j.properties
+++ b/stack/core/src/test/resources/log4j.properties
@@ -18,7 +18,8 @@
 # and the pattern to %c instead of %l.  (%l is slower.)
 
 # output messages into a rolling log file as well as stdout
-log4j.rootLogger=ERROR,stdout
+#log4j.rootLogger=ERROR,stdout\
+log4j.rootLogger=DEBUG,stdout
 
 # stdout
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/TargetIdObservableImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/TargetIdObservableImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/TargetIdObservableImpl.java
index 82c7d54..bd8cd3c 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/TargetIdObservableImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/TargetIdObservableImpl.java
@@ -55,18 +55,13 @@ public class TargetIdObservableImpl implements TargetIdObservable {
     public Observable<Id> getTargetNodes(final GraphManager gm, final Id sourceNode) {
 
         //only search edge types that start with collections
-        return edgesFromSourceObservable.edgesFromSourceDescending( gm, sourceNode ).map( new Func1<Edge, Id>() {
+        return edgesFromSourceObservable.edgesFromSourceDescending( gm, sourceNode ).map( edge -> {
+            final Id targetNode = edge.getTargetNode();
 
+            logger.debug( "Emitting targetId of {}", edge );
 
-            @Override
-            public Id call( final Edge edge ) {
-                final Id targetNode = edge.getTargetNode();
 
-                logger.debug( "Emitting targetId of {}", edge );
-
-
-                return targetNode;
-            }
+            return targetNode;
         } );
     }
 }


[21/44] usergrid git commit: Reduces logging and adds filter into delete listener

Posted by md...@apache.org.
Reduces logging and adds filter into delete listener


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

Branch: refs/heads/USERGRID-933
Commit: b7a22c2d51602e32692b22ad584ce128b1592ed0
Parents: 6233bf0
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Sep 15 17:27:14 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Sep 15 17:27:14 2015 -0600

----------------------------------------------------------------------
 stack/core/src/test/resources/log4j.properties                   | 4 ++--
 .../persistence/graph/impl/stage/EdgeDeleteRepairImpl.java       | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/b7a22c2d/stack/core/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/core/src/test/resources/log4j.properties b/stack/core/src/test/resources/log4j.properties
index 93951fe..4267293 100644
--- a/stack/core/src/test/resources/log4j.properties
+++ b/stack/core/src/test/resources/log4j.properties
@@ -19,7 +19,7 @@
 
 # output messages into a rolling log file as well as stdout
 #log4j.rootLogger=ERROR,stdout\
-log4j.rootLogger=DEBUG,stdout
+log4j.rootLogger=INFO,stdout
 
 # stdout
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
@@ -48,7 +48,7 @@ log4j.logger.org.apache.usergrid.corepersistence.migration=WARN
 
 #Debug our queries
 #log4j.logger.org.apache.usergrid.persistence.index.impl.EsApplicationEntityIndexImpl=DEBUG
-log4j.logger.org.apache.usergrid.corepersistence.service.ConnectionServiceImpl=DEBUG
+#log4j.logger.org.apache.usergrid.corepersistence.service.ConnectionServiceImpl=DEBUG
 
 #log4j.logger.org.apache.usergrid.persistence.index.impl=DEBUG
 #log4j.logger.org.apache.usergrid.corepersistence.CpSetup=INFO

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b7a22c2d/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java
index 643dcc1..a87a079 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java
@@ -79,7 +79,7 @@ public class EdgeDeleteRepairImpl implements EdgeDeleteRepair {
 
 
         //merge source and target then deal with the distinct values
-        return Observable.just( edge )
+        return Observable.just( edge ).filter( markedEdge-> markedEdge.isDeleted() )
                 .doOnNext( markedEdge -> {
                     //it's still in the same state as it was when we queued it. Remove it
                         LOG.info( "Removing edge {} ", markedEdge );


[43/44] usergrid git commit: Merge branch '2.1-release' of https://git-wip-us.apache.org/repos/asf/usergrid into USERGRID-933

Posted by md...@apache.org.
Merge branch '2.1-release' of https://git-wip-us.apache.org/repos/asf/usergrid into USERGRID-933


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

Branch: refs/heads/USERGRID-933
Commit: 5ead5fdca6cc33b6cc5dc8a1f839a66dcd0246af
Parents: bd0f10b 0b243c4
Author: Mike Dunker <md...@apache.org>
Authored: Thu Sep 24 15:04:56 2015 -0700
Committer: Mike Dunker <md...@apache.org>
Committed: Thu Sep 24 15:04:56 2015 -0700

----------------------------------------------------------------------
 stack/scripts/migrate_entity_data.py            | 66 ++++++++++++++-----
 .../management/AppInfoMigrationPlugin.java      | 69 +++++++++-----------
 2 files changed, 79 insertions(+), 56 deletions(-)
----------------------------------------------------------------------



[22/44] usergrid git commit: Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into USERGRID-1018

Posted by md...@apache.org.
Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into USERGRID-1018


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

Branch: refs/heads/USERGRID-933
Commit: fb1cf2e939fc123b9468df372c80664459ef0b96
Parents: b7a22c2 723ee3a
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Sep 15 17:27:20 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Sep 15 17:27:20 2015 -0600

----------------------------------------------------------------------
 .../rx/impl/AllApplicationsObservableImpl.java  | 36 +++-----
 .../corepersistence/CpEntityMapUtilsTest.java   |  4 +-
 .../org/apache/usergrid/persistence/GeoIT.java  | 52 ++++++++++-
 .../migration/MvccEntityDataMigrationImpl.java  | 94 +++++++++++---------
 .../model/entity/MapToEntityConverter.java      |  8 +-
 5 files changed, 119 insertions(+), 75 deletions(-)
----------------------------------------------------------------------



[11/44] usergrid git commit: Change 'expire' property for notifications to support milliseconds, matching the 'deliver' property.

Posted by md...@apache.org.
Change 'expire' property for notifications to support milliseconds, matching the 'deliver' property.


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

Branch: refs/heads/USERGRID-933
Commit: ca32186e9117fd51c56c4320cd816c1be381b79b
Parents: 5680173
Author: Michael Russo <mi...@gmail.com>
Authored: Fri Sep 11 16:50:16 2015 -0700
Committer: Michael Russo <mi...@gmail.com>
Committed: Fri Sep 11 16:50:16 2015 -0700

----------------------------------------------------------------------
 .../apache/usergrid/persistence/entities/Notification.java    | 7 +++----
 .../usergrid/services/notifications/gcm/GCMAdapter.java       | 2 +-
 .../services/notifications/apns/NotificationsServiceIT.java   | 2 +-
 .../services/notifications/gcm/NotificationsServiceIT.java    | 2 +-
 4 files changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/ca32186e/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
index d1101a5..362201a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
@@ -147,7 +147,7 @@ public class Notification extends TypedEntity {
 
     @JsonIgnore
     public boolean isExpired() {
-        return expire != null && expire > System.currentTimeMillis();
+        return expire != null && expire < System.currentTimeMillis();
     }
 
     @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@@ -232,13 +232,12 @@ public class Notification extends TypedEntity {
 
     @JsonIgnore
     public long getExpireTimeMillis() {
-        long expireAtMillis = getExpire() != null ? getExpire() * 1000 : 0;
-        return expireAtMillis;
+        return getExpire() != null ? getExpire() : 0;
     }
 
     @JsonIgnore
     public long getExpireTTLSeconds() {
-        Long ttlSeconds = (getExpireTimeMillis() - new Date().getTime()) / 1000;
+        long ttlSeconds = (getExpireTimeMillis() - System.currentTimeMillis()) / 1000;
         return ttlSeconds > 0 ? ttlSeconds : 0;
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ca32186e/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
index df1b580..bdd7737 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
@@ -71,7 +71,7 @@ public class GCMAdapter implements ProviderAdapter {
         final String expiresKey = "time_to_live";
         if(!map.containsKey(expiresKey) && notification.getExpire() != null){
             // ttl provided to GCM is in seconds.  calculate the difference from now
-            Long ttlSeconds = notification.getExpireTTLSeconds();
+            long ttlSeconds = notification.getExpireTTLSeconds();
             // max ttl for gcm is 4 weeks - https://developers.google.com/cloud-messaging/http-server-ref
             ttlSeconds = ttlSeconds <= 2419200 ? ttlSeconds : 2419200;
             map.put(expiresKey, ttlSeconds);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ca32186e/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
index bd248a5..9c1bcbe 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
@@ -153,7 +153,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
         app.put("payloads", payloads);
         app.put("queued", System.currentTimeMillis());
         app.put("debug",true);
-        app.put("expire", (System.currentTimeMillis() / 1000) + 300); // add 5 minutes to current time
+        app.put("expire", System.currentTimeMillis() + 300000); // add 5 minutes to current time
 
         // post notification to service manager
         Entity e = app.testRequest(ServiceAction.POST, 1,"devices",device1.getUuid(), "notifications").getEntity();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ca32186e/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
index 38a6f2e..96653a5 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
@@ -153,7 +153,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
         app.put("payloads", payloads);
         app.put("queued", System.currentTimeMillis());
         app.put("debug",true);
-        app.put("expire", (System.currentTimeMillis() / 1000) + 300); // add 5 minutes to current time
+        app.put("expire", System.currentTimeMillis() + 300000); // add 5 minutes to current time
 
         Entity e = app.testRequest(ServiceAction.POST, 1, "devices",device1.getUuid(),"notifications").getEntity();
         app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid());


[39/44] usergrid git commit: Merge branch '2.1-release' of https://git-wip-us.apache.org/repos/asf/usergrid into USERGRID-933

Posted by md...@apache.org.
Merge branch '2.1-release' of https://git-wip-us.apache.org/repos/asf/usergrid into USERGRID-933


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

Branch: refs/heads/USERGRID-933
Commit: bd0f10b4a457bf1aff01de48f1302e3951448344
Parents: c035fb4 8281430
Author: Mike Dunker <md...@apache.org>
Authored: Wed Sep 23 12:44:13 2015 -0700
Committer: Mike Dunker <md...@apache.org>
Committed: Wed Sep 23 12:44:13 2015 -0700

----------------------------------------------------------------------
 .../creating-and-managing-notifications.md      |   2 +
 portal/bower.json                               |   2 +-
 portal/js/libs/usergrid.sdk.js                  |   8 +-
 portal/package.json                             |   2 +-
 .../usergrid/corepersistence/CoreModule.java    |  51 +++-
 .../corepersistence/CpRelationManager.java      |  34 ++-
 .../asyncevents/AmazonAsyncEventService.java    |   6 +-
 .../asyncevents/AsyncEventService.java          |   2 +
 .../migration/CoreMigration.java                |  45 +--
 .../migration/CoreMigrationPlugin.java          |  38 ++-
 .../migration/DeDupConnectionDataMigration.java |  93 ++++++
 .../migration/EntityTypeMappingMigration.java   | 104 -------
 .../migration/MigrationModuleVersionPlugin.java |   5 -
 .../corepersistence/migration/Versions.java     |  31 --
 .../builder/PipelineBuilderFactory.java         |   3 +
 .../rx/impl/AllApplicationsObservableImpl.java  |  36 +--
 .../service/ConnectionScope.java                |  53 ++++
 .../service/ConnectionService.java              |  10 +
 .../service/ConnectionServiceImpl.java          |  90 +++++-
 .../corepersistence/util/CpNamingUtils.java     |  13 +-
 .../persistence/entities/Notification.java      |  13 +-
 .../corepersistence/CpEntityMapUtilsTest.java   |  52 +++-
 .../corepersistence/TestCoreModule.java         |  34 +++
 .../DeDupConnectionDataMigrationTest.java       | 145 +++++++++
 .../migration/EntityTypeMappingMigrationIT.java | 125 --------
 .../service/ConnectionServiceImplTest.java      | 235 +++++++++++++++
 .../org/apache/usergrid/persistence/GeoIT.java  |  52 +++-
 stack/core/src/test/resources/log4j.properties  |   6 +-
 .../serialization/impl/SerializationModule.java |   4 +-
 .../migration/CollectionMigrationPlugin.java    |   8 +-
 .../migration/MvccEntityDataMigrationImpl.java  | 104 ++++---
 ...ctMvccEntityDataMigrationV1ToV3ImplTest.java |  39 ++-
 .../migration/data/AbstractMigrationPlugin.java |  17 +-
 .../core/migration/data/DataMigration.java      |  11 +-
 .../migration/data/MigrationDataProvider.java   |   2 +-
 .../core/migration/data/MigrationPlugin.java    |   4 +-
 .../migration/schema/MigrationManagerFig.java   |   1 +
 .../migration/data/TestProgressObserver.java    |  10 +-
 .../persistence/graph/guice/GraphModule.java    |   4 +-
 .../graph/impl/GraphManagerImpl.java            |   4 +-
 .../impl/stage/EdgeDeleteListenerImpl.java      |   4 +-
 .../graph/impl/stage/EdgeDeleteRepairImpl.java  |  61 ++--
 .../impl/TargetIdObservableImpl.java            |  13 +-
 .../impl/migration/EdgeDataMigrationImpl.java   |  12 +-
 .../impl/migration/GraphMigrationPlugin.java    |   8 +-
 .../impl/shard/impl/EdgeSearcher.java           |  14 +-
 .../impl/ShardedEdgeSerializationImpl.java      |  59 ++--
 .../shard/impl/serialize/EdgeSerializer.java    |  21 +-
 .../persistence/graph/GraphManagerIT.java       |  73 ++++-
 .../migration/EdgeDataMigrationImplTest.java    |  59 ++--
 stack/corepersistence/model/pom.xml             |   6 +-
 .../model/entity/MapToEntityConverter.java      |  64 ++--
 .../persistence/index/CandidateResult.java      |  32 +-
 .../persistence/index/CandidateResults.java     |  34 +--
 .../SearchRequestBuilderStrategyV2.java         |  30 +-
 .../usergrid/persistence/index/IndexEdge.java   |  36 +--
 .../index/IndexLocationStrategy.java            |  30 +-
 .../persistence/index/IndexRefreshCommand.java  |  30 +-
 .../usergrid/persistence/index/SearchType.java  |  30 +-
 .../usergrid/persistence/index/SearchTypes.java |  32 +-
 .../persistence/index/SelectFieldMapping.java   |  36 +--
 .../persistence/index/guice/IndexModule.java    |   4 +-
 .../persistence/index/impl/EntityField.java     |  32 +-
 .../index/impl/EntityMappingParser.java         |  37 ++-
 .../index/impl/EsEntityIndexFactoryImpl.java    |  29 +-
 .../index/impl/EsIndexBufferConsumerImpl.java   |  28 +-
 .../index/impl/EsIndexCacheImpl.java            |  29 +-
 .../persistence/index/impl/EsQueryVistor.java   |  50 ++-
 .../persistence/index/impl/FailureMonitor.java  |  30 +-
 .../index/impl/FailureMonitorImpl.java          |  32 +-
 .../persistence/index/impl/FieldParser.java     |  36 +--
 .../persistence/index/impl/GeoSortFields.java   |  36 +--
 .../index/impl/IndexBufferConsumer.java         |  28 +-
 .../persistence/index/impl/IndexCache.java      |  30 +-
 .../persistence/index/impl/IndexEdgeImpl.java   |  36 +--
 .../index/impl/IndexIdentifierv2Impl.java       |  30 +-
 .../index/impl/IndexRefreshCommandImpl.java     |  30 +-
 .../index/impl/NoOpFilterBuilder.java           |  32 +-
 .../index/impl/NoOpQueryBuilder.java            |  32 +-
 .../impl/SearchRequestBuilderStrategy.java      |  30 +-
 .../persistence/index/impl/SortBuilder.java     |  36 +--
 .../EsIndexMappingMigrationPlugin.java          |  30 +-
 .../index/migration/EsIndexMigrationPlugin.java |   8 +-
 .../index/migration/IndexDataVersions.java      |  30 +-
 .../persistence/index/query/ParsedQuery.java    |  36 +--
 .../index/query/ParsedQueryBuilder.java         |  36 +--
 .../persistence/index/query/SortPredicate.java  |  36 +--
 .../persistence/index/usergrid-mappings.json    |   5 -
 .../persistence/index/impl/EntityIndexTest.java |  13 +-
 .../index/impl/EntityToMapConverterTest.java    |  38 +--
 .../impl/EsIndexMappingMigrationPluginTest.java |  30 +-
 .../persistence/index/impl/EsRunner.java        |  32 +-
 .../persistence/index/impl/GeoPagingTest.java   |  36 +--
 .../index/impl/TestIndexIdentifier.java         |  30 +-
 .../queue/impl/QueueManagerFactoryImpl.java     |  16 +-
 .../rest/applications/ApplicationResource.java  |  11 +-
 .../exceptions/AbstractExceptionMapper.java     |  13 +-
 .../applications/ApplicationResourceIT.java     |  12 +
 .../users/ConnectionResourceTest.java           | 302 ++++++++++++++-----
 stack/scripts/migrate_entity_data.py            |  17 ++
 .../management/AppInfoMigrationPlugin.java      | 234 +++++++-------
 .../services/AbstractConnectionsService.java    |  43 ++-
 .../notifications/apns/APNsNotification.java    |   8 +-
 .../services/notifications/gcm/GCMAdapter.java  |   9 +-
 .../services/notifications/wns/WNSAdapter.java  |  13 +-
 .../apns/NotificationsServiceIT.java            |   1 +
 .../gcm/NotificationsServiceIT.java             |   1 +
 107 files changed, 2360 insertions(+), 1489 deletions(-)
----------------------------------------------------------------------



[38/44] usergrid git commit: Adds rest tests and fixes bugs with POST/PUT re-ordering

Posted by md...@apache.org.
Adds rest tests and fixes bugs with POST/PUT re-ordering


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

Branch: refs/heads/USERGRID-933
Commit: 82814303135e47cc976fea373396aad85afb07f5
Parents: 079ba97
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Sep 23 11:32:11 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Sep 23 11:32:11 2015 -0600

----------------------------------------------------------------------
 .../corepersistence/CpRelationManager.java      |   7 +-
 .../users/ConnectionResourceTest.java           | 302 ++++++++++++++-----
 .../services/AbstractConnectionsService.java    |  43 ++-
 3 files changed, 275 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/82814303/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 21a2ee7..de687b3 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -713,15 +713,16 @@ public class CpRelationManager implements RelationManager {
             if ( logger.isDebugEnabled() ) {
                 logger.debug( "Marking edge {} for deletion", edgeToDelete );
             }
-            return gm.markEdge( edge );
+            return gm.markEdge( edgeToDelete );
         } ).lastOrDefault( null ).doOnNext( lastEdge -> {
             //no op if we hit our default
             if(lastEdge == null){
                 return;
             }
 
-            //queue up async processing
-            indexService.queueDeleteEdge( applicationScope, lastEdge );
+            //don't queue delete b/c that de-indexes, we need to delete the edges only since we have a version still existing to index.
+
+            gm.deleteEdge( lastEdge ).subscribe();
         }).subscribe();
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/82814303/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
index 22a6165..777b04e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
@@ -17,19 +17,26 @@
 package org.apache.usergrid.rest.applications.collection.users;
 
 
-import com.sun.jersey.api.client.UniformInterfaceException;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.endpoints.CollectionEndpoint;
+import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource.model.Collection;
 import org.apache.usergrid.rest.test.resource.model.Entity;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 
-import java.io.IOException;
-import java.util.Map;
+import com.sun.jersey.api.client.UniformInterfaceException;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 
 /**
@@ -39,44 +46,46 @@ import static org.junit.Assert.*;
  * @since 4.0
  */
 public class ConnectionResourceTest extends AbstractRestIT {
-    private static Logger log = LoggerFactory.getLogger(ConnectionResourceTest.class);
+    private static Logger log = LoggerFactory.getLogger( ConnectionResourceTest.class );
+
 
     @Test
     public void connectionsQueryTest() throws IOException {
 
         //create a peep
         Entity peep = new Entity();
-        peep.put("type", "chicken");
+        peep.put( "type", "chicken" );
 
-        peep = this.app().collection("peeps").post(peep);
+        peep = this.app().collection( "peeps" ).post( peep );
 
 
         Entity todd = new Entity();
-        todd.put("username", "todd");
-        todd = this.app().collection("users").post(todd);
+        todd.put( "username", "todd" );
+        todd = this.app().collection( "users" ).post( todd );
 
         Entity scott = new Entity();
-        scott.put("username", "scott");
-        scott = this.app().collection("users").post(scott);
+        scott.put( "username", "scott" );
+        scott = this.app().collection( "users" ).post( scott );
 
         Entity objectOfDesire = new Entity();
-        objectOfDesire.put("codingmunchies", "doritoes");
-        objectOfDesire = this.app().collection("snacks").post(objectOfDesire);
+        objectOfDesire.put( "codingmunchies", "doritoes" );
+        objectOfDesire = this.app().collection( "snacks" ).post( objectOfDesire );
         refreshIndex();
 
-        Entity toddWant = this.app().collection("users").entity(todd).collection("likes").collection("snacks").entity(objectOfDesire).post();
-        assertNotNull(toddWant);
+        Entity toddWant = this.app().collection( "users" ).entity( todd ).collection( "likes" ).collection( "snacks" )
+                              .entity( objectOfDesire ).post();
+        assertNotNull( toddWant );
 
         try {
 
-            this.app().collection("users").entity(scott).collection("likes").collection("peeps").entity(peep).get();
-            fail("This should throw an exception");
-        } catch (UniformInterfaceException uie) {
+            this.app().collection( "users" ).entity( scott ).collection( "likes" ).collection( "peeps" ).entity( peep )
+                .get();
+            fail( "This should throw an exception" );
+        }
+        catch ( UniformInterfaceException uie ) {
             // Should return a 404 Not Found
-            assertEquals(404, uie.getResponse().getStatus());
+            assertEquals( 404, uie.getResponse().getStatus() );
         }
-
-
     }
 
 
@@ -85,125 +94,274 @@ public class ConnectionResourceTest extends AbstractRestIT {
 
         // create entities thing1 and thing2
         Entity thing1 = new Entity();
-        thing1.put("name", "thing1");
-        thing1 = this.app().collection("things").post(thing1);
+        thing1.put( "name", "thing1" );
+        thing1 = this.app().collection( "things" ).post( thing1 );
 
         Entity thing2 = new Entity();
-        thing2.put("name", "thing2");
-        thing2 = this.app().collection("things").post(thing2);
+        thing2.put( "name", "thing2" );
+        thing2 = this.app().collection( "things" ).post( thing2 );
 
         refreshIndex();
         //create the connection: thing1 likes thing2
-        this.app().collection("things").entity(thing1).connection("likes").collection("things").entity(thing2).post();
+        this.app().collection( "things" ).entity( thing1 ).connection( "likes" ).collection( "things" ).entity( thing2 )
+            .post();
         refreshIndex();
 
         //test we have the "likes" in our connection meta data response
-        thing1 = this.app().collection("things").entity(thing1).get();
+        thing1 = this.app().collection( "things" ).entity( thing1 ).get();
         //TODO this is ugly. revisit.
-        String url = (String) ((Map<String, Object>) ((Map<String, Object>) thing1.get("metadata")).get("connections")).get("likes");
-        assertNotNull("Connection url returned with entity", url);
+        String url = ( String ) ( ( Map<String, Object> ) ( ( Map<String, Object> ) thing1.get( "metadata" ) )
+            .get( "connections" ) ).get( "likes" );
+        assertNotNull( "Connection url returned with entity", url );
 
         //now that we know the URl is correct, follow it
-        CollectionEndpoint likesEndpoint = new CollectionEndpoint(url, this.context(), this.app());
+        CollectionEndpoint likesEndpoint = new CollectionEndpoint( url, this.context(), this.app() );
         Collection likes = likesEndpoint.get();
-        assertNotNull(likes);
+        assertNotNull( likes );
         Entity likedEntity = likes.next();
-        assertNotNull(likedEntity);
+        assertNotNull( likedEntity );
 
         //make sure the returned entity is thing2
-        assertEquals(thing2.getUuid(), likedEntity.getUuid());
+        assertEquals( thing2.getUuid(), likedEntity.getUuid() );
 
 
         //now follow the loopback, which should be pointers to the other entity
-        thing2 = this.app().collection("things").entity(thing2).get();
+        thing2 = this.app().collection( "things" ).entity( thing2 ).get();
         //TODO this is ugly. revisit.
-        url = (String) ((Map<String, Object>) ((Map<String, Object>) thing2.get("metadata")).get("connecting")).get("likes");
-        assertNotNull("Connecting url returned with entity", url);
+        url = ( String ) ( ( Map<String, Object> ) ( ( Map<String, Object> ) thing2.get( "metadata" ) )
+            .get( "connecting" ) ).get( "likes" );
+        assertNotNull( "Connecting url returned with entity", url );
 
-        CollectionEndpoint likedByEndpoint = new CollectionEndpoint(url, this.context(), this.app());
+        CollectionEndpoint likedByEndpoint = new CollectionEndpoint( url, this.context(), this.app() );
         Collection likedBy = likedByEndpoint.get();
-        assertNotNull(likedBy);
+        assertNotNull( likedBy );
         Entity likedByEntity = likedBy.next();
-        assertNotNull(likedByEntity);
+        assertNotNull( likedByEntity );
 
         //make sure the returned entity is thing1
-        assertEquals(thing1.getUuid(), likedByEntity.getUuid());
-
+        assertEquals( thing1.getUuid(), likedByEntity.getUuid() );
     }
 
 
     /**
-     * Ensure that the connected entity can be deleted
-     * properly after it has been connected to another entity
-     *
-     * @throws IOException
+     * Ensure that the connected entity can be deleted properly after it has been connected to another entity
      */
     @Test //USERGRID-3011
     public void connectionsDeleteSecondEntityInConnectionTest() throws IOException {
 
         //Create 2 entities, thing1 and thing2
         Entity thing1 = new Entity();
-        thing1.put("name", "thing1");
-        thing1 = this.app().collection("things").post(thing1);
+        thing1.put( "name", "thing1" );
+        thing1 = this.app().collection( "things" ).post( thing1 );
 
         Entity thing2 = new Entity();
-        thing2.put("name", "thing2");
-        thing2 = this.app().collection("things").post(thing2);
+        thing2.put( "name", "thing2" );
+        thing2 = this.app().collection( "things" ).post( thing2 );
 
         refreshIndex();
         //create the connection: thing1 likes thing2
-        this.app().collection("things").entity(thing1).connection("likes").collection("things").entity(thing2).post();
+        this.app().collection( "things" ).entity( thing1 ).connection( "likes" ).collection( "things" ).entity( thing2 )
+            .post();
         //delete thing2
-        this.app().collection("things").entity(thing2).delete();
+        this.app().collection( "things" ).entity( thing2 ).delete();
 
         refreshIndex();
 
         try {
             //attempt to retrieve thing1
-            thing2 = this.app().collection("things").entity(thing2).get();
-            fail("This should throw an exception");
-        } catch (UniformInterfaceException uie) {
+            thing2 = this.app().collection( "things" ).entity( thing2 ).get();
+            fail( "This should throw an exception" );
+        }
+        catch ( UniformInterfaceException uie ) {
             // Should return a 404 Not Found
-            assertEquals(404, uie.getResponse().getStatus());
+            assertEquals( 404, uie.getResponse().getStatus() );
         }
     }
 
+
     /**
-     * Ensure that the connecting entity can be deleted
-     * properly after a connection has been added
-     *
-     * @throws IOException
+     * Ensure that the connecting entity can be deleted properly after a connection has been added
      */
     @Test //USERGRID-3011
     public void connectionsDeleteFirstEntityInConnectionTest() throws IOException {
 
         //Create 2 entities, thing1 and thing2
         Entity thing1 = new Entity();
-        thing1.put("name", "thing1");
-        thing1 = this.app().collection("things").post(thing1);
+        thing1.put( "name", "thing1" );
+        thing1 = this.app().collection( "things" ).post( thing1 );
 
         Entity thing2 = new Entity();
-        thing2.put("name", "thing2");
-        thing2 = this.app().collection("things").post(thing2);
+        thing2.put( "name", "thing2" );
+        thing2 = this.app().collection( "things" ).post( thing2 );
 
         refreshIndex();
         //create the connection: thing1 likes thing2
-        this.app().collection("things").entity(thing1).connection("likes").collection("things").entity(thing2).post();
+        this.app().collection( "things" ).entity( thing1 ).connection( "likes" ).collection( "things" ).entity( thing2 )
+            .post();
         //delete thing1
-        this.app().collection("things").entity(thing1).delete();
+        this.app().collection( "things" ).entity( thing1 ).delete();
 
         refreshIndex();
 
         try {
             //attempt to retrieve thing1
-            thing1 = this.app().collection("things").entity(thing1).get();
-            fail("This should throw an exception");
-        } catch (UniformInterfaceException uie) {
+            thing1 = this.app().collection( "things" ).entity( thing1 ).get();
+            fail( "This should throw an exception" );
+        }
+        catch ( UniformInterfaceException uie ) {
             // Should return a 404 Not Found
-            assertEquals(404, uie.getResponse().getStatus());
+            assertEquals( 404, uie.getResponse().getStatus() );
         }
+    }
+
+
+    /**
+     * UERGRID-1018
+     */
+    @Test
+    public void testRePostOrder() {
+
+        Entity thing1 = new Entity();
+        thing1.put( "name", "thing1" );
+
+        final CollectionEndpoint collection = this.app().collection( "things" );
+
+        thing1 = collection.post( thing1 );
+
+        Entity thing2 = new Entity();
+        thing2.put( "name", "thing2" );
+        thing2 = collection.post( thing2 );
+
+        Entity thing3 = new Entity();
+        thing3.put( "name", "thing3" );
+        thing3 = collection.post( thing3 );
+
+        //now connect them
+
+        //connect thing1 -> thing2
+
+        final CollectionEndpoint connectionEndpoint = collection.entity( thing1 ).connection( "connectorder" );
+        connectionEndpoint.entity( thing2 ).post();
 
+        //connect thing1 -> thing3
+        connectionEndpoint.entity( thing3 ).post();
+
+        refreshIndex();
+
+        //now do a GET, we should see thing2 then thing3
+
+        final ApiResponse order1 = connectionEndpoint.get().getResponse();
+
+        //now verify order
+        verifyOrder( order1, thing3, thing2 );
+
+        final QueryParameters queryParameters = new QueryParameters();
+        queryParameters.setQuery( "select * order by modified desc" );
+
+        final ApiResponse order1Query = connectionEndpoint.get( queryParameters ).getResponse();
+
+        //now verify order
+        verifyOrder( order1Query, thing3, thing2 );
+
+
+        //now re-post thing 2 it should appear second
+        connectionEndpoint.entity( thing2 ).post();
+
+        refreshIndex();
+
+
+        final ApiResponse order2 = connectionEndpoint.get().getResponse();
+
+        //now verify order
+        verifyOrder( order2, thing2, thing3 );
+
+        final ApiResponse order2Query = connectionEndpoint.get( queryParameters ).getResponse();
+
+        //now verify order
+        verifyOrder( order2Query, thing3, thing2 );
     }
 
 
+    /**
+     * UERGRID-1018
+     */
+    @Test
+    public void testRePutOrder() {
+
+        Entity thing1 = new Entity();
+        thing1.put( "name", "thing1" );
+
+        final CollectionEndpoint collection = this.app().collection( "things" );
+
+        thing1 = collection.post( thing1 );
+
+        Entity thing2 = new Entity();
+        thing2.put( "name", "thing2" );
+        thing2 = collection.post( thing2 );
+
+
+        Entity thing3 = new Entity();
+        thing3.put( "name", "thing3" );
+        thing3 = collection.post( thing3 );
+
+        //now connect them
+
+        //connect thing1 -> thing2
+
+        final CollectionEndpoint connectionEndpoint = collection.entity( thing1 ).connection( "connectorder" );
+        connectionEndpoint.entity( thing2 ).put( thing2 );
+
+        //connect thing1 -> thing3
+        connectionEndpoint.entity( thing3 ).put( thing3 );
+
+        refreshIndex();
+
+        //now do a GET, we should see thing2 then thing3
+
+        final ApiResponse order1 = connectionEndpoint.get().getResponse();
+
+        //now verify order
+        verifyOrder( order1, thing3, thing2 );
+
+        final QueryParameters queryParameters = new QueryParameters();
+        queryParameters.setQuery( "select * order by modified desc" );
+
+        final ApiResponse order1Query = connectionEndpoint.get( queryParameters ).getResponse();
+
+        //now verify order
+        verifyOrder( order1Query, thing3, thing2 );
+
+
+        //now re-post thing 2 it should appear second
+        connectionEndpoint.entity( thing2 ).put( thing2 );
+
+        refreshIndex();
+
+        final ApiResponse order2 = connectionEndpoint.get().getResponse();
+
+
+        //now verify order
+        verifyOrder( order2, thing2, thing3 );
+    }
+
+
+    /**
+     * Verify our response
+     */
+    private void verifyOrder( final ApiResponse apiResponse, final Entity... verifyOrder ) {
+
+        final List<Entity> responseEntities = apiResponse.getEntities();
+
+        assertEquals( "Size should be equals", verifyOrder.length, responseEntities.size() );
+
+
+        for ( int i = 0; i < verifyOrder.length; i++ ) {
+
+            final Entity verifyEntity = verifyOrder[i];
+
+            final Entity returned = responseEntities.get( i );
+
+            assertEquals( "Should be the same entity", verifyEntity.getUuid(), returned.getUuid() );
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/82814303/stack/services/src/main/java/org/apache/usergrid/services/AbstractConnectionsService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/AbstractConnectionsService.java b/stack/services/src/main/java/org/apache/usergrid/services/AbstractConnectionsService.java
index c4142a0..ee322d2 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/AbstractConnectionsService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/AbstractConnectionsService.java
@@ -23,20 +23,25 @@ import java.util.UUID;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 import org.apache.usergrid.persistence.ConnectionRef;
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.index.query.Identifier;
 import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.Query.Level;
 import org.apache.usergrid.persistence.Results;
 import org.apache.usergrid.persistence.Schema;
 import org.apache.usergrid.persistence.SimpleEntityRef;
-import org.apache.usergrid.persistence.Query.Level;
+import org.apache.usergrid.persistence.index.query.Identifier;
 import org.apache.usergrid.services.ServiceParameter.IdParameter;
 import org.apache.usergrid.services.ServiceParameter.NameParameter;
 import org.apache.usergrid.services.ServiceParameter.QueryParameter;
 import org.apache.usergrid.services.ServiceResults.Type;
 import org.apache.usergrid.services.exceptions.ServiceResourceNotFoundException;
+
+import rx.Observable;
+import rx.schedulers.Schedulers;
+
 import static org.apache.usergrid.services.ServiceParameter.filter;
 import static org.apache.usergrid.services.ServiceParameter.firstParameterIsName;
 import static org.apache.usergrid.utils.ClassUtils.cast;
@@ -398,6 +403,11 @@ public class AbstractConnectionsService extends AbstractService {
             String entityType = getEntityType();
             item = em.create( id, entityType, context.getPayload().getProperties() );
         }
+
+        //create the connection
+        createConnection( context.getOwner(), context.getCollectionName(), item );
+
+
         return new ServiceResults( this, context, Type.CONNECTION, Results.fromEntity( item ), null, null );
     }
 
@@ -426,6 +436,35 @@ public class AbstractConnectionsService extends AbstractService {
 
         updateEntities( context, r );
 
+          //create the connection
+
+        //TODO wire the RX scheduler in here and use our parallelism system
+
+
+        /**
+         * Create all the connections for all the entities
+         */
+        final List<Entity> entities = r.getEntities();
+        if ( entities != null ) {
+
+            /**
+             * Save up to 10 connections in parallel
+             */
+            Observable.from(entities).flatMap( emittedEntity -> {
+                return Observable.just( emittedEntity ).doOnNext( toSave -> {
+                    try {
+                        createConnection( context.getOwner(), context.getCollectionName(), toSave );
+                    }
+                    catch ( Exception e ) {
+                        throw new RuntimeException( "Unable to save connection", e );
+                    }
+                }).subscribeOn( Schedulers.io() );
+            }, 10).subscribe();
+
+
+        }
+
+
         return new ServiceResults( this, context, Type.CONNECTION, r, null, null );
     }
 


[30/44] usergrid git commit: Fixes test

Posted by md...@apache.org.
Fixes test


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

Branch: refs/heads/USERGRID-933
Commit: acbf3a17216180f67f0f6c9f390e740efd55b223
Parents: d971ec5
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Sep 17 11:46:45 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Sep 17 11:46:45 2015 -0600

----------------------------------------------------------------------
 ...ctMvccEntityDataMigrationV1ToV3ImplTest.java | 34 ++++++++++++++------
 1 file changed, 25 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/acbf3a17/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
index f51b339..9be979b 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
@@ -30,7 +30,10 @@ import org.apache.usergrid.persistence.collection.MvccEntity;
 import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
 import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
 import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy;
+import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
 import org.apache.usergrid.persistence.collection.serialization.impl.CollectionDataVersions;
+import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntitySerializationStrategyV3Impl;
 import org.apache.usergrid.persistence.core.guice.DataMigrationResetRule;
 import org.apache.usergrid.persistence.core.guice.MigrationManagerRule;
 import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
@@ -48,6 +51,7 @@ import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 
 import com.google.inject.Inject;
+import com.netflix.astyanax.Keyspace;
 import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
 
 import net.jcip.annotations.NotThreadSafe;
@@ -63,7 +67,8 @@ import static org.junit.Assert.assertTrue;
 @NotThreadSafe
 @RunWith( ITRunner.class )
 @UseModules( { TestCollectionModule.class } )
-public abstract class AbstractMvccEntityDataMigrationV1ToV3ImplTest implements DataMigrationResetRule.DataMigrationManagerProvider {
+public abstract class AbstractMvccEntityDataMigrationV1ToV3ImplTest
+    implements DataMigrationResetRule.DataMigrationManagerProvider {
 
 
     @Inject
@@ -76,11 +81,19 @@ public abstract class AbstractMvccEntityDataMigrationV1ToV3ImplTest implements D
 
 
     @Inject
-    public MvccEntityDataMigrationImpl mvccEntityDataMigrationImpl;
+    public VersionedMigrationSet<MvccEntitySerializationStrategy> versions;
 
 
     @Inject
-    public VersionedMigrationSet<MvccEntitySerializationStrategy> versions;
+    public Keyspace keyspace;
+    @Inject
+    public VersionedMigrationSet<MvccEntitySerializationStrategy> allVersions;
+    @Inject
+    public MvccEntitySerializationStrategyV3Impl mvccEntitySerializationStrategyV3;
+    @Inject
+    public UniqueValueSerializationStrategy uniqueValueSerializationStrategy;
+    @Inject
+    public MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy;
 
     /**
      * Rule to do the resets we need
@@ -121,20 +134,26 @@ public abstract class AbstractMvccEntityDataMigrationV1ToV3ImplTest implements D
             Observable.just( new EntityIdScope( scope, entity1.getId() ), new EntityIdScope( scope, entity2.getId() ) );
 
 
+        final MigrationDataProvider<EntityIdScope> migrationProvider = () -> entityIdScope;
+
         final TestProgressObserver progressObserver = new TestProgressObserver();
 
         final CollectionDataVersions startVersion = getSourceVersion();
 
         final MigrationRelationship<MvccEntitySerializationStrategy> tuple =
-                  versions.getMigrationRelationship( startVersion.getVersion() );
+            versions.getMigrationRelationship( startVersion.getVersion() );
 
 
         assertEquals( "Same instance for from", v1Impl.getClass(), tuple.from.getClass() );
         assertEquals( "Same instance for to", v3Impl.getClass(), tuple.to.getClass() );
 
+
+        MvccEntityDataMigrationImpl mvccEntityDataMigrationImpl = new MvccEntityDataMigrationImpl(keyspace, allVersions, mvccEntitySerializationStrategyV3, uniqueValueSerializationStrategy,  mvccLogEntrySerializationStrategy, migrationProvider);
+
+
         //now migration
-        final int newVersion = mvccEntityDataMigrationImpl
-            .migrate( startVersion.getVersion(), progressObserver );
+        final int newVersion =
+            mvccEntityDataMigrationImpl.migrate( startVersion.getVersion(), progressObserver );
 
 
         final CollectionDataVersions expectedVersion = expectedTargetVersion();
@@ -183,19 +202,16 @@ public abstract class AbstractMvccEntityDataMigrationV1ToV3ImplTest implements D
 
     /**
      * Get the expected source mvcc implementation for this test
-     * @return
      */
     protected abstract MvccEntitySerializationStrategy getExpectedSourceImpl();
 
     /**
      * Get the expected target mvcc for this test
-     * @return
      */
     protected abstract MvccEntitySerializationStrategy getExpectedTargetImpl();
 
     /**
      * Get the expected start version
-     * @return
      */
     protected abstract CollectionDataVersions getSourceVersion();
 


[23/44] usergrid git commit: change parsing logic to parse uuid as string

Posted by md...@apache.org.
change parsing logic to parse uuid as string


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

Branch: refs/heads/USERGRID-933
Commit: e2fe93981ea11d78906eafbecd26f912e3dd6703
Parents: 723ee3a
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Sep 15 18:18:21 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Sep 15 18:18:21 2015 -0600

----------------------------------------------------------------------
 .../index/impl/EntityMappingParser.java         |  2 +-
 .../persistence/index/impl/EsQueryVistor.java   | 52 ++++++++++----------
 .../persistence/index/impl/EntityIndexTest.java | 12 ++++-
 3 files changed, 38 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/e2fe9398/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
index bfefaa9..e328d29 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
@@ -72,7 +72,7 @@ public class EntityMappingParser implements FieldParser {
      * Visit al the primitive values
      */
     private void visit( final UUID value ) {
-        fields.add( EntityField.create( fieldStack.peek(), value ) );
+       visit(value.toString());
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/e2fe9398/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
index 7b66c0d..af60ed6 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
@@ -107,7 +107,7 @@ public class EsQueryVistor implements QueryVisitor {
          * We use a left and a right, add our boolean query
          */
         if ( useLeftQuery && useRightQuery ) {
-            final BoolQueryBuilder qb = QueryBuilders.boolQuery().must( leftQuery ).must( rightQuery );
+            final BoolQueryBuilder qb = QueryBuilders.boolQuery().must(leftQuery).must(rightQuery);
             queryBuilders.push( qb );
         }
         //only use the left
@@ -131,7 +131,7 @@ public class EsQueryVistor implements QueryVisitor {
 
         //use left and right
         if ( useLeftFilter && useRightFilter ) {
-            final BoolFilterBuilder fb = FilterBuilders.boolFilter().must( leftFilter ).must( rightFilter );
+            final BoolFilterBuilder fb = FilterBuilders.boolFilter().must(leftFilter).must(rightFilter);
             filterBuilders.push( fb );
         }
 
@@ -166,13 +166,13 @@ public class EsQueryVistor implements QueryVisitor {
 
 
         final boolean useLeftQuery = use( leftQuery );
-        final boolean useRightQuery = use( rightQuery );
+        final boolean useRightQuery = use(rightQuery);
 
         //push our boolean filters
         if ( useLeftQuery && useRightQuery ) {
             //when we issue an OR query in usergrid, 1 or more of the terms should match.  When doing bool query in ES, there is no requirement for more than 1 to match, where as in a filter more than 1 must match
-            final BoolQueryBuilder qb = QueryBuilders.boolQuery().should( leftQuery ).should( rightQuery ).minimumNumberShouldMatch(
-                1 );
+            final BoolQueryBuilder qb = QueryBuilders.boolQuery().should( leftQuery ).should(rightQuery).minimumNumberShouldMatch(
+                1);
             queryBuilders.push( qb );
         }
         else if ( useLeftQuery ) {
@@ -189,7 +189,7 @@ public class EsQueryVistor implements QueryVisitor {
 
 
         final boolean useLeftFilter = use( leftFilter );
-        final boolean useRightFilter = use( rightFilter );
+        final boolean useRightFilter = use(rightFilter);
 
         //use left and right
         if ( useLeftFilter && useRightFilter ) {
@@ -225,7 +225,7 @@ public class EsQueryVistor implements QueryVisitor {
         final QueryBuilder notQueryBuilder = queryBuilders.pop();
 
         if ( use( notQueryBuilder ) ) {
-            final QueryBuilder notQuery = QueryBuilders.boolQuery().mustNot( notQueryBuilder );
+            final QueryBuilder notQuery = QueryBuilders.boolQuery().mustNot(notQueryBuilder);
             queryBuilders.push( notQuery  );
         }
         else {
@@ -307,14 +307,14 @@ public class EsQueryVistor implements QueryVisitor {
 
         final GeoDistanceSortBuilder geoSort =
                 SortBuilders.geoDistanceSort( IndexingUtils.FIELD_LOCATION_NESTED ).unit( DistanceUnit.METERS )
-                            .geoDistance( GeoDistance.SLOPPY_ARC ).point( lat, lon );
+                            .geoDistance(GeoDistance.SLOPPY_ARC).point(lat, lon);
 
-        final TermFilterBuilder sortPropertyName = sortPropertyTermFilter( name );
+        final TermFilterBuilder sortPropertyName = sortPropertyTermFilter(name);
 
         geoSort.setNestedFilter( sortPropertyName );
 
 
-        geoSortFields.addField( name, geoSort );
+        geoSortFields.addField(name, geoSort);
         //no op for query, push
 
 
@@ -329,7 +329,7 @@ public class EsQueryVistor implements QueryVisitor {
 
 
         final RangeFilterBuilder termQuery =
-                FilterBuilders.rangeFilter( getFieldNameForType( value ) ).lt( sanitize( value ) );
+                FilterBuilders.rangeFilter( getFieldNameForType( value ) ).lt(sanitize(value));
 
 
         queryBuilders.push( NoOpQueryBuilder.INSTANCE );
@@ -347,7 +347,7 @@ public class EsQueryVistor implements QueryVisitor {
 
 
         final RangeFilterBuilder termQuery =
-                FilterBuilders.rangeFilter( getFieldNameForType( value ) ).lte( sanitize( value ) );
+                FilterBuilders.rangeFilter( getFieldNameForType( value ) ).lte(sanitize(value));
 
 
         queryBuilders.push( NoOpQueryBuilder.INSTANCE );
@@ -362,8 +362,8 @@ public class EsQueryVistor implements QueryVisitor {
         final Object value = op.getLiteral().getValue();
 
         //special case so we support our '*' char with wildcard
-        if ( value instanceof String ) {
-            final String stringValue = (( String ) value).toLowerCase().trim();
+        if ( value instanceof String || value instanceof UUID ) {
+            final String stringValue = (value.toString()).toLowerCase().trim();
 
             // or field is just a string that does need a prefix us a query
             if ( stringValue.contains( "*" ) ) {
@@ -390,7 +390,7 @@ public class EsQueryVistor implements QueryVisitor {
         // assume all other types need prefix
 
         final TermFilterBuilder termQuery =
-                FilterBuilders.termFilter( getFieldNameForType( value ), sanitize( value ) );
+                FilterBuilders.termFilter(getFieldNameForType(value), sanitize(value));
 
         filterBuilders.push( fieldNameTerm( name, termQuery ) );
 
@@ -405,7 +405,7 @@ public class EsQueryVistor implements QueryVisitor {
 
 
         final RangeFilterBuilder rangeQuery =
-                FilterBuilders.rangeFilter( getFieldNameForType( value ) ).gt( sanitize( value ) );
+                FilterBuilders.rangeFilter( getFieldNameForType( value ) ).gt(sanitize(value));
 
         filterBuilders.push( fieldNameTerm( name, rangeQuery ) );
 
@@ -420,9 +420,9 @@ public class EsQueryVistor implements QueryVisitor {
 
 
         final RangeFilterBuilder rangeQuery =
-                FilterBuilders.rangeFilter( getFieldNameForType( value ) ).gte( sanitize( value ) );
+                FilterBuilders.rangeFilter( getFieldNameForType( value ) ).gte(sanitize(value));
 
-        filterBuilders.push( fieldNameTerm( name, rangeQuery ) );
+        filterBuilders.push(fieldNameTerm(name, rangeQuery));
 
         queryBuilders.push( NoOpQueryBuilder.INSTANCE );
     }
@@ -474,12 +474,12 @@ public class EsQueryVistor implements QueryVisitor {
 
         final BoolQueryBuilder booleanQuery = QueryBuilders.boolQuery();
 
-        booleanQuery.must( QueryBuilders.termQuery( IndexingUtils.FIELD_NAME_NESTED, fieldName ) );
+        booleanQuery.must( QueryBuilders.termQuery(IndexingUtils.FIELD_NAME_NESTED, fieldName) );
 
         booleanQuery.must( fieldValueQuery );
 
 
-        return QueryBuilders.nestedQuery( IndexingUtils.ENTITY_FIELDS, booleanQuery );
+        return QueryBuilders.nestedQuery(IndexingUtils.ENTITY_FIELDS, booleanQuery);
     }
 
 
@@ -503,7 +503,11 @@ public class EsQueryVistor implements QueryVisitor {
      * Get the field name for the primitive type
      */
     private String getFieldNameForType( final Object object ) {
-        if ( object instanceof String ) {
+        if ( object instanceof String) {
+            return IndexingUtils.FIELD_STRING_NESTED;
+        }
+
+        if(object instanceof UUID){
             return IndexingUtils.FIELD_STRING_NESTED;
         }
 
@@ -521,10 +525,6 @@ public class EsQueryVistor implements QueryVisitor {
         }
 
 
-        if ( object instanceof UUID ) {
-            return IndexingUtils.FIELD_UUID_NESTED;
-        }
-
 
         throw new UnsupportedOperationException(
                 "Unkown search type of " + object.getClass().getName() + " encountered" );
@@ -540,7 +540,7 @@ public class EsQueryVistor implements QueryVisitor {
         }
 
         if ( input instanceof UUID ) {
-            return input.toString();
+            return  input.toString() ;
         }
 
         return input;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/e2fe9398/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index 34256ca..7aa97b1 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -127,11 +127,13 @@ public class EntityIndexTest extends BaseIT {
         EntityIndexBatch batch = entityIndex.createBatch();
 
 
+        UUID uuid = UUID.randomUUID();
         Entity entity1 = new Entity( entityType );
         EntityUtils.setVersion(entity1, UUIDGenerator.newTimeUUID());
-        entity1.setField( new UUIDField( IndexingUtils.ENTITY_ID_FIELDNAME, UUID.randomUUID() ) );
+        entity1.setField(new UUIDField(IndexingUtils.ENTITY_ID_FIELDNAME, UUID.randomUUID()));
         entity1.setField( new StringField( "testfield", "test" ) );
         entity1.setField(new IntegerField("ordinal", 0));
+        entity1.setField(new UUIDField("testuuid",uuid));
 
 
         batch.index( indexEdge, entity1 );
@@ -176,6 +178,14 @@ public class EntityIndexTest extends BaseIT {
         //check the id and version
         assertEquals( entity2.getId(), candidate2.getId() );
         assertEquals( entity2.getVersion(), candidate2.getVersion() );
+
+        candidateResults =
+            entityIndex.search( indexEdge, searchTypes, "select * where testuuid = '"+uuid+"'", 100, 0 );
+        assertEquals(entity1.getId(),candidateResults.get(0).getId());
+
+        candidateResults =
+            entityIndex.search( indexEdge, searchTypes, "select * where testuuid = "+uuid, 100, 0 );
+        assertEquals(entity1.getId(),candidateResults.get(0).getId());
     }
 
 


[26/44] usergrid git commit: Fixing weird formatting in license headers, no code changes. This closes #385.

Posted by md...@apache.org.
http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsIndexMappingMigrationPluginTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsIndexMappingMigrationPluginTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsIndexMappingMigrationPluginTest.java
index d4ce9e6..90d030b 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsIndexMappingMigrationPluginTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsIndexMappingMigrationPluginTest.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  The ASF licenses this file to You
- *  * under the Apache License, Version 2.0 (the "License"); you may not
- *  * use this file except in compliance with the License.
- *  * You may obtain a copy of the License at
- *  *
- *  *     http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing, software
- *  * distributed under the License is distributed on an "AS IS" BASIS,
- *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  * See the License for the specific language governing permissions and
- *  * limitations under the License.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsRunner.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsRunner.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsRunner.java
index c972851..2bfa8f6 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsRunner.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsRunner.java
@@ -1,21 +1,21 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
index fbe2bf5..dce69f9 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  *    http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *  *
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
  *
  */
 package org.apache.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/TestIndexIdentifier.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/TestIndexIdentifier.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/TestIndexIdentifier.java
index 29f9bad..2cc7e62 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/TestIndexIdentifier.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/TestIndexIdentifier.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  The ASF licenses this file to You
- *  * under the Apache License, Version 2.0 (the "License"); you may not
- *  * use this file except in compliance with the License.
- *  * You may obtain a copy of the License at
- *  *
- *  *     http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing, software
- *  * distributed under the License is distributed on an "AS IS" BASIS,
- *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  * See the License for the specific language governing permissions and
- *  * limitations under the License.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index.impl;


[31/44] usergrid git commit: Fixes issue with incorrectly not rolling version when no app-infos are present.

Posted by md...@apache.org.
Fixes issue with incorrectly not rolling version when no app-infos are present.


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

Branch: refs/heads/USERGRID-933
Commit: 9294af73ff1af563fd06d9b5dc6a04e37dc76788
Parents: 65d2608
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Sep 17 11:53:09 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Sep 17 11:53:09 2015 -0600

----------------------------------------------------------------------
 .../management/AppInfoMigrationPlugin.java      | 234 +++++++++----------
 1 file changed, 116 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/9294af73/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java b/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
index ff73402..54779b9 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
@@ -20,11 +20,21 @@
 package org.apache.usergrid.management;
 
 
-import com.google.common.base.Optional;
-import com.google.inject.Inject;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.BeanFactory;
+
 import org.apache.usergrid.corepersistence.util.CpEntityMapUtils;
 import org.apache.usergrid.corepersistence.util.CpNamingUtils;
-import org.apache.usergrid.persistence.*;
+import org.apache.usergrid.persistence.EntityFactory;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.EntityManagerFactory;
+import org.apache.usergrid.persistence.EntityRef;
+import org.apache.usergrid.persistence.Schema;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
 import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
@@ -42,21 +52,17 @@ import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.utils.UUIDUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.BeanFactory;
-import rx.Observable;
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicInteger;
+import com.google.common.base.Optional;
+import com.google.inject.Inject;
+
+import rx.Observable;
 
 import static org.apache.usergrid.corepersistence.util.CpNamingUtils.getApplicationScope;
 import static org.apache.usergrid.persistence.Schema.PROPERTY_NAME;
 
+
 /**
  * Migration of appinfos collection to application_info collection.
  *
@@ -68,7 +74,7 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
     /** Old and deprecated SYSTEM_APP */
     public static final UUID SYSTEM_APP_ID = UUID.fromString( "b6768a08-b5d5-11e3-a495-10ddb1de66c3" );
 
-    private static final Logger logger = LoggerFactory.getLogger(AppInfoMigrationPlugin.class);
+    private static final Logger logger = LoggerFactory.getLogger( AppInfoMigrationPlugin.class );
 
     public static String PLUGIN_NAME = "appinfo-migration";
 
@@ -85,27 +91,23 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
     final private GraphManagerFactory graphManagerFactory;
     private final ManagementService managementService;
 
+
     @Inject
-    public AppInfoMigrationPlugin(
-        EntityManagerFactory emf,
-        MigrationInfoSerialization migrationInfoSerialization,
-        EntityCollectionManagerFactory entityCollectionManagerFactory,
-        GraphManagerFactory graphManagerFactory,
-        BeanFactory beanFactory) {
+    public AppInfoMigrationPlugin( EntityManagerFactory emf, MigrationInfoSerialization migrationInfoSerialization,
+                                   EntityCollectionManagerFactory entityCollectionManagerFactory,
+                                   GraphManagerFactory graphManagerFactory, BeanFactory beanFactory ) {
 
         this.emf = emf;
         this.migrationInfoSerialization = migrationInfoSerialization;
         this.entityCollectionManagerFactory = entityCollectionManagerFactory;
         this.graphManagerFactory = graphManagerFactory;
-        this.managementService = beanFactory.getBean(ManagementService.class);
+        this.managementService = beanFactory.getBean( ManagementService.class );
     }
 
-    public AppInfoMigrationPlugin(
-        EntityManagerFactory emf,
-        MigrationInfoSerialization migrationInfoSerialization,
-        EntityCollectionManagerFactory entityCollectionManagerFactory,
-        GraphManagerFactory graphManagerFactory,
-        ManagementService managementService) {
+
+    public AppInfoMigrationPlugin( EntityManagerFactory emf, MigrationInfoSerialization migrationInfoSerialization,
+                                   EntityCollectionManagerFactory entityCollectionManagerFactory,
+                                   GraphManagerFactory graphManagerFactory, ManagementService managementService ) {
 
         this.emf = emf;
         this.migrationInfoSerialization = migrationInfoSerialization;
@@ -134,12 +136,12 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
 
 
     @Override
-    public void run(ProgressObserver observer) {
+    public void run( ProgressObserver observer ) {
 
-        final int version = migrationInfoSerialization.getVersion(getName());
+        final int version = migrationInfoSerialization.getVersion( getName() );
 
-        if (version == getMaxVersion()) {
-            logger.debug("Skipping Migration Plugin: " + getName());
+        if ( version == getMaxVersion() ) {
+            logger.debug( "Skipping Migration Plugin: " + getName() );
             return;
         }
 
@@ -147,80 +149,78 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
         AtomicInteger count = new AtomicInteger();
         //get old app infos to migrate
         final Observable<Entity> oldAppInfos = getOldAppInfos();
-        oldAppInfos
-            .doOnNext(oldAppInfoEntity -> {
-                try {
-                    migrateAppInfo(oldAppInfoEntity, observer);
+        oldAppInfos.doOnNext( oldAppInfoEntity -> {
+            try {
+                migrateAppInfo( oldAppInfoEntity, observer );
+                count.incrementAndGet();
+            }
+            catch ( Exception e ) {
+                if ( e.getCause() instanceof ApplicationAlreadyExistsException ) {
                     count.incrementAndGet();
-                }catch (Exception e){
-                    if(e.getCause() instanceof ApplicationAlreadyExistsException){
-                        count.incrementAndGet();
-                        logger.info("Application already migrated",oldAppInfoEntity.getId().getUuid());
-                    }else {
-                        logger.error("Failed to migrate app info" + oldAppInfoEntity.getId().getUuid(), e);
-                        throw new RuntimeException(e);
-                    }
+                    logger.info( "Application already migrated", oldAppInfoEntity.getId().getUuid() );
                 }
-
-            })
-            .doOnCompleted(() -> {
-                if(count.get()>0) {
-                    migrationInfoSerialization.setVersion(getName(), getMaxVersion());
-                }else{
-                    logger.error("Failed to migrate any app infos");
+                else {
+                    logger.error( "Failed to migrate app info" + oldAppInfoEntity.getId().getUuid(), e );
+                    throw new RuntimeException( e );
                 }
-                observer.complete();
-            }).toBlocking().lastOrDefault(null);
-
+            }
+        } ).doOnCompleted( () -> {
+            migrationInfoSerialization.setVersion( getName(), getMaxVersion() );
+            observer.complete();
+        } ).toBlocking().lastOrDefault( null );
     }
 
 
-    private void migrateAppInfo( org.apache.usergrid.persistence.model.entity.Entity oldAppInfoEntity, ProgressObserver observer) {
+    private void migrateAppInfo( org.apache.usergrid.persistence.model.entity.Entity oldAppInfoEntity,
+                                 ProgressObserver observer ) {
         // Get appinfos from the Graph, we don't expect many so use iterator
         final EntityManager managementEm = emf.getManagementEntityManager();
 
-        Map oldAppInfoMap = CpEntityMapUtils.toMap(oldAppInfoEntity);
+        Map oldAppInfoMap = CpEntityMapUtils.toMap( oldAppInfoEntity );
 
-        final String name = (String) oldAppInfoMap.get(PROPERTY_NAME);
+        final String name = ( String ) oldAppInfoMap.get( PROPERTY_NAME );
 
         try {
-            final String orgName = name.split("/")[0];
-            final String appName = name.split("/")[1];
-            UUID applicationId = getUuid(oldAppInfoMap,"applicationUuid") ;
-            applicationId = applicationId == null ?  getUuid(oldAppInfoMap,"appUuid") : applicationId ;
+            final String orgName = name.split( "/" )[0];
+            final String appName = name.split( "/" )[1];
+            UUID applicationId = getUuid( oldAppInfoMap, "applicationUuid" );
+            applicationId = applicationId == null ? getUuid( oldAppInfoMap, "appUuid" ) : applicationId;
             //get app info from graph to see if it has been migrated already
-            org.apache.usergrid.persistence.Entity appInfo = getApplicationInfo(applicationId);
-            if (appInfo == null) {
+            org.apache.usergrid.persistence.Entity appInfo = getApplicationInfo( applicationId );
+            if ( appInfo == null ) {
 
-                observer.update(getMaxVersion(), "Created application_info for " + appName);
+                observer.update( getMaxVersion(), "Created application_info for " + appName );
                 // create org->app connections, but not for apps in dummy "usergrid" internal organization
-                if(!orgName.equals("usergrid")) { //avoid management org
+                if ( !orgName.equals( "usergrid" ) ) { //avoid management org
 
-                    EntityRef orgRef = managementEm.getAlias(Group.ENTITY_TYPE, orgName);
+                    EntityRef orgRef = managementEm.getAlias( Group.ENTITY_TYPE, orgName );
                     // create and connect new APPLICATION_INFO oldAppInfo to Organization
-                    managementService.createApplication(orgRef.getUuid(), name, applicationId, null);
+                    managementService.createApplication( orgRef.getUuid(), name, applicationId, null );
                 }
-            } else {
+            }
+            else {
                 //already migrated don't do anything
-                observer.update(getMaxVersion(), "Received existing application_info for " + appName + " don't do anything");
+                observer.update( getMaxVersion(),
+                    "Received existing application_info for " + appName + " don't do anything" );
             }
-
-        } catch (Exception e) {
+        }
+        catch ( Exception e ) {
             String msg = "Exception writing application_info for " + name;
-            logger.error(msg, e);
-            observer.failed(getMaxVersion(), msg);
-            throw new RuntimeException(e);
+            logger.error( msg, e );
+            observer.failed( getMaxVersion(), msg );
+            throw new RuntimeException( e );
         }
-
     }
 
-    private UUID getUuid(Map oldAppInfoMap, String key) {
+
+    private UUID getUuid( Map oldAppInfoMap, String key ) {
         UUID applicationId;
-        Object uuidObject = oldAppInfoMap.get(key);
-        if (uuidObject instanceof UUID) {
-            applicationId = (UUID) uuidObject;
-        } else {
-            applicationId = uuidObject == null ? null : UUIDUtils.tryExtractUUID(uuidObject.toString());
+        Object uuidObject = oldAppInfoMap.get( key );
+        if ( uuidObject instanceof UUID ) {
+            applicationId = ( UUID ) uuidObject;
+        }
+        else {
+            applicationId = uuidObject == null ? null : UUIDUtils.tryExtractUUID( uuidObject.toString() );
         }
         return applicationId;
     }
@@ -231,84 +231,82 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
      */
     private org.apache.usergrid.persistence.Entity getApplicationInfo( final UUID appId ) throws Exception {
 
-        final ApplicationScope managementAppScope = getApplicationScope(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
-        final EntityCollectionManager managementCollectionManager = entityCollectionManagerFactory.createCollectionManager(managementAppScope);
+        final ApplicationScope managementAppScope = getApplicationScope( CpNamingUtils.MANAGEMENT_APPLICATION_ID );
+        final EntityCollectionManager managementCollectionManager =
+            entityCollectionManagerFactory.createCollectionManager( managementAppScope );
 
-        Observable<Edge> edgesObservable = getApplicationInfoEdges(appId);
+        Observable<Edge> edgesObservable = getApplicationInfoEdges( appId );
         //get the graph for all app infos
-        Observable<org.apache.usergrid.persistence.model.entity.Entity> entityObs =
-            edgesObservable.flatMap(edge -> {
-                final Id appInfoId = edge.getTargetNode();
-                return managementCollectionManager
-                    .load(appInfoId)
-                    .filter( entity ->{
-                        //check for app id
-                        return  entity != null ? entity.getId().getUuid().equals(appId) : false;
-                    });
-            });
+        Observable<org.apache.usergrid.persistence.model.entity.Entity> entityObs = edgesObservable.flatMap( edge -> {
+            final Id appInfoId = edge.getTargetNode();
+            return managementCollectionManager.load( appInfoId ).filter( entity -> {
+                //check for app id
+                return entity != null ? entity.getId().getUuid().equals( appId ) : false;
+            } );
+        } );
 
         // don't expect many applications, so we block
         org.apache.usergrid.persistence.model.entity.Entity applicationInfo =
-            entityObs.toBlocking().lastOrDefault(null);
+            entityObs.toBlocking().lastOrDefault( null );
 
         if ( applicationInfo == null ) {
             return null;
         }
 
-        Class clazz = Schema.getDefaultSchema().getEntityClass(applicationInfo.getId().getType());
+        Class clazz = Schema.getDefaultSchema().getEntityClass( applicationInfo.getId().getType() );
 
-        org.apache.usergrid.persistence.Entity entity = EntityFactory.newEntity(
-            applicationInfo.getId().getUuid(), applicationInfo.getId().getType(), clazz);
+        org.apache.usergrid.persistence.Entity entity =
+            EntityFactory.newEntity( applicationInfo.getId().getUuid(), applicationInfo.getId().getType(), clazz );
 
         entity.setProperties( CpEntityMapUtils.toMap( applicationInfo ) );
 
         return entity;
-
     }
 
 
     /**
      * Use Graph to get old appinfos from the old and deprecated System App.
      */
-    public Observable<org.apache.usergrid.persistence.model.entity.Entity> getOldAppInfos( ) {
+    public Observable<org.apache.usergrid.persistence.model.entity.Entity> getOldAppInfos() {
 
-        final ApplicationScope systemAppScope = getApplicationScope(SYSTEM_APP_ID);
+        final ApplicationScope systemAppScope = getApplicationScope( SYSTEM_APP_ID );
 
         final EntityCollectionManager systemCollectionManager =
-            entityCollectionManagerFactory.createCollectionManager(systemAppScope);
+            entityCollectionManagerFactory.createCollectionManager( systemAppScope );
 
-        final GraphManager gm = graphManagerFactory.createEdgeManager(systemAppScope);
+        final GraphManager gm = graphManagerFactory.createEdgeManager( systemAppScope );
 
-        String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName("appinfos");
+        String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( "appinfos" );
 
         Id rootAppId = systemAppScope.getApplication();
 
-        final SimpleSearchByEdgeType simpleSearchByEdgeType =  new SimpleSearchByEdgeType(
-            rootAppId, edgeType, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, Optional.absent());
+        final SimpleSearchByEdgeType simpleSearchByEdgeType =
+            new SimpleSearchByEdgeType( rootAppId, edgeType, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING,
+                Optional.absent() );
 
         Observable<org.apache.usergrid.persistence.model.entity.Entity> entityObs =
-            gm.loadEdgesFromSource( simpleSearchByEdgeType )
-                .flatMap(edge -> {
-                    final Id appInfoId = edge.getTargetNode();
+            gm.loadEdgesFromSource( simpleSearchByEdgeType ).flatMap( edge -> {
+                final Id appInfoId = edge.getTargetNode();
 
-                    return systemCollectionManager.load(appInfoId)
-                        .filter(entity -> (entity != null));
-                });
+                return systemCollectionManager.load( appInfoId ).filter( entity -> ( entity != null ) );
+            } );
 
         return entityObs;
     }
 
-    public Observable<Edge> getApplicationInfoEdges(final UUID applicationId) {
-        final ApplicationScope managementAppScope = getApplicationScope(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
-        final GraphManager gm = graphManagerFactory.createEdgeManager(managementAppScope);
 
-        String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName(CpNamingUtils.APPLICATION_INFOS);
+    public Observable<Edge> getApplicationInfoEdges( final UUID applicationId ) {
+        final ApplicationScope managementAppScope = getApplicationScope( CpNamingUtils.MANAGEMENT_APPLICATION_ID );
+        final GraphManager gm = graphManagerFactory.createEdgeManager( managementAppScope );
+
+        String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( CpNamingUtils.APPLICATION_INFOS );
 
 
-        final SimpleSearchByEdge simpleSearchByEdgeType =  new SimpleSearchByEdge(
-            CpNamingUtils.generateApplicationId(CpNamingUtils.MANAGEMENT_APPLICATION_ID), edgeType, CpNamingUtils.generateApplicationId( applicationId ), Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING,
-            Optional.absent());
+        final SimpleSearchByEdge simpleSearchByEdgeType =
+            new SimpleSearchByEdge( CpNamingUtils.generateApplicationId( CpNamingUtils.MANAGEMENT_APPLICATION_ID ),
+                edgeType, CpNamingUtils.generateApplicationId( applicationId ), Long.MAX_VALUE,
+                SearchByEdgeType.Order.DESCENDING, Optional.absent() );
 
-        return gm.loadEdgeVersions(simpleSearchByEdgeType  );
+        return gm.loadEdgeVersions( simpleSearchByEdgeType );
     }
 }


[44/44] usergrid git commit: In progress, not working

Posted by md...@apache.org.
In progress, not working


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

Branch: refs/heads/USERGRID-933
Commit: a5185f2e72a3be91a8eac35f1b96a2cc1f72e8f8
Parents: 5ead5fd
Author: Mike Dunker <md...@apache.org>
Authored: Fri Sep 25 18:30:04 2015 -0700
Committer: Mike Dunker <md...@apache.org>
Committed: Fri Sep 25 18:30:04 2015 -0700

----------------------------------------------------------------------
 .../usergrid/corepersistence/CoreModule.java    |   6 +-
 .../corepersistence/CpEntityManagerFactory.java |  14 +-
 .../ManagementOrganizationDataMigration.java    | 155 +++++++++++++++++++
 .../corepersistence/util/CpNamingUtils.java     |  32 +++-
 .../persistence/EntityManagerFactory.java       |   2 +
 .../persistence/cassandra/CassandraService.java |   1 +
 .../usergrid/management/OrganizationConfig.java |   5 +
 .../cassandra/ManagementServiceImpl.java        |   6 +-
 .../migration/AppInfoMigrationPluginTest.java   |   2 +-
 9 files changed, 204 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/a5185f2e/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
index 486aa6f..8e4e58f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
@@ -16,6 +16,7 @@
 package org.apache.usergrid.corepersistence;
 
 
+import org.apache.usergrid.corepersistence.migration.*;
 import org.safehaus.guicyfig.GuicyFigModule;
 
 import org.apache.usergrid.corepersistence.asyncevents.AsyncEventService;
@@ -31,10 +32,6 @@ import org.apache.usergrid.corepersistence.index.IndexService;
 import org.apache.usergrid.corepersistence.index.IndexServiceImpl;
 import org.apache.usergrid.corepersistence.index.ReIndexService;
 import org.apache.usergrid.corepersistence.index.ReIndexServiceImpl;
-import org.apache.usergrid.corepersistence.migration.CoreMigration;
-import org.apache.usergrid.corepersistence.migration.CoreMigrationPlugin;
-import org.apache.usergrid.corepersistence.migration.DeDupConnectionDataMigration;
-import org.apache.usergrid.corepersistence.migration.MigrationModuleVersionPlugin;
 import org.apache.usergrid.corepersistence.pipeline.PipelineModule;
 import org.apache.usergrid.corepersistence.rx.impl.AllApplicationsObservable;
 import org.apache.usergrid.corepersistence.rx.impl.AllApplicationsObservableImpl;
@@ -131,6 +128,7 @@ public class CoreModule  extends AbstractModule {
 
 
         dataMigrationMultibinder.addBinding().to( DeDupConnectionDataMigration.class );
+        dataMigrationMultibinder.addBinding().to( ManagementOrganizationDataMigration.class );
 
 
         //wire up the collection migration plugin

http://git-wip-us.apache.org/repos/asf/usergrid/blob/a5185f2e/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index 4bdade5..8985f3d 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -71,6 +71,7 @@ import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 import org.apache.usergrid.utils.UUIDUtils;
+import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 
 import com.google.common.base.Optional;
 import com.google.common.cache.CacheBuilder;
@@ -166,7 +167,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
             if ( em.getApplication() == null ) {
                 logger.info("Creating management application");
                 Map mgmtAppProps = new HashMap<String, Object>();
-                mgmtAppProps.put(PROPERTY_NAME, "systemapp");
+                mgmtAppProps.put(PROPERTY_NAME, CassandraService.MANAGEMENT_APPLICATION);
                 em.create( getManagementAppId(), TYPE_APPLICATION, mgmtAppProps);
                 em.getApplication();
             }
@@ -448,7 +449,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
     @Override
     public Map<String, UUID> getApplications() throws Exception {
-        return getApplications( CpNamingUtils.getEdgeTypeFromCollectionName( CpNamingUtils.APPLICATION_INFOS ) );
+        return getApplications(CpNamingUtils.getEdgeTypeFromCollectionName( CpNamingUtils.APPLICATION_INFOS ) );
     }
 
 
@@ -504,7 +505,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
                             final String applicationName = ( String ) entityData.getField( PROPERTY_NAME ).getValue();
 
                             appMap.put( applicationName , applicationId );
-                        } ).toBlocking().last();
+                    } ).toBlocking().last();
     }
 
 
@@ -578,7 +579,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
         // intentionally going only one-level deep into fields and treating all
         // values as strings because that is all we need for service properties
-        for ( String key : properties.keySet() ) {
+        for ( String key : properties.keySet()) {
             propsEntity.setProperty(key, properties.get(key).toString());
         }
 
@@ -669,6 +670,11 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     }
 
     @Override
+    public UUID getManagementOrgId() {
+        return CpNamingUtils.MANAGEMENT_ORGANIZATION_ID;
+    }
+
+    @Override
     public EntityManager getManagementEntityManager() {
         return getEntityManager(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/a5185f2e/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/ManagementOrganizationDataMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/ManagementOrganizationDataMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/ManagementOrganizationDataMigration.java
new file mode 100644
index 0000000..66f4b71
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/ManagementOrganizationDataMigration.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.corepersistence.migration;
+
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.apache.usergrid.corepersistence.util.CpNamingUtils;
+import org.apache.usergrid.persistence.*;
+import org.apache.usergrid.persistence.cassandra.CassandraService;
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+import org.apache.usergrid.persistence.core.migration.data.ProgressObserver;
+import org.apache.usergrid.persistence.entities.Application;
+import org.apache.usergrid.persistence.entities.Group;
+import static org.apache.usergrid.persistence.Schema.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.UUID;
+
+
+@Singleton
+public class ManagementOrganizationDataMigration implements DataMigration {
+
+    private static final Logger logger = LoggerFactory.getLogger(ManagementOrganizationDataMigration.class);
+
+    private final EntityManagerFactory entityManagerFactory;
+    private final ManagementService managementService;
+
+    @Inject
+    public ManagementOrganizationDataMigration(final EntityManagerFactory entityManagerFactory, final ManagementService managementService) {
+        this.entityManagerFactory = entityManagerFactory;
+        this.managementService = managementService;
+    }
+
+
+    @Override
+    public int migrate( final int currentVersion, final ProgressObserver observer ) {
+
+        final int migrationVersion = getMaxVersion();
+
+        observer.start();
+
+        EntityManager em = entityManagerFactory.getEntityManager(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
+
+        UUID managementAppId = entityManagerFactory.getManagementAppId();
+        UUID managementOrgId = entityManagerFactory.getManagementOrgId();
+        String managementAppName = CassandraService.MANAGEMENT_APPLICATION;
+        String managementOrgName = CassandraService.DEFAULT_ORGANIZATION;
+        String managementOrgPlusAppName = CassandraService.MANAGEMENT_ORGPLUSAPP;
+        Application app = null;
+
+        // make sure management app exists
+        try {
+            app = em.getApplication();
+            if (app == null) {
+                // create the management application
+                entityManagerFactory.createApplicationV2(managementOrgName, managementAppName,
+                        managementAppId, null);
+                app = em.getApplication();
+            } else if (!managementAppName.equals(app.getName())) {
+                logger.info(String.format("Management application name is %s, should be %s", app.getName(), managementOrgPlusAppName));
+                observer.update(migrationVersion, String.format("Management application name is %s, should be %s", app.getName(), managementOrgPlusAppName));
+            }
+        } catch (Exception e) {
+            // should never happen -- abort
+            logger.error("MANAGEMENT APPLICATION ERROR", e);
+            observer.failed(migrationVersion, String.format("MANAGEMENT APPLICATION ERROR: %s", e.getMessage()));
+            return currentVersion;
+        }
+
+        // check for existence of management org, and create if necessary
+        boolean createdOrg = false;
+        try {
+            if (!em.isPropertyValueUniqueForEntity(Group.ENTITY_TYPE, PROPERTY_PATH, managementOrgName)) {
+                // organization already exists
+                logger.info(String.format("Organization with name %s already exists", managementOrgName));
+                observer.update(migrationVersion, String.format("Management organization %s already exists", managementOrgName));
+            } else if (!em.isPropertyValueUniqueForEntity(Group.ENTITY_TYPE, PROPERTY_UUID, managementOrgId)) {
+                // organization does not have correct UUID
+                logger.error("Organization that has management organization UUID does not have correct organization name");
+                observer.failed(migrationVersion, "Organization that has management organization UUID does not have correct organization name");
+                return migrationVersion;
+            } else {
+                // create management org
+                Group organizationEntity = new Group();
+                organizationEntity.setPath(managementOrgName);
+                em.create(managementOrgId, Group.ENTITY_TYPE, organizationEntity.getProperties());
+                logger.info("Management org created");
+                createdOrg = true;
+            }
+        } catch (Exception e) {
+            // error with management org
+            logger.error("MANAGEMENT ORGANIZATION ERROR", e);
+            observer.update(migrationVersion, String.format("MANAGEMENT ORGANIZATION ERROR: %s", e.getMessage()));
+        }
+
+        // add org property to app
+        if (createdOrg && app != null && !managementOrgName.equals(app.getProperty("org"))) {
+            try {
+                app.setProperty("org", managementOrgName);
+                em.update(app);
+                logger.info("Management app updated with management org");
+            } catch (Exception e) {
+                // error linking management app to management org
+                logger.error("ERROR ADDING MANAGEMENT ORG TO MANAGEMENT APP", e);
+                observer.update(migrationVersion, String.format("ERROR ADDING MANAGEMENT ORG TO MANAGEMENT APP: %s", e.getMessage()));
+            }
+        }
+
+        // add connection
+        if (app != null) {
+            if (managementService)
+            Results r = em.getSourceEntities(new SimpleEntityRef(CpNamingUtils.APPLICATION_INFO, managementAppId),
+                    ORG_APP_RELATIONSHIP, Group.ENTITY_TYPE, Query.Level.ALL_PROPERTIES);
+            Entity entity = r.getEntity();
+            if (entity == null) {
+                // add the connection
+            }
+        }
+
+
+        observer.complete();
+
+        return migrationVersion;
+
+    }
+
+
+    @Override
+    public boolean supports( final int currentVersion ) {
+        return currentVersion == getMaxVersion() - 1;
+    }
+
+
+    @Override
+    public int getMaxVersion() {
+        return 3;
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/a5185f2e/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
index 55bc49a..b7e90fe 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
@@ -21,6 +21,7 @@ package org.apache.usergrid.corepersistence.util;
 
 import java.util.UUID;
 
+import org.apache.usergrid.persistence.cassandra.CassandraService;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
 import org.apache.usergrid.persistence.entities.Application;
@@ -65,8 +66,9 @@ public class CpNamingUtils {
      */
     private static final int EDGE_CONN_PREFIX_LENGTH = EDGE_CONN_PREFIX.length()+1;
 
-    /** App where we store management info */
+    /** App/org where we store management info */
     public static final UUID MANAGEMENT_APPLICATION_ID = UUID.fromString( "b6768a08-b5d5-11e3-a495-11ddb1de66c8" );
+    public static final UUID MANAGEMENT_ORGANIZATION_ID = UUID.fromString( "d090d165-7dd8-4132-8aa2-7e0ec5484c7f" );
 
     /**
      * Information about applications is stored in the management app using these types
@@ -103,7 +105,7 @@ public class CpNamingUtils {
      * @return
      */
     public static String getConnectionNameFromEdgeName(final String edgeName){
-        return edgeName.substring( EDGE_CONN_PREFIX_LENGTH );
+        return edgeName.substring(EDGE_CONN_PREFIX_LENGTH);
     }
 
     /**
@@ -121,7 +123,7 @@ public class CpNamingUtils {
        * @return
        */
       public static String getCollectionNameFromEdgeName(final String edgeName){
-          return edgeName.substring( EDGE_COLL_PREFIX_LENGTH );
+          return edgeName.substring(EDGE_COLL_PREFIX_LENGTH);
       }
 
 
@@ -177,7 +179,7 @@ public class CpNamingUtils {
      * TODO move sourceId to ApplicationScope
      */
     public static Edge createCollectionEdge( final Id sourceId, final String collectionName, final Id entityId ) {
-        final String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( collectionName );
+        final String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName(collectionName);
 
 
         // create graph edge connection from head entity to member entity
@@ -270,12 +272,22 @@ public class CpNamingUtils {
 
 
     /**
+     * Generate an entity Id from the given UUID
+     *
+     * @param entityId the entity's UUID
+     */
+    protected static Id generateEntityId( UUID entityId ) {
+        return new SimpleId( entityId, Application.ENTITY_TYPE );
+    }
+
+
+    /**
      * Generate an applicationId from the given UUID
      *
      * @param applicationId the applicationId
      */
     public static Id generateApplicationId( UUID applicationId ) {
-        return new SimpleId( applicationId, Application.ENTITY_TYPE );
+        return generateEntityId( applicationId );
     }
 
 
@@ -283,7 +295,15 @@ public class CpNamingUtils {
      * Generate an application scope for the management application
      */
     public static Id getManagementApplicationId() {
-        return generateApplicationId( MANAGEMENT_APPLICATION_ID );
+        return generateEntityId(MANAGEMENT_APPLICATION_ID);
+    }
+
+
+    /**
+     * Generate an id for the management organization
+     */
+    public static Id getManagementOrganizationId() {
+        return generateEntityId(MANAGEMENT_ORGANIZATION_ID);
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/a5185f2e/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
index bde1bd2..befcc83 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
@@ -166,6 +166,8 @@ public interface EntityManagerFactory {
 
     public UUID getManagementAppId();
 
+    public UUID getManagementOrgId();
+
     public IndexRefreshCommand.IndexRefreshCommandInfo refreshIndex(UUID applicationId);
 
     /**

http://git-wip-us.apache.org/repos/asf/usergrid/blob/a5185f2e/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
index a08c543..85fcd7f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
@@ -79,6 +79,7 @@ public class CassandraService {
     public static final String DEFAULT_APPLICATION = "default-app";
     public static final String DEFAULT_ORGANIZATION = "usergrid";
     public static final String MANAGEMENT_APPLICATION = "management";
+    public static final String MANAGEMENT_ORGPLUSAPP = "usergrid/management";
 
     private static final Logger logger = LoggerFactory.getLogger( CassandraService.class );
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/a5185f2e/stack/services/src/main/java/org/apache/usergrid/management/OrganizationConfig.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/OrganizationConfig.java b/stack/services/src/main/java/org/apache/usergrid/management/OrganizationConfig.java
index bc22dad..276bad8 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/OrganizationConfig.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/OrganizationConfig.java
@@ -69,6 +69,11 @@ public class OrganizationConfig {
     private OrganizationConfig() {
     }
 
+    public OrganizationConfig(OrganizationConfigProps configFileProperties) {
+        setDefaultProperties(configFileProperties);
+        // will add id and name once default org exists
+    }
+
     public OrganizationConfig(OrganizationConfigProps configFileProperties, UUID id, String name) {
         setDefaultProperties(configFileProperties);
         this.id = id;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/a5185f2e/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
index 329f0d2..198798b 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
@@ -3214,12 +3214,10 @@ public class ManagementServiceImpl implements ManagementService {
         if ( entity != null ) {
             Map entityProperties = em.getDictionaryAsMap(entity, ORGANIZATION_CONFIG_DICTIONARY);
             return new OrganizationConfig(orgConfigProperties, entity.getUuid(), entity.getName(), entityProperties);
-        } else {
-            // return the defaults
-            return new OrganizationConfig(orgConfigProperties)
         }
 
-        return null;
+        // return the defaults
+        return new OrganizationConfig(orgConfigProperties);
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/a5185f2e/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java b/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
index ef97188..cad9cca 100644
--- a/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
+++ b/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
@@ -120,7 +120,7 @@ public class AppInfoMigrationPluginTest {
         List<Entity> deletedApps = new ArrayList<>();
 
         setup.getEmf().initializeApplicationV2(
-            CassandraService.DEFAULT_ORGANIZATION, AppInfoMigrationPlugin.SYSTEM_APP_ID, "systemapp", null);
+            CassandraService.DEFAULT_ORGANIZATION, AppInfoMigrationPlugin.SYSTEM_APP_ID, CassandraService.MANAGEMENT_APPLICATION, null);
 
         EntityManager systemAppEm = setup.getEmf().getEntityManager( AppInfoMigrationPlugin.SYSTEM_APP_ID );
 


[10/44] usergrid git commit: remove location if its not a map

Posted by md...@apache.org.
remove location if its not a map


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

Branch: refs/heads/USERGRID-933
Commit: 56801735c9af438b090df700c17b8ca8c22f6be9
Parents: 58f7402
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Sep 11 17:44:57 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Sep 11 17:44:57 2015 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityMapUtilsTest.java   |  5 ++-
 stack/corepersistence/model/pom.xml             |  6 ++-
 .../model/entity/MapToEntityConverter.java      | 39 +++++++++++++++-----
 3 files changed, 37 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/56801735/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
index 6e4e9a4..325e51f 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
@@ -38,6 +38,7 @@ import java.io.IOException;
 import java.util.*;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 
@@ -132,14 +133,14 @@ public class CpEntityMapUtilsTest {
 
         cpEntity = CpEntityMapUtils.fromMap(properties, "loc", true);
 
-        assertTrue(cpEntity.getFieldMap().get("location") instanceof EntityObjectField);
+        assertNull(cpEntity.getFieldMap().get("location"));
 
         properties = new LinkedHashMap<String, Object>();
         properties.put("location", "denver");
 
         cpEntity = CpEntityMapUtils.fromMap(properties, "loc", true);
 
-        assertTrue(cpEntity.getFieldMap().get("location") instanceof StringField);
+        assertNull(cpEntity.getFieldMap().get("location") );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/56801735/stack/corepersistence/model/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/pom.xml b/stack/corepersistence/model/pom.xml
index 142bca1..591935f 100644
--- a/stack/corepersistence/model/pom.xml
+++ b/stack/corepersistence/model/pom.xml
@@ -40,7 +40,11 @@
             <artifactId>commons-lang3</artifactId>
             <version>${commons.lang.version}</version>
         </dependency>
-
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>${slf4j.version}</version>
+        </dependency>
       <!-- the core, which includes Streaming API, shared low-level abstractions (but NOT data-binding) -->
       <dependency>
         <groupId>com.fasterxml.jackson.core</groupId>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/56801735/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
index e6744c4..dbd1b2a 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
@@ -25,15 +25,22 @@ import com.fasterxml.jackson.datatype.guava.GuavaModule;
 import org.apache.usergrid.persistence.model.collection.SchemaManager;
 import org.apache.usergrid.persistence.model.field.*;
 import org.apache.usergrid.persistence.model.field.value.Location;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.nio.ByteBuffer;
 import java.util.*;
 
 public class MapToEntityConverter{
+    public static final Logger logger = LoggerFactory.getLogger(MapToEntityConverter.class);
 
     private final JsonFactory jsonFactory = new JsonFactory();
     private final ObjectMapper objectMapper = new ObjectMapper(jsonFactory).registerModule(new GuavaModule());
 
+    static final String locationKey = "location";
+    static final String lat = "latitude";
+    static final String lon = "longitude";
+
     public  Entity fromMap( Map<String, Object> map,  boolean topLevel ) {
 
         Entity  entity = new Entity();
@@ -48,9 +55,15 @@ public class MapToEntityConverter{
             }
             Object value = map.get( fieldName );
             boolean unique = schemaManager == null ? topLevel :  topLevel && schemaManager.isPropertyUnique(entityType, fieldName);
+            //cannot store fields that aren't locations
+            if(fieldName.toLowerCase().equals(locationKey) && !(value instanceof Map)) {
+                logger.warn("can't map entity with location field");
+                continue;
+            }
 
             if ( value instanceof String ) {
-                entity.setField( new StringField( fieldName, (String)value, unique  ));
+                String stringValue =(String)value;
+                entity.setField(new StringField(fieldName, stringValue, unique));
 
             } else if ( value instanceof Boolean ) {
                 entity.setField( new BooleanField( fieldName, (Boolean)value, unique  ));
@@ -190,26 +203,28 @@ public class MapToEntityConverter{
 
         // Expect at least two fields in a Location object and must have lat lon
         if (m.size() >= 2 && (
-            (m.containsKey("latitude")  && m.containsKey("longitude") )
+            (m.containsKey(lat)  && m.containsKey(lon) )
                 || (m.containsKey("lat") && m.containsKey("lon") )
         )) {
 
-            Double lat, lon;
+            Double latVal, lonVal;
 
             // check the properties to make sure they are set and are doubles
-            if (m.containsKey("latitude")  && m.containsKey("longitude")) {
+            if (m.containsKey(lat)  && m.containsKey(lon)) {
                 try {
-                    lat = Double.parseDouble(m.get("latitude").toString());
-                    lon = Double.parseDouble(m.get("longitude").toString());
+                    latVal = Double.parseDouble(m.get(lat).toString());
+                    lonVal = Double.parseDouble(m.get(lon).toString());
 
                 } catch (NumberFormatException ignored) {
                     throw new IllegalArgumentException(
                         "Latitude and longitude must be doubles (e.g. 32.1234).");
                 }
             } else if (m.containsKey("lat") && m.containsKey("lon")) {
+                logger.warn("Entity contains latitude and longitude in old format location{lat,long}"
+                );
                 try {
-                    lat = Double.parseDouble(m.get("lat").toString());
-                    lon = Double.parseDouble(m.get("lon").toString());
+                    latVal = Double.parseDouble(m.get("lat").toString());
+                    lonVal = Double.parseDouble(m.get("lon").toString());
                 } catch (NumberFormatException ignored) {
                     throw new IllegalArgumentException(""
                         + "Latitude and longitude must be doubles (e.g. 32.1234).");
@@ -219,9 +234,13 @@ public class MapToEntityConverter{
                     + "latitude and longitude, or lat and lon");
             }
 
-            entity.setField(new LocationField(fieldName, new Location(lat, lon)));
+            entity.setField(new LocationField(fieldName, new Location(latVal, lonVal)));
         } else {
-            entity.setField(new EntityObjectField(fieldName,fromMap( value, false))); // recursion
+            //can't process non enties
+            logger.warn(
+                "entity cannot process location values that don't have valid location{latitude,longitude} values"
+            );
+           // entity.setField(new EntityObjectField(fieldName,fromMap( value, false))); // recursion
         }
     }
 }


[02/44] usergrid git commit: fix default queue

Posted by md...@apache.org.
fix default queue


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

Branch: refs/heads/USERGRID-933
Commit: 1c7ab04338e89fd1a7d1ebd15918be8875f933d7
Parents: 929528a
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Sep 10 17:06:39 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Sep 10 17:06:39 2015 -0600

----------------------------------------------------------------------
 .../queue/impl/QueueManagerFactoryImpl.java         | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/1c7ab043/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerFactoryImpl.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerFactoryImpl.java
index 2f9e7b1..d0ed1ef 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerFactoryImpl.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerFactoryImpl.java
@@ -25,6 +25,9 @@ import com.google.inject.Provider;
 import com.google.inject.Singleton;
 import org.apache.usergrid.persistence.queue.*;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * manages whether we take in an external in memory override for queues.
  */
@@ -34,14 +37,25 @@ public class QueueManagerFactoryImpl implements QueueManagerFactory {
 
     private final QueueFig queueFig;
     private final QueueManagerInternalFactory queuemanagerInternalFactory;
+    private final Map<String,QueueManager> defaultManager;
 
     @Inject
     public QueueManagerFactoryImpl(final QueueFig queueFig, final QueueManagerInternalFactory queuemanagerInternalFactory){
         this.queueFig = queueFig;
         this.queuemanagerInternalFactory = queuemanagerInternalFactory;
+        this.defaultManager = new HashMap<>(10);
     }
     @Override
     public QueueManager getQueueManager(QueueScope scope) {
-        return queueFig.overrideQueueForDefault() ? new DefaultQueueManager() : queuemanagerInternalFactory.getQueueManager(scope);
+        if(queueFig.overrideQueueForDefault()){
+            QueueManager manager = defaultManager.get(scope.getName());
+            if(manager==null){
+                manager = new DefaultQueueManager();
+                defaultManager.put(scope.getName(),manager);
+            }
+            return manager;
+        }else{
+            return queuemanagerInternalFactory.getQueueManager(scope);
+        }
     }
 }


[05/44] usergrid git commit: Add database setup to migration script.

Posted by md...@apache.org.
Add database setup to migration script.


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

Branch: refs/heads/USERGRID-933
Commit: 66ba6b47702dfd13e472fdc62eb0e97af07afe00
Parents: cf6cf83
Author: Michael Russo <mi...@gmail.com>
Authored: Fri Sep 11 12:48:57 2015 -0700
Committer: Michael Russo <mi...@gmail.com>
Committed: Fri Sep 11 12:48:57 2015 -0700

----------------------------------------------------------------------
 stack/scripts/migrate_entity_data.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/66ba6b47/stack/scripts/migrate_entity_data.py
----------------------------------------------------------------------
diff --git a/stack/scripts/migrate_entity_data.py b/stack/scripts/migrate_entity_data.py
index 66a9dd0..4258a71 100644
--- a/stack/scripts/migrate_entity_data.py
+++ b/stack/scripts/migrate_entity_data.py
@@ -130,6 +130,8 @@ class Migrate:
 
         try:
 
+            self.run_database_setup()
+
             # We need to check and roll the migration system to 1 if not already
             migration_system_updated = self.is_migration_system_updated()
 
@@ -220,6 +222,10 @@ class Migrate:
             self.log_metrics()
             self.logger.error('Keyboard interrupted migration. Please run again to ensure the migration finished.')
 
+    def get_database_setup_url(self):
+        url = self.endpoint + '/system/database/setup'
+        return url
+
     def get_migration_url(self):
         url = self.endpoint + '/system/migrate/run'
         return url
@@ -255,6 +261,17 @@ class Migrate:
             self.logger.error('Failed to start migration, %s', e)
             exit_on_error(str(e))
 
+    def run_database_setup(self):
+        try:
+            setupUrl = self.get_database_setup_url()
+            r = requests.put(url=setupUrl, auth=(self.admin_user, self.admin_pass))
+            if r.status_code != 200:
+                exit_on_error('Database Setup Failed')
+
+        except requests.exceptions.RequestException as e:
+            self.logger.error('Failed to run database setup, %s', e)
+            exit_on_error(str(e))
+
     def start_index_mapping_migration(self):
         try:
             migrateUrl = self.get_migration_url() + '/' + PLUGIN_INDEX_MAPPING


[36/44] usergrid git commit: Merge branch 'USERGRID-1018' into 2.1-release

Posted by md...@apache.org.
Merge branch 'USERGRID-1018' into 2.1-release


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

Branch: refs/heads/USERGRID-933
Commit: 0c12abb154c85ea5ccfd936490a2f84b0ffe5d24
Parents: 61dd559 0d4dd11
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Sep 18 10:48:34 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Sep 18 10:48:34 2015 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/CoreModule.java    |  51 +++-
 .../corepersistence/CpRelationManager.java      |  23 +-
 .../asyncevents/AsyncEventService.java          |   2 +
 .../migration/CoreMigration.java                |  45 +---
 .../migration/CoreMigrationPlugin.java          |  38 ++-
 .../migration/DeDupConnectionDataMigration.java |  93 ++++++++
 .../migration/EntityTypeMappingMigration.java   | 104 --------
 .../migration/MigrationModuleVersionPlugin.java |   5 -
 .../corepersistence/migration/Versions.java     |  31 ---
 .../builder/PipelineBuilderFactory.java         |   3 +
 .../service/ConnectionScope.java                |  53 +++++
 .../service/ConnectionService.java              |  10 +
 .../service/ConnectionServiceImpl.java          |  89 ++++++-
 .../corepersistence/util/CpNamingUtils.java     |  13 +-
 .../corepersistence/TestCoreModule.java         |  34 +++
 .../DeDupConnectionDataMigrationTest.java       | 145 ++++++++++++
 .../migration/EntityTypeMappingMigrationIT.java | 125 ----------
 .../service/ConnectionServiceImplTest.java      | 235 +++++++++++++++++++
 stack/core/src/test/resources/log4j.properties  |   6 +-
 .../serialization/impl/SerializationModule.java |   4 +-
 .../migration/CollectionMigrationPlugin.java    |   8 +-
 .../migration/MvccEntityDataMigrationImpl.java  |  10 +-
 ...ctMvccEntityDataMigrationV1ToV3ImplTest.java |  39 +--
 .../migration/data/AbstractMigrationPlugin.java |  17 +-
 .../core/migration/data/DataMigration.java      |  11 +-
 .../migration/data/MigrationDataProvider.java   |   2 +-
 .../core/migration/data/MigrationPlugin.java    |   4 +-
 .../migration/schema/MigrationManagerFig.java   |   1 +
 .../migration/data/TestProgressObserver.java    |  10 +-
 .../persistence/graph/guice/GraphModule.java    |   4 +-
 .../graph/impl/GraphManagerImpl.java            |   4 +-
 .../impl/stage/EdgeDeleteListenerImpl.java      |   4 +-
 .../graph/impl/stage/EdgeDeleteRepairImpl.java  |  61 ++---
 .../impl/TargetIdObservableImpl.java            |  13 +-
 .../impl/migration/EdgeDataMigrationImpl.java   |  12 +-
 .../impl/migration/GraphMigrationPlugin.java    |   8 +-
 .../impl/shard/impl/EdgeSearcher.java           |  14 +-
 .../impl/ShardedEdgeSerializationImpl.java      |  59 +++--
 .../shard/impl/serialize/EdgeSerializer.java    |  21 +-
 .../persistence/graph/GraphManagerIT.java       |  73 +++++-
 .../migration/EdgeDataMigrationImplTest.java    |  59 +++--
 .../persistence/index/guice/IndexModule.java    |   4 +-
 .../index/migration/EsIndexMigrationPlugin.java |   8 +-
 43 files changed, 1038 insertions(+), 517 deletions(-)
----------------------------------------------------------------------



[09/44] usergrid git commit: removing noop exceptions, removing failures due to bad location fields

Posted by md...@apache.org.
removing noop exceptions, removing failures due to bad location fields


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

Branch: refs/heads/USERGRID-933
Commit: 58f7402db5686ada9174b301ebeebb09a55ceb29
Parents: c3c71c9
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Sep 11 17:17:02 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Sep 11 17:17:02 2015 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityMapUtilsTest.java   | 51 ++++++++++++++++++--
 1 file changed, 47 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/58f7402d/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
index 5dd8f3a..6e4e9a4 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
@@ -21,20 +21,21 @@ import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
+import junit.framework.Assert;
 import org.apache.usergrid.corepersistence.util.CpEntityMapUtils;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.model.field.EntityObjectField;
 import org.apache.usergrid.persistence.model.field.ListField;
+import org.apache.usergrid.persistence.model.field.LocationField;
+import org.apache.usergrid.persistence.model.field.StringField;
 import org.apache.usergrid.persistence.model.field.value.EntityObject;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -100,6 +101,48 @@ public class CpEntityMapUtilsTest {
     }
 
 
+    @Test
+    public void testLocation() {
+
+        /*** This tests example property input of
+
+         {
+         "nestedarray" : [ [ "fred" ] ]
+         }
+
+         ****/
+        Map<String, Object> locMap = new HashMap<>();
+        locMap.put("latitude", 123.1);
+        locMap.put("longitude", 123.1);
+
+        Map<String, Object> properties = new LinkedHashMap<String, Object>();
+        properties.put("location", locMap);
+
+        Entity cpEntity = CpEntityMapUtils.fromMap(properties, "loc", true);
+
+        assertTrue(cpEntity.getFieldMap().get("location") instanceof LocationField);
+
+
+        locMap = new HashMap<>();
+        locMap.put("latitude", 123.1);
+        locMap.put("lgnosoos", 123.1);
+
+        properties = new LinkedHashMap<String, Object>();
+        properties.put("location", locMap);
+
+        cpEntity = CpEntityMapUtils.fromMap(properties, "loc", true);
+
+        assertTrue(cpEntity.getFieldMap().get("location") instanceof EntityObjectField);
+
+        properties = new LinkedHashMap<String, Object>();
+        properties.put("location", "denver");
+
+        cpEntity = CpEntityMapUtils.fromMap(properties, "loc", true);
+
+        assertTrue(cpEntity.getFieldMap().get("location") instanceof StringField);
+    }
+
+
 
     @Test
     public void testSerialization() throws JsonProcessingException, IOException {


[25/44] usergrid git commit: clean up uuid to string code for index

Posted by md...@apache.org.
clean up uuid to string code for index


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

Branch: refs/heads/USERGRID-933
Commit: a562079989cfe2d9ae46e0f8eb9ac07ded794023
Parents: 968496d
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Sep 16 07:40:07 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Sep 16 07:40:07 2015 -0600

----------------------------------------------------------------------
 .../usergrid/persistence/index/impl/EsQueryVistor.java  | 12 ++++--------
 .../persistence/index/impl/EntityIndexTest.java         |  1 +
 2 files changed, 5 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/a5620799/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
index af60ed6..414f716 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
@@ -361,9 +361,9 @@ public class EsQueryVistor implements QueryVisitor {
         final String name = op.getProperty().getValue().toLowerCase();
         final Object value = op.getLiteral().getValue();
 
-        //special case so we support our '*' char with wildcard
+        //special case so we support our '*' char with wildcard, also should work for uuids
         if ( value instanceof String || value instanceof UUID ) {
-            final String stringValue = (value.toString()).toLowerCase().trim();
+            final String stringValue = ((value instanceof String) ? (String)value : value.toString()).toLowerCase().trim();
 
             // or field is just a string that does need a prefix us a query
             if ( stringValue.contains( "*" ) ) {
@@ -503,11 +503,7 @@ public class EsQueryVistor implements QueryVisitor {
      * Get the field name for the primitive type
      */
     private String getFieldNameForType( final Object object ) {
-        if ( object instanceof String) {
-            return IndexingUtils.FIELD_STRING_NESTED;
-        }
-
-        if(object instanceof UUID){
+        if ( object instanceof String || object instanceof UUID) {
             return IndexingUtils.FIELD_STRING_NESTED;
         }
 
@@ -540,7 +536,7 @@ public class EsQueryVistor implements QueryVisitor {
         }
 
         if ( input instanceof UUID ) {
-            return  input.toString() ;
+            return input.toString().toLowerCase() ;
         }
 
         return input;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/a5620799/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index 7aa97b1..6348a44 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -179,6 +179,7 @@ public class EntityIndexTest extends BaseIT {
         assertEquals( entity2.getId(), candidate2.getId() );
         assertEquals( entity2.getVersion(), candidate2.getVersion() );
 
+        //make sure we can query uuids out as strings and not wrapped
         candidateResults =
             entityIndex.search( indexEdge, searchTypes, "select * where testuuid = '"+uuid+"'", 100, 0 );
         assertEquals(entity1.getId(),candidateResults.get(0).getId());


[03/44] usergrid git commit: Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into two-dot-o-dev

Posted by md...@apache.org.
Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into two-dot-o-dev


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

Branch: refs/heads/USERGRID-933
Commit: a7ae791501ca67ea511d0cb1a0a3f29639c97502
Parents: 1c7ab04 1efd176
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Sep 10 17:07:05 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Sep 10 17:07:05 2015 -0600

----------------------------------------------------------------------
 .../persistence/entities/Notification.java      | 12 ++++++----
 .../organizations/OrganizationResource.java     |  7 ++++--
 .../security/SecuredResourceFilterFactory.java  |  7 +++---
 .../shiro/filters/BasicAuthSecurityFilter.java  |  5 ++--
 .../apache/usergrid/security/shiro/Realm.java   | 24 ++++++++++++++++++++
 .../notifications/apns/APNsNotification.java    |  8 +++----
 .../services/notifications/gcm/GCMAdapter.java  |  9 ++++----
 .../services/notifications/wns/WNSAdapter.java  | 13 ++++++++---
 .../apns/NotificationsServiceIT.java            |  1 +
 .../gcm/NotificationsServiceIT.java             |  1 +
 10 files changed, 65 insertions(+), 22 deletions(-)
----------------------------------------------------------------------



[04/44] usergrid git commit: add apm mobile config

Posted by md...@apache.org.
add apm mobile config


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

Branch: refs/heads/USERGRID-933
Commit: cf6cf83348819ead3ad58b1308832c06e1c9b412
Parents: a7ae791
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Sep 11 10:44:38 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Sep 11 10:44:38 2015 -0600

----------------------------------------------------------------------
 .../usergrid/rest/applications/ApplicationResource.java | 11 +++++++++--
 .../rest/applications/ApplicationResourceIT.java        | 12 ++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/cf6cf833/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
index 52a0f99..c521d4f 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
@@ -35,6 +35,7 @@ import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.SimpleEntityRef;
 import org.apache.usergrid.persistence.entities.Application;
 import org.apache.usergrid.persistence.entities.User;
+import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
 import org.apache.usergrid.persistence.index.query.Identifier;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.applications.assets.AssetsResource;
@@ -42,6 +43,7 @@ import org.apache.usergrid.rest.applications.events.EventsResource;
 import org.apache.usergrid.rest.applications.queues.QueueResource;
 import org.apache.usergrid.rest.applications.users.UsersResource;
 import org.apache.usergrid.rest.exceptions.AuthErrorInfo;
+import org.apache.usergrid.rest.exceptions.NotFoundExceptionMapper;
 import org.apache.usergrid.rest.exceptions.RedirectionException;
 import org.apache.usergrid.rest.security.annotations.RequireApplicationAccess;
 import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess;
@@ -589,8 +591,13 @@ public class ApplicationResource extends ServiceResource {
                 APIGEE_MOBILE_APM_CONFIG_JSON_KEY );
         //If there is no apm configuration then try to create apm config on the fly
         if ( value == null ) {
-            value = management.registerAppWithAPM( management.getOrganizationForApplication( applicationId ),
-                    management.getApplicationInfo( applicationId ) );
+            value = management.registerAppWithAPM(
+                management.getOrganizationForApplication( applicationId ),
+                management.getApplicationInfo( applicationId )
+            );
+        }
+        if(value==null){
+            throw new EntityNotFoundException("apigeeMobileConfig not found, it is possibly not enabled for your config.");
         }
         return new JSONWithPadding( value, callback );
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/cf6cf833/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
index ec858f7..f7e8dc3 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
@@ -21,10 +21,12 @@ import com.sun.jersey.api.client.ClientResponse.Status;
 import com.sun.jersey.api.client.UniformInterfaceException;
 import com.sun.jersey.api.client.WebResource;
 import com.sun.jersey.api.representation.Form;
+import junit.framework.Assert;
 import org.apache.commons.lang.RandomStringUtils;
 import org.apache.shiro.codec.Base64;
 import org.apache.usergrid.cassandra.SpringResource;
 import org.apache.usergrid.management.ManagementService;
+import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.endpoints.mgmt.OrganizationResource;
 import org.apache.usergrid.rest.test.resource.model.*;
@@ -845,6 +847,16 @@ public class ApplicationResourceIT extends AbstractRestIT {
         assertNull(response.getError());
     }
 
+    @Test
+    public void getApmConfig(){
+        try {
+            Collection collection = this.app().collection("apm/apigeeMobileConfig").get();
+            fail();
+        }catch (UniformInterfaceException e){
+            Assert.assertEquals(404, e.getResponse().getStatus());
+        }
+    }
+
     /**
      * Get the client credentials for the current app
      * @return Credentials


[12/44] usergrid git commit: Fix issue with portal login button not handling failed logins properly when logging is disabled. Bump version.

Posted by md...@apache.org.
Fix issue with portal login button not handling failed logins properly when logging is disabled.  Bump version.


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

Branch: refs/heads/USERGRID-933
Commit: 7eb997b1c550bbd1661e223570b18f4cf2ba84d7
Parents: ca32186
Author: Michael Russo <mi...@gmail.com>
Authored: Fri Sep 11 16:59:40 2015 -0700
Committer: Michael Russo <mi...@gmail.com>
Committed: Fri Sep 11 16:59:40 2015 -0700

----------------------------------------------------------------------
 portal/bower.json              | 2 +-
 portal/js/libs/usergrid.sdk.js | 8 +++++---
 portal/package.json            | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/7eb997b1/portal/bower.json
----------------------------------------------------------------------
diff --git a/portal/bower.json b/portal/bower.json
index 3c4784c..7ffb4ff 100644
--- a/portal/bower.json
+++ b/portal/bower.json
@@ -1,6 +1,6 @@
 {
   "name": "usergrid-portal",
-  "version": "2.0.17",
+  "version": "2.0.18",
   "ignore": [
     ".jshintrc",
     "**/*.txt",

http://git-wip-us.apache.org/repos/asf/usergrid/blob/7eb997b1/portal/js/libs/usergrid.sdk.js
----------------------------------------------------------------------
diff --git a/portal/js/libs/usergrid.sdk.js b/portal/js/libs/usergrid.sdk.js
index 795e3e2..d527ea0 100755
--- a/portal/js/libs/usergrid.sdk.js
+++ b/portal/js/libs/usergrid.sdk.js
@@ -774,8 +774,10 @@
       var user = {};
       var organizations = {};
       var applications = {};
-      if (err && self.logging) {
-        console.log('error trying to log user in');
+      if (err ) {
+        if(self.logging) {
+          console.log('error trying to log user in');
+        }
       } else {
         var options = {
           client: self,
@@ -2563,4 +2565,4 @@
     return tail.join("&");
   }
 
-})(window, sessionStorage);
\ No newline at end of file
+})(window, sessionStorage);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/7eb997b1/portal/package.json
----------------------------------------------------------------------
diff --git a/portal/package.json b/portal/package.json
index d91ec7a..e36a910 100644
--- a/portal/package.json
+++ b/portal/package.json
@@ -1,6 +1,6 @@
 {
   "name": "usergrid", 
-  "version": "2.0.17",
+  "version": "2.0.18",
   "packageName": "appsvc-ui",
   "description": "full usergrid portal",
   "main": "./scripts/web-server.js",


[20/44] usergrid git commit: Fixes incorrect Cassandra range scanning in serialization with min/max values

Posted by md...@apache.org.
Fixes incorrect Cassandra range scanning in serialization with min/max values


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

Branch: refs/heads/USERGRID-933
Commit: 6233bf0b23e6f86b0d57607d2dd423599c27e726
Parents: 13d2594
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Sep 15 17:20:24 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Sep 15 17:20:24 2015 -0600

----------------------------------------------------------------------
 .../service/ConnectionServiceImpl.java          | 30 +++++-----
 .../service/ConnectionServiceImplTest.java      | 19 ++++---
 .../core/astyanax/MultiRowColumnIterator.java   |  2 +-
 .../graph/impl/GraphManagerImpl.java            |  4 +-
 .../impl/shard/impl/EdgeSearcher.java           | 14 ++++-
 .../impl/ShardedEdgeSerializationImpl.java      | 59 ++++++++++++++------
 .../shard/impl/serialize/EdgeSerializer.java    | 21 ++++++-
 .../persistence/graph/GraphManagerIT.java       |  4 +-
 8 files changed, 105 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/6233bf0b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
index d60426c..1b36321 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
@@ -170,7 +170,7 @@ public class ConnectionServiceImpl implements ConnectionService {
 
                     final SearchByEdgeType searchByEdge =
                         new SimpleSearchByEdgeType( entityId, edgeType, Long.MAX_VALUE,
-                            SearchByEdgeType.Order.ASCENDING, Optional.absent() );
+                            SearchByEdgeType.Order.DESCENDING, Optional.absent() );
 
                     //load edges from the source the with type specified
                     return gm.loadEdgesFromSource( searchByEdge );
@@ -182,21 +182,25 @@ public class ConnectionServiceImpl implements ConnectionService {
                     logger.debug( "Found edge {}, searching for multiple versions of edge", edge );
 
                     final SearchByEdge searchByEdge =
-                        new SimpleSearchByEdge( edge.getSourceNode(), edge.getType(), edge.getTargetNode(),
-                            Long.MAX_VALUE, SearchByEdgeType.Order.ASCENDING, Optional.absent() );
-                    return gm.loadEdgeVersions( searchByEdge );
-                } )
+                        new SimpleSearchByEdge( edge.getSourceNode(), edge.getType(), edge.getTargetNode(), 0,
+                            SearchByEdgeType.Order.ASCENDING, Optional.absent() );
+                    return gm.loadEdgeVersions( searchByEdge )
+                        //skip the first version since it's the one we want to retain
+                        .skip( 1 )
+                            //mark for deletion
+                        .flatMap( edgeToDelete -> {
 
-                    //skip the first version since it's the one we want to retain
-                    // validate there is only 1 version of it, delete anything > than the min
-                .skip( 1 ).flatMap( edgeToDelete -> {
+                            logger.debug( "Deleting edge {}", edgeToDelete );
 
-                    logger.debug( "Deleting edge {}", edgeToDelete );
+                            //mark the edge and ignore the cleanup result
+                            return gm.markEdge( edgeToDelete );
+                        } )
+                            //mark all versions, then on the last, delete them from cass
+                        .flatMap( lastMarkedEdge -> gm.deleteEdge( lastMarkedEdge ) );
+
+
+                    // validate there is only 1 version of it, delete anything > than the min
 
-                    //mark the edge and ignore the cleanup result
-                    return gm.markEdge( edgeToDelete )
-                        //delete the edge
-                        .flatMap( edge -> gm.deleteEdge( edgeToDelete ) );
                 } ).map( deletedEdge -> new ConnectionScope( applicationScope, deletedEdge ) );
         } );
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6233bf0b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
index 152721a..a2c18b1 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
@@ -49,6 +49,7 @@ import rx.Observable;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 
 @RunWith( ITRunner.class )
@@ -179,19 +180,20 @@ public class ConnectionServiceImplTest {
 
         final Edge written3 = gm.writeEdge( connection3 ).toBlocking().last();
 
+
         logger.info( "Wrote edge 3 with edge {}", written3 );
 
 
+
+        assertTrue( "Expected edge timestamp to be in order", written1.getTimestamp() <= written2.getTimestamp() );
+        assertTrue( "Expected edge timestamp to be in order", written2.getTimestamp() <= written3.getTimestamp() );
+
         //now run the cleanup
 
         final List<ConnectionScope> deletedConnections =
             connectionService.deDupeConnections( Observable.just( applicationScope ) ).toList().toBlocking().last();
 
-//        assertEquals( "2 edges deleted", 2, deletedConnections.size() );
-
         //check our oldest was deleted first
-
-
         assertEdgeData( written2, deletedConnections.get( 0 ).getEdge() );
 
         assertEdgeData( written3, deletedConnections.get( 1 ).getEdge() );
@@ -221,12 +223,13 @@ public class ConnectionServiceImplTest {
      * @param asserted
      */
     private void assertEdgeData(final Edge expected, final Edge asserted){
-        assertEquals("SourceId the same", expected.getSourceNode(), expected.getTargetNode());
-        assertEquals("TargetId the same", expected.getTargetNode(), expected.getTargetNode());
+        assertEquals("SourceId the same", expected.getSourceNode(), asserted.getSourceNode());
+
+        assertEquals("TargetId the same", expected.getTargetNode(), asserted.getTargetNode());
 
-        assertEquals("Type the same", expected.getType(), expected.getType());
+        assertEquals("Type the same", expected.getType(), asserted.getType());
 
-        assertEquals("Timestamp the same", expected.getTimestamp(), expected.getTimestamp());
+        assertEquals("Timestamp the same", expected.getTimestamp(), asserted.getTimestamp());
 
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6233bf0b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
index 667992c..16249ae 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
@@ -201,7 +201,7 @@ public class MultiRowColumnIterator<R, C, T> implements Iterator<T> {
         final List<T> mergedResults;
 
         if ( containsSingleRowOnly( result ) ) {
-            mergedResults = singleRowResult( result );
+               mergedResults = singleRowResult( result );
         }
         else {
             mergedResults = mergeResults( result, selectSize );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6233bf0b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java
index 8c64fa1..e119c59 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java
@@ -217,7 +217,7 @@ public class GraphManagerImpl implements GraphManager {
                 protected Iterator<MarkedEdge> getIterator() {
                     return storageEdgeSerialization.getEdgeVersions( scope,
                         new SimpleSearchByEdge( edge.getSourceNode(), edge.getType(), edge.getTargetNode(),
-                            Long.MAX_VALUE, SearchByEdgeType.Order.ASCENDING, Optional.absent() ) );
+                            Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, Optional.absent() ) );
                 }
             } ).filter( markedEdge -> markedEdge.isDeleted() ).flatMap( marked ->
                 //fire our delete listener and wait for the results
@@ -458,7 +458,7 @@ public class GraphManagerImpl implements GraphManager {
                     final long edgeTimestamp = edge.getTimestamp();
 
                     //our edge needs to not be deleted and have a version that's > max Version
-                    if ( edge.isDeleted() || Long.compare( edgeTimestamp, maxVersion ) > 0 ) {
+                    if ( edge.isDeleted() ) {
                         return false;
                     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6233bf0b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeSearcher.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeSearcher.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeSearcher.java
index 8bcefbb..4d02ba9 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeSearcher.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeSearcher.java
@@ -1,6 +1,7 @@
 package org.apache.usergrid.persistence.graph.serialization.impl.shard.impl;
 
 
+import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Comparator;
@@ -13,6 +14,7 @@ import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.graph.Edge;
 import org.apache.usergrid.persistence.graph.MarkedEdge;
 import org.apache.usergrid.persistence.graph.SearchByEdgeType;
+import org.apache.usergrid.persistence.graph.serialization.impl.shard.DirectedEdge;
 import org.apache.usergrid.persistence.graph.serialization.impl.shard.Shard;
 
 import com.google.common.base.Optional;
@@ -107,12 +109,12 @@ public abstract class EdgeSearcher<R, C, T> implements ColumnParser<C, T>, Colum
         if ( last.isPresent() ) {
             C sourceEdge = createColumn( last.get() );
 
-
             rangeBuilder.setStart( sourceEdge, getSerializer() );
+        }else {
+            setTimeScan( rangeBuilder );
         }
 
-
-        setRangeOptions(rangeBuilder);
+        setRangeOptions( rangeBuilder );
 
 
     }
@@ -122,6 +124,7 @@ public abstract class EdgeSearcher<R, C, T> implements ColumnParser<C, T>, Colum
         final boolean reversed = order == SearchByEdgeType.Order.ASCENDING;
 
         rangeBuilder.setReversed( reversed );
+
     }
 
 
@@ -153,6 +156,11 @@ public abstract class EdgeSearcher<R, C, T> implements ColumnParser<C, T>, Colum
      */
     protected abstract C createColumn( final T last );
 
+    /**
+     * Set the time scan into the range builder
+     * @param rangeBuilder
+     */
+    protected abstract void setTimeScan(final RangeBuilder rangeBuilder);
 
     /**
      * Create an edge to return to the user based on the directed edge provided

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6233bf0b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/ShardedEdgeSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/ShardedEdgeSerializationImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/ShardedEdgeSerializationImpl.java
index 13f7427..2ef50f5 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/ShardedEdgeSerializationImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/ShardedEdgeSerializationImpl.java
@@ -21,8 +21,8 @@
 package org.apache.usergrid.persistence.graph.serialization.impl.shard.impl;
 
 
+import java.nio.ByteBuffer;
 import java.util.Collection;
-import java.util.Comparator;
 import java.util.Iterator;
 import java.util.UUID;
 
@@ -54,14 +54,14 @@ import org.apache.usergrid.persistence.graph.serialization.impl.shard.ShardedEdg
 import org.apache.usergrid.persistence.graph.serialization.impl.shard.impl.comparators.DescendingTimestampComparator;
 import org.apache.usergrid.persistence.graph.serialization.impl.shard.impl.comparators.OrderedComparator;
 import org.apache.usergrid.persistence.graph.serialization.impl.shard.impl.comparators
-        .SourceDirectedEdgeDescendingComparator;
+    .SourceDirectedEdgeDescendingComparator;
 import org.apache.usergrid.persistence.graph.serialization.impl.shard.impl.comparators
-        .TargetDirectedEdgeDescendingComparator;
+    .TargetDirectedEdgeDescendingComparator;
+import org.apache.usergrid.persistence.graph.serialization.impl.shard.impl.serialize.EdgeSerializer;
 import org.apache.usergrid.persistence.graph.serialization.util.GraphValidation;
 import org.apache.usergrid.persistence.model.entity.Id;
 
 import com.google.common.base.Function;
-import com.google.common.base.Optional;
 import com.google.inject.Singleton;
 import com.netflix.astyanax.Keyspace;
 import com.netflix.astyanax.MutationBatch;
@@ -388,19 +388,6 @@ public class ShardedEdgeSerializationImpl implements ShardedEdgeSerialization {
                     }
 
 
-                    @Override
-                    public void buildRange( final RangeBuilder builder ) {
-
-
-                        if ( last.isPresent() ) {
-                            super.buildRange( builder );
-                            return;
-                        }
-
-                        //start seeking at a value < our max version
-                        builder.setStart( maxTimestamp );
-                    }
-
 
                     @Override
                     protected EdgeRowKey generateRowKey( long shard ) {
@@ -415,6 +402,13 @@ public class ShardedEdgeSerializationImpl implements ShardedEdgeSerialization {
 
 
                     @Override
+                    protected void setTimeScan( final RangeBuilder rangeBuilder ) {
+                          //start seeking at a value < our max version
+                        rangeBuilder.setStart( maxTimestamp );
+                    }
+
+
+                    @Override
                     protected MarkedEdge createEdge( final Long column, final boolean marked ) {
                         return new SimpleMarkedEdge( sourceId, type, targetId, column.longValue(), marked );
                     }
@@ -472,6 +466,14 @@ public class ShardedEdgeSerializationImpl implements ShardedEdgeSerialization {
 
 
                     @Override
+                    protected void setTimeScan( final RangeBuilder rangeBuilder ) {
+                        final ByteBuffer buffer = EdgeSerializer.INSTANCE.fromTimeRange( maxTimestamp );
+
+                        rangeBuilder.setStart( buffer );
+                    }
+
+
+                    @Override
                     protected MarkedEdge createEdge( final DirectedEdge edge, final boolean marked ) {
                         return new SimpleMarkedEdge( sourceId, type, edge.id, edge.timestamp, marked );
                     }
@@ -526,6 +528,14 @@ public class ShardedEdgeSerializationImpl implements ShardedEdgeSerialization {
 
 
                     @Override
+                    protected void setTimeScan( final RangeBuilder rangeBuilder ) {
+                        final ByteBuffer buffer = EdgeSerializer.INSTANCE.fromTimeRange( maxTimestamp );
+
+                        rangeBuilder.setStart( buffer );
+                    }
+
+
+                    @Override
                     protected MarkedEdge createEdge( final DirectedEdge edge, final boolean marked ) {
                         return new SimpleMarkedEdge( targetId, type, edge.id, edge.timestamp, marked );
                     }
@@ -574,6 +584,14 @@ public class ShardedEdgeSerializationImpl implements ShardedEdgeSerialization {
 
 
                     @Override
+                    protected void setTimeScan( final RangeBuilder rangeBuilder ) {
+                        final ByteBuffer buffer = EdgeSerializer.INSTANCE.fromTimeRange( maxTimestamp );
+
+                        rangeBuilder.setStart( buffer );
+                    }
+
+
+                    @Override
                     protected MarkedEdge createEdge( final DirectedEdge edge, final boolean marked ) {
                         return new SimpleMarkedEdge( edge.id, type, targetId, edge.timestamp, marked );
                     }
@@ -627,6 +645,13 @@ public class ShardedEdgeSerializationImpl implements ShardedEdgeSerialization {
 
 
                     @Override
+                    protected void setTimeScan( final RangeBuilder rangeBuilder ) {
+                        final ByteBuffer buffer = EdgeSerializer.INSTANCE.fromTimeRange( maxTimestamp );
+
+                        rangeBuilder.setStart( buffer );
+                    }
+
+                    @Override
                     protected MarkedEdge createEdge( final DirectedEdge edge, final boolean marked ) {
                         return new SimpleMarkedEdge( edge.id, type, targetId, edge.timestamp, marked );
                     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6233bf0b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/serialize/EdgeSerializer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/serialize/EdgeSerializer.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/serialize/EdgeSerializer.java
index 590cf35..e652c73 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/serialize/EdgeSerializer.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/serialize/EdgeSerializer.java
@@ -35,14 +35,16 @@ import com.netflix.astyanax.serializers.LongSerializer;
 
 
 /**
- * Serializes to a source->target edge Note that we cannot set the edge type on de-serialization.  Only the target
- * Id and version.
+ * Serializes to a source->target edge Note that we cannot set the edge type on de-serialization.  Only the target Id
+ * and version.
  */
 public class EdgeSerializer extends AbstractSerializer<DirectedEdge> {
 
     private static final IdColDynamicCompositeSerializer ID_COL_SERIALIZER = IdColDynamicCompositeSerializer.get();
     private static final LongSerializer LONG_SERIALIZER = LongSerializer.get();
 
+    public static final EdgeSerializer INSTANCE = new EdgeSerializer();
+
 
     @Override
     public ByteBuffer toByteBuffer( final DirectedEdge edge ) {
@@ -74,4 +76,19 @@ public class EdgeSerializer extends AbstractSerializer<DirectedEdge> {
 
         return new DirectedEdge( id, timestamp );
     }
+
+
+    /**
+     * Create a scan range that represents the timestamp of the edge
+     * @param timestamp
+     * @return
+     */
+    public ByteBuffer fromTimeRange( final long timestamp ) {
+        DynamicComposite composite = new DynamicComposite();
+
+        composite.addComponent( timestamp, LONG_SERIALIZER );
+
+
+        return composite.serialize();
+    }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6233bf0b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
index 4b2ffc8..eaded15 100644
--- a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
+++ b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
@@ -2353,7 +2353,7 @@ public class GraphManagerIT {
 
 
         final SearchByEdge searchDescending =
-            new SimpleSearchByEdge( edge1.getSourceNode(), edge1.getType(), edge1.getTargetNode(),Long.MAX_VALUE,
+            new SimpleSearchByEdge( edge1.getSourceNode(), edge1.getType(), edge1.getTargetNode(), Long.MAX_VALUE,
                 SearchByEdgeType.Order.DESCENDING, Optional.<Edge>absent()   );
 
         final Observable<Edge> edgesDescending = gm.loadEdgeVersions( searchDescending );
@@ -2373,7 +2373,7 @@ public class GraphManagerIT {
         //now search ascending
 
         final SearchByEdge searchAscending =
-                    new SimpleSearchByEdge( edge1.getSourceNode(), edge1.getType(), edge1.getTargetNode(),Long.MAX_VALUE,
+                    new SimpleSearchByEdge( edge1.getSourceNode(), edge1.getType(), edge1.getTargetNode(), 0,
                         SearchByEdgeType.Order.ASCENDING, Optional.<Edge>absent()   );
 
         Observable<Edge> edgesAscending = gm.loadEdgeVersions( searchAscending );


[18/44] usergrid git commit: Corrects test setup and adds debug logging

Posted by md...@apache.org.
Corrects test setup and adds debug logging


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

Branch: refs/heads/USERGRID-933
Commit: 85e1e7c1e17470bf012308011950a7ae43565b5f
Parents: b625ed2
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Sep 14 19:07:28 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Sep 14 19:07:28 2015 -0600

----------------------------------------------------------------------
 .../service/ConnectionServiceImpl.java          | 26 ++++++++++++++++++--
 .../service/ConnectionServiceImplTest.java      | 12 ++++++---
 2 files changed, 33 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/85e1e7c1/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
index 82c1038..41e6f80 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
@@ -18,6 +18,9 @@
 package org.apache.usergrid.corepersistence.service;
 
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.usergrid.corepersistence.pipeline.builder.EntityBuilder;
 import org.apache.usergrid.corepersistence.pipeline.builder.IdBuilder;
 import org.apache.usergrid.corepersistence.pipeline.builder.PipelineBuilderFactory;
@@ -47,6 +50,9 @@ import rx.Observable;
 @Singleton
 public class ConnectionServiceImpl implements ConnectionService {
 
+
+    private static final Logger logger = LoggerFactory.getLogger( ConnectionServiceImpl.class );
+
     private final PipelineBuilderFactory pipelineBuilderFactory;
     private final AllEntityIdsObservable allEntityIdsObservable;
     private final GraphManagerFactory graphManagerFactory;
@@ -152,11 +158,16 @@ public class ConnectionServiceImpl implements ConnectionService {
 
             final GraphManager gm = graphManagerFactory.createEdgeManager(applicationScope );
 
+           logger.debug( "Checking connections of id {} in application {}", entityId, applicationScope );
+
             return gm.getEdgeTypesFromSource(
                 new SimpleSearchEdgeType( entityId, CpNamingUtils.EDGE_CONN_PREFIX, Optional.absent() ) )
 
                 //now load all edges from this node of this type
                 .flatMap( edgeType -> {
+
+                    logger.debug( "Found edge of types of {}, searching for edges", edgeType );
+
                     final SearchByEdgeType searchByEdge =
                         new SimpleSearchByEdgeType( entityId, edgeType, Long.MAX_VALUE,
                             SearchByEdgeType.Order.ASCENDING, Optional.absent() );
@@ -167,6 +178,9 @@ public class ConnectionServiceImpl implements ConnectionService {
 
                 //now that we have a stream of edges, stream all versions
                 .flatMap( edge -> {
+
+                    logger.debug( "Found edge {}, searching for multiple versions of edge", edge );
+
                     final SearchByEdge searchByEdge =
                         new SimpleSearchByEdge( edge.getSourceNode(), edge.getType(), edge.getTargetNode(),
                             Long.MAX_VALUE, SearchByEdgeType.Order.ASCENDING, Optional.absent() );
@@ -176,8 +190,16 @@ public class ConnectionServiceImpl implements ConnectionService {
             //skip the first version since it's the one we want to retain
             // validate there is only 1 version of it, delete anything > than the min
                 .skip( 1 )
-                .flatMap( edgeToDelete -> gm.deleteEdge( edgeToDelete ) )
-                .map(deletedEdge ->  new ConnectionScope( applicationScope, deletedEdge ) ) ;
+                .flatMap( edgeToDelete -> {
+
+                    logger.debug( "Deleting edge {}", edgeToDelete );
+
+                    //mark the edge and ignore the cleanup result
+                    return gm.markEdge( edgeToDelete )
+                             //delete the edge
+                             .flatMap( edge -> gm.deleteEdge( edgeToDelete ));
+                } )
+                .map( deletedEdge -> new ConnectionScope( applicationScope, deletedEdge ) ) ;
         });
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/85e1e7c1/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
index 0a29286..e03a9b3 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
@@ -132,9 +132,6 @@ public class ConnectionServiceImplTest {
 
         final Id source = new SimpleId( "source" );
 
-        final Id target = new SimpleId( "target" );
-
-        final String connectionType = "testConnection";
 
 
           //add to a collection
@@ -147,6 +144,15 @@ public class ConnectionServiceImplTest {
 
         assertNotNull("Collection edge written", writtenCollection);
 
+
+        //now write 3 connections between the same nodes.
+
+        final Id target = new SimpleId( "target" );
+
+        final String connectionType = "testConnection";
+
+
+
         //write our first connection
         final Edge connection1 = CpNamingUtils.createConnectionEdge( source, connectionType, target );
 


[41/44] usergrid git commit: Fixes missing observer update

Posted by md...@apache.org.
Fixes missing observer update


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

Branch: refs/heads/USERGRID-933
Commit: 29c1a12dd1a1f070b1c8523e6213f1bf5ac12931
Parents: 521fc03
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Sep 24 12:45:20 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Sep 24 12:45:20 2015 -0600

----------------------------------------------------------------------
 .../management/AppInfoMigrationPlugin.java      | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/29c1a12d/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java b/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
index d0f39e9..ff6bbe3 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
@@ -150,20 +150,10 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
         //get old app infos to migrate
         final Observable<Entity> oldAppInfos = getOldAppInfos();
         oldAppInfos.doOnNext( oldAppInfoEntity -> {
-            try {
-                migrateAppInfo( oldAppInfoEntity, observer );
-                count.incrementAndGet();
-            }
-            catch ( Exception e ) {
-                if ( e.getCause() instanceof ApplicationAlreadyExistsException ) {
-                    count.incrementAndGet();
-                    logger.info( "Application already migrated", oldAppInfoEntity.getId().getUuid() );
-                }
-                else {
-                    logger.error( "Failed to migrate app info" + oldAppInfoEntity.getId().getUuid(), e );
-                    throw new RuntimeException( e );
-                }
-            }
+
+
+            migrateAppInfo( oldAppInfoEntity, observer );
+            count.incrementAndGet();
         } )
             //we want a doOnError to catch something going wrong, otherwise we'll mark as complete
             .doOnError( error -> {
@@ -196,7 +186,6 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
             //get app info from graph to see if it has been migrated already
 
 
-
             // create org->app connections, but not for apps in dummy "usergrid" internal organization
             //avoid management org
 
@@ -209,6 +198,7 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
         //swallow
         catch ( ApplicationAlreadyExistsException appExists ) {
             logger.info( "Application {} already migrated.  Ignoring.", name );
+            observer.update( getMaxVersion(), "Skipping application " + name + " it already exists" );
         }
         catch ( Exception e ) {
             throw new RuntimeException( e );


[35/44] usergrid git commit: Fixes issues found during review

Posted by md...@apache.org.
Fixes issues found during review


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

Branch: refs/heads/USERGRID-933
Commit: 0d4dd1161e0ffacbfe056de205da0860652b0e17
Parents: 901d7c6
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Sep 17 17:10:24 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Sep 17 17:10:24 2015 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/CoreModule.java    |  6 ------
 .../migration/DeDupConnectionDataMigration.java | 22 ++++++++++----------
 .../DeDupConnectionDataMigrationTest.java       |  7 ++++---
 .../core/astyanax/MultiRowColumnIterator.java   |  2 +-
 .../persistence/graph/GraphManagerIT.java       |  6 +++---
 5 files changed, 19 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/0d4dd116/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
index 11707be..486aa6f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
@@ -190,12 +190,6 @@ public class CoreModule  extends AbstractModule {
 
         bind( StatusService.class ).to( StatusServiceImpl.class );
 
-        /**
-         * Install migration services
-         */
-
-          //migrations
-        //we want to make sure our generics are retained, so we use a typeliteral
 
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0d4dd116/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java
index f65864a..bec8d6c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java
@@ -56,24 +56,23 @@ public class DeDupConnectionDataMigration implements DataMigration {
 
         observer.start();
 
-        connectionService.deDupeConnections( allApplicationsObservable.getData() ).reduce( 0l, (count, deDuped) ->{
+        connectionService.deDupeConnections( allApplicationsObservable.getData() ).reduce( 0l, ( count, deDuped ) -> {
 
-            final long newCount = count+1;
+            final long newCount = count + 1;
 
             /**
              * Update our progress observer
              */
-            if(newCount % UPDATE_COUNT == 0){
+            if ( newCount % UPDATE_COUNT == 0 ) {
                 logger.info( "De duped {} edges", newCount );
-                observer.update( migrationVersion, String.format("De duped %d edges", newCount) );
+                observer.update( migrationVersion, String.format( "De duped %d edges", newCount ) );
             }
 
             return newCount;
-
-        }).doOnNext( total -> {
-            logger.info("Completed de-duping {} edges", total );
-            observer.complete();;
-        }).subscribe();
+        } ).doOnNext( total -> {
+            logger.info( "Completed de-duping {} edges", total );
+            observer.complete();
+        } ).subscribe();
 
         return migrationVersion;
 
@@ -82,12 +81,13 @@ public class DeDupConnectionDataMigration implements DataMigration {
 
     @Override
     public boolean supports( final int currentVersion ) {
-        return currentVersion == getMaxVersion() - 1;
+        return currentVersion <= getMaxVersion() - 1;
     }
 
 
     @Override
     public int getMaxVersion() {
-        return 1;
+        //needs to be 2 b/c our obsolete EntityTypeMappingMigration was 1
+        return 2;
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0d4dd116/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java
index c84ad2b..aad6259 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java
@@ -49,8 +49,6 @@ public class DeDupConnectionDataMigrationTest {
     public void testVersion() {
 
         //mock up an initial system state
-        final int version = 0;
-
         final ConnectionService connectionService = mock( ConnectionService.class );
 
         final AllApplicationsObservable allApplicationsObservable = mock( AllApplicationsObservable.class );
@@ -60,7 +58,10 @@ public class DeDupConnectionDataMigrationTest {
             new DeDupConnectionDataMigration( connectionService, allApplicationsObservable );
 
 
-        assertTrue( plugin.supports( version ) );
+        //anything less than 2 should be supported
+        assertTrue( plugin.supports( 0 ) );
+
+        assertTrue( plugin.supports( 1 ) );
 
         assertFalse( plugin.supports( plugin.getMaxVersion() ) );
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0d4dd116/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
index 16249ae..667992c 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
@@ -201,7 +201,7 @@ public class MultiRowColumnIterator<R, C, T> implements Iterator<T> {
         final List<T> mergedResults;
 
         if ( containsSingleRowOnly( result ) ) {
-               mergedResults = singleRowResult( result );
+            mergedResults = singleRowResult( result );
         }
         else {
             mergedResults = mergeResults( result, selectSize );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0d4dd116/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
index eaded15..eda3a02 100644
--- a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
+++ b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
@@ -2339,15 +2339,15 @@ public class GraphManagerIT {
         //write 3 edges with 3 different timestamp
         final Edge edge1 = createEdge( sourceId, "test", target, 1, false );
 
-        gm.writeEdge( edge1 ).toBlocking().last();
+        gm.writeEdge( edge1 ).subscribe();
 
         final Edge edge2 = createEdge( sourceId, "test", target, 2, false );
 
-        gm.writeEdge( edge2 ).toBlocking().last();
+        gm.writeEdge( edge2 ).subscribe();
 
         final Edge edge3 = createEdge( sourceId, "test", target, 3, false );
 
-        gm.writeEdge( edge3 ).toBlocking().last();
+        gm.writeEdge( edge3 ).subscribe();
 
         //now test retrieving it
 


[24/44] usergrid git commit: change parsing logic to parse uuid as string

Posted by md...@apache.org.
change parsing logic to parse uuid as string


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

Branch: refs/heads/USERGRID-933
Commit: 968496d0e66327339b7122af271f86edc4e18e9d
Parents: e2fe939
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Sep 15 18:42:19 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Sep 15 18:42:19 2015 -0600

----------------------------------------------------------------------
 .../usergrid/persistence/index/impl/EntityToMapConverterTest.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/968496d0/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
index 2fb32cd..5ebe14e 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
@@ -170,7 +170,7 @@ public class EntityToMapConverterTest {
     @Test
     public void testUUIDField() {
         testSingleField( new UUIDField( "Name", UUIDGenerator.newTimeUUID() ),
-            ( field, entityField ) -> assertEquals( field.getValue().toString(), entityField.get( IndexingUtils.FIELD_UUID ) ) );
+            ( field, entityField ) -> assertEquals( field.getValue().toString(), entityField.get( IndexingUtils.FIELD_STRING ) ) );
     }
 
 


[28/44] usergrid git commit: Refactored migrations to read their own data sets rather than be passed with an invocation

Posted by md...@apache.org.
Refactored migrations to read their own data sets rather than be passed with an invocation


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

Branch: refs/heads/USERGRID-933
Commit: d971ec509528fa24977a15501776ebb356e6e1c7
Parents: fb1cf2e
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Sep 16 16:44:02 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Sep 16 16:44:02 2015 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/CoreModule.java    |  4 +-
 .../migration/CoreMigrationPlugin.java          |  9 +--
 .../migration/EntityTypeMappingMigration.java   |  4 +-
 .../migration/MigrationModuleVersionPlugin.java |  5 --
 .../migration/EntityTypeMappingMigrationIT.java |  2 +-
 .../serialization/impl/SerializationModule.java |  4 +-
 .../migration/CollectionMigrationPlugin.java    |  8 +--
 .../migration/MvccEntityDataMigrationImpl.java  | 10 ++--
 ...ctMvccEntityDataMigrationV1ToV3ImplTest.java |  9 +--
 .../migration/data/AbstractMigrationPlugin.java | 17 +++---
 .../core/migration/data/DataMigration.java      | 11 ++--
 .../migration/data/MigrationDataProvider.java   |  2 +-
 .../core/migration/data/MigrationPlugin.java    |  4 +-
 .../persistence/graph/guice/GraphModule.java    |  4 +-
 .../impl/migration/EdgeDataMigrationImpl.java   | 12 ++--
 .../impl/migration/GraphMigrationPlugin.java    |  8 +--
 .../migration/EdgeDataMigrationImplTest.java    | 59 +++++++++++---------
 .../persistence/index/guice/IndexModule.java    |  4 +-
 .../index/migration/EsIndexMigrationPlugin.java |  8 +--
 19 files changed, 86 insertions(+), 98 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
index e290cfe..7ed95e2 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
@@ -100,9 +100,9 @@ public class CoreModule  extends AbstractModule {
         /**
          * Create our migrations for within our core plugin
          */
-        Multibinder<DataMigration<EntityIdScope>> dataMigrationMultibinder =
+        Multibinder<DataMigration> dataMigrationMultibinder =
                     Multibinder.newSetBinder( binder(),
-                        new TypeLiteral<DataMigration<EntityIdScope>>() {}, CoreMigration.class );
+                        new TypeLiteral<DataMigration>() {}, CoreMigration.class );
 
 
         dataMigrationMultibinder.addBinding().to( EntityTypeMappingMigration.class );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
index 58233e0..810f9fb 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
@@ -22,11 +22,9 @@ package org.apache.usergrid.corepersistence.migration;
 
 import java.util.Set;
 
-import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
 import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
 import org.apache.usergrid.persistence.core.migration.data.AbstractMigrationPlugin;
 import org.apache.usergrid.persistence.core.migration.data.DataMigration;
-import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
 import org.apache.usergrid.persistence.core.migration.data.PluginPhase;
 
 import com.google.inject.Inject;
@@ -37,17 +35,16 @@ import com.google.inject.Singleton;
  * Migration plugin for the collection module
  */
 @Singleton
-public class CoreMigrationPlugin extends AbstractMigrationPlugin<EntityIdScope> {
+public class CoreMigrationPlugin extends AbstractMigrationPlugin {
 
     public static final String PLUGIN_NAME = "core-data";
 
 
 
     @Inject
-    public CoreMigrationPlugin( @CoreMigration final Set<DataMigration<EntityIdScope>> entityDataMigrations,
-                                final MigrationDataProvider<EntityIdScope> entityIdScopeDataMigrationProvider,
+    public CoreMigrationPlugin( @CoreMigration final Set<DataMigration> entityDataMigrations,
                                 final MigrationInfoSerialization migrationInfoSerialization ) {
-        super( entityDataMigrations, entityIdScopeDataMigrationProvider, migrationInfoSerialization );
+        super( entityDataMigrations, migrationInfoSerialization );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
index 47ad30a..ef65ff2 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
@@ -41,7 +41,7 @@ import rx.schedulers.Schedulers;
 /**
  * Migration to ensure that our entity id is written into our map data
  */
-public class EntityTypeMappingMigration implements DataMigration<EntityIdScope> {
+public class EntityTypeMappingMigration implements DataMigration {
 
     private final ManagerCache managerCache;
     private final MigrationDataProvider<EntityIdScope> allEntitiesInSystemObservable;
@@ -56,7 +56,7 @@ public class EntityTypeMappingMigration implements DataMigration<EntityIdScope>
 
 
     @Override
-    public int migrate( final int currentVersion, final MigrationDataProvider<EntityIdScope> migrationDataProvider,
+    public int migrate( final int currentVersion,
                         final ProgressObserver observer ) {
 
         final AtomicLong atomicLong = new AtomicLong();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/MigrationModuleVersionPlugin.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/MigrationModuleVersionPlugin.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/MigrationModuleVersionPlugin.java
index 2ffe335..145e76f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/MigrationModuleVersionPlugin.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/MigrationModuleVersionPlugin.java
@@ -56,11 +56,6 @@ public class MigrationModuleVersionPlugin implements MigrationPlugin{
      */
     private static final int ENTITY_V2_MIGRATION = 3;
 
-    /**
-     * Appinfo to application_info migration.
-     */
-    private static final int APPINFO_MIGRATION = 4;
-
 
     /**
      * Get versions directly from impls so we know they're accurate

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
index 84215a1..7d22abe 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
@@ -101,7 +101,7 @@ public class EntityTypeMappingMigrationIT  {
 
         //run it
 
-        final int returnedVersion = migration.migrate(CoreDataVersions.INITIAL.getVersion(), migrationDataProvider, progressObserver );
+        final int returnedVersion = migration.migrate(CoreDataVersions.INITIAL.getVersion(), progressObserver );
 
 
         assertEquals(CoreDataVersions.ID_MAP_FIX.getVersion(), returnedVersion);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
index bd2728b..3a6fd14 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
@@ -96,8 +96,8 @@ public class SerializationModule extends AbstractModule {
 
         //migrations
         //we want to make sure our generics are retained, so we use a typeliteral
-        Multibinder<DataMigration<EntityIdScope>> dataMigrationMultibinder = Multibinder
-            .newSetBinder( binder(), new TypeLiteral<DataMigration<EntityIdScope>>() {}, CollectionMigration.class );
+        Multibinder<DataMigration> dataMigrationMultibinder = Multibinder
+            .newSetBinder( binder(), new TypeLiteral<DataMigration>() {}, CollectionMigration.class );
 
 
         dataMigrationMultibinder.addBinding().to( MvccEntityDataMigrationImpl.class );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java
index c757d28..4e92d3c 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java
@@ -28,7 +28,6 @@ import java.util.Set;
 
 import org.apache.usergrid.persistence.core.migration.data.AbstractMigrationPlugin;
 import org.apache.usergrid.persistence.core.migration.data.DataMigration;
-import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
 import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
 import org.apache.usergrid.persistence.core.migration.data.PluginPhase;
 
@@ -40,7 +39,7 @@ import com.google.inject.Singleton;
  * Migration plugin for the collection module
  */
 @Singleton
-public class CollectionMigrationPlugin extends AbstractMigrationPlugin<EntityIdScope> {
+public class CollectionMigrationPlugin extends AbstractMigrationPlugin {
 
     public static final String PLUGIN_NAME = "collections-entity-data";
 
@@ -48,10 +47,9 @@ public class CollectionMigrationPlugin extends AbstractMigrationPlugin<EntityIdS
 
     @Inject
     public CollectionMigrationPlugin( @CollectionMigration
-                                          final Set<DataMigration<EntityIdScope>> entityDataMigrations,
-                                      final MigrationDataProvider<EntityIdScope> entityIdScopeDataMigrationProvider,
+                                          final Set<DataMigration> entityDataMigrations,
                                       final MigrationInfoSerialization migrationInfoSerialization ) {
-        super( entityDataMigrations, entityIdScopeDataMigrationProvider, migrationInfoSerialization );
+        super( entityDataMigrations, migrationInfoSerialization );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
index 86fd701..5143c49 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
@@ -65,7 +65,7 @@ import rx.schedulers.Schedulers;
  * Data migration strategy for entities
  */
 @Singleton
-public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope> {
+public class MvccEntityDataMigrationImpl implements DataMigration{
 
 
     private static final Logger LOGGER = LoggerFactory.getLogger( MvccEntityDataMigrationImpl.class );
@@ -75,6 +75,7 @@ public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope>
     private final MvccEntitySerializationStrategyV3Impl mvccEntitySerializationStrategyV3;
     private final UniqueValueSerializationStrategy uniqueValueSerializationStrategy;
     private final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy;
+    private final MigrationDataProvider<EntityIdScope> migrationDataProvider;
 
 
     @Inject
@@ -82,12 +83,14 @@ public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope>
                                         final VersionedMigrationSet<MvccEntitySerializationStrategy> allVersions,
                                         final MvccEntitySerializationStrategyV3Impl mvccEntitySerializationStrategyV3,
                                         final UniqueValueSerializationStrategy uniqueValueSerializationStrategy,
-                                        final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy ) {
+                                        final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy,
+                                        final MigrationDataProvider<EntityIdScope> migrationDataProvider ) {
         this.keyspace = keyspace;
         this.allVersions = allVersions;
         this.mvccEntitySerializationStrategyV3 = mvccEntitySerializationStrategyV3;
         this.uniqueValueSerializationStrategy = uniqueValueSerializationStrategy;
         this.mvccLogEntrySerializationStrategy = mvccLogEntrySerializationStrategy;
+        this.migrationDataProvider = migrationDataProvider;
     }
 
 
@@ -105,8 +108,7 @@ public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope>
 
 
     @Override
-    public int migrate( final int currentVersion, final MigrationDataProvider<EntityIdScope> migrationDataProvider,
-                        final ProgressObserver observer ) {
+    public int migrate( final int currentVersion,  final ProgressObserver observer ) {
 
         final AtomicLong atomicLong = new AtomicLong();
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
index 986b740..f51b339 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
@@ -121,13 +121,6 @@ public abstract class AbstractMvccEntityDataMigrationV1ToV3ImplTest implements D
             Observable.just( new EntityIdScope( scope, entity1.getId() ), new EntityIdScope( scope, entity2.getId() ) );
 
 
-        final MigrationDataProvider<EntityIdScope> migrationProvider = new MigrationDataProvider<EntityIdScope>() {
-            @Override
-            public Observable<EntityIdScope> getData() {
-                return entityIdScope;
-            }
-        };
-
         final TestProgressObserver progressObserver = new TestProgressObserver();
 
         final CollectionDataVersions startVersion = getSourceVersion();
@@ -141,7 +134,7 @@ public abstract class AbstractMvccEntityDataMigrationV1ToV3ImplTest implements D
 
         //now migration
         final int newVersion = mvccEntityDataMigrationImpl
-            .migrate( startVersion.getVersion(), migrationProvider, progressObserver );
+            .migrate( startVersion.getVersion(), progressObserver );
 
 
         final CollectionDataVersions expectedVersion = expectedTargetVersion();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/AbstractMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/AbstractMigrationPlugin.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/AbstractMigrationPlugin.java
index 0cd26d4..9671bc5 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/AbstractMigrationPlugin.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/AbstractMigrationPlugin.java
@@ -34,23 +34,20 @@ import org.slf4j.LoggerFactory;
  * Standard implementation logic for plugins to extend
  * @param <T>
  */
-public abstract class AbstractMigrationPlugin<T> implements MigrationPlugin {
+public abstract class AbstractMigrationPlugin implements MigrationPlugin {
 
 
 
     private static final Logger LOG = LoggerFactory.getLogger( AbstractMigrationPlugin.class );
 
 
-    private final Set<DataMigration<T>> entityDataMigrations;
-    private final MigrationDataProvider<T> entityIdScopeDataMigrationProvider;
+    private final Set<DataMigration> entityDataMigrations;
     private final MigrationInfoSerialization migrationInfoSerialization;
 
 
-    protected AbstractMigrationPlugin( final Set<DataMigration<T>> entityDataMigrations,
-                                       final MigrationDataProvider<T> entityIdScopeDataMigrationProvider,
+    protected AbstractMigrationPlugin( final Set<DataMigration>entityDataMigrations,
                                        final MigrationInfoSerialization migrationInfoSerialization ) {
         this.entityDataMigrations = entityDataMigrations;
-        this.entityIdScopeDataMigrationProvider = entityIdScopeDataMigrationProvider;
         this.migrationInfoSerialization = migrationInfoSerialization;
     }
 
@@ -71,7 +68,7 @@ public abstract class AbstractMigrationPlugin<T> implements MigrationPlugin {
 
         int max = 0;
 
-        for(DataMigration<T> entityMigration: entityDataMigrations){
+        for(DataMigration entityMigration: entityDataMigrations){
             max = Math.max( max, entityMigration.getMaxVersion() );
         }
 
@@ -85,12 +82,12 @@ public abstract class AbstractMigrationPlugin<T> implements MigrationPlugin {
      * @return True if we ran a migration
      */
     private boolean runMigration( final ProgressObserver po ) {
-        DataMigration<T> migrationToExecute = null;
+        DataMigration migrationToExecute = null;
 
 
         final int version = migrationInfoSerialization.getVersion( getName() );
 
-        for ( DataMigration<T> entityMigration : entityDataMigrations ) {
+        for ( DataMigration entityMigration : entityDataMigrations ) {
             if ( entityMigration.supports( version ) ) {
                 if ( migrationToExecute != null ) {
                     throw new DataMigrationException(
@@ -113,7 +110,7 @@ public abstract class AbstractMigrationPlugin<T> implements MigrationPlugin {
 
 
         //run the migration
-        final int newSystemVersion = migrationToExecute.migrate( version, entityIdScopeDataMigrationProvider, po );
+        final int newSystemVersion = migrationToExecute.migrate( version, po );
 
         //write the version
         migrationInfoSerialization.setVersion( getName(), newSystemVersion );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
index ce250cc..a3ee675 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
@@ -27,32 +27,31 @@ package org.apache.usergrid.persistence.core.migration.data;
 /**
  * Data migration.  The internal version to migrate
  *
- * @param <T>
+ * @param
  */
-public interface DataMigration<T> {
+public interface DataMigration {
 
     /**
      * Perform the migration, returning an observable with a single emitted value
      * @param currentVersion the current version of the system
-     * @param migrationDataProvider
      * @param observer The observer to receive updates of the progress
      *
      * @return The version that the system is now running
      */
-    public int migrate(final int currentVersion, MigrationDataProvider<T> migrationDataProvider, ProgressObserver observer);
+    int migrate( final int currentVersion, ProgressObserver observer );
 
     /**
      * Check if this version supports migration from the current system version.  If this returns false,
      * migrate will not be invoked
      * @return
      */
-    public boolean supports(final int currentVersion);
+    boolean supports( final int currentVersion );
 
     /**
      * Get the max version this migration can migrate to
      * @return
      */
-    public int getMaxVersion();
+    int getMaxVersion();
 
 
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationDataProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationDataProvider.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationDataProvider.java
index e232d7b..1608742 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationDataProvider.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationDataProvider.java
@@ -38,6 +38,6 @@ public interface MigrationDataProvider<T> {
      * Get data that can be used in the migration
      * @return
      */
-    public Observable<T> getData();
+    Observable<T> getData();
 
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationPlugin.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationPlugin.java
index 4953f25..cb9297d 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationPlugin.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationPlugin.java
@@ -34,12 +34,12 @@ public interface MigrationPlugin {
      * Get the name of the plugin.  Must be unique
      * @return
      */
-    public String getName();
+    String getName();
 
     /**
      * Run any migrations that may need to be run in this plugin
      */
-    public void run(ProgressObserver observer);
+    void run( ProgressObserver observer );
 
 
     /**

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java
index 4b628d1..6280c7c 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java
@@ -128,8 +128,8 @@ public abstract class GraphModule extends AbstractModule {
 
 
         //wire up the edg migration
-        Multibinder<DataMigration<GraphNode>> dataMigrationMultibinder =
-                Multibinder.newSetBinder( binder(), new TypeLiteral<DataMigration<GraphNode>>() {}, GraphMigration.class );
+        Multibinder<DataMigration> dataMigrationMultibinder =
+                Multibinder.newSetBinder( binder(), new TypeLiteral<DataMigration>() {}, GraphMigration.class );
 
 
         dataMigrationMultibinder.addBinding().to( EdgeDataMigrationImpl.class );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImpl.java
index d6c42e3..15ff337 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImpl.java
@@ -49,7 +49,7 @@ import java.util.concurrent.atomic.AtomicLong;
  * The migration data provider assumes that is will visit every node in the graph
  * all edges from these source node will then be re-indexed.
  */
-public class EdgeDataMigrationImpl implements DataMigration<GraphNode> {
+public class EdgeDataMigrationImpl implements DataMigration {
 
     private static final Logger logger = LoggerFactory.getLogger(EdgeDataMigrationImpl.class);
 
@@ -58,24 +58,26 @@ public class EdgeDataMigrationImpl implements DataMigration<GraphNode> {
     private final EdgesObservable edgesFromSourceObservable;
     private final VersionedMigrationSet<EdgeMetadataSerialization> allVersions;
     private final EdgeMetadataSerializationV2Impl edgeMetadataSerializationV2;
+    private final MigrationDataProvider<GraphNode> migrationDataProvider;
 
     @Inject
-    public EdgeDataMigrationImpl( final Keyspace keyspace,
-                                  final GraphManagerFactory graphManagerFactory,
+    public EdgeDataMigrationImpl( final Keyspace keyspace, final GraphManagerFactory graphManagerFactory,
                                   final EdgesObservable edgesFromSourceObservable,
                                   final VersionedMigrationSet<EdgeMetadataSerialization> allVersions,
-                                  final EdgeMetadataSerializationV2Impl edgeMetadataSerializationV2 ) {
+                                  final EdgeMetadataSerializationV2Impl edgeMetadataSerializationV2,
+                                  final MigrationDataProvider<GraphNode> migrationDataProvider ) {
 
         this.keyspace = keyspace;
         this.graphManagerFactory = graphManagerFactory;
         this.edgesFromSourceObservable = edgesFromSourceObservable;
         this.allVersions = allVersions;
         this.edgeMetadataSerializationV2 = edgeMetadataSerializationV2;
+        this.migrationDataProvider = migrationDataProvider;
     }
 
 
     @Override
-    public int migrate( final int currentVersion, final MigrationDataProvider<GraphNode> migrationDataProvider,
+    public int migrate( final int currentVersion,
                         final ProgressObserver observer ) {
 
         final AtomicLong counter = new AtomicLong();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/GraphMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/GraphMigrationPlugin.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/GraphMigrationPlugin.java
index ed51c27..97edf3b 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/GraphMigrationPlugin.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/GraphMigrationPlugin.java
@@ -29,7 +29,6 @@ import java.util.Set;
 import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
 import org.apache.usergrid.persistence.core.migration.data.AbstractMigrationPlugin;
 import org.apache.usergrid.persistence.core.migration.data.DataMigration;
-import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
 import org.apache.usergrid.persistence.core.migration.data.PluginPhase;
 
 import com.google.inject.Inject;
@@ -41,7 +40,7 @@ import com.google.inject.Singleton;
  * Migration plugin for the collection module
  */
 @Singleton
-public class GraphMigrationPlugin extends AbstractMigrationPlugin<GraphNode> {
+public class GraphMigrationPlugin extends AbstractMigrationPlugin {
 
     public static final String PLUGIN_NAME = "graph-data";
 
@@ -49,10 +48,9 @@ public class GraphMigrationPlugin extends AbstractMigrationPlugin<GraphNode> {
 
     @Inject
     public GraphMigrationPlugin(@GraphMigration
-                                    final Set<DataMigration<GraphNode>> entityDataMigrations,
-                                      final MigrationDataProvider<GraphNode> entityIdScopeDataMigrationProvider,
+                                    final Set<DataMigration> entityDataMigrations,
                                       final MigrationInfoSerialization migrationInfoSerialization ) {
-        super( entityDataMigrations, entityIdScopeDataMigrationProvider, migrationInfoSerialization );
+        super( entityDataMigrations, migrationInfoSerialization );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImplTest.java b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImplTest.java
index 049c3d2..bc2afdc 100644
--- a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImplTest.java
+++ b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImplTest.java
@@ -28,8 +28,9 @@ import org.junit.runner.RunWith;
 
 import org.apache.usergrid.persistence.core.guice.DataMigrationResetRule;
 import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
-import org.apache.usergrid.persistence.core.migration.data.TestProgressObserver;
 import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
+import org.apache.usergrid.persistence.core.migration.data.TestProgressObserver;
+import org.apache.usergrid.persistence.core.migration.data.VersionedMigrationSet;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
 import org.apache.usergrid.persistence.core.test.ITRunner;
@@ -40,25 +41,28 @@ import org.apache.usergrid.persistence.graph.GraphManager;
 import org.apache.usergrid.persistence.graph.GraphManagerFactory;
 import org.apache.usergrid.persistence.graph.guice.TestGraphModule;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchEdgeType;
+import org.apache.usergrid.persistence.graph.serialization.EdgeMetadataSerialization;
+import org.apache.usergrid.persistence.graph.serialization.EdgesObservable;
+import org.apache.usergrid.persistence.graph.serialization.impl.EdgeMetadataSerializationV2Impl;
 import org.apache.usergrid.persistence.graph.serialization.impl.GraphDataVersions;
 import org.apache.usergrid.persistence.model.entity.Id;
 
 import com.google.inject.Inject;
+import com.netflix.astyanax.Keyspace;
 
 import net.jcip.annotations.NotThreadSafe;
 
 import rx.Observable;
 
 import static org.apache.usergrid.persistence.graph.test.util.EdgeTestUtils.createEdge;
-import static org.apache.usergrid.persistence.core.util.IdGenerator.createId;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 
 @NotThreadSafe
-@RunWith(ITRunner.class)
-@UseModules({ TestGraphModule.class })
+@RunWith( ITRunner.class )
+@UseModules( { TestGraphModule.class } )
 public class EdgeDataMigrationImplTest implements DataMigrationResetRule.DataMigrationManagerProvider {
 
 
@@ -68,16 +72,26 @@ public class EdgeDataMigrationImplTest implements DataMigrationResetRule.DataMig
     @Inject
     public GraphManagerFactory graphManagerFactory;
 
+
+    @Inject
+    public Keyspace keyspace;
+
     @Inject
-    public EdgeDataMigrationImpl edgeDataMigrationImpl;
+    public EdgesObservable edgesFromSourceObservable;
+
+    @Inject
+    public VersionedMigrationSet<EdgeMetadataSerialization> allVersions;
+
+    @Inject
+    public EdgeMetadataSerializationV2Impl edgeMetadataSerializationV2;
+
 
     /**
      * Rule to do the resets we need
      */
     @Rule
-    public DataMigrationResetRule migrationTestRule = new DataMigrationResetRule(this, GraphMigrationPlugin.PLUGIN_NAME,  GraphDataVersions.INITIAL.getVersion());
-
-
+    public DataMigrationResetRule migrationTestRule =
+        new DataMigrationResetRule( this, GraphMigrationPlugin.PLUGIN_NAME, GraphDataVersions.INITIAL.getVersion() );
 
 
     @Test
@@ -90,7 +104,7 @@ public class EdgeDataMigrationImplTest implements DataMigrationResetRule.DataMig
         final ApplicationScope applicationScope = new ApplicationScopeImpl( IdGenerator.createId( "application" ) );
 
 
-        GraphManager gm = graphManagerFactory.createEdgeManager(applicationScope );
+        GraphManager gm = graphManagerFactory.createEdgeManager( applicationScope );
 
 
         final Id sourceId1 = IdGenerator.createId( "source1" );
@@ -103,17 +117,15 @@ public class EdgeDataMigrationImplTest implements DataMigrationResetRule.DataMig
         final Id target2 = IdGenerator.createId( "target2" );
 
 
-        Edge s1t1 = createEdge(sourceId1, "test", target1 );
+        Edge s1t1 = createEdge( sourceId1, "test", target1 );
 
         Edge s1t2 = createEdge( sourceId1, "baz", target2 );
 
-        Edge s2t1 = createEdge(sourceId2, "foo", target1);
+        Edge s2t1 = createEdge( sourceId2, "foo", target1 );
 
         Edge s2t2 = createEdge( sourceId2, "bar", target2 );
 
 
-
-
         gm.writeEdge( s1t1 ).toBlocking().last();
         gm.writeEdge( s1t2 ).toBlocking().last();
         gm.writeEdge( s2t1 ).toBlocking().last();
@@ -121,24 +133,24 @@ public class EdgeDataMigrationImplTest implements DataMigrationResetRule.DataMig
 
 
         //walk from s1 and s2
-        final Observable<GraphNode> graphNodes = Observable.just( new GraphNode( applicationScope, sourceId1), new GraphNode(applicationScope, sourceId2 ) );
+        final Observable<GraphNode> graphNodes = Observable
+            .just( new GraphNode( applicationScope, sourceId1 ), new GraphNode( applicationScope, sourceId2 ) );
 
-        final MigrationDataProvider<GraphNode> testMigrationProvider = new MigrationDataProvider<GraphNode>() {
-            @Override
-            public Observable<GraphNode> getData() {
-                return graphNodes;
-            }
-        };
+        final MigrationDataProvider<GraphNode> testMigrationProvider = () -> graphNodes;
 
 
         final TestProgressObserver progressObserver = new TestProgressObserver();
 
 
-
         //read everything in previous version format and put it into our types.
 
 
-        final int returned = edgeDataMigrationImpl.migrate( GraphDataVersions.INITIAL.getVersion() , testMigrationProvider, progressObserver );
+        EdgeDataMigrationImpl edgeDataMigrationImpl =
+            new EdgeDataMigrationImpl( keyspace, graphManagerFactory, edgesFromSourceObservable, allVersions,
+                edgeMetadataSerializationV2, testMigrationProvider );
+
+
+        final int returned = edgeDataMigrationImpl.migrate( GraphDataVersions.INITIAL.getVersion(), progressObserver );
         //perform the migration
 
         assertEquals( "Correct version returned", returned, GraphDataVersions.META_SHARDING.getVersion() );
@@ -164,9 +176,6 @@ public class EdgeDataMigrationImplTest implements DataMigrationResetRule.DataMig
 
         assertTrue( "Edge type present", source2Edges.contains( "foo" ) );
         assertTrue( "Edge type present", source2Edges.contains( "bar" ) );
-
-
-
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
index d03bbf8..7279174 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
@@ -56,8 +56,8 @@ public abstract class IndexModule extends AbstractModule {
 
 
         //wire up the edg migration. A no-op ATM, but retained for future development
-        Multibinder<DataMigration<ApplicationScope>> dataMigrationMultibinder =
-                Multibinder.newSetBinder( binder(), new TypeLiteral<DataMigration<ApplicationScope>>() {}, IndexMigration.class );
+        Multibinder<DataMigration> dataMigrationMultibinder =
+                Multibinder.newSetBinder( binder(), new TypeLiteral<DataMigration>() {}, IndexMigration.class );
 
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMigrationPlugin.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMigrationPlugin.java
index a28c701..c8e353d 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMigrationPlugin.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMigrationPlugin.java
@@ -18,20 +18,18 @@ package org.apache.usergrid.persistence.index.migration;
 
 import com.google.inject.Inject;
 import org.apache.usergrid.persistence.core.migration.data.*;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 
 import java.util.Set;
 
 /**
  * Classy class class.
  */
-public class EsIndexMigrationPlugin  extends AbstractMigrationPlugin<ApplicationScope>{
+public class EsIndexMigrationPlugin  extends AbstractMigrationPlugin {
 
     @Inject
-    public EsIndexMigrationPlugin(@IndexMigration final Set<DataMigration<ApplicationScope>> entityDataMigrations,
-                                  final MigrationDataProvider<ApplicationScope> entityIdScopeDataMigrationProvider,
+    public EsIndexMigrationPlugin(@IndexMigration final Set<DataMigration> entityDataMigrations,
                                   final MigrationInfoSerialization migrationInfoSerialization ){
-        super(entityDataMigrations,entityIdScopeDataMigrationProvider,migrationInfoSerialization);
+        super(entityDataMigrations,migrationInfoSerialization);
     }
 
     @Override


[40/44] usergrid git commit: Fixed bugs in migration of apps

Posted by md...@apache.org.
Fixed bugs in migration of apps


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

Branch: refs/heads/USERGRID-933
Commit: 521fc03e556af47d110f0a7d98f2af215cb3fda1
Parents: 8281430
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Sep 24 11:07:24 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Sep 24 11:07:24 2015 -0600

----------------------------------------------------------------------
 .../management/AppInfoMigrationPlugin.java      | 47 +++++++++++---------
 1 file changed, 25 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/521fc03e/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java b/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
index 54779b9..d0f39e9 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
@@ -164,10 +164,18 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
                     throw new RuntimeException( e );
                 }
             }
-        } ).doOnCompleted( () -> {
-            migrationInfoSerialization.setVersion( getName(), getMaxVersion() );
-            observer.complete();
-        } ).toBlocking().lastOrDefault( null );
+        } )
+            //we want a doOnError to catch something going wrong, otherwise we'll mark as complete
+            .doOnError( error -> {
+                logger.error( "Unable to migrate applications, an error occurred.  Please try again", error );
+                observer.failed( getMaxVersion(), "Unable to migrate applications", error );
+            } )
+
+                //if we complete successfully, set the version and notify the observer
+            .doOnCompleted( () -> {
+                migrationInfoSerialization.setVersion( getName(), getMaxVersion() );
+                observer.complete();
+            } ).subscribe();
     }
 
 
@@ -186,28 +194,23 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
             UUID applicationId = getUuid( oldAppInfoMap, "applicationUuid" );
             applicationId = applicationId == null ? getUuid( oldAppInfoMap, "appUuid" ) : applicationId;
             //get app info from graph to see if it has been migrated already
-            org.apache.usergrid.persistence.Entity appInfo = getApplicationInfo( applicationId );
-            if ( appInfo == null ) {
 
-                observer.update( getMaxVersion(), "Created application_info for " + appName );
-                // create org->app connections, but not for apps in dummy "usergrid" internal organization
-                if ( !orgName.equals( "usergrid" ) ) { //avoid management org
 
-                    EntityRef orgRef = managementEm.getAlias( Group.ENTITY_TYPE, orgName );
-                    // create and connect new APPLICATION_INFO oldAppInfo to Organization
-                    managementService.createApplication( orgRef.getUuid(), name, applicationId, null );
-                }
-            }
-            else {
-                //already migrated don't do anything
-                observer.update( getMaxVersion(),
-                    "Received existing application_info for " + appName + " don't do anything" );
-            }
+
+            // create org->app connections, but not for apps in dummy "usergrid" internal organization
+            //avoid management org
+
+            EntityRef orgRef = managementEm.getAlias( Group.ENTITY_TYPE, orgName );
+            // create and connect new APPLICATION_INFO oldAppInfo to Organization
+            managementService.createApplication( orgRef.getUuid(), name, applicationId, null );
+
+            observer.update( getMaxVersion(), "Created application_info for " + appName );
+        }
+        //swallow
+        catch ( ApplicationAlreadyExistsException appExists ) {
+            logger.info( "Application {} already migrated.  Ignoring.", name );
         }
         catch ( Exception e ) {
-            String msg = "Exception writing application_info for " + name;
-            logger.error( msg, e );
-            observer.failed( getMaxVersion(), msg );
             throw new RuntimeException( e );
         }
     }


[29/44] usergrid git commit: change mappings file

Posted by md...@apache.org.
change mappings file


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

Branch: refs/heads/USERGRID-933
Commit: fad32aa271820a83d34d7fc1be162a9751ef6808
Parents: 65d2608
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Sep 17 11:23:49 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Sep 17 11:23:49 2015 -0600

----------------------------------------------------------------------
 .../index/migration/EsIndexMappingMigrationPlugin.java          | 2 +-
 .../apache/usergrid/persistence/index/usergrid-mappings.json    | 5 -----
 2 files changed, 1 insertion(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/fad32aa2/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java
index 6d46beb..5c2e9c1 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java
@@ -136,7 +136,7 @@ public class EsIndexMappingMigrationPlugin implements MigrationPlugin {
 
     @Override
     public int getMaxVersion() {
-        return 1;
+        return 2;//1->new storage format,2->remove uuid
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/usergrid/blob/fad32aa2/stack/corepersistence/queryindex/src/main/resources/org/apache/usergrid/persistence/index/usergrid-mappings.json
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/resources/org/apache/usergrid/persistence/index/usergrid-mappings.json b/stack/corepersistence/queryindex/src/main/resources/org/apache/usergrid/persistence/index/usergrid-mappings.json
index 1b6a7f3..3d2517c 100644
--- a/stack/corepersistence/queryindex/src/main/resources/org/apache/usergrid/persistence/index/usergrid-mappings.json
+++ b/stack/corepersistence/queryindex/src/main/resources/org/apache/usergrid/persistence/index/usergrid-mappings.json
@@ -90,11 +90,6 @@
                                 "ignore_above": 10922
                             }
                         }
-                    },
-                    "uuid": {
-                        "type": "string",
-                        "index": "not_analyzed",
-                        "doc_values": true
                     }
                 }
             }