You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2014/10/30 04:39:27 UTC

[01/45] git commit: add queuescope factory

Repository: incubator-usergrid
Updated Branches:
  refs/heads/key-row-sharding 00ae4031b -> 5c56fa016


add queuescope factory


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

Branch: refs/heads/key-row-sharding
Commit: fc3c42c13268c5f4066174f8840669c198f39c41
Parents: a3e3b1f
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Oct 23 14:30:15 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Oct 23 14:40:25 2014 -0600

----------------------------------------------------------------------
 .../usergrid/persistence/queue/QueueFig.java    |  3 ++
 .../persistence/queue/QueueScopeFactory.java    | 34 ++++++++++++++
 .../persistence/queue/guice/QueueModule.java    | 10 ++++-
 .../queue/impl/QueueScopeFactoryImpl.java       | 47 ++++++++++++++++++++
 .../persistence/queue/QueueManagerTest.java     | 27 ++++++++---
 .../notifications/ApplicationQueueManager.java  |  1 -
 .../notifications/NotificationsService.java     |  5 ++-
 .../services/notifications/QueueListener.java   |  5 ++-
 8 files changed, 122 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fc3c42c1/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java
index fd71f9e..7fd2258 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueFig.java
@@ -12,5 +12,8 @@ public interface QueueFig extends GuicyFig {
     @Default("us-east-1")
     public String getRegion();
 
+    @Key( "queue.prefix" )
+    @Default("usergrid")
+    public String getPrefix();
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fc3c42c1/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueScopeFactory.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueScopeFactory.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueScopeFactory.java
new file mode 100644
index 0000000..3a508a9
--- /dev/null
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueScopeFactory.java
@@ -0,0 +1,34 @@
+/*
+ *
+ *  * 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.queue;
+
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.queue.impl.QueueScopeImpl;
+
+import java.util.UUID;
+
+/**
+ * Created by ApigeeCorporation on 10/23/14.
+ */
+public interface QueueScopeFactory {
+
+    public QueueScope getScope(  UUID id, String queueName);
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fc3c42c1/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueModule.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueModule.java
index e8fc7c8..4e487e1 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueModule.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueModule.java
@@ -22,6 +22,8 @@ import com.google.inject.assistedinject.FactoryModuleBuilder;
 import org.apache.usergrid.persistence.queue.QueueFig;
 import org.apache.usergrid.persistence.queue.QueueManager;
 import org.apache.usergrid.persistence.queue.QueueManagerFactory;
+import org.apache.usergrid.persistence.queue.QueueScopeFactory;
+import org.apache.usergrid.persistence.queue.impl.QueueScopeFactoryImpl;
 import org.apache.usergrid.persistence.queue.impl.SQSQueueManagerImpl;
 import org.safehaus.guicyfig.GuicyFigModule;
 
@@ -37,10 +39,14 @@ public class QueueModule extends AbstractModule {
     @Override
     protected void configure() {
 
+
         install( new GuicyFigModule( QueueFig.class) );
+
         // create a guice factory for getting our collection manager
-        install( new FactoryModuleBuilder().implement( QueueManager.class, SQSQueueManagerImpl.class )
-                                           .build( QueueManagerFactory.class ) );
+        install(new FactoryModuleBuilder()
+                .implement(QueueManager.class, SQSQueueManagerImpl.class)
+                .build(QueueManagerFactory.class));
+        bind( QueueScopeFactory.class ).to( QueueScopeFactoryImpl.class );
 
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fc3c42c1/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeFactoryImpl.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeFactoryImpl.java
new file mode 100644
index 0000000..92ed075
--- /dev/null
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeFactoryImpl.java
@@ -0,0 +1,47 @@
+/*
+ *
+ *  * 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.queue.impl;
+
+import com.google.inject.Inject;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.queue.QueueFig;
+import org.apache.usergrid.persistence.queue.QueueScope;
+import org.apache.usergrid.persistence.queue.QueueScopeFactory;
+
+import java.util.UUID;
+
+/**
+ * Classy class class.
+ */
+public class QueueScopeFactoryImpl implements QueueScopeFactory {
+
+    private QueueFig fig;
+
+    @Inject
+    public QueueScopeFactoryImpl(QueueFig fig){
+        this.fig = fig;
+    }
+
+    @Override
+    public QueueScope getScope(UUID applicationId, String queueName) {
+        return new QueueScopeImpl(new SimpleId(applicationId, fig.getPrefix()), queueName);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fc3c42c1/stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/QueueManagerTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/QueueManagerTest.java b/stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/QueueManagerTest.java
index 26a350c..1d3c049 100644
--- a/stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/QueueManagerTest.java
+++ b/stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/QueueManagerTest.java
@@ -22,6 +22,7 @@ package org.apache.usergrid.persistence.queue;
 import com.amazonaws.services.glacier.TreeHashGenerator;
 import org.apache.usergrid.persistence.collection.util.InvalidEntityGenerator;
 import org.apache.usergrid.persistence.queue.guice.TestQueueModule;
+import org.apache.usergrid.persistence.queue.impl.QueueScopeFactoryImpl;
 import org.apache.usergrid.persistence.queue.impl.QueueScopeImpl;
 import org.jukito.UseModules;
 import org.junit.Before;
@@ -33,12 +34,13 @@ import org.apache.usergrid.persistence.core.cassandra.ITRunner;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 
 import com.google.inject.Inject;
+import org.safehaus.guicyfig.Bypass;
+import org.safehaus.guicyfig.OptionState;
+import org.safehaus.guicyfig.Overrides;
 
+import java.beans.PropertyChangeListener;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import static org.junit.Assert.*;
 
@@ -46,10 +48,14 @@ import static org.junit.Assert.*;
 @UseModules( { TestQueueModule.class } )
 public class QueueManagerTest {
 
-
+    @Inject
+    protected QueueFig queueFig;
     @Inject
     protected QueueManagerFactory qmf;
 
+    @Inject
+    protected QueueScopeFactory queueScopeFactory;
+
     protected QueueScope scope;
     private QueueManager qm;
 
@@ -58,6 +64,16 @@ public class QueueManagerTest {
     public void mockApp() {
         this.scope = new QueueScopeImpl( new SimpleId( "application" ), "testQueue" );
         qm = qmf.getQueueManager(scope);
+        queueScopeFactory = new QueueScopeFactoryImpl(queueFig);
+    }
+
+    @Test
+    public void scopeFactory(){
+        UUID uuid = UUID.randomUUID();
+        String key = "test";
+        QueueScope scope =queueScopeFactory.getScope(uuid,key);
+        assertEquals(key,scope.getName());
+        assertEquals(scope.getApplication().getUuid(),uuid);
     }
 
     @Ignore("need aws creds")
@@ -97,4 +113,5 @@ public class QueueManagerTest {
 
     }
 
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fc3c42c1/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
index e819356..a83513f 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
@@ -54,7 +54,6 @@ public class ApplicationQueueManager  {
 
     private static ExecutorService INACTIVE_DEVICE_CHECK_POOL = Executors.newFixedThreadPool(5);
     public static final String NOTIFIER_ID_POSTFIX = ".notifier.id";
-    public static final String QUEUE_PREFIX = "usergrid";
 
     private final EntityManager em;
     private final QueueManager qm;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fc3c42c1/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
index 750b305..69f66e5 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
@@ -33,6 +33,7 @@ import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.queue.QueueManager;
 import org.apache.usergrid.persistence.queue.QueueManagerFactory;
 import org.apache.usergrid.persistence.queue.QueueScope;
+import org.apache.usergrid.persistence.queue.QueueScopeFactory;
 import org.apache.usergrid.persistence.queue.impl.QueueScopeImpl;
 import org.apache.usergrid.services.*;
 import org.slf4j.Logger;
@@ -99,13 +100,15 @@ public class NotificationsService extends AbstractCollectionService {
         super.init(info);
         smf = getApplicationContext().getBean(ServiceManagerFactory.class);
         emf = getApplicationContext().getBean(EntityManagerFactory.class);
+
         Properties props = (Properties)getApplicationContext().getBean("properties");
         metricsService = getApplicationContext().getBean(MetricsFactory.class);
         postMeter = metricsService.getMeter(NotificationsService.class, "requests");
         postTimer = metricsService.getTimer(this.getClass(), "execution_rest");
         JobScheduler jobScheduler = new JobScheduler(sm,em);
         String name = ApplicationQueueManager.getQueueNames(props);
-        QueueScope queueScope = new QueueScopeImpl(new SimpleId(smf.getManagementAppId(),ApplicationQueueManager.QUEUE_PREFIX),name);
+        QueueScopeFactory queueScopeFactory = CpSetup.getInjector().getInstance(QueueScopeFactory.class);
+        QueueScope queueScope = queueScopeFactory.getScope(smf.getManagementAppId(), name);
         queueManagerFactory = CpSetup.getInjector().getInstance(QueueManagerFactory.class);
         QueueManager queueManager = TEST_QUEUE_MANAGER !=null ? TEST_QUEUE_MANAGER : queueManagerFactory.getQueueManager(queueScope);
         notificationQueueManager = new ApplicationQueueManager(jobScheduler,em,queueManager,metricsService,props);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fc3c42c1/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
index 3ef9198..7ce315b 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
@@ -43,6 +43,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 public class QueueListener  {
     public  final int MESSAGE_TRANSACTION_TIMEOUT =  25 * 1000;
     private final QueueManagerFactory queueManagerFactory;
+    private final QueueScopeFactory queueScopeFactory;
 
     public   long DEFAULT_SLEEP = 5000;
 
@@ -78,6 +79,8 @@ public class QueueListener  {
         this.emf = emf;
         this.metricsService = metricsService;
         this.properties = props;
+        this.queueScopeFactory = CpSetup.getInjector().getInstance(QueueScopeFactory.class);
+
     }
 
     @PostConstruct
@@ -137,7 +140,7 @@ public class QueueListener  {
         com.codahale.metrics.Timer timer = metricsService.getTimer(QueueListener.class, "dequeue");
         svcMgr = smf.getServiceManager(smf.getManagementAppId());
         LOG.info("getting from queue {} ", queueName);
-        QueueScope queueScope = new QueueScopeImpl(new SimpleId(smf.getManagementAppId(),ApplicationQueueManager.QUEUE_PREFIX),queueName);
+        QueueScope queueScope = queueScopeFactory.getScope(smf.getManagementAppId(), queueName);
         QueueManager queueManager = TEST_QUEUE_MANAGER != null ? TEST_QUEUE_MANAGER : queueManagerFactory.getQueueManager(queueScope);
         // run until there are no more active jobs
         while ( true ) {


[16/45] git commit: fix rat issue; remove debug

Posted by to...@apache.org.
fix rat issue; remove debug


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

Branch: refs/heads/key-row-sharding
Commit: 960ce6baecf747797c461c1a1a52a980772bfb45
Parents: 34a6d12
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Oct 27 17:37:41 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Oct 27 17:37:41 2014 -0600

----------------------------------------------------------------------
 .../scenarios/NotificationScenarios.scala        |  2 +-
 stack/loadtests/src/test/resources/logback.xml   | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/960ce6ba/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
index ab4d813..2ac8995 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
@@ -60,7 +60,7 @@ object NotificationScenarios {
 
   val sendNotificationToUser= exec(http("Send Notification to All Devices")
     .post("/users/${userId}/notifications")
-    .body(StringBody("{\"debug\":\"true\",\"payloads\":{\"" + notifier + "\":\"testmessage\"}}"))
+    .body(StringBody("{\"payloads\":{\"" + notifier + "\":\"testmessage\"}}"))
     .check(status.is(200))
   )
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/960ce6ba/stack/loadtests/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/test/resources/logback.xml b/stack/loadtests/src/test/resources/logback.xml
index f112f98..1d512d6 100644
--- a/stack/loadtests/src/test/resources/logback.xml
+++ b/stack/loadtests/src/test/resources/logback.xml
@@ -1,6 +1,23 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration>
-
+<!--
+/*
+ * 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.
+ */
+-->
 	<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
 		<encoder>
 			<pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>


[31/45] git commit: Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into pushy_4-0

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


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

Branch: refs/heads/key-row-sharding
Commit: 78e34b2bfba8e699a4525426f0888b82f5f8b597
Parents: 25e36e6 a100c07
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Oct 29 10:29:06 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Oct 29 10:29:06 2014 -0600

----------------------------------------------------------------------
 .../main/resources/usergrid-default.properties  |   3 +
 .../corepersistence/CpEntityManager.java        |  73 +-
 .../corepersistence/CpEntityManagerFactory.java |  53 +-
 .../corepersistence/CpManagerCache.java         | 117 ++-
 .../corepersistence/CpRelationManager.java      | 944 +++++++++++--------
 .../persistence/index/query/EntityResults.java  |   6 +-
 stack/loadtests/src/main/scripts/gatling-mvn.sh |  28 +
 7 files changed, 767 insertions(+), 457 deletions(-)
----------------------------------------------------------------------



[45/45] git commit: Added migration to system resource and emf

Posted by to...@apache.org.
Added migration to system resource and emf


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

Branch: refs/heads/key-row-sharding
Commit: 5c56fa016a231fb3884c7fcfa93371c5dfa47d1b
Parents: f85fed1
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Oct 29 21:39:12 2014 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Oct 29 21:39:12 2014 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityManagerFactory.java | 22 +++++
 .../usergrid/corepersistence/GuiceModule.java   |  8 ++
 .../HybridEntityManagerFactory.java             | 19 ++++
 .../migration/GraphShardVersionMigration.java   | 17 +++-
 .../corepersistence/migration/Versions.java     | 35 +++++++-
 .../persistence/EntityManagerFactory.java       | 18 ++++
 .../cassandra/EntityManagerFactoryImpl.java     | 19 ++++
 .../data/DataMigrationManagerImpl.java          |  2 +
 .../apache/usergrid/rest/SystemResource.java    | 94 +++++++++++++++-----
 9 files changed, 212 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5c56fa01/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 6e6b461..86e7c31 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
@@ -52,6 +52,7 @@ import org.apache.usergrid.persistence.cassandra.Setup;
 import org.apache.usergrid.persistence.collection.CollectionScope;
 import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
 import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
+import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
 import org.apache.usergrid.persistence.entities.Application;
@@ -122,6 +123,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
 
     private CpManagerCache managerCache;
+    private DataMigrationManager dataMigrationManager;
 
     CassandraService cass;
     CounterUtils counterUtils;
@@ -183,6 +185,8 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
             mmf = injector.getInstance( MapManagerFactory.class );
 
             managerCache = new CpManagerCache( ecmf, eif, gmf, mmf );
+
+            dataMigrationManager = injector.getInstance( DataMigrationManager.class );
         }
         return managerCache;
     }
@@ -707,6 +711,24 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
 
     @Override
+    public void migrateData() throws Exception {
+         dataMigrationManager.migrate();
+    }
+
+
+    @Override
+    public String getMigrateDataStatus() {
+        return dataMigrationManager.getLastStatus();
+    }
+
+
+    @Override
+    public int getMigrateDataVersion() {
+        return dataMigrationManager.getCurrentVersion();
+    }
+
+
+    @Override
     public void flushEntityManagerCaches() {
         Map<UUID, EntityManager>  entityManagersMap = entityManagers.asMap();
         for ( UUID appUuid : entityManagersMap.keySet() ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5c56fa01/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
index 2221f80..fb4800c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
@@ -18,8 +18,12 @@ package org.apache.usergrid.corepersistence;
 
 
 import com.google.inject.AbstractModule;
+import com.google.inject.multibindings.Multibinder;
+
+import org.apache.usergrid.corepersistence.migration.GraphShardVersionMigration;
 import org.apache.usergrid.persistence.collection.guice.CollectionModule;
 import org.apache.usergrid.persistence.core.guice.CommonModule;
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
 import org.apache.usergrid.persistence.graph.guice.GraphModule;
 import org.apache.usergrid.persistence.index.guice.IndexModule;
 import org.apache.usergrid.persistence.map.guice.MapModule;
@@ -47,6 +51,10 @@ public class GuiceModule  extends AbstractModule {
         bind(CpEntityDeleteListener.class).asEagerSingleton();
         bind(CpEntityIndexDeleteListener.class).asEagerSingleton();
 
+        Multibinder<DataMigration> dataMigrationMultibinder = Multibinder.newSetBinder( binder(), DataMigration.class );
+        dataMigrationMultibinder.addBinding().to( GraphShardVersionMigration.class );
+
+
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5c56fa01/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
index 54a5dee..ebb0ee6 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
@@ -159,6 +159,25 @@ public class HybridEntityManagerFactory implements EntityManagerFactory, Applica
         factory.rebuildApplicationIndexes(appId, po);
     }
 
+
+    @Override
+    public void migrateData() throws Exception {
+        factory.migrateData();
+    }
+
+
+    @Override
+    public String getMigrateDataStatus() {
+        return factory.getMigrateDataStatus();
+    }
+
+
+    @Override
+    public int getMigrateDataVersion() {
+        return factory.getMigrateDataVersion();
+    }
+
+
     @Override
     public void rebuildCollectionIndex(UUID appId, String collection, ProgressObserver po) {
         factory.rebuildCollectionIndex(appId, collection, po);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5c56fa01/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java
index e714b5e..92982ba 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java
@@ -22,7 +22,22 @@
 package org.apache.usergrid.corepersistence.migration;
 
 
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+
+
 /**
  * Migration for migrating graph edges to the new Shards
  */
-public class GraphShardVersionMigration {}
+public class GraphShardVersionMigration implements DataMigration{
+
+    @Override
+    public void migrate( final ProgressObserver observer ) throws Throwable {
+
+    }
+
+
+    @Override
+    public int getVersion() {
+        return Versions.VERSION_1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5c56fa01/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
index 56bd65e..e9ee517 100644
--- 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
@@ -1,4 +1,37 @@
+/*
+ *
+ *  * 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;
 
 
-public class Versions {}
+import org.apache.usergrid.persistence.graph.serialization.impl.EdgeMetadataSerializationProxyImpl;
+
+
+/**
+ * Simple class to hold the constants of all versions
+ */
+public class Versions {
+
+    /**
+     * Version 1
+     */
+    public static final int VERSION_1 = EdgeMetadataSerializationProxyImpl.MIGRATION_VERSION;
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5c56fa01/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 e57aa69..e7c0874 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
@@ -123,6 +123,24 @@ public interface EntityManagerFactory {
 
     public void rebuildApplicationIndexes( UUID appId, ProgressObserver po ) throws Exception;
 
+    /**
+     * Perform any data migrations necessary in the system
+     * @throws Exception
+     */
+    public void migrateData() throws Exception;
+
+    /**
+     * Return the migration status message
+     * @return
+     */
+    public String getMigrateDataStatus();
+
+    /**
+     * Return the current migration version of the system
+     * @return
+     */
+    public int getMigrateDataVersion();
+
     public void setApplicationContext(ApplicationContext ac);
 
     /** For testing purposes */

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5c56fa01/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
index 399bccd..f09c1eb 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
@@ -434,6 +434,25 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
         throw new UnsupportedOperationException("Not supported."); 
     }
 
+
+    @Override
+    public void migrateData() throws Exception {
+
+    }
+
+
+    @Override
+    public String getMigrateDataStatus() {
+        return null;
+    }
+
+
+    @Override
+    public int getMigrateDataVersion() {
+        return 0;
+    }
+
+
     @Override
     public void rebuildCollectionIndex(UUID appId, String collection, ProgressObserver po) {
         throw new UnsupportedOperationException("Not supported."); 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5c56fa01/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
index e739648..cf0d15d 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
@@ -151,6 +151,8 @@ public class DataMigrationManagerImpl implements DataMigrationManager {
             //set the version
             migrationInfoSerialization.setVersion( migrationVersion );
 
+            versionCache.invalidateAll();
+
             //update the observer for progress so other nodes can see it
             observer.update( migrationVersion, "Completed successfully" );
         }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5c56fa01/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
index d068846..bdf647b 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
@@ -38,12 +38,14 @@ import org.springframework.stereotype.Component;
 
 import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.EntityManagerFactory;
+import org.apache.usergrid.persistence.EntityManagerFactory.ProgressObserver;
 import org.apache.usergrid.persistence.EntityRef;
 import org.apache.usergrid.persistence.index.utils.UUIDUtils;
 import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
 
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.sun.jersey.api.json.JSONWithPadding;
-import org.apache.usergrid.persistence.EntityManagerFactory.ProgressObserver;
 
 
 @Path( "/system" )
@@ -67,7 +69,7 @@ public class SystemResource extends AbstractContextResource {
     @GET
     @Path( "database/setup" )
     public JSONWithPadding getSetup( @Context UriInfo ui,
-                             @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+                                     @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
 
         ApiResponse response = createApiResponse();
@@ -91,7 +93,7 @@ public class SystemResource extends AbstractContextResource {
     @GET
     @Path( "superuser/setup" )
     public JSONWithPadding getSetupSuperuser( @Context UriInfo ui,
-                             @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+                                              @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
 
         ApiResponse response = createApiResponse();
@@ -114,9 +116,67 @@ public class SystemResource extends AbstractContextResource {
 
     @RequireSystemAccess
     @PUT
+    @Path( "migrate/run" )
+    public JSONWithPadding migrateData( @Context UriInfo ui,
+                                        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+            throws Exception {
+
+        ApiResponse response = createApiResponse();
+        response.setAction( "Migrate Data" );
+
+
+        final Thread migrate = new Thread() {
+
+            @Override
+            public void run() {
+                logger.info( "Rebuilding all indexes" );
+
+                try {
+                    emf.migrateData();
+                }
+                catch ( Exception e ) {
+                    logger.error( "Unable to rebuild indexes", e );
+                }
+            }
+        };
+
+        migrate.setName( "Index migrate data formats" );
+        migrate.setDaemon( true );
+        migrate.start();
+
+
+        response.setSuccess();
+
+        return new JSONWithPadding( response, callback );
+    }
+
+
+    @RequireSystemAccess
+    @GET
+    @Path( "migrate/status" )
+    public JSONWithPadding migrateStatus( @Context UriInfo ui,
+                                          @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+            throws Exception {
+
+        ApiResponse response = createApiResponse();
+        response.setAction( "Migrate Schema indexes" );
+
+        ObjectNode node = JsonNodeFactory.instance.objectNode();
+        node.put( "currentVersion", emf.getMigrateDataVersion() );
+        node.put( "lastMessage", emf.getMigrateDataStatus() );
+        response.setProperty( "status", node );
+
+        response.setSuccess();
+
+        return new JSONWithPadding( response, callback );
+    }
+
+
+    @RequireSystemAccess
+    @PUT
     @Path( "index/rebuild" )
     public JSONWithPadding rebuildIndexes( @Context UriInfo ui,
-                             @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+                                           @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
 
         ApiResponse response = createApiResponse();
@@ -168,11 +228,9 @@ public class SystemResource extends AbstractContextResource {
     @RequireSystemAccess
     @PUT
     @Path( "index/rebuild/" + RootResource.APPLICATION_ID_PATH )
-    public JSONWithPadding rebuildIndexes( 
-                @Context UriInfo ui, 
-                @PathParam( "applicationId" ) String applicationIdStr,
-                @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
-                @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay)
+    public JSONWithPadding rebuildIndexes( @Context UriInfo ui, @PathParam( "applicationId" ) String applicationIdStr,
+                                           @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
+                                           @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay )
 
             throws Exception {
 
@@ -181,8 +239,6 @@ public class SystemResource extends AbstractContextResource {
         response.setAction( "rebuild indexes" );
 
 
-
-
         final EntityManager em = emf.getEntityManager( appId );
 
         final Set<String> collectionNames = em.getApplicationCollections();
@@ -213,12 +269,11 @@ public class SystemResource extends AbstractContextResource {
     @RequireSystemAccess
     @PUT
     @Path( "index/rebuild/" + RootResource.APPLICATION_ID_PATH + "/{collectionName}" )
-    public JSONWithPadding rebuildIndexes( 
-                @Context UriInfo ui,
-                @PathParam( "applicationId" ) final String applicationIdStr,
-                @PathParam( "collectionName" ) final String collectionName,
-                @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
-                @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay )
+    public JSONWithPadding rebuildIndexes( @Context UriInfo ui,
+                                           @PathParam( "applicationId" ) final String applicationIdStr,
+                                           @PathParam( "collectionName" ) final String collectionName,
+                                           @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
+                                           @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay )
             throws Exception {
 
         final UUID appId = UUIDUtils.tryExtractUUID( applicationIdStr );
@@ -233,8 +288,7 @@ public class SystemResource extends AbstractContextResource {
             }
         };
 
-        rebuild.setName( String.format( 
-                "Index rebuild for app %s and collection %s", appId, collectionName ) );
+        rebuild.setName( String.format( "Index rebuild for app %s and collection %s", appId, collectionName ) );
         rebuild.setDaemon( true );
         rebuild.start();
 
@@ -249,7 +303,7 @@ public class SystemResource extends AbstractContextResource {
 
             @Override
             public void onProgress( final EntityRef entity ) {
-                logger.info( "Indexing entity {}:{}", entity.getType(), entity.getUuid());
+                logger.info( "Indexing entity {}:{}", entity.getType(), entity.getUuid() );
             }
 
 


[19/45] git commit: add comments

Posted by to...@apache.org.
add comments


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

Branch: refs/heads/key-row-sharding
Commit: ad0cce91dadc20525a2442a8c8d0a102cbeb83ad
Parents: bb25b5b
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Oct 28 08:48:59 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Oct 28 08:48:59 2014 -0600

----------------------------------------------------------------------
 .../org/apache/usergrid/services/notifications/QueueListener.java  | 2 +-
 .../usergrid/services/notifications/apns/EntityPushManager.java    | 2 +-
 .../usergrid/services/notifications/apns/ExpiredTokenListener.java | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ad0cce91/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
index ef87b3a..fffc8cd 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
@@ -97,10 +97,10 @@ public class QueueListener  {
                 sleepBetweenRuns = new Long(properties.getProperty("usergrid.notifications.listener.sleep.between", ""+sleepBetweenRuns)).longValue();
                 sleepWhenNoneFound = new Long(properties.getProperty("usergrid.notifications.listener.sleep.after", ""+DEFAULT_SLEEP)).longValue();
                 batchSize = new Integer(properties.getProperty("usergrid.notifications.listener.batchSize", (""+batchSize)));
+                consecutiveCallsToRemoveDevices = new Integer(properties.getProperty("usergrid.notifications.inactive.interval", ""+200));
                 queueName = ApplicationQueueManager.getQueueNames(properties);
 
                 int maxThreads = new Integer(properties.getProperty("usergrid.notifications.listener.maxThreads", ""+MAX_THREADS));
-                consecutiveCallsToRemoveDevices = new Integer(properties.getProperty("usergrid.notifications.inactive.interval", ""+100));
 
                 futures = new ArrayList<Future>(maxThreads);
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ad0cce91/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java
index 29841f0..8283458 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java
@@ -34,7 +34,7 @@ import java.security.KeyStore;
 import java.util.concurrent.LinkedBlockingDeque;
 
 /**
- * Classy class class.
+ * Store notifier within PushManager so it can be retrieved later.  Need this for the async token listener
  */
 public class EntityPushManager extends PushManager<SimpleApnsPushNotification> {
     private final Notifier notifier;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ad0cce91/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java
index 4c38013..3daa20c 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java
@@ -39,7 +39,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 /**
- * Classy class class.
+ * Listen for token expirations and remove
  */
 public class ExpiredTokenListener implements com.relayrides.pushy.apns.ExpiredTokenListener<SimpleApnsPushNotification> {
 


[37/45] git commit: fix google push logic

Posted by to...@apache.org.
fix google push logic


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

Branch: refs/heads/key-row-sharding
Commit: 610eb2da7202a899d41637ddd513488861e2bb16
Parents: ca78792
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Oct 29 11:59:50 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Oct 29 11:59:50 2014 -0600

----------------------------------------------------------------------
 .../services/notifications/gcm/GCMAdapter.java  | 91 +++++++++++---------
 1 file changed, 52 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/610eb2da/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 e5867ea..36cb7f0 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
@@ -79,20 +79,24 @@ public class GCMAdapter implements ProviderAdapter {
         batch.add(providerId, tracker);
     }
 
-    synchronized private Batch getBatch( Map<String, Object> payload) {
-        long hash = MurmurHash.hash64(payload);
-        Batch batch = batches.get(hash);
-        if (batch == null && payload != null) {
-            batch = new Batch(notifier,payload);
-            batches.put(hash,batch);
+    private Batch getBatch( Map<String, Object> payload) {
+        synchronized (this) {
+            long hash = MurmurHash.hash64(payload);
+            Batch batch = batches.get(hash);
+            if (batch == null && payload != null) {
+                batch = new Batch(notifier, payload);
+                batches.put(hash, batch);
+            }
+            return batch;
         }
-        return batch;
     }
 
     @Override
-    synchronized public void doneSendingNotifications() throws Exception {
-        for (Batch batch : batches.values()) {
-            batch.send();
+    public void doneSendingNotifications() throws Exception {
+        synchronized (this) {
+            for (Batch batch : batches.values()) {
+                batch.send();
+            }
         }
     }
 
@@ -163,11 +167,18 @@ public class GCMAdapter implements ProviderAdapter {
             return map;
         }
 
-        synchronized void add(String id, TaskTracker tracker) throws Exception {
-            ids.add(id);
-            trackers.add(tracker);
-            if (ids.size() == BATCH_SIZE) {
-                send();
+        void add(String id, TaskTracker tracker) throws Exception {
+            synchronized (this) {
+                if(!ids.contains(id)) { //dedupe to a device
+                    ids.add(id);
+                    trackers.add(tracker);
+                    if (ids.size() == BATCH_SIZE) {
+                        send();
+                    }
+                }else{
+                    tracker.completed();
+                }
+
             }
         }
 
@@ -177,33 +188,35 @@ public class GCMAdapter implements ProviderAdapter {
         // anything that JSONValue can handle is fine.
         // (What is necessary here is that the Map needs to have a nested
         // structure.)
-        synchronized void send() throws Exception {
-            if (ids.size() == 0)
-                return;
-            Sender sender = new Sender(notifier.getApiKey());
-            Message.Builder builder = new Message.Builder();
-            builder.setData(payload);
-            Message message = builder.build();
-
-            MulticastResult multicastResult = sender.send(message, ids, SEND_RETRIES);
-            LOG.debug("sendNotification result: {}", multicastResult);
-
-            for (int i = 0; i < multicastResult.getResults().size(); i++) {
-                Result result = multicastResult.getResults().get(i);
-
-                if (result.getMessageId() != null) {
-                    String canonicalRegId = result.getCanonicalRegistrationId();
-                    trackers.get(i).completed(canonicalRegId);
-                } else {
-                    String error = result.getErrorCodeName();
-                    trackers.get(i).failed(error, error);
-                    if (Constants.ERROR_NOT_REGISTERED.equals(error) || Constants.ERROR_INVALID_REGISTRATION.equals(error)) {
-                        inactiveDevices.put(ids.get(i), new Date());
+        void send() throws Exception {
+            synchronized (this) {
+                if (ids.size() == 0)
+                    return;
+                Sender sender = new Sender(notifier.getApiKey());
+                Message.Builder builder = new Message.Builder();
+                builder.setData(payload);
+                Message message = builder.build();
+
+                MulticastResult multicastResult = sender.send(message, ids, SEND_RETRIES);
+                LOG.debug("sendNotification result: {}", multicastResult);
+
+                for (int i = 0; i < multicastResult.getResults().size(); i++) {
+                    Result result = multicastResult.getResults().get(i);
+
+                    if (result.getMessageId() != null) {
+                        String canonicalRegId = result.getCanonicalRegistrationId();
+                        trackers.get(i).completed(canonicalRegId);
+                    } else {
+                        String error = result.getErrorCodeName();
+                        trackers.get(i).failed(error, error);
+                        if (Constants.ERROR_NOT_REGISTERED.equals(error) || Constants.ERROR_INVALID_REGISTRATION.equals(error)) {
+                            inactiveDevices.put(ids.get(i), new Date());
+                        }
                     }
                 }
+                this.ids.clear();
+                this.trackers.clear();
             }
-            this.ids.clear();
-            this.trackers.clear();
         }
     }
 }


[03/45] git commit: rewrite remove inactive devices

Posted by to...@apache.org.
rewrite remove inactive devices


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

Branch: refs/heads/key-row-sharding
Commit: e1b2e7365e84c4d0a5a02fdae10d7adac80e5263
Parents: d5d859b
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Oct 24 16:07:40 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Oct 24 16:07:40 2014 -0600

----------------------------------------------------------------------
 .../usergrid/persistence/entities/Notifier.java | 10 ++-
 .../notifications/ApplicationQueueManager.java  | 90 +++++---------------
 .../notifications/InactiveDeviceManager.java    | 77 +++++++++++++++++
 .../notifications/NotificationsService.java     |  1 +
 .../services/notifications/ProviderAdapter.java |  2 +-
 .../services/notifications/QueueListener.java   | 24 ++++--
 .../notifications/apns/APNsAdapter.java         | 68 ++++-----------
 .../notifications/apns/EntityPushManager.java   | 72 ++++++++++++++++
 .../apns/ExpiredTokenListener.java              | 60 +++++++++++++
 .../services/notifications/gcm/GCMAdapter.java  |  7 +-
 10 files changed, 280 insertions(+), 131 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e1b2e736/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java
index be0b447..ba3f2fc 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java
@@ -18,6 +18,7 @@ package org.apache.usergrid.persistence.entities;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.TypedEntity;
 import org.apache.usergrid.persistence.annotations.EntityProperty;
 
@@ -34,6 +35,8 @@ public class Notifier extends TypedEntity {
 
     public static final String ENTITY_TYPE = "notifier";
 
+    protected EntityManager entityManager;
+
     @EntityProperty(aliasProperty = true, unique = true, basic = true)
     protected String name;
 
@@ -63,8 +66,6 @@ public class Notifier extends TypedEntity {
         uuid = id;
     }
 
-
-
     @Override
     @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
     public String getName() {
@@ -131,5 +132,10 @@ public class Notifier extends TypedEntity {
         this.apiKey = apiKey;
     }
 
+    @JsonIgnore
+    public EntityManager getEntityManager(){return entityManager;}
+
+    public void setEntityManager(EntityManager entityManager){ this.entityManager = entityManager;}
+
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e1b2e736/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
index a83513f..3fd84a6 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
@@ -63,16 +63,7 @@ public class ApplicationQueueManager  {
 
     HashMap<Object, Notifier> notifierHashMap; // only retrieve notifiers once
 
-    public final Map<String, ProviderAdapter> providerAdapters =   new HashMap<String, ProviderAdapter>(3);
-    {
-        providerAdapters.put("apple", APNS_ADAPTER);
-        providerAdapters.put("google", new GCMAdapter());
-        providerAdapters.put("noop", TEST_ADAPTER);
-    };
-    // these 2 can be static, but GCM can't. future: would be nice to get gcm
-    // static as well...
-    public static ProviderAdapter APNS_ADAPTER = new APNsAdapter();
-    public static ProviderAdapter TEST_ADAPTER = new TestAdapter();
+    public final Map<String, ProviderAdapter> providerAdapters;
 
 
     public ApplicationQueueManager(JobScheduler jobScheduler, EntityManager entityManager, QueueManager queueManager, MetricsFactory metricsFactory, Properties properties){
@@ -81,6 +72,12 @@ public class ApplicationQueueManager  {
         this.jobScheduler = jobScheduler;
         this.metricsFactory = metricsFactory;
         this.queueName = getQueueNames(properties);
+        providerAdapters =   new HashMap<String, ProviderAdapter>(3);
+        {
+            providerAdapters.put("apple", new APNsAdapter());
+            providerAdapters.put("google", new GCMAdapter());
+            providerAdapters.put("noop", new TestAdapter());
+        };
     }
 
     public boolean scheduleQueueJob(Notification notification) throws Exception{
@@ -254,6 +251,7 @@ public class ApplicationQueueManager  {
             int count = 0;
             while (notifierIterator.hasNext()) {
                 Notifier notifier = notifierIterator.next();
+                notifier.setEntityManager(em);
                 String name = notifier.getName() != null ? notifier.getName() : "";
                 UUID uuid = notifier.getUuid() != null ? notifier.getUuid() : UUID.randomUUID();
                 notifierHashMap.put(name.toLowerCase(), notifier);
@@ -454,71 +452,27 @@ public class ApplicationQueueManager  {
         }
     }
 
-    public void asyncCheckForInactiveDevices(Set<Notifier> notifiers)  throws Exception {
+    public void asyncCheckForInactiveDevices() throws Exception {
+        Collection<Notifier> notifiers = getNotifierMap().values();
         for (final Notifier notifier : notifiers) {
-            INACTIVE_DEVICE_CHECK_POOL.execute(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        checkForInactiveDevices(notifier);
-                    } catch (Exception e) {
-                        LOG.error("checkForInactiveDevices", e); // not
-                        // essential so
-                        // don't fail,
-                        // but log
-                    }
-                }
-            });
-        }
-    }
+            try {
+                ProviderAdapter providerAdapter = providerAdapters.get(notifier.getProvider());
+                if (providerAdapter != null) {
+                    LOG.debug("checking notifier {} for inactive devices", notifier);
+                    providerAdapter.removeInactiveDevices(notifier, em);
 
-    /** gets the list of inactive devices from the Provider and updates them */
-    private void checkForInactiveDevices(Notifier notifier) throws Exception {
-        ProviderAdapter providerAdapter = providerAdapters.get(notifier
-                .getProvider());
-        if (providerAdapter != null) {
-            LOG.debug("checking notifier {} for inactive devices", notifier);
-            Map<String, Date> inactiveDeviceMap = providerAdapter
-                    .getInactiveDevices(notifier, em);
-
-            if (inactiveDeviceMap != null && inactiveDeviceMap.size() > 0) {
-                LOG.debug("processing {} inactive devices",
-                        inactiveDeviceMap.size());
-                Map<String, Object> clearPushtokenMap = new HashMap<String, Object>(
-                        2);
-                clearPushtokenMap.put(notifier.getName() + NOTIFIER_ID_POSTFIX,
-                        "");
-                clearPushtokenMap.put(notifier.getUuid() + NOTIFIER_ID_POSTFIX,
-                        "");
-
-                // todo: this could be done in a single query
-                for (Map.Entry<String, Date> entry : inactiveDeviceMap
-                        .entrySet()) {
-                    // name
-                    Query query = new Query();
-                    query.addEqualityFilter(notifier.getName()
-                            + NOTIFIER_ID_POSTFIX, entry.getKey());
-                    Results results = em.searchCollection(em.getApplication(),
-                            "devices", query);
-                    for (Entity e : results.getEntities()) {
-                        em.updateProperties(e, clearPushtokenMap);
-                    }
-                    // uuid
-                    query = new Query();
-                    query.addEqualityFilter(notifier.getUuid()
-                            + NOTIFIER_ID_POSTFIX, entry.getKey());
-                    results = em.searchCollection(em.getApplication(),
-                            "devices", query);
-                    for (Entity e : results.getEntities()) {
-                        em.updateProperties(e, clearPushtokenMap);
-                    }
+                    LOG.debug("finished checking notifier {} for inactive devices",notifier);
                 }
+            } catch (Exception e) {
+                LOG.error("checkForInactiveDevices", e); // not
+                // essential so
+                // don't fail,
+                // but log
             }
-            LOG.debug("finished checking notifier {} for inactive devices",
-                    notifier);
         }
     }
 
+
     private boolean isOkToSend(Notification notification) {
         Map<String,Long> stats = notification.getStatistics();
         if (stats != null && notification.getExpectedCount() == (stats.get("sent")+ stats.get("errors"))) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e1b2e736/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
new file mode 100644
index 0000000..ecee485
--- /dev/null
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
@@ -0,0 +1,77 @@
+/*
+ *
+ *  * 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.services.notifications;
+
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.Results;
+import org.apache.usergrid.persistence.entities.Notifier;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Classy class class.
+ */
+public class InactiveDeviceManager {
+    private static final Logger LOG = LoggerFactory.getLogger(InactiveDeviceManager.class);
+    private final Notifier notifier;
+
+    public InactiveDeviceManager(Notifier notifier){
+        this.notifier = notifier;
+    }
+    public void removeInactiveDevices( Map<String,Date> inactiveDeviceMap  ){
+        final String notfierPostFix = ApplicationQueueManager.NOTIFIER_ID_POSTFIX;
+        final EntityManager em = notifier.getEntityManager();
+        if (inactiveDeviceMap != null && inactiveDeviceMap.size() > 0) {
+            LOG.debug("processing {} inactive devices",  inactiveDeviceMap.size());
+            Map<String, Object> clearPushtokenMap = new HashMap<String, Object>( 2);
+            clearPushtokenMap.put(notifier.getName() + notfierPostFix,  "");
+            clearPushtokenMap.put(notifier.getUuid() + notfierPostFix,  "");
+
+            // todo: this could be done in a single query
+            for (Map.Entry<String, Date> entry : inactiveDeviceMap.entrySet()) {
+                try {
+                    // name
+                    Query query = new Query();
+                    query.addEqualityFilter(notifier.getName() + notfierPostFix, entry.getKey());
+                    Results results = em.searchCollection(em.getApplication(), "devices", query);
+                    for (Entity e : results.getEntities()) {
+                        em.updateProperties(e, clearPushtokenMap);
+                    }
+                    // uuid
+                    query = new Query();
+                    query.addEqualityFilter(notifier.getUuid() + notfierPostFix, entry.getKey());
+                    results = em.searchCollection(em.getApplication(),  "devices", query);
+                    for (Entity e : results.getEntities()) {
+                        em.updateProperties(e, clearPushtokenMap);
+                    }
+                }catch (Exception e){
+                    LOG.error("failed to remove token",e);
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e1b2e736/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
index 69f66e5..5420d29 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
@@ -356,6 +356,7 @@ public class NotificationsService extends AbstractCollectionService {
     public void testConnection(Notifier notifier) throws Exception {
         ProviderAdapter providerAdapter = providerAdapters.get(notifier.getProvider());
         if (providerAdapter != null) {
+            notifier.setEntityManager(em);
             providerAdapter.testConnection(notifier);
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e1b2e736/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapter.java
index 5268674..33e921f 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapter.java
@@ -46,7 +46,7 @@ public interface ProviderAdapter {
      */
     public void doneSendingNotifications() throws Exception;
 
-    public Map<String, Date> getInactiveDevices(Notifier notifier,
+    public void removeInactiveDevices(Notifier notifier,
                                                 EntityManager em) throws Exception;
 
     public Object translatePayload(Object payload) throws Exception;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e1b2e736/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
index 7ce315b..432ad7f 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
@@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
 import rx.Observable;
 import javax.annotation.PostConstruct;
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -151,7 +152,7 @@ public class QueueListener  {
                 LOG.info("retrieved batch of {} messages from queue {} ", messages.size(),queueName);
 
                 if (messages.size() > 0) {
-
+                    Map<UUID,ApplicationQueueManager> queueManagerMap = new ConcurrentHashMap<>();
                     HashMap<UUID, List<QueueMessage>> messageMap = new HashMap<>(messages.size());
                     //group messages into hash map by app id
                     for (QueueMessage message : messages) {
@@ -172,14 +173,18 @@ public class QueueListener  {
                         UUID applicationId = entry.getKey();
                         EntityManager entityManager = emf.getEntityManager(applicationId);
                         ServiceManager serviceManager = smf.getServiceManager(applicationId);
-                        final ApplicationQueueManager manager = new ApplicationQueueManager(
-                                new JobScheduler(serviceManager, entityManager),
-                                entityManager,
-                                queueManager,
-                                metricsService,
-                                properties
-                        );
 
+                        ApplicationQueueManager manager = queueManagerMap.get(applicationId);
+                        if(manager==null) {
+                            manager = new ApplicationQueueManager(
+                                    new JobScheduler(serviceManager, entityManager),
+                                    entityManager,
+                                    queueManager,
+                                    metricsService,
+                                    properties
+                            );
+                            queueManagerMap.put(applicationId,manager);
+                        }
                         LOG.info("send batch for app {} of {} messages", entry.getKey(), entry.getValue().size());
                         Observable current = manager.sendBatchToProviders(entry.getValue(),queueName);
                         if(merge == null)
@@ -192,6 +197,9 @@ public class QueueListener  {
                         merge.toBlocking().lastOrDefault(null);
                     }
                     queueManager.commitMessages(messages);
+                    for(ApplicationQueueManager applicationQueueManager : queueManagerMap.values()){
+                        applicationQueueManager.asyncCheckForInactiveDevices();
+                    }
                     meter.mark(messages.size());
                     LOG.info("sent batch {} messages duration {} ms", messages.size(),System.currentTimeMillis() - now);
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e1b2e736/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
index 4277b8a..7ab1dc3 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
@@ -47,8 +47,7 @@ import javax.net.ssl.SSLContext;
  */
 public class APNsAdapter implements ProviderAdapter {
 
-    private static final Logger logger = LoggerFactory
-            .getLogger(APNsAdapter.class);
+    private static final Logger logger = LoggerFactory.getLogger(APNsAdapter.class);
 
     public static int MAX_CONNECTION_POOL_SIZE = 15;
     private static final Set<String> validEnvironments = new HashSet<String>();
@@ -72,7 +71,7 @@ public class APNsAdapter implements ProviderAdapter {
         try {
             CountDownLatch latch = new CountDownLatch(1);
             notification.setLatch(latch);
-                PushManager<SimpleApnsPushNotification> pushManager = getPushManager(notifier);
+            EntityPushManager pushManager = getPushManager(notifier);
                 addToQueue(pushManager, notification);
                 latch.await(10000,TimeUnit.MILLISECONDS);
                 if(notification.hasFailed()){
@@ -80,10 +79,10 @@ public class APNsAdapter implements ProviderAdapter {
                     throw new ConnectionException("Bad certificate. Double-check your environment.",notification.getCause() != null ? notification.getCause() : new Exception("Bad certificate."));
                 }
                 notification.finished();
-            } catch (Exception e) {
-                notification.finished();
+        } catch (Exception e) {
+            notification.finished();
 
-                if (e instanceof ConnectionException) {
+            if (e instanceof ConnectionException) {
                 throw (ConnectionException) e;
             }
             if (e instanceof InterruptedException) {
@@ -120,16 +119,13 @@ public class APNsAdapter implements ProviderAdapter {
     }
 
     @Override
-    public Map<String, Date> getInactiveDevices(Notifier notifier,
-            EntityManager em) throws Exception {
-        Map<String,Date> map = new HashMap<String,Date>();
+    public void removeInactiveDevices(Notifier notifier,EntityManager em) throws Exception {
         PushManager<SimpleApnsPushNotification> pushManager = getPushManager(notifier);
         pushManager.requestExpiredTokens();
-        return map;
     }
 
-    private PushManager<SimpleApnsPushNotification> getPushManager(Notifier notifier) throws ExecutionException {
-        PushManager<SimpleApnsPushNotification> pushManager = apnsServiceMap.get(notifier);
+    private EntityPushManager getPushManager(Notifier notifier) throws ExecutionException {
+        EntityPushManager pushManager = apnsServiceMap.get(notifier);
         if(pushManager != null &&  !pushManager.isStarted() && pushManager.isShutDown()){
             apnsServiceMap.invalidate(notifier);
             pushManager = apnsServiceMap.get(notifier);
@@ -138,15 +134,15 @@ public class APNsAdapter implements ProviderAdapter {
     }
 
     //cache to retrieve push manager, cached per notifier, so many notifications will get same push manager
-    private static LoadingCache<Notifier, PushManager<SimpleApnsPushNotification>> apnsServiceMap = CacheBuilder
+    private static LoadingCache<Notifier, EntityPushManager> apnsServiceMap = CacheBuilder
             .newBuilder()
             .expireAfterAccess(10, TimeUnit.MINUTES)
-            .removalListener(new RemovalListener<Notifier, PushManager<SimpleApnsPushNotification>>() {
+            .removalListener(new RemovalListener<Notifier, EntityPushManager>() {
                 @Override
                 public void onRemoval(
-                        RemovalNotification<Notifier, PushManager<SimpleApnsPushNotification>> notification) {
+                        RemovalNotification<Notifier,EntityPushManager> notification) {
                     try {
-                        PushManager<SimpleApnsPushNotification> manager = notification.getValue();
+                        EntityPushManager manager = notification.getValue();
                         if (!manager.isShutDown()) {
                             List<SimpleApnsPushNotification> notifications = manager.shutdown(3000);
                             for (SimpleApnsPushNotification notification1 : notifications) {
@@ -161,31 +157,20 @@ public class APNsAdapter implements ProviderAdapter {
                         logger.error("Failed to shutdown from cache", ie);
                     }
                 }
-            }).build(new CacheLoader<Notifier, PushManager<SimpleApnsPushNotification>>() {
+            }).build(new CacheLoader<Notifier, EntityPushManager>() {
                 @Override
-                public PushManager<SimpleApnsPushNotification> load(Notifier notifier) {
+                public EntityPushManager load(final Notifier notifier) {
                     try {
-                        LinkedBlockingQueue<SimpleApnsPushNotification> queue = new LinkedBlockingQueue<SimpleApnsPushNotification>();
-                        NioEventLoopGroup group = new NioEventLoopGroup();
                         PushManagerConfiguration config = new PushManagerConfiguration();
                         config.setConcurrentConnectionCount(Runtime.getRuntime().availableProcessors() * 2);
-                        PushManager<SimpleApnsPushNotification> pushManager =  new PushManager<>(getApnsEnvironment(notifier), getSSLContext(notifier), group,null , queue, config,notifier.getName());
+                        EntityPushManager pushManager =  new EntityPushManager(notifier, config);
                         //only tested when a message is sent
                         pushManager.registerRejectedNotificationListener(new RejectedAPNsListener());
                         //this will get tested when start is called
                         pushManager.registerFailedConnectionListener(new FailedConnectionListener());
+                        //unregistered expired devices
+                        pushManager.registerExpiredTokenListener(new ExpiredTokenListener());
 
-                        pushManager.registerExpiredTokenListener(new ExpiredTokenListener<SimpleApnsPushNotification>() {
-                            @Override
-                            public void handleExpiredTokens(PushManager<? extends SimpleApnsPushNotification> pushManager, Collection<ExpiredToken> expiredTokens) {
-                                Map<String,Date> map = new HashMap<String,Date>();
-                                for(ExpiredToken token : expiredTokens){
-                                    String expiredToken = new String(token.getToken());
-                                    map.put(expiredToken, token.getExpiration());
-                                }
-                                //TODO figure out way to call back and clear out em references
-                            }
-                        });
                         try {
                             if (!pushManager.isStarted()) { //ensure manager is started
                                 pushManager.start();
@@ -253,24 +238,7 @@ public class APNsAdapter implements ProviderAdapter {
         return wasDelayed;
     }
 
-    private static ApnsEnvironment getApnsEnvironment(Notifier notifier){
-        return  notifier.isProduction()
-                ? ApnsEnvironment.getProductionEnvironment()
-                : ApnsEnvironment.getSandboxEnvironment();
-    }
 
 
-    private static SSLContext getSSLContext(Notifier notifier) {
-        try {
-            KeyStore keyStore = KeyStore.getInstance("PKCS12");
-            String password = notifier.getCertificatePassword();
-            char[] passChars =(password != null ? password : "").toCharArray();
-            InputStream stream = notifier.getP12CertificateStream();
-            keyStore.load(stream,passChars);
-            SSLContext context =  SSLContextUtil.createDefaultSSLContext(keyStore, passChars);
-            return context;
-        }catch (Exception e){
-            throw new RuntimeException("Error getting certificate",e);
-        }
-    }
 }
+

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e1b2e736/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java
new file mode 100644
index 0000000..29841f0
--- /dev/null
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java
@@ -0,0 +1,72 @@
+/*
+ *
+ *  * 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.services.notifications.apns;
+
+import com.relayrides.pushy.apns.ApnsEnvironment;
+import com.relayrides.pushy.apns.PushManager;
+import com.relayrides.pushy.apns.PushManagerConfiguration;
+import com.relayrides.pushy.apns.util.SSLContextUtil;
+import com.relayrides.pushy.apns.util.SimpleApnsPushNotification;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.entities.Notifier;
+
+import javax.net.ssl.SSLContext;
+import java.io.InputStream;
+import java.security.KeyStore;
+import java.util.concurrent.LinkedBlockingDeque;
+
+/**
+ * Classy class class.
+ */
+public class EntityPushManager extends PushManager<SimpleApnsPushNotification> {
+    private final Notifier notifier;
+
+    public EntityPushManager( Notifier notifier, PushManagerConfiguration configuration) {
+        super(getApnsEnvironment(notifier), getSSLContext(notifier), null, null, new LinkedBlockingDeque<SimpleApnsPushNotification>(), configuration, notifier.getName());
+        this.notifier = notifier;
+    }
+
+    public EntityManager getEntityManager() {
+        return notifier.getEntityManager();
+    }
+
+    public Notifier getNotifier() {
+        return notifier;
+    }
+    private static ApnsEnvironment getApnsEnvironment(Notifier notifier){
+        return  notifier.isProduction()
+                ? ApnsEnvironment.getProductionEnvironment()
+                : ApnsEnvironment.getSandboxEnvironment();
+    }
+    private static SSLContext getSSLContext(Notifier notifier) {
+        try {
+            KeyStore keyStore = KeyStore.getInstance("PKCS12");
+            String password = notifier.getCertificatePassword();
+            char[] passChars =(password != null ? password : "").toCharArray();
+            InputStream stream = notifier.getP12CertificateStream();
+            keyStore.load(stream,passChars);
+            SSLContext context =  SSLContextUtil.createDefaultSSLContext(keyStore, passChars);
+            return context;
+        }catch (Exception e){
+            throw new RuntimeException("Error getting certificate",e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e1b2e736/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java
new file mode 100644
index 0000000..4c38013
--- /dev/null
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java
@@ -0,0 +1,60 @@
+/*
+ *
+ *  * 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.services.notifications.apns;
+
+import com.relayrides.pushy.apns.ExpiredToken;
+import com.relayrides.pushy.apns.PushManager;
+import com.relayrides.pushy.apns.util.SimpleApnsPushNotification;
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.Results;
+import org.apache.usergrid.persistence.entities.Notifier;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.services.notifications.ApplicationQueueManager;
+import org.apache.usergrid.services.notifications.InactiveDeviceManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Classy class class.
+ */
+public class ExpiredTokenListener implements com.relayrides.pushy.apns.ExpiredTokenListener<SimpleApnsPushNotification> {
+
+
+    @Override
+    public void handleExpiredTokens(PushManager<? extends SimpleApnsPushNotification> pushManager, Collection<ExpiredToken> expiredTokens) {
+        Map<String,Date> inactiveDeviceMap = new HashMap<>();
+        for(ExpiredToken token : expiredTokens){
+            String expiredToken = new String(token.getToken());
+            inactiveDeviceMap.put(expiredToken, token.getExpiration());
+        }
+        if(pushManager instanceof EntityPushManager){
+            EntityPushManager entityPushManager = (EntityPushManager) pushManager;
+            InactiveDeviceManager inactiveDeviceManager = new InactiveDeviceManager(entityPushManager.getNotifier());
+            inactiveDeviceManager.removeInactiveDevices(inactiveDeviceMap);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e1b2e736/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 dca4a73..f8de5ff 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
@@ -19,6 +19,7 @@ package org.apache.usergrid.services.notifications.gcm;
 import com.google.android.gcm.server.*;
 import org.apache.usergrid.persistence.entities.Notification;
 import org.apache.usergrid.persistence.entities.Notifier;
+import org.apache.usergrid.services.notifications.InactiveDeviceManager;
 import org.mortbay.util.ajax.JSON;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -87,14 +88,16 @@ public class GCMAdapter implements ProviderAdapter {
     }
 
     @Override
-    public Map<String, Date> getInactiveDevices(Notifier notifier,
+    public void removeInactiveDevices(Notifier notifier,
             EntityManager em) throws Exception {
         Batch batch = getBatch(notifier, null);
         Map<String,Date> map = null;
         if(batch != null) {
             map = batch.getAndClearInactiveDevices();
+            InactiveDeviceManager deviceManager = new InactiveDeviceManager(notifier);
+            deviceManager.removeInactiveDevices(map);
         }
-        return map;
+
     }
 
     @Override


[08/45] git commit: fixes to push test

Posted by to...@apache.org.
fixes to push test


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

Branch: refs/heads/key-row-sharding
Commit: 6149bf1397c14c23f94575f094a03b893b7e0029
Parents: c9d6b7e
Author: amuramoto <am...@apigee.com>
Authored: Mon Oct 27 10:08:32 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Mon Oct 27 10:08:32 2014 -0700

----------------------------------------------------------------------
 stack/loadtests/README.md                       |  53 +++++++
 stack/loadtests/pom.xml                         | 140 +++++++++++++++++
 .../datagenerators/EntityDataGenerator.scala    |  59 +++++++
 .../datagenerators/FeederGenerator.scala        | 114 ++++++++++++++
 .../scenarios/ApplicationScenarios.scala        |  46 ++++++
 .../scenarios/ConnectionScenarios.scala         |  36 +++++
 .../usergrid/scenarios/DeviceScenarios.scala    |  85 ++++++++++
 .../usergrid/scenarios/GeoScenarios.scala       |  44 ++++++
 .../scenarios/NotificationScenarios.scala       |  74 +++++++++
 .../usergrid/scenarios/NotifierScenarios.scala  |  66 ++++++++
 .../scenarios/OrganizationScenarios.scala       |  43 ++++++
 .../usergrid/scenarios/TokenScenarios.scala     |  60 ++++++++
 .../usergrid/scenarios/UserScenarios.scala      |  53 +++++++
 .../org/apache/usergrid/settings/Headers.scala  |  43 ++++++
 .../org/apache/usergrid/settings/Settings.scala |  50 ++++++
 .../org/apache/usergrid/settings/Utils.scala    |  91 +++++++++++
 .../simulations/GetEntitySimulation.scala       |  44 ++++++
 .../simulations/PostDevicesSimulation.scala     |  45 ++++++
 .../simulations/PostUsersSimulation.scala       |  50 ++++++
 ...PushNotificationTargetDeviceSimulation.scala |  57 +++++++
 .../PushNotificationTargetUserSimulation.scala  |  72 +++++++++
 stack/loadtests/src/main/scripts/gatling-ug.sh  |  51 ++++++
 stack/loadtests/src/test/resources/gatling.conf | 154 +++++++++++++++++++
 stack/loadtests/src/test/resources/logback.xml  |  20 +++
 .../loadtests/src/test/resources/recorder.conf  |  37 +++++
 stack/loadtests/src/test/scala/Engine.scala     |  16 ++
 .../src/test/scala/IDEPathHelper.scala          |  21 +++
 stack/loadtests/src/test/scala/Recorder.scala   |  12 ++
 28 files changed, 1636 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/README.md
----------------------------------------------------------------------
diff --git a/stack/loadtests/README.md b/stack/loadtests/README.md
new file mode 100644
index 0000000..0c1774a
--- /dev/null
+++ b/stack/loadtests/README.md
@@ -0,0 +1,53 @@
+To make it easy for you to load test your instance of Usergrid, we have bundledin the Gatling load test tool, along with some pre-built tests of different functionality. To get started do the following:
+
+### Setting up Gatling
+1. Unzip loadtest.zip
+2. cd to the 'gatling' dir
+3. Run 'sh loadtest_setup.sh'. This will do the following:
+	- Add some handy options to gatling/bin/gatling.sh that will allow you to set certain test parameters using environment variables (more on this later)
+	- Run the PostUsersSimulation, which will load 5k users with geolocation data into a specified UG org/app. This is just to seed some data entities to make it easier to run some of the tests.
+4. Set the following environment variables:
+- GATLING_BASE_URL - Required. UG base url, e.g. http://api.usergrid.com/.
+- GATLING_ORG      - Required. UG organization name.
+- GATLING_APP      - Required. UG application name.
+
+- GATLING_NUMUSERS - Number of users in the simulation. Default is 100.
+- GATLING_DURATION - Duration of the simulation. Default is 300.
+- GATLING_RAMPTIME - Time period to inject the users over. Default is 0.
+- GATLING_THROTTLE - Requests per second the simulation to try to reach. Default is 50.
+
+- GATLING_NOTIFIER - Name of the notifier to use for PushNotificationSimulation.
+- GATLING_PROVIDER - Push notification provider that corresponds to the notifier, e.g. apple, google, etc.
+
+### Running load tests
+To run Gatling, do the following:
+1. Run 'gatling/bin/gatling.sh'
+2. Enter the number of the test you want to run from the list (see below for an explanation of each test)
+3. Optional. Set a identifier for the results of this run of the simulation
+4. Optional. Set a description for this run of the simulation
+
+### Viewing results
+Results of the test are output to the gatling/results. The output directory is shown once the test has successfully run. The location of the generated report is also shown.
+
+### Default tests
+The following default tests are available. Not that the GATLING_BASE_URL, GATLING_ORG, and GATLING_APP environment variables must be set before any tests can be run. Each test also requires certain additional env variables to be set.
+
+- PostUsersSimulation
+
+POSTs 5k entities with geolocation data to /users. Entities are named sequentially, i.e. user1, user2, etc.
+
+- GetEntitySimulation
+
+Performs simple GETs on the /users collection. You should run PostUsersSimulation or loadtest_Setup.sh first to load data into the collection.
+
+- PostDevicesSimulation
+
+POSTs a user-specified number of entities in the /devices collection. This is useful if you want to load test push notifications
+
+- PushTargetDeviceSimulation
+
+Creates users, devices, connects users with devices, then sends push notification to all user devices. To run this, you will need to do create a notifier, then set the GATLING_NOTIFIER environment variable to equal the name or UUID of the notifier. You'll also need to set GATLING_PROVIDER to match the provider in the notifier.
+
+- PushTargetDeviceSimulation
+
+Sends push notifications. To run this, you will need to do create a notifier, then set the GATLING_NOTIFIER environment variable to equal the name or UUID of the notifier. You'll also need to set GATLING_PROVIDER to match the provider in the notifier.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/pom.xml
----------------------------------------------------------------------
diff --git a/stack/loadtests/pom.xml b/stack/loadtests/pom.xml
new file mode 100644
index 0000000..0fa6272
--- /dev/null
+++ b/stack/loadtests/pom.xml
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.apache.usergrid</groupId>
+	<artifactId>gatling</artifactId>
+	<version>1.0-SNAPSHOT</version>
+
+	<repositories>
+		<repository>
+			<id>sonatype</id>
+			<name>Sonatype OSS</name>
+			<url>https://oss.sonatype.org/content/groups/public</url>
+			<releases>
+				<updatePolicy>never</updatePolicy>
+			</releases>
+			<snapshots>
+				<enabled>true</enabled>
+			</snapshots>
+		</repository>
+	</repositories>
+	<pluginRepositories>
+		<pluginRepository>
+			<id>sonatype</id>
+			<name>Sonatype OSS</name>
+			<url>https://oss.sonatype.org/content/groups/public</url>
+			<snapshots>
+				<enabled>true</enabled>
+			</snapshots>
+		</pluginRepository>
+	</pluginRepositories>
+
+	<properties>
+		<maven.compiler.source>1.7</maven.compiler.source>
+		<maven.compiler.target>1.6</maven.compiler.target>
+		<scala.version>2.10.4</scala.version>
+		<encoding>UTF-8</encoding>
+
+		<gatling.version>2.0.0</gatling.version>
+		<gatling-highcharts.version>2.0.0</gatling-highcharts.version>
+
+		<scala-maven-plugin.version>3.1.6</scala-maven-plugin.version>
+	</properties>
+
+	<dependencyManagement>
+		<dependencies>
+			<dependency>
+				<groupId>io.gatling</groupId>
+				<artifactId>gatling-app</artifactId>
+				<version>${gatling.version}</version>
+			</dependency>
+			<dependency>
+				<groupId>io.gatling</groupId>
+				<artifactId>gatling-recorder</artifactId>
+				<version>${gatling.version}</version>
+			</dependency>
+			<dependency>
+				<groupId>io.gatling.highcharts</groupId>
+				<artifactId>gatling-charts-highcharts</artifactId>
+				<version>${gatling-highcharts.version}</version>
+			</dependency>
+			<dependency>
+				<groupId>org.scala-lang</groupId>
+				<artifactId>scala-library</artifactId>
+				<version>${scala.version}</version>
+			</dependency>
+		</dependencies>
+	</dependencyManagement>
+
+	<dependencies>
+		<dependency>
+			<groupId>io.gatling.highcharts</groupId>
+			<artifactId>gatling-charts-highcharts</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>io.gatling</groupId>
+			<artifactId>gatling-app</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>io.gatling</groupId>
+			<artifactId>gatling-recorder</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.scala-lang</groupId>
+			<artifactId>scala-library</artifactId>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<sourceDirectory>src/main/scala</sourceDirectory>
+		<testSourceDirectory>src/test/scala</testSourceDirectory>
+		<pluginManagement>
+			<plugins>
+				<plugin>
+					<groupId>net.alchim31.maven</groupId>
+					<artifactId>scala-maven-plugin</artifactId>
+					<version>${scala-maven-plugin.version}</version>
+				</plugin>
+				<plugin>
+					<groupId>io.gatling</groupId>
+					<artifactId>gatling-maven-plugin</artifactId>
+					<version>${gatling.version}</version>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+		<plugins>
+			<plugin>
+				<groupId>net.alchim31.maven</groupId>
+				<artifactId>scala-maven-plugin</artifactId>
+				<executions>
+					<execution>
+						<goals>
+							<goal>compile</goal>
+							<goal>testCompile</goal>
+						</goals>
+						<configuration>
+							<args>
+								<arg>-target:jvm-1.6</arg>
+								<arg>-deprecation</arg>
+								<arg>-feature</arg>
+								<arg>-unchecked</arg>
+								<arg>-language:implicitConversions</arg>
+								<arg>-language:postfixOps</arg>
+							</args>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>io.gatling</groupId>
+				<artifactId>gatling-maven-plugin</artifactId>
+        <configuration>
+          <simulationsFolder>src/main/scala</simulationsFolder>
+          <simulationClass>org.apache.usergrid.simulations.PushNotificationTargetDeviceSimulation</simulationClass>
+        </configuration>
+
+			</plugin>
+		</plugins>
+	</build>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala
new file mode 100755
index 0000000..5d1d8f6
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala
@@ -0,0 +1,59 @@
+/*
+ * 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.datagenerators
+
+ import org.apache.usergrid.settings.Utils
+
+ import scala.collection.mutable.ArrayBuffer
+
+object EntityDataGenerator {
+
+  def generateBlockUserLists(numUsers: Int): Map[String, String] = {
+
+    var blocks: ArrayBuffer[String] = new ArrayBuffer[String]
+    var blockedBy: ArrayBuffer[String] = new ArrayBuffer[String]
+
+    for (numBlock <- 1 to Utils.generateRandomInt(1, 7)) {
+      blocks += "user".concat(Utils.generateRandomInt(0, numUsers).toString)
+    }
+
+    for (numBlockedBy <- 1 to Utils.generateRandomInt(1, 7)) {
+      blockedBy += "user".concat(Utils.generateRandomInt(0, numUsers).toString)
+    }
+
+    return Map("blocks" -> blocks.toArray.mkString(","), "blockedBy" -> blockedBy.toArray.mkString(","))
+
+  }
+
+  def generateUser(userId: Int): Map[String,String] = {
+
+    return Map("username" -> "user".concat(userId.toString),
+      "profileId" -> Utils.generateRandomInt(10000, 1000000).toString,
+      "displayName" -> Utils.generateRandomInt(10000, 1000000).toString,
+      "showAge" -> Utils.generateRandomInt(0, 1).toString,
+      "ethnicity" -> Utils.generateRandomInt(1, 15).toString,
+      "relationshipStatus" -> Utils.generateRandomInt(1, 4).toString,
+      "headline" -> "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
+      "aboutMe" -> "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
+      "age" -> Utils.generateRandomInt(18, 65).toString,
+      "height" -> Utils.generateRandomInt(48, 84).toString,
+      "weight" -> Utils.generateRandomInt(120, 350).toString,
+      "seen" -> Utils.generateRandomInt(50, 100000).toString
+    )
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/FeederGenerator.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/FeederGenerator.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/FeederGenerator.scala
new file mode 100755
index 0000000..9f17900
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/FeederGenerator.scala
@@ -0,0 +1,114 @@
+/*
+ * 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.datagenerators
+
+import io.gatling.core.Predef._
+ import org.apache.usergrid.settings.Utils
+ import scala.collection.mutable.ArrayBuffer
+
+object FeederGenerator {
+
+  def generateUserWithGeolocationFeeder(numUsers: Int, radius: Double, centerLatitude: Double, centerLongitude: Double): Array[Map[String, String]] = {
+    var userArray: ArrayBuffer[Map[String, String]] = new ArrayBuffer[Map[String, String]]
+    for (userCount <- 1 to numUsers) {
+      var user: Map[String, String] = EntityDataGenerator.generateUser(userCount)
+      var geolocation: Map[String, String] = Utils.generateRandomGeolocation(radius, centerLatitude, centerLongitude)
+      var blockLists: Map[String, String] = EntityDataGenerator.generateBlockUserLists(numUsers)
+
+      user = user ++ geolocation ++ blockLists
+
+      userArray += user
+    }
+    return userArray.toArray
+  }
+
+  def generateGeolocationFeeder(radius: Double, centerLatitude: Double, centerLongitude: Double): Feeder[String] = {
+
+    val geolocationFeeder = new Feeder[String] {
+
+      // always return true as this feeder can be polled infinitively
+      override def hasNext = true
+
+      override def next: Map[String, String] = {
+        var geolocation: Map[String, String] = Utils.generateRandomGeolocation(radius, centerLatitude, centerLongitude)
+        Map("latitude" -> geolocation("latitude"), "longitude" -> geolocation("longitude"))
+      }
+    }
+
+    return geolocationFeeder
+
+  }
+
+  def generateGeolocationWithQueryFeeder(radius: Double, centerLatitude: Double, centerLongitude: Double): Feeder[String] = {
+
+    val geolocationFeeder = new Feeder[String] {
+
+      // always return true as this feeder can be polled infinitively
+      override def hasNext = true
+
+      override def next: Map[String, String] = {
+        var geolocation: Map[String, String] = Utils.generateRandomGeolocation(radius, centerLatitude, centerLongitude)
+        var queryParams = Utils.generateRandomQueryString
+        Map("latitude" -> geolocation("latitude"), "longitude" -> geolocation("longitude"), "queryParams" -> queryParams)
+      }
+    }
+
+    return geolocationFeeder
+
+  }
+
+  def generateUserConnectionFeeder(numUsers: Int): Feeder[String] = {
+
+    val userIdFeeder = new Feeder[String] {
+
+      // always return true as this feeder can be polled infinitively
+      override def hasNext = true
+
+      override def next: Map[String, String] = {
+        Map("user1" -> "user".concat(Utils.generateRandomInt(1, numUsers).toString), "user2" -> "user".concat(Utils.generateRandomInt(1, numUsers).toString))
+      }
+    }
+
+    return userIdFeeder
+
+  }
+
+  def generateEntityNameFeeder(prefix: String, numEntities: Int): Array[Map[String, String]] = {
+
+    var nameArray: ArrayBuffer[Map[String, String]] = new ArrayBuffer[Map[String, String]]
+
+    for (entityCount <- 1 to numEntities) {
+      nameArray += Map("entityName" -> prefix.concat(entityCount.toString))
+    }
+
+    return nameArray.toArray
+
+  }
+
+  def generateRandomEntityNameFeeder(prefix: String, numEntities: Int): Array[Map[String, String]] = {
+
+    var nameArray: ArrayBuffer[Map[String, String]] = new ArrayBuffer[Map[String, String]]
+
+    for (entityCount <- 1 to numEntities) {
+      nameArray += Map("entityName" -> prefix.concat(Utils.generateRandomInt(0, 100000000).toString))
+    }
+
+    return nameArray.toArray
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala
new file mode 100755
index 0000000..ffc7d96
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala
@@ -0,0 +1,46 @@
+/*
+ * 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.scenarios
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid.settings.{Settings, Headers}
+
+ /**
+ * Performs organization registration
+ *
+ *
+ * Expects:
+ *
+ * authToken The auth token to use when creating the application
+ * orgName The organization name
+ *
+ * Produces:
+ *
+ * appName The name of the created application
+ */
+object ApplicationScenarios {
+
+  val createApplication = exec(http("Create Application")
+    .post("/management/organizations/${org}/applications")
+    .headers(Headers.jsonAuthorized)
+    .body(StringBody("{\"name\":\"" + Settings.app + "\"}"))
+    .check(status.is(200))
+
+    )
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala
new file mode 100755
index 0000000..4a5e2ae
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala
@@ -0,0 +1,36 @@
+/*
+ * 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.scenarios
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+
+object ConnectionScenarios {
+
+  val postConnection = exec(
+    http("POST connection")
+    .post("/users/${user1}/likes/users/${user2}")
+    .check(status.is(200))
+  )
+
+  val postUserToDeviceConnection = exec(
+    http("Connect user with device")
+    .post("/users/${username}/devices/${deviceId}")
+    .check(status.is(200))
+  )
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
new file mode 100755
index 0000000..5737e24
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
@@ -0,0 +1,85 @@
+/*
+ * 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.scenarios
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef.StringBody
+import io.gatling.http.Predef._
+import org.apache.usergrid.settings.Settings
+
+/**
+ *
+ * Creates a new device
+ *
+ * Expects:
+ *
+ * authToken The auth token to use when creating the application
+ * orgName The name of the org
+ * appName The name of the app
+ * notifierName The name of the created notifier
+ *
+ * Produces:
+ *
+ * deviceName the name of the device created
+ *
+ */
+object DeviceScenarios {
+
+  val notifier = Settings.pushNotifier
+
+  /**
+   * Create a device
+   */
+  val postDeviceWithNotifier = exec(http("Create device with notifier")
+    .post("/devices")
+    .body(StringBody("""{"deviceModel":"Fake Device",
+    "deviceOSVerion":"Negative Version",
+    """" + notifier + """.notifier.id":"${entityName}"}"""))
+    .check(status.is(200), jsonPath("$..entities[0].uuid").exists , jsonPath("$..entities[0].uuid").saveAs("deviceId")))
+
+
+  val postDeviceWithNotifier400ok = exec(http("Create device with notifier")
+    .post("/devices")
+    .body(StringBody("""{"name":"${entityName}",
+    "deviceModel":"Fake Device",
+    "deviceOSVerion":"Negative Version",
+    "${notifier}.notifier.id":"${entityName}"}"""))
+    .check(status.in(200 to 400), jsonPath("$.entities[0].uuid").saveAs("deviceId")))
+
+
+  /**
+   * Requires: entityName to feed to the device name.  If it exists, it will be created
+   */
+  val maybeCreateDevice = exec(
+    //try to do a GET on device name, if it 404's create it
+    http("Check and create device").get("/devices/${entityName}").check(status.not(404).saveAs("deviceExists")))
+    //create the device if we got a 404
+    .doIf("${deviceExists}", "404") {
+
+    exec(
+
+      http("Create device and save deviceId").post("/devices").body(StringBody(
+        """{"name":"${entityName}",
+          "deviceModel":"Fake Device",
+          "deviceOSVerion":"Negative Version",
+          "${notifier}.notifier.id":"${entityName}"}"""))
+          .check(status.is(200), jsonPath("$.entities[0].uuid").saveAs("deviceId"))
+    )
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/GeoScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/GeoScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/GeoScenarios.scala
new file mode 100755
index 0000000..2954abd
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/GeoScenarios.scala
@@ -0,0 +1,44 @@
+/*
+ * 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.scenarios
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid.settings.{Utils, Settings}
+
+ object GeoScenarios {
+
+  val getGeolocation = exec(
+      http("GET geolocated user")
+        .get("/users?ql=location%20within%20" + Settings.geosearchRadius + "%20of%20${latitude},${longitude}")
+        .check(status.is(200))
+    )
+
+  val getGeolocationWithQuery = exec(
+      http("GET geolocated user with query")
+        .get("/users?ql=${queryParams}%20AND%20location%20within%20" + Settings.geosearchRadius + "%20of%20${latitude},${longitude}")
+        .check(status.is(200))
+    )
+
+  val updateGeolocation = exec(
+    http("PUT user location")
+      .put("/users/user" + Utils.generateRandomInt(1, Settings.numUsers))
+      .body(StringBody("{\"location\":{\"latitude\":\"${latitude}\",\"longitude\":\"${longitude}\"}}"))
+      .check(status.is(200))
+  )
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
new file mode 100755
index 0000000..dad4cae
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
@@ -0,0 +1,74 @@
+/*
+ * 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.scenarios
+
+import java.io.File
+import java.nio.file.{Paths, Files}
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+import scala.concurrent.duration._
+
+import scala.io.Source
+
+import org.apache.usergrid.settings.Settings
+
+/**
+ *
+ * Creates a new device
+ *
+ * Expects:
+ *
+ * authToken The auth token to use when creating the application
+ * orgName The name of the org
+ * appName The name of the app
+ * notifierName The name of the created notifier
+ * deviceName the name of the device created to send the notification to
+ *
+ * Produces:
+ *
+ * N/A
+ *
+ *
+ */
+object NotificationScenarios {
+
+  val notifier = Settings.pushNotifier
+
+  /**
+   * send the notification now
+   */
+  val sendNotification = exec(http("Send Single Notification")
+      .post("/devices/${entityName}/notifications")
+      .body(StringBody("{\"payloads\":{\"" + notifier + "\":\"testmessage\"}}"))
+      .check(status.is(200))
+    )
+
+  val sendNotificationToUser= exec(http("Send Notification to All Devices")
+    .post("/users/${username}/notifications")
+    .body(StringBody("{\"debug\":\"true\",\"payloads\":{\"" + notifier + "\":\"testmessage\"}}"))
+    .check(status.is(200))
+  )
+
+  /**
+   * TODO: Add posting to users, which would expect a user in the session
+   */
+
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala
new file mode 100755
index 0000000..00cdd71
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala
@@ -0,0 +1,66 @@
+/*
+ * 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.scenarios
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid.settings.Settings
+ import scala.concurrent.duration._
+
+/**
+ *
+ * Creates a new no-op notifier
+ *
+ *
+ * Expects:
+ *
+ * authToken The auth token to use when creating the application
+ * orgName The name of the org
+ * appName The name of the app
+ *
+ * Produces:
+ *
+ * notifierName The name of the created notifier
+ *
+ */
+object NotifierScenarios {
+  
+  val notifier = Settings.pushNotifier
+  val provider = Settings.pushProvider
+
+  /**
+   * Create a notifier
+   */
+  val createNotifier = exec(
+      session => {
+        session.set("notifier", notifier)
+        session.set("provider", provider)
+      }
+    )
+
+    .exec(http("Create Notifier")
+    .post("/notifiers")
+    .body(StringBody("{\"name\":\"" + notifier + "\",\"provider\":\"" + provider + "\"}"))
+    //remnants of trying to upload an apple certificate
+//    .param("name", "${notifierName}")
+//    .param("provider", "apple")
+//    .param("environment", "mock")
+//    .fileBody("p12Certificate", Map).fileBody(pkcs12Cert)
+    .check(status.is(200)))
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala
new file mode 100755
index 0000000..f79efd6
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala
@@ -0,0 +1,43 @@
+/*
+ * 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.scenarios
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid.settings.{Settings, Headers}
+ import scala.concurrent.duration._
+
+/**
+ * Performs organization registration
+ *
+ *
+ * Produces:
+ *
+ * orgName The name of the created organization
+ * userName  The user name of the admin to log in with
+ * password The password of the admin to use
+ */
+object OrganizationScenarios {
+
+  //register the org with the randomly generated org
+  val createOrgAndAdmin = exec(http("Create Organization")
+  .post("/management/organizations")
+  .headers(Headers.jsonAnonymous)
+  .body(StringBody("{\"organization\":\"" + Settings.org + "\",\"username\":\"${entityName}\",\"name\":\"${entityName}\",\"email\":\"${entityName}@apigee.com\",\"password\":\"test\"}"))
+  .check(status.is(200)))
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/TokenScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/TokenScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/TokenScenarios.scala
new file mode 100755
index 0000000..3508d6f
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/TokenScenarios.scala
@@ -0,0 +1,60 @@
+/*
+ * 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.scenarios
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid.settings.Headers
+ import scala.concurrent.duration._
+
+/**
+ * Class that will get the token and insert it into the test session.
+ * Assumes that  the following values are present in the session.
+ *
+ * Expects:
+ *
+ * userName  The user name to log in with
+ * password The password to use
+ *
+ * Produces:
+ *
+ * authToken A valid access token if the login attempt is successful
+ */
+
+object TokenScenarios {
+
+
+  val getManagementToken =
+    exec(
+      http("POST Org Token")
+        .post("/management/token")
+        .headers(Headers.jsonAnonymous)
+        //pass in the the username and password, store the "access_token" json response element as the var "authToken" in the session
+        .body(StringBody("{\"username\":\"${username}\",\"password\":\"${password}\",\"grant_type\":\"password\"}"))
+        .check(jsonPath("access_token")
+        .saveAs("authToken"))
+    )
+
+  val getUserToken =
+    exec(
+      http("POST user token")
+        .post("/token")
+        .body(StringBody("{\"grant_type\":\"password\",\"username\":\"${user1}\",\"password\":\"password\"}"))
+        .check(status.is(200))
+    )
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
new file mode 100755
index 0000000..ff96714
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
@@ -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.scenarios
+
+import io.gatling.core.Predef._
+ import io.gatling.http.Predef.StringBody
+ import io.gatling.http.Predef._
+ import io.gatling.http.request.StringBody
+ import org.apache.usergrid.settings.{Settings, Utils}
+
+ object UserScenarios {
+
+  val getRandomUser = exec(
+    http("GET user")
+      .get("/users/user" + Utils.generateRandomInt(1, Settings.numEntities))
+      .check(status.is(200))
+  )
+
+  val postUser = exec(
+    http("POST geolocated Users")
+      .post("/users")
+      .body(new StringBody("""{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
+      "displayName":"${displayName}","age":"${age}","seen":"${seen}","weight":"${weight}",
+      "height":"${height}","aboutMe":"${aboutMe}","profileId":"${profileId}","headline":"${headline}","
+      "showAge":"${showAge}","relationshipStatus":"${relationshipStatus}","ethnicity":"${ethnicity}","password":"password"}"""))
+      .check(status.is(200))
+  )
+
+  val postUser400ok = exec(
+    http("POST geolocated Users")
+      .post("/users")
+      .body(new StringBody("""{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
+      "displayName":"${displayName}","age":"${age}","seen":"${seen}","weight":"${weight}",
+      "height":"${height}","aboutMe":"${aboutMe}","profileId":"${profileId}","headline":"${headline}",
+      "showAge":"${showAge}","relationshipStatus":"${relationshipStatus}","ethnicity":"${ethnicity}","password":"password"}"""))
+      .check(status.in(200 to 400))
+  )
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
new file mode 100755
index 0000000..9b735e5
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
@@ -0,0 +1,43 @@
+/*
+ * 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.settings
+
+/**
+ *
+ */
+object Headers {
+
+  /**
+   * Headers for anonymous posts
+   */
+  val jsonAnonymous = Map(
+    "Cache-Control" -> """no-cache""",
+    "Content-Type" -> """application/json; charset=UTF-8"""
+  )
+
+  /**
+   * Headers for authorized users with token and json content type
+   */
+  val jsonAuthorized = Map(
+    "Cache-Control" -> """no-cache""",
+    "Content-Type" -> """application/json; charset=UTF-8""",
+    "Authorization" -> "Bearer ${authToken}"
+  )
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala
new file mode 100755
index 0000000..bb82100
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala
@@ -0,0 +1,50 @@
+/*
+ * 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.settings
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+import scala.concurrent.duration._
+
+object Settings {
+
+  // Target settings
+  val org = System.getProperty("org")
+  val app = System.getProperty("app")
+  val baseUrl = System.getProperty("baseurl")
+  val httpConf = http.baseURL(baseUrl + "/" + org + "/" + app)
+
+  // Simulation settings
+  val numUsers:Int = Integer.getInteger("numUsers", 10).toInt
+  val numEntities:Int = Integer.getInteger("numEntities", 5000).toInt
+  val numDevices:Int = Integer.getInteger("numDevices", 2000).toInt
+
+  val rampTime:Int = Integer.getInteger("rampTime", 0).toInt // in seconds
+  val duration:Int = Integer.getInteger("duration", 300).toInt // in seconds
+  val throttle:Int = Integer.getInteger("throttle", 50).toInt // in seconds
+
+  // Geolocation settings
+  val centerLatitude:Double = 37.442348 // latitude of center point
+  val centerLongitude:Double = -122.138268 // longitude of center point
+  val userLocationRadius:Double = 32000 // location of requesting user in meters
+  val geosearchRadius:Int = 8000 // search area in meters
+
+  // Push Notification settings
+  val pushNotifier = System.getProperty("pushNotifier")
+  val pushProvider = System.getProperty("pushProvider")
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Utils.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Utils.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Utils.scala
new file mode 100755
index 0000000..8997d8c
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Utils.scala
@@ -0,0 +1,91 @@
+/*
+ * 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.settings
+
+import scala.util.Random
+import scala.math
+import Array._
+
+/**
+ *
+ * Utility for creating various data elements
+ *
+ */
+object Utils {
+
+  private val RNG = new Random
+
+  /**
+   * Generate a new uuid and replace the '-' with empty
+   */
+  def generateUUIDString(): String = {
+    return java.util.UUID.randomUUID.toString.replace("-", "")
+  }
+
+  /**
+   * Generate a unique string with a prefix
+   *
+   * @param prefix
+   * @return
+   */
+  def generateUniqueName(prefix : String): String = {
+     return prefix + generateUUIDString()
+  }
+
+  // random number in between [a...b]
+  def generateRandomInt(lowerBound: Int, upperBound: Int) = RNG.nextInt(upperBound - lowerBound) + lowerBound
+
+  def generateRandomGeolocation(radius: Double, centerLatitude: Double, centerLongitude: Double):Map[String, String] = {
+
+    var rd = radius / 111300 // Convert Radius from meters to degrees.
+    var u = RNG.nextFloat()
+    var v = RNG.nextFloat()
+    var q = math.sqrt(u) * rd
+    var w = q * rd
+    var t = 2 * math.Pi * v
+    var x = math.cos(t) * w
+    var y = math.sin(t) * w
+    var xp = x/math.cos(centerLatitude)
+    var latitude = (y + centerLatitude).toString
+    var longitude = (xp + centerLongitude).toString
+    var geolocation: Map[String, String] = Map("latitude"->latitude,"longitude"->longitude)
+
+    return geolocation
+  }
+
+  def generateRandomQueryString: String = {
+
+    val queryParams = Array("age", "height", "weight")
+    var queryString = ""
+
+    for (numParams <- 1 to generateRandomInt(1, queryParams.length)) {
+      queryString = "age=" + Utils.generateRandomInt(18, 65).toString
+      if (numParams == 2) {
+        queryString += "%20AND%20height=" + Utils.generateRandomInt(48, 84).toString
+      } else if (numParams == 3) {
+        queryString += "%20AND%20weight=" + Utils.generateRandomInt(120, 350).toString
+      }
+    }
+
+    return queryString
+  }
+
+  def createRandomPushNotifier:String = {
+    return Utils.generateUniqueName("notifier")
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala
new file mode 100644
index 0000000..7b9df21
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala
@@ -0,0 +1,44 @@
+/*
+ * 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.simulations
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid.datagenerators.FeederGenerator
+ import org.apache.usergrid.scenarios.UserScenarios
+ import org.apache.usergrid.settings.Settings
+ import scala.concurrent.duration._
+
+class GetEntitySimulation extends Simulation {
+
+  // Target settings
+  val httpConf = Settings.httpConf
+
+  // Simulation settings
+  val numUsers:Int = Settings.numUsers
+  val numEntities:Int = Settings.numEntities
+  val rampTime:Int = Settings.rampTime
+  val throttle:Int = Settings.throttle
+
+  val feeder = FeederGenerator.generateEntityNameFeeder("user", numEntities).circular
+
+  val scnToRun = scenario("GET entity")
+    .exec(UserScenarios.getRandomUser)
+
+  setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf)).maxDuration(Settings.duration)
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostDevicesSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostDevicesSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostDevicesSimulation.scala
new file mode 100755
index 0000000..d7c6dd8
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostDevicesSimulation.scala
@@ -0,0 +1,45 @@
+/*
+ * 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.simulations
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid.datagenerators.FeederGenerator
+ import org.apache.usergrid.scenarios.DeviceScenarios
+ import org.apache.usergrid.settings.Settings
+ import scala.concurrent.duration._
+
+class PostDevicesSimulation extends Simulation {
+
+  // Target settings
+  val httpConf = Settings.httpConf
+
+  // Simulation settings
+  val numUsers:Int = Settings.numUsers
+  val numEntities:Int = Settings.numEntities
+  val rampTime:Int = Settings.rampTime
+  val throttle:Int = Settings.throttle
+
+  val feeder = FeederGenerator.generateEntityNameFeeder("device", numEntities)
+
+  val scnToRun = scenario("POST device")
+    .feed(feeder)
+    .exec(DeviceScenarios.postDeviceWithNotifier)
+
+  setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
new file mode 100755
index 0000000..cbac041
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
@@ -0,0 +1,50 @@
+/*
+ * 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.simulations
+
+import io.gatling.core.Predef._
+ import org.apache.usergrid.datagenerators.FeederGenerator
+ import org.apache.usergrid.scenarios.UserScenarios
+ import org.apache.usergrid.settings.Settings
+
+ import scala.concurrent.duration._
+
+class PostUsersSimulation extends Simulation {
+
+  // Target settings
+  val httpConf = Settings.httpConf
+
+  // Simulation settings
+  val numUsers:Int = Settings.numUsers
+  val rampTime:Int = Settings.rampTime
+  val throttle:Int = Settings.throttle
+
+  // Geolocation settings
+  val centerLatitude:Double = Settings.centerLatitude
+  val centerLongitude:Double = Settings.centerLongitude
+  val userLocationRadius:Double = Settings.userLocationRadius
+  val geosearchRadius:Int = Settings.geosearchRadius
+
+  val feeder = FeederGenerator.generateUserWithGeolocationFeeder(numUsers, userLocationRadius, centerLatitude, centerLongitude).queue
+
+  val scnToRun = scenario("POST geolocated users")
+    .feed(feeder)
+    .exec(UserScenarios.postUser)
+
+  setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetDeviceSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetDeviceSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetDeviceSimulation.scala
new file mode 100755
index 0000000..731423c
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetDeviceSimulation.scala
@@ -0,0 +1,57 @@
+/*
+ * 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.simulations
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid._
+ import org.apache.usergrid.datagenerators.FeederGenerator
+ import org.apache.usergrid.scenarios.{NotificationScenarios, DeviceScenarios, NotifierScenarios}
+ import org.apache.usergrid.settings.Settings
+ import scala.concurrent.duration._
+
+/**
+ *
+ * Simple test for setting up multiple orgs and creating push notifications
+ *
+ */
+class PushNotificationTargetDeviceSimulation extends Simulation {
+
+  val numUsers:Int = Settings.numUsers
+  val numEntities:Int = Settings.numEntities
+  val rampTime:Int = Settings.rampTime
+  val throttle:Int = Settings.throttle
+  val duration:Int = Settings.duration  
+  val httpConf = Settings.httpConf
+    .acceptHeader("application/json")
+
+  val createNotifier = NotifierScenarios.createNotifier
+  val createDevice = DeviceScenarios.postDeviceWithNotifier
+  val sendNotification = NotificationScenarios.sendNotification
+
+  val deviceNameFeeder = FeederGenerator.generateEntityNameFeeder("device", numEntities).circular
+
+  val scnToRun = scenario("Create Push Notification")    
+    .during(duration.seconds) {
+      feed(deviceNameFeeder)
+      .exec(sendNotification)
+    }
+
+
+  setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala
new file mode 100644
index 0000000..9391160
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala
@@ -0,0 +1,72 @@
+/*
+ * 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.simulations
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+import org.apache.usergrid.settings.Utils
+import org.apache.usergrid.datagenerators.FeederGenerator
+import org.apache.usergrid.scenarios._
+import org.apache.usergrid.settings.Settings
+import scala.concurrent.duration._
+
+class PushNotificationTargetUserSimulation extends Simulation {
+
+  val duration:Int = Settings.duration
+  val numUsersPerSecond:Int = Settings.numUsers
+  val numEntities:Int = numUsersPerSecond * 3 * duration
+  val rampTime:Int = Settings.rampTime
+  val throttle:Int = Settings.throttle
+
+  val httpConf = Settings.httpConf.acceptHeader("application/json")
+  val notifier = Settings.pushNotifier
+
+  val createNotifier = NotifierScenarios.createNotifier
+  val createDevice = DeviceScenarios.postDeviceWithNotifier
+  val sendNotification = NotificationScenarios.sendNotificationToUser
+  val createUser = UserScenarios.postUser400ok
+  val createOrg = OrganizationScenarios.createOrgAndAdmin
+  val connectUserToDevice = ConnectionScenarios.postUserToDeviceConnection
+
+  val deviceNameFeeder = FeederGenerator.generateEntityNameFeeder("device", numEntities)
+  val userFeeder = FeederGenerator.generateUserWithGeolocationFeeder(numUsersPerSecond * duration, Settings.userLocationRadius, Settings.centerLatitude, Settings.centerLongitude)
+  val orgFeeder = FeederGenerator.generateRandomEntityNameFeeder("org", 1)
+
+  val scnCreateOrg = scenario("Create org")
+    .feed(orgFeeder)
+    .exec(createOrg)
+
+  val scnCreateNotifier = scenario("Create notifier")
+    .exec(createNotifier)
+
+  val scnToRun = scenario("Create Push Notification")
+    .feed(userFeeder)
+    .exec(createUser)
+    .repeat(2){
+      feed(deviceNameFeeder)
+      .exec(createDevice)
+      .exec(connectUserToDevice)
+    }
+    .exec(sendNotification)
+
+
+
+  setUp(scnCreateOrg.inject(atOnceUsers(1)).protocols(http.baseURL(Settings.baseUrl)),
+    scnCreateNotifier.inject(nothingFor(5), atOnceUsers(1)).protocols(httpConf),
+    scnToRun.inject(nothingFor(7), constantUsersPerSec(numUsersPerSecond) during (duration)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/main/scripts/gatling-ug.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scripts/gatling-ug.sh b/stack/loadtests/src/main/scripts/gatling-ug.sh
new file mode 100755
index 0000000..4c6bc0c
--- /dev/null
+++ b/stack/loadtests/src/main/scripts/gatling-ug.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# Licensed 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.
+#
+die () {
+    echo >&2 "$@"
+    exit 1
+}
+
+[ "$#" -eq 5 ] || die "5 arguments required, $# provided.  Arguments are URL ORG APP NUM_USERS RAMP_TIME"
+
+OLDDIR=`pwd`
+BIN_DIR=`dirname $0`
+cd "${BIN_DIR}/.." && DEFAULT_GATLING_HOME=`pwd` && cd "${OLDDIR}"
+
+GATLING_HOME="${GATLING_HOME:=${DEFAULT_GATLING_HOME}}"
+GATLING_CONF="${GATLING_CONF:=$GATLING_HOME/conf}"
+URL="$1"
+ORG="$2"
+APP="$3"
+USERS="$4"
+RAMP="$5"
+
+#Shift off our first operation
+shift 5
+
+export GATLING_HOME GATLING_CONF
+
+echo "GATLING_HOME is set to ${GATLING_HOME}"
+
+curl -X POST "${URL}/usergrid/sandbox/notifiers" -d '{"name":"notifier82e05787a8c24361a2992c64436b6e6a","provider":"noop"}'
+
+#Add -Ds=<simulation class name>
+
+JAVA_OPTS="-Dthrottle=3000 -Dduration=300 -Dorg=${ORG} -Dbaseurl=${URL} -Dnotifier=notifier82e05787a8c24361a2992c64436b6e6a -DnumEntities=10000 -DnumUsers=${USERS} -DrampTime=${RAMP} -Dapp=${APP} -server -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms512M -Xmx512M -Xmn100M -XX:+HeapDumpOnOutOfMemoryError -XX:+AggressiveOpts -XX:+OptimizeStringConcat -XX:+UseFastAccessorMethods -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv6Addresses=false ${JAVA_OPTS}"
+
+echo $JAVA_OPTS
+
+CLASSPATH="$GATLING_HOME/lib/*:$GATLING_CONF:$GATLING_HOME/user-files:${JAVA_CLASSPATH}"
+
+java $JAVA_OPTS -cp "$CLASSPATH" io.gatling.app.Gatling "$@"

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/test/resources/gatling.conf
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/test/resources/gatling.conf b/stack/loadtests/src/test/resources/gatling.conf
new file mode 100644
index 0000000..1455242
--- /dev/null
+++ b/stack/loadtests/src/test/resources/gatling.conf
@@ -0,0 +1,154 @@
+#########################
+# Gatling Configuration #
+#########################
+
+# This file contains all the settings configurable for Gatling with their default values
+
+gatling {
+  core {
+    #outputDirectoryBaseName = "" # The prefix for each simulation result folder (then suffixed by the report generation timestamp)
+    #runDescription = ""          # The description for this simulation run, displayed in each report
+    #encoding = "utf-8"           # Encoding to use throughout Gatling for file and string manipulation
+    #simulationClass = ""         # The FQCN of the simulation to run (when used in conjunction with noReports, the simulation for which assertions will be validated)
+    #disableCompiler = false      # When set to true, skip compiling and load an already compiled simulation (used in conjunction with simulationClass)
+    #mute = false                 # When set to true, don't ask for simulation name nor run description (currently only used by Gatling SBT plugin)
+
+    extract {
+      regex {
+        #cacheMaxCapacity = 200 # Cache size for the compiled regexes, set to 0 to disable caching
+      }
+      xpath {
+        #cacheMaxCapacity = 200 # Cache size for the compiled XPath queries,  set to 0 to disable caching
+      }
+      jsonPath {
+        #cacheMaxCapacity = 200 # Cache size for the compiled jsonPath queries, set to 0 to disable caching
+        #preferJackson = false  # When set to true, prefer Jackson over Boon for JSON-related operations
+        jackson {
+          #allowComments = false           # Allow comments in JSON files
+          #allowUnquotedFieldNames = false # Allow unquoted JSON fields names
+          #allowSingleQuotes = false       # Allow single quoted JSON field names
+        }
+
+      }
+      css {
+        #cacheMaxCapacity = 200 # Cache size for the compiled CSS selectors queries,  set to 0 to disable caching
+      }
+    }
+
+    timeOut {
+      #simulation = 8640000 # Absolute timeout, in seconds, of a simulation
+    }
+    directory {
+      #data = user-files/data                    # Folder where user's data (e.g. files used by Feeders) is located
+      #requestBodies = user-files/request-bodies # Folder where request bodies are located
+      #simulations = user-files/simulations      # Folder where the bundle's simulations are located
+      simulations = src/main/scala              # Folder where the bundle's simulations are located
+      #reportsOnly = ""                          # If set, name of report folder to look for in order to generate its report
+      #binaries = ""                             # If set, name of the folder where compiles classes are located
+      #results = results                         # Name of the folder where all reports folder are located
+    }
+    zinc {
+      #jvmArgs = "-Xss10M" # JVM args passed to Zinc (in charge of compiling Gatling Simulations)
+    }
+  }
+  charting {
+    #noReports = false       # When set to true, don't generate HTML reports
+    #maxPlotPerSeries = 1000 # Number of points per graph in Gatling reports
+    #accuracy = 10           # Accuracy, in milliseconds, of the report's stats
+    indicators {
+      #lowerBound = 800      # Lower bound for the requests' response time to track in the reports and the console summary
+      #higherBound = 1200    # Higher bound for the requests' response time to track in the reports and the console summary
+      #percentile1 = 95      # Value for the first percentile to track in the reports, the console summary and GraphiteDataWriter
+      #percentile2 = 99      # Value for the second percentile to track in the reports, the console summary and GraphiteDataWriter
+    }
+  }
+  http {
+    #elFileBodiesCacheMaxCapacity = 200        # Cache size for request body EL templates, set to 0 to disable
+    #rawFileBodiesCacheMaxCapacity = 200       # Cache size for request body Raw templates, set to 0 to disable
+    #fetchedCssCacheMaxCapacity = 200          # Cache size for CSS parsed content, set to 0 to disable
+    #fetchedHtmlCacheMaxCapacity = 200         # Cache size for HTML parsed content, set to 0 to disable
+    #redirectPerUserCacheMaxCapacity = 200     # Per virtual user cache size for permanent redirects, set to 0 to disable
+    #expirePerUserCacheMaxCapacity = 200       # Per virtual user cache size for permanent 'Expire' headers, set to 0 to disable
+    #lastModifiedPerUserCacheMaxCapacity = 200 # Per virtual user cache size for permanent 'Last-Modified' headers, set to 0 to disable
+    #etagPerUserCacheMaxCapacity = 200         # Per virtual user cache size for permanent ETag headers, set to 0 to disable
+    #warmUpUrl = "http://goo.gl/pq1Xwu"        # The URL to use to warm-up the HTTP stack (blank means disabled)
+    ssl {
+      trustStore {
+        #type = ""      # Type of SSLContext's TrustManagers store
+        #file = ""      # Location of SSLContext's TrustManagers store
+        #password = ""  # Password for SSLContext's TrustManagers store
+        #algorithm = "" # Algorithm used by SSLContext's TrustManagers store
+      }
+      keyStore {
+        #type = ""      # Type of SSLContext's KeyManagers store
+        #file = ""      # Location of SSLContext's KeyManagers store
+        #password = ""  # Password for SSLContext's KeyManagers store
+        #algorithm = "" # Algorithm used SSLContext's KeyManagers store
+      }
+    }
+    ahc {
+      #allowPoolingConnections = true             # Allow pooling HTTP connections (keep-alive header automatically added)
+      #allowPoolingSslConnections = true          # Allow pooling HTTPS connections (keep-alive header automatically added)
+      #compressionEnforced = false                # Enforce gzip/deflate when Accept-Encoding header is not defined
+      #connectTimeout = 60000                     # Timeout when establishing a connection
+      #pooledConnectionIdleTimeout = 60000        # Timeout when a connection stays unused in the pool
+      #readTimeout = 60000                        # Timeout when a used connection stays idle
+      #connectionTTL = -1                         # Max duration a connection can stay open (-1 means no limit)
+      #ioThreadMultiplier = 2                     # Number of Netty worker threads per core
+      #maxConnectionsPerHost = -1                 # Max number of connections per host (-1 means no limit)
+      #maxConnections = -1                        # Max number of connections (-1 means no limit)
+      #maxRetry = 0                               # Number of times that a request should be tried again
+      #requestTimeout = 60000                     # Timeout of the requests
+      #useProxyProperties = false                 # When set to true, supports standard Proxy System properties
+      #webSocketTimeout = 60000                   # Timeout when a used websocket connection stays idle
+      #useRelativeURIsWithConnectProxies = true   # When set to true, use relative URIs when talking with an SSL proxy or a WebSocket proxy
+      #acceptAnyCertificate = true                # When set to true, doesn't validate SSL certificates
+      #httpClientCodecMaxInitialLineLength = 4096 # Maximum length of the initial line of the response (e.g. "HTTP/1.0 200 OK")
+      #httpClientCodecMaxHeaderSize = 8192        # Maximum size, in bytes, of each request's headers
+      #httpClientCodecMaxChunkSize = 8192         # Maximum length of the content or each chunk
+      #keepEncodingHeader = true                  # Don't drop Encoding response header after decoding
+      #webSocketMaxFrameSize = 10240              # Maximum frame payload size
+    }
+  }
+  data {
+    #writers = "console, file" # The lists of DataWriters to which Gatling write simulation data (currently supported : "console", "file", "graphite", "jdbc")
+    #reader = file             # The DataReader used by the charting engine for reading simulation results
+    console {
+      #light = false           # When set to true, displays a light version without detailed request stats
+    }
+    file {
+      #bufferSize = 8192       # FileDataWriter's internal data buffer size, in bytes
+    }
+    leak {
+      #noActivityTimeout = 30  # Period, in seconds, for which Gatling may have no activity before considering a leak may be happening
+    }
+    jdbc {
+      db {
+        #url = "jdbc:mysql://localhost:3306/temp" # The JDBC URL used by the JDBC DataWriter
+        #username = "root"                        # The database user used by the JDBC DataWriter
+        #password = "123123q"                     # The password for the specified user
+      }
+      #bufferSize = 20                            # The size for each batch of SQL inserts to send to the database
+      create {
+        #createRunRecordTable = "CREATE TABLE IF NOT EXISTS `RunRecords` ( `id` INT NOT NULL AUTO_INCREMENT , `runDate` DATETIME NULL , `simulationId` VARCHAR(45) NULL , `runDescription` VARCHAR(45) NULL , PRIMARY KEY (`id`) )"
+        #createRequestRecordTable = "CREATE TABLE IF NOT EXISTS `RequestRecords` (`id` int(11) NOT NULL AUTO_INCREMENT, `runId` int DEFAULT NULL, `scenario` varchar(45) DEFAULT NULL, `userId` VARCHAR(20) NULL, `name` varchar(50) DEFAULT NULL, `requestStartDate` bigint DEFAULT NULL, `requestEndDate` bigint DEFAULT NULL, `responseStartDate` bigint DEFAULT NULL, `responseEndDate` bigint DEFAULT NULL, `status` varchar(2) DEFAULT NULL, `message` varchar(4500) DEFAULT NULL, `responseTime` bigint DEFAULT NULL, PRIMARY KEY (`id`) )"
+        #createScenarioRecordTable = "CREATE TABLE IF NOT EXISTS `ScenarioRecords` (`id` int(11) NOT NULL AUTO_INCREMENT, `runId` int DEFAULT NULL, `scenarioName` varchar(45) DEFAULT NULL, `userId` VARCHAR(20) NULL, `event` varchar(50) DEFAULT NULL, `startDate` bigint DEFAULT NULL, `endDate` bigint DEFAULT NULL, PRIMARY KEY (`id`) )"
+        #createGroupRecordTable = "CREATE TABLE IF NOT EXISTS `GroupRecords` (`id` int(11) NOT NULL AUTO_INCREMENT, `runId` int DEFAULT NULL, `scenarioName` varchar(45) DEFAULT NULL, `userId` VARCHAR(20) NULL, `entryDate` bigint DEFAULT NULL, `exitDate` bigint DEFAULT NULL, `status` varchar(2) DEFAULT NULL, PRIMARY KEY (`id`) )"
+      }
+      insert {
+        #insertRunRecord = "INSERT INTO RunRecords (runDate, simulationId, runDescription) VALUES (?,?,?)"
+        #insertRequestRecord = "INSERT INTO RequestRecords (runId, scenario, userId, name, requestStartDate, requestEndDate, responseStartDate, responseEndDate, status, message, responseTime) VALUES (?,?,?,?,?,?,?,?,?,?,?)"
+        #insertScenarioRecord = "INSERT INTO ScenarioRecords (runId, scenarioName, userId, event, startDate, endDate) VALUES (?,?,?,?,?,?)"
+        #insertGroupRecord = "INSERT INTO GroupRecords (runId, scenarioName, userId, entryDate, exitDate, status) VALUES (?,?,?,?,?,?)"
+      }
+    }
+    graphite {
+      #light = false              # only send the all* stats
+      #host = "localhost"         # The host where the Carbon server is located
+      #port = 2003                # The port to which the Carbon server listens to
+      #protocol = "tcp"           # The protocol used to send data to Carbon (currently supported : "tcp", "udp")
+      #rootPathPrefix = "gatling" # The common prefix of all metrics sent to Graphite
+      #bufferSize = 8192          # GraphiteDataWriter's internal data buffer size, in bytes
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/test/resources/logback.xml b/stack/loadtests/src/test/resources/logback.xml
new file mode 100644
index 0000000..f112f98
--- /dev/null
+++ b/stack/loadtests/src/test/resources/logback.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+
+	<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+		<encoder>
+			<pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
+			<immediateFlush>false</immediateFlush>
+		</encoder>
+	</appender>
+
+	<!-- Uncomment for logging ALL HTTP request and responses -->
+	 	<logger name="io.gatling.http.ahc.AsyncHandlerActor" level="TRACE" />
+	<!-- Uncomment for logging ONLY FAILED HTTP request and responses -->
+	 	<!--<logger name="io.gatling.http.ahc.AsyncHandlerActor" level="DEBUG" />-->
+
+	<root level="WARN">
+		<appender-ref ref="CONSOLE" />
+	</root>
+
+</configuration>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/test/resources/recorder.conf
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/test/resources/recorder.conf b/stack/loadtests/src/test/resources/recorder.conf
new file mode 100644
index 0000000..6c2366e
--- /dev/null
+++ b/stack/loadtests/src/test/resources/recorder.conf
@@ -0,0 +1,37 @@
+recorder {
+  core {
+    #encoding = "utf-8"               # The encoding used for reading/writing request bodies and the generated simulation
+    #outputFolder = ""                # The folder where generated simulation will we written
+    #package = ""                     # The package's name of the generated simulation
+    #className = "RecordedSimulation" # The name of the generated Simulation class
+    #thresholdForPauseCreation = 100  # The minimum time, in milliseconds, that must pass between requests to trigger a pause creation
+    #saveConfig = false               # When set to true, the configuration from the Recorder GUI overwrites this configuration
+  }
+  filters {
+    #filterStrategy = "Disabled" # The selected filter resources filter strategy (currently supported : "Disabled", "BlackList", "WhiteList")
+    #whitelist = []              # The list of ressources patterns that are part of the Recorder's whitelist
+    #blacklist = []              # The list of ressources patterns that are part of the Recorder's blacklist
+  }
+  http {
+    #automaticReferer = true       # When set to false, write the referer + enable 'disableAutoReferer' in the generated simulation
+    #followRedirect = true         # When set to false, write redirect requests + enable 'disableFollowRedirect' in the generated simulation
+    #removeConditionalCache = true # When set to true, removes from the generated requests headers leading to request caching
+    #inferHtmlResources = true     # When set to true, add inferred resources + set 'inferHtmlResources' with the configured blacklist/whitelist in the generated simulation
+  }
+  proxy {
+    #port = 8000     # Local port used by Gatling's Proxy for HTTP/HTTPS
+    outgoing {
+      #host = ""     # The outgoing proxy's hostname
+      #username = "" # The username to use to connect to the outgoing proxy
+      #password = "" # The password corresponding to the user to use to connect to the outgoing proxy
+      #port = 0      # The HTTP port to use to connect to the outgoing proxy
+      #sslPort = 0   # If set, The HTTPS port to use to connect to the outgoing proxy
+    }
+  }
+  netty {
+    #maxInitialLineLength = 10000 # Maximum length of the initial line of the response (e.g. "HTTP/1.0 200 OK")
+    #maxHeaderSize = 20000        # Maximum size, in bytes, of each request's headers
+    #maxChunkSize = 8192          # Maximum length of the content or each chunk
+    #maxContentLength = 100000000 # Maximum length of the aggregated content of each response
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/test/scala/Engine.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/test/scala/Engine.scala b/stack/loadtests/src/test/scala/Engine.scala
new file mode 100644
index 0000000..b6dfa44
--- /dev/null
+++ b/stack/loadtests/src/test/scala/Engine.scala
@@ -0,0 +1,16 @@
+import io.gatling.app.Gatling
+import io.gatling.core.config.GatlingPropertiesBuilder
+
+object Engine extends App {
+
+	val props = new GatlingPropertiesBuilder
+	props.disableCompiler
+	props.dataDirectory(IDEPathHelper.dataDirectory.toString)
+	props.resultsDirectory(IDEPathHelper.resultsDirectory.toString)
+	props.requestBodiesDirectory(IDEPathHelper.requestBodiesDirectory.toString)
+	props.binariesDirectory(IDEPathHelper.mavenBinariesDirectory.toString)
+
+  props.simulationClass("org.apache.usergrid.simulations.PushNotificationTargetUserSimulation")
+
+	Gatling.fromMap(props.build)
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/test/scala/IDEPathHelper.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/test/scala/IDEPathHelper.scala b/stack/loadtests/src/test/scala/IDEPathHelper.scala
new file mode 100644
index 0000000..988b616
--- /dev/null
+++ b/stack/loadtests/src/test/scala/IDEPathHelper.scala
@@ -0,0 +1,21 @@
+import scala.tools.nsc.io.File
+import scala.tools.nsc.io.Path.string2path
+
+object IDEPathHelper {
+
+	val gatlingConfUrl = getClass.getClassLoader.getResource("gatling.conf").getPath
+	val projectRootDir = File(gatlingConfUrl).parents(2)
+
+	val mavenSourcesDirectory = projectRootDir / "src" / "test" / "scala"
+	val mavenResourcesDirectory = projectRootDir / "src" / "test" / "resources"
+	val mavenTargetDirectory = projectRootDir / "target"
+	val mavenBinariesDirectory = mavenTargetDirectory / "test-classes"
+
+	val dataDirectory = mavenResourcesDirectory / "data"
+	val requestBodiesDirectory = mavenResourcesDirectory / "request-bodies"
+
+	val recorderOutputDirectory = mavenSourcesDirectory
+	val resultsDirectory = mavenTargetDirectory / "results"
+
+	val recorderConfigFile = (mavenResourcesDirectory / "recorder.conf").toFile
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6149bf13/stack/loadtests/src/test/scala/Recorder.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/test/scala/Recorder.scala b/stack/loadtests/src/test/scala/Recorder.scala
new file mode 100644
index 0000000..b132063
--- /dev/null
+++ b/stack/loadtests/src/test/scala/Recorder.scala
@@ -0,0 +1,12 @@
+import io.gatling.recorder.config.RecorderPropertiesBuilder
+import io.gatling.recorder.controller.RecorderController
+
+object Recorder extends App {
+
+	val props = new RecorderPropertiesBuilder
+	props.simulationOutputFolder(IDEPathHelper.recorderOutputDirectory.toString)
+	props.simulationPackage("org.apache.usergrid")
+	props.requestBodiesFolder(IDEPathHelper.requestBodiesDirectory.toString)
+
+	RecorderController(props.build, Some(IDEPathHelper.recorderConfigFile))
+}
\ No newline at end of file


[29/45] git commit: remove unneeded refs

Posted by to...@apache.org.
remove unneeded refs


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

Branch: refs/heads/key-row-sharding
Commit: 8bd1ab46f230c3ab7e28a9c2c295844735e28ff5
Parents: 0f4584c
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Oct 29 10:01:02 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Oct 29 10:01:02 2014 -0600

----------------------------------------------------------------------
 .../services/notifiers/NotifiersService.java       | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8bd1ab46/stack/services/src/main/java/org/apache/usergrid/services/notifiers/NotifiersService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifiers/NotifiersService.java b/stack/services/src/main/java/org/apache/usergrid/services/notifiers/NotifiersService.java
index ae089fe..3e9ca3e 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifiers/NotifiersService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifiers/NotifiersService.java
@@ -16,22 +16,14 @@
  */
 package org.apache.usergrid.services.notifiers;
 
-import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.entities.Notifier;
 import org.apache.usergrid.services.notifications.ProviderAdapterFactory;
-import org.apache.usergrid.services.notifications.TestAdapter;
-import org.apache.usergrid.services.notifications.apns.APNsAdapter;
-import org.apache.usergrid.services.notifications.gcm.GCMAdapter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.usergrid.services.*;
 import org.apache.usergrid.services.notifications.NotificationsService;
 import org.apache.usergrid.services.notifications.ProviderAdapter;
-
 import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
 
 public class NotifiersService extends AbstractCollectionService {
 
@@ -46,15 +38,7 @@ public class NotifiersService extends AbstractCollectionService {
     @Override
     public ServiceResults postCollection(ServiceContext context)
             throws Exception {
-
         ServicePayload payload = context.getPayload();
-
-        NotificationsService ns = (NotificationsService) sm
-                .getService("notifications");
-
-        String provider = payload.getStringProperty("provider");
-
-
         ServiceResults results = super.postCollection(context);
         Notifier notifier = (Notifier) results.getEntity();
         if (notifier != null) {
@@ -66,6 +50,7 @@ public class NotifiersService extends AbstractCollectionService {
                             + Arrays.toString(ProviderAdapterFactory.getValidProviders()));
                 }
                 providerAdapter.validateCreateNotifier(payload);
+                NotificationsService ns = (NotificationsService) sm.getService("notifications");
                 ns.testConnection(notifier);
             } catch (Exception e) {
                 logger.info("notifier testConnection() failed", e);


[10/45] git commit: fix failure sqs message

Posted by to...@apache.org.
fix failure sqs message


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

Branch: refs/heads/key-row-sharding
Commit: 990786392acf9818cfaf09cf649cea8053279945
Parents: e30a7b3
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Oct 27 15:27:07 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Oct 27 15:27:07 2014 -0600

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


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/99078639/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SQSQueueManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SQSQueueManagerImpl.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SQSQueueManagerImpl.java
index 313b4d7..888370c 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SQSQueueManagerImpl.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SQSQueueManagerImpl.java
@@ -205,7 +205,7 @@ public class SQSQueueManagerImpl implements QueueManager {
         }
         DeleteMessageBatchRequest request = new DeleteMessageBatchRequest(url,entries);
         DeleteMessageBatchResult result = sqs.deleteMessageBatch(request);
-        boolean successful = result.getFailed().size() > 0;
+        boolean successful = result.getFailed().size() <= 0;
         if(!successful){
             LOG.error("Commit failed {} messages", result.getFailed().size());
         }


[18/45] git commit: log failure

Posted by to...@apache.org.
log failure


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

Branch: refs/heads/key-row-sharding
Commit: bb25b5b38be755c4183b803189183ff953a712c1
Parents: 45d3ce4
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Oct 27 17:54:01 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Oct 27 17:54:01 2014 -0600

----------------------------------------------------------------------
 .../usergrid/persistence/queue/impl/SQSQueueManagerImpl.java     | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bb25b5b3/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SQSQueueManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SQSQueueManagerImpl.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SQSQueueManagerImpl.java
index 888370c..8c8ffff 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SQSQueueManagerImpl.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SQSQueueManagerImpl.java
@@ -207,7 +207,9 @@ public class SQSQueueManagerImpl implements QueueManager {
         DeleteMessageBatchResult result = sqs.deleteMessageBatch(request);
         boolean successful = result.getFailed().size() <= 0;
         if(!successful){
-            LOG.error("Commit failed {} messages", result.getFailed().size());
+            for( BatchResultErrorEntry failed : result.getFailed()) {
+                LOG.error("Commit failed reason: {} messages id: {}", failed.getMessage(),failed.getId());
+            }
         }
     }
 


[36/45] git commit: fix gcm batching

Posted by to...@apache.org.
fix gcm batching


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

Branch: refs/heads/key-row-sharding
Commit: ca78792686f1cd06c984045d4a27921009134866
Parents: a62df3a
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Oct 29 11:44:51 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Oct 29 11:44:51 2014 -0600

----------------------------------------------------------------------
 .../services/notifications/gcm/GCMAdapter.java  | 24 +++++++++++---------
 1 file changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ca787926/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 e0b32ee..e5867ea 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
@@ -16,6 +16,7 @@
  */
 package org.apache.usergrid.services.notifications.gcm;
 
+import com.clearspring.analytics.hash.MurmurHash;
 import com.google.android.gcm.server.*;
 import org.apache.usergrid.persistence.entities.Notification;
 import org.apache.usergrid.persistence.entities.Notifier;
@@ -34,6 +35,8 @@ 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 {
 
@@ -43,11 +46,12 @@ public class GCMAdapter implements ProviderAdapter {
     private final Notifier notifier;
     private EntityManager entityManager;
 
-    private Map<Notifier, Batch> notifierBatches = new HashMap<>();
+    private ConcurrentHashMap<Long,Batch> batches;
 
     public GCMAdapter(EntityManager entityManager,Notifier notifier){
         this.notifier = notifier;
         this.entityManager = entityManager;
+        batches = new ConcurrentHashMap<>();
     }
     @Override
     public void testConnection() throws ConnectionException {
@@ -62,8 +66,7 @@ public class GCMAdapter implements ProviderAdapter {
     }
 
     @Override
-    public void sendNotification(String providerId,
-            Object payload, Notification notification, TaskTracker tracker)
+    public void sendNotification(String providerId, Object payload, Notification notification, TaskTracker tracker)
             throws Exception {
         Map<String,Object> map = (Map<String, Object>) payload;
         final String expiresKey = "time_to_live";
@@ -77,17 +80,18 @@ public class GCMAdapter implements ProviderAdapter {
     }
 
     synchronized private Batch getBatch( Map<String, Object> payload) {
-        Batch batch = notifierBatches.get(notifier);
+        long hash = MurmurHash.hash64(payload);
+        Batch batch = batches.get(hash);
         if (batch == null && payload != null) {
-            batch = new Batch(notifier, payload);
-            notifierBatches.put(notifier, batch);
+            batch = new Batch(notifier,payload);
+            batches.put(hash,batch);
         }
         return batch;
     }
 
     @Override
     synchronized public void doneSendingNotifications() throws Exception {
-        for (Batch batch : notifierBatches.values()) {
+        for (Batch batch : batches.values()) {
             batch.send();
         }
     }
@@ -95,9 +99,8 @@ public class GCMAdapter implements ProviderAdapter {
     @Override
     public void removeInactiveDevices( ) throws Exception {
         Batch batch = getBatch( null);
-        Map<String,Date> map = null;
         if(batch != null) {
-            map = batch.getAndClearInactiveDevices();
+            Map<String,Date> map = batch.getAndClearInactiveDevices();
             InactiveDeviceManager deviceManager = new InactiveDeviceManager(notifier,entityManager);
             deviceManager.removeInactiveDevices(map);
         }
@@ -147,7 +150,7 @@ public class GCMAdapter implements ProviderAdapter {
         private List<TaskTracker> trackers;
         private Map<String, Date> inactiveDevices = new HashMap<String, Date>();
 
-        Batch(Notifier notifier, Map<String, Object> payload) {
+        Batch(Notifier notifier, Map<String,Object> payload) {
             this.notifier = notifier;
             this.payload = payload;
             this.ids = new ArrayList<String>();
@@ -163,7 +166,6 @@ public class GCMAdapter implements ProviderAdapter {
         synchronized void add(String id, TaskTracker tracker) throws Exception {
             ids.add(id);
             trackers.add(tracker);
-
             if (ids.size() == BATCH_SIZE) {
                 send();
             }


[35/45] git commit: remove em

Posted by to...@apache.org.
remove em


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

Branch: refs/heads/key-row-sharding
Commit: a62df3a317e0a4d4b100e73025959396d6f30710
Parents: c51c0ce
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Oct 29 11:13:48 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Oct 29 11:13:48 2014 -0600

----------------------------------------------------------------------
 .../java/org/apache/usergrid/persistence/entities/Notifier.java   | 3 ---
 1 file changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a62df3a3/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java
index 819ccde..1de2753 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java
@@ -18,7 +18,6 @@ package org.apache.usergrid.persistence.entities;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.TypedEntity;
 import org.apache.usergrid.persistence.annotations.EntityProperty;
 
@@ -35,8 +34,6 @@ public class Notifier extends TypedEntity {
 
     public static final String ENTITY_TYPE = "notifier";
 
-    protected EntityManager entityManager;
-
     @EntityProperty(aliasProperty = true, unique = true, basic = true)
     protected String name;
 


[11/45] git commit: add config for inactive dev retrieval

Posted by to...@apache.org.
add config for inactive dev retrieval


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

Branch: refs/heads/key-row-sharding
Commit: f3343f1f8561ddc36c632e665ef8706163bbbcd0
Parents: 9907863
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Oct 27 15:33:49 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Oct 27 15:33:49 2014 -0600

----------------------------------------------------------------------
 .../services/notifications/QueueListener.java       | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f3343f1f/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
index 48c110b..286daf1 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
@@ -64,7 +64,7 @@ public class QueueListener  {
 
     private long sleepWhenNoneFound = 0;
 
-    private long sleepBetweenRuns = 5000;
+    private long sleepBetweenRuns = 0;
 
     private ExecutorService pool;
     private List<Future> futures;
@@ -73,6 +73,7 @@ public class QueueListener  {
     private Integer batchSize = 10;
     private String queueName;
     public QueueManager TEST_QUEUE_MANAGER;
+    private int consecutiveCallsToRemoveDevices;
 
     public QueueListener(ServiceManagerFactory smf, EntityManagerFactory emf, MetricsFactory metricsService, Properties props){
         this.queueManagerFactory = CpSetup.getInjector().getInstance(QueueManagerFactory.class);
@@ -93,12 +94,14 @@ public class QueueListener  {
             int threadCount = 0;
 
             try {
-                sleepBetweenRuns = new Long(properties.getProperty("usergrid.notifications.listener.sleep.between", "0")).longValue();
+                sleepBetweenRuns = new Long(properties.getProperty("usergrid.notifications.listener.sleep.between", ""+sleepBetweenRuns)).longValue();
                 sleepWhenNoneFound = new Long(properties.getProperty("usergrid.notifications.listener.sleep.after", ""+DEFAULT_SLEEP)).longValue();
                 batchSize = new Integer(properties.getProperty("usergrid.notifications.listener.batchSize", (""+batchSize)));
                 queueName = ApplicationQueueManager.getQueueNames(properties);
 
                 int maxThreads = new Integer(properties.getProperty("usergrid.notifications.listener.maxThreads", ""+MAX_THREADS));
+                consecutiveCallsToRemoveDevices = new Integer(properties.getProperty("usergrid.notifications.inactive.interval", ""+100));
+
                 futures = new ArrayList<Future>(maxThreads);
 
                 //create our thread pool based on our threadcount.
@@ -154,7 +157,6 @@ public class QueueListener  {
                 LOG.info("retrieved batch of {} messages from queue {} ", messages.size(),queueName);
 
                 if (messages.size() > 0) {
-                    runCount++;
                     HashMap<UUID, List<QueueMessage>> messageMap = new HashMap<>(messages.size());
                     //group messages into hash map by app id
                     for (QueueMessage message : messages) {
@@ -207,9 +209,13 @@ public class QueueListener  {
                         LOG.info("sleep between rounds...sleep...{}", sleepBetweenRuns);
                         Thread.sleep(sleepBetweenRuns);
                     }
-                    if(runCount % 100 == 0){
+                    if(runCount++ % consecutiveCallsToRemoveDevices == 0){
                         for(ApplicationQueueManager applicationQueueManager : queueManagerMap.values()){
-                            applicationQueueManager.asyncCheckForInactiveDevices();
+                            try {
+                                applicationQueueManager.asyncCheckForInactiveDevices();
+                            }catch (Exception inactiveDeviceException){
+                                LOG.error("Inactive Device Get failed",inactiveDeviceException);
+                            }
                         }
                         //clear everything
                         queueManagerMap.clear();


[12/45] git commit: changed push load test to use user uuid instead of username; improved error handling for when user already exists; updated loadtest pom to call pushNotificationTargetUserSimulation instead of PushNotificationTargetDeviceSimulation

Posted by to...@apache.org.
changed push load test to use user uuid instead of username; improved error handling for when user already exists; updated loadtest pom to call pushNotificationTargetUserSimulation instead of PushNotificationTargetDeviceSimulation


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

Branch: refs/heads/key-row-sharding
Commit: 0eda724ffd61c511f7de72317baaa1ad6911ca14
Parents: 6149bf1
Author: amuramoto <am...@apigee.com>
Authored: Mon Oct 27 15:49:31 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Mon Oct 27 15:49:31 2014 -0700

----------------------------------------------------------------------
 stack/loadtests/pom.xml                         |  2 +-
 .../scenarios/NotificationScenarios.scala       |  2 +-
 .../usergrid/scenarios/UserScenarios.scala      | 23 +++++++++-----------
 .../PushNotificationTargetUserSimulation.scala  |  2 +-
 4 files changed, 13 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0eda724f/stack/loadtests/pom.xml
----------------------------------------------------------------------
diff --git a/stack/loadtests/pom.xml b/stack/loadtests/pom.xml
index 0fa6272..0a2f4de 100644
--- a/stack/loadtests/pom.xml
+++ b/stack/loadtests/pom.xml
@@ -131,7 +131,7 @@
 				<artifactId>gatling-maven-plugin</artifactId>
         <configuration>
           <simulationsFolder>src/main/scala</simulationsFolder>
-          <simulationClass>org.apache.usergrid.simulations.PushNotificationTargetDeviceSimulation</simulationClass>
+          <simulationClass>org.apache.usergrid.simulations.PushNotificationTargetUserSimulation</simulationClass>
         </configuration>
 
 			</plugin>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0eda724f/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
index dad4cae..ab4d813 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
@@ -59,7 +59,7 @@ object NotificationScenarios {
     )
 
   val sendNotificationToUser= exec(http("Send Notification to All Devices")
-    .post("/users/${username}/notifications")
+    .post("/users/${userId}/notifications")
     .body(StringBody("{\"debug\":\"true\",\"payloads\":{\"" + notifier + "\":\"testmessage\"}}"))
     .check(status.is(200))
   )

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0eda724f/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
index ff96714..a2fa227 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
@@ -30,24 +30,21 @@ import io.gatling.core.Predef._
       .check(status.is(200))
   )
 
-  val postUser = exec(
-    http("POST geolocated Users")
-      .post("/users")
-      .body(new StringBody("""{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
-      "displayName":"${displayName}","age":"${age}","seen":"${seen}","weight":"${weight}",
-      "height":"${height}","aboutMe":"${aboutMe}","profileId":"${profileId}","headline":"${headline}","
-      "showAge":"${showAge}","relationshipStatus":"${relationshipStatus}","ethnicity":"${ethnicity}","password":"password"}"""))
-      .check(status.is(200))
-  )
+   val getUserByUsername = exec(
+     http("GET user")
+       .get("/users/${username}")
+       .check(status.is(200), jsonPath("$..entities[0].uuid").saveAs("userId"))
+   )
 
-  val postUser400ok = exec(
+  val postUser = exec(
     http("POST geolocated Users")
       .post("/users")
       .body(new StringBody("""{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
       "displayName":"${displayName}","age":"${age}","seen":"${seen}","weight":"${weight}",
       "height":"${height}","aboutMe":"${aboutMe}","profileId":"${profileId}","headline":"${headline}",
       "showAge":"${showAge}","relationshipStatus":"${relationshipStatus}","ethnicity":"${ethnicity}","password":"password"}"""))
-      .check(status.in(200 to 400))
-  )
-
+      .check(status.is(200), status.saveAs("userStatus"), jsonPath("$..entities[0].uuid").saveAs("userId")))
+    .doIf ("${userStatus}", "400") {
+      exec(getUserByUsername)
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0eda724f/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala
index 9391160..af95f8b 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala
@@ -38,7 +38,7 @@ class PushNotificationTargetUserSimulation extends Simulation {
   val createNotifier = NotifierScenarios.createNotifier
   val createDevice = DeviceScenarios.postDeviceWithNotifier
   val sendNotification = NotificationScenarios.sendNotificationToUser
-  val createUser = UserScenarios.postUser400ok
+  val createUser = UserScenarios.postUser
   val createOrg = OrganizationScenarios.createOrgAndAdmin
   val connectUserToDevice = ConnectionScenarios.postUserToDeviceConnection
 


[30/45] git commit: add comments

Posted by to...@apache.org.
add comments


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

Branch: refs/heads/key-row-sharding
Commit: 25e36e69cfe9911eb385546b5042864fd3a7e69e
Parents: 8bd1ab4
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Oct 29 10:25:39 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Oct 29 10:25:39 2014 -0600

----------------------------------------------------------------------
 .../usergrid/persistence/queue/impl/QueueScopeFactoryImpl.java | 2 +-
 .../services/notifications/ApplicationQueueManager.java        | 6 +++++-
 .../usergrid/services/notifications/InactiveDeviceManager.java | 2 +-
 .../services/notifications/ProviderAdapterFactory.java         | 2 +-
 .../apache/usergrid/services/notifications/gcm/GCMAdapter.java | 2 +-
 5 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/25e36e69/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeFactoryImpl.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeFactoryImpl.java
index 92ed075..2f8c43f 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeFactoryImpl.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueScopeFactoryImpl.java
@@ -29,7 +29,7 @@ import org.apache.usergrid.persistence.queue.QueueScopeFactory;
 import java.util.UUID;
 
 /**
- * Classy class class.
+ * Returns scope for queues.
  */
 public class QueueScopeFactoryImpl implements QueueScopeFactory {
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/25e36e69/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
index 11b197c..1058c34 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
@@ -390,7 +390,11 @@ public class ApplicationQueueManager  {
 
     public void stop(){
         for(ProviderAdapter adapter : getNotifierMap().values()){
-            adapter.stop();
+            try {
+                adapter.stop();
+            }catch (Exception e){
+                LOG.error("failed to stop adapter",e);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/25e36e69/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
index c54a595..82841d2 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
@@ -33,7 +33,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 /**
- * Classy class class.
+ * remove inactive devices.
  */
 public class InactiveDeviceManager {
     private static final Logger LOG = LoggerFactory.getLogger(InactiveDeviceManager.class);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/25e36e69/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
index a4022c1..ea42480 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
@@ -28,7 +28,7 @@ import org.apache.usergrid.services.notifications.gcm.GCMAdapter;
 import java.util.HashMap;
 
 /**
- * Classy class class.
+ * Get valid provideradapters
  */
 public class ProviderAdapterFactory {
     private static final String[] providers =  new String[]{"apple", "google", "noop"};

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/25e36e69/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 b65b25a..e0b32ee 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
@@ -43,7 +43,7 @@ public class GCMAdapter implements ProviderAdapter {
     private final Notifier notifier;
     private EntityManager entityManager;
 
-    private Map<Notifier, Batch> notifierBatches = new HashMap<Notifier, Batch>();
+    private Map<Notifier, Batch> notifierBatches = new HashMap<>();
 
     public GCMAdapter(EntityManager entityManager,Notifier notifier){
         this.notifier = notifier;


[25/45] git commit: Add a short-term cache to avoid redundant Entity reloading in CpEntityManager & CpRelationManager.

Posted by to...@apache.org.
Add a short-term cache to avoid redundant Entity reloading in CpEntityManager & CpRelationManager.


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

Branch: refs/heads/key-row-sharding
Commit: c57196546f8c278b3eda3789015caa26d0c45229
Parents: 3d3f189
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Oct 29 10:38:14 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Oct 29 10:38:14 2014 -0400

----------------------------------------------------------------------
 .../main/resources/usergrid-default.properties  |  3 +
 .../corepersistence/CpEntityManager.java        | 73 +++++++++++++++++---
 .../corepersistence/CpRelationManager.java      | 31 +++++----
 .../persistence/index/query/EntityResults.java  |  6 +-
 4 files changed, 87 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c5719654/stack/config/src/main/resources/usergrid-default.properties
----------------------------------------------------------------------
diff --git a/stack/config/src/main/resources/usergrid-default.properties b/stack/config/src/main/resources/usergrid-default.properties
index a4760dd..fb043d4 100644
--- a/stack/config/src/main/resources/usergrid-default.properties
+++ b/stack/config/src/main/resources/usergrid-default.properties
@@ -62,6 +62,9 @@ elasticsearch.port=9300
 
 index.query.limit.default=1000
 
+usergrid.entity_cache_size=200
+usergrid.entity_cache_timeout_ms=500
+
 
 ###############################################################################
 #

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c5719654/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index c9ad87b..78c9433 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -17,6 +17,10 @@ package org.apache.usergrid.corepersistence;
 
 
 import com.google.common.base.Preconditions;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
+import com.google.common.cache.LoadingCache;
 import com.netflix.hystrix.exception.HystrixRuntimeException;
 import com.yammer.metrics.annotation.Metered;
 import static java.lang.String.CASE_INSENSITIVE_ORDER;
@@ -37,6 +41,8 @@ import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
 import me.prettyprint.hector.api.Keyspace;
 import me.prettyprint.hector.api.beans.ColumnSlice;
 import me.prettyprint.hector.api.beans.CounterRow;
@@ -86,10 +92,8 @@ import static org.apache.usergrid.persistence.Schema.PROPERTY_TYPE;
 import static org.apache.usergrid.persistence.Schema.PROPERTY_UUID;
 import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
 import static org.apache.usergrid.persistence.Schema.TYPE_ENTITY;
-import static org.apache.usergrid.persistence.Schema.getDefaultSchema;
 import org.apache.usergrid.persistence.SimpleEntityRef;
 import static org.apache.usergrid.persistence.SimpleEntityRef.getUuid;
-import static org.apache.usergrid.persistence.SimpleEntityRef.ref;
 import org.apache.usergrid.persistence.SimpleRoleRef;
 import org.apache.usergrid.persistence.TypedEntity;
 import org.apache.usergrid.persistence.cassandra.ApplicationCF;
@@ -131,7 +135,6 @@ import org.apache.usergrid.persistence.index.query.CounterResolution;
 import org.apache.usergrid.persistence.index.query.Identifier;
 import org.apache.usergrid.persistence.index.query.Query;
 import org.apache.usergrid.persistence.index.query.Query.Level;
-import static org.apache.usergrid.persistence.index.query.Query.Level.REFS;
 import org.apache.usergrid.persistence.map.MapManager;
 import org.apache.usergrid.persistence.map.MapScope;
 import org.apache.usergrid.persistence.map.impl.MapScopeImpl;
@@ -140,7 +143,6 @@ import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.model.field.Field;
 import org.apache.usergrid.persistence.model.field.StringField;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.apache.usergrid.persistence.schema.CollectionInfo;
 import org.apache.usergrid.utils.ClassUtils;
 import static org.apache.usergrid.utils.ClassUtils.cast;
 import org.apache.usergrid.utils.CompositeUtils;
@@ -185,6 +187,9 @@ public class CpEntityManager implements EntityManager {
 
     private String TYPES_BY_UUID_MAP = "zzz_typesbyuuid_zzz";
 
+    /** Short-term cache to keep us from reloading same Entity during single request. */
+    private LoadingCache<EntityScope, org.apache.usergrid.persistence.model.entity.Entity> entityCache;
+
 
     public CpEntityManager() {}
 
@@ -206,6 +211,56 @@ public class CpEntityManager implements EntityManager {
 
         // set to false for now
         this.skipAggregateCounters = false;
+
+        int entityCacheSize = Integer.parseInt( 
+            cass.getProperties().getProperty("usergrid.entity_cache_size", "100"));
+
+        int entityCacheTimeout = Integer.parseInt( 
+            cass.getProperties().getProperty("usergrid.entity_cache_timeout_ms", "500"));
+
+        this.entityCache = CacheBuilder.newBuilder()
+            .maximumSize( entityCacheSize )
+            .expireAfterWrite( entityCacheTimeout, TimeUnit.MILLISECONDS )
+            .build( new CacheLoader<EntityScope, org.apache.usergrid.persistence.model.entity.Entity>() {
+                public org.apache.usergrid.persistence.model.entity.Entity load( EntityScope entityScope ) { 
+                    return managerCache.getEntityCollectionManager( 
+                        entityScope.scope ).load( entityScope.entityId ).toBlocking().lastOrDefault(null);
+                }
+            }
+        );
+    }
+
+
+    /** Needed to support short-term Entity cache. */ 
+    public static class EntityScope {
+        CollectionScope scope;
+        Id entityId;
+        public EntityScope( CollectionScope scope, Id entityId ) {
+            this.scope = scope;
+            this.entityId = entityId;
+        }
+    }
+
+
+    /**
+     * Load entity from short-term cache. 
+     * Package scope so that CpRelationManager can use it too.
+     * 
+     * @param es Carries Entity Id and CollectionScope from which to load Entity.
+     * @return Entity or null if not found
+     */
+    org.apache.usergrid.persistence.model.entity.Entity load( EntityScope es ) {
+        try {
+            return entityCache.get( es );
+            
+        } catch ( InvalidCacheLoadException icle ) { 
+            // fine, entity not found
+            return null;
+
+        } catch ( ExecutionException exex ) { 
+            // uh-oh, more serious problem
+            throw new RuntimeException( "Error loading entity", exex );
+        }
     }
 
 
@@ -320,7 +375,7 @@ public class CpEntityManager implements EntityManager {
 //        }
 
        org.apache.usergrid.persistence.model.entity.Entity cpEntity = 
-                ecm.load( id ).toBlockingObservable().last();
+               load( new EntityScope( collectionScope, id ) );
 
         if ( cpEntity == null ) {
             if ( logger.isDebugEnabled() ) {
@@ -407,7 +462,7 @@ public class CpEntityManager implements EntityManager {
 //        }
 
         org.apache.usergrid.persistence.model.entity.Entity cpEntity = 
-                ecm.load( id ).toBlocking().last();
+            load( new EntityScope( collectionScope, id ) );
 
         if ( cpEntity == null ) {
             if ( logger.isDebugEnabled() ) {
@@ -497,6 +552,8 @@ public class CpEntityManager implements EntityManager {
 
         try {
             cpEntity = ecm.update( cpEntity ).toBlockingObservable().last();
+
+            // need to reload entity so bypass entity cache
             cpEntity = ecm.load( entityId ).toBlockingObservable().last();
 
             logger.debug("Wrote {}:{} version {}", new Object[] { 
@@ -545,7 +602,7 @@ public class CpEntityManager implements EntityManager {
 //        }
 
         org.apache.usergrid.persistence.model.entity.Entity entity = 
-                ecm.load( entityId ).toBlockingObservable().last();
+            load( new EntityScope( collectionScope, entityId ) );
 
         if ( entity != null ) {
 
@@ -996,7 +1053,7 @@ public class CpEntityManager implements EntityManager {
 //        }
 
         org.apache.usergrid.persistence.model.entity.Entity cpEntity =
-                ecm.load( entityId ).toBlocking().last();
+            load( new EntityScope( collectionScope, entityId ) );
 
         cpEntity.removeField( propertyName );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c5719654/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 d0da90f..1e8dcc3 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
@@ -234,9 +234,9 @@ public class CpRelationManager implements RelationManager {
                 } );
         }
 
-        //TODO PERFORMANCE why are we loading this again here?
-        this.cpHeadEntity = ecm.load( new SimpleId( 
-            headEntity.getUuid(), headEntity.getType() )).toBlocking().lastOrDefault(null);
+        Id entityId = new SimpleId( headEntity.getUuid(), headEntity.getType() );
+        this.cpHeadEntity = ((CpEntityManager)em).load( 
+            new CpEntityManager.EntityScope( headEntityScope, entityId));
 
         // commented out because it is possible that CP entity has not been created yet
         Assert.notNull( cpHeadEntity, "cpHeadEntity cannot be null" );
@@ -626,12 +626,12 @@ public class CpRelationManager implements RelationManager {
                 applicationScope.getApplication(),
                 applicationScope.getApplication(),
                 CpNamingUtils.getCollectionScopeNameFromEntityType( itemRef.getType() ) );
-
         EntityCollectionManager memberMgr = managerCache.getEntityCollectionManager( memberScope );
 
         //TODO, this double load should disappear once events are in
-        org.apache.usergrid.persistence.model.entity.Entity memberEntity = memberMgr.load( 
-                new SimpleId( itemRef.getUuid(), itemRef.getType() ) ).toBlocking().last();
+        Id entityId = new SimpleId( itemRef.getUuid(), itemRef.getType() ); 
+        org.apache.usergrid.persistence.model.entity.Entity memberEntity = 
+            ((CpEntityManager)em).load( new CpEntityManager.EntityScope( memberScope, entityId));
 
         if ( memberEntity == null ) {
             throw new RuntimeException(
@@ -796,8 +796,9 @@ public class CpRelationManager implements RelationManager {
                });
         }
 
-        org.apache.usergrid.persistence.model.entity.Entity memberEntity = memberMgr.load( 
-            new SimpleId( itemRef.getUuid(), itemRef.getType() ) ).toBlockingObservable().last();
+        Id entityId = new SimpleId( itemRef.getUuid(), itemRef.getType() ); 
+        org.apache.usergrid.persistence.model.entity.Entity memberEntity = 
+            ((CpEntityManager)em).load( new CpEntityManager.EntityScope( memberScope, entityId));
 
         final EntityIndex ei = managerCache.getEntityIndex( applicationScope );
         final EntityIndexBatch batch = ei.createBatch();
@@ -1015,9 +1016,9 @@ public class CpRelationManager implements RelationManager {
             });
         }
 
-        org.apache.usergrid.persistence.model.entity.Entity targetEntity = targetEcm.load( 
-            new SimpleId( connectedEntityRef.getUuid(), connectedEntityRef.getType() ) )
-                .toBlockingObservable().last();
+        Id entityId = new SimpleId( connectedEntityRef.getUuid(), connectedEntityRef.getType()); 
+        org.apache.usergrid.persistence.model.entity.Entity targetEntity = 
+            ((CpEntityManager)em).load( new CpEntityManager.EntityScope( targetScope, entityId));
 
         String edgeType = CpNamingUtils.getEdgeTypeFromConnectionType( connectionType );
 
@@ -1240,12 +1241,12 @@ public class CpRelationManager implements RelationManager {
                     connectingEntityRef.getUuid(),
                     connectedEntityRef.getType(),
                     connectedEntityRef.getUuid()
-                    } );
+                });
         }
 
-        org.apache.usergrid.persistence.model.entity.Entity targetEntity = targetEcm.load( 
-            new SimpleId( connectedEntityRef.getUuid(), connectedEntityRef.getType() ) ) 
-                .toBlockingObservable().last();
+        Id entityId = new SimpleId( connectedEntityRef.getUuid(), connectedEntityRef.getType() );
+        org.apache.usergrid.persistence.model.entity.Entity targetEntity = 
+            ((CpEntityManager)em).load( new CpEntityManager.EntityScope( targetScope, entityId));
 
         // Delete graph edge connection from head entity to member entity
         Edge edge = new SimpleEdge( 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c5719654/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/EntityResults.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/EntityResults.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/EntityResults.java
index 4ce3848..b2aef93 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/EntityResults.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/EntityResults.java
@@ -67,18 +67,18 @@ public class EntityResults implements Iterable<Entity>, Iterator<Entity> {
 
 
     /**
-     * Advance to our next candidate so that it is avaiablel
+     * Advance to our next candidate so that it is available
      */
     private void doAdvance(){
         while(itr.hasNext() && next == null){
             CandidateResult candidate = itr.next();
 
-            //our candidate is > our max, we can't use it
+            // our candidate is > our max, we can't use it
             if( UUIDUtils.compare( candidate.getVersion(), maxVersion ) > 0){
                 continue;
             }
 
-            //our candidate was too new, ignore it
+            // our candidate was too new, ignore it
             next = ecm.load( candidate.getId() ).toBlocking().single();
         }
     }


[41/45] git commit: send out final notifications on stop

Posted by to...@apache.org.
send out final notifications on stop


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

Branch: refs/heads/key-row-sharding
Commit: 7cd722ee0b6f3fea990432baed19d4550077fd94
Parents: 77b8c59
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Oct 29 13:47:39 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Oct 29 13:47:39 2014 -0600

----------------------------------------------------------------------
 .../usergrid/services/notifications/gcm/GCMAdapter.java   | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7cd722ee/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 36cb7f0..5580ea8 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
@@ -139,7 +139,15 @@ public class GCMAdapter implements ProviderAdapter {
 
     @Override
     public void stop() {
-
+        try {
+            synchronized (this) {
+                for (Batch batch : batches.values()) {
+                    batch.send();
+                }
+            }
+        }catch (Exception e){
+            LOG.error("error while trying to send on stop",e);
+        }
     }
 
     @Override


[27/45] git commit: refactor static classes out of adapters

Posted by to...@apache.org.
refactor static classes out of adapters


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

Branch: refs/heads/key-row-sharding
Commit: 0f4584c47a775d97d0b2f3e297e5a5be8b06a31b
Parents: ad0cce9
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Oct 29 09:50:03 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Oct 29 09:50:03 2014 -0600

----------------------------------------------------------------------
 .../usergrid/persistence/entities/Notifier.java |   5 -
 .../notifications/ApplicationQueueManager.java  |  76 ++++++-----
 .../notifications/InactiveDeviceManager.java    |  13 +-
 .../notifications/NotificationsService.java     |  24 +---
 .../services/notifications/ProviderAdapter.java |  12 +-
 .../notifications/ProviderAdapterFactory.java   |  49 ++++++++
 .../services/notifications/QueueListener.java   |  65 +++++++---
 .../services/notifications/TestAdapter.java     |  21 +++-
 .../notifications/apns/APNsAdapter.java         | 126 +++++++------------
 .../notifications/apns/EntityPushManager.java   |   6 +-
 .../apns/ExpiredTokenListener.java              |   2 +-
 .../services/notifications/gcm/GCMAdapter.java  |  32 +++--
 .../services/notifiers/NotifiersService.java    |  23 ++--
 .../notifications/NotifiersServiceIT.java       |  33 +----
 .../apns/MockSuccessfulProviderAdapter.java     |  37 ++----
 .../apns/NotificationsServiceIT.java            |  43 ++-----
 .../gcm/MockSuccessfulProviderAdapter.java      |  31 ++---
 .../gcm/NotificationsServiceIT.java             |  74 -----------
 18 files changed, 292 insertions(+), 380 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java
index ba3f2fc..819ccde 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notifier.java
@@ -132,10 +132,5 @@ public class Notifier extends TypedEntity {
         this.apiKey = apiKey;
     }
 
-    @JsonIgnore
-    public EntityManager getEntityManager(){return entityManager;}
-
-    public void setEntityManager(EntityManager entityManager){ this.entityManager = entityManager;}
-
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
index 3fd84a6..11b197c 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
@@ -39,6 +39,7 @@ import rx.functions.Action1;
 import rx.functions.Func1;
 import rx.schedulers.Schedulers;
 
+import java.security.Provider;
 import java.util.*;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -61,9 +62,7 @@ public class ApplicationQueueManager  {
     private final MetricsFactory metricsFactory;
     private final String queueName;
 
-    HashMap<Object, Notifier> notifierHashMap; // only retrieve notifiers once
-
-    public final Map<String, ProviderAdapter> providerAdapters;
+    HashMap<Object, ProviderAdapter> notifierHashMap; // only retrieve notifiers once
 
 
     public ApplicationQueueManager(JobScheduler jobScheduler, EntityManager entityManager, QueueManager queueManager, MetricsFactory metricsFactory, Properties properties){
@@ -72,12 +71,7 @@ public class ApplicationQueueManager  {
         this.jobScheduler = jobScheduler;
         this.metricsFactory = metricsFactory;
         this.queueName = getQueueNames(properties);
-        providerAdapters =   new HashMap<String, ProviderAdapter>(3);
-        {
-            providerAdapters.put("apple", new APNsAdapter());
-            providerAdapters.put("google", new GCMAdapter());
-            providerAdapters.put("noop", new TestAdapter());
-        };
+
     }
 
     public boolean scheduleQueueJob(Notification notification) throws Exception{
@@ -106,7 +100,7 @@ public class ApplicationQueueManager  {
         final AtomicInteger deviceCount = new AtomicInteger(); //count devices so you can make a judgement on batching
         final ConcurrentLinkedQueue<String> errorMessages = new ConcurrentLinkedQueue<String>(); //build up list of issues
 
-        final HashMap<Object,Notifier> notifierMap =  getNotifierMap();
+        final HashMap<Object,ProviderAdapter> notifierMap =  getNotifierMap();
 
         //get devices in querystring, and make sure you have access
         if (pathQuery != null) {
@@ -147,9 +141,9 @@ public class ApplicationQueueManager  {
 
                             //find the device notifier info, match it to the payload
                             for (Map.Entry<String, Object> entry : payloads.entrySet()) {
-                                Notifier notifier = notifierMap.get(entry.getKey().toLowerCase());
+                                ProviderAdapter adapter = notifierMap.get(entry.getKey().toLowerCase());
                                 now = System.currentTimeMillis();
-                                String providerId = getProviderId(deviceRef, notifier);
+                                String providerId = getProviderId(deviceRef, adapter.getNotifier());
                                 if (providerId != null) {
                                     notifierId = providerId;
                                     notifierKey = entry.getKey().toLowerCase();
@@ -236,10 +230,10 @@ public class ApplicationQueueManager  {
      * only need to get notifiers once. will reset on next batch
      * @return
      */
-    public HashMap<Object,Notifier> getNotifierMap(){
+    public HashMap<Object,ProviderAdapter> getNotifierMap(){
         if(notifierHashMap == null) {
             long now = System.currentTimeMillis();
-            notifierHashMap = new HashMap<Object, Notifier>();
+            notifierHashMap = new HashMap<Object, ProviderAdapter>();
             Query query = new Query();
             query.setCollection("notifiers");
             query.setLimit(100);
@@ -251,12 +245,12 @@ public class ApplicationQueueManager  {
             int count = 0;
             while (notifierIterator.hasNext()) {
                 Notifier notifier = notifierIterator.next();
-                notifier.setEntityManager(em);
                 String name = notifier.getName() != null ? notifier.getName() : "";
                 UUID uuid = notifier.getUuid() != null ? notifier.getUuid() : UUID.randomUUID();
-                notifierHashMap.put(name.toLowerCase(), notifier);
-                notifierHashMap.put(uuid, notifier);
-                notifierHashMap.put(uuid.toString(), notifier);
+                ProviderAdapter providerAdapter = ProviderAdapterFactory.getProviderAdapter(notifier,em);
+                notifierHashMap.put(name.toLowerCase(), providerAdapter);
+                notifierHashMap.put(uuid, providerAdapter);
+                notifierHashMap.put(uuid.toString(), providerAdapter);
                 if(count++ >= 100){
                     LOG.error("ApplicationQueueManager: too many notifiers...breaking out ", notifierHashMap.size());
                     break;
@@ -276,7 +270,7 @@ public class ApplicationQueueManager  {
         LOG.info("sending batch of {} notifications.", messages.size());
         final Meter sendMeter = metricsFactory.getMeter(NotificationsService.class, "send");
 
-        final Map<Object, Notifier> notifierMap = getNotifierMap();
+        final Map<Object, ProviderAdapter> notifierMap = getNotifierMap();
         final ApplicationQueueManager proxy = this;
         final ConcurrentHashMap<UUID,TaskManager> taskMap = new ConcurrentHashMap<UUID, TaskManager>(messages.size());
         final ConcurrentHashMap<UUID,Notification> notificationMap = new ConcurrentHashMap<UUID, Notification>(messages.size());
@@ -310,10 +304,10 @@ public class ApplicationQueueManager  {
 
                     try {
                         String notifierName = message.getNotifierKey().toLowerCase();
-                        Notifier notifier = notifierMap.get(notifierName.toLowerCase());
+                        ProviderAdapter providerAdapter = notifierMap.get(notifierName.toLowerCase());
                         Object payload = translatedPayloads.get(notifierName);
                         Receipt receipt = new Receipt(notification.getUuid(), message.getNotifierId(), payload, deviceUUID);
-                        TaskTracker tracker = new TaskTracker(notifier, taskManager, receipt, deviceUUID);
+                        TaskTracker tracker = new TaskTracker(providerAdapter.getNotifier(), taskManager, receipt, deviceUUID);
                         if(!isOkToSend(notification)){
                              tracker.failed(0, "Notification is duplicate/expired/cancelled.");
                         }else {
@@ -323,8 +317,7 @@ public class ApplicationQueueManager  {
                             } else {
                                 long now = System.currentTimeMillis();
                                 try {
-                                    ProviderAdapter providerAdapter = providerAdapters.get(notifier.getProvider());
-                                    providerAdapter.sendNotification(message.getNotifierId(), notifier, payload, notification, tracker);
+                                    providerAdapter.sendNotification(message.getNotifierId(), payload, notification, tracker);
                                 } catch (Exception e) {
                                     tracker.failed(0, e.getMessage());
                                 } finally {
@@ -362,7 +355,7 @@ public class ApplicationQueueManager  {
                     @Override
                     public HashMap<UUID, ApplicationQueueMessage> call(List<ApplicationQueueMessage> queueMessages) {
                         //for gcm this will actually send notification
-                        for (ProviderAdapter providerAdapter : providerAdapters.values()) {
+                        for (ProviderAdapter providerAdapter : notifierMap.values()) {
                             try {
                                 providerAdapter.doneSendingNotifications();
                             } catch (Exception e) {
@@ -395,24 +388,26 @@ public class ApplicationQueueManager  {
         return o;
     }
 
+    public void stop(){
+        for(ProviderAdapter adapter : getNotifierMap().values()){
+            adapter.stop();
+        }
+    }
+
 
     /**
      * Call the adapter with the notifier
      */
-    private Map<String, Object> translatePayloads(Map<String, Object> payloads, Map<Object, Notifier> notifierMap) throws Exception {
-        Map<String, Object> translatedPayloads = new HashMap<String, Object>(
-                payloads.size());
+    private Map<String, Object> translatePayloads(Map<String, Object> payloads, Map<Object, ProviderAdapter> notifierMap) throws Exception {
+        Map<String, Object> translatedPayloads = new HashMap<String, Object>(  payloads.size());
         for (Map.Entry<String, Object> entry : payloads.entrySet()) {
             String payloadKey = entry.getKey().toLowerCase();
             Object payloadValue = entry.getValue();
-            Notifier notifier = notifierMap.get(payloadKey);
-            if (notifier != null) {
-                ProviderAdapter providerAdapter = providerAdapters.get(notifier.getProvider());
-                if (providerAdapter != null) {
-                    Object translatedPayload = payloadValue != null ? providerAdapter.translatePayload(payloadValue) : null;
-                    if (translatedPayload != null) {
-                        translatedPayloads.put(payloadKey, translatedPayload);
-                    }
+            ProviderAdapter providerAdapter = notifierMap.get(payloadKey);
+            if (providerAdapter != null) {
+                Object translatedPayload = payloadValue != null ? providerAdapter.translatePayload(payloadValue) : null;
+                if (translatedPayload != null) {
+                    translatedPayloads.put(payloadKey, translatedPayload);
                 }
             }
         }
@@ -453,15 +448,14 @@ public class ApplicationQueueManager  {
     }
 
     public void asyncCheckForInactiveDevices() throws Exception {
-        Collection<Notifier> notifiers = getNotifierMap().values();
-        for (final Notifier notifier : notifiers) {
+        Collection<ProviderAdapter> providerAdapters = getNotifierMap().values();
+        for (final ProviderAdapter providerAdapter : providerAdapters) {
             try {
-                ProviderAdapter providerAdapter = providerAdapters.get(notifier.getProvider());
                 if (providerAdapter != null) {
-                    LOG.debug("checking notifier {} for inactive devices", notifier);
-                    providerAdapter.removeInactiveDevices(notifier, em);
+                    LOG.debug("checking notifier {} for inactive devices", providerAdapter.getNotifier());
+                    providerAdapter.removeInactiveDevices();
 
-                    LOG.debug("finished checking notifier {} for inactive devices",notifier);
+                    LOG.debug("finished checking notifier {} for inactive devices",providerAdapter.getNotifier());
                 }
             } catch (Exception e) {
                 LOG.error("checkForInactiveDevices", e); // not

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
index ecee485..c54a595 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
@@ -38,13 +38,14 @@ import java.util.Map;
 public class InactiveDeviceManager {
     private static final Logger LOG = LoggerFactory.getLogger(InactiveDeviceManager.class);
     private final Notifier notifier;
+    private EntityManager entityManager;
 
-    public InactiveDeviceManager(Notifier notifier){
+    public InactiveDeviceManager(Notifier notifier,EntityManager entityManager){
         this.notifier = notifier;
+        this.entityManager = entityManager;
     }
     public void removeInactiveDevices( Map<String,Date> inactiveDeviceMap  ){
         final String notfierPostFix = ApplicationQueueManager.NOTIFIER_ID_POSTFIX;
-        final EntityManager em = notifier.getEntityManager();
         if (inactiveDeviceMap != null && inactiveDeviceMap.size() > 0) {
             LOG.debug("processing {} inactive devices",  inactiveDeviceMap.size());
             Map<String, Object> clearPushtokenMap = new HashMap<String, Object>( 2);
@@ -57,16 +58,16 @@ public class InactiveDeviceManager {
                     // name
                     Query query = new Query();
                     query.addEqualityFilter(notifier.getName() + notfierPostFix, entry.getKey());
-                    Results results = em.searchCollection(em.getApplication(), "devices", query);
+                    Results results = entityManager.searchCollection(entityManager.getApplication(), "devices", query);
                     for (Entity e : results.getEntities()) {
-                        em.updateProperties(e, clearPushtokenMap);
+                        entityManager.updateProperties(e, clearPushtokenMap);
                     }
                     // uuid
                     query = new Query();
                     query.addEqualityFilter(notifier.getUuid() + notfierPostFix, entry.getKey());
-                    results = em.searchCollection(em.getApplication(),  "devices", query);
+                    results = entityManager.searchCollection(entityManager.getApplication(),  "devices", query);
                     for (Entity e : results.getEntities()) {
-                        em.updateProperties(e, clearPushtokenMap);
+                        entityManager.updateProperties(e, clearPushtokenMap);
                     }
                 }catch (Exception e){
                     LOG.error("failed to remove token",e);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
index 5420d29..a64704c 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
@@ -72,18 +72,6 @@ public class NotificationsService extends AbstractCollectionService {
                 MESSAGE_PROPERTY_DEVICE_UUID, UUID.class);
     }
 
-    // these 2 can be static, but GCM can't. future: would be nice to get gcm
-    // static as well...
-    public static ProviderAdapter APNS_ADAPTER = new APNsAdapter();
-    public static ProviderAdapter TEST_ADAPTER = new TestAdapter();
-
-    public final Map<String, ProviderAdapter> providerAdapters =
-            new HashMap<String, ProviderAdapter>(3);
-    {
-        providerAdapters.put("apple", APNS_ADAPTER);
-        providerAdapters.put("google", new GCMAdapter());
-        providerAdapters.put("noop", TEST_ADAPTER);
-    }
 
     private ApplicationQueueManager notificationQueueManager;
     private long gracePeriod;
@@ -250,10 +238,6 @@ public class NotificationsService extends AbstractCollectionService {
         return (notification.getStarted() == null);
     }
 
-    public Set<String> getProviders() {
-        return providerAdapters.keySet();
-    }
-
     // validate payloads
     private void validate(EntityRef ref, ServicePayload servicePayload)
             throws Exception {
@@ -278,8 +262,7 @@ public class NotificationsService extends AbstractCollectionService {
                         throw new IllegalArgumentException("notifier \""
                                 + notifierId + "\" not found");
                     }
-                    ProviderAdapter providerAdapter = providerAdapters.get(notifier
-                            .getProvider());
+                    ProviderAdapter providerAdapter = ProviderAdapterFactory.getProviderAdapter(notifier,em);
                     Object payload = entry.getValue();
                     try {
                         return providerAdapter.translatePayload(payload); // validate
@@ -354,10 +337,9 @@ public class NotificationsService extends AbstractCollectionService {
      * failure
      */
     public void testConnection(Notifier notifier) throws Exception {
-        ProviderAdapter providerAdapter = providerAdapters.get(notifier.getProvider());
+        ProviderAdapter providerAdapter = ProviderAdapterFactory.getProviderAdapter(notifier,em);
         if (providerAdapter != null) {
-            notifier.setEntityManager(em);
-            providerAdapter.testConnection(notifier);
+            providerAdapter.testConnection();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapter.java
index 33e921f..8acd006 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapter.java
@@ -34,10 +34,9 @@ import org.apache.usergrid.services.ServicePayload;
  */
 public interface ProviderAdapter {
 
-    public void testConnection(Notifier notifier) throws ConnectionException;
+    public void testConnection() throws ConnectionException;
 
-    public void sendNotification(String providerId, Notifier notifier,
-                                 Object payload, Notification notification, TaskTracker tracker)
+    public void sendNotification(String providerId,  Object payload, Notification notification, TaskTracker tracker)
             throws Exception;
 
     /**
@@ -46,10 +45,13 @@ public interface ProviderAdapter {
      */
     public void doneSendingNotifications() throws Exception;
 
-    public void removeInactiveDevices(Notifier notifier,
-                                                EntityManager em) throws Exception;
+    public void removeInactiveDevices() throws Exception;
 
     public Object translatePayload(Object payload) throws Exception;
 
     public void validateCreateNotifier(ServicePayload payload) throws Exception;
+
+    public void stop();
+
+    public Notifier getNotifier();
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
new file mode 100644
index 0000000..a4022c1
--- /dev/null
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapterFactory.java
@@ -0,0 +1,49 @@
+/*
+ *
+ *  * 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.services.notifications;
+
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.entities.Notifier;
+import org.apache.usergrid.services.notifications.apns.APNsAdapter;
+import org.apache.usergrid.services.notifications.gcm.GCMAdapter;
+
+import java.util.HashMap;
+
+/**
+ * Classy class class.
+ */
+public class ProviderAdapterFactory {
+    private static final String[] providers =  new String[]{"apple", "google", "noop"};
+   public static ProviderAdapter getProviderAdapter(Notifier notifier, EntityManager entityManager){
+       ProviderAdapter adapter = null;
+       switch(notifier.getProvider().toLowerCase()){
+           case "apple" : adapter = new APNsAdapter(entityManager,notifier); break;
+           case "google" : adapter = new GCMAdapter(entityManager ,notifier); break;
+           case "noop" : adapter = new TestAdapter(notifier); break;
+       }
+       return adapter;
+
+   }
+
+    public static String[] getValidProviders() {
+        return providers;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
index fffc8cd..3c788a9 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
@@ -18,6 +18,7 @@ package org.apache.usergrid.services.notifications;
 
 import com.codahale.metrics.*;
 import com.codahale.metrics.Timer;
+import com.google.common.cache.*;
 import org.apache.usergrid.corepersistence.CpSetup;
 import org.apache.usergrid.metrics.MetricsFactory;
 
@@ -35,10 +36,7 @@ import org.slf4j.LoggerFactory;
 import rx.Observable;
 import javax.annotation.PostConstruct;
 import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
+import java.util.concurrent.*;
 import java.util.concurrent.atomic.AtomicInteger;
 
 public class QueueListener  {
@@ -148,7 +146,9 @@ public class QueueListener  {
         QueueManager queueManager = TEST_QUEUE_MANAGER != null ? TEST_QUEUE_MANAGER : queueManagerFactory.getQueueManager(queueScope);
         // run until there are no more active jobs
         long runCount = 0;
-        Map<UUID,ApplicationQueueManager> queueManagerMap = new ConcurrentHashMap<>(); //keep a cache of queuemangers then clear them at an interval
+        //cache to retrieve push manager, cached per notifier, so many notifications will get same push manager
+        LoadingCache<UUID, ApplicationQueueManager> queueManagerMap = getQueueManagerCache(queueManager);
+
         while ( true ) {
             try {
 
@@ -175,20 +175,7 @@ public class QueueListener  {
                     //send each set of app ids together
                     for (Map.Entry<UUID, List<QueueMessage>> entry : messageMap.entrySet()) {
                         UUID applicationId = entry.getKey();
-                        EntityManager entityManager = emf.getEntityManager(applicationId);
-                        ServiceManager serviceManager = smf.getServiceManager(applicationId);
-
                         ApplicationQueueManager manager = queueManagerMap.get(applicationId);
-                        if(manager==null) {
-                            manager = new ApplicationQueueManager(
-                                    new JobScheduler(serviceManager, entityManager),
-                                    entityManager,
-                                    queueManager,
-                                    metricsService,
-                                    properties
-                            );
-                            queueManagerMap.put(applicationId,manager);
-                        }
                         LOG.info("send batch for app {} of {} messages", entry.getKey(), entry.getValue().size());
                         Observable current = manager.sendBatchToProviders(entry.getValue(),queueName);
                         if(merge == null)
@@ -210,7 +197,7 @@ public class QueueListener  {
                         Thread.sleep(sleepBetweenRuns);
                     }
                     if(++runCount % consecutiveCallsToRemoveDevices == 0){
-                        for(ApplicationQueueManager applicationQueueManager : queueManagerMap.values()){
+                        for(ApplicationQueueManager applicationQueueManager : queueManagerMap.asMap().values()){
                             try {
                                 applicationQueueManager.asyncCheckForInactiveDevices();
                             }catch (Exception inactiveDeviceException){
@@ -218,7 +205,6 @@ public class QueueListener  {
                             }
                         }
                         //clear everything
-                        queueManagerMap.clear();
                         runCount=0;
                     }
                 }
@@ -244,6 +230,43 @@ public class QueueListener  {
         }
     }
 
+    private LoadingCache<UUID, ApplicationQueueManager> getQueueManagerCache(final QueueManager queueManager) {
+        return CacheBuilder
+                    .newBuilder()
+                    .expireAfterAccess(10, TimeUnit.MINUTES)
+                    .removalListener(new RemovalListener<UUID, ApplicationQueueManager>() {
+                        @Override
+                        public void onRemoval(
+                                RemovalNotification<UUID, ApplicationQueueManager> queueManagerNotifiication) {
+                            try {
+                                queueManagerNotifiication.getValue().stop();
+                            } catch (Exception ie) {
+                                LOG.error("Failed to shutdown from cache", ie);
+                            }
+                        }
+                    }).build(new CacheLoader<UUID, ApplicationQueueManager>() {
+                         @Override
+                         public ApplicationQueueManager load(final UUID applicationId) {
+                             try {
+                                 EntityManager entityManager = emf.getEntityManager(applicationId);
+                                 ServiceManager serviceManager = smf.getServiceManager(applicationId);
+
+                                 ApplicationQueueManager manager = new ApplicationQueueManager(
+                                         new JobScheduler(serviceManager, entityManager),
+                                         entityManager,
+                                         queueManager,
+                                         metricsService,
+                                         properties
+                                 );
+                                 return manager;
+                             } catch (Exception e) {
+                                 LOG.error("Could not instantiate queue manager", e);
+                                 return null;
+                             }
+                         }
+                     });
+    }
+
     public void stop(){
         LOG.info("stop processes");
 
@@ -263,4 +286,6 @@ public class QueueListener  {
     }
     public int getBatchSize(){return batchSize;}
 
+
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/stack/services/src/main/java/org/apache/usergrid/services/notifications/TestAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/TestAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/TestAdapter.java
index b4eb767..1007dc6 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/TestAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/TestAdapter.java
@@ -38,25 +38,26 @@ public class TestAdapter implements ProviderAdapter {
 
     private static final Logger log = LoggerFactory.getLogger(TestAdapter.class);
     private static final int DELAY = 1; // if delay > 0, uses threadpool
+    private final Notifier notifier;
 
     private ExecutorService pool = null;
 
-    public TestAdapter() {
+    public TestAdapter(Notifier notifier) {
         if (DELAY > 0) {
             pool = Executors
                     .newFixedThreadPool(APNsAdapter.MAX_CONNECTION_POOL_SIZE);
         }
+        this.notifier = notifier;
     }
 
     @Override
-    public void testConnection(Notifier notifier) throws ConnectionException {
+    public void testConnection() throws ConnectionException {
     }
 
     @Override
     public void sendNotification(
             String providerId, 
-            Notifier notifier,
-            final Object payload, 
+            final Object payload,
             Notification notification,
             TaskTracker tracker)
             throws Exception {
@@ -89,7 +90,7 @@ public class TestAdapter implements ProviderAdapter {
     }
 
     @Override
-    public void removeInactiveDevices(Notifier notifier, EntityManager em) throws Exception {
+    public void removeInactiveDevices() throws Exception {
         log.debug("getInactiveDevices()");
     }
 
@@ -101,4 +102,14 @@ public class TestAdapter implements ProviderAdapter {
     @Override
     public void validateCreateNotifier(ServicePayload payload) throws Exception {
     }
+
+    @Override
+    public void stop() {
+
+    }
+
+    @Override
+    public Notifier getNotifier() {
+        return notifier;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
index 7ab1dc3..da5d3e5 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
@@ -60,13 +60,18 @@ public class APNsAdapter implements ProviderAdapter {
         validEnvironments.add("mock");
     }
 
-    public APNsAdapter(){}
+    private final Notifier notifier;
+
+    private EntityManager entityManager;
+    private EntityPushManager pushManager;
+
+    public APNsAdapter(EntityManager entityManager, Notifier notifier){
+        this.entityManager = entityManager;
+        this.notifier = notifier;
+    }
 
     @Override
-    public void testConnection(Notifier notifier) throws ConnectionException {
-        if(isMock(notifier)){
-            delayRandom(notifier); return;
-        }
+    public void testConnection() throws ConnectionException {
         TestAPNsNotification notification =  TestAPNsNotification.create(TEST_TOKEN, TEST_PAYLOAD);
         try {
             CountDownLatch latch = new CountDownLatch(1);
@@ -99,8 +104,7 @@ public class APNsAdapter implements ProviderAdapter {
     }
 
     @Override
-    public void sendNotification(String providerId, Notifier notifier,
-            Object payload, Notification notification, TaskTracker tracker)
+    public void sendNotification(String providerId, Object payload, Notification notification, TaskTracker tracker)
             throws Exception {
         APNsNotification apnsNotification = APNsNotification.create(providerId, payload.toString(), notification, tracker);
         PushManager<SimpleApnsPushNotification> pushManager = getPushManager(notifier);
@@ -119,74 +123,35 @@ public class APNsAdapter implements ProviderAdapter {
     }
 
     @Override
-    public void removeInactiveDevices(Notifier notifier,EntityManager em) throws Exception {
+    public void removeInactiveDevices() throws Exception {
         PushManager<SimpleApnsPushNotification> pushManager = getPushManager(notifier);
         pushManager.requestExpiredTokens();
     }
 
     private EntityPushManager getPushManager(Notifier notifier) throws ExecutionException {
-        EntityPushManager pushManager = apnsServiceMap.get(notifier);
         if(pushManager != null &&  !pushManager.isStarted() && pushManager.isShutDown()){
-            apnsServiceMap.invalidate(notifier);
-            pushManager = apnsServiceMap.get(notifier);
+            PushManagerConfiguration config = new PushManagerConfiguration();
+            config.setConcurrentConnectionCount(Runtime.getRuntime().availableProcessors() * 2);
+            EntityPushManager pushManager =  new EntityPushManager(notifier,entityManager, config);
+            //only tested when a message is sent
+            pushManager.registerRejectedNotificationListener(new RejectedAPNsListener());
+            //this will get tested when start is called
+            pushManager.registerFailedConnectionListener(new FailedConnectionListener());
+            //unregistered expired devices
+            pushManager.registerExpiredTokenListener(new ExpiredTokenListener());
+
+            try {
+                if (!pushManager.isStarted()) { //ensure manager is started
+                    pushManager.start();
+                }
+            }catch(IllegalStateException ise){
+                logger.debug("failed to start",ise);//could have failed because its started
+            }
+            return pushManager;
         }
         return pushManager;
     }
 
-    //cache to retrieve push manager, cached per notifier, so many notifications will get same push manager
-    private static LoadingCache<Notifier, EntityPushManager> apnsServiceMap = CacheBuilder
-            .newBuilder()
-            .expireAfterAccess(10, TimeUnit.MINUTES)
-            .removalListener(new RemovalListener<Notifier, EntityPushManager>() {
-                @Override
-                public void onRemoval(
-                        RemovalNotification<Notifier,EntityPushManager> notification) {
-                    try {
-                        EntityPushManager manager = notification.getValue();
-                        if (!manager.isShutDown()) {
-                            List<SimpleApnsPushNotification> notifications = manager.shutdown(3000);
-                            for (SimpleApnsPushNotification notification1 : notifications) {
-                                try {
-                                    ((APNsNotification) notification1).messageSendFailed(new Exception("Cache Expired: Shutting down sender"));
-                                }catch (Exception e){
-                                    logger.error("Failed to mark notification",e);
-                                }
-                            }
-                        }
-                    } catch (Exception ie) {
-                        logger.error("Failed to shutdown from cache", ie);
-                    }
-                }
-            }).build(new CacheLoader<Notifier, EntityPushManager>() {
-                @Override
-                public EntityPushManager load(final Notifier notifier) {
-                    try {
-                        PushManagerConfiguration config = new PushManagerConfiguration();
-                        config.setConcurrentConnectionCount(Runtime.getRuntime().availableProcessors() * 2);
-                        EntityPushManager pushManager =  new EntityPushManager(notifier, config);
-                        //only tested when a message is sent
-                        pushManager.registerRejectedNotificationListener(new RejectedAPNsListener());
-                        //this will get tested when start is called
-                        pushManager.registerFailedConnectionListener(new FailedConnectionListener());
-                        //unregistered expired devices
-                        pushManager.registerExpiredTokenListener(new ExpiredTokenListener());
-
-                        try {
-                            if (!pushManager.isStarted()) { //ensure manager is started
-                                pushManager.start();
-                            }
-                        }catch(IllegalStateException ise){
-                            logger.debug("failed to start",ise);//could have failed because its started
-                        }
-                        return pushManager;
-                    } catch (Exception e) {
-                        logger.error("Could not instantiate pushmanager", e);
-                        return null;
-                    }
-                }
-            });
-
-
 
     @Override
     public Object translatePayload(Object objPayload) throws Exception {
@@ -220,23 +185,26 @@ public class APNsAdapter implements ProviderAdapter {
                     "p12Certificate");
         }
     }
-    public boolean isMock(Notifier notifier){
-        return notifier.getEnvironment() !=null ? notifier.getEnvironment().equals("mock") : false ;
-    }
-    public boolean delayRandom(Notifier notifier) {
-        boolean wasDelayed = false;
-        if (isMock(notifier)) {
+
+    @Override
+    public void stop(){
             try {
-                Thread.sleep(
-                        new Random().nextInt(300)
-                );
-                wasDelayed = true;
-            } catch (InterruptedException ie) {
-                //delay was stopped
+                if (!pushManager.isShutDown()) {
+                    List<SimpleApnsPushNotification> notifications = pushManager.shutdown(3000);
+                    for (SimpleApnsPushNotification notification1 : notifications) {
+                        try {
+                            ((APNsNotification) notification1).messageSendFailed(new Exception("Cache Expired: Shutting down sender"));
+                        }catch (Exception e){
+                            logger.error("Failed to mark notification",e);
+                        }
+                    }
+                }
+            } catch (Exception ie) {
+                logger.error("Failed to shutdown from cache", ie);
             }
-        }
-        return wasDelayed;
     }
+    @Override
+    public Notifier getNotifier(){return notifier;}
 
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java
index 8283458..d675081 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java
@@ -38,14 +38,16 @@ import java.util.concurrent.LinkedBlockingDeque;
  */
 public class EntityPushManager extends PushManager<SimpleApnsPushNotification> {
     private final Notifier notifier;
+    private final EntityManager entityManager;
 
-    public EntityPushManager( Notifier notifier, PushManagerConfiguration configuration) {
+    public EntityPushManager( Notifier notifier, EntityManager entityManager, PushManagerConfiguration configuration) {
         super(getApnsEnvironment(notifier), getSSLContext(notifier), null, null, new LinkedBlockingDeque<SimpleApnsPushNotification>(), configuration, notifier.getName());
         this.notifier = notifier;
+        this.entityManager = entityManager;
     }
 
     public EntityManager getEntityManager() {
-        return notifier.getEntityManager();
+        return entityManager;
     }
 
     public Notifier getNotifier() {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java
index 3daa20c..6408dfd 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java
@@ -53,7 +53,7 @@ public class ExpiredTokenListener implements com.relayrides.pushy.apns.ExpiredTo
         }
         if(pushManager instanceof EntityPushManager){
             EntityPushManager entityPushManager = (EntityPushManager) pushManager;
-            InactiveDeviceManager inactiveDeviceManager = new InactiveDeviceManager(entityPushManager.getNotifier());
+            InactiveDeviceManager inactiveDeviceManager = new InactiveDeviceManager(entityPushManager.getNotifier(),entityPushManager.getEntityManager());
             inactiveDeviceManager.removeInactiveDevices(inactiveDeviceMap);
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/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 f8de5ff..b65b25a 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
@@ -40,11 +40,17 @@ public class GCMAdapter implements ProviderAdapter {
     private static final Logger LOG = LoggerFactory.getLogger(GCMAdapter.class);
     private static final int SEND_RETRIES = 3;
     private static int BATCH_SIZE = 1000;
+    private final Notifier notifier;
+    private EntityManager entityManager;
 
     private Map<Notifier, Batch> notifierBatches = new HashMap<Notifier, Batch>();
 
+    public GCMAdapter(EntityManager entityManager,Notifier notifier){
+        this.notifier = notifier;
+        this.entityManager = entityManager;
+    }
     @Override
-    public void testConnection(Notifier notifier) throws ConnectionException {
+    public void testConnection() throws ConnectionException {
         Sender sender = new Sender(notifier.getApiKey());
         Message message = new Message.Builder().build();
         try {
@@ -56,7 +62,7 @@ public class GCMAdapter implements ProviderAdapter {
     }
 
     @Override
-    public void sendNotification(String providerId, Notifier notifier,
+    public void sendNotification(String providerId,
             Object payload, Notification notification, TaskTracker tracker)
             throws Exception {
         Map<String,Object> map = (Map<String, Object>) payload;
@@ -66,12 +72,11 @@ public class GCMAdapter implements ProviderAdapter {
             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);
         }
-        Batch batch = getBatch(notifier, map);
+        Batch batch = getBatch( map);
         batch.add(providerId, tracker);
     }
 
-    synchronized private Batch getBatch(Notifier notifier,
-            Map<String, Object> payload) {
+    synchronized private Batch getBatch( Map<String, Object> payload) {
         Batch batch = notifierBatches.get(notifier);
         if (batch == null && payload != null) {
             batch = new Batch(notifier, payload);
@@ -88,13 +93,12 @@ public class GCMAdapter implements ProviderAdapter {
     }
 
     @Override
-    public void removeInactiveDevices(Notifier notifier,
-            EntityManager em) throws Exception {
-        Batch batch = getBatch(notifier, null);
+    public void removeInactiveDevices( ) throws Exception {
+        Batch batch = getBatch( null);
         Map<String,Date> map = null;
         if(batch != null) {
             map = batch.getAndClearInactiveDevices();
-            InactiveDeviceManager deviceManager = new InactiveDeviceManager(notifier);
+            InactiveDeviceManager deviceManager = new InactiveDeviceManager(notifier,entityManager);
             deviceManager.removeInactiveDevices(map);
         }
 
@@ -126,6 +130,16 @@ public class GCMAdapter implements ProviderAdapter {
         }
     }
 
+    @Override
+    public void stop() {
+
+    }
+
+    @Override
+    public Notifier getNotifier() {
+        return notifier;
+    }
+
     private class Batch {
         private Notifier notifier;
         private Map payload;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/stack/services/src/main/java/org/apache/usergrid/services/notifiers/NotifiersService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifiers/NotifiersService.java b/stack/services/src/main/java/org/apache/usergrid/services/notifiers/NotifiersService.java
index 8c41e0a..ae089fe 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifiers/NotifiersService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifiers/NotifiersService.java
@@ -18,6 +18,10 @@ package org.apache.usergrid.services.notifiers;
 
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.entities.Notifier;
+import org.apache.usergrid.services.notifications.ProviderAdapterFactory;
+import org.apache.usergrid.services.notifications.TestAdapter;
+import org.apache.usergrid.services.notifications.apns.APNsAdapter;
+import org.apache.usergrid.services.notifications.gcm.GCMAdapter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.usergrid.services.*;
@@ -25,6 +29,8 @@ import org.apache.usergrid.services.notifications.NotificationsService;
 import org.apache.usergrid.services.notifications.ProviderAdapter;
 
 import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Set;
 
 public class NotifiersService extends AbstractCollectionService {
@@ -45,22 +51,21 @@ public class NotifiersService extends AbstractCollectionService {
 
         NotificationsService ns = (NotificationsService) sm
                 .getService("notifications");
-        Set<String> providers = ns.getProviders();
 
         String provider = payload.getStringProperty("provider");
-        if (!providers.contains(provider)) {
-            throw new IllegalArgumentException("provider must be one of: "
-                    + Arrays.toString(providers.toArray()));
-        }
 
-        ProviderAdapter providerAdapter = ns.providerAdapters.get(provider);
-        providerAdapter.validateCreateNotifier(payload);
 
         ServiceResults results = super.postCollection(context);
-
-        Notifier notifier =(Notifier) results.getEntity();
+        Notifier notifier = (Notifier) results.getEntity();
         if (notifier != null) {
             try {
+                ProviderAdapter providerAdapter = ProviderAdapterFactory.getProviderAdapter(notifier, em);
+
+                if (providerAdapter==null) {
+                    throw new IllegalArgumentException("provider must be one of: "
+                            + Arrays.toString(ProviderAdapterFactory.getValidProviders()));
+                }
+                providerAdapter.validateCreateNotifier(payload);
                 ns.testConnection(notifier);
             } catch (Exception e) {
                 logger.info("notifier testConnection() failed", e);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/stack/services/src/test/java/org/apache/usergrid/services/notifications/NotifiersServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/NotifiersServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/NotifiersServiceIT.java
index 61cf1e6..7ced70c 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/NotifiersServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/NotifiersServiceIT.java
@@ -44,7 +44,6 @@ public class NotifiersServiceIT extends AbstractServiceIT {
     @Before
     public void before() throws Exception {
         ns = (NotificationsService) app.getSm().getService("notifications");
-        MockSuccessfulProviderAdapter.install(ns);
     }
 
     @Test
@@ -76,16 +75,6 @@ public class NotifiersServiceIT extends AbstractServiceIT {
             // ok
         }
 
-        // mock action (based on verified actual behavior) //
-        ns.providerAdapters
-                .put("google",
-                        new org.apache.usergrid.services.notifications.gcm.MockSuccessfulProviderAdapter() {
-                            @Override
-                            public void testConnection(Notifier notifier)
-                                    throws ConnectionException {
-                                throw new ConnectionException("", null);
-                            }
-                        });
 
         app.put("apiKey", "xxx");
 
@@ -100,8 +89,6 @@ public class NotifiersServiceIT extends AbstractServiceIT {
     @Test
     public void badAPNsEnvironment() throws Exception {
 
-        MockSuccessfulProviderAdapter.uninstall(ns);
-
         app.clear();
         app.put("provider", "apple");
         app.put("environment", "xxx");
@@ -141,16 +128,7 @@ public class NotifiersServiceIT extends AbstractServiceIT {
     @Test
     public void badAPNsCertificate() throws Exception {
 
-        // mock error (based on verified actual behavior) //
-        ns.providerAdapters.put("apple", new MockSuccessfulProviderAdapter() {
-            @Override
-            public void testConnection(Notifier notifier)
-                    throws ConnectionException {
-                Exception e = new SocketException(
-                        "Connection closed by remote host");
-                throw new ConnectionException(e.getMessage(), e);
-            }
-        });
+
 
         app.clear();
         app.put("provider", "apple");
@@ -174,15 +152,6 @@ public class NotifiersServiceIT extends AbstractServiceIT {
     @Test
     public void badAPNsPassword() throws Exception {
 
-        // mock error (based on verified actual behavior) //
-        ns.providerAdapters.put("apple", new MockSuccessfulProviderAdapter() {
-            @Override
-            public void testConnection(Notifier notifier)
-                    throws ConnectionException {
-                Exception e = new Exception("invalid ssl config");
-                throw new ConnectionException(e.getMessage(), e);
-            }
-        });
 
         app.clear();
         app.put("provider", "apple");

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/MockSuccessfulProviderAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/MockSuccessfulProviderAdapter.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/MockSuccessfulProviderAdapter.java
index e864e4f..b3096b7 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/MockSuccessfulProviderAdapter.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/MockSuccessfulProviderAdapter.java
@@ -23,34 +23,15 @@ import org.apache.usergrid.services.notifications.NotificationsService;
 import org.apache.usergrid.services.notifications.ProviderAdapter;
 import org.apache.usergrid.services.notifications.TaskTracker;
 
-import java.util.Date;
-import java.util.Map;
 import java.util.Random;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.services.ServicePayload;
 
 public class MockSuccessfulProviderAdapter implements ProviderAdapter {
 
     private static ProviderAdapter realProviderAdapter;
 
-    public static void install(NotificationsService ns) {
-        install(ns, false);
-    }
-
-    public static void install(NotificationsService ns, boolean doAsync) {
-        if (realProviderAdapter != null)
-            realProviderAdapter = ns.providerAdapters.get("apple");
-        ns.providerAdapters.put("apple", new MockSuccessfulProviderAdapter(
-                doAsync));
-    }
-
-    public static void uninstall(NotificationsService ns) {
-        if (realProviderAdapter != null) {
-            ns.providerAdapters.put("apple", realProviderAdapter);
-        }
-    }
 
     private ExecutorService pool;
 
@@ -65,7 +46,7 @@ public class MockSuccessfulProviderAdapter implements ProviderAdapter {
     }
 
     @Override
-    public void testConnection(Notifier notifier) throws ConnectionException {
+    public void testConnection() throws ConnectionException {
     }
 
     @Override
@@ -74,8 +55,7 @@ public class MockSuccessfulProviderAdapter implements ProviderAdapter {
     }
 
     @Override
-    public void removeInactiveDevices(Notifier notifier,
-            EntityManager em) {
+    public void removeInactiveDevices() {
     }
 
     @Override
@@ -83,12 +63,21 @@ public class MockSuccessfulProviderAdapter implements ProviderAdapter {
     }
 
     @Override
+    public void stop() {
+
+    }
+
+    @Override
+    public Notifier getNotifier() {
+        return null;
+    }
+
+    @Override
     public void doneSendingNotifications() throws Exception {
     }
 
     @Override
-    public void sendNotification(final String providerId,
-            final Notifier notifier, final Object payload,
+    public void sendNotification(final String providerId, final Object payload,
             final Notification notification, final TaskTracker tracker)
             throws Exception {
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/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 31a653c..2a4ec73 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
@@ -327,8 +327,6 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
     @Test
     public void badPayloads() throws Exception {
 
-        MockSuccessfulProviderAdapter.uninstall(ns);
-
         // bad payloads format
 
         app.clear();
@@ -400,24 +398,6 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
 
         // mock action (based on verified actual behavior) //
 
-        if (!USE_REAL_CONNECTIONS) {
-            ns.providerAdapters.put("apple",
-                    new MockSuccessfulProviderAdapter() {
-                        @Override
-                        public void sendNotification(String providerId,
-                                                     Notifier notifier, Object payload,
-                                                     Notification notification, TaskTracker tracker)
-                                throws Exception {
-                            APNsNotification apnsNotification = APNsNotification
-                                    .create(providerId, payload.toString(),
-                                            notification, tracker);
-                            apnsNotification.messageSent();
-                            apnsNotification
-                                    .messageSendFailed( RejectedNotificationReason.INVALID_TOKEN);
-                        }
-                    });
-        }
-
         // create push notification //
 
         HashMap<String, Object> properties = new LinkedHashMap<String, Object>();
@@ -628,16 +608,16 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
 
         // mock error (based on verified actual behavior) //
         if (!USE_REAL_CONNECTIONS) {
-            ns.providerAdapters.put("apple",
-                    new MockSuccessfulProviderAdapter() {
-                        @Override
-                        public void testConnection(Notifier notifier)
-                                throws ConnectionException {
-                            Exception e = new SocketException(
-                                    "Connection closed by remote host");
-                            throw new ConnectionException(e.getMessage(), e);
-                        }
-                    });
+//            ns.providerAdapters.put("apple",
+//                    new MockSuccessfulProviderAdapter() {
+//                        @Override
+//                        public void testConnection(Notifier notifier)
+//                                throws ConnectionException {
+//                            Exception e = new SocketException(
+//                                    "Connection closed by remote host");
+//                            throw new ConnectionException(e.getMessage(), e);
+//                        }
+//                    });
         }
 
         // create push notification //
@@ -685,8 +665,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
 
         // mock action (based on verified actual behavior) //
         if (!USE_REAL_CONNECTIONS) {
-            ns.providerAdapters.put("apple",
-                    new MockSuccessfulProviderAdapter());
+
         }
 
         // create push notification //

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/MockSuccessfulProviderAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/MockSuccessfulProviderAdapter.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/MockSuccessfulProviderAdapter.java
index 3836fe8..c41e5ab 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/MockSuccessfulProviderAdapter.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/MockSuccessfulProviderAdapter.java
@@ -32,23 +32,13 @@ public class MockSuccessfulProviderAdapter implements ProviderAdapter {
 
     private static ProviderAdapter realProviderAdapter;
 
-    public static void install(NotificationsService ns) {
-        if (realProviderAdapter != null)
-            realProviderAdapter = ns.providerAdapters.get("google");
-        ns.providerAdapters.put("google", new MockSuccessfulProviderAdapter());
-    }
 
-    public static void uninstall(NotificationsService ns) {
-        if (realProviderAdapter != null) {
-            ns.providerAdapters.put("google", realProviderAdapter);
-        }
-    }
 
     public MockSuccessfulProviderAdapter() {
     }
 
     @Override
-    public void testConnection(Notifier notifier) throws ConnectionException {
+    public void testConnection() throws ConnectionException {
     }
 
     @Override
@@ -56,14 +46,20 @@ public class MockSuccessfulProviderAdapter implements ProviderAdapter {
         return payload.toString();
     }
 
+
+
     @Override
-    public void removeInactiveDevices(Notifier notifier,
-            EntityManager em) throws Exception {
+    public void validateCreateNotifier(ServicePayload payload) throws Exception {
+    }
+
+    @Override
+    public void stop() {
 
     }
 
     @Override
-    public void validateCreateNotifier(ServicePayload payload) throws Exception {
+    public Notifier getNotifier() {
+        return null;
     }
 
     @Override
@@ -71,7 +67,12 @@ public class MockSuccessfulProviderAdapter implements ProviderAdapter {
     }
 
     @Override
-    public void sendNotification(String providerId, Notifier notifier,
+    public void removeInactiveDevices() throws Exception {
+
+    }
+
+    @Override
+    public void sendNotification(String providerId,
             Object payload, Notification notification, final TaskTracker tracker)
             throws Exception {
         new Thread() {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0f4584c4/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 ea0b7da..3795be1 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
@@ -240,51 +240,6 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
         }
     }
 
-    @Ignore("todo: how can I mock this?")
-    @Test
-    public void providerIdUpdate() throws Exception {
-
-        // mock action (based on verified actual behavior) //
-        final String newProviderId = "newProviderId";
-        ns.providerAdapters.put("google", new MockSuccessfulProviderAdapter() {
-            @Override
-            public void sendNotification(String providerId, Notifier notifier,
-                                         Object payload, Notification notification,
-                                         TaskTracker tracker) throws Exception {
-                tracker.completed(newProviderId);
-            }
-        });
-
-        // create push notification //
-
-        app.clear();
-        String payload = "Hello, World!";
-        Map<String, String> payloads = new HashMap<String, String>(1);
-        payloads.put(notifier.getUuid().toString(), payload);
-        app.put("payloads", payloads);
-        app.put("queued", System.currentTimeMillis());
-        app.put("debug",true);
-
-        Entity e = app.testRequest(ServiceAction.POST, 1,"devices",device1.getUuid(), "notifications")
-                .getEntity();
-        app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid());
-
-        Notification notification = app.getEm().get(e.getUuid(),
-                Notification.class);
-        assertEquals(
-                notification.getPayloads().get(notifier.getUuid().toString()),
-                payload);
-
-        ns.addDevice(notification, device1);
-
-        // perform push //
-        notification = scheduleNotificationAndWait(notification);
-        checkReceipts(notification, 1);
-
-        Device device = (Device) app.getEm().get(device1).toTypedEntity();
-        assertEquals(newProviderId,
-                device.getProperty(notifier.getName() + NOTIFIER_ID_POSTFIX));
-    }
 
     @Test
     public void badPayloads() throws Exception {
@@ -353,20 +308,6 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
     @Test
     public void badToken() throws Exception {
 
-        // mock action (based on verified actual behavior) //
-        if (!USE_REAL_CONNECTIONS) {
-            ns.providerAdapters.put("google",
-                    new MockSuccessfulProviderAdapter() {
-                        @Override
-                        public void sendNotification(String providerId,
-                                                     Notifier notifier, Object payload,
-                                                     Notification notification, TaskTracker tracker)
-                                throws Exception {
-                            tracker.failed("InvalidRegistration",
-                                    "InvalidRegistration");
-                        }
-                    });
-        }
 
         // create push notification //
 
@@ -410,21 +351,6 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
     @Test
     public void badAPIKey() throws Exception {
 
-        if (!USE_REAL_CONNECTIONS) {
-            // mock action (based on verified actual behavior) //
-            ns.providerAdapters.put("google",
-                    new MockSuccessfulProviderAdapter() {
-                        @Override
-                        public void sendNotification(String providerId,
-                                                     Notifier notifier, Object payload,
-                                                     Notification notification, TaskTracker tracker)
-                                throws Exception {
-                            Exception e = new IOException();
-                            throw new ConnectionException(e.getMessage(), e);
-                        }
-                    });
-        }
-
         // create push notification //
 
         app.clear();


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

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


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

Branch: refs/heads/key-row-sharding
Commit: 3e1f33dc86a7c693fc1e4ab3ab406e3e57229c57
Parents: 7cd722e 97ee70f
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Oct 29 13:48:00 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Oct 29 13:48:00 2014 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityDeleteListener.java | 45 +++++++------
 .../usergrid/corepersistence/CpSetup.java       |  1 -
 .../usergrid/corepersistence/CpWalker.java      | 44 +++++++-----
 .../results/FilteringLoader.java                | 63 +++++++++--------
 .../results/ResultsLoaderFactory.java           |  5 +-
 .../results/ResultsLoaderFactoryImpl.java       |  4 --
 .../results/ResultsVerifier.java                |  6 +-
 .../results/VersionVerifier.java                |  8 ++-
 .../corepersistence/util/CpEntityMapUtils.java  |  5 +-
 .../usergrid/persistence/index/EntityIndex.java |  4 +-
 .../persistence/index/EntityIndexBatch.java     |  6 --
 .../persistence/index/EntityIndexFactory.java   |  2 -
 .../usergrid/persistence/index/IndexScope.java  |  9 +--
 .../persistence/index/guice/IndexModule.java    |  1 -
 .../index/impl/EsEntityIndexBatchImpl.java      |  3 +-
 .../index/impl/EsEntityIndexImpl.java           | 71 ++++++++++----------
 .../persistence/index/impl/EsProvider.java      | 11 ++-
 .../index/query/CandidateResults.java           |  7 +-
 .../persistence/index/query/Identifier.java     |  3 +-
 .../usergrid/persistence/index/query/Query.java | 27 +++++---
 .../persistence/index/query/Results.java        |  4 +-
 21 files changed, 169 insertions(+), 160 deletions(-)
----------------------------------------------------------------------



[02/45] git commit: pushy 4_0 upgrade

Posted by to...@apache.org.
pushy 4_0 upgrade


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

Branch: refs/heads/key-row-sharding
Commit: d5d859b707df3e293702bac4c3240c0ca3bf895e
Parents: fc3c42c
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Oct 24 13:25:37 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Oct 24 13:25:37 2014 -0600

----------------------------------------------------------------------
 .../_maven.repositories                         |   8 -
 ...14c97c6e3ef40c88590e1b196d3ec55b-javadoc.jar | Bin 160201 -> 0 bytes
 ...14c97c6e3ef40c88590e1b196d3ec55b-sources.jar | Bin 59744 -> 0 bytes
 ...63dec68314c97c6e3ef40c88590e1b196d3ec55b.jar | Bin 67751 -> 0 bytes
 ...7c6e3ef40c88590e1b196d3ec55b.jar.lastUpdated |  13 --
 ...63dec68314c97c6e3ef40c88590e1b196d3ec55b.pom | 166 -------------------
 ...7c6e3ef40c88590e1b196d3ec55b.pom.lastUpdated |  13 --
 .../pushy-0.4-apigee.pom                        | 166 -------------------
 stack/pom.xml                                   |   2 +-
 stack/services/pom.xml                          |   2 +-
 .../notifications/apns/APNsAdapter.java         |  32 ++--
 11 files changed, 18 insertions(+), 384 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d5d859b7/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/_maven.repositories
----------------------------------------------------------------------
diff --git a/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/_maven.repositories b/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/_maven.repositories
deleted file mode 100644
index 4b4ac07..0000000
--- a/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/_maven.repositories
+++ /dev/null
@@ -1,8 +0,0 @@
-#NOTE: This is an internal implementation file, its format can be changed without prior notice.
-#Wed Aug 20 23:57:49 MDT 2014
-pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.jar>local-dependencies=
-pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.pom>=
-pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b-sources.jar>=
-pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.jar>=
-pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.pom>local-dependencies=
-pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b-javadoc.jar>=

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d5d859b7/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b-javadoc.jar
----------------------------------------------------------------------
diff --git a/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b-javadoc.jar b/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b-javadoc.jar
deleted file mode 100644
index 969757f..0000000
Binary files a/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b-javadoc.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d5d859b7/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b-sources.jar
----------------------------------------------------------------------
diff --git a/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b-sources.jar b/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b-sources.jar
deleted file mode 100644
index 9e167fb..0000000
Binary files a/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b-sources.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d5d859b7/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.jar
----------------------------------------------------------------------
diff --git a/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.jar b/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.jar
deleted file mode 100644
index 3246a7a..0000000
Binary files a/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d5d859b7/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.jar.lastUpdated
----------------------------------------------------------------------
diff --git a/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.jar.lastUpdated b/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.jar.lastUpdated
deleted file mode 100644
index 592c733..0000000
--- a/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.jar.lastUpdated
+++ /dev/null
@@ -1,13 +0,0 @@
-#NOTE: This is an internal implementation file, its format can be changed without prior notice.
-#Tue Jul 29 08:11:52 MDT 2014
-http\://oss.sonatype.org/content/repositories/snapshots/.lastUpdated=1406643112428
-http\://download.java.net/maven/2/.lastUpdated=1406643110976
-http\://oss.sonatype.org/content/repositories/snapshots/.error=
-http\://download.java.net/maven/2/.error=
-http\://maven.springframework.org/milestone/.lastUpdated=1406643112690
-http\://repository.codehaus.org/.lastUpdated=1406643111574
-https\://repository-hector-dev.forge.cloudbees.com/snapshot/.error=
-http\://repository.codehaus.org/.error=
-http\://maven.springframework.org/milestone/.error=
-file\:///Users/ApigeeCorporation/Dev/apigee/apigee-URAP/m2/repository/.lastUpdated=1406643112703
-https\://repository-hector-dev.forge.cloudbees.com/snapshot/.lastUpdated=1406643111364

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d5d859b7/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.pom
----------------------------------------------------------------------
diff --git a/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.pom b/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.pom
deleted file mode 100644
index 78f6a8e..0000000
--- a/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.pom
+++ /dev/null
@@ -1,166 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>com.relayrides</groupId>
-  <artifactId>pushy</artifactId>
-  <version>0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b</version>
-  <name>Pushy</name>
-  <description>A Java library for sending push notifications</description>
-  <parent>
-    <groupId>org.sonatype.oss</groupId>
-    <artifactId>oss-parent</artifactId>
-    <version>7</version>
-  </parent>
-  <licenses>
-    <license>
-      <name>The MIT License (MIT)</name>
-      <url>http://opensource.org/licenses/MIT</url>
-      <distribution>repo</distribution>
-    </license>
-  </licenses>
-  <dependencies>
-  	<dependency>
-  		<groupId>org.slf4j</groupId>
-  		<artifactId>slf4j-api</artifactId>
-  		<version>1.7.6</version>
-  	</dependency>
-  	<dependency>
-  		<groupId>junit</groupId>
-  		<artifactId>junit</artifactId>
-  		<version>4.11</version>
-  		<scope>test</scope>
-  	</dependency>
-  	<dependency>
-  		<groupId>io.netty</groupId>
-  		<artifactId>netty-all</artifactId>
-  		<version>4.0.23.Final</version>
-  	</dependency>
-  	<dependency>
-  		<groupId>com.googlecode.json-simple</groupId>
-  		<artifactId>json-simple</artifactId>
-  		<version>1.1.1</version>
-  		<exclusions>
-  			<exclusion>
-  				<groupId>junit</groupId>
-  				<artifactId>junit</artifactId>
-  			</exclusion>
-  		</exclusions>
-  	</dependency>
-  	<dependency>
-  		<groupId>org.slf4j</groupId>
-  		<artifactId>slf4j-simple</artifactId>
-  		<version>1.7.6</version>
-  		<scope>test</scope>
-  	</dependency>
-  </dependencies>
-  <properties>
-  	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <version>3.1</version>
-        <configuration>
-          <source>1.6</source>
-          <target>1.6</target>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <version>2.16</version>
-        <configuration>
-            <argLine>-Dorg.slf4j.simpleLogger.defaultLogLevel=warn</argLine>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-javadoc-plugin</artifactId>
-        <version>2.9.1</version>
-        <configuration>
-          <overview>${basedir}/src/main/java/overview.html</overview>
-          <show>public</show>
-          <links>
-              <link>http://netty.io/4.0/api/</link>
-          </links>
-        </configuration>
-        <executions>
-          <execution>
-            <id>attach-javadocs</id>
-            <goals>
-              <goal>jar</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-source-plugin</artifactId>
-        <version>2.2.1</version>
-        <executions>
-          <execution>
-            <id>attach-sources</id>
-            <goals>
-              <goal>jar</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-  <profiles>
-    <profile>
-      <id>release-sign-artifacts</id>
-      <activation>
-        <property>
-          <name>performRelease</name>
-          <value>true</value>
-        </property>
-      </activation>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-gpg-plugin</artifactId>
-            <version>1.1</version>
-            <executions>
-              <execution>
-                <id>sign-artifacts</id>
-                <phase>verify</phase>
-                <goals>
-                  <goal>sign</goal>
-                </goals>
-              </execution>
-            </executions>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
-  </profiles>
-  <organization>
-  	<name>RelayRides</name>
-  	<url>https://relayrides.com/</url>
-  </organization>
-  <developers>
-    <developer>
-      <id>jon</id>
-      <name>Jon Chambers</name>
-	  <email>jon@relayrides.com</email>
-	  <url>https://github.com/jchambers</url>
-	  <organization>RelayRides</organization>
-	  <organizationUrl>https://relayrides.com/</organizationUrl>
-	  <roles>
-	    <role>developer</role>
-	  </roles>
-	  <timezone>-5</timezone>
-    </developer>
-  </developers>
-  <inceptionYear>2013</inceptionYear>
-  <url>http://relayrides.github.com/pushy/</url>
-  <scm>
-  	<connection>scm:git:https://github.com/relayrides/pushy.git</connection>
-  	<developerConnection>scm:git:git@github.com:relayrides/pushy.git</developerConnection>
-  	<url>https://github.com/relayrides/pushy</url>
-  </scm>
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d5d859b7/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.pom.lastUpdated
----------------------------------------------------------------------
diff --git a/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.pom.lastUpdated b/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.pom.lastUpdated
deleted file mode 100644
index 1038f38..0000000
--- a/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b.pom.lastUpdated
+++ /dev/null
@@ -1,13 +0,0 @@
-#NOTE: This is an internal implementation file, its format can be changed without prior notice.
-#Tue Jul 29 08:11:50 MDT 2014
-http\://oss.sonatype.org/content/repositories/snapshots/.lastUpdated=1406643109745
-http\://download.java.net/maven/2/.lastUpdated=1406643106235
-http\://oss.sonatype.org/content/repositories/snapshots/.error=
-http\://download.java.net/maven/2/.error=
-http\://maven.springframework.org/milestone/.lastUpdated=1406643110610
-http\://repository.codehaus.org/.lastUpdated=1406643107580
-https\://repository-hector-dev.forge.cloudbees.com/snapshot/.error=
-http\://repository.codehaus.org/.error=
-http\://maven.springframework.org/milestone/.error=
-file\:///Users/ApigeeCorporation/Dev/apigee/apigee-URAP/m2/repository/.lastUpdated=1406643110624
-https\://repository-hector-dev.forge.cloudbees.com/snapshot/.lastUpdated=1406643107290

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d5d859b7/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee.pom
----------------------------------------------------------------------
diff --git a/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee.pom b/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee.pom
deleted file mode 100644
index 39f61e3..0000000
--- a/stack/m2/repository/com/relayrides/pushy/0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b/pushy-0.4-apigee.pom
+++ /dev/null
@@ -1,166 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>com.relayrides</groupId>
-  <artifactId>pushy</artifactId>
-  <version>0.4-apigee</version>
-  <name>Pushy</name>
-  <description>A Java library for sending push notifications</description>
-  <parent>
-    <groupId>org.sonatype.oss</groupId>
-    <artifactId>oss-parent</artifactId>
-    <version>7</version>
-  </parent>
-  <licenses>
-    <license>
-      <name>The MIT License (MIT)</name>
-      <url>http://opensource.org/licenses/MIT</url>
-      <distribution>repo</distribution>
-    </license>
-  </licenses>
-  <dependencies>
-  	<dependency>
-  		<groupId>org.slf4j</groupId>
-  		<artifactId>slf4j-api</artifactId>
-  		<version>1.7.6</version>
-  	</dependency>
-  	<dependency>
-  		<groupId>junit</groupId>
-  		<artifactId>junit</artifactId>
-  		<version>4.11</version>
-  		<scope>test</scope>
-  	</dependency>
-  	<dependency>
-  		<groupId>io.netty</groupId>
-  		<artifactId>netty-all</artifactId>
-  		<version>4.0.21.Final</version>
-  	</dependency>
-  	<dependency>
-  		<groupId>com.googlecode.json-simple</groupId>
-  		<artifactId>json-simple</artifactId>
-  		<version>1.1.1</version>
-  		<exclusions>
-  			<exclusion>
-  				<groupId>junit</groupId>
-  				<artifactId>junit</artifactId>
-  			</exclusion>
-  		</exclusions>
-  	</dependency>
-  	<dependency>
-  		<groupId>org.slf4j</groupId>
-  		<artifactId>slf4j-simple</artifactId>
-  		<version>1.7.6</version>
-  		<scope>test</scope>
-  	</dependency>
-  </dependencies>
-  <properties>
-  	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <version>3.1</version>
-        <configuration>
-          <source>1.6</source>
-          <target>1.6</target>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <version>2.16</version>
-        <configuration>
-            <argLine>-Dorg.slf4j.simpleLogger.defaultLogLevel=warn</argLine>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-javadoc-plugin</artifactId>
-        <version>2.9.1</version>
-        <configuration>
-          <overview>${basedir}/src/main/java/overview.html</overview>
-          <show>public</show>
-          <links>
-              <link>http://netty.io/4.0/api/</link>
-          </links>
-        </configuration>
-        <executions>
-          <execution>
-            <id>attach-javadocs</id>
-            <goals>
-              <goal>jar</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-source-plugin</artifactId>
-        <version>2.2.1</version>
-        <executions>
-          <execution>
-            <id>attach-sources</id>
-            <goals>
-              <goal>jar</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-  <profiles>
-    <profile>
-      <id>release-sign-artifacts</id>
-      <activation>
-        <property>
-          <name>performRelease</name>
-          <value>true</value>
-        </property>
-      </activation>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-gpg-plugin</artifactId>
-            <version>1.1</version>
-            <executions>
-              <execution>
-                <id>sign-artifacts</id>
-                <phase>verify</phase>
-                <goals>
-                  <goal>sign</goal>
-                </goals>
-              </execution>
-            </executions>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
-  </profiles>
-  <organization>
-  	<name>RelayRides</name>
-  	<url>https://relayrides.com/</url>
-  </organization>
-  <developers>
-    <developer>
-      <id>jon</id>
-      <name>Jon Chambers</name>
-	  <email>jon@relayrides.com</email>
-	  <url>https://github.com/jchambers</url>
-	  <organization>RelayRides</organization>
-	  <organizationUrl>https://relayrides.com/</organizationUrl>
-	  <roles>
-	    <role>developer</role>
-	  </roles>
-	  <timezone>-5</timezone>
-    </developer>
-  </developers>
-  <inceptionYear>2013</inceptionYear>
-  <url>http://relayrides.github.com/pushy/</url>
-  <scm>
-  	<connection>scm:git:https://github.com/relayrides/pushy.git</connection>
-  	<developerConnection>scm:git:git@github.com:relayrides/pushy.git</developerConnection>
-  	<url>https://github.com/relayrides/pushy</url>
-  </scm>
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d5d859b7/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index b752b2b..2a2fcb0 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -1436,7 +1436,7 @@
         <groupId>com.relayrides</groupId>
         <artifactId>pushy</artifactId>
         <!-- The sha in the version is the git commit used in this build.  Check out the pushy source, then this commit to build the library locally -->
-        <version>0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b</version>
+        <version>0.4</version>
       </dependency>
 
       <dependency>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d5d859b7/stack/services/pom.xml
----------------------------------------------------------------------
diff --git a/stack/services/pom.xml b/stack/services/pom.xml
index e401440..0537613 100644
--- a/stack/services/pom.xml
+++ b/stack/services/pom.xml
@@ -564,7 +564,7 @@
       <groupId>com.relayrides</groupId>
       <artifactId>pushy</artifactId>
       <!-- The sha in the version is the git commit used in this build.  Check out the pushy source, then this commit to build the library locally -->
-      <version>0.4-apigee-63dec68314c97c6e3ef40c88590e1b196d3ec55b</version>
+      <version>0.4</version>
     </dependency>
 
     <dependency>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d5d859b7/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
index 01fda92..4277b8a 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
@@ -21,6 +21,7 @@ import com.google.common.cache.*;
 import com.relayrides.pushy.apns.*;
 import com.relayrides.pushy.apns.util.*;
 
+import io.netty.channel.nio.NioEventLoopGroup;
 import org.apache.usergrid.persistence.entities.Notification;
 import org.apache.usergrid.persistence.entities.Notifier;
 import org.mortbay.util.ajax.JSON;
@@ -122,22 +123,8 @@ public class APNsAdapter implements ProviderAdapter {
     public Map<String, Date> getInactiveDevices(Notifier notifier,
             EntityManager em) throws Exception {
         Map<String,Date> map = new HashMap<String,Date>();
-        if(isMock(notifier)){
-            return map;
-        }
         PushManager<SimpleApnsPushNotification> pushManager = getPushManager(notifier);
-
-        List<ExpiredToken> tokens = null;
-        try {
-            tokens = pushManager.getExpiredTokens();
-        }catch (FeedbackConnectionException fce){
-            logger.debug("Failed to get tokens",fce);
-            return map;
-        }
-        for(ExpiredToken token : tokens){
-            String expiredToken = new String(token.getToken());
-            map.put(expiredToken, token.getExpiration());
-        }
+        pushManager.requestExpiredTokens();
         return map;
     }
 
@@ -179,13 +166,26 @@ public class APNsAdapter implements ProviderAdapter {
                 public PushManager<SimpleApnsPushNotification> load(Notifier notifier) {
                     try {
                         LinkedBlockingQueue<SimpleApnsPushNotification> queue = new LinkedBlockingQueue<SimpleApnsPushNotification>();
+                        NioEventLoopGroup group = new NioEventLoopGroup();
                         PushManagerConfiguration config = new PushManagerConfiguration();
                         config.setConcurrentConnectionCount(Runtime.getRuntime().availableProcessors() * 2);
-                        PushManager<SimpleApnsPushNotification> pushManager =  new PushManager<SimpleApnsPushNotification>(getApnsEnvironment(notifier), getSSLContext(notifier), null, null, queue, config);
+                        PushManager<SimpleApnsPushNotification> pushManager =  new PushManager<>(getApnsEnvironment(notifier), getSSLContext(notifier), group,null , queue, config,notifier.getName());
                         //only tested when a message is sent
                         pushManager.registerRejectedNotificationListener(new RejectedAPNsListener());
                         //this will get tested when start is called
                         pushManager.registerFailedConnectionListener(new FailedConnectionListener());
+
+                        pushManager.registerExpiredTokenListener(new ExpiredTokenListener<SimpleApnsPushNotification>() {
+                            @Override
+                            public void handleExpiredTokens(PushManager<? extends SimpleApnsPushNotification> pushManager, Collection<ExpiredToken> expiredTokens) {
+                                Map<String,Date> map = new HashMap<String,Date>();
+                                for(ExpiredToken token : expiredTokens){
+                                    String expiredToken = new String(token.getToken());
+                                    map.put(expiredToken, token.getExpiration());
+                                }
+                                //TODO figure out way to call back and clear out em references
+                            }
+                        });
                         try {
                             if (!pushManager.isStarted()) { //ensure manager is started
                                 pushManager.start();


[43/45] git commit: changing tab order in portal

Posted by to...@apache.org.
changing tab order in portal


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

Branch: refs/heads/key-row-sharding
Commit: 0bfca7e39e40c4efd8e9344303167655c2e1b2d5
Parents: 3e1f33d
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Oct 29 14:12:48 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Oct 29 14:12:48 2014 -0600

----------------------------------------------------------------------
 portal/js/push/push-config.html | 89 ++++++++++++++++++------------------
 1 file changed, 45 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0bfca7e3/portal/js/push/push-config.html
----------------------------------------------------------------------
diff --git a/portal/js/push/push-config.html b/portal/js/push/push-config.html
index b4ab1a3..1184964 100644
--- a/portal/js/push/push-config.html
+++ b/portal/js/push/push-config.html
@@ -6,16 +6,16 @@
   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.
 -->
-    <page-title icon="&#9874;" title="Configuration"></page-title>
+    <page-title icon="&#9874;" title="Configure Notifiers"></page-title>
 
 
   <bsmodal id="deleteNotifier"
@@ -30,6 +30,47 @@
 
   <a style="float: right" target="_blank" href="http://apigee.com/docs/usergrid/content/push-notifications" class="notifications-links">Learn more in our docs</a>
   <tabs>
+    <pane heading="Notifiers">
+
+        <bsmodal id="deleteNotifiers"
+                 title="Are you sure you want to delete the notifiers(s)?"
+                 close="hideModal"
+                 closelabel="Cancel"
+                 extrabutton="deleteNotifiersDialog"
+                 extrabuttonlabel="Delete"
+                 ng-cloak>
+            <fieldset>
+                <div class="control-group">
+                </div>
+            </fieldset>
+        </bsmodal>
+
+      <span  class="button-strip">
+        <button class="btn btn-primary" ng-disabled="!valueSelected(notifiersCollection._list)" ng-click="deleteNotifiersDialog()">Delete Notifier(s)</button>
+      </span>
+      <table class="table table-striped collection-list">
+        <tbody>
+        <tr class="zebraRows notifications-row">
+          <td style="width: 30px;"><input type="checkbox"  ng-click="selectAllEntities(notifiersCollection._list,this,'queryBoxesSelected',true)"></td>
+          <td class="notifications-details bold-header">Provider</td>
+          <td class="notifications-details bold-header">Notifier</td>
+        </tr>
+
+        <tr class="zebraRows notifications-row" ng-repeat="notifier in notifiersCollection._list">
+          <td>
+            <input
+              type="checkbox"
+              ng-value="notifier.uuid"
+
+              ng-model="notifier.checked"
+              >
+          </td>
+          <td class="details">{{notifier.get('provider')}}</td>
+          <td class="details">{{notifier.get('name')}}</td>
+        </tr>
+      </table>
+    </pane>
+
     <pane heading="Apple">
       <div style="margin-top: 10px;"> <!-- ng-controller="PushConfigCtrl"-->
         <div class="user-header-title">Apple Push Notification Service</div>
@@ -117,48 +158,8 @@
       </div>
 
     </pane>
-    <pane heading="Notifiers">
-
-        <bsmodal id="deleteNotifiers"
-                 title="Are you sure you want to delete the notifiers(s)?"
-                 close="hideModal"
-                 closelabel="Cancel"
-                 extrabutton="deleteNotifiersDialog"
-                 extrabuttonlabel="Delete"
-                 ng-cloak>
-            <fieldset>
-                <div class="control-group">
-                </div>
-            </fieldset>
-        </bsmodal>
-
-      <span  class="button-strip">
-        <button class="btn btn-primary" ng-disabled="!valueSelected(notifiersCollection._list)" ng-click="deleteNotifiersDialog()">Delete Notifier(s)</button>
-      </span>
-      <table class="table table-striped collection-list">
-        <tbody>
-        <tr class="zebraRows notifications-row">
-          <td style="width: 30px;"><input type="checkbox"  ng-click="selectAllEntities(notifiersCollection._list,this,'queryBoxesSelected',true)"></td>
-          <td class="notifications-details bold-header">Provider</td>
-          <td class="notifications-details bold-header">Notifier</td>
-        </tr>
-
-        <tr class="zebraRows notifications-row" ng-repeat="notifier in notifiersCollection._list">
-          <td>
-            <input
-              type="checkbox"
-              ng-value="notifier.uuid"
-
-              ng-model="notifier.checked"
-              >
-          </td>
-          <td class="details">{{notifier.get('provider')}}</td>
-          <td class="details">{{notifier.get('name')}}</td>
-        </tr>
-      </table>
-    </pane>
 
 
   </tabs>
 
-</div>
\ No newline at end of file
+</div>


[33/45] git commit: move queue maanger behind interface

Posted by to...@apache.org.
move queue maanger behind interface


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

Branch: refs/heads/key-row-sharding
Commit: 8f4720db79534172f964378c08b5f51884e046d0
Parents: 955a92b
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Oct 29 11:05:27 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Oct 29 11:05:27 2014 -0600

----------------------------------------------------------------------
 .../notifications/ApplicationQueueManager.java  | 532 +------------------
 .../notifications/InactiveDeviceManager.java    |   3 +-
 .../notifications/NotificationsService.java     |  14 +-
 .../services/notifications/QueueListener.java   |   7 +-
 .../services/notifications/TaskManager.java     |  17 +-
 .../apns/ExpiredTokenListener.java              |   8 -
 .../impl/ApplicationQueueManagerImpl.java       | 523 ++++++++++++++++++
 .../apns/NotificationsServiceIT.java            |   7 +-
 .../gcm/NotificationsServiceIT.java             |   7 +-
 9 files changed, 569 insertions(+), 549 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f4720db/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
index 1058c34..8012b42 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
@@ -1,526 +1,48 @@
 /*
- * 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
+ *  * 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.
  *
- * 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.services.notifications;
 
-import com.clearspring.analytics.hash.MurmurHash;
-import com.clearspring.analytics.stream.frequency.CountMinSketch;
-import com.codahale.metrics.Meter;
 import org.apache.usergrid.batch.JobExecution;
-import org.apache.usergrid.metrics.MetricsFactory;
-import org.apache.usergrid.persistence.*;
-import org.apache.usergrid.persistence.entities.Device;
 import org.apache.usergrid.persistence.entities.Notification;
-import org.apache.usergrid.persistence.entities.Notifier;
-import org.apache.usergrid.persistence.entities.Receipt;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.queue.QueueManager;
 import org.apache.usergrid.persistence.queue.QueueMessage;
-import org.apache.usergrid.services.notifications.apns.APNsAdapter;
-import org.apache.usergrid.services.notifications.gcm.GCMAdapter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import rx.Observable;
-import rx.Subscriber;
-import rx.functions.Action1;
-import rx.functions.Func1;
-import rx.schedulers.Schedulers;
-
-import java.security.Provider;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicInteger;
 
+import java.util.List;
 
-public class ApplicationQueueManager  {
+/**
+ * Classy class class.
+ */
+public interface ApplicationQueueManager {
 
-    public static  String DEFAULT_QUEUE_NAME = "push_v1";
     public static final String DEFAULT_QUEUE_PROPERTY = "usergrid.notifications.listener.queue";
-    private static final Logger LOG = LoggerFactory.getLogger(ApplicationQueueManager.class);
-
-    //this is for tests, will not mark initial post complete, set to false for tests
 
-    private static ExecutorService INACTIVE_DEVICE_CHECK_POOL = Executors.newFixedThreadPool(5);
     public static final String NOTIFIER_ID_POSTFIX = ".notifier.id";
 
-    private final EntityManager em;
-    private final QueueManager qm;
-    private final JobScheduler jobScheduler;
-    private final MetricsFactory metricsFactory;
-    private final String queueName;
-
-    HashMap<Object, ProviderAdapter> notifierHashMap; // only retrieve notifiers once
-
-
-    public ApplicationQueueManager(JobScheduler jobScheduler, EntityManager entityManager, QueueManager queueManager, MetricsFactory metricsFactory, Properties properties){
-        this.em = entityManager;
-        this.qm = queueManager;
-        this.jobScheduler = jobScheduler;
-        this.metricsFactory = metricsFactory;
-        this.queueName = getQueueNames(properties);
-
-    }
-
-    public boolean scheduleQueueJob(Notification notification) throws Exception{
-        return jobScheduler.scheduleQueueJob(notification);
-    }
-
-    public void queueNotification(final Notification notification, final JobExecution jobExecution) throws Exception {
-        if(scheduleQueueJob(notification)){
-            em.update(notification);
-            return;
-        }
-        final Meter queueMeter = metricsFactory.getMeter(ApplicationQueueManager.class,"queue");
-        long startTime = System.currentTimeMillis();
-
-        if (notification.getCanceled() == Boolean.TRUE) {
-            LOG.info("notification " + notification.getUuid() + " canceled");
-            if (jobExecution != null) {
-                jobExecution.killed();
-            }
-            return;
-        }
-
-        LOG.info("notification {} start queuing", notification.getUuid());
-
-        final PathQuery<Device> pathQuery = notification.getPathQuery() ; //devices query
-        final AtomicInteger deviceCount = new AtomicInteger(); //count devices so you can make a judgement on batching
-        final ConcurrentLinkedQueue<String> errorMessages = new ConcurrentLinkedQueue<String>(); //build up list of issues
-
-        final HashMap<Object,ProviderAdapter> notifierMap =  getNotifierMap();
-
-        //get devices in querystring, and make sure you have access
-        if (pathQuery != null) {
-            LOG.info("notification {} start query", notification.getUuid());
-            final Iterator<Device> iterator = pathQuery.iterator(em);
-            //if there are more pages (defined by PAGE_SIZE) you probably want this to be async, also if this is already a job then don't reschedule
-            if (iterator instanceof ResultsIterator && ((ResultsIterator) iterator).hasPages() && jobExecution == null) {
-                jobScheduler.scheduleQueueJob(notification, true);
-                em.update(notification);
-                return;
-            }
-            final CountMinSketch sketch = new CountMinSketch(0.0001,.99,7364181); //add probablistic counter to find dups
-            final UUID appId = em.getApplication().getUuid();
-            final Map<String,Object> payloads = notification.getPayloads();
-
-            final Func1<Entity,Entity> entityListFunct = new Func1<Entity, Entity>() {
-                @Override
-                public Entity call(Entity entity) {
-
-                    try {
-
-                        long now = System.currentTimeMillis();
-                        List<EntityRef> devicesRef = getDevices(entity); // resolve group
-
-                        LOG.info("notification {} queue  {} devices, duration "+(System.currentTimeMillis()-now)+" ms", notification.getUuid(), devicesRef.size());
-
-                        for (EntityRef deviceRef : devicesRef) {
-                            LOG.info("notification {} starting to queue device {} ", notification.getUuid(), deviceRef.getUuid());
-                            long hash = MurmurHash.hash(deviceRef.getUuid());
-                            if (sketch.estimateCount(hash) > 0) { //look for duplicates
-                                LOG.warn("Maybe Found duplicate device: {}", deviceRef.getUuid());
-                                continue;
-                            } else {
-                                sketch.add(hash, 1);
-                            }
-                            String notifierId = null;
-                            String notifierKey = null;
-
-                            //find the device notifier info, match it to the payload
-                            for (Map.Entry<String, Object> entry : payloads.entrySet()) {
-                                ProviderAdapter adapter = notifierMap.get(entry.getKey().toLowerCase());
-                                now = System.currentTimeMillis();
-                                String providerId = getProviderId(deviceRef, adapter.getNotifier());
-                                if (providerId != null) {
-                                    notifierId = providerId;
-                                    notifierKey = entry.getKey().toLowerCase();
-                                    break;
-                                }
-                                LOG.info("Provider query for notification {} device {} took "+(System.currentTimeMillis()-now)+" ms",notification.getUuid(),deviceRef.getUuid());
-                            }
-
-                            if (notifierId == null) {
-                                LOG.info("Notifier did not match for device {} ", deviceRef);
-                                continue;
-                            }
-
-                            ApplicationQueueMessage message = new ApplicationQueueMessage(appId, notification.getUuid(), deviceRef.getUuid(), notifierKey, notifierId);
-                            if (notification.getQueued() == null) {
-                                // update queued time
-                                now = System.currentTimeMillis();
-                                notification.setQueued(System.currentTimeMillis());
-                                LOG.info("notification {} device {} queue time set. duration "+(System.currentTimeMillis()-now)+" ms", notification.getUuid(), deviceRef.getUuid());
-                            }
-                            now = System.currentTimeMillis();
-                            qm.sendMessage(message);
-                            LOG.info("notification {} post-queue to device {} duration " + (System.currentTimeMillis() - now) + " ms "+queueName+" queue", notification.getUuid(), deviceRef.getUuid());
-                            deviceCount.incrementAndGet();
-                            queueMeter.mark();
-                        }
-                    } catch (Exception deviceLoopException) {
-                        LOG.error("Failed to add devices", deviceLoopException);
-                        errorMessages.add("Failed to add devices for entity: " + entity.getUuid() + " error:" + deviceLoopException);
-                    }
-                    return entity;
-                }
-            };
-
-            long now = System.currentTimeMillis();
-            Observable o = rx.Observable.create(new IteratorObservable<Entity>(iterator))
-                    .parallel(new Func1<Observable<Entity>, Observable<Entity>>() {
-                        @Override
-                        public rx.Observable<Entity> call(rx.Observable<Entity> deviceObservable) {
-                            return deviceObservable.map(entityListFunct);
-                        }
-                    }, Schedulers.io())
-                    .doOnError(new Action1<Throwable>() {
-                        @Override
-                        public void call(Throwable throwable) {
-                            LOG.error("Failed while writing", throwable);
-                        }
-                    });
-            o.toBlocking().lastOrDefault(null);
-            LOG.info("notification {} done queueing duration {} ms", notification.getUuid(), System.currentTimeMillis() - now);
-        }
-
-        // update queued time
-        Map<String, Object> properties = new HashMap<String, Object>(2);
-        properties.put("queued", notification.getQueued());
-        properties.put("state", notification.getState());
-        if(errorMessages.size()>0){
-            if (notification.getErrorMessage() == null) {
-                notification.setErrorMessage("There was a problem delivering all of your notifications. See deliveryErrors in properties");
-            }
-        }
-
-        notification.setExpectedCount(deviceCount.get());
-        notification.addProperties(properties);
-        long now = System.currentTimeMillis();
-
-
-        LOG.info("notification {} updated notification duration {} ms", notification.getUuid(), System.currentTimeMillis() - now);
-
-        //do i have devices, and have i already started batching.
-        if (deviceCount.get() <= 0 || !notification.getDebug()) {
-            TaskManager taskManager = new TaskManager(em, this, notification);
-            //if i'm in a test value will be false, do not mark finished for test orchestration, not ideal need real tests
-            taskManager.finishedBatch(false,true);
-        }else {
-            em.update(notification);
-        }
-
-        long elapsed = notification.getQueued() != null ? notification.getQueued() - startTime : 0;
-        LOG.info("notification {} done queuing to {} devices in " + elapsed + " ms", notification.getUuid().toString(), deviceCount.get());
-    }
-
-    /**
-     * only need to get notifiers once. will reset on next batch
-     * @return
-     */
-    public HashMap<Object,ProviderAdapter> getNotifierMap(){
-        if(notifierHashMap == null) {
-            long now = System.currentTimeMillis();
-            notifierHashMap = new HashMap<Object, ProviderAdapter>();
-            Query query = new Query();
-            query.setCollection("notifiers");
-            query.setLimit(100);
-            PathQuery<Notifier> pathQuery = new PathQuery<Notifier>(
-                    new SimpleEntityRef(em.getApplicationRef()),
-                    query
-            );
-            Iterator<Notifier> notifierIterator = pathQuery.iterator(em);
-            int count = 0;
-            while (notifierIterator.hasNext()) {
-                Notifier notifier = notifierIterator.next();
-                String name = notifier.getName() != null ? notifier.getName() : "";
-                UUID uuid = notifier.getUuid() != null ? notifier.getUuid() : UUID.randomUUID();
-                ProviderAdapter providerAdapter = ProviderAdapterFactory.getProviderAdapter(notifier,em);
-                notifierHashMap.put(name.toLowerCase(), providerAdapter);
-                notifierHashMap.put(uuid, providerAdapter);
-                notifierHashMap.put(uuid.toString(), providerAdapter);
-                if(count++ >= 100){
-                    LOG.error("ApplicationQueueManager: too many notifiers...breaking out ", notifierHashMap.size());
-                    break;
-                }
-            }
-            LOG.info("ApplicationQueueManager: fetching notifiers finished size={}, duration {} ms", notifierHashMap.size(),System.currentTimeMillis() - now);
-        }
-        return notifierHashMap;
-    }
-
-    /**
-     * send batches of notifications to provider
-     * @param messages
-     * @throws Exception
-     */
-    public Observable sendBatchToProviders( final List<QueueMessage> messages, final String queuePath) {
-        LOG.info("sending batch of {} notifications.", messages.size());
-        final Meter sendMeter = metricsFactory.getMeter(NotificationsService.class, "send");
-
-        final Map<Object, ProviderAdapter> notifierMap = getNotifierMap();
-        final ApplicationQueueManager proxy = this;
-        final ConcurrentHashMap<UUID,TaskManager> taskMap = new ConcurrentHashMap<UUID, TaskManager>(messages.size());
-        final ConcurrentHashMap<UUID,Notification> notificationMap = new ConcurrentHashMap<UUID, Notification>(messages.size());
-
-        final Func1<QueueMessage, ApplicationQueueMessage> func = new Func1<QueueMessage, ApplicationQueueMessage>() {
-            @Override
-            public ApplicationQueueMessage call(QueueMessage queueMessage) {
-                boolean messageCommitted = false;
-                ApplicationQueueMessage message = null;
-                try {
-                    message = (ApplicationQueueMessage) queueMessage.getBody();
-                    LOG.info("start sending notification for device {} for Notification: {} on thread "+Thread.currentThread().getId(), message.getDeviceId(), message.getNotificationId());
-
-                    UUID deviceUUID = message.getDeviceId();
-
-                    Notification notification = notificationMap.get(message.getNotificationId());
-                    if (notification == null) {
-                        notification = em.get(message.getNotificationId(), Notification.class);
-                        notificationMap.put(message.getNotificationId(), notification);
-                    }
-                    TaskManager taskManager = taskMap.get(message.getNotificationId());
-                    if (taskManager == null) {
-                        taskManager = new TaskManager(em, proxy, notification);
-                        taskMap.putIfAbsent(message.getNotificationId(), taskManager);
-                        taskManager = taskMap.get(message.getNotificationId());
-                    }
-
-                    final Map<String, Object> payloads = notification.getPayloads();
-                    final Map<String, Object> translatedPayloads = translatePayloads(payloads, notifierMap);
-                    LOG.info("sending notification for device {} for Notification: {}", deviceUUID, notification.getUuid());
-
-                    try {
-                        String notifierName = message.getNotifierKey().toLowerCase();
-                        ProviderAdapter providerAdapter = notifierMap.get(notifierName.toLowerCase());
-                        Object payload = translatedPayloads.get(notifierName);
-                        Receipt receipt = new Receipt(notification.getUuid(), message.getNotifierId(), payload, deviceUUID);
-                        TaskTracker tracker = new TaskTracker(providerAdapter.getNotifier(), taskManager, receipt, deviceUUID);
-                        if(!isOkToSend(notification)){
-                             tracker.failed(0, "Notification is duplicate/expired/cancelled.");
-                        }else {
-                            if (payload == null) {
-                                LOG.debug("selected device {} for notification {} doesn't have a valid payload. skipping.", deviceUUID, notification.getUuid());
-                                tracker.failed(0, "failed to match payload to " + message.getNotifierId() + " notifier");
-                            } else {
-                                long now = System.currentTimeMillis();
-                                try {
-                                    providerAdapter.sendNotification(message.getNotifierId(), payload, notification, tracker);
-                                } catch (Exception e) {
-                                    tracker.failed(0, e.getMessage());
-                                } finally {
-                                    LOG.info("sending to device {} for Notification: {} duration " + (System.currentTimeMillis() - now) + " ms", deviceUUID, notification.getUuid());
-                                }
-                            }
-                        }
-                        messageCommitted = true;
-                    } finally {
-                        sendMeter.mark();
-                    }
-
-                } catch (Exception e) {
-                    LOG.error("Failure while sending",e);
-                    try {
-                        if(!messageCommitted && queuePath != null) {
-                            qm.commitMessage(queueMessage);
-                        }
-                    }catch (Exception queueException){
-                        LOG.error("Failed to commit message.",queueException);
-                    }
-                }
-                return message;
-            }
-        };
-        Observable o = rx.Observable.from(messages)
-                .parallel(new Func1<rx.Observable<QueueMessage>, rx.Observable<ApplicationQueueMessage>>() {
-                    @Override
-                    public rx.Observable<ApplicationQueueMessage> call(rx.Observable<QueueMessage> messageObservable) {
-                        return messageObservable.map(func);
-                    }
-                }, Schedulers.io())
-                .buffer(messages.size())
-                .map(new Func1<List<ApplicationQueueMessage>, HashMap<UUID, ApplicationQueueMessage>>() {
-                    @Override
-                    public HashMap<UUID, ApplicationQueueMessage> call(List<ApplicationQueueMessage> queueMessages) {
-                        //for gcm this will actually send notification
-                        for (ProviderAdapter providerAdapter : notifierMap.values()) {
-                            try {
-                                providerAdapter.doneSendingNotifications();
-                            } catch (Exception e) {
-                                LOG.error("providerAdapter.doneSendingNotifications: ", e);
-                            }
-                        }
-                        //TODO: check if a notification is done and mark it
-                        HashMap<UUID, ApplicationQueueMessage> notifications = new HashMap<UUID, ApplicationQueueMessage>();
-                        for (ApplicationQueueMessage message : queueMessages) {
-                            if (notifications.get(message.getNotificationId()) == null) {
-                                try {
-                                    TaskManager taskManager = taskMap.get(message.getNotificationId());
-                                    notifications.put(message.getNotificationId(), message);
-                                    taskManager.finishedBatch();
-                                } catch (Exception e) {
-                                    LOG.error("Failed to finish batch", e);
-                                }
-                            }
-
-                        }
-                        return notifications;
-                    }
-                })
-                .doOnError(new Action1<Throwable>() {
-                    @Override
-                    public void call(Throwable throwable) {
-                        LOG.error("Failed while sending",throwable);
-                    }
-                });
-        return o;
-    }
-
-    public void stop(){
-        for(ProviderAdapter adapter : getNotifierMap().values()){
-            try {
-                adapter.stop();
-            }catch (Exception e){
-                LOG.error("failed to stop adapter",e);
-            }
-        }
-    }
-
-
-    /**
-     * Call the adapter with the notifier
-     */
-    private Map<String, Object> translatePayloads(Map<String, Object> payloads, Map<Object, ProviderAdapter> notifierMap) throws Exception {
-        Map<String, Object> translatedPayloads = new HashMap<String, Object>(  payloads.size());
-        for (Map.Entry<String, Object> entry : payloads.entrySet()) {
-            String payloadKey = entry.getKey().toLowerCase();
-            Object payloadValue = entry.getValue();
-            ProviderAdapter providerAdapter = notifierMap.get(payloadKey);
-            if (providerAdapter != null) {
-                Object translatedPayload = payloadValue != null ? providerAdapter.translatePayload(payloadValue) : null;
-                if (translatedPayload != null) {
-                    translatedPayloads.put(payloadKey, translatedPayload);
-                }
-            }
-        }
-        return translatedPayloads;
-    }
-
-    public static String getQueueNames(Properties properties) {
-        String name = properties.getProperty(ApplicationQueueManager.DEFAULT_QUEUE_PROPERTY,ApplicationQueueManager.DEFAULT_QUEUE_NAME);
-        return name;
-    }
-
-    private static final class IteratorObservable<T> implements rx.Observable.OnSubscribe<T> {
-        private final Iterator<T> input;
-        private IteratorObservable( final Iterator input ) {this.input = input;}
-
-        @Override
-        public void call( final Subscriber<? super T> subscriber ) {
-
-            /**
-             * You would replace this code with your file reading.  Instead of emitting from an iterator,
-             * you would create a bean object that represents the entity, and then emit it
-             */
-
-            try {
-                while ( !subscriber.isUnsubscribed() && input.hasNext() ) {
-                    //send our input to the next
-                    subscriber.onNext( (T) input.next() );
-                }
-
-                //tell the subscriber we don't have any more data
-                subscriber.onCompleted();
-            }
-            catch ( Throwable t ) {
-                LOG.error("failed on subscriber",t);
-                subscriber.onError( t );
-            }
-        }
-    }
-
-    public void asyncCheckForInactiveDevices() throws Exception {
-        Collection<ProviderAdapter> providerAdapters = getNotifierMap().values();
-        for (final ProviderAdapter providerAdapter : providerAdapters) {
-            try {
-                if (providerAdapter != null) {
-                    LOG.debug("checking notifier {} for inactive devices", providerAdapter.getNotifier());
-                    providerAdapter.removeInactiveDevices();
-
-                    LOG.debug("finished checking notifier {} for inactive devices",providerAdapter.getNotifier());
-                }
-            } catch (Exception e) {
-                LOG.error("checkForInactiveDevices", e); // not
-                // essential so
-                // don't fail,
-                // but log
-            }
-        }
-    }
-
-
-    private boolean isOkToSend(Notification notification) {
-        Map<String,Long> stats = notification.getStatistics();
-        if (stats != null && notification.getExpectedCount() == (stats.get("sent")+ stats.get("errors"))) {
-            LOG.info("notification {} already processed. not sending.",
-                    notification.getUuid());
-            return false;
-        }
-        if (notification.getCanceled() == Boolean.TRUE) {
-            LOG.info("notification {} canceled. not sending.",
-                    notification.getUuid());
-            return false;
-        }
-        if (notification.isExpired()) {
-            LOG.info("notification {} expired. not sending.",
-                    notification.getUuid());
-            return false;
-        }
-        return true;
-    }
-
-    private List<EntityRef> getDevices(EntityRef ref) throws Exception {
-        List<EntityRef> devices = Collections.EMPTY_LIST;
-        if ("device".equals(ref.getType())) {
-            devices = Collections.singletonList(ref);
-        } else if ("user".equals(ref.getType())) {
-            devices = em.getCollection(ref, "devices", null, Query.MAX_LIMIT,
-                    Query.Level.REFS, false).getRefs();
-        } else if ("group".equals(ref.getType())) {
-            devices = new ArrayList<EntityRef>();
-            for (EntityRef r : em.getCollection(ref, "users", null,
-                    Query.MAX_LIMIT, Query.Level.REFS, false).getRefs()) {
-                devices.addAll(getDevices(r));
-            }
-        }
-        return devices;
-    }
+    public static final  String DEFAULT_QUEUE_NAME = "push_v1";
 
+    void queueNotification(Notification notification, JobExecution jobExecution) throws Exception;
 
-    private String getProviderId(EntityRef device, Notifier notifier) throws Exception {
-        try {
-            Object value = em.getProperty(device, notifier.getName() + NOTIFIER_ID_POSTFIX);
-            if (value == null) {
-                value = em.getProperty(device, notifier.getUuid() + NOTIFIER_ID_POSTFIX);
-            }
-            return value != null ? value.toString() : null;
-        } catch (Exception e) {
-            LOG.error("Errer getting provider ID, proceding with rest of batch", e);
-            return null;
-        }
-    }
+    Observable sendBatchToProviders(List<QueueMessage> messages, String queuePath);
 
+    void stop();
 
-}
\ No newline at end of file
+    void asyncCheckForInactiveDevices() throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f4720db/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
index 82841d2..108a4a0 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
@@ -25,6 +25,7 @@ import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.Results;
 import org.apache.usergrid.persistence.entities.Notifier;
 import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.services.notifications.impl.ApplicationQueueManagerImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -45,7 +46,7 @@ public class InactiveDeviceManager {
         this.entityManager = entityManager;
     }
     public void removeInactiveDevices( Map<String,Date> inactiveDeviceMap  ){
-        final String notfierPostFix = ApplicationQueueManager.NOTIFIER_ID_POSTFIX;
+        final String notfierPostFix = ApplicationQueueManagerImpl.NOTIFIER_ID_POSTFIX;
         if (inactiveDeviceMap != null && inactiveDeviceMap.size() > 0) {
             LOG.debug("processing {} inactive devices",  inactiveDeviceMap.size());
             Map<String, Object> clearPushtokenMap = new HashMap<String, Object>( 2);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f4720db/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
index a64704c..5de4d7d 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
@@ -29,13 +29,12 @@ import org.apache.usergrid.persistence.entities.Notifier;
 import org.apache.usergrid.persistence.entities.Receipt;
 import org.apache.usergrid.persistence.index.query.Identifier;
 import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.queue.QueueManager;
 import org.apache.usergrid.persistence.queue.QueueManagerFactory;
 import org.apache.usergrid.persistence.queue.QueueScope;
 import org.apache.usergrid.persistence.queue.QueueScopeFactory;
-import org.apache.usergrid.persistence.queue.impl.QueueScopeImpl;
 import org.apache.usergrid.services.*;
+import org.apache.usergrid.services.notifications.impl.ApplicationQueueManagerImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -44,9 +43,6 @@ import org.apache.usergrid.persistence.exceptions.RequiredPropertyNotFoundExcept
 import org.apache.usergrid.services.exceptions.ForbiddenServiceOperationException;
 import static org.apache.usergrid.utils.InflectionUtils.pluralize;
 
-import org.apache.usergrid.services.notifications.apns.APNsAdapter;
-import org.apache.usergrid.services.notifications.gcm.GCMAdapter;
-import org.springframework.beans.factory.annotation.Autowired;
 import rx.Observable;
 import rx.functions.Func1;
 import rx.schedulers.Schedulers;
@@ -63,8 +59,6 @@ public class NotificationsService extends AbstractCollectionService {
     //need a mocking framework, this is to substitute for no mocking
     public static QueueManager TEST_QUEUE_MANAGER = null;
 
-    public static final String NOTIFIER_ID_POSTFIX = ".notifier.id";
-
     static final String MESSAGE_PROPERTY_DEVICE_UUID = "deviceUUID";
 
     static {
@@ -94,12 +88,12 @@ public class NotificationsService extends AbstractCollectionService {
         postMeter = metricsService.getMeter(NotificationsService.class, "requests");
         postTimer = metricsService.getTimer(this.getClass(), "execution_rest");
         JobScheduler jobScheduler = new JobScheduler(sm,em);
-        String name = ApplicationQueueManager.getQueueNames(props);
+        String name = ApplicationQueueManagerImpl.getQueueNames(props);
         QueueScopeFactory queueScopeFactory = CpSetup.getInjector().getInstance(QueueScopeFactory.class);
         QueueScope queueScope = queueScopeFactory.getScope(smf.getManagementAppId(), name);
         queueManagerFactory = CpSetup.getInjector().getInstance(QueueManagerFactory.class);
         QueueManager queueManager = TEST_QUEUE_MANAGER !=null ? TEST_QUEUE_MANAGER : queueManagerFactory.getQueueManager(queueScope);
-        notificationQueueManager = new ApplicationQueueManager(jobScheduler,em,queueManager,metricsService,props);
+        notificationQueueManager = new ApplicationQueueManagerImpl(jobScheduler,em,queueManager,metricsService,props);
         gracePeriod = jobScheduler.SCHEDULER_GRACE_PERIOD;
     }
 
@@ -262,7 +256,7 @@ public class NotificationsService extends AbstractCollectionService {
                         throw new IllegalArgumentException("notifier \""
                                 + notifierId + "\" not found");
                     }
-                    ProviderAdapter providerAdapter = ProviderAdapterFactory.getProviderAdapter(notifier,em);
+                    ProviderAdapter providerAdapter = ProviderAdapterFactory.getProviderAdapter(notifier, em);
                     Object payload = entry.getValue();
                     try {
                         return providerAdapter.translatePayload(payload); // validate

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f4720db/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
index 3c788a9..b5aaeda 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
@@ -25,12 +25,11 @@ import org.apache.usergrid.metrics.MetricsFactory;
 import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.EntityManagerFactory;
 
-import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.queue.*;
 import org.apache.usergrid.persistence.queue.QueueManager;
-import org.apache.usergrid.persistence.queue.impl.QueueScopeImpl;
 import org.apache.usergrid.services.ServiceManager;
 import org.apache.usergrid.services.ServiceManagerFactory;
+import org.apache.usergrid.services.notifications.impl.ApplicationQueueManagerImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import rx.Observable;
@@ -96,7 +95,7 @@ public class QueueListener  {
                 sleepWhenNoneFound = new Long(properties.getProperty("usergrid.notifications.listener.sleep.after", ""+DEFAULT_SLEEP)).longValue();
                 batchSize = new Integer(properties.getProperty("usergrid.notifications.listener.batchSize", (""+batchSize)));
                 consecutiveCallsToRemoveDevices = new Integer(properties.getProperty("usergrid.notifications.inactive.interval", ""+200));
-                queueName = ApplicationQueueManager.getQueueNames(properties);
+                queueName = ApplicationQueueManagerImpl.getQueueNames(properties);
 
                 int maxThreads = new Integer(properties.getProperty("usergrid.notifications.listener.maxThreads", ""+MAX_THREADS));
 
@@ -251,7 +250,7 @@ public class QueueListener  {
                                  EntityManager entityManager = emf.getEntityManager(applicationId);
                                  ServiceManager serviceManager = smf.getServiceManager(applicationId);
 
-                                 ApplicationQueueManager manager = new ApplicationQueueManager(
+                                 ApplicationQueueManagerImpl manager = new ApplicationQueueManagerImpl(
                                          new JobScheduler(serviceManager, entityManager),
                                          entityManager,
                                          queueManager,

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f4720db/stack/services/src/main/java/org/apache/usergrid/services/notifications/TaskManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/TaskManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/TaskManager.java
index 5902a93..148a2dc 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/TaskManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/TaskManager.java
@@ -23,19 +23,15 @@ import org.apache.usergrid.persistence.entities.Device;
 import org.apache.usergrid.persistence.entities.Notification;
 import org.apache.usergrid.persistence.entities.Notifier;
 import org.apache.usergrid.persistence.entities.Receipt;
-import org.apache.usergrid.persistence.queue.QueueManager;
-import org.apache.usergrid.persistence.queue.QueueMessage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLong;
 
 public class TaskManager {
 
     private static final Logger LOG = LoggerFactory.getLogger(TaskManager.class);
-    private final ApplicationQueueManager proxy;
 
     private Notification notification;
     private AtomicLong successes = new AtomicLong();
@@ -43,10 +39,9 @@ public class TaskManager {
     private EntityManager em;
     private boolean hasFinished;
 
-    public TaskManager(EntityManager em,ApplicationQueueManager proxy, Notification notification) {
+    public TaskManager(EntityManager em, Notification notification) {
         this.em = em;
         this.notification = notification;
-        this.proxy = proxy;
         hasFinished = false;
     }
 
@@ -132,14 +127,14 @@ public class TaskManager {
     protected void replaceProviderId(EntityRef device, Notifier notifier,
                                      String newProviderId) throws Exception {
         Object value = em.getProperty(device, notifier.getName()
-                + NotificationsService.NOTIFIER_ID_POSTFIX);
+                + ApplicationQueueManager.NOTIFIER_ID_POSTFIX);
         if (value != null) {
-            em.setProperty(device, notifier.getName() + NotificationsService.NOTIFIER_ID_POSTFIX, newProviderId);
+            em.setProperty(device, notifier.getName() + ApplicationQueueManager.NOTIFIER_ID_POSTFIX, newProviderId);
         } else {
             value = em.getProperty(device, notifier.getUuid()
-                    + NotificationsService.NOTIFIER_ID_POSTFIX);
+                    + ApplicationQueueManager.NOTIFIER_ID_POSTFIX);
             if (value != null) {
-                em.setProperty(device, notifier.getUuid() + NotificationsService.NOTIFIER_ID_POSTFIX, newProviderId);
+                em.setProperty(device, notifier.getUuid() + ApplicationQueueManager.NOTIFIER_ID_POSTFIX, newProviderId);
             }
         }
     }
@@ -183,7 +178,7 @@ public class TaskManager {
             LOG.info("notification finished batch: {} of {} devices in " + latency + "ms", notification.getUuid(), totals);
 
             em.update(notification);
-//        Set<Notifier> notifiers = new HashSet<>(proxy.getNotifierMap().values()); // remove dups
+//        Set<Notifier> notifiers = new HashSet<>(proxy.getAdapterMap().values()); // remove dups
 //        proxy.asyncCheckForInactiveDevices(notifiers);
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f4720db/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java
index 6408dfd..1f7984a 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/ExpiredTokenListener.java
@@ -23,15 +23,7 @@ package org.apache.usergrid.services.notifications.apns;
 import com.relayrides.pushy.apns.ExpiredToken;
 import com.relayrides.pushy.apns.PushManager;
 import com.relayrides.pushy.apns.util.SimpleApnsPushNotification;
-import org.apache.usergrid.persistence.Entity;
-import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.entities.Notifier;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.services.notifications.ApplicationQueueManager;
 import org.apache.usergrid.services.notifications.InactiveDeviceManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.util.Collection;
 import java.util.Date;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f4720db/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
new file mode 100644
index 0000000..c8c5165
--- /dev/null
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
@@ -0,0 +1,523 @@
+/*
+ * 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.services.notifications.impl;
+
+import com.clearspring.analytics.hash.MurmurHash;
+import com.clearspring.analytics.stream.frequency.CountMinSketch;
+import com.codahale.metrics.Meter;
+import org.apache.usergrid.batch.JobExecution;
+import org.apache.usergrid.metrics.MetricsFactory;
+import org.apache.usergrid.persistence.*;
+import org.apache.usergrid.persistence.entities.Device;
+import org.apache.usergrid.persistence.entities.Notification;
+import org.apache.usergrid.persistence.entities.Notifier;
+import org.apache.usergrid.persistence.entities.Receipt;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.queue.QueueManager;
+import org.apache.usergrid.persistence.queue.QueueMessage;
+import org.apache.usergrid.services.notifications.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import rx.Observable;
+import rx.Subscriber;
+import rx.functions.Action1;
+import rx.functions.Func1;
+import rx.schedulers.Schedulers;
+
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.AtomicInteger;
+
+
+public class ApplicationQueueManagerImpl implements ApplicationQueueManager {
+
+    private static final Logger LOG = LoggerFactory.getLogger(ApplicationQueueManagerImpl.class);
+
+    //this is for tests, will not mark initial post complete, set to false for tests
+
+    private final EntityManager em;
+    private final QueueManager qm;
+    private final JobScheduler jobScheduler;
+    private final MetricsFactory metricsFactory;
+    private final String queueName;
+
+    HashMap<Object, ProviderAdapter> notifierHashMap; // only retrieve notifiers once
+
+
+    public ApplicationQueueManagerImpl(JobScheduler jobScheduler, EntityManager entityManager, QueueManager queueManager, MetricsFactory metricsFactory, Properties properties){
+        this.em = entityManager;
+        this.qm = queueManager;
+        this.jobScheduler = jobScheduler;
+        this.metricsFactory = metricsFactory;
+        this.queueName = getQueueNames(properties);
+
+    }
+
+    private boolean scheduleQueueJob(Notification notification) throws Exception{
+        return jobScheduler.scheduleQueueJob(notification);
+    }
+
+    @Override
+    public void queueNotification(final Notification notification, final JobExecution jobExecution) throws Exception {
+        if(scheduleQueueJob(notification)){
+            em.update(notification);
+            return;
+        }
+        final Meter queueMeter = metricsFactory.getMeter(ApplicationQueueManagerImpl.class,"queue");
+        long startTime = System.currentTimeMillis();
+
+        if (notification.getCanceled() == Boolean.TRUE) {
+            LOG.info("notification " + notification.getUuid() + " canceled");
+            if (jobExecution != null) {
+                jobExecution.killed();
+            }
+            return;
+        }
+
+        LOG.info("notification {} start queuing", notification.getUuid());
+
+        final PathQuery<Device> pathQuery = notification.getPathQuery() ; //devices query
+        final AtomicInteger deviceCount = new AtomicInteger(); //count devices so you can make a judgement on batching
+        final ConcurrentLinkedQueue<String> errorMessages = new ConcurrentLinkedQueue<String>(); //build up list of issues
+
+
+        //get devices in querystring, and make sure you have access
+        if (pathQuery != null) {
+            final HashMap<Object,ProviderAdapter> notifierMap =  getAdapterMap();
+            LOG.info("notification {} start query", notification.getUuid());
+            final Iterator<Device> iterator = pathQuery.iterator(em);
+            //if there are more pages (defined by PAGE_SIZE) you probably want this to be async, also if this is already a job then don't reschedule
+            if (iterator instanceof ResultsIterator && ((ResultsIterator) iterator).hasPages() && jobExecution == null) {
+                jobScheduler.scheduleQueueJob(notification, true);
+                em.update(notification);
+                return;
+            }
+            final CountMinSketch sketch = new CountMinSketch(0.0001,.99,7364181); //add probablistic counter to find dups
+            final UUID appId = em.getApplication().getUuid();
+            final Map<String,Object> payloads = notification.getPayloads();
+
+            final Func1<Entity,Entity> entityListFunct = new Func1<Entity, Entity>() {
+                @Override
+                public Entity call(Entity entity) {
+
+                    try {
+
+                        long now = System.currentTimeMillis();
+                        List<EntityRef> devicesRef = getDevices(entity); // resolve group
+
+                        LOG.info("notification {} queue  {} devices, duration "+(System.currentTimeMillis()-now)+" ms", notification.getUuid(), devicesRef.size());
+
+                        for (EntityRef deviceRef : devicesRef) {
+                            LOG.info("notification {} starting to queue device {} ", notification.getUuid(), deviceRef.getUuid());
+                            long hash = MurmurHash.hash(deviceRef.getUuid());
+                            if (sketch.estimateCount(hash) > 0) { //look for duplicates
+                                LOG.warn("Maybe Found duplicate device: {}", deviceRef.getUuid());
+                                continue;
+                            } else {
+                                sketch.add(hash, 1);
+                            }
+                            String notifierId = null;
+                            String notifierKey = null;
+
+                            //find the device notifier info, match it to the payload
+                            for (Map.Entry<String, Object> entry : payloads.entrySet()) {
+                                ProviderAdapter adapter = notifierMap.get(entry.getKey().toLowerCase());
+                                now = System.currentTimeMillis();
+                                String providerId = getProviderId(deviceRef, adapter.getNotifier());
+                                if (providerId != null) {
+                                    notifierId = providerId;
+                                    notifierKey = entry.getKey().toLowerCase();
+                                    break;
+                                }
+                                LOG.info("Provider query for notification {} device {} took "+(System.currentTimeMillis()-now)+" ms",notification.getUuid(),deviceRef.getUuid());
+                            }
+
+                            if (notifierId == null) {
+                                LOG.info("Notifier did not match for device {} ", deviceRef);
+                                continue;
+                            }
+
+                            ApplicationQueueMessage message = new ApplicationQueueMessage(appId, notification.getUuid(), deviceRef.getUuid(), notifierKey, notifierId);
+                            if (notification.getQueued() == null) {
+                                // update queued time
+                                now = System.currentTimeMillis();
+                                notification.setQueued(System.currentTimeMillis());
+                                LOG.info("notification {} device {} queue time set. duration "+(System.currentTimeMillis()-now)+" ms", notification.getUuid(), deviceRef.getUuid());
+                            }
+                            now = System.currentTimeMillis();
+                            qm.sendMessage(message);
+                            LOG.info("notification {} post-queue to device {} duration " + (System.currentTimeMillis() - now) + " ms "+queueName+" queue", notification.getUuid(), deviceRef.getUuid());
+                            deviceCount.incrementAndGet();
+                            queueMeter.mark();
+                        }
+                    } catch (Exception deviceLoopException) {
+                        LOG.error("Failed to add devices", deviceLoopException);
+                        errorMessages.add("Failed to add devices for entity: " + entity.getUuid() + " error:" + deviceLoopException);
+                    }
+                    return entity;
+                }
+            };
+
+            long now = System.currentTimeMillis();
+            Observable o = rx.Observable.create(new IteratorObservable<Entity>(iterator))
+                    .parallel(new Func1<Observable<Entity>, Observable<Entity>>() {
+                        @Override
+                        public rx.Observable<Entity> call(rx.Observable<Entity> deviceObservable) {
+                            return deviceObservable.map(entityListFunct);
+                        }
+                    }, Schedulers.io())
+                    .doOnError(new Action1<Throwable>() {
+                        @Override
+                        public void call(Throwable throwable) {
+                            LOG.error("Failed while writing", throwable);
+                        }
+                    });
+            o.toBlocking().lastOrDefault(null);
+            LOG.info("notification {} done queueing duration {} ms", notification.getUuid(), System.currentTimeMillis() - now);
+        }
+
+        // update queued time
+        Map<String, Object> properties = new HashMap<String, Object>(2);
+        properties.put("queued", notification.getQueued());
+        properties.put("state", notification.getState());
+        if(errorMessages.size()>0){
+            if (notification.getErrorMessage() == null) {
+                notification.setErrorMessage("There was a problem delivering all of your notifications. See deliveryErrors in properties");
+            }
+        }
+
+        notification.setExpectedCount(deviceCount.get());
+        notification.addProperties(properties);
+        long now = System.currentTimeMillis();
+
+
+        LOG.info("notification {} updated notification duration {} ms", notification.getUuid(), System.currentTimeMillis() - now);
+
+        //do i have devices, and have i already started batching.
+        if (deviceCount.get() <= 0 || !notification.getDebug()) {
+            TaskManager taskManager = new TaskManager(em, notification);
+            //if i'm in a test value will be false, do not mark finished for test orchestration, not ideal need real tests
+            taskManager.finishedBatch(false,true);
+        }else {
+            em.update(notification);
+        }
+
+        long elapsed = notification.getQueued() != null ? notification.getQueued() - startTime : 0;
+        LOG.info("notification {} done queuing to {} devices in " + elapsed + " ms", notification.getUuid().toString(), deviceCount.get());
+    }
+
+    /**
+     * only need to get notifiers once. will reset on next batch
+     * @return
+     */
+    private HashMap<Object,ProviderAdapter> getAdapterMap(){
+        if(notifierHashMap == null) {
+            long now = System.currentTimeMillis();
+            notifierHashMap = new HashMap<Object, ProviderAdapter>();
+            Query query = new Query();
+            query.setCollection("notifiers");
+            query.setLimit(100);
+            PathQuery<Notifier> pathQuery = new PathQuery<Notifier>(
+                    new SimpleEntityRef(em.getApplicationRef()),
+                    query
+            );
+            Iterator<Notifier> notifierIterator = pathQuery.iterator(em);
+            int count = 0;
+            while (notifierIterator.hasNext()) {
+                Notifier notifier = notifierIterator.next();
+                String name = notifier.getName() != null ? notifier.getName() : "";
+                UUID uuid = notifier.getUuid() != null ? notifier.getUuid() : UUID.randomUUID();
+                ProviderAdapter providerAdapter = ProviderAdapterFactory.getProviderAdapter(notifier,em);
+                notifierHashMap.put(name.toLowerCase(), providerAdapter);
+                notifierHashMap.put(uuid, providerAdapter);
+                notifierHashMap.put(uuid.toString(), providerAdapter);
+                if(count++ >= 100){
+                    LOG.error("ApplicationQueueManager: too many notifiers...breaking out ", notifierHashMap.size());
+                    break;
+                }
+            }
+            LOG.info("ApplicationQueueManager: fetching notifiers finished size={}, duration {} ms", notifierHashMap.size(),System.currentTimeMillis() - now);
+        }
+        return notifierHashMap;
+    }
+
+    /**
+     * send batches of notifications to provider
+     * @param messages
+     * @throws Exception
+     */
+    @Override
+    public Observable sendBatchToProviders(final List<QueueMessage> messages, final String queuePath) {
+        LOG.info("sending batch of {} notifications.", messages.size());
+        final Meter sendMeter = metricsFactory.getMeter(NotificationsService.class, "send");
+
+        final Map<Object, ProviderAdapter> notifierMap = getAdapterMap();
+        final ApplicationQueueManagerImpl proxy = this;
+        final ConcurrentHashMap<UUID,TaskManager> taskMap = new ConcurrentHashMap<UUID, TaskManager>(messages.size());
+        final ConcurrentHashMap<UUID,Notification> notificationMap = new ConcurrentHashMap<UUID, Notification>(messages.size());
+
+        final Func1<QueueMessage, ApplicationQueueMessage> func = new Func1<QueueMessage, ApplicationQueueMessage>() {
+            @Override
+            public ApplicationQueueMessage call(QueueMessage queueMessage) {
+                boolean messageCommitted = false;
+                ApplicationQueueMessage message = null;
+                try {
+                    message = (ApplicationQueueMessage) queueMessage.getBody();
+                    LOG.info("start sending notification for device {} for Notification: {} on thread "+Thread.currentThread().getId(), message.getDeviceId(), message.getNotificationId());
+
+                    UUID deviceUUID = message.getDeviceId();
+
+                    Notification notification = notificationMap.get(message.getNotificationId());
+                    if (notification == null) {
+                        notification = em.get(message.getNotificationId(), Notification.class);
+                        notificationMap.put(message.getNotificationId(), notification);
+                    }
+                    TaskManager taskManager = taskMap.get(message.getNotificationId());
+                    if (taskManager == null) {
+                        taskManager = new TaskManager(em, notification);
+                        taskMap.putIfAbsent(message.getNotificationId(), taskManager);
+                        taskManager = taskMap.get(message.getNotificationId());
+                    }
+
+                    final Map<String, Object> payloads = notification.getPayloads();
+                    final Map<String, Object> translatedPayloads = translatePayloads(payloads, notifierMap);
+                    LOG.info("sending notification for device {} for Notification: {}", deviceUUID, notification.getUuid());
+
+                    try {
+                        String notifierName = message.getNotifierKey().toLowerCase();
+                        ProviderAdapter providerAdapter = notifierMap.get(notifierName.toLowerCase());
+                        Object payload = translatedPayloads.get(notifierName);
+                        Receipt receipt = new Receipt(notification.getUuid(), message.getNotifierId(), payload, deviceUUID);
+                        TaskTracker tracker = new TaskTracker(providerAdapter.getNotifier(), taskManager, receipt, deviceUUID);
+                        if(!isOkToSend(notification)){
+                             tracker.failed(0, "Notification is duplicate/expired/cancelled.");
+                        }else {
+                            if (payload == null) {
+                                LOG.debug("selected device {} for notification {} doesn't have a valid payload. skipping.", deviceUUID, notification.getUuid());
+                                tracker.failed(0, "failed to match payload to " + message.getNotifierId() + " notifier");
+                            } else {
+                                long now = System.currentTimeMillis();
+                                try {
+                                    providerAdapter.sendNotification(message.getNotifierId(), payload, notification, tracker);
+                                } catch (Exception e) {
+                                    tracker.failed(0, e.getMessage());
+                                } finally {
+                                    LOG.info("sending to device {} for Notification: {} duration " + (System.currentTimeMillis() - now) + " ms", deviceUUID, notification.getUuid());
+                                }
+                            }
+                        }
+                        messageCommitted = true;
+                    } finally {
+                        sendMeter.mark();
+                    }
+
+                } catch (Exception e) {
+                    LOG.error("Failure while sending",e);
+                    try {
+                        if(!messageCommitted && queuePath != null) {
+                            qm.commitMessage(queueMessage);
+                        }
+                    }catch (Exception queueException){
+                        LOG.error("Failed to commit message.",queueException);
+                    }
+                }
+                return message;
+            }
+        };
+        Observable o = rx.Observable.from(messages)
+                .parallel(new Func1<rx.Observable<QueueMessage>, rx.Observable<ApplicationQueueMessage>>() {
+                    @Override
+                    public rx.Observable<ApplicationQueueMessage> call(rx.Observable<QueueMessage> messageObservable) {
+                        return messageObservable.map(func);
+                    }
+                }, Schedulers.io())
+                .buffer(messages.size())
+                .map(new Func1<List<ApplicationQueueMessage>, HashMap<UUID, ApplicationQueueMessage>>() {
+                    @Override
+                    public HashMap<UUID, ApplicationQueueMessage> call(List<ApplicationQueueMessage> queueMessages) {
+                        //for gcm this will actually send notification
+                        for (ProviderAdapter providerAdapter : notifierMap.values()) {
+                            try {
+                                providerAdapter.doneSendingNotifications();
+                            } catch (Exception e) {
+                                LOG.error("providerAdapter.doneSendingNotifications: ", e);
+                            }
+                        }
+                        //TODO: check if a notification is done and mark it
+                        HashMap<UUID, ApplicationQueueMessage> notifications = new HashMap<UUID, ApplicationQueueMessage>();
+                        for (ApplicationQueueMessage message : queueMessages) {
+                            if (notifications.get(message.getNotificationId()) == null) {
+                                try {
+                                    TaskManager taskManager = taskMap.get(message.getNotificationId());
+                                    notifications.put(message.getNotificationId(), message);
+                                    taskManager.finishedBatch();
+                                } catch (Exception e) {
+                                    LOG.error("Failed to finish batch", e);
+                                }
+                            }
+
+                        }
+                        return notifications;
+                    }
+                })
+                .doOnError(new Action1<Throwable>() {
+                    @Override
+                    public void call(Throwable throwable) {
+                        LOG.error("Failed while sending",throwable);
+                    }
+                });
+        return o;
+    }
+
+    @Override
+    public void stop(){
+        for(ProviderAdapter adapter : getAdapterMap().values()){
+            try {
+                adapter.stop();
+            }catch (Exception e){
+                LOG.error("failed to stop adapter",e);
+            }
+        }
+    }
+
+
+    /**
+     * Call the adapter with the notifier
+     */
+    private Map<String, Object> translatePayloads(Map<String, Object> payloads, Map<Object, ProviderAdapter> notifierMap) throws Exception {
+        Map<String, Object> translatedPayloads = new HashMap<String, Object>(  payloads.size());
+        for (Map.Entry<String, Object> entry : payloads.entrySet()) {
+            String payloadKey = entry.getKey().toLowerCase();
+            Object payloadValue = entry.getValue();
+            ProviderAdapter providerAdapter = notifierMap.get(payloadKey);
+            if (providerAdapter != null) {
+                Object translatedPayload = payloadValue != null ? providerAdapter.translatePayload(payloadValue) : null;
+                if (translatedPayload != null) {
+                    translatedPayloads.put(payloadKey, translatedPayload);
+                }
+            }
+        }
+        return translatedPayloads;
+    }
+
+    public static String getQueueNames(Properties properties) {
+        String name = properties.getProperty(ApplicationQueueManagerImpl.DEFAULT_QUEUE_PROPERTY, ApplicationQueueManagerImpl.DEFAULT_QUEUE_NAME);
+        return name;
+    }
+
+    private static final class IteratorObservable<T> implements rx.Observable.OnSubscribe<T> {
+        private final Iterator<T> input;
+        private IteratorObservable( final Iterator input ) {this.input = input;}
+
+        @Override
+        public void call( final Subscriber<? super T> subscriber ) {
+
+            /**
+             * You would replace this code with your file reading.  Instead of emitting from an iterator,
+             * you would create a bean object that represents the entity, and then emit it
+             */
+
+            try {
+                while ( !subscriber.isUnsubscribed() && input.hasNext() ) {
+                    //send our input to the next
+                    subscriber.onNext( (T) input.next() );
+                }
+
+                //tell the subscriber we don't have any more data
+                subscriber.onCompleted();
+            }
+            catch ( Throwable t ) {
+                LOG.error("failed on subscriber",t);
+                subscriber.onError( t );
+            }
+        }
+    }
+
+    @Override
+    public void asyncCheckForInactiveDevices() throws Exception {
+        Collection<ProviderAdapter> providerAdapters = getAdapterMap().values();
+        for (final ProviderAdapter providerAdapter : providerAdapters) {
+            try {
+                if (providerAdapter != null) {
+                    LOG.debug("checking notifier {} for inactive devices", providerAdapter.getNotifier());
+                    providerAdapter.removeInactiveDevices();
+
+                    LOG.debug("finished checking notifier {} for inactive devices",providerAdapter.getNotifier());
+                }
+            } catch (Exception e) {
+                LOG.error("checkForInactiveDevices", e); // not
+                // essential so
+                // don't fail,
+                // but log
+            }
+        }
+    }
+
+
+    private boolean isOkToSend(Notification notification) {
+        Map<String,Long> stats = notification.getStatistics();
+        if (stats != null && notification.getExpectedCount() == (stats.get("sent")+ stats.get("errors"))) {
+            LOG.info("notification {} already processed. not sending.",
+                    notification.getUuid());
+            return false;
+        }
+        if (notification.getCanceled() == Boolean.TRUE) {
+            LOG.info("notification {} canceled. not sending.",
+                    notification.getUuid());
+            return false;
+        }
+        if (notification.isExpired()) {
+            LOG.info("notification {} expired. not sending.",
+                    notification.getUuid());
+            return false;
+        }
+        return true;
+    }
+
+    private List<EntityRef> getDevices(EntityRef ref) throws Exception {
+        List<EntityRef> devices = Collections.EMPTY_LIST;
+        if ("device".equals(ref.getType())) {
+            devices = Collections.singletonList(ref);
+        } else if ("user".equals(ref.getType())) {
+            devices = em.getCollection(ref, "devices", null, Query.MAX_LIMIT,
+                    Query.Level.REFS, false).getRefs();
+        } else if ("group".equals(ref.getType())) {
+            devices = new ArrayList<EntityRef>();
+            for (EntityRef r : em.getCollection(ref, "users", null,
+                    Query.MAX_LIMIT, Query.Level.REFS, false).getRefs()) {
+                devices.addAll(getDevices(r));
+            }
+        }
+        return devices;
+    }
+
+
+    private String getProviderId(EntityRef device, Notifier notifier) throws Exception {
+        try {
+            Object value = em.getProperty(device, notifier.getName() + NOTIFIER_ID_POSTFIX);
+            if (value == null) {
+                value = em.getProperty(device, notifier.getUuid() + NOTIFIER_ID_POSTFIX);
+            }
+            return value != null ? value.toString() : null;
+        } catch (Exception e) {
+            LOG.error("Errer getting provider ID, proceding with rest of batch", e);
+            return null;
+        }
+    }
+
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f4720db/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 2a4ec73..02f881d 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
@@ -16,10 +16,8 @@
  */
 package org.apache.usergrid.services.notifications.apns;
 
-import com.relayrides.pushy.apns.*;
 import com.relayrides.pushy.apns.util.*;
 import org.apache.commons.io.IOUtils;
-import org.apache.usergrid.services.ServiceParameter;
 import org.apache.usergrid.persistence.*;
 import org.apache.usergrid.persistence.entities.*;
 import org.apache.usergrid.persistence.index.query.Query;
@@ -30,7 +28,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.InputStream;
-import java.net.SocketException;
 import java.util.*;
 
 import org.apache.usergrid.services.ServiceAction;
@@ -40,7 +37,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.fail;
 
-import static org.apache.usergrid.services.notifications.NotificationsService.NOTIFIER_ID_POSTFIX;
+import static org.apache.usergrid.services.notifications.impl.ApplicationQueueManagerImpl.NOTIFIER_ID_POSTFIX;
 
 // todo: test reschedule on delivery time change
 // todo: test restart of queuing
@@ -68,7 +65,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
 
     @BeforeClass
     public static void setup(){
-        ApplicationQueueManager.DEFAULT_QUEUE_NAME = "test";
+
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f4720db/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 3795be1..ad1c9f2 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
@@ -18,22 +18,19 @@ package org.apache.usergrid.services.notifications.gcm;
 
 import org.apache.usergrid.persistence.*;
 import org.apache.usergrid.persistence.entities.*;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.services.ServiceParameter;
 import org.apache.usergrid.services.TestQueueManager;
 import org.apache.usergrid.services.notifications.*;
 import org.junit.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
 import java.lang.reflect.Field;
 import java.util.*;
 
 import org.apache.usergrid.services.ServiceAction;
 
 import static org.junit.Assert.*;
-import static org.apache.usergrid.services.notifications.NotificationsService.NOTIFIER_ID_POSTFIX;
+import static org.apache.usergrid.services.notifications.ApplicationQueueManager.NOTIFIER_ID_POSTFIX;
 
 public class NotificationsServiceIT extends AbstractServiceNotificationIT {
 
@@ -59,7 +56,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
 
     @BeforeClass
     public static void setup(){
-        ApplicationQueueManager.DEFAULT_QUEUE_NAME = "test";
+
     }
     @Override
     @Before


[15/45] git commit: fix config of inactive devices

Posted by to...@apache.org.
fix config of inactive devices


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

Branch: refs/heads/key-row-sharding
Commit: bbed017f80d04fb09b925304d0ae838ecfd3d329
Parents: f3343f1
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Oct 27 17:23:20 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Oct 27 17:23:20 2014 -0600

----------------------------------------------------------------------
 .../org/apache/usergrid/services/notifications/QueueListener.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bbed017f/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
index 286daf1..ef87b3a 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
@@ -209,7 +209,7 @@ public class QueueListener  {
                         LOG.info("sleep between rounds...sleep...{}", sleepBetweenRuns);
                         Thread.sleep(sleepBetweenRuns);
                     }
-                    if(runCount++ % consecutiveCallsToRemoveDevices == 0){
+                    if(++runCount % consecutiveCallsToRemoveDevices == 0){
                         for(ApplicationQueueManager applicationQueueManager : queueManagerMap.values()){
                             try {
                                 applicationQueueManager.asyncCheckForInactiveDevices();


[26/45] git commit: Only init application index at most once per JVM.

Posted by to...@apache.org.
Only init application index at most once per JVM.


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

Branch: refs/heads/key-row-sharding
Commit: 89cf61f08f795bea8d8bf23d5213644f1e1eac3d
Parents: c571965
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Oct 29 11:26:45 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Oct 29 11:26:45 2014 -0400

----------------------------------------------------------------------
 .../corepersistence/CpEntityManagerFactory.java | 53 ++++++++++----------
 1 file changed, 27 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/89cf61f0/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 bc45769..6e6b461 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
@@ -24,9 +24,11 @@ import static java.lang.String.CASE_INSENSITIVE_ORDER;
 
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.TreeMap;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -91,23 +93,23 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
     public static final Class<DynamicEntity> APPLICATION_ENTITY_CLASS = DynamicEntity.class;
 
-    // The System Application where we store app and org metadata
+    /** The System Application where we store app and org metadata */
     public static final UUID SYSTEM_APP_ID =
             UUID.fromString("b6768a08-b5d5-11e3-a495-10ddb1de66c3");
 
-    /**
-     * App where we store management info
-     */
+    /** App where we store management info */
     public static final  UUID MANAGEMENT_APPLICATION_ID =
             UUID.fromString("b6768a08-b5d5-11e3-a495-11ddb1de66c8");
 
-    /**
-     * TODO Dave what is this?
-     */
+    /** TODO Do we need this in two-dot-o? */
     public static final  UUID DEFAULT_APPLICATION_ID =
             UUID.fromString("b6768a08-b5d5-11e3-a495-11ddb1de66c9");
 
-    private AtomicBoolean init_indexes = new AtomicBoolean(  );
+    /** Have we already initialized the index for the management app? */
+    private AtomicBoolean indexInitialized = new AtomicBoolean(  );
+
+    /** Keep track of applications that already have indexes to avoid redundant re-creation. */
+    private static final Set<UUID> applicationIndexesCreated = new HashSet<UUID>();
 
 
     // cache of already instantiated entity managers
@@ -205,13 +207,16 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
 
     private EntityManager _getEntityManager( UUID applicationId ) {
+
         EntityManager em = new CpEntityManager();
         em.init( this, applicationId );
-        //TODO PERFORMANCE  Can we remove this?  Seems like we should fix our lifecycle instead...
-        //if this is the first time we've loaded this entity manager in the JVM, create it's indexes, it may be new
-        //not sure how to handle other than this if the system dies after the application em has been created
-        //but before the create call can create the index
-        em.createIndex();
+
+        // only need to do this once 
+        if ( !applicationIndexesCreated.contains( applicationId ) ) {
+            em.createIndex();
+            applicationIndexesCreated.add( applicationId );
+        }
+
         return em;
     }
 
@@ -295,10 +300,6 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         properties.put( PROPERTY_NAME, appName );
         EntityManager appEm = getEntityManager( applicationId );
 
-        //create our ES index since we're initializing this application
-//  TODO PERFORMANCE  pushed this down into the cache load can we do this here?
-//        appEm.createIndex();
-
         appEm.create( applicationId, TYPE_APPLICATION, properties );
         appEm.resetRoles();
         appEm.refreshIndex();
@@ -640,7 +641,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
     private void maybeCreateIndexes() {
         // system app
-        if ( init_indexes.getAndSet( true ) ) {
+        if ( indexInitialized.getAndSet( true ) ) {
             return;
         }
 
@@ -653,16 +654,16 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     private List<EntityIndex> getManagementIndexes() {
 
         return Arrays.asList(
-                getManagerCache().getEntityIndex(
-                        new ApplicationScopeImpl( new SimpleId( SYSTEM_APP_ID, "application" ) ) ),
+            getManagerCache().getEntityIndex(
+                new ApplicationScopeImpl( new SimpleId( SYSTEM_APP_ID, "application" ))),
 
-                // default app
-               getManagerCache().getEntityIndex(
-                       new ApplicationScopeImpl( new SimpleId( getManagementAppId(), "application" ) ) ),
+            // management app
+            getManagerCache().getEntityIndex(
+                new ApplicationScopeImpl( new SimpleId( getManagementAppId(), "application" ))),
 
-                // management app
-               getManagerCache().getEntityIndex(
-                       new ApplicationScopeImpl( new SimpleId( getDefaultAppId(), "application" ) ) ) );
+            // default app TODO: do we need this in two-dot-o
+            getManagerCache().getEntityIndex(
+                new ApplicationScopeImpl( new SimpleId( getDefaultAppId(), "application" ))));
     }
 
 


[13/45] git commit: Merge branch 'mvn_loadtests' of github.com:amuramoto/incubator-usergrid into mvn_loadtests

Posted by to...@apache.org.
Merge branch 'mvn_loadtests' of github.com:amuramoto/incubator-usergrid into mvn_loadtests


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

Branch: refs/heads/key-row-sharding
Commit: d5ead33122361da6d69f9490a4e7492c9915f16a
Parents: 0eda724 7947bae
Author: amuramoto <am...@apigee.com>
Authored: Mon Oct 27 15:51:39 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Mon Oct 27 15:51:39 2014 -0700

----------------------------------------------------------------------
 stack/loadtests/README.md | 52 ------------------------------------------
 1 file changed, 52 deletions(-)
----------------------------------------------------------------------



[07/45] git commit: fixes to push test

Posted by to...@apache.org.
fixes to push test


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

Branch: refs/heads/key-row-sharding
Commit: c9d6b7e1168125e7ecf3e85b67c82eb25d7b120d
Parents: fc3c42c
Author: amuramoto <am...@apigee.com>
Authored: Mon Oct 27 10:08:01 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Mon Oct 27 10:08:01 2014 -0700

----------------------------------------------------------------------
 stack/loadtests/README.md                       |  53 -----
 stack/loadtests/gatling/LICENSE                 | 202 -------------------
 stack/loadtests/gatling/conf/application.conf   |  21 --
 stack/loadtests/gatling/conf/gatling.conf       | 162 ---------------
 stack/loadtests/gatling/conf/logback.xml        |  35 ----
 stack/loadtests/gatling/conf/recorder.conf      |  51 -----
 .../gatling/lib/Saxon-HE-9.5.1-6-compressed.jar | Bin 3813075 -> 0 bytes
 .../gatling/lib/akka-actor_2.10-2.3.6.jar       | Bin 2583959 -> 0 bytes
 .../lib/async-http-client-1.9.0-BETA13.jar      | Bin 579954 -> 0 bytes
 stack/loadtests/gatling/lib/boon-0.26.jar       | Bin 1026950 -> 0 bytes
 .../loadtests/gatling/lib/commons-pool-1.6.jar  | Bin 111119 -> 0 bytes
 .../lib/compiler-interface-0.13.5-sources.jar   | Bin 30056 -> 0 bytes
 .../lib/concurrentlinkedhashmap-lru-1.4.jar     | Bin 116575 -> 0 bytes
 stack/loadtests/gatling/lib/config-1.2.1.jar    | Bin 219554 -> 0 bytes
 .../gatling/lib/fastring_2.10-0.2.4.jar         | Bin 98640 -> 0 bytes
 .../gatling/lib/gatling-app-2.0.0-RC5.jar       | Bin 73052 -> 0 bytes
 .../gatling/lib/gatling-charts-2.0.0-RC5.jar    | Bin 500609 -> 0 bytes
 .../lib/gatling-charts-highcharts-2.0.0-RC5.jar | Bin 214683 -> 0 bytes
 .../gatling/lib/gatling-core-2.0.0-RC5.jar      | Bin 1678475 -> 0 bytes
 .../gatling/lib/gatling-http-2.0.0-RC5.jar      | Bin 1222752 -> 0 bytes
 .../gatling/lib/gatling-jdbc-2.0.0-RC5.jar      | Bin 41648 -> 0 bytes
 .../gatling/lib/gatling-jms-2.0.0-RC5.jar       | Bin 174279 -> 0 bytes
 .../gatling/lib/gatling-metrics-2.0.0-RC5.jar   | Bin 72446 -> 0 bytes
 .../gatling/lib/gatling-recorder-2.0.0-RC5.jar  | Bin 815471 -> 0 bytes
 .../gatling/lib/gatling-redis-2.0.0-RC5.jar     | Bin 19970 -> 0 bytes
 .../gatling/lib/geronimo-jms_1.1_spec-1.1.1.jar | Bin 32359 -> 0 bytes
 .../gatling/lib/incremental-compiler-0.13.5.jar | Bin 2214694 -> 0 bytes
 .../gatling/lib/jackson-annotations-2.4.0.jar   | Bin 38605 -> 0 bytes
 .../gatling/lib/jackson-core-2.4.2.jar          | Bin 225316 -> 0 bytes
 .../gatling/lib/jackson-databind-2.4.2.jar      | Bin 1075759 -> 0 bytes
 stack/loadtests/gatling/lib/jodd-core-3.6.jar   | Bin 373882 -> 0 bytes
 .../loadtests/gatling/lib/jodd-lagarto-3.6.jar  | Bin 204738 -> 0 bytes
 stack/loadtests/gatling/lib/jodd-log-3.6.jar    | Bin 14547 -> 0 bytes
 .../gatling/lib/jsonpath_2.10-0.5.0.jar         | Bin 180090 -> 0 bytes
 stack/loadtests/gatling/lib/jzlib-1.1.3.jar     | Bin 71976 -> 0 bytes
 .../gatling/lib/logback-classic-1.1.2.jar       | Bin 270750 -> 0 bytes
 .../gatling/lib/logback-core-1.1.2.jar          | Bin 427729 -> 0 bytes
 .../loadtests/gatling/lib/netty-3.9.4.Final.jar | Bin 1310154 -> 0 bytes
 stack/loadtests/gatling/lib/opencsv-2.3.jar     | Bin 19827 -> 0 bytes
 .../gatling/lib/redisclient_2.10-2.13.jar       | Bin 712616 -> 0 bytes
 .../gatling/lib/sbt-interface-0.13.5.jar        | Bin 52012 -> 0 bytes
 stack/loadtests/gatling/lib/scala-compiler.jar  | Bin 14445780 -> 0 bytes
 stack/loadtests/gatling/lib/scala-library.jar   | Bin 7126372 -> 0 bytes
 stack/loadtests/gatling/lib/scala-reflect.jar   | Bin 3203471 -> 0 bytes
 .../gatling/lib/scala-swing-2.10.4.jar          | Bin 707298 -> 0 bytes
 .../lib/scalalogging-slf4j_2.10-1.1.0.jar       | Bin 79003 -> 0 bytes
 .../loadtests/gatling/lib/scopt_2.10-3.2.0.jar  | Bin 122918 -> 0 bytes
 stack/loadtests/gatling/lib/slf4j-api-1.7.7.jar | Bin 29257 -> 0 bytes
 stack/loadtests/gatling/lib/t-digest-3.0.jar    | Bin 49754 -> 0 bytes
 stack/loadtests/gatling/lib/threetenbp-1.0.jar  | Bin 507797 -> 0 bytes
 .../gatling/lib/uncommons-maths-1.2.3.jar       | Bin 49923 -> 0 bytes
 stack/loadtests/gatling/lib/zinc-0.3.5.3.jar    | Bin 392810 -> 0 bytes
 stack/loadtests/gatling/scripts/gatling-ug.sh   |  49 -----
 .../gatling/user-files/data/search.csv          |   3 -
 .../gatling/user-files/request-bodies/.keep     |   0
 stack/loadtests/loadtest_setup.sh               |  45 -----
 .../data-generators/EntityDataGenerator.scala   |  57 ------
 .../data-generators/FeederGenerator.scala       | 101 ----------
 .../scenarios/ApplicationScenarios.scala        |  45 -----
 .../scenarios/ConnectionScenarios.scala         |  30 ---
 .../usergrid/scenarios/DeviceScenarios.scala    |  65 ------
 .../usergrid/scenarios/GeoScenarios.scala       |  43 ----
 .../scenarios/NotificationScenarios.scala       |  71 -------
 .../usergrid/scenarios/NotifierScenarios.scala  |  65 ------
 .../scenarios/OrganizationScenarios.scala       |  42 ----
 .../usergrid/scenarios/TokenScenarios.scala     |  59 ------
 .../usergrid/scenarios/UserScenarios.scala      |  50 -----
 .../org/apache/usergrid/settings/Headers.scala  |  43 ----
 .../org/apache/usergrid/settings/Settings.scala |  54 -----
 .../org/apache/usergrid/settings/Utils.scala    |  87 --------
 .../simulations/GetEntitySimulation.scala       |  41 ----
 .../simulations/PostDevicesSimulation.scala     |  42 ----
 .../simulations/PostUsersSimulation.scala       |  47 -----
 .../PushTargetDeviceSimulation.scala            |  53 -----
 .../simulations/PushTargetUserSimulation.scala  |  68 -------
 75 files changed, 1684 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/README.md
----------------------------------------------------------------------
diff --git a/stack/loadtests/README.md b/stack/loadtests/README.md
deleted file mode 100644
index 0c1774a..0000000
--- a/stack/loadtests/README.md
+++ /dev/null
@@ -1,53 +0,0 @@
-To make it easy for you to load test your instance of Usergrid, we have bundledin the Gatling load test tool, along with some pre-built tests of different functionality. To get started do the following:
-
-### Setting up Gatling
-1. Unzip loadtest.zip
-2. cd to the 'gatling' dir
-3. Run 'sh loadtest_setup.sh'. This will do the following:
-	- Add some handy options to gatling/bin/gatling.sh that will allow you to set certain test parameters using environment variables (more on this later)
-	- Run the PostUsersSimulation, which will load 5k users with geolocation data into a specified UG org/app. This is just to seed some data entities to make it easier to run some of the tests.
-4. Set the following environment variables:
-- GATLING_BASE_URL - Required. UG base url, e.g. http://api.usergrid.com/.
-- GATLING_ORG      - Required. UG organization name.
-- GATLING_APP      - Required. UG application name.
-
-- GATLING_NUMUSERS - Number of users in the simulation. Default is 100.
-- GATLING_DURATION - Duration of the simulation. Default is 300.
-- GATLING_RAMPTIME - Time period to inject the users over. Default is 0.
-- GATLING_THROTTLE - Requests per second the simulation to try to reach. Default is 50.
-
-- GATLING_NOTIFIER - Name of the notifier to use for PushNotificationSimulation.
-- GATLING_PROVIDER - Push notification provider that corresponds to the notifier, e.g. apple, google, etc.
-
-### Running load tests
-To run Gatling, do the following:
-1. Run 'gatling/bin/gatling.sh'
-2. Enter the number of the test you want to run from the list (see below for an explanation of each test)
-3. Optional. Set a identifier for the results of this run of the simulation
-4. Optional. Set a description for this run of the simulation
-
-### Viewing results
-Results of the test are output to the gatling/results. The output directory is shown once the test has successfully run. The location of the generated report is also shown.
-
-### Default tests
-The following default tests are available. Not that the GATLING_BASE_URL, GATLING_ORG, and GATLING_APP environment variables must be set before any tests can be run. Each test also requires certain additional env variables to be set.
-
-- PostUsersSimulation
-
-POSTs 5k entities with geolocation data to /users. Entities are named sequentially, i.e. user1, user2, etc.
-
-- GetEntitySimulation
-
-Performs simple GETs on the /users collection. You should run PostUsersSimulation or loadtest_Setup.sh first to load data into the collection.
-
-- PostDevicesSimulation
-
-POSTs a user-specified number of entities in the /devices collection. This is useful if you want to load test push notifications
-
-- PushTargetDeviceSimulation
-
-Creates users, devices, connects users with devices, then sends push notification to all user devices. To run this, you will need to do create a notifier, then set the GATLING_NOTIFIER environment variable to equal the name or UUID of the notifier. You'll also need to set GATLING_PROVIDER to match the provider in the notifier.
-
-- PushTargetDeviceSimulation
-
-Sends push notifications. To run this, you will need to do create a notifier, then set the GATLING_NOTIFIER environment variable to equal the name or UUID of the notifier. You'll also need to set GATLING_PROVIDER to match the provider in the notifier.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/LICENSE
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/LICENSE b/stack/loadtests/gatling/LICENSE
deleted file mode 100644
index a82aed2..0000000
--- a/stack/loadtests/gatling/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright 2012 eBusiness Information (Excilys Group)
-
-   Licensed 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.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/conf/application.conf
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/conf/application.conf b/stack/loadtests/gatling/conf/application.conf
deleted file mode 100644
index 6bb275a..0000000
--- a/stack/loadtests/gatling/conf/application.conf
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Licensed 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.
-#
-
-akka {
-  actor {
-    default-dispatcher {
-      throughput = 20
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/conf/gatling.conf
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/conf/gatling.conf b/stack/loadtests/gatling/conf/gatling.conf
deleted file mode 100755
index ea8f754..0000000
--- a/stack/loadtests/gatling/conf/gatling.conf
+++ /dev/null
@@ -1,162 +0,0 @@
-#
-# Licensed 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.
-#
-
-#########################
-# Gatling Configuration #
-#########################
-
-# This file contains all the settings configurable for Gatling with their default values
-
-gatling {
-  core {
-    #outputDirectoryBaseName = "" # The prefix for each simulation result folder (then suffixed by the report generation timestamp)
-    #runDescription = ""          # The description for this simulation run, displayed in each report
-    #encoding = "utf-8"           # Encoding to use throughout Gatling for file and string manipulation
-    #simulationClass = ""         # The FQCN of the simulation to run (when used in conjunction with noReports, the simulation for which assertions will be validated)
-    #disableCompiler = false      # When set to true, skip compiling and load an already compiled simulation (used in conjunction with simulationClass)
-    #mute = false                 # When set to true, don't ask for simulation name nor run description (currently only used by Gatling SBT plugin)
-
-    extract {
-      regex {
-        #cacheMaxCapacity = 200 # Cache size for the compiled regexes, set to 0 to disable caching
-      }
-      xpath {
-        #cacheMaxCapacity = 200 # Cache size for the compiled XPath queries,  set to 0 to disable caching
-      }
-      jsonPath {
-        #cacheMaxCapacity = 200 # Cache size for the compiled jsonPath queries, set to 0 to disable caching
-        #preferJackson = false  # When set to true, prefer Jackson over Boon for JSON-related operations
-        jackson {
-          #allowComments = false           # Allow comments in JSON files
-          #allowUnquotedFieldNames = false # Allow unquoted JSON fields names
-          #allowSingleQuotes = false       # Allow single quoted JSON field names
-        }
-
-      }
-      css {
-        #cacheMaxCapacity = 200 # Cache size for the compiled CSS selectors queries,  set to 0 to disable caching
-      }
-    }
-
-    timeOut {
-      #simulation = 8640000 # Absolute timeout, in seconds, of a simulation
-    }
-    directory {
-      #data = user-files/data                    # Folder where user's data (e.g. files used by Feeders) is located
-      #requestBodies = user-files/request-bodies # Folder where request bodies are located
-      simulations = ../../simulations      # Folder where the bundle's simulations are located
-      #reportsOnly = ""                          # If set, name of report folder to look for in order to generate its report
-      #binaries = ""                             # If set, name of the folder where compiles classes are located
-      #results = results                         # Name of the folder where all reports folder are located
-    }
-    zinc {
-      #jvmArgs = "-Xss10M" # JVM args passed to Zinc (in charge of compiling Gatling Simulations)
-    }
-  }
-  charting {
-    #noReports = false       # When set to true, don't generate HTML reports
-    #maxPlotPerSeries = 1000 # Number of points per graph in Gatling reports
-    #accuracy = 10           # Accuracy, in milliseconds, of the report's stats
-    indicators {
-      #lowerBound = 800      # Lower bound for the requests' response time to track in the reports and the console summary
-      #higherBound = 1200    # Higher bound for the requests' response time to track in the reports and the console summary
-      #percentile1 = 95      # Value for the first percentile to track in the reports, the console summary and GraphiteDataWriter
-      #percentile2 = 99      # Value for the second percentile to track in the reports, the console summary and GraphiteDataWriter
-    }
-  }
-  http {
-    #elFileBodiesCacheMaxCapacity = 200        # Cache size for request body EL templates, set to 0 to disable
-    #rawFileBodiesCacheMaxCapacity = 200       # Cache size for request body Raw templates, set to 0 to disable
-    #fetchedCssCacheMaxCapacity = 200          # Cache size for CSS parsed content, set to 0 to disable
-    #fetchedHtmlCacheMaxCapacity = 200         # Cache size for HTML parsed content, set to 0 to disable
-    #redirectPerUserCacheMaxCapacity = 200     # Per virtual user cache size for permanent redirects, set to 0 to disable
-    #expirePerUserCacheMaxCapacity = 200       # Per virtual user cache size for permanent 'Expire' headers, set to 0 to disable
-    #lastModifiedPerUserCacheMaxCapacity = 200 # Per virtual user cache size for permanent 'Last-Modified' headers, set to 0 to disable
-    #etagPerUserCacheMaxCapacity = 200         # Per virtual user cache size for permanent ETag headers, set to 0 to disable
-    #warmUpUrl = "http://goo.gl/xUrsE"         # The URL to use to warm-up the HTTP stack (blank means disabled)
-    ssl {
-      trustStore {
-        #type = ""      # Type of SSLContext's TrustManagers store
-        #file = ""      # Location of SSLContext's TrustManagers store
-        #password = ""  # Password for SSLContext's TrustManagers store
-        #algorithm = "" # Algorithm used by SSLContext's TrustManagers store
-      }
-      keyStore {
-        #type = ""      # Type of SSLContext's KeyManagers store
-        #file = ""      # Location of SSLContext's KeyManagers store
-        #password = ""  # Password for SSLContext's KeyManagers store
-        #algorithm = "" # Algorithm used SSLContext's KeyManagers store
-      }
-    }
-    ahc {
-      #allowPoolingConnections = true             # Allow pooling HTTP connections (keep-alive header automatically added)
-      #allowPoolingSslConnections = true          # Allow pooling HTTPS connections (keep-alive header automatically added)
-      #compressionEnabled = true                  # Support gzipped responses
-      #connectionTimeout = 60000                  # Timeout when establishing a connection
-      #pooledConnectionIdleTimeout = 60000        # Timeout when a connection stays unused in the pool
-      #readTimeout = 60000                        # Timeout when a used connection stays idle
-      #connectionTTL = -1                         # Max duration a connection can stay open (-1 means no limit)
-      #ioThreadMultiplier = 2                     # Number of Netty worker threads per core
-      #maxConnectionsPerHost = -1                 # Max number of connections per host (-1 means no limit)
-      #maxConnections = -1                        # Max number of connections (-1 means no limit)
-      #maxRetry = 4                               # Number of times that a request should be tried again
-      #requestTimeout = 60000                     # Timeout of the requests
-      #useProxyProperties = false                 # When set to true, supports standard Proxy System properties
-      #webSocketTimeout = 60000                   # Timeout when a used websocket connection stays idle
-      #useRelativeURIsWithConnectProxies = true   # When set to true, use relative URIs when talking with an SSL proxy or a WebSocket proxy
-      #acceptAnyCertificate = true                # When set to true, doesn't validate SSL certificates
-      #httpClientCodecMaxInitialLineLength = 4096 # Maximum length of the initial line of the response (e.g. "HTTP/1.0 200 OK")
-      #httpClientCodecMaxHeaderSize = 8192        # Maximum size, in bytes, of each request's headers
-      #httpClientCodecMaxChunkSize = 8192         # Maximum length of the content or each chunk
-    }
-  }
-  data {
-    #writers = "console, file" # The lists of DataWriters to which Gatling write simulation data (currently supported : "console", "file", "graphite", "jdbc")
-    #reader = file             # The DataReader used by the charting engine for reading simulation results
-    console {
-      #light = false           # When set to true, displays a light version without detailed request stats
-    }
-    file {
-      #bufferSize = 8192       # FileDataWriter's internal data buffer size, in bytes
-    }
-    jdbc {
-      db {
-        #url = "jdbc:mysql://localhost:3306/temp" # The JDBC URL used by the JDBC DataWriter
-        #username = "root"                        # The database user used by the JDBC DataWriter
-        #password = "123123q"                     # The password for the specified user
-      }
-      #bufferSize = 20                            # The size for each batch of SQL inserts to send to the database
-      create {
-        #createRunRecordTable = "CREATE TABLE IF NOT EXISTS `RunRecords` ( `id` INT NOT NULL AUTO_INCREMENT , `runDate` DATETIME NULL , `simulationId` VARCHAR(45) NULL , `runDescription` VARCHAR(45) NULL , PRIMARY KEY (`id`) )"
-        #createRequestRecordTable = "CREATE TABLE IF NOT EXISTS `RequestRecords` (`id` int(11) NOT NULL AUTO_INCREMENT, `runId` int DEFAULT NULL, `scenario` varchar(45) DEFAULT NULL, `userId` VARCHAR(20) NULL, `name` varchar(50) DEFAULT NULL, `requestStartDate` bigint DEFAULT NULL, `requestEndDate` bigint DEFAULT NULL, `responseStartDate` bigint DEFAULT NULL, `responseEndDate` bigint DEFAULT NULL, `status` varchar(2) DEFAULT NULL, `message` varchar(4500) DEFAULT NULL, `responseTime` bigint DEFAULT NULL, PRIMARY KEY (`id`) )"
-        #createScenarioRecordTable = "CREATE TABLE IF NOT EXISTS `ScenarioRecords` (`id` int(11) NOT NULL AUTO_INCREMENT, `runId` int DEFAULT NULL, `scenarioName` varchar(45) DEFAULT NULL, `userId` VARCHAR(20) NULL, `event` varchar(50) DEFAULT NULL, `startDate` bigint DEFAULT NULL, `endDate` bigint DEFAULT NULL, PRIMARY KEY (`id`) )"
-        #createGroupRecordTable = "CREATE TABLE IF NOT EXISTS `GroupRecords` (`id` int(11) NOT NULL AUTO_INCREMENT, `runId` int DEFAULT NULL, `scenarioName` varchar(45) DEFAULT NULL, `userId` VARCHAR(20) NULL, `entryDate` bigint DEFAULT NULL, `exitDate` bigint DEFAULT NULL, `status` varchar(2) DEFAULT NULL, PRIMARY KEY (`id`) )"
-      }
-      insert {
-        #insertRunRecord = "INSERT INTO RunRecords (runDate, simulationId, runDescription) VALUES (?,?,?)"
-        #insertRequestRecord = "INSERT INTO RequestRecords (runId, scenario, userId, name, requestStartDate, requestEndDate, responseStartDate, responseEndDate, status, message, responseTime) VALUES (?,?,?,?,?,?,?,?,?,?,?)"
-        #insertScenarioRecord = "INSERT INTO ScenarioRecords (runId, scenarioName, userId, event, startDate, endDate) VALUES (?,?,?,?,?,?)"
-        #insertGroupRecord = "INSERT INTO GroupRecords (runId, scenarioName, userId, entryDate, exitDate, status) VALUES (?,?,?,?,?,?)"
-      }
-    }
-    graphite {
-      #light = false              # only send the all* stats
-      #host = "localhost"         # The host where the Carbon server is located
-      #port = 2003                # The port to which the Carbon server listens to
-      #protocol = "tcp"           # The protocol used to send data to Carbon (currently supported : "tcp", "udp")
-      #rootPathPrefix = "gatling" # The common prefix of all metrics sent to Graphite
-      #bufferSize = 8192          # GraphiteDataWriter's internal data buffer size, in bytes
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/conf/logback.xml
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/conf/logback.xml b/stack/loadtests/gatling/conf/logback.xml
deleted file mode 100644
index f859ad3..0000000
--- a/stack/loadtests/gatling/conf/logback.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration>
-  <!--
-   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.
-     -->
-	<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
-		<encoder>
-			<pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
-			<immediateFlush>false</immediateFlush>
-		</encoder>
-	</appender>
-
-	<!-- Uncomment for logging ALL HTTP request and responses -->
-	<!-- 	<logger name="io.gatling.http" level="TRACE" /> -->
-	<!-- Uncomment for logging ONLY FAILED HTTP request and responses -->
-	 	<logger name="io.gatling.http" level="DEBUG" /> 
-
-	<root level="WARN">
-		<appender-ref ref="CONSOLE" />
-	</root>
-
-</configuration>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/conf/recorder.conf
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/conf/recorder.conf b/stack/loadtests/gatling/conf/recorder.conf
deleted file mode 100644
index c496068..0000000
--- a/stack/loadtests/gatling/conf/recorder.conf
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Licensed 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.
-#
-
-recorder {
-  core {
-    #encoding = "utf-8"               # The encoding used for reading/writing request bodies and the generated simulation
-    #outputFolder = ""                # The folder where generated simulation will we written
-    #package = ""                     # The package's name of the generated simulation
-    #className = "RecordedSimulation" # The name of the generated Simulation class
-    #thresholdForPauseCreation = 100  # The minimum time, in milliseconds, that must pass between requests to trigger a pause creation
-    #saveConfig = false               # When set to true, the configuration from the Recorder GUI overwrites this configuration
-  }
-  filters {
-    #filterStrategy = "Disabled" # The selected filter resources filter strategy (currently supported : "Disabled", "BlackList", "WhiteList")
-    #whitelist = []              # The list of ressources patterns that are part of the Recorder's whitelist
-    #blacklist = []              # The list of ressources patterns that are part of the Recorder's blacklist
-  }
-  http {
-    #automaticReferer = true       # When set to false, write the referer + enable 'disableAutoReferer' in the generated simulation
-    #followRedirect = true         # When set to false, write redirect requests + enable 'disableFollowRedirect' in the generated simulation
-    #removeConditionalCache = true # When set to true, removes from the generated requests headers leading to request caching
-    #inferHtmlResources = true     # When set to true, add inferred resources + set 'inferHtmlResources' with the configured blacklist/whitelist in the generated simulation
-  }
-  proxy {
-    #port = 8000     # Local port used by Gatling's Proxy for HTTP/HTTPS
-    outgoing {
-      #host = ""     # The outgoing proxy's hostname
-      #username = "" # The username to use to connect to the outgoing proxy
-      #password = "" # The password corresponding to the user to use to connect to the outgoing proxy
-      #port = 0      # The HTTP port to use to connect to the outgoing proxy
-      #sslPort = 0   # If set, The HTTPS port to use to connect to the outgoing proxy
-    }
-  }
-  netty {
-    #maxInitialLineLength = 10000 # Maximum length of the initial line of the response (e.g. "HTTP/1.0 200 OK")
-    #maxHeaderSize = 20000        # Maximum size, in bytes, of each request's headers
-    #maxChunkSize = 8192          # Maximum length of the content or each chunk
-    #maxContentLength = 100000000 # Maximum length of the aggregated content of each response
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/Saxon-HE-9.5.1-6-compressed.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/Saxon-HE-9.5.1-6-compressed.jar b/stack/loadtests/gatling/lib/Saxon-HE-9.5.1-6-compressed.jar
deleted file mode 100644
index aed23e5..0000000
Binary files a/stack/loadtests/gatling/lib/Saxon-HE-9.5.1-6-compressed.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/akka-actor_2.10-2.3.6.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/akka-actor_2.10-2.3.6.jar b/stack/loadtests/gatling/lib/akka-actor_2.10-2.3.6.jar
deleted file mode 100644
index 4aa4afe..0000000
Binary files a/stack/loadtests/gatling/lib/akka-actor_2.10-2.3.6.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/async-http-client-1.9.0-BETA13.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/async-http-client-1.9.0-BETA13.jar b/stack/loadtests/gatling/lib/async-http-client-1.9.0-BETA13.jar
deleted file mode 100644
index 8865809..0000000
Binary files a/stack/loadtests/gatling/lib/async-http-client-1.9.0-BETA13.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/boon-0.26.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/boon-0.26.jar b/stack/loadtests/gatling/lib/boon-0.26.jar
deleted file mode 100644
index 99ae220..0000000
Binary files a/stack/loadtests/gatling/lib/boon-0.26.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/commons-pool-1.6.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/commons-pool-1.6.jar b/stack/loadtests/gatling/lib/commons-pool-1.6.jar
deleted file mode 100644
index 72ca75a..0000000
Binary files a/stack/loadtests/gatling/lib/commons-pool-1.6.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/compiler-interface-0.13.5-sources.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/compiler-interface-0.13.5-sources.jar b/stack/loadtests/gatling/lib/compiler-interface-0.13.5-sources.jar
deleted file mode 100644
index 7ea2783..0000000
Binary files a/stack/loadtests/gatling/lib/compiler-interface-0.13.5-sources.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/concurrentlinkedhashmap-lru-1.4.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/concurrentlinkedhashmap-lru-1.4.jar b/stack/loadtests/gatling/lib/concurrentlinkedhashmap-lru-1.4.jar
deleted file mode 100644
index 572b258..0000000
Binary files a/stack/loadtests/gatling/lib/concurrentlinkedhashmap-lru-1.4.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/config-1.2.1.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/config-1.2.1.jar b/stack/loadtests/gatling/lib/config-1.2.1.jar
deleted file mode 100644
index d2ed5a6..0000000
Binary files a/stack/loadtests/gatling/lib/config-1.2.1.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/fastring_2.10-0.2.4.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/fastring_2.10-0.2.4.jar b/stack/loadtests/gatling/lib/fastring_2.10-0.2.4.jar
deleted file mode 100644
index 8a81f03..0000000
Binary files a/stack/loadtests/gatling/lib/fastring_2.10-0.2.4.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/gatling-app-2.0.0-RC5.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/gatling-app-2.0.0-RC5.jar b/stack/loadtests/gatling/lib/gatling-app-2.0.0-RC5.jar
deleted file mode 100644
index bd2c6bc..0000000
Binary files a/stack/loadtests/gatling/lib/gatling-app-2.0.0-RC5.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/gatling-charts-2.0.0-RC5.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/gatling-charts-2.0.0-RC5.jar b/stack/loadtests/gatling/lib/gatling-charts-2.0.0-RC5.jar
deleted file mode 100644
index 3347eca..0000000
Binary files a/stack/loadtests/gatling/lib/gatling-charts-2.0.0-RC5.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/gatling-charts-highcharts-2.0.0-RC5.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/gatling-charts-highcharts-2.0.0-RC5.jar b/stack/loadtests/gatling/lib/gatling-charts-highcharts-2.0.0-RC5.jar
deleted file mode 100644
index 92e9c54..0000000
Binary files a/stack/loadtests/gatling/lib/gatling-charts-highcharts-2.0.0-RC5.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/gatling-core-2.0.0-RC5.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/gatling-core-2.0.0-RC5.jar b/stack/loadtests/gatling/lib/gatling-core-2.0.0-RC5.jar
deleted file mode 100644
index ad03856..0000000
Binary files a/stack/loadtests/gatling/lib/gatling-core-2.0.0-RC5.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/gatling-http-2.0.0-RC5.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/gatling-http-2.0.0-RC5.jar b/stack/loadtests/gatling/lib/gatling-http-2.0.0-RC5.jar
deleted file mode 100644
index 7954dd6..0000000
Binary files a/stack/loadtests/gatling/lib/gatling-http-2.0.0-RC5.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/gatling-jdbc-2.0.0-RC5.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/gatling-jdbc-2.0.0-RC5.jar b/stack/loadtests/gatling/lib/gatling-jdbc-2.0.0-RC5.jar
deleted file mode 100644
index bad010c..0000000
Binary files a/stack/loadtests/gatling/lib/gatling-jdbc-2.0.0-RC5.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/gatling-jms-2.0.0-RC5.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/gatling-jms-2.0.0-RC5.jar b/stack/loadtests/gatling/lib/gatling-jms-2.0.0-RC5.jar
deleted file mode 100644
index e5e510b..0000000
Binary files a/stack/loadtests/gatling/lib/gatling-jms-2.0.0-RC5.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/gatling-metrics-2.0.0-RC5.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/gatling-metrics-2.0.0-RC5.jar b/stack/loadtests/gatling/lib/gatling-metrics-2.0.0-RC5.jar
deleted file mode 100644
index 56f73fb..0000000
Binary files a/stack/loadtests/gatling/lib/gatling-metrics-2.0.0-RC5.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/gatling-recorder-2.0.0-RC5.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/gatling-recorder-2.0.0-RC5.jar b/stack/loadtests/gatling/lib/gatling-recorder-2.0.0-RC5.jar
deleted file mode 100644
index cb1b02d..0000000
Binary files a/stack/loadtests/gatling/lib/gatling-recorder-2.0.0-RC5.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/gatling-redis-2.0.0-RC5.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/gatling-redis-2.0.0-RC5.jar b/stack/loadtests/gatling/lib/gatling-redis-2.0.0-RC5.jar
deleted file mode 100644
index 4410540..0000000
Binary files a/stack/loadtests/gatling/lib/gatling-redis-2.0.0-RC5.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/geronimo-jms_1.1_spec-1.1.1.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/geronimo-jms_1.1_spec-1.1.1.jar b/stack/loadtests/gatling/lib/geronimo-jms_1.1_spec-1.1.1.jar
deleted file mode 100644
index 4f5e646..0000000
Binary files a/stack/loadtests/gatling/lib/geronimo-jms_1.1_spec-1.1.1.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/incremental-compiler-0.13.5.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/incremental-compiler-0.13.5.jar b/stack/loadtests/gatling/lib/incremental-compiler-0.13.5.jar
deleted file mode 100644
index 16e0f26..0000000
Binary files a/stack/loadtests/gatling/lib/incremental-compiler-0.13.5.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/jackson-annotations-2.4.0.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/jackson-annotations-2.4.0.jar b/stack/loadtests/gatling/lib/jackson-annotations-2.4.0.jar
deleted file mode 100644
index 0b55559..0000000
Binary files a/stack/loadtests/gatling/lib/jackson-annotations-2.4.0.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/jackson-core-2.4.2.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/jackson-core-2.4.2.jar b/stack/loadtests/gatling/lib/jackson-core-2.4.2.jar
deleted file mode 100644
index fad6f9b..0000000
Binary files a/stack/loadtests/gatling/lib/jackson-core-2.4.2.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/jackson-databind-2.4.2.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/jackson-databind-2.4.2.jar b/stack/loadtests/gatling/lib/jackson-databind-2.4.2.jar
deleted file mode 100644
index ea95c53..0000000
Binary files a/stack/loadtests/gatling/lib/jackson-databind-2.4.2.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/jodd-core-3.6.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/jodd-core-3.6.jar b/stack/loadtests/gatling/lib/jodd-core-3.6.jar
deleted file mode 100644
index 520caa9..0000000
Binary files a/stack/loadtests/gatling/lib/jodd-core-3.6.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/jodd-lagarto-3.6.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/jodd-lagarto-3.6.jar b/stack/loadtests/gatling/lib/jodd-lagarto-3.6.jar
deleted file mode 100644
index 1cf8b20..0000000
Binary files a/stack/loadtests/gatling/lib/jodd-lagarto-3.6.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/jodd-log-3.6.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/jodd-log-3.6.jar b/stack/loadtests/gatling/lib/jodd-log-3.6.jar
deleted file mode 100644
index a5eef88..0000000
Binary files a/stack/loadtests/gatling/lib/jodd-log-3.6.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/jsonpath_2.10-0.5.0.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/jsonpath_2.10-0.5.0.jar b/stack/loadtests/gatling/lib/jsonpath_2.10-0.5.0.jar
deleted file mode 100644
index 0804afc..0000000
Binary files a/stack/loadtests/gatling/lib/jsonpath_2.10-0.5.0.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/jzlib-1.1.3.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/jzlib-1.1.3.jar b/stack/loadtests/gatling/lib/jzlib-1.1.3.jar
deleted file mode 100644
index 2fa60b1..0000000
Binary files a/stack/loadtests/gatling/lib/jzlib-1.1.3.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/logback-classic-1.1.2.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/logback-classic-1.1.2.jar b/stack/loadtests/gatling/lib/logback-classic-1.1.2.jar
deleted file mode 100644
index 9230b2a..0000000
Binary files a/stack/loadtests/gatling/lib/logback-classic-1.1.2.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/logback-core-1.1.2.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/logback-core-1.1.2.jar b/stack/loadtests/gatling/lib/logback-core-1.1.2.jar
deleted file mode 100644
index 391da64..0000000
Binary files a/stack/loadtests/gatling/lib/logback-core-1.1.2.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/netty-3.9.4.Final.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/netty-3.9.4.Final.jar b/stack/loadtests/gatling/lib/netty-3.9.4.Final.jar
deleted file mode 100644
index 7ee6ba4..0000000
Binary files a/stack/loadtests/gatling/lib/netty-3.9.4.Final.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/opencsv-2.3.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/opencsv-2.3.jar b/stack/loadtests/gatling/lib/opencsv-2.3.jar
deleted file mode 100644
index 01f82ca..0000000
Binary files a/stack/loadtests/gatling/lib/opencsv-2.3.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/redisclient_2.10-2.13.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/redisclient_2.10-2.13.jar b/stack/loadtests/gatling/lib/redisclient_2.10-2.13.jar
deleted file mode 100644
index 38bb671..0000000
Binary files a/stack/loadtests/gatling/lib/redisclient_2.10-2.13.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/sbt-interface-0.13.5.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/sbt-interface-0.13.5.jar b/stack/loadtests/gatling/lib/sbt-interface-0.13.5.jar
deleted file mode 100644
index d95ec3a..0000000
Binary files a/stack/loadtests/gatling/lib/sbt-interface-0.13.5.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/scala-compiler.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/scala-compiler.jar b/stack/loadtests/gatling/lib/scala-compiler.jar
deleted file mode 100644
index 5e769de..0000000
Binary files a/stack/loadtests/gatling/lib/scala-compiler.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/scala-library.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/scala-library.jar b/stack/loadtests/gatling/lib/scala-library.jar
deleted file mode 100644
index 278a51e..0000000
Binary files a/stack/loadtests/gatling/lib/scala-library.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/scala-reflect.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/scala-reflect.jar b/stack/loadtests/gatling/lib/scala-reflect.jar
deleted file mode 100644
index 40e8156..0000000
Binary files a/stack/loadtests/gatling/lib/scala-reflect.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/scala-swing-2.10.4.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/scala-swing-2.10.4.jar b/stack/loadtests/gatling/lib/scala-swing-2.10.4.jar
deleted file mode 100644
index 9c43b92..0000000
Binary files a/stack/loadtests/gatling/lib/scala-swing-2.10.4.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/scalalogging-slf4j_2.10-1.1.0.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/scalalogging-slf4j_2.10-1.1.0.jar b/stack/loadtests/gatling/lib/scalalogging-slf4j_2.10-1.1.0.jar
deleted file mode 100644
index beaa38e..0000000
Binary files a/stack/loadtests/gatling/lib/scalalogging-slf4j_2.10-1.1.0.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/scopt_2.10-3.2.0.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/scopt_2.10-3.2.0.jar b/stack/loadtests/gatling/lib/scopt_2.10-3.2.0.jar
deleted file mode 100644
index 6fe0f76..0000000
Binary files a/stack/loadtests/gatling/lib/scopt_2.10-3.2.0.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/slf4j-api-1.7.7.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/slf4j-api-1.7.7.jar b/stack/loadtests/gatling/lib/slf4j-api-1.7.7.jar
deleted file mode 100644
index bebabd9..0000000
Binary files a/stack/loadtests/gatling/lib/slf4j-api-1.7.7.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/t-digest-3.0.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/t-digest-3.0.jar b/stack/loadtests/gatling/lib/t-digest-3.0.jar
deleted file mode 100644
index cfb29bc..0000000
Binary files a/stack/loadtests/gatling/lib/t-digest-3.0.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/threetenbp-1.0.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/threetenbp-1.0.jar b/stack/loadtests/gatling/lib/threetenbp-1.0.jar
deleted file mode 100644
index 020c227..0000000
Binary files a/stack/loadtests/gatling/lib/threetenbp-1.0.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/uncommons-maths-1.2.3.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/uncommons-maths-1.2.3.jar b/stack/loadtests/gatling/lib/uncommons-maths-1.2.3.jar
deleted file mode 100644
index 098d6ec..0000000
Binary files a/stack/loadtests/gatling/lib/uncommons-maths-1.2.3.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/lib/zinc-0.3.5.3.jar
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/lib/zinc-0.3.5.3.jar b/stack/loadtests/gatling/lib/zinc-0.3.5.3.jar
deleted file mode 100644
index bde5266..0000000
Binary files a/stack/loadtests/gatling/lib/zinc-0.3.5.3.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/scripts/gatling-ug.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/scripts/gatling-ug.sh b/stack/loadtests/gatling/scripts/gatling-ug.sh
deleted file mode 100755
index 67f1392..0000000
--- a/stack/loadtests/gatling/scripts/gatling-ug.sh
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/sh
-#
-# Licensed 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.
-#
-die () {
-    echo >&2 "$@"
-    exit 1
-}
-
-[ "$#" -eq 5 ] || die "5 arguments required, $# provided.  Arguments are URL ORG APP NUM_USERS RAMP_TIME"
-
-OLDDIR=`pwd`
-BIN_DIR=`dirname $0`
-cd "${BIN_DIR}/.." && DEFAULT_GATLING_HOME=`pwd` && cd "${OLDDIR}"
-
-GATLING_HOME="${GATLING_HOME:=${DEFAULT_GATLING_HOME}}"
-GATLING_CONF="${GATLING_CONF:=$GATLING_HOME/conf}"
-URL="$1"
-ORG="$2"
-APP="$3"
-USERS="$4"
-RAMP="$5"
-
-#Shift off our first operation
-shift 5
-
-export GATLING_HOME GATLING_CONF
-
-echo "GATLING_HOME is set to ${GATLING_HOME}"
-
-curl -X POST "${URL}/usergrid/sandbox/notifiers" -d '{"name":"notifier82e05787a8c24361a2992c64436b6e6a","provider":"noop"}'
-
-JAVA_OPTS="-Dthrottle=3000 -Dduration=300 -Dorg=${ORG} -Dbaseurl=${URL} -Dnotifier=notifier82e05787a8c24361a2992c64436b6e6a -DnumEntities=10000 -DnumUsers=${USERS} -DrampTime=${RAMP} -Dapp=${APP} -server -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms512M -Xmx512M -Xmn100M -XX:+HeapDumpOnOutOfMemoryError -XX:+AggressiveOpts -XX:+OptimizeStringConcat -XX:+UseFastAccessorMethods -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv6Addresses=false ${JAVA_OPTS}"
-
-echo $JAVA_OPTS
-
-CLASSPATH="$GATLING_HOME/lib/*:$GATLING_CONF:$GATLING_HOME/user-files:${JAVA_CLASSPATH}"
-
-java $JAVA_OPTS -cp "$CLASSPATH" io.gatling.app.Gatling "$@"

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/user-files/data/search.csv
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/user-files/data/search.csv b/stack/loadtests/gatling/user-files/data/search.csv
deleted file mode 100644
index fdeab9e..0000000
--- a/stack/loadtests/gatling/user-files/data/search.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-searchCriterion,searchComputerName
-Macbook,MacBook Pro
-eee,ASUS Eee PC 1005PE
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/gatling/user-files/request-bodies/.keep
----------------------------------------------------------------------
diff --git a/stack/loadtests/gatling/user-files/request-bodies/.keep b/stack/loadtests/gatling/user-files/request-bodies/.keep
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/loadtest_setup.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/loadtest_setup.sh b/stack/loadtests/loadtest_setup.sh
deleted file mode 100644
index 3c5cf58..0000000
--- a/stack/loadtests/loadtest_setup.sh
+++ /dev/null
@@ -1,45 +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.
-
-#!/bin/bash -x
-check=`grep "DnumUsers" gatling/bin/gatling.sh`
-if [[ $check == "" ]]
-then 
-sed -i.bak 's/JAVA_OPTS="/JAVA_OPTS="-Dthrottle=${GATLING_THROTTLE} -DnumUsers=${GATLING_NUMUSERS} -DrampTime=${GATLING_RAMPTIME} -Dduration=${GATLING_DURATION} -DnumEntities=${GATLING_NUMENTITIES} -Dbaseurl=${GATLING_BASE_URL} -Dorg=${GATLING_ORG} -Dapp=${GATLING_APP} -Dnotifier=${GATLING_NOTIFIER} -Dprovider=${GATLING_PROVIDER} /g' gatling/bin/gatling.sh
-fi
-GATLING_NUMUSERS=5000
-GATLING_RAMPTIME=300
-echo "Enter base url for target server, e.g. http://api.usergrid.com/ (note the trailing slash)"
-read GATLING_BASE_URL
-echo "Enter org name"
-read GATLING_ORG
-echo "Enter app name"
-read GATLING_APP
-echo "Running simulation to load 5k users with geolocation data into /users collection. This will take ~5 minutes."
-echo -e "2\n\n\n" | gatling/bin/gatling.sh
-echo "Finished loading data into /users collection"
-echo 'All done! To get started, set these environment variables:
-
-GATLING_BASE_URL - Required. UG base url, e.g. http://api.usergrid.com/.
-GATLING_ORG      - Required. UG organization name.
-GATLING_APP      - Required. UG application name.
-
-GATLING_NUMUSERS - Number of users in the simulation. Default is 100.
-GATLING_DURATION - Duration of the simulation. Default is 300.
-GATLING_RAMPTIME - Time period to inject the users over. Default is 0.
-GATLING_THROTTLE - Requests per second the simulation to try to reach. Default is 50.
-
-GATLING_NOTIFIER - Name of the notifier to use for PushNotificationSimulation.
-GATLING_PROVIDER - Push notification provider that corresponds to the notifier, e.g. apple, google, etc.'
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/data-generators/EntityDataGenerator.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/data-generators/EntityDataGenerator.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/data-generators/EntityDataGenerator.scala
deleted file mode 100755
index b1a7a90..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/data-generators/EntityDataGenerator.scala
+++ /dev/null
@@ -1,57 +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
-
-import scala.collection.mutable.ArrayBuffer
-
-object EntityDataGenerator {
-
-  def generateBlockUserLists(numUsers: Int): Map[String, String] = {
-
-    var blocks: ArrayBuffer[String] = new ArrayBuffer[String]
-    var blockedBy: ArrayBuffer[String] = new ArrayBuffer[String]
-
-    for (numBlock <- 1 to Utils.generateRandomInt(1, 7)) {
-      blocks += "user".concat(Utils.generateRandomInt(1, numUsers).toString)
-    }
-
-    for (numBlockedBy <- 1 to Utils.generateRandomInt(1, 7)) {
-      blockedBy += "user".concat(Utils.generateRandomInt(1, numUsers).toString)
-    }
-
-    return Map("blocks" -> blocks.toArray.mkString(","), "blockedBy" -> blockedBy.toArray.mkString(","))
-
-  }
-
-  def generateUser(userId: Int): Map[String,String] = {
-
-    return Map("username" -> "user".concat(userId.toString),
-      "profileId" -> Utils.generateRandomInt(10000, 1000000).toString,
-      "displayName" -> Utils.generateRandomInt(10000, 1000000).toString,
-      "showAge" -> Utils.generateRandomInt(0, 1).toString,
-      "ethnicity" -> Utils.generateRandomInt(1, 15).toString,
-      "relationshipStatus" -> Utils.generateRandomInt(1, 4).toString,
-      "headline" -> "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
-      "aboutMe" -> "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
-      "age" -> Utils.generateRandomInt(18, 65).toString,
-      "height" -> Utils.generateRandomInt(48, 84).toString,
-      "weight" -> Utils.generateRandomInt(120, 350).toString,
-      "seen" -> Utils.generateRandomInt(50, 100000).toString
-    )
-  }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/data-generators/FeederGenerator.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/data-generators/FeederGenerator.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/data-generators/FeederGenerator.scala
deleted file mode 100755
index ffe324c..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/data-generators/FeederGenerator.scala
+++ /dev/null
@@ -1,101 +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
-
-import io.gatling.core.Predef._
-import scala.collection.mutable.ArrayBuffer
-
-object FeederGenerator {
-
-  def generateUserWithGeolocationFeeder(numUsers: Int, radius: Double, centerLatitude: Double, centerLongitude: Double): Array[Map[String, String]] = {
-    var userArray: ArrayBuffer[Map[String, String]] = new ArrayBuffer[Map[String, String]]
-    for (userCount <- 1 to numUsers) {
-      var user: Map[String, String] = EntityDataGenerator.generateUser(userCount)
-      var geolocation: Map[String, String] = Utils.generateRandomGeolocation(radius, centerLatitude, centerLongitude)
-      var blockLists: Map[String, String] = EntityDataGenerator.generateBlockUserLists(numUsers)
-
-      user = user ++ geolocation ++ blockLists
-
-      userArray += user
-    }
-    return userArray.toArray
-  }
-
-  def generateGeolocationFeeder(radius: Double, centerLatitude: Double, centerLongitude: Double): Feeder[String] = {
-
-    val geolocationFeeder = new Feeder[String] {
-
-      // always return true as this feeder can be polled infinitively
-      override def hasNext = true
-
-      override def next: Map[String, String] = {
-        var geolocation: Map[String, String] = Utils.generateRandomGeolocation(radius, centerLatitude, centerLongitude)
-        Map("latitude" -> geolocation("latitude"), "longitude" -> geolocation("longitude"))
-      }
-    }
-
-    return geolocationFeeder
-
-  }
-
-  def generateGeolocationWithQueryFeeder(radius: Double, centerLatitude: Double, centerLongitude: Double): Feeder[String] = {
-
-    val geolocationFeeder = new Feeder[String] {
-
-      // always return true as this feeder can be polled infinitively
-      override def hasNext = true
-
-      override def next: Map[String, String] = {
-        var geolocation: Map[String, String] = Utils.generateRandomGeolocation(radius, centerLatitude, centerLongitude)
-        var queryParams = Utils.generateRandomQueryString
-        Map("latitude" -> geolocation("latitude"), "longitude" -> geolocation("longitude"), "queryParams" -> queryParams)
-      }
-    }
-
-    return geolocationFeeder
-
-  }
-
-  def generateUserConnectionFeeder(numUsers: Int): Feeder[String] = {
-
-    val userIdFeeder = new Feeder[String] {
-
-      // always return true as this feeder can be polled infinitively
-      override def hasNext = true
-
-      override def next: Map[String, String] = {
-        Map("user1" -> "user".concat(Utils.generateRandomInt(1, numUsers).toString), "user2" -> "user".concat(Utils.generateRandomInt(1, numUsers).toString))
-      }
-    }
-
-    return userIdFeeder
-
-  }
-
-  def generateEntityNameFeeder(prefix: String, numEntities: Int): Array[Map[String, String]] = {
-
-    var nameArray: ArrayBuffer[Map[String, String]] = new ArrayBuffer[Map[String, String]]
-
-    for (entityCount <- 1 to numEntities) {
-      nameArray += Map("entityName" -> prefix.concat(entityCount.toString))
-    }
-
-    return nameArray.toArray
-
-  }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala
deleted file mode 100755
index f5f7901..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala
+++ /dev/null
@@ -1,45 +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
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-
-/**
- * Performs organization registration
- *
- *
- * Expects:
- *
- * authToken The auth token to use when creating the application
- * orgName The organization name
- *
- * Produces:
- *
- * appName The name of the created application
- */
-object ApplicationScenarios {
-
-  val createApplication = exec(http("Create Application")
-    .post("/management/organizations/${org}/applications")
-    .headers(Headers.jsonAuthorized)
-    .body(StringBody("{\"name\":\"" + Settings.app + "\"}"))
-    .check(status.is(200))
-
-    )
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala
deleted file mode 100755
index ba2449f..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala
+++ /dev/null
@@ -1,30 +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
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-
-object ConnectionScenarios {
-
-  val postConnection = exec(
-    http("POST connection")
-      .post("/users/${user1}/likes/users/${user2}")
-      .check(status.is(200))
-  )
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
deleted file mode 100755
index d8d8af0..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
+++ /dev/null
@@ -1,65 +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
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-
-/**
- *
- * Creates a new device
- *
- * Expects:
- *
- * authToken The auth token to use when creating the application
- * orgName The name of the org
- * appName The name of the app
- * notifierName The name of the created notifier
- *
- * Produces:
- *
- * deviceName the name of the device created
- *
- */
-object DeviceScenarios {
-
-  /**
-   * Create a device
-   */
-  val postDeviceWithNotifier = exec(http("Create device with notifier")
-    .post("/devices")
-    .body(StringBody("{\"name\":\"${entityName}\"," +
-      "\"deviceModel\":\"Fake Device\"," +
-      " \"deviceOSVerion\":\"Negative Version\", " +
-      "\"${notifier}.notifier.id\":\"${entityName}\"}"))
-    .check(status.is(200)))
-
-  val postDeviceWithNotifier400ok = exec(http("Create device with notifier")
-    .post("/devices")
-    .body(StringBody("{\"name\":\"${entityName}\"," +
-    "\"deviceModel\":\"Fake Device\"," +
-    " \"deviceOSVerion\":\"Negative Version\", " +
-    "\"${notifier}.notifier.id\":\"${entityName}\"}"))
-    .check(status.in(200 to 400)))
-
-  /**
-   * TODO: Add a device to a user, which would expect a user in the session
-   */
-
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/GeoScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/GeoScenarios.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/GeoScenarios.scala
deleted file mode 100755
index 94bf0af..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/GeoScenarios.scala
+++ /dev/null
@@ -1,43 +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
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-
-object GeoScenarios {
-
-  val getGeolocation = exec(
-      http("GET geolocated user")
-        .get("/users?ql=location%20within%20" + Settings.geosearchRadius + "%20of%20${latitude},${longitude}")
-        .check(status.is(200))
-    )
-
-  val getGeolocationWithQuery = exec(
-      http("GET geolocated user with query")
-        .get("/users?ql=${queryParams}%20AND%20location%20within%20" + Settings.geosearchRadius + "%20of%20${latitude},${longitude}")
-        .check(status.is(200))
-    )
-
-  val updateGeolocation = exec(
-    http("PUT user location")
-      .put("/users/user" + Utils.generateRandomInt(1, Settings.numUsers))
-      .body(StringBody("{\"location\":{\"latitude\":\"${latitude}\",\"longitude\":\"${longitude}\"}}"))
-      .check(status.is(200))
-  )
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
deleted file mode 100755
index 91d6754..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
+++ /dev/null
@@ -1,71 +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
-
-import java.io.File
-import java.nio.file.{Paths, Files}
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import scala.concurrent.duration._
-
-import scala.io.Source
-
-/**
- *
- * Creates a new device
- *
- * Expects:
- *
- * authToken The auth token to use when creating the application
- * orgName The name of the org
- * appName The name of the app
- * notifierName The name of the created notifier
- * deviceName the name of the device created to send the notification to
- *
- * Produces:
- *
- * N/A
- *
- *
- */
-object NotificationScenarios {
-
-
-  /**
-   * send the notification now
-   */
-  val sendNotification = exec(http("Send Single Notification")
-      .post("/devices/${entityName}/notifications")
-      .body(StringBody("{\"payloads\":{\"${notifier}\":\"testmessage\"}}"))
-      .check(status.is(200))
-    )
-
-  val sendNotificationToUser= exec(http("Send Notification to All Devices")
-    .post("/users/${user}/notifications")
-    .body(StringBody("{\"payloads\":{\"${notifier}\":\"testmessage\"}}"))
-    .check(status.is(200))
-  )
-
-  /**
-   * TODO: Add posting to users, which would expect a user in the session
-   */
-
-
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala
deleted file mode 100755
index 0c2fc0c..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala
+++ /dev/null
@@ -1,65 +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
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import scala.concurrent.duration._
-
-/**
- *
- * Creates a new no-op notifier
- *
- *
- * Expects:
- *
- * authToken The auth token to use when creating the application
- * orgName The name of the org
- * appName The name of the app
- *
- * Produces:
- *
- * notifierName The name of the created notifier
- *
- */
-object NotifierScenarios {
-  
-  val notifier = Settings.pushNotifier
-  val provider = Settings.pushProvider
-
-  /**
-   * Create a notifier
-   */
-  val createNotifier = exec(
-      session => {
-        session.set("notifier", notifier)
-        session.set("provider", provider)
-      }
-    )
-
-    .exec(http("Create Notifier")
-    .post("/notifiers")
-    .body(StringBody("{\"name\":\"${notifier}\",\"provider\":\"${provider}\"}"))
-    //remnants of trying to upload an apple certificate
-//    .param("name", "${notifierName}")
-//    .param("provider", "apple")
-//    .param("environment", "mock")
-//    .fileBody("p12Certificate", Map).fileBody(pkcs12Cert)
-    .check(status.is(200)))
-
-
-}


[28/45] git commit: Add missing ASL header.

Posted by to...@apache.org.
Add missing ASL header.


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

Branch: refs/heads/key-row-sharding
Commit: a100c0741f8900dff7cb786b7396962729ae4e6c
Parents: 89cf61f
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Oct 29 11:59:14 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Oct 29 11:59:14 2014 -0400

----------------------------------------------------------------------
 stack/loadtests/src/main/scripts/gatling-mvn.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a100c074/stack/loadtests/src/main/scripts/gatling-mvn.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scripts/gatling-mvn.sh b/stack/loadtests/src/main/scripts/gatling-mvn.sh
index ad02feb..531a638 100644
--- a/stack/loadtests/src/main/scripts/gatling-mvn.sh
+++ b/stack/loadtests/src/main/scripts/gatling-mvn.sh
@@ -1,4 +1,17 @@
 #!/bin/sh
+#
+# Licensed 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.
+#
 URL="$1"
 ORG="$2"
 APP="$3"


[24/45] git commit: Use Guava Cache for manager caches.

Posted by to...@apache.org.
Use Guava Cache for manager caches.


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

Branch: refs/heads/key-row-sharding
Commit: 3d3f1897953bffa96b18a9012b34c0480c849cee
Parents: 8df2185
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Oct 29 09:07:05 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Oct 29 09:07:05 2014 -0400

----------------------------------------------------------------------
 .../corepersistence/CpManagerCache.java         | 117 +++++++++++--------
 1 file changed, 70 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3d3f1897/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
index 62ea81f..99bde22 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
@@ -15,6 +15,11 @@
  */
 package org.apache.usergrid.corepersistence;
 
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
 import org.apache.usergrid.persistence.collection.CollectionScope;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
@@ -26,7 +31,7 @@ import org.apache.usergrid.persistence.index.EntityIndexFactory;
 import org.apache.usergrid.persistence.map.MapManager;
 import org.apache.usergrid.persistence.map.MapManagerFactory;
 import org.apache.usergrid.persistence.map.MapScope;
-import org.apache.usergrid.utils.LRUCache2;
+
 
 public class CpManagerCache {
 
@@ -36,19 +41,50 @@ public class CpManagerCache {
     private final MapManagerFactory mmf;
 
     // TODO: consider making these cache sizes and timeouts configurable
-    // TODO: replace with Guava cache
-    private final LRUCache2<CollectionScope, EntityCollectionManager> ecmCache
-            = new LRUCache2<CollectionScope, EntityCollectionManager>(50, 1 * 60 * 60 * 1000);
-
-    private final LRUCache2<ApplicationScope, EntityIndex> eiCache
-            = new LRUCache2<>(50, 1 * 60 * 60 * 1000);
-
-    private final LRUCache2<ApplicationScope, GraphManager> gmCache
-            = new LRUCache2<ApplicationScope, GraphManager>(50, 1 * 60 * 60 * 1000);
-
-    private final LRUCache2<MapScope, MapManager> mmCache
-            = new LRUCache2<MapScope, MapManager>(50, 1 * 60 * 60 * 1000);
 
+    private LoadingCache<CollectionScope, EntityCollectionManager> ecmCache = 
+        CacheBuilder.newBuilder()
+            .maximumSize(100)
+            .expireAfterWrite( 1, TimeUnit.HOURS)
+            .build( new CacheLoader<CollectionScope, EntityCollectionManager>() {
+                public EntityCollectionManager load( CollectionScope scope ) { 
+                    return ecmf.createCollectionManager( scope );
+                }
+            }
+        );
+
+    private LoadingCache<ApplicationScope, EntityIndex> eiCache = 
+        CacheBuilder.newBuilder()
+            .maximumSize(100)
+            .expireAfterWrite( 1, TimeUnit.HOURS )
+            .build( new CacheLoader<ApplicationScope, EntityIndex>() {
+                public EntityIndex load( ApplicationScope scope ) { 
+                    return eif.createEntityIndex( scope );
+                }
+            }
+        );
+
+    private LoadingCache<ApplicationScope, GraphManager> gmCache = 
+        CacheBuilder.newBuilder()
+            .maximumSize(100)
+            .expireAfterWrite( 1, TimeUnit.HOURS )
+            .build( new CacheLoader<ApplicationScope, GraphManager>() {
+                public GraphManager load( ApplicationScope scope ) { 
+                    return gmf.createEdgeManager( scope );
+                }
+            }
+        );
+
+    private LoadingCache<MapScope, MapManager> mmCache = 
+        CacheBuilder.newBuilder()
+            .maximumSize(100)
+            .expireAfterWrite( 1, TimeUnit.HOURS )
+            .build( new CacheLoader<MapScope, MapManager>() {
+                public MapManager load( MapScope scope ) { 
+                    return mmf.createMapManager( scope );
+                }
+            }
+        );
 
     public CpManagerCache(
             EntityCollectionManagerFactory ecmf, 
@@ -63,54 +99,41 @@ public class CpManagerCache {
     }
 
     public EntityCollectionManager getEntityCollectionManager(CollectionScope scope) {
-
-        EntityCollectionManager ecm = ecmCache.get(scope);
-
-        if (ecm == null) {
-            ecm = ecmf.createCollectionManager(scope);
-            ecmCache.put(scope, ecm);
+        try {
+            return ecmCache.get( scope );
+        } catch (ExecutionException ex) {
+            throw new RuntimeException("Error getting manager", ex);
         }
-        return ecm;
     }
 
-    public EntityIndex getEntityIndex(ApplicationScope applicationScope) {
-
-        EntityIndex ei = eiCache.get(applicationScope);
-
-        if (ei == null) {
-            ei = eif.createEntityIndex(applicationScope);
-            eiCache.put(applicationScope, ei);
+    public EntityIndex getEntityIndex(ApplicationScope appScope) {
+        try {
+            return eiCache.get( appScope );
+        } catch (ExecutionException ex) {
+            throw new RuntimeException("Error getting manager", ex);
         }
-        return ei;
     }
 
     public GraphManager getGraphManager(ApplicationScope appScope) {
-
-        GraphManager gm = gmCache.get(appScope);
-
-        if (gm == null) {
-            gm = gmf.createEdgeManager(appScope);
-            gmCache.put(appScope, gm);
+        try {
+            return gmCache.get( appScope );
+        } catch (ExecutionException ex) {
+            throw new RuntimeException("Error getting manager", ex);
         }
-        return gm;
     }
 
     public MapManager getMapManager( MapScope mapScope) {
-
-        MapManager mm = mmCache.get(mapScope);
-
-        if (mm == null) {
-            mm = mmf.createMapManager(mapScope);
-            mmCache.put(mapScope, mm);
+        try {
+            return mmCache.get( mapScope );
+        } catch (ExecutionException ex) {
+            throw new RuntimeException("Error getting manager", ex);
         }
-        return mm;
     }
 
     void flush() {
-        gmCache.purge();
-        ecmCache.purge();
-        eiCache.purge();
+        ecmCache.invalidateAll();
+        eiCache.invalidateAll();
+        gmCache.invalidateAll();
+        mmCache.invalidateAll();
     }
-
-
 }


[23/45] git commit: adding gatling script

Posted by to...@apache.org.
adding gatling script


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

Branch: refs/heads/key-row-sharding
Commit: 8df2185a4a8530a63fe8ea7382e5db758437605d
Parents: 744e5a8
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Oct 28 12:43:19 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Oct 28 12:43:19 2014 -0600

----------------------------------------------------------------------
 stack/loadtests/src/main/scripts/gatling-mvn.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8df2185a/stack/loadtests/src/main/scripts/gatling-mvn.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scripts/gatling-mvn.sh b/stack/loadtests/src/main/scripts/gatling-mvn.sh
new file mode 100644
index 0000000..ad02feb
--- /dev/null
+++ b/stack/loadtests/src/main/scripts/gatling-mvn.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+URL="$1"
+ORG="$2"
+APP="$3"
+NOTIFIER="$4"
+USERS="$5"
+RAMP="$6"
+shift 6
+rm -rf usergrid
+git clone https://github.com/apache/incubator-usergrid.git usergrid
+cd usergrid/stack
+git checkout -b two-dot-o origin/two-dot-o
+cd loadtests
+mvn clean install
+mvn gatling:execute -Dthrottle=3000 -Dduration=300 -DnumEntities=5000 -DnumUsers=${USERS} -DrampTime=${RAMP} -Dbaseurl=${URL} -Dorg=${ORG} -Dapp=${APP} -DpushNotifier=${NOTIFIER} -DpushProvider=noop


[39/45] git commit: Formatting and import cleanup only.

Posted by to...@apache.org.
Formatting and import cleanup only.


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

Branch: refs/heads/key-row-sharding
Commit: 707c9b9989cfcdf21b39977494afb36b8a495000
Parents: 610eb2d
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Oct 29 15:19:30 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Oct 29 15:19:30 2014 -0400

----------------------------------------------------------------------
 .../corepersistence/CpEntityDeleteListener.java | 45 +++++++------
 .../usergrid/corepersistence/CpSetup.java       |  1 -
 .../usergrid/corepersistence/CpWalker.java      | 44 +++++++-----
 .../results/FilteringLoader.java                | 63 +++++++++--------
 .../results/ResultsLoaderFactory.java           |  5 +-
 .../results/ResultsLoaderFactoryImpl.java       |  4 --
 .../results/ResultsVerifier.java                |  6 +-
 .../results/VersionVerifier.java                |  8 ++-
 .../corepersistence/util/CpEntityMapUtils.java  |  5 +-
 .../usergrid/persistence/index/EntityIndex.java |  4 +-
 .../persistence/index/EntityIndexBatch.java     |  6 --
 .../persistence/index/EntityIndexFactory.java   |  2 -
 .../usergrid/persistence/index/IndexScope.java  |  9 +--
 .../persistence/index/guice/IndexModule.java    |  1 -
 .../index/impl/EsEntityIndexBatchImpl.java      |  3 +-
 .../index/impl/EsEntityIndexImpl.java           | 71 ++++++++++----------
 .../persistence/index/impl/EsProvider.java      | 11 ++-
 .../index/query/CandidateResults.java           |  7 +-
 .../persistence/index/query/Identifier.java     |  3 +-
 .../usergrid/persistence/index/query/Query.java | 27 +++++---
 .../persistence/index/query/Results.java        |  4 +-
 21 files changed, 169 insertions(+), 160 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityDeleteListener.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityDeleteListener.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityDeleteListener.java
index 70df7d5..4ec4056 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityDeleteListener.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityDeleteListener.java
@@ -68,28 +68,35 @@ public class CpEntityDeleteListener {
         return Observable.create( new ObservableIterator<MvccEntity>( "deleteEntities" ) {
             @Override
             protected Iterator<MvccEntity> getIterator() {
-                Iterator<MvccEntity> iterator = entityMetadataSerialization.loadHistory( entityEvent.getCollectionScope(), entity.getId(), entity.getVersion(), serializationFig.getHistorySize() );
+                Iterator<MvccEntity> iterator = entityMetadataSerialization.loadHistory( 
+                        entityEvent.getCollectionScope(), 
+                        entity.getId(), 
+                        entity.getVersion(), 
+                        serializationFig.getHistorySize() );
                 return iterator;
             }
         } ).subscribeOn(Schedulers.io())
-                .buffer(serializationFig.getBufferSize())
-                .flatMap(new Func1<List<MvccEntity>, Observable<EntityVersion>>() {
-                    @Override
-                    public Observable<EntityVersion> call(List<MvccEntity> mvccEntities) {
-                        MutationBatch mutationBatch = keyspace.prepareMutationBatch();
-                        List<EntityVersion> versions = new ArrayList<>();
-                        //actually delete the edge from both the commit log and
-                        for (MvccEntity mvccEntity : mvccEntities) {
-                            versions.add(mvccEntity);
-                            mutationBatch.mergeShallow(entityMetadataSerialization.delete(entityEvent.getCollectionScope(), mvccEntity.getId(), mvccEntity.getVersion()));
-                        }
-                        try {
-                            mutationBatch.execute();
-                        } catch (ConnectionException e) {
-                            throw new RuntimeException("Unable to execute mutation", e);
-                        }
-                        return Observable.from(versions);
+            .buffer(serializationFig.getBufferSize())
+            .flatMap(new Func1<List<MvccEntity>, Observable<EntityVersion>>() {
+                @Override
+                public Observable<EntityVersion> call(List<MvccEntity> mvccEntities) {
+                    MutationBatch mutationBatch = keyspace.prepareMutationBatch();
+                    List<EntityVersion> versions = new ArrayList<>();
+                    //actually delete the edge from both the commit log and
+                    for (MvccEntity mvccEntity : mvccEntities) {
+                        versions.add(mvccEntity);
+                        mutationBatch.mergeShallow(entityMetadataSerialization.delete(
+                                entityEvent.getCollectionScope(), 
+                                mvccEntity.getId(), 
+                                mvccEntity.getVersion()));
                     }
-                });
+                    try {
+                        mutationBatch.execute();
+                    } catch (ConnectionException e) {
+                        throw new RuntimeException("Unable to execute mutation", e);
+                    }
+                    return Observable.from(versions);
+                }
+            });
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
index c1bab12..9f7b031 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
@@ -22,7 +22,6 @@ import com.google.inject.Injector;
 import com.netflix.config.ConfigurationManager;
 import java.util.Properties;
 import java.util.UUID;
-import java.util.logging.Level;
 import me.prettyprint.cassandra.service.CassandraHost;
 import me.prettyprint.hector.api.ddl.ComparatorType;
 import static me.prettyprint.hector.api.factory.HFactory.createColumnFamilyDefinition;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
index 27d4224..c3a9fe6 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
@@ -56,40 +56,52 @@ public class CpWalker {
     }
 
 
-    public void walkCollections( final CpEntityManager em, final EntityRef start, final CpVisitor visitor )
-            throws Exception {
+    public void walkCollections( final CpEntityManager em, final EntityRef start, 
+            final CpVisitor visitor ) throws Exception {
 
         doWalkCollections( em, new SimpleId( start.getUuid(), start.getType() ), visitor );
     }
 
 
-    private void doWalkCollections( final CpEntityManager em, final Id applicationId, final CpVisitor visitor ) {
+    private void doWalkCollections( 
+            final CpEntityManager em, final Id applicationId, final CpVisitor visitor ) {
 
         final ApplicationScope applicationScope = em.getApplicationScope();
 
         final GraphManager gm = em.getManagerCache().getGraphManager( applicationScope );
 
-        logger.debug( "Loading edges types from {}:{}\n   scope {}:{}", new Object[] {
-                applicationId.getType(), applicationId.getUuid(), applicationScope.getApplication().getType(),
-                        applicationScope.getApplication().getUuid()
-                } );
+        logger.debug( "Loading edges types from {}:{}\n   scope {}:{}",
+            new Object[] {
+                applicationId.getType(),
+                applicationId.getUuid(),
+                applicationScope.getApplication().getType(),
+                applicationScope.getApplication().getUuid()
+            } );
 
         //only search edge types that start with collections
 
         Observable<String> edgeTypes = gm.getEdgeTypesFromSource(
-                       new SimpleSearchEdgeType( applicationId, CpNamingUtils.EDGE_COLL_SUFFIX, null ) );
+            new SimpleSearchEdgeType( applicationId, CpNamingUtils.EDGE_COLL_SUFFIX, null ) );
 
         edgeTypes.flatMap( new Func1<String, Observable<Edge>>() {
             @Override
             public Observable<Edge> call( final String edgeType ) {
 
-                logger.debug( "Loading edges of edgeType {} from {}:{}\n   scope {}:{}", new Object[] {
-                        edgeType, applicationId.getType(), applicationId.getUuid(), applicationScope.getApplication().getType(),
+                logger.debug( "Loading edges of edgeType {} from {}:{}\n   scope {}:{}", 
+                    new Object[] {
+                        edgeType,
+                        applicationId.getType(),
+                        applicationId.getUuid(),
+                        applicationScope.getApplication().getType(),
                         applicationScope.getApplication().getUuid()
                 } );
 
-                return gm.loadEdgesFromSource( new SimpleSearchByEdgeType( applicationId, edgeType, Long.MAX_VALUE,
-                                SearchByEdgeType.Order.DESCENDING, null ) );
+                return gm.loadEdgesFromSource( new SimpleSearchByEdgeType( 
+                    applicationId,
+                    edgeType,
+                    Long.MAX_VALUE,
+                    SearchByEdgeType.Order.DESCENDING,
+                    null ) );
             }
         } ).doOnNext( new Action1<Edge>() {
 
@@ -98,16 +110,16 @@ public class CpWalker {
 
                 logger.info( "Re-indexing edge {}", edge );
 
-                EntityRef targetNodeEntityRef =
-                        new SimpleEntityRef( edge.getTargetNode().getType(), edge.getTargetNode().getUuid() );
+                EntityRef targetNodeEntityRef = new SimpleEntityRef( 
+                        edge.getTargetNode().getType(), edge.getTargetNode().getUuid() );
 
                 Entity entity;
                 try {
                     entity = em.get( targetNodeEntityRef );
                 }
                 catch ( Exception ex ) {
-                    logger.error( "Error getting sourceEntity {}:{}, continuing", targetNodeEntityRef.getType(),
-                            targetNodeEntityRef.getUuid() );
+                    logger.error( "Error getting sourceEntity {}:{}, continuing", 
+                            targetNodeEntityRef.getType(), targetNodeEntityRef.getUuid() );
                     return;
                 }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/FilteringLoader.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/FilteringLoader.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/FilteringLoader.java
index 00faefd..8ca2211 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/FilteringLoader.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/FilteringLoader.java
@@ -96,40 +96,32 @@ public class FilteringLoader implements ResultsLoader {
         }
 
 
-        /**
-         * For each entity, holds the index it appears in our candidates for keeping ordering correct
-         */
+        // For each entity, holds the index it appears in our candidates for keeping ordering correct
         final Map<Id, Integer> orderIndex = new HashMap<>( crs.size() );
 
-        /**
-         * Maps the entity ids to our candidates
-         */
+        // Maps the entity ids to our candidates
         final Map<Id, CandidateResult> maxCandidateMapping = new HashMap<>( crs.size() );
 
-        /**
-         * Groups all candidate results by types.  When search connections there will be multiple types,
-         * so we want to batch
-         * fetch them more efficiently
-         */
-        final HashMultimap<String, CandidateResult> groupedByScopes = HashMultimap.create( crs.size(), crs.size() );
+        // Groups all candidate results by types.  When search connections there will be multiple 
+        // types, so we want to batch fetch them more efficiently
+        
+        final HashMultimap<String, CandidateResult> groupedByScopes = 
+                HashMultimap.create( crs.size(), crs.size() );
 
         final Iterator<CandidateResult> iter = crs.iterator();
 
 
-        /**
-         * TODO, in this case we're "optimizing" due to the limitations of collection scope.  Perhaps  we should
-         * change the API to just be an application, then an "owner" scope?
-         */
+        // TODO, in this case we're "optimizing" due to the limitations of collection scope.  
+        // Perhaps  we should change the API to just be an application, then an "owner" scope?
 
-        /**
-         * Go through the candidates and group them by scope for more efficient retrieval.  Also remove duplicates before we even make a network call
-         */
+        // Go through the candidates and group them by scope for more efficient retrieval.  
+        // Also remove duplicates before we even make a network call
         for ( int i = 0; iter.hasNext(); i++ ) {
 
             final CandidateResult currentCandidate = iter.next();
 
-            final String collectionType =
-                    CpNamingUtils.getCollectionScopeNameFromEntityType( currentCandidate.getId().getType() );
+            final String collectionType = CpNamingUtils.getCollectionScopeNameFromEntityType( 
+                    currentCandidate.getId().getType() );
 
             final Id entityId = currentCandidate.getId();
 
@@ -154,9 +146,12 @@ public class FilteringLoader implements ResultsLoader {
             if ( UUIDComparator.staticCompare( currentVersion, previousMaxVersion ) > 0 ) {
 
                 //de-index it
-                logger.debug( "Stale version of Entity uuid:{} type:{}, stale v:{}, latest v:{}", new Object[] {
-                                entityId.getUuid(), entityId.getType(), previousMaxVersion, currentVersion
-                        } );
+                logger.debug( "Stale version of Entity uuid:{} type:{}, stale v:{}, latest v:{}", 
+                    new Object[] { 
+                        entityId.getUuid(), 
+                        entityId.getType(), 
+                        previousMaxVersion, 
+                        currentVersion } );
 
                 //deindex this document, and remove the previous maxVersion
                 //we have to deindex this from our ownerId, since this is what gave us the reference
@@ -197,12 +192,13 @@ public class FilteringLoader implements ResultsLoader {
 
             //now using the scope, load the collection
 
-            // Get the collection scope and batch load all the versions.  We put all entities in app/app for easy retrieval
-            // unless persistence changes, we never want to read from any scope other than the app, app, scope name scope
+            // Get the collection scope and batch load all the versions.  We put all entities in 
+            // app/app for easy retrieval/ unless persistence changes, we never want to read from 
+            // any scope other than the app, app, scope name scope
             final CollectionScope collScope = new CollectionScopeImpl( 
-                    applicationScope.getApplication(), applicationScope.getApplication(), scopeName );
+                applicationScope.getApplication(), applicationScope.getApplication(), scopeName);
 
-            final EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collScope );
+            final EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collScope);
 
 
             //load the results into the loader for this scope for validation
@@ -228,7 +224,8 @@ public class FilteringLoader implements ResultsLoader {
         }
 
 
-         //NOTE DO NOT execute the batch here.  It changes the results and we need consistent paging until we aggregate all results
+         // NOTE DO NOT execute the batch here.  
+        // It changes the results and we need consistent paging until we aggregate all results
         return resultsVerifier.getResults( sortedResults.values() );
     }
 
@@ -239,10 +236,12 @@ public class FilteringLoader implements ResultsLoader {
     }
 
 
-    protected void deIndex( final EntityIndexBatch batch, final Id ownerId, final CandidateResult candidateResult ) {
+    protected void deIndex( final EntityIndexBatch batch, final Id ownerId, 
+            final CandidateResult candidateResult ) {
 
-        IndexScope indexScope = new IndexScopeImpl( ownerId,
-                CpNamingUtils.getCollectionScopeNameFromEntityType( candidateResult.getId().getType() ) );
+        IndexScope indexScope = new IndexScopeImpl( 
+            ownerId,
+            CpNamingUtils.getCollectionScopeNameFromEntityType( candidateResult.getId().getType()));
 
         batch.deindex( indexScope, candidateResult );
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactory.java
index ebd9380..779d604 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactory.java
@@ -32,8 +32,7 @@ public interface ResultsLoaderFactory {
 
     /**
      * Get the load for results
-     * @return
      */
-    public ResultsLoader getLoader(final ApplicationScope applicationScope, final EntityRef ownerId,
-                                        final Query.Level resultsLevel );
+    public ResultsLoader getLoader( final ApplicationScope applicationScope, 
+            final EntityRef ownerId, final Query.Level resultsLevel );
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactoryImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactoryImpl.java
index e987882..0f39fe3 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactoryImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactoryImpl.java
@@ -31,10 +31,8 @@ import com.google.inject.Inject;
 /**
  * Factory for creating results
  */
-
 public class ResultsLoaderFactoryImpl implements ResultsLoaderFactory {
 
-
     private final CpManagerCache managerCache;
 
 
@@ -48,7 +46,6 @@ public class ResultsLoaderFactoryImpl implements ResultsLoaderFactory {
     public ResultsLoader getLoader( final ApplicationScope applicationScope, 
             final EntityRef ownerId, final Query.Level resultsLevel ) {
 
-
         ResultsVerifier verifier;
 
         if ( resultsLevel == Query.Level.REFS ) {
@@ -61,7 +58,6 @@ public class ResultsLoaderFactoryImpl implements ResultsLoaderFactory {
             verifier = new EntityVerifier(Query.MAX_LIMIT);
         }
 
-
         return new FilteringLoader( managerCache, verifier, ownerId, applicationScope );
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsVerifier.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsVerifier.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsVerifier.java
index 995c50a..1b92bcc 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsVerifier.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsVerifier.java
@@ -21,7 +21,6 @@ package org.apache.usergrid.corepersistence.results;
 
 
 import java.util.Collection;
-
 import org.apache.usergrid.persistence.Results;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.index.query.CandidateResult;
@@ -38,10 +37,9 @@ public interface ResultsVerifier {
     public void loadResults(Collection<Id> ids, EntityCollectionManager ecm);
 
     /**
-     * Return true if the candidate result is a valid result that should be retained. * If it 
-     * should not it should also be removed from the list of possible return values in this loader
+     * Return true if the candidate result is a valid result that should be retained. If it should 
+     * not it should also be removed from the list of possible return values in this loader
      * @param candidateResult
-     * @return
      */
     public boolean isValid(CandidateResult candidateResult);
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/VersionVerifier.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/VersionVerifier.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/VersionVerifier.java
index 3a03b7b..c541550 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/VersionVerifier.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/VersionVerifier.java
@@ -36,7 +36,7 @@ import com.fasterxml.uuid.UUIDComparator;
 
 
 /**
- * A loader that verifies versions are correct in cassandra and match elasticsearch
+ * A loader that verifies versions are correct in Cassandra and match ElasticSearch
  */
 public abstract class VersionVerifier implements ResultsVerifier {
 
@@ -69,7 +69,11 @@ public abstract class VersionVerifier implements ResultsVerifier {
 
         if ( UUIDComparator.staticCompare( savedVersion, candidateResult.getVersion() ) > 0 ) {
             logger.debug( "Stale version of Entity uuid:{} type:{}, stale v:{}, latest v:{}",
-                new Object[] { entityId.getUuid(), entityId.getType(), candidateResult.getVersion(), savedVersion
+                new Object[] { 
+                    entityId.getUuid(), 
+                    entityId.getType(), 
+                    candidateResult.getVersion(), 
+                    savedVersion
             } );
 
             return false;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java
index feed396..c110509 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java
@@ -68,7 +68,8 @@ public class CpEntityMapUtils {
         return fromMap( null, map, entityType, topLevel );
     }
 
-    public static Entity fromMap( Entity entity, Map<String, Object> map, String entityType, boolean topLevel ) {
+    public static Entity fromMap( 
+            Entity entity, Map<String, Object> map, String entityType, boolean topLevel ) {
 
         if ( entity == null ) {
             entity = new Entity();
@@ -263,7 +264,7 @@ public class CpEntityMapUtils {
                 // field names lat and lon trigger ElasticSearch geo location 
                 locMap.put("lat", locField.getValue().getLatitude());
                 locMap.put("lon", locField.getValue().getLongitude());
-                 entityMap.put( field.getName(), field.getValue());
+                entityMap.put( field.getName(), field.getValue());
 
             } else if (f instanceof ByteArrayField) {
                     ByteArrayField bf = ( ByteArrayField ) f;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
index 44ad05c..5f4606c 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
@@ -30,8 +30,8 @@ import org.apache.usergrid.persistence.model.entity.Id;
 public interface EntityIndex {
 
     /**
-     * This should ONLY ever be called once on application create.  Otherwise we're introducing slowness into our system
-     *
+     * This should ONLY ever be called once on application create.  
+     * Otherwise we're introducing slowness into our system
      */
     public void initializeIndex();
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java
index f98025b..1a11e9b 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java
@@ -27,9 +27,6 @@ import org.apache.usergrid.persistence.model.entity.Id;
 
 public interface EntityIndexBatch {
 
-
-
-
     /**
      * Create index for Entity
      * @param indexScope The scope for the index
@@ -59,9 +56,6 @@ public interface EntityIndexBatch {
      */
     public EntityIndexBatch deindex(final IndexScope scope, final Id id, final UUID version);
 
-
-    //TODO: Create a delete method that delete's  by Id.  This will delete all documents from ES with the same entity Id
-
     /**
      * Execute the batch
      */

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexFactory.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexFactory.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexFactory.java
index 1a97b5a..78a5137 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexFactory.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexFactory.java
@@ -19,9 +19,7 @@
 package org.apache.usergrid.persistence.index;
 
 
-
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-
 import com.google.inject.assistedinject.Assisted;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexScope.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexScope.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexScope.java
index 9fbb7f5..5b70304 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexScope.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexScope.java
@@ -18,8 +18,6 @@
  */
 package org.apache.usergrid.persistence.index;
 
-
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.model.entity.Id;
 
 
@@ -31,11 +29,10 @@ public interface IndexScope {
      */
     public String getName();
 
-
     /**
-     * @return A uuid that is unique to this context.  It can be any uuid (time uuid preferred). Can be an application id
-     * if this is indexed in a collection, or the collection owner.  In a graph structure, this will be the source
-     * node in the graph
+     * @return A uuid that is unique to this context.  It can be any uuid (time uuid preferred). 
+     * Can be an application id if this is indexed in a collection, or the collection owner.  
+     * In a graph structure, this will be the source node in the graph
      */
     public Id getOwner();
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/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 13661cc..edc938b 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
@@ -22,7 +22,6 @@ package org.apache.usergrid.persistence.index.guice;
 import org.apache.usergrid.persistence.index.IndexFig;
 import com.google.inject.AbstractModule;
 import com.google.inject.assistedinject.FactoryModuleBuilder;
-import org.apache.usergrid.persistence.collection.guice.CollectionModule;
 import org.apache.usergrid.persistence.index.EntityIndex;
 import org.apache.usergrid.persistence.index.EntityIndexFactory;
 import org.apache.usergrid.persistence.index.impl.EsEntityIndexImpl;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
index 151e850..fab135a 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
@@ -312,7 +312,8 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
             }
             else if ( f instanceof UUIDField ) {
 
-                entityMap.put( STRING_PREFIX + field.getName().toLowerCase(), field.getValue().toString().toLowerCase() );
+                entityMap.put( STRING_PREFIX + field.getName().toLowerCase(), 
+                        field.getValue().toString().toLowerCase() );
             }
             else {
                 entityMap.put( field.getName().toLowerCase(), field.getValue() );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 7584386..fc09b5a 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -130,15 +130,12 @@ public class EsEntityIndexImpl implements EntityIndex {
             CreateIndexResponse cir = admin.indices().prepareCreate( indexName ).execute().actionGet();
             log.info( "Created new Index Name [{}] ACK=[{}]", indexName, cir.isAcknowledged() );
 
+            // create the document, this ensures the index is ready
+
+            // Immediately create a document and remove it to ensure the entire cluster is ready 
+            // to receive documents. Occasionally we see errors.  See this post:
+            // http://elasticsearch-users.115913.n3.nabble.com/IndexMissingException-on-create-index-followed-by-refresh-td1832793.html
 
-            //create the document, this ensures the index is ready
-            /**
-             * Immediately create a document and remove it to ensure the entire cluster is ready to receive documents
-             * .  Occasionally we see
-             * errors.  See this post.
-             * http://elasticsearch-users.115913.n3.nabble.com/IndexMissingException-on-create-index-followed-by-refresh-td1832793.html
-             *
-             */
             testNewIndex();
         }
         catch ( IndexAlreadyExistsException expected ) {
@@ -167,18 +164,18 @@ public class EsEntityIndexImpl implements EntityIndex {
             public boolean doOp() {
                 final String tempId = UUIDGenerator.newTimeUUID().toString();
 
+                client.prepareIndex( indexName, VERIFY_TYPE, tempId )
+                        .setSource( DEFAULT_PAYLOAD ).get();
 
-                client.prepareIndex( indexName, VERIFY_TYPE, tempId ).setSource( DEFAULT_PAYLOAD ).get();
-
-                log.info( "Successfully created new document with docId {} in index {} and type {}", tempId, indexName,
-                        VERIFY_TYPE );
+                log.info( "Successfully created new document with docId {} in index {} and type {}", 
+                        tempId, indexName, VERIFY_TYPE );
 
-                //delete all types, this way if we miss one it will get cleaned up
+                // delete all types, this way if we miss one it will get cleaned up
+                client.prepareDeleteByQuery( indexName ).setTypes( VERIFY_TYPE )
+                        .setQuery( MATCH_ALL_QUERY_BUILDER ).get();
 
-                client.prepareDeleteByQuery( indexName ).setTypes( VERIFY_TYPE ).setQuery( MATCH_ALL_QUERY_BUILDER )
-                      .get();
-
-                log.info( "Successfully deleted all documents in index {} and type {}", indexName, VERIFY_TYPE );
+                log.info( "Successfully deleted all documents in index {} and type {}", 
+                        indexName, VERIFY_TYPE );
 
                 return true;
             }
@@ -189,18 +186,19 @@ public class EsEntityIndexImpl implements EntityIndex {
 
 
     /**
-     * Setup ElasticSearch type mappings as a template that applies to all new indexes. Applies to all indexes that
-     * start with our prefix.
+     * Setup ElasticSearch type mappings as a template that applies to all new indexes. 
+     * Applies to all indexes that start with our prefix.
      */
     private void createMappings() throws IOException {
 
-        XContentBuilder xcb =
-                IndexingUtils.createDoubleStringIndexMapping( XContentFactory.jsonBuilder(), "_default_" );
+        XContentBuilder xcb = IndexingUtils
+                .createDoubleStringIndexMapping( XContentFactory.jsonBuilder(), "_default_" );
 
-        PutIndexTemplateResponse pitr = client.admin().indices().preparePutTemplate( "usergrid_template" )
-                                              .setTemplate( config.getIndexPrefix() + "*" ).addMapping( "_default_",
-                        xcb ) // set mapping as the default for all types
-                .execute().actionGet();
+        PutIndexTemplateResponse pitr = client.admin().indices()
+            .preparePutTemplate( "usergrid_template" )
+            .setTemplate( config.getIndexPrefix() + "*" )
+            .addMapping( "_default_", xcb ) // set mapping as the default for all types
+            .execute().actionGet();
     }
 
 
@@ -226,9 +224,8 @@ public class EsEntityIndexImpl implements EntityIndex {
         SearchResponse searchResponse;
         if ( query.getCursor() == null ) {
 
-            SearchRequestBuilder srb =
-                    client.prepareSearch( indexName ).setTypes( indexType ).setScroll( cursorTimeout + "m" )
-                          .setQuery( qb );
+            SearchRequestBuilder srb = client.prepareSearch( indexName )
+                    .setTypes( indexType ).setScroll( cursorTimeout + "m" ) .setQuery( qb );
 
             FilterBuilder fb = query.createFilterBuilder();
             if ( fb != null ) {
@@ -252,21 +249,22 @@ public class EsEntityIndexImpl implements EntityIndex {
                 // type prefix to use. So, here we add an order by clause for every possible type 
                 // that you can order by: string, number and boolean and we ask ElasticSearch 
                 // to ignore any fields that are not present.
+
                 final String stringFieldName = STRING_PREFIX + sp.getPropertyName();
-                final FieldSortBuilder stringSort =
-                        SortBuilders.fieldSort( stringFieldName ).order( order ).ignoreUnmapped( true );
+                final FieldSortBuilder stringSort = SortBuilders.fieldSort( stringFieldName )
+                        .order( order ).ignoreUnmapped( true );
                 srb.addSort( stringSort );
                 log.debug( "   Sort: {} order by {}", stringFieldName, order.toString() );
 
                 final String numberFieldName = NUMBER_PREFIX + sp.getPropertyName();
-                final FieldSortBuilder numberSort =
-                        SortBuilders.fieldSort( numberFieldName ).order( order ).ignoreUnmapped( true );
+                final FieldSortBuilder numberSort = SortBuilders.fieldSort( numberFieldName )
+                        .order( order ).ignoreUnmapped( true );
                 srb.addSort( numberSort );
                 log.debug( "   Sort: {} order by {}", numberFieldName, order.toString() );
 
                 final String booleanFieldName = BOOLEAN_PREFIX + sp.getPropertyName();
-                final FieldSortBuilder booleanSort =
-                        SortBuilders.fieldSort( booleanFieldName ).order( order ).ignoreUnmapped( true );
+                final FieldSortBuilder booleanSort = SortBuilders.fieldSort( booleanFieldName )
+                        .order( order ).ignoreUnmapped( true );
                 srb.addSort( booleanSort );
                 log.debug( "   Sort: {} order by {}", booleanFieldName, order.toString() );
             }
@@ -283,7 +281,8 @@ public class EsEntityIndexImpl implements EntityIndex {
             }
             log.debug( "Executing query with cursor: {} ", scrollId );
 
-            SearchScrollRequestBuilder ssrb = client.prepareSearchScroll( scrollId ).setScroll( cursorTimeout + "m" );
+            SearchScrollRequestBuilder ssrb = client.prepareSearchScroll( scrollId )
+                    .setScroll( cursorTimeout + "m" );
             searchResponse = ssrb.execute().actionGet();
         }
 
@@ -329,7 +328,7 @@ public class EsEntityIndexImpl implements EntityIndex {
                     return true;
                 }
                 catch ( IndexMissingException e ) {
-                    log.error( "Unable to refresh index after create. Waiting before sleeping.", e );
+                    log.error( "Unable to refresh index after create. Waiting before sleeping.", e);
                     throw e;
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
index 9b37952..efc61a9 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
@@ -25,16 +25,13 @@ import java.io.IOException;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.Properties;
-import java.util.logging.Level;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.RandomStringUtils;
 import org.apache.usergrid.persistence.core.util.AvailablePortFinder;
 import org.apache.usergrid.persistence.index.IndexFig;
 import org.elasticsearch.client.Client;
-import org.elasticsearch.client.transport.TransportClient;
 import org.elasticsearch.common.settings.ImmutableSettings;
 import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.transport.InetSocketTransportAddress;
 import org.elasticsearch.node.Node;
 import org.elasticsearch.node.NodeBuilder;
 import org.slf4j.Logger;
@@ -112,7 +109,7 @@ public class EsProvider {
                     .build();
 
                 log.info("-----------------------------------------------------------------------");
-                log.info("Starting ElasticSearch embedded server with settings: \n" + settings.getAsMap() );
+                log.info("Starting ElasticSearch embedded server settings: \n"+settings.getAsMap());
                 log.info("-----------------------------------------------------------------------");
 
                 Node node = NodeBuilder.nodeBuilder().settings(settings)
@@ -172,8 +169,10 @@ public class EsProvider {
 
                 log.debug("Creating ElasticSearch client with settings: " +  settings.getAsMap());
 
-                //use this client when connecting via socket only, such as ssh tunnel or other firewall issues
-//                newClient  = new TransportClient(settings).addTransportAddress( new InetSocketTransportAddress("localhost", 9300) );
+                // use this client when connecting via socket only, 
+                // such as ssh tunnel or other firewall issues
+                // newClient  = new TransportClient(settings).addTransportAddress( 
+                //                  new InetSocketTransportAddress("localhost", 9300) );
 
                 //use this client for quick connectivity
                 Node node = NodeBuilder.nodeBuilder().settings(settings)

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/CandidateResults.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/CandidateResults.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/CandidateResults.java
index d8c225f..a71bcbe 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/CandidateResults.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/CandidateResults.java
@@ -27,8 +27,8 @@ import org.slf4j.LoggerFactory;
 
 
 /**
- * Internal results class, should not be returned as results to a user.  Only returns candidate entity results
- *
+ * Internal results class, should not be returned as results to a user.  
+ * Only returns candidate entity results
  */
 public class CandidateResults implements Iterable<CandidateResult> {
 
@@ -66,8 +66,7 @@ public class CandidateResults implements Iterable<CandidateResult> {
         return query;
     }
 
-
-
+    
     public int size() {
         return candidates.size();
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Identifier.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Identifier.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Identifier.java
index 8d886d5..66dcd3b 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Identifier.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Identifier.java
@@ -43,7 +43,8 @@ public class Identifier implements Serializable {
     Object value;
 
     static Pattern emailRegEx = Pattern.compile( EMAIL_REX );
-    //"Pattern nameRegEx" below used to be [a-zA-Z0-9_\\-./], changed it to contain a 'space' to address https://issues.apache.org/jira/browse/USERGRID-94
+    // "Pattern nameRegEx" below used to be [a-zA-Z0-9_\\-./], changed it to contain a 'space' to a
+    // ddress https://issues.apache.org/jira/browse/USERGRID-94
     static Pattern nameRegEx = Pattern.compile( "[a-zA-Z0-9_\\-./ ]*" );
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
index a1e25da..778134e 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
@@ -115,12 +115,13 @@ public class Query {
     public Query( Query q ) {
         if ( q != null ) {
             type = q.type;
-            sortPredicates = q.sortPredicates != null ? new ArrayList<SortPredicate>( q.sortPredicates ) : null;
+            sortPredicates = q.sortPredicates != null 
+                    ? new ArrayList<SortPredicate>( q.sortPredicates ) : null;
             startResult = q.startResult;
             cursor = q.cursor;
             limit = q.limit;
-            selectAssignments =
-                    q.selectAssignments != null ? new LinkedHashMap<String, String>( q.selectAssignments ) : null;
+            selectAssignments = q.selectAssignments != null 
+                    ? new LinkedHashMap<String, String>( q.selectAssignments ) : null;
             mergeSelectResults = q.mergeSelectResults;
             //level = q.level;
             connection = q.connection;
@@ -132,9 +133,10 @@ public class Query {
             resolution = q.resolution;
             pad = q.pad;
             rootOperand = q.rootOperand;
-            identifiers = q.identifiers != null ? new ArrayList<Identifier>( q.identifiers ) : null;
-            counterFilters =
-                    q.counterFilters != null ? new ArrayList<CounterFilterPredicate>( q.counterFilters ) : null;
+            identifiers = q.identifiers != null 
+                    ? new ArrayList<Identifier>( q.identifiers ) : null;
+            counterFilters = q.counterFilters != null 
+                    ? new ArrayList<CounterFilterPredicate>( q.counterFilters ) : null;
             collection = q.collection;
         }
     }
@@ -253,7 +255,8 @@ public class Query {
     }
 
 
-    public static Query fromQueryParams( Map<String, List<String>> params ) throws QueryParseException {
+    public static Query fromQueryParams( Map<String, List<String>> params ) 
+            throws QueryParseException {
         Query q = null;
         CounterResolution resolution = null;
         List<Identifier> identifiers = null;
@@ -621,8 +624,8 @@ public class Query {
 
         for ( SortPredicate s : sortPredicates ) {
             if ( s.getPropertyName().equals( sort.getPropertyName() ) ) {
-                throw new QueryParseException(
-                        String.format( "Attempted to set sort order for %s more than once", s.getPropertyName() ) );
+                throw new QueryParseException( String.format( 
+                    "Attempted to set sort order for %s more than once", s.getPropertyName() ) );
             }
         }
         sortPredicates.add( sort );
@@ -1094,7 +1097,9 @@ public class Query {
         private final Query.SortDirection direction;
 
 
-        public SortPredicate(@JsonProperty("propertyName")  String propertyName, @JsonProperty("direction")  Query.SortDirection direction ) {
+        public SortPredicate(@JsonProperty("propertyName")  String propertyName, 
+                @JsonProperty("direction")  Query.SortDirection direction ) {
+
             if ( propertyName == null ) {
                 throw new NullPointerException( "Property name was null" );
             }
@@ -1232,7 +1237,7 @@ public class Query {
                 }
             }
 
-            if ( ( user == null ) && ( group == null ) && ( category == null ) && ( name == null ) ) {
+            if ( ( user == null ) && ( group == null ) && ( category == null ) && ( name == null)) {
                 return null;
             }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Results.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Results.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Results.java
index d0c0571..89745d0 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Results.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Results.java
@@ -53,7 +53,9 @@ public class Results implements Iterable<Entity> {
     final EntityCollectionManagerFactory ecmf;
 
 
-    public Results( Query query, List<CandidateResult> candidates, EntityCollectionManagerFactory ecmf ) {
+    public Results( Query query, List<CandidateResult> candidates, 
+            EntityCollectionManagerFactory ecmf ) {
+
         this.query = query;
         this.candidates = candidates;
         this.ecmf = ecmf;


[05/45] git commit: fix build error

Posted by to...@apache.org.
fix build error


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

Branch: refs/heads/key-row-sharding
Commit: e30a7b32258b95b1d5d74d6c9ba448dcc80a42f1
Parents: 19aa1a6
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Oct 24 16:19:36 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Oct 24 16:19:36 2014 -0600

----------------------------------------------------------------------
 .../apns/MockSuccessfulProviderAdapter.java      |  5 ++---
 .../apns/NotificationsServiceIT.java             | 19 +++----------------
 .../gcm/MockSuccessfulProviderAdapter.java       |  4 ++--
 3 files changed, 7 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e30a7b32/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/MockSuccessfulProviderAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/MockSuccessfulProviderAdapter.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/MockSuccessfulProviderAdapter.java
index 8c26ef4..e864e4f 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/MockSuccessfulProviderAdapter.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/MockSuccessfulProviderAdapter.java
@@ -74,9 +74,8 @@ public class MockSuccessfulProviderAdapter implements ProviderAdapter {
     }
 
     @Override
-    public Map<String, Date> getInactiveDevices(Notifier notifier,
-            EntityManager em) throws Exception {
-        return null;
+    public void removeInactiveDevices(Notifier notifier,
+            EntityManager em) {
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e30a7b32/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 a834400..31a653c 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
@@ -686,15 +686,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
         // mock action (based on verified actual behavior) //
         if (!USE_REAL_CONNECTIONS) {
             ns.providerAdapters.put("apple",
-                    new MockSuccessfulProviderAdapter() {
-                        @Override
-                        public Map<String, Date> getInactiveDevices(
-                                Notifier notifier, EntityManager em)
-                                throws Exception {
-                            return Collections.singletonMap(PUSH_TOKEN,
-                                    new Date());
-                        }
-                    });
+                    new MockSuccessfulProviderAdapter());
         }
 
         // create push notification //
@@ -716,9 +708,6 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
         assertEquals(
                 notification.getPayloads().get(notifier.getUuid().toString()),
                 payload);
-//
-//        ns.addDevice(notification, device1);
-//        ns.addDevice(notification, device2);
 
         assertNotNull(device1.getProperty(notifier.getName()
                 + NOTIFIER_ID_POSTFIX));
@@ -731,11 +720,9 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
         // check provider IDs //
 
         device1 = app.getEm().get(device1, Device.class);
-        assertNull(device1
-                .getProperty(notifier.getName() + NOTIFIER_ID_POSTFIX));
+        assertNull(device1 .getProperty(notifier.getName() + NOTIFIER_ID_POSTFIX));
         device2 = app.getEm().get(device2, Device.class);
-        assertNull(device2
-                .getProperty(notifier.getName() + NOTIFIER_ID_POSTFIX));
+        assertNull(device2 .getProperty(notifier.getName() + NOTIFIER_ID_POSTFIX));
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e30a7b32/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/MockSuccessfulProviderAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/MockSuccessfulProviderAdapter.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/MockSuccessfulProviderAdapter.java
index 4c258fe..3836fe8 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/MockSuccessfulProviderAdapter.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/MockSuccessfulProviderAdapter.java
@@ -57,9 +57,9 @@ public class MockSuccessfulProviderAdapter implements ProviderAdapter {
     }
 
     @Override
-    public Map<String, Date> getInactiveDevices(Notifier notifier,
+    public void removeInactiveDevices(Notifier notifier,
             EntityManager em) throws Exception {
-        return null;
+
     }
 
     @Override


[20/45] git commit: Restoring some semblance of my original formatting, take it easy with that auto-formatter folks!

Posted by to...@apache.org.
Restoring some semblance of my original formatting, take it easy with that auto-formatter folks!


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

Branch: refs/heads/key-row-sharding
Commit: 3771e3f933f4d13963b16507389a750c08024c90
Parents: 960ce6b
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Oct 28 11:21:05 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Oct 28 11:21:05 2014 -0400

----------------------------------------------------------------------
 .../corepersistence/CpRelationManager.java      | 889 ++++++++++++-------
 1 file changed, 555 insertions(+), 334 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3771e3f9/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 96f0e1e..8c0d886 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
@@ -189,8 +189,11 @@ public class CpRelationManager implements RelationManager {
     public CpRelationManager() {}
 
 
-    public CpRelationManager init( EntityManager em, CpEntityManagerFactory emf, UUID applicationId,
-                                   EntityRef headEntity, IndexBucketLocator indexBucketLocator ) {
+    public CpRelationManager init( EntityManager em,
+            CpEntityManagerFactory emf,
+            UUID applicationId,
+            EntityRef headEntity, 
+            IndexBucketLocator indexBucketLocator ) {
 
         Assert.notNull( em, "Entity manager cannot be null" );
         Assert.notNull( emf, "Entity manager factory cannot be null" );
@@ -212,21 +215,25 @@ public class CpRelationManager implements RelationManager {
         this.indexBucketLocator = indexBucketLocator; // TODO: this also
 
         // load the Core Persistence version of the head entity as well
-        this.headEntityScope =
-                new CollectionScopeImpl( this.applicationScope.getApplication(), this.applicationScope.getApplication(),
-                        CpNamingUtils.getCollectionScopeNameFromEntityType( headEntity.getType() ) );
+        this.headEntityScope = new CollectionScopeImpl( 
+            this.applicationScope.getApplication(), 
+            this.applicationScope.getApplication(),
+            CpNamingUtils.getCollectionScopeNameFromEntityType( headEntity.getType() ) );
 
         EntityCollectionManager ecm = managerCache.getEntityCollectionManager( headEntityScope );
         if ( logger.isDebugEnabled() ) {
-            logger.debug( "Loading head entity {}:{} from scope\n   app {}\n   owner {}\n   name {}", new Object[] {
-                            headEntity.getType(), headEntity.getUuid(), headEntityScope.getApplication(),
-                            headEntityScope.getOwner(), headEntityScope.getName()
-                    } );
+            logger.debug( "Loading head entity {}:{} from scope\n   app {}\n   owner {}\n   name {}",
+                new Object[] { headEntity.getType(),
+                    headEntity.getUuid(),
+                    headEntityScope.getApplication(),
+                    headEntityScope.getOwner(),
+                    headEntityScope.getName()
+                } );
         }
 
         //TODO PERFORMANCE why are we loading this again here?
-        this.cpHeadEntity = ecm.load( new SimpleId( headEntity.getUuid(), headEntity.getType() ) ).toBlocking()
-                               .lastOrDefault( null );
+        this.cpHeadEntity = ecm.load( new SimpleId( 
+                headEntity.getUuid(), headEntity.getType() ) ).toBlocking() .lastOrDefault( null );
 
         // commented out because it is possible that CP entity has not been created yet
         Assert.notNull( cpHeadEntity, "cpHeadEntity cannot be null" );
@@ -245,12 +252,14 @@ public class CpRelationManager implements RelationManager {
 
         String edgeTypePrefix = CpNamingUtils.getEdgeTypeFromCollectionName( collectionName );
 
-        logger.debug( "getCollectionIndexes(): Searching for edge type prefix {} to target {}:{}", new Object[] {
-                        edgeTypePrefix, cpHeadEntity.getId().getType(), cpHeadEntity.getId().getUuid()
-                } );
+        logger.debug( "getCollectionIndexes(): Searching for edge type prefix {} to target {}:{}",
+            new Object[] { edgeTypePrefix,
+                cpHeadEntity.getId().getType(),
+                cpHeadEntity.getId().getUuid() 
+            } ); 
 
-        Observable<String> types =
-                gm.getEdgeTypesFromSource( new SimpleSearchEdgeType( cpHeadEntity.getId(), edgeTypePrefix, null ) );
+        Observable<String> types = gm.getEdgeTypesFromSource( 
+            new SimpleSearchEdgeType( cpHeadEntity.getId(), edgeTypePrefix, null ) );
 
         Iterator<String> iter = types.toBlockingObservable().getIterator();
         while ( iter.hasNext() ) {
@@ -267,7 +276,8 @@ public class CpRelationManager implements RelationManager {
         //Map<EntityRef, Set<String>> containerEntities = getContainers(-1, "owns", null);
         Map<EntityRef, Set<String>> containerEntities = getContainers();
 
-        Map<String, Map<UUID, Set<String>>> owners = new LinkedHashMap<String, Map<UUID, Set<String>>>();
+        Map<String, Map<UUID, Set<String>>> owners = 
+                new LinkedHashMap<String, Map<UUID, Set<String>>>();
 
         for ( EntityRef owner : containerEntities.keySet() ) {
             Set<String> collections = containerEntities.get( owner );
@@ -298,35 +308,38 @@ public class CpRelationManager implements RelationManager {
 
         GraphManager gm = managerCache.getGraphManager( applicationScope );
 
-        Iterator<String> edgeTypes =
-                gm.getEdgeTypesToTarget( new SimpleSearchEdgeType( cpHeadEntity.getId(), edgeType, null ) ).toBlocking()
-                  .getIterator();
+        Iterator<String> edgeTypes = gm.getEdgeTypesToTarget( new SimpleSearchEdgeType( 
+                cpHeadEntity.getId(), edgeType, null ) ).toBlocking() .getIterator();
 
-        logger.debug(
-                "getContainers(): " + "Searched for edges of type {}\n   to target {}:{}\n   in scope {}\n   found: {}",
-                new Object[] {
-                        edgeType, cpHeadEntity.getId().getType(), cpHeadEntity.getId().getUuid(),
-                        applicationScope.getApplication(), edgeTypes.hasNext()
-                } );
+        logger.debug( "getContainers(): "
+                + "Searched for edges of type {}\n   to target {}:{}\n   in scope {}\n   found: {}",
+            new Object[] { edgeType,
+                cpHeadEntity.getId().getType(),
+                cpHeadEntity.getId().getUuid(),
+                applicationScope.getApplication(),
+                edgeTypes.hasNext() 
+            } );
 
         while ( edgeTypes.hasNext() ) {
 
             String etype = edgeTypes.next();
 
-            Observable<Edge> edges = gm.loadEdgesToTarget(
-                    new SimpleSearchByEdgeType( cpHeadEntity.getId(), etype, Long.MAX_VALUE,
-                            SearchByEdgeType.Order.DESCENDING, null ) );
+            Observable<Edge> edges = gm.loadEdgesToTarget( new SimpleSearchByEdgeType( 
+                cpHeadEntity.getId(), etype, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, null ) );
 
             Iterator<Edge> iter = edges.toBlockingObservable().getIterator();
             while ( iter.hasNext() ) {
                 Edge edge = iter.next();
 
-                if ( fromEntityType != null && !fromEntityType.equals( edge.getSourceNode().getType() ) ) {
-                    logger.debug( "Ignoring edge from entity type {}", edge.getSourceNode().getType() );
+                if (     fromEntityType != null 
+                     && !fromEntityType.equals( edge.getSourceNode().getType() ) ) {
+                    logger.debug( "Ignoring edge from entity type {}", 
+                            edge.getSourceNode().getType() );
                     continue;
                 }
 
-                EntityRef eref = new SimpleEntityRef( edge.getSourceNode().getType(), edge.getSourceNode().getUuid() );
+                EntityRef eref = new SimpleEntityRef( 
+                        edge.getSourceNode().getType(), edge.getSourceNode().getUuid() );
 
                 String name = null;
                 if ( CpNamingUtils.isConnectionEdgeType( edge.getType() ) ) {
@@ -353,11 +366,11 @@ public class CpRelationManager implements RelationManager {
 
         final GraphManager gm = managerCache.getGraphManager( applicationScope );
 
-        logger.debug( "updateContainingCollectionsAndCollections(): "
-                        + "Searched for edges to target {}:{}\n   in scope {}\n   found: {}", new Object[] {
-                        cpHeadEntity.getId().getType(), cpHeadEntity.getId().getUuid(),
-                        applicationScope.getApplication()
-                } );
+        logger.debug( "updateContainingCollectionsAndCollections(): " + "Searched for edges to target {}:{}\n   in scope {}\n   found: {}",
+            new Object[] { cpHeadEntity.getId().getType(),
+                cpHeadEntity.getId().getUuid(),
+                applicationScope.getApplication() 
+            } );
 
         // loop through all types of edge to target
 
@@ -367,25 +380,25 @@ public class CpRelationManager implements RelationManager {
         final EntityIndexBatch entityIndexBatch = ei.createBatch();
 
         final int count = gm.getEdgeTypesToTarget(
-                new SimpleSearchEdgeType( cpHeadEntity.getId(), null, null ) )
-                //for each edge type, emit all the edges of that type
-                            .flatMap( new Func1<String, Observable<Edge>>() {
-                                @Override
-                                public Observable<Edge> call( final String etype ) {
-                                    return gm.loadEdgesToTarget(
-                                            new SimpleSearchByEdgeType( cpHeadEntity.getId(), etype, Long.MAX_VALUE,
-                                                    SearchByEdgeType.Order.DESCENDING, null ) );
-                                }
-                            } )
-
-                            //for each edge we receive index and add to the batch
-                            .doOnNext( new Action1<Edge>() {
+            new SimpleSearchEdgeType( cpHeadEntity.getId(), null, null ) )
+
+                // for each edge type, emit all the edges of that type
+                .flatMap( new Func1<String, Observable<Edge>>() {
                     @Override
-                    public void call( final Edge edge ) {
+                    public Observable<Edge> call( final String etype ) {
+                        return gm.loadEdgesToTarget( new SimpleSearchByEdgeType( 
+                            cpHeadEntity.getId(), etype, Long.MAX_VALUE, 
+                            SearchByEdgeType.Order.DESCENDING, null ) );
+                    }
+                } )
 
+                //for each edge we receive index and add to the batch
+                .doOnNext( new Action1<Edge>() {
+                    @Override
+                    public void call( final Edge edge ) {
 
-                        EntityRef sourceEntity =
-                                new SimpleEntityRef( edge.getSourceNode().getType(), edge.getSourceNode().getUuid() );
+                        EntityRef sourceEntity = new SimpleEntityRef( 
+                                edge.getSourceNode().getType(), edge.getSourceNode().getUuid() );
 
                         // reindex the entity in the source entity's collection or connection index
 
@@ -393,29 +406,29 @@ public class CpRelationManager implements RelationManager {
                         if ( CpNamingUtils.isCollectionEdgeType( edge.getType() ) ) {
 
                             String collName = CpNamingUtils.getCollectionName( edge.getType() );
-                            indexScope =
-                                    new IndexScopeImpl( new SimpleId( sourceEntity.getUuid(), sourceEntity.getType() ),
-                                            CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ) );
+                            indexScope = new IndexScopeImpl( new SimpleId( sourceEntity.getUuid(),
+                                sourceEntity.getType() ),
+                                CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ));
                         }
                         else {
 
                             String connName = CpNamingUtils.getCollectionName( edge.getType() );
-                            indexScope =
-                                    new IndexScopeImpl( new SimpleId( sourceEntity.getUuid(), sourceEntity.getType() ),
-                                            CpNamingUtils.getConnectionScopeName( cpEntity.getId().getType(),
-                                                    connName ) );
+                            indexScope = new IndexScopeImpl( new SimpleId( sourceEntity.getUuid(),
+                                sourceEntity.getType() ),
+                                CpNamingUtils.getConnectionScopeName( cpEntity.getId().getType(),
+                                connName ) );
                         }
 
                         entityIndexBatch.index( indexScope, cpEntity );
 
                         // reindex the entity in the source entity's all-types index
 
-                        indexScope = new IndexScopeImpl( new SimpleId( sourceEntity.getUuid(), sourceEntity.getType() ),
-                                CpNamingUtils.ALL_TYPES );
+                        indexScope = new IndexScopeImpl( new SimpleId( 
+                            sourceEntity.getUuid(), sourceEntity.getType() ), CpNamingUtils.ALL_TYPES );
 
                         entityIndexBatch.index( indexScope, cpEntity );
                     }
-                } ).count().toBlocking().lastOrDefault( 0 );
+            } ).count().toBlocking().lastOrDefault( 0 );
 
 
         entityIndexBatch.execute();
@@ -431,14 +444,22 @@ public class CpRelationManager implements RelationManager {
 
         String edgeType = CpNamingUtils.getEdgeTypeFromConnectionType( connectionType );
 
-        logger.debug( "isConnectionMember(): Checking for edge type {} from {}:{} to {}:{}", new Object[] {
-                        edgeType, headEntity.getType(), headEntity.getUuid(), entity.getType(), entity.getUuid()
-                } );
+        logger.debug( "isConnectionMember(): Checking for edge type {} from {}:{} to {}:{}",
+            new Object[] { 
+                edgeType,
+                headEntity.getType(),
+                headEntity.getUuid(),
+                entity.getType(), entity.getUuid() 
+            } );
 
         GraphManager gm = managerCache.getGraphManager( applicationScope );
-        Observable<Edge> edges = gm.loadEdgeVersions(
-                new SimpleSearchByEdge( new SimpleId( headEntity.getUuid(), headEntity.getType() ), edgeType, entityId,
-                        Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, null ) );
+        Observable<Edge> edges = gm.loadEdgeVersions( new SimpleSearchByEdge( 
+            new SimpleId( headEntity.getUuid(), headEntity.getType() ), 
+            edgeType,
+            entityId,
+            Long.MAX_VALUE,
+            SearchByEdgeType.Order.DESCENDING, 
+            null ) );
 
         return edges.toBlockingObservable().firstOrDefault( null ) != null;
     }
@@ -453,14 +474,22 @@ public class CpRelationManager implements RelationManager {
 
         String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( collName );
 
-        logger.debug( "isCollectionMember(): Checking for edge type {} from {}:{} to {}:{}", new Object[] {
-                        edgeType, headEntity.getType(), headEntity.getUuid(), entity.getType(), entity.getUuid()
-                } );
+        logger.debug( "isCollectionMember(): Checking for edge type {} from {}:{} to {}:{}",
+            new Object[] { 
+                edgeType,
+                headEntity.getType(),
+                headEntity.getUuid(),
+                entity.getType(), entity.getUuid() 
+            } );
 
         GraphManager gm = managerCache.getGraphManager( applicationScope );
-        Observable<Edge> edges = gm.loadEdgeVersions(
-                new SimpleSearchByEdge( new SimpleId( headEntity.getUuid(), headEntity.getType() ), edgeType, entityId,
-                        Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, null ) );
+        Observable<Edge> edges = gm.loadEdgeVersions( new SimpleSearchByEdge( 
+            new SimpleId( headEntity.getUuid(), headEntity.getType() ), 
+            edgeType,
+            entityId,
+            Long.MAX_VALUE,
+            SearchByEdgeType.Order.DESCENDING,
+            null ) );
 
         return edges.toBlockingObservable().firstOrDefault( null ) != null;
     }
@@ -472,9 +501,12 @@ public class CpRelationManager implements RelationManager {
 
         GraphManager gm = managerCache.getGraphManager( applicationScope );
 
-        Observable<Edge> edgesToTarget = gm.loadEdgesToTarget(
-                new SimpleSearchByEdgeType( targetId, CpNamingUtils.getEdgeTypeFromConnectionType( connectionType ),
-                        System.currentTimeMillis(), SearchByEdgeType.Order.DESCENDING, null ) ); // last
+        Observable<Edge> edgesToTarget = gm.loadEdgesToTarget( new SimpleSearchByEdgeType( 
+            targetId,
+            CpNamingUtils.getEdgeTypeFromConnectionType( connectionType ),
+            System.currentTimeMillis(),
+            SearchByEdgeType.Order.DESCENDING, 
+            null ) ); // last
 
         Iterator<Edge> iterator = edgesToTarget.toBlockingObservable().getIterator();
         int count = 0;
@@ -494,9 +526,12 @@ public class CpRelationManager implements RelationManager {
 
         GraphManager gm = managerCache.getGraphManager( applicationScope );
 
-        Observable<Edge> edgesFromSource = gm.loadEdgesFromSource(
-                new SimpleSearchByEdgeType( sourceId, CpNamingUtils.getEdgeTypeFromConnectionType( connectionType ),
-                        System.currentTimeMillis(), SearchByEdgeType.Order.DESCENDING, null ) ); // last
+        Observable<Edge> edgesFromSource = gm.loadEdgesFromSource( new SimpleSearchByEdgeType( 
+            sourceId,
+            CpNamingUtils.getEdgeTypeFromConnectionType( connectionType ),
+            System.currentTimeMillis(),
+            SearchByEdgeType.Order.DESCENDING,
+            null ) ); // last
 
         int count = edgesFromSource.take( 2 ).count().toBlocking().last();
 
@@ -511,8 +546,8 @@ public class CpRelationManager implements RelationManager {
 
         GraphManager gm = managerCache.getGraphManager( applicationScope );
 
-        Observable<String> str =
-                gm.getEdgeTypesFromSource( new SimpleSearchEdgeType( cpHeadEntity.getId(), null, null ) );
+        Observable<String> str = gm.getEdgeTypesFromSource( 
+                new SimpleSearchEdgeType( cpHeadEntity.getId(), null, null ) );
 
         Iterator<String> iter = str.toBlockingObservable().getIterator();
         while ( iter.hasNext() ) {
@@ -525,8 +560,11 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    public Results getCollection( String collectionName, UUID startResult, int count, Level resultsLevel,
-                                  boolean reversed ) throws Exception {
+    public Results getCollection( String collectionName,
+            UUID startResult,
+            int count,
+            Level resultsLevel,
+            boolean reversed ) throws Exception {
 
         Query query = Query.fromQL( "select *" );
         query.setLimit( count );
@@ -551,12 +589,14 @@ public class CpRelationManager implements RelationManager {
     @Override
     public Entity addToCollection( String collName, EntityRef itemRef ) throws Exception {
 
-        CollectionInfo collection = getDefaultSchema().getCollection( headEntity.getType(), collName );
+        CollectionInfo collection = 
+                getDefaultSchema().getCollection( headEntity.getType(), collName );
         if ( ( collection != null ) && !collection.getType().equals( itemRef.getType() ) ) {
             return null;
         }
 
-        return addToCollection( collName, itemRef, ( collection != null && collection.getLinkedCollection() != null ) );
+        return addToCollection( collName, itemRef, 
+                ( collection != null && collection.getLinkedCollection() != null ) );
     }
 
 
@@ -581,15 +621,16 @@ public class CpRelationManager implements RelationManager {
         }
 
         // load the new member entity to be added to the collection from its default scope
-        CollectionScope memberScope =
-                new CollectionScopeImpl( applicationScope.getApplication(), applicationScope.getApplication(),
-                        CpNamingUtils.getCollectionScopeNameFromEntityType( itemRef.getType() ) );
+        CollectionScope memberScope = new CollectionScopeImpl( 
+                applicationScope.getApplication(),
+                applicationScope.getApplication(),
+                CpNamingUtils.getCollectionScopeNameFromEntityType( itemRef.getType() ) );
 
         EntityCollectionManager memberMgr = managerCache.getEntityCollectionManager( memberScope );
 
         //TODO, this double load should disappear once events are in
-        org.apache.usergrid.persistence.model.entity.Entity memberEntity =
-                memberMgr.load( new SimpleId( itemRef.getUuid(), itemRef.getType() ) ).toBlocking().last();
+        org.apache.usergrid.persistence.model.entity.Entity memberEntity = memberMgr.load( 
+                new SimpleId( itemRef.getUuid(), itemRef.getType() ) ).toBlocking().last();
 
         if ( memberEntity == null ) {
             throw new RuntimeException(
@@ -597,18 +638,23 @@ public class CpRelationManager implements RelationManager {
         }
 
         if ( logger.isDebugEnabled() ) {
-            logger.debug( "Loaded member entity {}:{} from scope\n   app {}\n   " + "owner {}\n   name {} data {}",
-                    new Object[] {
-                            itemRef.getType(), itemRef.getUuid(), memberScope.getApplication(), memberScope.getOwner(),
-                            memberScope.getName(), CpEntityMapUtils.toMap( memberEntity )
-                    } );
+            logger.debug( "Loaded member entity {}:{} from scope\n   app {}\n   " 
+                + "owner {}\n   name {} data {}",
+                new Object[] {
+                    itemRef.getType(),
+                    itemRef.getUuid(),
+                    memberScope.getApplication(),
+                    memberScope.getOwner(),
+                    memberScope.getName(),
+                    CpEntityMapUtils.toMap( memberEntity )
+                } );
         }
 
         String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( collName );
 
-        UUID timeStampUuid =
-                memberEntity.getId().getUuid() != null && UUIDUtils.isTimeBased( memberEntity.getId().getUuid() ) ?
-                memberEntity.getId().getUuid() : UUIDUtils.newTimeUUID();
+        UUID timeStampUuid = memberEntity.getId().getUuid() != null 
+                && UUIDUtils.isTimeBased( memberEntity.getId().getUuid() ) 
+                ?  memberEntity.getId().getUuid() : UUIDUtils.newTimeUUID();
 
         long uuidHash = UUIDUtils.getUUIDLong( timeStampUuid );
 
@@ -617,10 +663,15 @@ public class CpRelationManager implements RelationManager {
         GraphManager gm = managerCache.getGraphManager( applicationScope );
         gm.writeEdge( edge ).toBlockingObservable().last();
 
-        logger.debug( "Wrote edgeType {}\n   from {}:{}\n   to {}:{}\n   scope {}:{}", new Object[] {
-                edgeType, cpHeadEntity.getId().getType(), cpHeadEntity.getId().getUuid(),
-                memberEntity.getId().getType(), memberEntity.getId().getUuid(),
-                applicationScope.getApplication().getType(), applicationScope.getApplication().getUuid()
+        logger.debug( "Wrote edgeType {}\n   from {}:{}\n   to {}:{}\n   scope {}:{}", 
+            new Object[] { 
+                edgeType,
+                cpHeadEntity.getId().getType(),
+                cpHeadEntity.getId().getUuid(),
+                memberEntity.getId().getType(),
+                memberEntity.getId().getUuid(),
+                applicationScope.getApplication().getType(),
+                applicationScope.getApplication().getUuid()
         } );
 
         ( ( CpEntityManager ) em ).indexEntityIntoCollection( cpHeadEntity, memberEntity, collName );
@@ -635,7 +686,8 @@ public class CpRelationManager implements RelationManager {
         //            headEntityScope.getName()});
 
         if ( connectBack && collection != null && collection.getLinkedCollection() != null ) {
-            getRelationManager( itemEntity ).addToCollection( collection.getLinkedCollection(), headEntity, false );
+            getRelationManager( itemEntity ).addToCollection( 
+                    collection.getLinkedCollection(), headEntity, false );
         }
 
         return itemEntity;
@@ -656,7 +708,8 @@ public class CpRelationManager implements RelationManager {
 
     @Override
     @Metered( group = "core", name = "RelationManager_createItemInCollection" )
-    public Entity createItemInCollection( String collName, String itemType, Map<String, Object> properties )
+    public Entity createItemInCollection( 
+            String collName, String itemType, Map<String, Object> properties )
             throws Exception {
 
         if ( headEntity.getUuid().equals( applicationId ) ) {
@@ -675,7 +728,9 @@ public class CpRelationManager implements RelationManager {
             return em.create( itemType, properties );
         }
 
-        else if ( headEntity.getType().equals( Group.ENTITY_TYPE ) && ( collName.equals( COLLECTION_ROLES ) ) ) {
+        else if ( headEntity.getType().equals( Group.ENTITY_TYPE ) 
+                && ( collName.equals( COLLECTION_ROLES ) ) ) {
+
             UUID groupId = headEntity.getUuid();
             String roleName = ( String ) properties.get( PROPERTY_NAME );
             return em.createGroupRole( groupId, roleName, ( Long ) properties.get( PROPERTY_INACTIVITY ) );
@@ -695,7 +750,8 @@ public class CpRelationManager implements RelationManager {
             addToCollection( collName, itemEntity );
 
             if ( collection != null && collection.getLinkedCollection() != null ) {
-                getRelationManager( getHeadEntity() ).addToCollection( collection.getLinkedCollection(), itemEntity );
+                getRelationManager( getHeadEntity() )
+                        .addToCollection( collection.getLinkedCollection(), itemEntity );
             }
         }
 
@@ -723,21 +779,26 @@ public class CpRelationManager implements RelationManager {
         }
 
         // load the entity to be removed to the collection
-        CollectionScope memberScope =
-                new CollectionScopeImpl( this.applicationScope.getApplication(), this.applicationScope.getApplication(),
-                        CpNamingUtils.getCollectionScopeNameFromEntityType( itemRef.getType() ) );
+        CollectionScope memberScope = new CollectionScopeImpl( 
+                this.applicationScope.getApplication(),
+                this.applicationScope.getApplication(),
+                CpNamingUtils.getCollectionScopeNameFromEntityType( itemRef.getType() ) );
         EntityCollectionManager memberMgr = managerCache.getEntityCollectionManager( memberScope );
 
         if ( logger.isDebugEnabled() ) {
-            logger.debug( "Loading entity to remove from collection "
-                            + "{}:{} from scope\n   app {}\n   owner {}\n   name {}", new Object[] {
-                            itemRef.getType(), itemRef.getUuid(), memberScope.getApplication(), memberScope.getOwner(),
-                            memberScope.getName()
-                    } );
+            logger.debug( "Loading entity to remove from collection " 
+                + "{}:{} from scope\n   app {}\n   owner {}\n   name {}", 
+                new Object[] {
+                    itemRef.getType(),
+                    itemRef.getUuid(),
+                    memberScope.getApplication(),
+                    memberScope.getOwner(),
+                    memberScope.getName()
+               });
         }
 
-        org.apache.usergrid.persistence.model.entity.Entity memberEntity =
-                memberMgr.load( new SimpleId( itemRef.getUuid(), itemRef.getType() ) ).toBlockingObservable().last();
+        org.apache.usergrid.persistence.model.entity.Entity memberEntity = memberMgr.load( 
+            new SimpleId( itemRef.getUuid(), itemRef.getType() ) ).toBlockingObservable().last();
 
         final EntityIndex ei = managerCache.getEntityIndex( applicationScope );
         final EntityIndexBatch batch = ei.createBatch();
@@ -760,15 +821,20 @@ public class CpRelationManager implements RelationManager {
 
         // remove edge from collection to item 
         GraphManager gm = managerCache.getGraphManager( applicationScope );
-        Edge collectionToItemEdge =
-                new SimpleEdge( cpHeadEntity.getId(), CpNamingUtils.getEdgeTypeFromCollectionName( collName ),
-                        memberEntity.getId(), UUIDUtils.getUUIDLong( memberEntity.getId().getUuid() ) );
+        Edge collectionToItemEdge = new SimpleEdge( 
+                cpHeadEntity.getId(), 
+                CpNamingUtils.getEdgeTypeFromCollectionName( collName ), 
+                memberEntity.getId(), UUIDUtils.getUUIDLong( memberEntity.getId().getUuid() ) );
         gm.deleteEdge( collectionToItemEdge ).toBlockingObservable().last();
 
         // remove edge from item to collection
-        Edge itemToCollectionEdge = new SimpleEdge( memberEntity.getId(), CpNamingUtils
-                .getEdgeTypeFromCollectionName( Schema.defaultCollectionName( cpHeadEntity.getId().getType() ) ),
-                cpHeadEntity.getId(), UUIDUtils.getUUIDLong( cpHeadEntity.getId().getUuid() ) );
+        Edge itemToCollectionEdge = new SimpleEdge( 
+                memberEntity.getId(), 
+                CpNamingUtils.getEdgeTypeFromCollectionName( 
+                    Schema.defaultCollectionName( cpHeadEntity.getId().getType() ) ), 
+                cpHeadEntity.getId(), 
+                UUIDUtils.getUUIDLong( cpHeadEntity.getId().getUuid() ) );
+
         gm.deleteEdge( itemToCollectionEdge ).toBlockingObservable().last();
 
         // special handling for roles collection of a group
@@ -797,9 +863,11 @@ public class CpRelationManager implements RelationManager {
         headEntity = em.validate( headEntity );
         dstEntityRef = em.validate( dstEntityRef );
 
-        CollectionInfo srcCollection = getDefaultSchema().getCollection( headEntity.getType(), srcRelationName );
+        CollectionInfo srcCollection = 
+                getDefaultSchema().getCollection( headEntity.getType(), srcRelationName );
 
-        CollectionInfo dstCollection = getDefaultSchema().getCollection( dstEntityRef.getType(), dstRelationName );
+        CollectionInfo dstCollection = 
+                getDefaultSchema().getCollection( dstEntityRef.getType(), dstRelationName );
 
         Results results = null;
         do {
@@ -838,9 +906,8 @@ public class CpRelationManager implements RelationManager {
         CollectionInfo collection = getDefaultSchema().getCollection( headEntity.getType(), collName );
 
         if ( collection == null ) {
-            throw new RuntimeException(
-                    "Cannot find collection-info for '" + collName + "' of " + headEntity.getType() + ":" + headEntity
-                            .getUuid() );
+            throw new RuntimeException( "Cannot find collection-info for '" + collName 
+                    + "' of " + headEntity.getType() + ":" + headEntity .getUuid() );
         }
 
         IndexScope indexScope = new IndexScopeImpl( cpHeadEntity.getId(),
@@ -922,29 +989,39 @@ public class CpRelationManager implements RelationManager {
 
         ConnectionRefImpl connection = new ConnectionRefImpl( headEntity, connectionType, connectedEntityRef );
 
-        CollectionScope targetScope =
-                new CollectionScopeImpl( applicationScope.getApplication(), applicationScope.getApplication(),
-                        CpNamingUtils.getCollectionScopeNameFromEntityType( connectedEntityRef.getType() ) );
+        CollectionScope targetScope = new CollectionScopeImpl( 
+            applicationScope.getApplication(), 
+            applicationScope.getApplication(),
+            CpNamingUtils.getCollectionScopeNameFromEntityType( connectedEntityRef.getType() ) );
 
         EntityCollectionManager targetEcm = managerCache.getEntityCollectionManager( targetScope );
 
         if ( logger.isDebugEnabled() ) {
-            logger.debug( "createConnection(): " + "Indexing connection type '{}'\n   from source {}:{}]\n"
-                            + "   to target {}:{}\n   from scope\n   app {}\n   owner {}\n   name {}", new Object[] {
-                            connectionType, headEntity.getType(), headEntity.getUuid(), connectedEntityRef.getType(),
-                            connectedEntityRef.getUuid(), targetScope.getApplication(), targetScope.getOwner(),
-                            targetScope.getName()
-                    } );
+            logger.debug( "createConnection(): " 
+                + "Indexing connection type '{}'\n   from source {}:{}]\n"
+                + "   to target {}:{}\n   from scope\n   app {}\n   owner {}\n   name {}", 
+                new Object[] {
+                    connectionType,
+                    headEntity.getType(),
+                    headEntity.getUuid(),
+                    connectedEntityRef.getType(),
+                    connectedEntityRef.getUuid(),
+                    targetScope.getApplication(), 
+                    targetScope.getOwner(), 
+                    targetScope.getName()
+                } );
         }
 
-        org.apache.usergrid.persistence.model.entity.Entity targetEntity =
-                targetEcm.load( new SimpleId( connectedEntityRef.getUuid(), connectedEntityRef.getType() ) )
-                         .toBlockingObservable().last();
+        org.apache.usergrid.persistence.model.entity.Entity targetEntity = targetEcm.load( 
+            new SimpleId( connectedEntityRef.getUuid(), connectedEntityRef.getType() ) )
+                .toBlockingObservable().last();
 
         String edgeType = CpNamingUtils.getEdgeTypeFromConnectionType( connectionType );
 
         // create graph edge connection from head entity to member entity
-        Edge edge = new SimpleEdge( cpHeadEntity.getId(), edgeType, targetEntity.getId(), System.currentTimeMillis() );
+        Edge edge = new SimpleEdge( 
+                cpHeadEntity.getId(), edgeType, targetEntity.getId(), System.currentTimeMillis() );
+
         GraphManager gm = managerCache.getGraphManager( applicationScope );
         gm.writeEdge( edge ).toBlockingObservable().last();
 
@@ -975,14 +1052,16 @@ public class CpRelationManager implements RelationManager {
 
     @SuppressWarnings( "unchecked" )
     @Metered( group = "core", name = "CpRelationManager_batchUpdateEntityConnection" )
-    public Mutator<ByteBuffer> batchUpdateEntityConnection( Mutator<ByteBuffer> batch, boolean disconnect,
-                                                            ConnectionRefImpl connection, UUID timestampUuid )
-            throws Exception {
+    public Mutator<ByteBuffer> batchUpdateEntityConnection( 
+            Mutator<ByteBuffer> batch, 
+            boolean disconnect, 
+            ConnectionRefImpl conn, 
+            UUID timestampUuid ) throws Exception {
 
         long timestamp = getTimestampInMicros( timestampUuid );
 
-        Entity connectedEntity =
-                em.get( new SimpleEntityRef( connection.getConnectedEntityType(), connection.getConnectedEntityId() ) );
+        Entity connectedEntity = em.get(new SimpleEntityRef( 
+                conn.getConnectedEntityType(), conn.getConnectedEntityId() ) );
 
         if ( connectedEntity == null ) {
             return batch;
@@ -992,59 +1071,59 @@ public class CpRelationManager implements RelationManager {
 
         if ( disconnect ) {
 
-            addDeleteToMutator( batch, ENTITY_COMPOSITE_DICTIONARIES,
-                    key( connection.getConnectingEntityId(), DICTIONARY_CONNECTED_ENTITIES,
-                            connection.getConnectionType() ),
-                    asList( connection.getConnectedEntityId(), connection.getConnectedEntityType() ), timestamp );
+            addDeleteToMutator(batch, ENTITY_COMPOSITE_DICTIONARIES,
+                key(conn.getConnectingEntityId(), DICTIONARY_CONNECTED_ENTITIES,
+                        conn.getConnectionType() ),
+                asList(conn.getConnectedEntityId(), conn.getConnectedEntityType() ), timestamp );
 
-            addDeleteToMutator( batch, ENTITY_COMPOSITE_DICTIONARIES,
-                    key( connection.getConnectedEntityId(), DICTIONARY_CONNECTING_ENTITIES,
-                            connection.getConnectionType() ),
-                    asList( connection.getConnectingEntityId(), connection.getConnectingEntityType() ), timestamp );
+            addDeleteToMutator(batch, ENTITY_COMPOSITE_DICTIONARIES,
+                key(conn.getConnectedEntityId(), DICTIONARY_CONNECTING_ENTITIES,
+                        conn.getConnectionType() ),
+                asList(conn.getConnectingEntityId(), conn.getConnectingEntityType() ), timestamp );
 
             // delete the connection path if there will be no connections left
 
             // check out outbound edges of the given type.  If we have more than the 1 specified,
             // we shouldn't delete the connection types from our outbound index
-            if ( !moreThanOneOutboundConnection( connection.getConnectingEntity(), connection.getConnectionType() ) ) {
+            if ( !moreThanOneOutboundConnection(conn.getConnectingEntity(), conn.getConnectionType() ) ) {
 
-                addDeleteToMutator( batch, ENTITY_DICTIONARIES,
-                        key( connection.getConnectingEntityId(), DICTIONARY_CONNECTED_TYPES ),
-                        connection.getConnectionType(), timestamp );
+                addDeleteToMutator(batch, ENTITY_DICTIONARIES,
+                        key(conn.getConnectingEntityId(), DICTIONARY_CONNECTED_TYPES ),
+                        conn.getConnectionType(), timestamp );
             }
 
             //check out inbound edges of the given type.  If we have more than the 1 specified,
             // we shouldn't delete the connection types from our outbound index
-            if ( !moreThanOneInboundConnection( connection.getConnectingEntity(), connection.getConnectionType() ) ) {
+            if ( !moreThanOneInboundConnection(conn.getConnectingEntity(), conn.getConnectionType() ) ) {
 
-                addDeleteToMutator( batch, ENTITY_DICTIONARIES,
-                        key( connection.getConnectedEntityId(), DICTIONARY_CONNECTING_TYPES ),
-                        connection.getConnectionType(), timestamp );
-            }
+                addDeleteToMutator(batch, ENTITY_DICTIONARIES,
+                    key(conn.getConnectedEntityId(), DICTIONARY_CONNECTING_TYPES ),
+                    conn.getConnectionType(), timestamp );
+        }
         }
         else {
 
-            addInsertToMutator( batch, ENTITY_COMPOSITE_DICTIONARIES,
-                    key( connection.getConnectingEntityId(), DICTIONARY_CONNECTED_ENTITIES,
-                            connection.getConnectionType() ),
-                    asList( connection.getConnectedEntityId(), connection.getConnectedEntityType() ), timestamp,
+            addInsertToMutator(batch, ENTITY_COMPOSITE_DICTIONARIES,
+                    key(conn.getConnectingEntityId(), DICTIONARY_CONNECTED_ENTITIES,
+                            conn.getConnectionType() ),
+                    asList(conn.getConnectedEntityId(), conn.getConnectedEntityType() ), timestamp,
                     timestamp );
 
-            addInsertToMutator( batch, ENTITY_COMPOSITE_DICTIONARIES,
-                    key( connection.getConnectedEntityId(), DICTIONARY_CONNECTING_ENTITIES,
-                            connection.getConnectionType() ),
-                    asList( connection.getConnectingEntityId(), connection.getConnectingEntityType() ), timestamp,
+            addInsertToMutator(batch, ENTITY_COMPOSITE_DICTIONARIES,
+                    key(conn.getConnectedEntityId(), DICTIONARY_CONNECTING_ENTITIES,
+                            conn.getConnectionType() ),
+                    asList(conn.getConnectingEntityId(), conn.getConnectingEntityType() ), timestamp,
                     timestamp );
 
             // Add connection type to connections set
-            addInsertToMutator( batch, ENTITY_DICTIONARIES,
-                    key( connection.getConnectingEntityId(), DICTIONARY_CONNECTED_TYPES ),
-                    connection.getConnectionType(), null, timestamp );
+            addInsertToMutator(batch, ENTITY_DICTIONARIES,
+                    key(conn.getConnectingEntityId(), DICTIONARY_CONNECTED_TYPES ),
+                    conn.getConnectionType(), null, timestamp );
 
             // Add connection type to connections set
-            addInsertToMutator( batch, ENTITY_DICTIONARIES,
-                    key( connection.getConnectedEntityId(), DICTIONARY_CONNECTING_TYPES ),
-                    connection.getConnectionType(), null, timestamp );
+            addInsertToMutator(batch, ENTITY_DICTIONARIES,
+                    key(conn.getConnectedEntityId(), DICTIONARY_CONNECTING_TYPES ),
+                    conn.getConnectionType(), null, timestamp );
         }
 
         // Add indexes for the connected entity's list properties
@@ -1058,17 +1137,20 @@ public class CpRelationManager implements RelationManager {
         Schema schema = getDefaultSchema();
 
         for ( String dictionaryName : dictionaryNames ) {
-            boolean has_dictionary = schema.hasDictionary( connectedEntity.getType(), dictionaryName );
-            boolean dictionary_indexed =
-                    schema.isDictionaryIndexedInConnections( connectedEntity.getType(), dictionaryName );
+
+            boolean has_dictionary = schema.hasDictionary( 
+                    connectedEntity.getType(), dictionaryName );
+
+            boolean dictionary_indexed = schema.isDictionaryIndexedInConnections( 
+                    connectedEntity.getType(), dictionaryName );
 
             if ( dictionary_indexed || !has_dictionary ) {
                 Set<Object> elementValues = em.getDictionaryAsSet( connectedEntity, dictionaryName );
                 for ( Object elementValue : elementValues ) {
-                    IndexUpdate indexUpdate =
-                            batchStartIndexUpdate( batch, connectedEntity, dictionaryName, elementValue, timestampUuid,
-                                    has_dictionary, true, disconnect, false );
-                    batchUpdateConnectionIndex( indexUpdate, connection );
+                    IndexUpdate indexUpdate = batchStartIndexUpdate( 
+                            batch, connectedEntity, dictionaryName, elementValue, 
+                            timestampUuid, has_dictionary, true, disconnect, false );
+                    batchUpdateConnectionIndex(indexUpdate, conn );
                 }
             }
         }
@@ -1079,8 +1161,11 @@ public class CpRelationManager implements RelationManager {
 
     @Override
     @Metered( group = "core", name = "RelationManager_createConnection_paired_connection_type" )
-    public ConnectionRef createConnection( String pairedConnectionType, EntityRef pairedEntity, String connectionType,
-                                           EntityRef connectedEntityRef ) throws Exception {
+    public ConnectionRef createConnection( 
+            String pairedConnectionType,
+            EntityRef pairedEntity,
+            String connectionType,
+            EntityRef connectedEntityRef ) throws Exception {
 
         throw new UnsupportedOperationException( "Paired connections not supported" );
     }
@@ -1095,7 +1180,8 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    public ConnectionRef connectionRef( String connectionType, EntityRef connectedEntityRef ) throws Exception {
+    public ConnectionRef connectionRef( 
+            String connectionType, EntityRef connectedEntityRef ) throws Exception {
 
         ConnectionRef connection = new ConnectionRefImpl( headEntity, connectionType, connectedEntityRef );
 
@@ -1104,8 +1190,11 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    public ConnectionRef connectionRef( String pairedConnectionType, EntityRef pairedEntity, String connectionType,
-                                        EntityRef connectedEntityRef ) throws Exception {
+    public ConnectionRef connectionRef( 
+            String pairedConnectionType,
+            EntityRef pairedEntity,
+            String connectionType,
+            EntityRef connectedEntityRef ) throws Exception {
 
         throw new UnsupportedOperationException( "Paired connections not supported" );
     }
@@ -1124,7 +1213,8 @@ public class CpRelationManager implements RelationManager {
         // First, clean up the dictionary records of the connection
         Keyspace ko = cass.getApplicationKeyspace( applicationId );
         Mutator<ByteBuffer> m = createMutator( ko, be );
-        batchUpdateEntityConnection( m, true, ( ConnectionRefImpl ) connectionRef, UUIDGenerator.newTimeUUID() );
+        batchUpdateEntityConnection( 
+                m, true, ( ConnectionRefImpl ) connectionRef, UUIDGenerator.newTimeUUID() );
         batchExecute( m, CassandraService.RETRY_COUNT );
 
         EntityRef connectingEntityRef = connectionRef.getConnectingEntity();  // source
@@ -1132,26 +1222,36 @@ public class CpRelationManager implements RelationManager {
 
         String connectionType = connectionRef.getConnectedEntity().getConnectionType();
 
-        CollectionScope targetScope =
-                new CollectionScopeImpl( applicationScope.getApplication(), applicationScope.getApplication(),
-                        CpNamingUtils.getCollectionScopeNameFromEntityType( connectedEntityRef.getType() ) );
+        CollectionScope targetScope = new CollectionScopeImpl( 
+                applicationScope.getApplication(),
+                applicationScope.getApplication(),
+                CpNamingUtils.getCollectionScopeNameFromEntityType( connectedEntityRef.getType()) );
 
         EntityCollectionManager targetEcm = managerCache.getEntityCollectionManager( targetScope );
 
         if ( logger.isDebugEnabled() ) {
-            logger.debug( "Deleting connection '{}' from source {}:{} \n   to target {}:{}", new Object[] {
-                            connectionType, connectingEntityRef.getType(), connectingEntityRef.getUuid(),
-                            connectedEntityRef.getType(), connectedEntityRef.getUuid()
+            logger.debug( "Deleting connection '{}' from source {}:{} \n   to target {}:{}", 
+                new Object[] {
+                    connectionType,
+                    connectingEntityRef.getType(),
+                    connectingEntityRef.getUuid(),
+                    connectedEntityRef.getType(),
+                    connectedEntityRef.getUuid()
                     } );
         }
 
-        org.apache.usergrid.persistence.model.entity.Entity targetEntity =
-                targetEcm.load( new SimpleId( connectedEntityRef.getUuid(), connectedEntityRef.getType() ) )
-                         .toBlockingObservable().last();
+        org.apache.usergrid.persistence.model.entity.Entity targetEntity = targetEcm.load( 
+            new SimpleId( connectedEntityRef.getUuid(), connectedEntityRef.getType() ) ) 
+                .toBlockingObservable().last();
 
         // Delete graph edge connection from head entity to member entity
-        Edge edge = new SimpleEdge( new SimpleId( connectingEntityRef.getUuid(), connectingEntityRef.getType() ),
-                connectionType, targetEntity.getId(), System.currentTimeMillis() );
+        Edge edge = new SimpleEdge( 
+            new SimpleId( connectingEntityRef.getUuid(),
+                connectingEntityRef.getType() ),
+                connectionType,
+                targetEntity.getId(),
+                System.currentTimeMillis() );
+
         GraphManager gm = managerCache.getGraphManager( applicationScope );
         gm.deleteEdge( edge ).toBlockingObservable().last();
 
@@ -1159,15 +1259,18 @@ public class CpRelationManager implements RelationManager {
         final EntityIndexBatch batch = ei.createBatch();
 
         // Deindex the connection in app|source|type context
-        IndexScope indexScope =
-                new IndexScopeImpl( new SimpleId( connectingEntityRef.getUuid(), connectingEntityRef.getType() ),
-                        CpNamingUtils.getConnectionScopeName( targetEntity.getId().getType(), connectionType ) );
+        IndexScope indexScope = new IndexScopeImpl( 
+            new SimpleId( connectingEntityRef.getUuid(),
+                connectingEntityRef.getType() ),
+                CpNamingUtils.getConnectionScopeName( targetEntity.getId().getType(),
+                connectionType ) );
         batch.deindex( indexScope, targetEntity );
 
         // Deindex the connection in app|source|type context
-        IndexScope allTypesIndexScope =
-                new IndexScopeImpl( new SimpleId( connectingEntityRef.getUuid(), connectingEntityRef.getType() ),
-                        CpNamingUtils.ALL_TYPES );
+        IndexScope allTypesIndexScope = new IndexScopeImpl( 
+            new SimpleId( connectingEntityRef.getUuid(),
+                connectingEntityRef.getType() ),
+                CpNamingUtils.ALL_TYPES );
 
         batch.deindex( allTypesIndexScope, targetEntity );
 
@@ -1189,7 +1292,8 @@ public class CpRelationManager implements RelationManager {
 
     @Override
     public Set<String> getConnectionTypes( boolean filterConnection ) throws Exception {
-        Set<String> connections = cast( em.getDictionaryAsSet( headEntity, Schema.DICTIONARY_CONNECTED_TYPES ) );
+        Set<String> connections = cast( 
+                em.getDictionaryAsSet( headEntity, Schema.DICTIONARY_CONNECTED_TYPES ) );
 
         if ( connections == null ) {
             return null;
@@ -1202,8 +1306,8 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    public Results getConnectedEntities( String connectionType, String connectedEntityType, Level level )
-            throws Exception {
+    public Results getConnectedEntities( 
+            String connectionType, String connectedEntityType, Level level ) throws Exception {
 
         Results raw = null;
 
@@ -1231,8 +1335,8 @@ public class CpRelationManager implements RelationManager {
             final EntityIndex ei = managerCache.getEntityIndex( applicationScope );
 
 
-            logger.debug( "Searching connected entities from scope {}:{}", indexScope.getOwner().toString(),
-                    indexScope.getName() );
+            logger.debug( "Searching connected entities from scope {}:{}", 
+                    indexScope.getOwner().toString(), indexScope.getName() );
 
             query = adjustQuery( query );
             CandidateResults crs = ei.search( indexScope, query );
@@ -1260,16 +1364,16 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    public Results getConnectingEntities( String connType, String fromEntityType, Level resultsLevel )
-            throws Exception {
+    public Results getConnectingEntities( 
+            String connType, String fromEntityType, Level resultsLevel ) throws Exception {
 
         return getConnectingEntities( connType, fromEntityType, resultsLevel, -1 );
     }
 
 
     @Override
-    public Results getConnectingEntities( String connType, String fromEntityType, Level level, int count )
-            throws Exception {
+    public Results getConnectingEntities( 
+            String connType, String fromEntityType, Level level, int count ) throws Exception {
 
         // looking for edges to the head entity
         String edgeType = CpNamingUtils.getEdgeTypeFromConnectionType( connType );
@@ -1312,12 +1416,14 @@ public class CpRelationManager implements RelationManager {
         if ( query.getEntityType() == null ) {
 
             // search across all types of collections of the head-entity
-            IndexScope indexScope = new IndexScopeImpl( cpHeadEntity.getId(), CpNamingUtils.ALL_TYPES );
+            IndexScope indexScope = new IndexScopeImpl( 
+                cpHeadEntity.getId(), 
+                CpNamingUtils.ALL_TYPES );
 
             EntityIndex ei = managerCache.getEntityIndex( applicationScope );
 
-            logger.debug( "Searching connections from the all-types scope {}:{}", indexScope.getOwner().toString(),
-                    indexScope.getName() );
+            logger.debug( "Searching connections from the all-types scope {}:{}", 
+                    indexScope.getOwner().toString(), indexScope.getName() );
 
             query = adjustQuery( query );
             CandidateResults crs = ei.search( indexScope, query );
@@ -1325,12 +1431,14 @@ public class CpRelationManager implements RelationManager {
             return buildConnectionResults( query, crs, query.getConnectionType() );
         }
 
-        IndexScope indexScope = new IndexScopeImpl( cpHeadEntity.getId(),
-                CpNamingUtils.getConnectionScopeName( query.getEntityType(), query.getConnectionType() ) );
+        IndexScope indexScope = new IndexScopeImpl( 
+            cpHeadEntity.getId(), 
+            CpNamingUtils.getConnectionScopeName( query.getEntityType(), 
+            query.getConnectionType() ) );
         EntityIndex ei = managerCache.getEntityIndex( applicationScope );
-
-        logger.debug( "Searching connections from the scope {}:{}", indexScope.getOwner().toString(),
-                indexScope.getName() );
+        
+        logger.debug( "Searching connections from the scope {}:{}", 
+                indexScope.getOwner().toString(), indexScope.getName() );
 
         query = adjustQuery( query );
         CandidateResults crs = ei.search( indexScope, query );
@@ -1353,29 +1461,31 @@ public class CpRelationManager implements RelationManager {
                 // This is fulgy to put here, but required.
                 if ( query.getEntityType().equals( User.ENTITY_TYPE ) && ident.isEmail() ) {
 
-                    Query newQuery =
-                            Query.fromQL( "select * where email='" + query.getSingleNameOrEmailIdentifier() + "'" );
+                    Query newQuery = Query.fromQL( "select * where email='" 
+                            + query.getSingleNameOrEmailIdentifier() + "'" );
                     query.setRootOperand( newQuery.getRootOperand() );
                 }
 
                 // use the ident with the default alias. could be an email
                 else {
 
-                    Query newQuery =
-                            Query.fromQL( "select * where name='" + query.getSingleNameOrEmailIdentifier() + "'" );
+                    Query newQuery = Query.fromQL( "select * where name='" 
+                            + query.getSingleNameOrEmailIdentifier() + "'" );
                     query.setRootOperand( newQuery.getRootOperand() );
                 }
             }
             else if ( query.containsSingleUuidIdentifier() ) {
 
-                Query newQuery = Query.fromQL( "select * where uuid='" + query.getSingleUuidIdentifier() + "'" );
+                Query newQuery = Query.fromQL( 
+                        "select * where uuid='" + query.getSingleUuidIdentifier() + "'" );
                 query.setRootOperand( newQuery.getRootOperand() );
             }
         }
 
         if ( query.isReversed() ) {
 
-            Query.SortPredicate desc = new Query.SortPredicate( PROPERTY_CREATED, Query.SortDirection.DESCENDING );
+            Query.SortPredicate desc = 
+                new Query.SortPredicate( PROPERTY_CREATED, Query.SortDirection.DESCENDING );
 
             try {
                 query.addSort( desc );
@@ -1387,8 +1497,8 @@ public class CpRelationManager implements RelationManager {
 
         if ( query.getSortPredicates().isEmpty() ) {
 
-            //TODO, should this be descending?
-            Query.SortPredicate asc = new Query.SortPredicate( PROPERTY_CREATED, Query.SortDirection.ASCENDING );
+            Query.SortPredicate asc = 
+                new Query.SortPredicate( PROPERTY_CREATED, Query.SortDirection.DESCENDING);
 
             query.addSort( asc );
         }
@@ -1424,7 +1534,8 @@ public class CpRelationManager implements RelationManager {
     }
 
 
-    private Results buildConnectionResults( Query query, CandidateResults crs, String connectionType ) {
+    private Results buildConnectionResults( 
+            Query query, CandidateResults crs, String connectionType ) {
 
         if ( query.getLevel().equals( Level.ALL_PROPERTIES ) ) {
             return buildResults( query, crs, connectionType );
@@ -1436,9 +1547,11 @@ public class CpRelationManager implements RelationManager {
 
         for ( CandidateResult cr : crs ) {
 
-            SimpleEntityRef targetRef = new SimpleEntityRef( cr.getId().getType(), cr.getId().getUuid() );
+            SimpleEntityRef targetRef = 
+                    new SimpleEntityRef( cr.getId().getType(), cr.getId().getUuid() );
 
-            final ConnectionRef ref = new ConnectionRefImpl( sourceRef, connectionType, targetRef );
+            final ConnectionRef ref = 
+                    new ConnectionRefImpl( sourceRef, connectionType, targetRef );
 
             refs.add( ref );
         }
@@ -1459,8 +1572,8 @@ public class CpRelationManager implements RelationManager {
         logger.debug( "buildResults() for {} from {} candidates", collName, crs.size() );
 
         //get an instance of our results loader
-        final ResultsLoader resultsLoader =
-                this.resultsLoaderFactory.getLoader( applicationScope, this.headEntity, query.getResultsLevel() );
+        final ResultsLoader resultsLoader = this.resultsLoaderFactory.getLoader( 
+                applicationScope, this.headEntity, query.getResultsLevel() );
 
         //load the results
         final Results results = resultsLoader.loadResults( crs );
@@ -1484,11 +1597,11 @@ public class CpRelationManager implements RelationManager {
 
         Entity entity = getHeadEntity();
 
-        elementValue = getDefaultSchema().validateEntitySetValue( entity.getType(), setName, elementValue );
+        elementValue = getDefaultSchema()
+                .validateEntitySetValue( entity.getType(), setName, elementValue );
 
-        IndexUpdate indexUpdate =
-                batchStartIndexUpdate( batch, entity, setName, elementValue, timestampUuid, true, true, removeFromSet,
-                        false );
+        IndexUpdate indexUpdate = batchStartIndexUpdate( batch, entity, setName, elementValue, 
+                timestampUuid, true, true, removeFromSet, false );
 
         // Update collections 
 
@@ -1498,8 +1611,8 @@ public class CpRelationManager implements RelationManager {
         if ( containers != null ) {
             Map<EntityRef, Set<String>> containerEntities = getContainers();
             for ( EntityRef containerEntity : containerEntities.keySet() ) {
-                if ( containerEntity.getType().equals( TYPE_APPLICATION ) && Schema
-                        .isAssociatedEntityType( entity.getType() ) ) {
+                if ( containerEntity.getType().equals( TYPE_APPLICATION ) 
+                        && Schema.isAssociatedEntityType( entity.getType() ) ) {
                     logger.debug( "Extended properties for {} not indexed by application", entity.getType() );
                     continue;
                 }
@@ -1525,25 +1638,28 @@ public class CpRelationManager implements RelationManager {
      * Batch update collection index.
      *
      * @param indexUpdate The update to apply
-     * @param owner The entity that is the owner context of this entity update. Can either be an application, or another
-     * entity
+     * @param owner The entity that is the owner context of this entity update. Can either be an 
+     * application, or another * entity
      * @param collectionName the collection name
-     *
+     * 
      * @return The indexUpdate with batch mutations
-     *
      * @throws Exception the exception
      */
     @Metered( group = "core", name = "RelationManager_batchUpdateCollectionIndex" )
-    public IndexUpdate batchUpdateCollectionIndex( IndexUpdate indexUpdate, EntityRef owner, String collectionName )
+    public IndexUpdate batchUpdateCollectionIndex( 
+            IndexUpdate indexUpdate, EntityRef owner, String collectionName )
             throws Exception {
 
         logger.debug( "batchUpdateCollectionIndex" );
 
         Entity indexedEntity = indexUpdate.getEntity();
 
-        String bucketId = indexBucketLocator
-                .getBucket( applicationId, IndexBucketLocator.IndexType.COLLECTION, indexedEntity.getUuid(),
-                        indexedEntity.getType(), indexUpdate.getEntryName() );
+        String bucketId = indexBucketLocator.getBucket( 
+                applicationId, 
+                IndexBucketLocator.IndexType.COLLECTION, 
+                indexedEntity.getUuid(),
+                indexedEntity.getType(), 
+                indexUpdate.getEntryName() );
 
         // the root name without the bucket
         // entity_id,collection_name,prop_name,
@@ -1561,14 +1677,14 @@ public class CpRelationManager implements RelationManager {
 
                 index_key = key( index_name, bucketId );
 
-                addDeleteToMutator( indexUpdate.getBatch(), ENTITY_INDEX, index_key, entry.getIndexComposite(),
-                        indexUpdate.getTimestamp() );
+                addDeleteToMutator( indexUpdate.getBatch(), ENTITY_INDEX, index_key, 
+                        entry.getIndexComposite(), indexUpdate.getTimestamp() );
 
                 if ( "location.coordinates".equals( entry.getPath() ) ) {
-                    EntityLocationRef loc = new EntityLocationRef( indexUpdate.getEntity(), entry.getTimestampUuid(),
-                            entry.getValue().toString() );
-                    batchRemoveLocationFromCollectionIndex( indexUpdate.getBatch(), indexBucketLocator, applicationId,
-                            index_name, loc );
+                    EntityLocationRef loc = new EntityLocationRef( indexUpdate.getEntity(), 
+                            entry.getTimestampUuid(), entry.getValue().toString() );
+                    batchRemoveLocationFromCollectionIndex( indexUpdate.getBatch(), 
+                            indexBucketLocator, applicationId, index_name, loc );
                 }
             }
             else {
@@ -1576,8 +1692,9 @@ public class CpRelationManager implements RelationManager {
             }
         }
 
-        if ( ( indexUpdate.getNewEntries().size() > 0 ) && ( !indexUpdate.isMultiValue() || ( indexUpdate.isMultiValue()
-                && !indexUpdate.isRemoveListEntry() ) ) ) {
+        if ( ( indexUpdate.getNewEntries().size() > 0 ) 
+                && ( !indexUpdate.isMultiValue() 
+                || ( indexUpdate.isMultiValue() && !indexUpdate.isRemoveListEntry() ) ) ) {
 
             for ( IndexUpdate.IndexEntry indexEntry : indexUpdate.getNewEntries() ) {
 
@@ -1589,15 +1706,21 @@ public class CpRelationManager implements RelationManager {
 
                 // int i = 0;
 
-                addInsertToMutator( indexUpdate.getBatch(), ENTITY_INDEX, index_key, indexEntry.getIndexComposite(),
-                        null, indexUpdate.getTimestamp() );
+                addInsertToMutator( indexUpdate.getBatch(), ENTITY_INDEX, index_key, 
+                        indexEntry.getIndexComposite(), null, indexUpdate.getTimestamp() );
 
                 if ( "location.coordinates".equals( indexEntry.getPath() ) ) {
-                    EntityLocationRef loc =
-                            new EntityLocationRef( indexUpdate.getEntity(), indexEntry.getTimestampUuid(),
-                                    indexEntry.getValue().toString() );
-                    batchStoreLocationInCollectionIndex( indexUpdate.getBatch(), indexBucketLocator, applicationId,
-                            index_name, indexedEntity.getUuid(), loc );
+                    EntityLocationRef loc = new EntityLocationRef( 
+                            indexUpdate.getEntity(), 
+                            indexEntry.getTimestampUuid(), 
+                            indexEntry.getValue().toString() );
+                    batchStoreLocationInCollectionIndex( 
+                            indexUpdate.getBatch(),
+                            indexBucketLocator,
+                            applicationId,
+                            index_name,
+                            indexedEntity.getUuid(),
+                            loc );
                 }
 
                 // i++;
@@ -1614,26 +1737,56 @@ public class CpRelationManager implements RelationManager {
     }
 
 
-    public IndexUpdate batchStartIndexUpdate( Mutator<ByteBuffer> batch, Entity entity, String entryName,
-                                              Object entryValue, UUID timestampUuid, boolean schemaHasProperty,
-                                              boolean isMultiValue, boolean removeListEntry, boolean fulltextIndexed )
+    public IndexUpdate batchStartIndexUpdate( 
+            Mutator<ByteBuffer> batch,
+            Entity entity,
+            String entryName,
+            Object entryValue,
+            UUID timestampUuid,
+            boolean schemaHasProperty,
+            boolean isMultiValue,
+            boolean removeListEntry,
+            boolean fulltextIndexed )
             throws Exception {
-        return batchStartIndexUpdate( batch, entity, entryName, entryValue, timestampUuid, schemaHasProperty,
-                isMultiValue, removeListEntry, fulltextIndexed, false );
+
+        return batchStartIndexUpdate( 
+                batch,
+                entity,
+                entryName,
+                entryValue,
+                timestampUuid,
+                schemaHasProperty,
+                isMultiValue,
+                removeListEntry,
+                fulltextIndexed,
+                false );
     }
 
 
     @Metered( group = "core", name = "RelationManager_batchStartIndexUpdate" )
-    public IndexUpdate batchStartIndexUpdate( Mutator<ByteBuffer> batch, Entity entity, String entryName,
-                                              Object entryValue, UUID timestampUuid, boolean schemaHasProperty,
-                                              boolean isMultiValue, boolean removeListEntry, boolean fulltextIndexed,
-                                              boolean skipRead ) throws Exception {
+    public IndexUpdate batchStartIndexUpdate( 
+            Mutator<ByteBuffer> batch,
+            Entity entity,
+            String entryName,
+            Object entryValue,
+            UUID timestampUuid,
+            boolean schemaHasProperty,
+            boolean isMultiValue,
+            boolean removeListEntry,
+            boolean fulltextIndexed,
+            boolean skipRead ) throws Exception {
 
         long timestamp = getTimestampInMicros( timestampUuid );
 
-        IndexUpdate indexUpdate =
-                new IndexUpdate( batch, entity, entryName, entryValue, schemaHasProperty, isMultiValue, removeListEntry,
-                        timestampUuid );
+        IndexUpdate indexUpdate = new IndexUpdate( 
+                batch,
+                entity,
+                entryName,
+                entryValue,
+                schemaHasProperty,
+                isMultiValue,
+                removeListEntry,
+                timestampUuid );
 
         // entryName = entryName.toLowerCase();
 
@@ -1644,17 +1797,30 @@ public class CpRelationManager implements RelationManager {
             List<HColumn<ByteBuffer, ByteBuffer>> entries = null;
 
             if ( isMultiValue && validIndexableValue( entryValue ) ) {
-                entries = cass.getColumns( cass.getApplicationKeyspace( applicationId ), ENTITY_INDEX_ENTRIES,
+                entries = cass.getColumns( 
+                    cass.getApplicationKeyspace( applicationId ), 
+                        ENTITY_INDEX_ENTRIES,
                         entity.getUuid(),
-                        new DynamicComposite( entryName, indexValueCode( entryValue ), toIndexableValue( entryValue ) ),
-                        setGreaterThanEqualityFlag( new DynamicComposite( entryName, indexValueCode( entryValue ),
-                                        toIndexableValue( entryValue ) ) ), INDEX_ENTRY_LIST_COUNT, false );
+                        new DynamicComposite( 
+                            entryName, 
+                            indexValueCode( entryValue ), 
+                            toIndexableValue( entryValue ) ),
+                        setGreaterThanEqualityFlag( 
+                            new DynamicComposite( 
+                                entryName, indexValueCode( entryValue ),
+                                toIndexableValue( entryValue ) ) ), 
+                        INDEX_ENTRY_LIST_COUNT, 
+                        false );
             }
             else {
-                entries = cass.getColumns( cass.getApplicationKeyspace( applicationId ), ENTITY_INDEX_ENTRIES,
-                        entity.getUuid(), new DynamicComposite( entryName ),
-                        setGreaterThanEqualityFlag( new DynamicComposite( entryName ) ), INDEX_ENTRY_LIST_COUNT,
-                        false );
+                entries = cass.getColumns( 
+                    cass.getApplicationKeyspace( applicationId ), 
+                    ENTITY_INDEX_ENTRIES, 
+                    entity.getUuid(), 
+                    new DynamicComposite( entryName ), 
+                    setGreaterThanEqualityFlag( new DynamicComposite( entryName ) ), 
+                    INDEX_ENTRY_LIST_COUNT, 
+                    false );
             }
 
             if ( logger.isDebugEnabled() ) {
@@ -1672,7 +1838,8 @@ public class CpRelationManager implements RelationManager {
                 // new format:
                 // composite(entryName,
                 // value_code,prev_value,prev_timestamp,prev_obj_path) = null
-                DynamicComposite composite = DynamicComposite.fromByteBuffer( entry.getName().duplicate() );
+                DynamicComposite composite = 
+                        DynamicComposite.fromByteBuffer( entry.getName().duplicate() );
                 prev_value = composite.get( 2 );
                 prev_timestamp = ( UUID ) composite.get( 3 );
                 if ( composite.size() > 4 ) {
@@ -1686,7 +1853,8 @@ public class CpRelationManager implements RelationManager {
                         entryPath = entryName + "." + prev_obj_path;
                     }
 
-                    indexUpdate.addPrevEntry( entryPath, prev_value, prev_timestamp, entry.getName().duplicate() );
+                    indexUpdate.addPrevEntry( 
+                            entryPath, prev_value, prev_timestamp, entry.getName().duplicate() );
 
                     // composite(property_value,connected_entity_id,entry_timestamp)
                     // addDeleteToMutator(batch, ENTITY_INDEX_ENTRIES,
@@ -1701,7 +1869,8 @@ public class CpRelationManager implements RelationManager {
 
         if ( !isMultiValue || ( isMultiValue && !removeListEntry ) ) {
 
-            List<Map.Entry<String, Object>> list = IndexUtils.getKeyValueList( entryName, entryValue, fulltextIndexed );
+            List<Map.Entry<String, Object>> list = 
+                    IndexUtils.getKeyValueList( entryName, entryValue, fulltextIndexed );
 
             if ( entryName.equalsIgnoreCase( "location" ) && ( entryValue instanceof Map ) ) {
                 @SuppressWarnings( "rawtypes" ) double latitude =
@@ -1715,14 +1884,15 @@ public class CpRelationManager implements RelationManager {
             for ( Map.Entry<String, Object> indexEntry : list ) {
 
                 if ( validIndexableValue( indexEntry.getValue() ) ) {
-                    indexUpdate.addNewEntry( indexEntry.getKey(), toIndexableValue( indexEntry.getValue() ) );
+                    indexUpdate.addNewEntry( 
+                            indexEntry.getKey(), toIndexableValue( indexEntry.getValue() ) );
                 }
             }
 
             if ( isMultiValue ) {
                 addInsertToMutator( batch, ENTITY_INDEX_ENTRIES, entity.getUuid(),
-                        asList( entryName, indexValueCode( entryValue ), toIndexableValue( entryValue ),
-                                indexUpdate.getTimestampUuid() ), null, timestamp );
+                    asList( entryName, indexValueCode( entryValue ), 
+                    toIndexableValue( entryValue ), indexUpdate.getTimestampUuid() ), null, timestamp );
             }
             else {
                 // int i = 0;
@@ -1740,7 +1910,8 @@ public class CpRelationManager implements RelationManager {
                     byte code = indexValueCode( indexEntry.getValue() );
                     Object val = toIndexableValue( indexEntry.getValue() );
                     addInsertToMutator( batch, ENTITY_INDEX_ENTRIES, entity.getUuid(),
-                            asList( entryName, code, val, indexUpdate.getTimestampUuid(), name ), null, timestamp );
+                            asList( entryName, code, val, indexUpdate.getTimestampUuid(), name ), 
+                            null, timestamp );
 
                     indexUpdate.addIndex( indexEntry.getKey() );
                 }
@@ -1844,10 +2015,17 @@ public class CpRelationManager implements RelationManager {
                 batchDeleteConnectionIndexEntries( indexUpdate, entry, connection, index_keys );
 
                 if ( "location.coordinates".equals( entry.getPath() ) ) {
-                    EntityLocationRef loc = new EntityLocationRef( indexUpdate.getEntity(), entry.getTimestampUuid(),
-                            entry.getValue().toString() );
-                    batchDeleteLocationInConnectionsIndex( indexUpdate.getBatch(), indexBucketLocator, applicationId,
-                            index_keys, entry.getPath(), loc );
+                    EntityLocationRef loc = new EntityLocationRef( 
+                        indexUpdate.getEntity(),
+                        entry.getTimestampUuid(),
+                        entry.getValue().toString() );
+                    batchDeleteLocationInConnectionsIndex( 
+                        indexUpdate.getBatch(),
+                        indexBucketLocator,
+                        applicationId,
+                        index_keys,
+                        entry.getPath(),
+                        loc );
                 }
             }
             else {
@@ -1855,19 +2033,25 @@ public class CpRelationManager implements RelationManager {
             }
         }
 
-        if ( ( indexUpdate.getNewEntries().size() > 0 ) && ( !indexUpdate.isMultiValue() || ( indexUpdate.isMultiValue()
-                && !indexUpdate.isRemoveListEntry() ) ) ) {
+        if ( ( indexUpdate.getNewEntries().size() > 0 ) 
+                && ( !indexUpdate.isMultiValue() || ( indexUpdate.isMultiValue() && !indexUpdate.isRemoveListEntry() ) ) ) {
 
             for ( IndexUpdate.IndexEntry indexEntry : indexUpdate.getNewEntries() ) {
 
                 batchAddConnectionIndexEntries( indexUpdate, indexEntry, connection, index_keys );
 
                 if ( "location.coordinates".equals( indexEntry.getPath() ) ) {
-                    EntityLocationRef loc =
-                            new EntityLocationRef( indexUpdate.getEntity(), indexEntry.getTimestampUuid(),
-                                    indexEntry.getValue().toString() );
-                    batchStoreLocationInConnectionsIndex( indexUpdate.getBatch(), indexBucketLocator, applicationId,
-                            index_keys, indexEntry.getPath(), loc );
+                    EntityLocationRef loc = new EntityLocationRef( 
+                        indexUpdate.getEntity(),
+                        indexEntry.getTimestampUuid(),
+                        indexEntry.getValue().toString() );
+                    batchStoreLocationInConnectionsIndex( 
+                        indexUpdate.getBatch(),
+                            indexBucketLocator,
+                            applicationId,
+                            index_keys,
+                            indexEntry.getPath(),
+                            loc );
                 }
             }
 
@@ -1897,10 +2081,11 @@ public class CpRelationManager implements RelationManager {
      *
      * @return connectionType The name of the edges to search
      */
-    private PagingResultsIterator getReversedConnectionsIterator( EntityRef targetEntity, String connectionType )
-            throws Exception {
+    private PagingResultsIterator getReversedConnectionsIterator( 
+            EntityRef targetEntity, String connectionType ) throws Exception {
 
-        return new PagingResultsIterator( getConnectingEntities( targetEntity, connectionType, null, Level.REFS ) );
+        return new PagingResultsIterator( 
+                getConnectingEntities( targetEntity, connectionType, null, Level.REFS ) );
     }
 
 
@@ -1912,8 +2097,11 @@ public class CpRelationManager implements RelationManager {
      * @param connectedEntityType The connected entity type, if not specified all types are returned
      * @param resultsLevel The results level to return
      */
-    private Results getConnectingEntities( EntityRef targetEntity, String connectionType, String connectedEntityType,
-                                           Level resultsLevel ) throws Exception {
+    private Results getConnectingEntities( 
+        EntityRef targetEntity,
+            String connectionType,
+            String connectedEntityType,
+            Level resultsLevel ) throws Exception {
 
         return getConnectingEntities( targetEntity, connectionType, connectedEntityType, resultsLevel, 0 );
     }
@@ -1927,16 +2115,21 @@ public class CpRelationManager implements RelationManager {
      * @param connectedEntityType The connected entity type, if not specified all types are returned
      * @param count result limit
      */
-    private Results getConnectingEntities( EntityRef targetEntity, String connectionType, String connectedEntityType,
-                                           Level level, int count ) throws Exception {
+    private Results getConnectingEntities( 
+            EntityRef targetEntity,
+            String connectionType,
+            String connectedEntityType,
+            Level level,
+            int count ) throws Exception {
 
         Query query = new Query();
         query.setResultsLevel( level );
         query.setLimit( count );
 
-        final ConnectionRefImpl connectionRef =
-                new ConnectionRefImpl( new SimpleEntityRef( connectedEntityType, null ), connectionType, targetEntity );
-        final ConnectionResultsLoaderFactory factory = new ConnectionResultsLoaderFactory( connectionRef );
+        final ConnectionRefImpl connectionRef = new ConnectionRefImpl( 
+                new SimpleEntityRef( connectedEntityType, null ), connectionType, targetEntity );
+        final ConnectionResultsLoaderFactory factory = 
+                new ConnectionResultsLoaderFactory( connectionRef );
 
         QueryProcessorImpl qp = new QueryProcessorImpl( query, null, em, factory );
         SearchConnectionVisitor visitor = new SearchConnectionVisitor( qp, connectionRef, false );
@@ -1946,9 +2139,11 @@ public class CpRelationManager implements RelationManager {
 
 
     @Metered( group = "core", name = "RelationManager_batchDeleteConnectionIndexEntries" )
-    public Mutator<ByteBuffer> batchDeleteConnectionIndexEntries( IndexUpdate indexUpdate, IndexUpdate.IndexEntry entry,
-                                                                  ConnectionRefImpl connection, UUID[] index_keys )
-            throws Exception {
+    public Mutator<ByteBuffer> batchDeleteConnectionIndexEntries( 
+            IndexUpdate indexUpdate,
+            IndexUpdate.IndexEntry entry,
+            ConnectionRefImpl connection,
+            UUID[] index_keys ) throws Exception {
 
         logger.debug( "batchDeleteConnectionIndexEntries" );
 
@@ -2059,15 +2254,16 @@ public class CpRelationManager implements RelationManager {
 
         private final ConnectionRefImpl connection;
 
-        /** True if we should search from source->target edges.  False if we should search from target<-source edges */
+        /** True if we should search from source->target edges.  
+         * False if we should search from target<-source edges */
         private final boolean outgoing;
 
 
         /**
          * @param queryProcessor They query processor to use
          * @param connection The connection refernce
-         * @param outgoing The direction to search.  True if we should search from source->target edges.  False if we
-         * should search from target<-source edges
+         * @param outgoing The direction to search.  True if we should search from source->target 
+         * edges.  False if we * should search from target<-source edges
          */
         public SearchConnectionVisitor( QueryProcessorImpl queryProcessor, ConnectionRefImpl connection,
                                         boolean outgoing ) {
@@ -2085,8 +2281,12 @@ public class CpRelationManager implements RelationManager {
         @Override
         protected IndexScanner secondaryIndexScan( QueryNode node, QuerySlice slice ) throws Exception {
 
-            UUID id = ConnectionRefImpl.getIndexId( ConnectionRefImpl.BY_CONNECTION_AND_ENTITY_TYPE, headEntity,
-                    connection.getConnectionType(), connection.getConnectedEntityType(), new ConnectedEntityRef[0] );
+            UUID id = ConnectionRefImpl.getIndexId( 
+                    ConnectionRefImpl.BY_CONNECTION_AND_ENTITY_TYPE,
+                    headEntity,
+                    connection.getConnectionType(),
+                    connection.getConnectedEntityType(),
+                    new ConnectedEntityRef[0] );
 
             Object key = key( id, INDEX_CONNECTIONS );
 
@@ -2120,10 +2320,13 @@ public class CpRelationManager implements RelationManager {
 
             queryProcessor.applyCursorAndSort( slice );
 
-            GeoIterator itr =
-                    new GeoIterator( new ConnectionGeoSearch( em, indexBucketLocator, cass, connection.getIndexId() ),
-                            query.getLimit(), slice, node.getPropertyName(),
-                            new Point( node.getLattitude(), node.getLongitude() ), node.getDistance() );
+            GeoIterator itr = new GeoIterator( 
+                new ConnectionGeoSearch( em, indexBucketLocator, cass, connection.getIndexId() ), 
+                query.getLimit(),
+                slice,
+                node.getPropertyName(),
+                new Point( node.getLattitude(), node.getLongitude() ),
+                node.getDistance() );
 
             results.push( itr );
         }
@@ -2181,12 +2384,20 @@ public class CpRelationManager implements RelationManager {
 
             //we need to iterate all connection types
             else {
-                connectionTypes = new ConnectionTypesIterator( cass, applicationId, entityIdToUse, outgoing, size );
+                connectionTypes = new ConnectionTypesIterator( 
+                        cass, applicationId, entityIdToUse, outgoing, size );
             }
 
-            IndexScanner connectionScanner =
-                    new ConnectedIndexScanner( cass, dictionaryType, applicationId, entityIdToUse, connectionTypes,
-                            start, slice.isReversed(), size, skipFirst );
+            IndexScanner connectionScanner = new ConnectedIndexScanner( 
+                    cass,
+                    dictionaryType,
+                    applicationId,
+                    entityIdToUse,
+                    connectionTypes,
+                    start,
+                    slice.isReversed(),
+                    size,
+                    skipFirst );
 
             this.results.push( new SliceIterator( slice, connectionScanner, connectionParser ) );
         }
@@ -2214,9 +2425,19 @@ public class CpRelationManager implements RelationManager {
 
         Object keyPrefix = key( indexKey, slice.getPropertyName() );
 
-        IndexScanner scanner = new IndexBucketScanner( cass, indexBucketLocator, ENTITY_INDEX, applicationId,
-                IndexBucketLocator.IndexType.CONNECTION, keyPrefix, range[0], range[1], slice.isReversed(), pageSize,
-                slice.hasCursor(), slice.getPropertyName() );
+        IndexScanner scanner = new IndexBucketScanner( 
+                cass,
+                indexBucketLocator,
+                ENTITY_INDEX,
+                applicationId,
+                IndexBucketLocator.IndexType.CONNECTION,
+                keyPrefix,
+                range[0],
+                range[1],
+                slice.isReversed(),
+                pageSize,
+                slice.hasCursor(),
+                slice.getPropertyName() );
 
         return scanner;
     }


[34/45] git commit: comments on interface

Posted by to...@apache.org.
comments on interface


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

Branch: refs/heads/key-row-sharding
Commit: c51c0ce4e55cbf503c0fe2194d3da4697ab190f2
Parents: 8f4720d
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Oct 29 11:08:31 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Oct 29 11:08:31 2014 -0600

----------------------------------------------------------------------
 .../notifications/ApplicationQueueManager.java  | 21 +++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c51c0ce4/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
index 8012b42..101c839 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
@@ -28,7 +28,7 @@ import rx.Observable;
 import java.util.List;
 
 /**
- * Classy class class.
+ * Manages Queues for Applications
  */
 public interface ApplicationQueueManager {
 
@@ -38,11 +38,30 @@ public interface ApplicationQueueManager {
 
     public static final  String DEFAULT_QUEUE_NAME = "push_v1";
 
+    /**
+     * send notification to queue
+     * @param notification
+     * @param jobExecution
+     * @throws Exception
+     */
     void queueNotification(Notification notification, JobExecution jobExecution) throws Exception;
 
+    /**
+     * send notifications to providers
+     * @param messages
+     * @param queuePath
+     * @return
+     */
     Observable sendBatchToProviders(List<QueueMessage> messages, String queuePath);
 
+    /**
+     * stop processing and send message to providers to stop
+     */
     void stop();
 
+    /**
+     * check for inactive devices, apple and google require this
+     * @throws Exception
+     */
     void asyncCheckForInactiveDevices() throws Exception;
 }


[32/45] git commit: adding docs

Posted by to...@apache.org.
adding docs


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

Branch: refs/heads/key-row-sharding
Commit: 955a92bc4d29a652f5398e980ac2322095f44577
Parents: 78e34b2
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Oct 29 10:44:39 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Oct 29 10:44:39 2014 -0600

----------------------------------------------------------------------
 .../services/notifications/ProviderAdapter.java | 30 ++++++++++++++++++++
 .../notifications/apns/APNsAdapter.java         | 25 ++++++++--------
 2 files changed, 43 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/955a92bc/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapter.java
index 8acd006..1783882 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ProviderAdapter.java
@@ -34,8 +34,20 @@ import org.apache.usergrid.services.ServicePayload;
  */
 public interface ProviderAdapter {
 
+    /**
+     * test the connection
+     * @throws ConnectionException
+     */
     public void testConnection() throws ConnectionException;
 
+    /**
+     * send a notification
+     * @param providerId
+     * @param payload
+     * @param notification
+     * @param tracker
+     * @throws Exception
+     */
     public void sendNotification(String providerId,  Object payload, Notification notification, TaskTracker tracker)
             throws Exception;
 
@@ -45,12 +57,30 @@ public interface ProviderAdapter {
      */
     public void doneSendingNotifications() throws Exception;
 
+    /**
+     * remove inactive devices
+     * @throws Exception
+     */
     public void removeInactiveDevices() throws Exception;
 
+    /**
+     * translate payload for each notifier
+     * @param payload
+     * @return
+     * @throws Exception
+     */
     public Object translatePayload(Object payload) throws Exception;
 
+    /**
+     * Validate payload from services
+     * @param payload
+     * @throws Exception
+     */
     public void validateCreateNotifier(ServicePayload payload) throws Exception;
 
+    /**
+     * stop the adapter when you are done, so it can quit processing notifications
+     */
     public void stop();
 
     public Notifier getNotifier();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/955a92bc/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
index da5d3e5..79a3b9e 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
@@ -187,22 +187,23 @@ public class APNsAdapter implements ProviderAdapter {
     }
 
     @Override
-    public void stop(){
-            try {
-                if (!pushManager.isShutDown()) {
-                    List<SimpleApnsPushNotification> notifications = pushManager.shutdown(3000);
-                    for (SimpleApnsPushNotification notification1 : notifications) {
-                        try {
-                            ((APNsNotification) notification1).messageSendFailed(new Exception("Cache Expired: Shutting down sender"));
-                        }catch (Exception e){
-                            logger.error("Failed to mark notification",e);
-                        }
+    public void stop() {
+        try {
+            if (!pushManager.isShutDown()) {
+                List<SimpleApnsPushNotification> notifications = pushManager.shutdown(3000);
+                for (SimpleApnsPushNotification notification1 : notifications) {
+                    try {
+                        ((APNsNotification) notification1).messageSendFailed(new Exception("Cache Expired: Shutting down sender"));
+                    } catch (Exception e) {
+                        logger.error("Failed to mark notification", e);
                     }
                 }
-            } catch (Exception ie) {
-                logger.error("Failed to shutdown from cache", ie);
             }
+        } catch (Exception ie) {
+            logger.error("Failed to shutdown from cache", ie);
+        }
     }
+
     @Override
     public Notifier getNotifier(){return notifier;}
 


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

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


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

Branch: refs/heads/key-row-sharding
Commit: 97ee70fe8b38366eb0790877154c961cf2773a9d
Parents: 707c9b9 77b8c59
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Oct 29 15:22:01 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Oct 29 15:22:01 2014 -0400

----------------------------------------------------------------------
 .../notifications/apns/APNsAdapter.java         | 37 ++++++++++----------
 .../notifications/apns/EntityPushManager.java   |  5 +--
 2 files changed, 22 insertions(+), 20 deletions(-)
----------------------------------------------------------------------



[17/45] git commit: Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into pushy_4-0

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


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

Branch: refs/heads/key-row-sharding
Commit: 45d3ce454fa3897ab4ddffa45967da4927c1f7b2
Parents: bbed017 960ce6b
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Oct 27 17:39:51 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Oct 27 17:39:51 2014 -0600

----------------------------------------------------------------------
 stack/loadtests/README.md                       |  52 -----
 stack/loadtests/gatling/LICENSE                 | 202 -------------------
 stack/loadtests/gatling/conf/application.conf   |  21 --
 stack/loadtests/gatling/conf/gatling.conf       | 162 ---------------
 stack/loadtests/gatling/conf/logback.xml        |  35 ----
 stack/loadtests/gatling/conf/recorder.conf      |  51 -----
 .../gatling/lib/Saxon-HE-9.5.1-6-compressed.jar | Bin 3813075 -> 0 bytes
 .../gatling/lib/akka-actor_2.10-2.3.6.jar       | Bin 2583959 -> 0 bytes
 .../lib/async-http-client-1.9.0-BETA13.jar      | Bin 579954 -> 0 bytes
 stack/loadtests/gatling/lib/boon-0.26.jar       | Bin 1026950 -> 0 bytes
 .../loadtests/gatling/lib/commons-pool-1.6.jar  | Bin 111119 -> 0 bytes
 .../lib/compiler-interface-0.13.5-sources.jar   | Bin 30056 -> 0 bytes
 .../lib/concurrentlinkedhashmap-lru-1.4.jar     | Bin 116575 -> 0 bytes
 stack/loadtests/gatling/lib/config-1.2.1.jar    | Bin 219554 -> 0 bytes
 .../gatling/lib/fastring_2.10-0.2.4.jar         | Bin 98640 -> 0 bytes
 .../gatling/lib/gatling-app-2.0.0-RC5.jar       | Bin 73052 -> 0 bytes
 .../gatling/lib/gatling-charts-2.0.0-RC5.jar    | Bin 500609 -> 0 bytes
 .../lib/gatling-charts-highcharts-2.0.0-RC5.jar | Bin 214683 -> 0 bytes
 .../gatling/lib/gatling-core-2.0.0-RC5.jar      | Bin 1678475 -> 0 bytes
 .../gatling/lib/gatling-http-2.0.0-RC5.jar      | Bin 1222752 -> 0 bytes
 .../gatling/lib/gatling-jdbc-2.0.0-RC5.jar      | Bin 41648 -> 0 bytes
 .../gatling/lib/gatling-jms-2.0.0-RC5.jar       | Bin 174279 -> 0 bytes
 .../gatling/lib/gatling-metrics-2.0.0-RC5.jar   | Bin 72446 -> 0 bytes
 .../gatling/lib/gatling-recorder-2.0.0-RC5.jar  | Bin 815471 -> 0 bytes
 .../gatling/lib/gatling-redis-2.0.0-RC5.jar     | Bin 19970 -> 0 bytes
 .../gatling/lib/geronimo-jms_1.1_spec-1.1.1.jar | Bin 32359 -> 0 bytes
 .../gatling/lib/incremental-compiler-0.13.5.jar | Bin 2214694 -> 0 bytes
 .../gatling/lib/jackson-annotations-2.4.0.jar   | Bin 38605 -> 0 bytes
 .../gatling/lib/jackson-core-2.4.2.jar          | Bin 225316 -> 0 bytes
 .../gatling/lib/jackson-databind-2.4.2.jar      | Bin 1075759 -> 0 bytes
 stack/loadtests/gatling/lib/jodd-core-3.6.jar   | Bin 373882 -> 0 bytes
 .../loadtests/gatling/lib/jodd-lagarto-3.6.jar  | Bin 204738 -> 0 bytes
 stack/loadtests/gatling/lib/jodd-log-3.6.jar    | Bin 14547 -> 0 bytes
 .../gatling/lib/jsonpath_2.10-0.5.0.jar         | Bin 180090 -> 0 bytes
 stack/loadtests/gatling/lib/jzlib-1.1.3.jar     | Bin 71976 -> 0 bytes
 .../gatling/lib/logback-classic-1.1.2.jar       | Bin 270750 -> 0 bytes
 .../gatling/lib/logback-core-1.1.2.jar          | Bin 427729 -> 0 bytes
 .../loadtests/gatling/lib/netty-3.9.4.Final.jar | Bin 1310154 -> 0 bytes
 stack/loadtests/gatling/lib/opencsv-2.3.jar     | Bin 19827 -> 0 bytes
 .../gatling/lib/redisclient_2.10-2.13.jar       | Bin 712616 -> 0 bytes
 .../gatling/lib/sbt-interface-0.13.5.jar        | Bin 52012 -> 0 bytes
 stack/loadtests/gatling/lib/scala-compiler.jar  | Bin 14445780 -> 0 bytes
 stack/loadtests/gatling/lib/scala-library.jar   | Bin 7126372 -> 0 bytes
 stack/loadtests/gatling/lib/scala-reflect.jar   | Bin 3203471 -> 0 bytes
 .../gatling/lib/scala-swing-2.10.4.jar          | Bin 707298 -> 0 bytes
 .../lib/scalalogging-slf4j_2.10-1.1.0.jar       | Bin 79003 -> 0 bytes
 .../loadtests/gatling/lib/scopt_2.10-3.2.0.jar  | Bin 122918 -> 0 bytes
 stack/loadtests/gatling/lib/slf4j-api-1.7.7.jar | Bin 29257 -> 0 bytes
 stack/loadtests/gatling/lib/t-digest-3.0.jar    | Bin 49754 -> 0 bytes
 stack/loadtests/gatling/lib/threetenbp-1.0.jar  | Bin 507797 -> 0 bytes
 .../gatling/lib/uncommons-maths-1.2.3.jar       | Bin 49923 -> 0 bytes
 stack/loadtests/gatling/lib/zinc-0.3.5.3.jar    | Bin 392810 -> 0 bytes
 stack/loadtests/gatling/scripts/gatling-ug.sh   |  49 -----
 .../gatling/user-files/data/search.csv          |   3 -
 .../gatling/user-files/request-bodies/.keep     |   0
 stack/loadtests/loadtest_setup.sh               |  45 -----
 stack/loadtests/pom.xml                         | 156 ++++++++++++++
 .../data-generators/EntityDataGenerator.scala   |  57 ------
 .../data-generators/FeederGenerator.scala       | 101 ----------
 .../scenarios/ApplicationScenarios.scala        |  45 -----
 .../scenarios/ConnectionScenarios.scala         |  30 ---
 .../usergrid/scenarios/DeviceScenarios.scala    |  65 ------
 .../usergrid/scenarios/GeoScenarios.scala       |  43 ----
 .../scenarios/NotificationScenarios.scala       |  71 -------
 .../usergrid/scenarios/NotifierScenarios.scala  |  65 ------
 .../scenarios/OrganizationScenarios.scala       |  42 ----
 .../usergrid/scenarios/TokenScenarios.scala     |  59 ------
 .../usergrid/scenarios/UserScenarios.scala      |  50 -----
 .../org/apache/usergrid/settings/Headers.scala  |  43 ----
 .../org/apache/usergrid/settings/Settings.scala |  54 -----
 .../org/apache/usergrid/settings/Utils.scala    |  87 --------
 .../simulations/GetEntitySimulation.scala       |  41 ----
 .../simulations/PostDevicesSimulation.scala     |  42 ----
 .../simulations/PostUsersSimulation.scala       |  47 -----
 .../PushTargetDeviceSimulation.scala            |  53 -----
 .../simulations/PushTargetUserSimulation.scala  |  68 -------
 .../datagenerators/EntityDataGenerator.scala    |  59 ++++++
 .../datagenerators/FeederGenerator.scala        | 114 +++++++++++
 .../scenarios/ApplicationScenarios.scala        |  46 +++++
 .../scenarios/ConnectionScenarios.scala         |  36 ++++
 .../usergrid/scenarios/DeviceScenarios.scala    |  85 ++++++++
 .../usergrid/scenarios/GeoScenarios.scala       |  44 ++++
 .../scenarios/NotificationScenarios.scala       |  74 +++++++
 .../usergrid/scenarios/NotifierScenarios.scala  |  66 ++++++
 .../scenarios/OrganizationScenarios.scala       |  43 ++++
 .../usergrid/scenarios/TokenScenarios.scala     |  60 ++++++
 .../usergrid/scenarios/UserScenarios.scala      |  50 +++++
 .../org/apache/usergrid/settings/Headers.scala  |  43 ++++
 .../org/apache/usergrid/settings/Settings.scala |  50 +++++
 .../org/apache/usergrid/settings/Utils.scala    |  91 +++++++++
 .../simulations/GetEntitySimulation.scala       |  44 ++++
 .../simulations/PostDevicesSimulation.scala     |  45 +++++
 .../simulations/PostUsersSimulation.scala       |  50 +++++
 ...PushNotificationTargetDeviceSimulation.scala |  57 ++++++
 .../PushNotificationTargetUserSimulation.scala  |  72 +++++++
 stack/loadtests/src/main/scripts/gatling-ug.sh  |  51 +++++
 stack/loadtests/src/test/resources/gatling.conf | 154 ++++++++++++++
 stack/loadtests/src/test/resources/logback.xml  |  37 ++++
 .../loadtests/src/test/resources/recorder.conf  |  37 ++++
 stack/loadtests/src/test/scala/Engine.scala     |  32 +++
 .../src/test/scala/IDEPathHelper.scala          |  37 ++++
 stack/loadtests/src/test/scala/Recorder.scala   |  28 +++
 102 files changed, 1661 insertions(+), 1683 deletions(-)
----------------------------------------------------------------------



[14/45] git commit: Added missing Apache license to load test files

Posted by to...@apache.org.
Added missing Apache license to load test files


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

Branch: refs/heads/key-row-sharding
Commit: 34a6d12e90bc8e47eab73a52f347af314ed909db
Parents: d5ead33
Author: amuramoto <am...@apigee.com>
Authored: Mon Oct 27 15:59:07 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Mon Oct 27 15:59:07 2014 -0700

----------------------------------------------------------------------
 stack/loadtests/pom.xml                            | 16 ++++++++++++++++
 stack/loadtests/src/test/scala/Engine.scala        | 16 ++++++++++++++++
 stack/loadtests/src/test/scala/IDEPathHelper.scala | 16 ++++++++++++++++
 stack/loadtests/src/test/scala/Recorder.scala      | 16 ++++++++++++++++
 4 files changed, 64 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/34a6d12e/stack/loadtests/pom.xml
----------------------------------------------------------------------
diff --git a/stack/loadtests/pom.xml b/stack/loadtests/pom.xml
index 0a2f4de..53cf8bb 100644
--- a/stack/loadtests/pom.xml
+++ b/stack/loadtests/pom.xml
@@ -1,4 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/34a6d12e/stack/loadtests/src/test/scala/Engine.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/test/scala/Engine.scala b/stack/loadtests/src/test/scala/Engine.scala
index b6dfa44..00f1004 100644
--- a/stack/loadtests/src/test/scala/Engine.scala
+++ b/stack/loadtests/src/test/scala/Engine.scala
@@ -1,3 +1,19 @@
+/*
+ * 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.
+ */
 import io.gatling.app.Gatling
 import io.gatling.core.config.GatlingPropertiesBuilder
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/34a6d12e/stack/loadtests/src/test/scala/IDEPathHelper.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/test/scala/IDEPathHelper.scala b/stack/loadtests/src/test/scala/IDEPathHelper.scala
index 988b616..d68ee4d 100644
--- a/stack/loadtests/src/test/scala/IDEPathHelper.scala
+++ b/stack/loadtests/src/test/scala/IDEPathHelper.scala
@@ -1,3 +1,19 @@
+/*
+ * 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.
+ */
 import scala.tools.nsc.io.File
 import scala.tools.nsc.io.Path.string2path
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/34a6d12e/stack/loadtests/src/test/scala/Recorder.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/test/scala/Recorder.scala b/stack/loadtests/src/test/scala/Recorder.scala
index b132063..266480c 100644
--- a/stack/loadtests/src/test/scala/Recorder.scala
+++ b/stack/loadtests/src/test/scala/Recorder.scala
@@ -1,3 +1,19 @@
+/*
+ * 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.
+ */
 import io.gatling.recorder.config.RecorderPropertiesBuilder
 import io.gatling.recorder.controller.RecorderController
 


[44/45] git commit: Merge remote-tracking branch 'origin/two-dot-o' into key-row-sharding

Posted by to...@apache.org.
Merge remote-tracking branch 'origin/two-dot-o' into key-row-sharding

Conflicts:
	stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java


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

Branch: refs/heads/key-row-sharding
Commit: f85fed191721bc761251d839f3042e2be7d3573d
Parents: 00ae403 0bfca7e
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Oct 29 21:38:44 2014 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Oct 29 21:38:44 2014 -0600

----------------------------------------------------------------------
 portal/js/push/push-config.html                 |  89 +-
 .../main/resources/usergrid-default.properties  |   3 +
 .../corepersistence/CpEntityDeleteListener.java |  45 +-
 .../corepersistence/CpEntityManager.java        |  73 +-
 .../corepersistence/CpEntityManagerFactory.java |  53 +-
 .../corepersistence/CpManagerCache.java         | 117 ++-
 .../corepersistence/CpRelationManager.java      | 944 +++++++++++--------
 .../usergrid/corepersistence/CpWalker.java      |  44 +-
 .../migration/GraphShardVersionMigration.java   |  28 +
 .../corepersistence/migration/Versions.java     |   4 +
 .../results/FilteringLoader.java                |  63 +-
 .../results/ResultsLoaderFactory.java           |   5 +-
 .../results/ResultsLoaderFactoryImpl.java       |   4 -
 .../results/ResultsVerifier.java                |   6 +-
 .../results/VersionVerifier.java                |   8 +-
 .../corepersistence/util/CpEntityMapUtils.java  |   5 +-
 .../usergrid/persistence/entities/Notifier.java |   2 -
 .../usergrid/persistence/index/EntityIndex.java |   4 +-
 .../persistence/index/EntityIndexBatch.java     |   6 -
 .../persistence/index/EntityIndexFactory.java   |   2 -
 .../usergrid/persistence/index/IndexScope.java  |   9 +-
 .../persistence/index/guice/IndexModule.java    |   1 -
 .../index/impl/EsEntityIndexBatchImpl.java      |   3 +-
 .../index/impl/EsEntityIndexImpl.java           |  71 +-
 .../persistence/index/impl/EsProvider.java      |  11 +-
 .../index/query/CandidateResults.java           |   7 +-
 .../persistence/index/query/EntityResults.java  |   6 +-
 .../persistence/index/query/Identifier.java     |   3 +-
 .../usergrid/persistence/index/query/Query.java |  27 +-
 .../persistence/index/query/Results.java        |   4 +-
 .../usergrid/persistence/queue/QueueFig.java    |   3 +
 .../persistence/queue/QueueScopeFactory.java    |  34 +
 .../persistence/queue/guice/QueueModule.java    |  10 +-
 .../queue/impl/QueueScopeFactoryImpl.java       |  47 +
 .../queue/impl/SQSQueueManagerImpl.java         |   6 +-
 .../persistence/queue/QueueManagerTest.java     |  27 +-
 stack/loadtests/README.md                       |  52 -
 stack/loadtests/gatling/LICENSE                 | 202 ----
 stack/loadtests/gatling/conf/application.conf   |  21 -
 stack/loadtests/gatling/conf/gatling.conf       | 162 ----
 stack/loadtests/gatling/conf/logback.xml        |  35 -
 stack/loadtests/gatling/conf/recorder.conf      |  51 -
 .../gatling/lib/Saxon-HE-9.5.1-6-compressed.jar | Bin 3813075 -> 0 bytes
 .../gatling/lib/akka-actor_2.10-2.3.6.jar       | Bin 2583959 -> 0 bytes
 .../lib/async-http-client-1.9.0-BETA13.jar      | Bin 579954 -> 0 bytes
 stack/loadtests/gatling/lib/boon-0.26.jar       | Bin 1026950 -> 0 bytes
 .../loadtests/gatling/lib/commons-pool-1.6.jar  | Bin 111119 -> 0 bytes
 .../lib/compiler-interface-0.13.5-sources.jar   | Bin 30056 -> 0 bytes
 .../lib/concurrentlinkedhashmap-lru-1.4.jar     | Bin 116575 -> 0 bytes
 stack/loadtests/gatling/lib/config-1.2.1.jar    | Bin 219554 -> 0 bytes
 .../gatling/lib/fastring_2.10-0.2.4.jar         | Bin 98640 -> 0 bytes
 .../gatling/lib/gatling-app-2.0.0-RC5.jar       | Bin 73052 -> 0 bytes
 .../gatling/lib/gatling-charts-2.0.0-RC5.jar    | Bin 500609 -> 0 bytes
 .../lib/gatling-charts-highcharts-2.0.0-RC5.jar | Bin 214683 -> 0 bytes
 .../gatling/lib/gatling-core-2.0.0-RC5.jar      | Bin 1678475 -> 0 bytes
 .../gatling/lib/gatling-http-2.0.0-RC5.jar      | Bin 1222752 -> 0 bytes
 .../gatling/lib/gatling-jdbc-2.0.0-RC5.jar      | Bin 41648 -> 0 bytes
 .../gatling/lib/gatling-jms-2.0.0-RC5.jar       | Bin 174279 -> 0 bytes
 .../gatling/lib/gatling-metrics-2.0.0-RC5.jar   | Bin 72446 -> 0 bytes
 .../gatling/lib/gatling-recorder-2.0.0-RC5.jar  | Bin 815471 -> 0 bytes
 .../gatling/lib/gatling-redis-2.0.0-RC5.jar     | Bin 19970 -> 0 bytes
 .../gatling/lib/geronimo-jms_1.1_spec-1.1.1.jar | Bin 32359 -> 0 bytes
 .../gatling/lib/incremental-compiler-0.13.5.jar | Bin 2214694 -> 0 bytes
 .../gatling/lib/jackson-annotations-2.4.0.jar   | Bin 38605 -> 0 bytes
 .../gatling/lib/jackson-core-2.4.2.jar          | Bin 225316 -> 0 bytes
 .../gatling/lib/jackson-databind-2.4.2.jar      | Bin 1075759 -> 0 bytes
 stack/loadtests/gatling/lib/jodd-core-3.6.jar   | Bin 373882 -> 0 bytes
 .../loadtests/gatling/lib/jodd-lagarto-3.6.jar  | Bin 204738 -> 0 bytes
 stack/loadtests/gatling/lib/jodd-log-3.6.jar    | Bin 14547 -> 0 bytes
 .../gatling/lib/jsonpath_2.10-0.5.0.jar         | Bin 180090 -> 0 bytes
 stack/loadtests/gatling/lib/jzlib-1.1.3.jar     | Bin 71976 -> 0 bytes
 .../gatling/lib/logback-classic-1.1.2.jar       | Bin 270750 -> 0 bytes
 .../gatling/lib/logback-core-1.1.2.jar          | Bin 427729 -> 0 bytes
 .../loadtests/gatling/lib/netty-3.9.4.Final.jar | Bin 1310154 -> 0 bytes
 stack/loadtests/gatling/lib/opencsv-2.3.jar     | Bin 19827 -> 0 bytes
 .../gatling/lib/redisclient_2.10-2.13.jar       | Bin 712616 -> 0 bytes
 .../gatling/lib/sbt-interface-0.13.5.jar        | Bin 52012 -> 0 bytes
 stack/loadtests/gatling/lib/scala-compiler.jar  | Bin 14445780 -> 0 bytes
 stack/loadtests/gatling/lib/scala-library.jar   | Bin 7126372 -> 0 bytes
 stack/loadtests/gatling/lib/scala-reflect.jar   | Bin 3203471 -> 0 bytes
 .../gatling/lib/scala-swing-2.10.4.jar          | Bin 707298 -> 0 bytes
 .../lib/scalalogging-slf4j_2.10-1.1.0.jar       | Bin 79003 -> 0 bytes
 .../loadtests/gatling/lib/scopt_2.10-3.2.0.jar  | Bin 122918 -> 0 bytes
 stack/loadtests/gatling/lib/slf4j-api-1.7.7.jar | Bin 29257 -> 0 bytes
 stack/loadtests/gatling/lib/t-digest-3.0.jar    | Bin 49754 -> 0 bytes
 stack/loadtests/gatling/lib/threetenbp-1.0.jar  | Bin 507797 -> 0 bytes
 .../gatling/lib/uncommons-maths-1.2.3.jar       | Bin 49923 -> 0 bytes
 stack/loadtests/gatling/lib/zinc-0.3.5.3.jar    | Bin 392810 -> 0 bytes
 stack/loadtests/gatling/scripts/gatling-ug.sh   |  49 -
 .../gatling/user-files/data/search.csv          |   3 -
 .../gatling/user-files/request-bodies/.keep     |   0
 stack/loadtests/loadtest_setup.sh               |  45 -
 stack/loadtests/pom.xml                         | 156 +++
 .../data-generators/EntityDataGenerator.scala   |  57 --
 .../data-generators/FeederGenerator.scala       | 101 --
 .../scenarios/ApplicationScenarios.scala        |  45 -
 .../scenarios/ConnectionScenarios.scala         |  30 -
 .../usergrid/scenarios/DeviceScenarios.scala    |  65 --
 .../usergrid/scenarios/GeoScenarios.scala       |  43 -
 .../scenarios/NotificationScenarios.scala       |  71 --
 .../usergrid/scenarios/NotifierScenarios.scala  |  65 --
 .../scenarios/OrganizationScenarios.scala       |  42 -
 .../usergrid/scenarios/TokenScenarios.scala     |  59 --
 .../usergrid/scenarios/UserScenarios.scala      |  50 -
 .../org/apache/usergrid/settings/Headers.scala  |  43 -
 .../org/apache/usergrid/settings/Settings.scala |  54 --
 .../org/apache/usergrid/settings/Utils.scala    |  87 --
 .../simulations/GetEntitySimulation.scala       |  41 -
 .../simulations/PostDevicesSimulation.scala     |  42 -
 .../simulations/PostUsersSimulation.scala       |  47 -
 .../PushTargetDeviceSimulation.scala            |  53 --
 .../simulations/PushTargetUserSimulation.scala  |  68 --
 .../datagenerators/EntityDataGenerator.scala    |  59 ++
 .../datagenerators/FeederGenerator.scala        | 114 +++
 .../scenarios/ApplicationScenarios.scala        |  46 +
 .../scenarios/ConnectionScenarios.scala         |  36 +
 .../usergrid/scenarios/DeviceScenarios.scala    |  85 ++
 .../usergrid/scenarios/GeoScenarios.scala       |  44 +
 .../scenarios/NotificationScenarios.scala       |  74 ++
 .../usergrid/scenarios/NotifierScenarios.scala  |  66 ++
 .../scenarios/OrganizationScenarios.scala       |  43 +
 .../usergrid/scenarios/TokenScenarios.scala     |  60 ++
 .../usergrid/scenarios/UserScenarios.scala      |  50 +
 .../org/apache/usergrid/settings/Headers.scala  |  43 +
 .../org/apache/usergrid/settings/Settings.scala |  50 +
 .../org/apache/usergrid/settings/Utils.scala    |  91 ++
 .../simulations/GetEntitySimulation.scala       |  44 +
 .../simulations/PostDevicesSimulation.scala     |  45 +
 .../simulations/PostUsersSimulation.scala       |  50 +
 ...PushNotificationTargetDeviceSimulation.scala |  57 ++
 .../PushNotificationTargetUserSimulation.scala  |  72 ++
 stack/loadtests/src/main/scripts/gatling-mvn.sh |  28 +
 stack/loadtests/src/main/scripts/gatling-ug.sh  |  51 +
 stack/loadtests/src/test/resources/gatling.conf | 154 +++
 stack/loadtests/src/test/resources/logback.xml  |  37 +
 .../loadtests/src/test/resources/recorder.conf  |  37 +
 stack/loadtests/src/test/scala/Engine.scala     |  32 +
 .../src/test/scala/IDEPathHelper.scala          |  37 +
 stack/loadtests/src/test/scala/Recorder.scala   |  28 +
 .../_maven.repositories                         |   8 -
 ...14c97c6e3ef40c88590e1b196d3ec55b-javadoc.jar | Bin 160201 -> 0 bytes
 ...14c97c6e3ef40c88590e1b196d3ec55b-sources.jar | Bin 59744 -> 0 bytes
 ...63dec68314c97c6e3ef40c88590e1b196d3ec55b.jar | Bin 67751 -> 0 bytes
 ...7c6e3ef40c88590e1b196d3ec55b.jar.lastUpdated |  13 -
 ...63dec68314c97c6e3ef40c88590e1b196d3ec55b.pom | 166 ----
 ...7c6e3ef40c88590e1b196d3ec55b.pom.lastUpdated |  13 -
 .../pushy-0.4-apigee.pom                        | 166 ----
 stack/pom.xml                                   |   2 +-
 stack/services/pom.xml                          |   2 +-
 .../notifications/ApplicationQueueManager.java  | 586 +-----------
 .../notifications/InactiveDeviceManager.java    |  79 ++
 .../notifications/NotificationsService.java     |  40 +-
 .../services/notifications/ProviderAdapter.java |  42 +-
 .../notifications/ProviderAdapterFactory.java   |  49 +
 .../services/notifications/QueueListener.java   |  89 +-
 .../services/notifications/TaskManager.java     |  17 +-
 .../services/notifications/TestAdapter.java     |  23 +-
 .../notifications/apns/APNsAdapter.java         | 200 ++--
 .../notifications/apns/EntityPushManager.java   |  75 ++
 .../apns/ExpiredTokenListener.java              |  52 +
 .../services/notifications/gcm/GCMAdapter.java  | 142 ++-
 .../impl/ApplicationQueueManagerImpl.java       | 523 ++++++++++
 .../services/notifiers/NotifiersService.java    |  30 +-
 .../notifications/NotifiersServiceIT.java       |  33 +-
 .../apns/MockSuccessfulProviderAdapter.java     |  38 +-
 .../apns/NotificationsServiceIT.java            |  67 +-
 .../gcm/MockSuccessfulProviderAdapter.java      |  33 +-
 .../gcm/NotificationsServiceIT.java             |  81 +-
 168 files changed, 3967 insertions(+), 3748 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f85fed19/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java
index 0000000,0000000..e714b5e
new file mode 100644
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/GraphShardVersionMigration.java
@@@ -1,0 -1,0 +1,28 @@@
++/*
++ *
++ *  * 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;
++
++
++/**
++ * Migration for migrating graph edges to the new Shards
++ */
++public class GraphShardVersionMigration {}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f85fed19/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/Versions.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/Versions.java
index 0000000,0000000..56bd65e
new file mode 100644
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/Versions.java
@@@ -1,0 -1,0 +1,4 @@@
++package org.apache.usergrid.corepersistence.migration;
++
++
++public class Versions {}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f85fed19/stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/QueueManagerTest.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/QueueManagerTest.java
index 85db87d,1d3c049..8eb5625
--- a/stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/QueueManagerTest.java
+++ b/stack/corepersistence/queue/src/test/java/org/apache/usergrid/persistence/queue/QueueManagerTest.java
@@@ -19,9 -19,12 +19,10 @@@
  
  package org.apache.usergrid.persistence.queue;
  
 -import com.amazonaws.services.glacier.TreeHashGenerator;
 -import org.apache.usergrid.persistence.collection.util.InvalidEntityGenerator;
  import org.apache.usergrid.persistence.queue.guice.TestQueueModule;
+ import org.apache.usergrid.persistence.queue.impl.QueueScopeFactoryImpl;
  import org.apache.usergrid.persistence.queue.impl.QueueScopeImpl;
 -import org.jukito.UseModules;
 +import org.apache.usergrid.persistence.core.test.UseModules;
  import org.junit.Before;
  import org.junit.Ignore;
  import org.junit.Test;


[06/45] fixes to push test

Posted by to...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala
deleted file mode 100755
index 7c411b0..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala
+++ /dev/null
@@ -1,42 +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
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import scala.concurrent.duration._
-
-/**
- * Performs organization registration
- *
- *
- * Produces:
- *
- * orgName The name of the created organization
- * userName  The user name of the admin to log in with
- * password The password of the admin to use
- */
-object OrganizationScenarios {
-
-  //register the org with the randomly generated org
-  val createOrgAndAdmin = exec(http("Create Organization")
-  .post("/management/organizations")
-  .headers(Headers.jsonAnonymous)
-  .body(StringBody("{\"organization\":\"" + Settings.org + "\",\"username\":\"${username}\",\"name\":\"${username}\",\"email\":\"${username}@apigee.com\",\"password\":\"${password}\"}"))
-  .check(status.is(200)))
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/TokenScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/TokenScenarios.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/TokenScenarios.scala
deleted file mode 100755
index 9dff0df..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/TokenScenarios.scala
+++ /dev/null
@@ -1,59 +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
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import scala.concurrent.duration._
-
-/**
- * Class that will get the token and insert it into the test session.
- * Assumes that  the following values are present in the session.
- *
- * Expects:
- *
- * userName  The user name to log in with
- * password The password to use
- *
- * Produces:
- *
- * authToken A valid access token if the login attempt is successful
- */
-
-object TokenScenarios {
-
-
-  val getManagementToken =
-    exec(
-      http("POST Org Token")
-        .post("/management/token")
-        .headers(Headers.jsonAnonymous)
-        //pass in the the username and password, store the "access_token" json response element as the var "authToken" in the session
-        .body(StringBody("{\"username\":\"${username}\",\"password\":\"${password}\",\"grant_type\":\"password\"}"))
-        .check(jsonPath("access_token")
-        .saveAs("authToken"))
-    )
-
-  val getUserToken =
-    exec(
-      http("POST user token")
-        .post("/token")
-        .body(StringBody("{\"grant_type\":\"password\",\"username\":\"${user1}\",\"password\":\"password\"}"))
-        .check(status.is(200))
-    )
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/UserScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/UserScenarios.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/UserScenarios.scala
deleted file mode 100755
index 843bc2e..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/UserScenarios.scala
+++ /dev/null
@@ -1,50 +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
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-
-object UserScenarios {
-
-  val getRandomUser = exec(
-    http("GET user")
-      .get("/users/user" + Utils.generateRandomInt(1, Settings.numEntities))
-      .check(status.is(200))
-  )
-
-  val postUser = exec(
-    http("POST geolocated Users")
-      .post("/users")
-      .body(StringBody("{\"location\":{\"latitude\":\"${latitude}\",\"longitude\":\"${longitude}\"},\"username\":\"${username}\"," +
-      "\"displayName\":\"${displayName}\",\"age\":\"${age}\",\"seen\":\"${seen}\",\"weight\":\"${weight}\"," +
-      "\"height\":\"${height}\",\"aboutMe\":\"${aboutMe}\",\"profileId\":\"${profileId}\",\"headline\":\"${headline}\"," +
-      "\"showAge\":\"${showAge}\",\"relationshipStatus\":\"${relationshipStatus}\",\"ethnicity\":\"${ethnicity}\",\"password\":\"password\"}"))
-      .check(status.is(200))
-  )
-
-  val postUser400ok = exec(
-    http("POST geolocated Users")
-      .post("/users")
-      .body(StringBody("{\"location\":{\"latitude\":\"${latitude}\",\"longitude\":\"${longitude}\"},\"username\":\"${username}\"," +
-      "\"displayName\":\"${displayName}\",\"age\":\"${age}\",\"seen\":\"${seen}\",\"weight\":\"${weight}\"," +
-      "\"height\":\"${height}\",\"aboutMe\":\"${aboutMe}\",\"profileId\":\"${profileId}\",\"headline\":\"${headline}\"," +
-      "\"showAge\":\"${showAge}\",\"relationshipStatus\":\"${relationshipStatus}\",\"ethnicity\":\"${ethnicity}\",\"password\":\"password\"}"))
-      .check(status.in(200 to 400))
-  )
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Headers.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Headers.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Headers.scala
deleted file mode 100755
index 319bdcf..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Headers.scala
+++ /dev/null
@@ -1,43 +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
-
-/**
- *
- */
-object Headers {
-
-  /**
-   * Headers for anonymous posts
-   */
-  val jsonAnonymous = Map(
-    "Cache-Control" -> """no-cache""",
-    "Content-Type" -> """application/json; charset=UTF-8"""
-  )
-
-  /**
-   * Headers for authorized users with token and json content type
-   */
-  val jsonAuthorized = Map(
-    "Cache-Control" -> """no-cache""",
-    "Content-Type" -> """application/json; charset=UTF-8""",
-    "Authorization" -> "Bearer ${authToken}"
-  )
-
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Settings.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Settings.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Settings.scala
deleted file mode 100755
index 5588b67..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Settings.scala
+++ /dev/null
@@ -1,54 +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
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import scala.concurrent.duration._
-
-object Settings {
-
-  // Target settings
-  val org = System.getProperty("org")
-  val app = System.getProperty("app")
-  val baseUrl = System.getProperty("baseurl")
-  val httpConf = http.baseURL(baseUrl + "/" + org + "/" + app)
-
-  // Simulation settings
-  val numUsers:Int = Integer.getInteger("numUsers", 10).toInt
-  val numEntities:Int = Integer.getInteger("numEntities", 5000).toInt
-  val numDevices:Int = Integer.getInteger("numDevices", 2000).toInt
-
-  val rampTime:Int = Integer.getInteger("rampTime", 0).toInt // in seconds
-  val duration:Int = Integer.getInteger("duration", 300).toInt // in seconds
-  val throttle:Int = Integer.getInteger("throttle", 50).toInt // in seconds
-
-  // Geolocation settings
-  val centerLatitude:Double = 37.442348 // latitude of center point
-  val centerLongitude:Double = -122.138268 // longitude of center point
-  val userLocationRadius:Double = 32000 // location of requesting user in meters
-  val geosearchRadius:Int = 8000 // search area in meters
-
-  // Push Notification settings
-  val pushNotifier = System.getProperty("notifier")
-  val pushProvider = System.getProperty("provider")
-
-  def createRandomPushNotifier:String = {
-    return Utils.generateUniqueName("notifier")
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Utils.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Utils.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Utils.scala
deleted file mode 100755
index 396f0b9..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Utils.scala
+++ /dev/null
@@ -1,87 +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
-
-import scala.util.Random
-import scala.math
-import Array._
-
-/**
- *
- * Utility for creating various data elements
- *
- */
-object Utils {
-
-  private val RNG = new Random
-
-  /**
-   * Generate a new uuid and replace the '-' with empty
-   */
-  def generateUUIDString(): String = {
-    return java.util.UUID.randomUUID.toString.replace("-", "")
-  }
-
-  /**
-   * Generate a unique string with a prefix
-   *
-   * @param prefix
-   * @return
-   */
-  def generateUniqueName(prefix : String): String = {
-     return prefix + generateUUIDString()
-  }
-
-  // random number in between [a...b]
-  def generateRandomInt(lowerBound: Int, upperBound: Int) = RNG.nextInt(upperBound - lowerBound) + lowerBound
-
-  def generateRandomGeolocation(radius: Double, centerLatitude: Double, centerLongitude: Double):Map[String, String] = {
-
-    var rd = radius / 111300 // Convert Radius from meters to degrees.
-    var u = RNG.nextFloat()
-    var v = RNG.nextFloat()
-    var q = math.sqrt(u) * rd
-    var w = q * rd
-    var t = 2 * math.Pi * v
-    var x = math.cos(t) * w
-    var y = math.sin(t) * w
-    var xp = x/math.cos(centerLatitude)
-    var latitude = (y + centerLatitude).toString
-    var longitude = (xp + centerLongitude).toString
-    var geolocation: Map[String, String] = Map("latitude"->latitude,"longitude"->longitude)
-
-    return geolocation
-  }
-
-  def generateRandomQueryString: String = {
-
-    val queryParams = Array("age", "height", "weight")
-    var queryString = ""
-
-    for (numParams <- 1 to generateRandomInt(1, queryParams.length)) {
-      queryString = "age=" + Utils.generateRandomInt(18, 65).toString
-      if (numParams == 2) {
-        queryString += "%20AND%20height=" + Utils.generateRandomInt(48, 84).toString
-      } else if (numParams == 3) {
-        queryString += "%20AND%20weight=" + Utils.generateRandomInt(120, 350).toString
-      }
-    }
-
-    return queryString
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala
deleted file mode 100644
index ac9bb7f..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala
+++ /dev/null
@@ -1,41 +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
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import scala.concurrent.duration._
-
-class GetEntitySimulation extends Simulation {
-
-  // Target settings
-  val httpConf = Settings.httpConf
-
-  // Simulation settings
-  val numUsers:Int = Settings.numUsers
-  val numEntities:Int = Settings.numEntities
-  val rampTime:Int = Settings.rampTime
-  val throttle:Int = Settings.throttle
-
-  val feeder = FeederGenerator.generateEntityNameFeeder("user", numEntities).circular
-
-  val scnToRun = scenario("GET entity")
-    .exec(UserScenarios.getRandomUser)
-
-  setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf)).maxDuration(Settings.duration)
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PostDevicesSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PostDevicesSimulation.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PostDevicesSimulation.scala
deleted file mode 100755
index 0c47a32..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PostDevicesSimulation.scala
+++ /dev/null
@@ -1,42 +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
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import scala.concurrent.duration._
-
-class PostDevicesSimulation extends Simulation {
-
-  // Target settings
-  val httpConf = Settings.httpConf
-
-  // Simulation settings
-  val numUsers:Int = Settings.numUsers
-  val numEntities:Int = Settings.numEntities
-  val rampTime:Int = Settings.rampTime
-  val throttle:Int = Settings.throttle
-
-  val feeder = FeederGenerator.generateEntityNameFeeder("device", numEntities)
-
-  val scnToRun = scenario("POST device")
-    .feed(feeder)
-    .exec(DeviceScenarios.postDeviceWithNotifier)
-
-  setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
deleted file mode 100755
index b49afc7..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
+++ /dev/null
@@ -1,47 +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
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import scala.concurrent.duration._
-
-class PostUsersSimulation extends Simulation {
-
-  // Target settings
-  val httpConf = Settings.httpConf
-
-  // Simulation settings
-  val numUsers:Int = Settings.numUsers
-  val rampTime:Int = Settings.rampTime
-  val throttle:Int = Settings.throttle
-
-  // Geolocation settings
-  val centerLatitude:Double = Settings.centerLatitude
-  val centerLongitude:Double = Settings.centerLongitude
-  val userLocationRadius:Double = Settings.userLocationRadius
-  val geosearchRadius:Int = Settings.geosearchRadius
-
-  val feeder = FeederGenerator.generateUserWithGeolocationFeeder(numUsers, userLocationRadius, centerLatitude, centerLongitude).queue
-
-  val scnToRun = scenario("POST geolocated users")
-    .feed(feeder)
-    .exec(UserScenarios.postUser)
-
-  setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PushTargetDeviceSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PushTargetDeviceSimulation.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PushTargetDeviceSimulation.scala
deleted file mode 100755
index 66b3c5d..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PushTargetDeviceSimulation.scala
+++ /dev/null
@@ -1,53 +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
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import scala.concurrent.duration._
-
-/**
- *
- * Simple test for setting up multiple orgs and creating push notifications
- *
- */
-class PushNotificationTargetDeviceSimulation extends Simulation {
-
-  val numUsers:Int = Settings.numUsers
-  val numEntities:Int = Settings.numEntities
-  val rampTime:Int = Settings.rampTime
-  val throttle:Int = Settings.throttle
-  val duration:Int = Settings.duration  
-  val httpConf = Settings.httpConf
-    .acceptHeader("application/json")
-
-  val createNotifier = NotifierScenarios.createNotifier
-  val createDevice = DeviceScenarios.postDeviceWithNotifier
-  val sendNotification = NotificationScenarios.sendNotification
-
-  val deviceNameFeeder = FeederGenerator.generateEntityNameFeeder("device", numEntities).circular
-
-  val scnToRun = scenario("Create Push Notification")    
-    .during(duration.seconds) {
-      feed(deviceNameFeeder)
-      .exec(sendNotification)
-    }
-
-
-  setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9d6b7e1/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PushTargetUserSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PushTargetUserSimulation.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PushTargetUserSimulation.scala
deleted file mode 100644
index fd565ba..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PushTargetUserSimulation.scala
+++ /dev/null
@@ -1,68 +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
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import scala.concurrent.duration._
-
-class PushNotificationTargetUserSimulation extends Simulation {
-
-  val numUsers:Int = Settings.numUsers
-  val numEntities:Int = Settings.numEntities
-  val rampTime:Int = Settings.rampTime
-  val throttle:Int = Settings.throttle
-  val duration:Int = Settings.duration
-  val httpConf = Settings.httpConf
-    .acceptHeader("application/json")
-
-  val notifier = Settings.pushNotifier
-  val createDevice = DeviceScenarios.postDeviceWithNotifier400ok
-  val sendNotification = NotificationScenarios.sendNotification
-  val createUser = UserScenarios.postUser400ok
-  val deviceNameFeeder = FeederGenerator.generateEntityNameFeeder("device", numEntities).circular
-  val userFeeder = FeederGenerator.generateUserWithGeolocationFeeder(numEntities, Settings.userLocationRadius, Settings.centerLatitude, Settings.centerLongitude)
-
-  val scnToRun = scenario("Create Push Notification")
-    .feed(userFeeder)
-    .exec(createUser)
-    .pause(1000)
-    .exec(http("Check user and user devices")
-      .get("/users/${username}/devices")
-      .check(status.is(200))
-    )
-    .feed(deviceNameFeeder)
-    .exec(createDevice)
-    .pause(1000)
-    .exec(http("Check device connections")
-      .get("/devices/${entityName}/users")
-      .check(status.is(200))
-    )
-    .exec(http("Connect user with device")
-      .post("/users/${username}/devices/${entityName}")
-      .check(status.is(200))
-    )
-    .exec(http("Send Notification to All Devices")
-      .post("/users/${username}/notifications")
-      .body(StringBody("{\"payloads\":{\"" + notifier + "\":\"testmessage\"}}"))
-      .check(status.is(200))
-    )
-
-
-  setUp(scnToRun.inject(constantUsersPerSec(numUsers) during (duration)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
-
-}


[22/45] git commit: Backing out a test breaking change inadvertently made during formatting.

Posted by to...@apache.org.
Backing out a test breaking change inadvertently made during formatting.


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

Branch: refs/heads/key-row-sharding
Commit: 744e5a814205b07522748d46f73291bd90aba0c0
Parents: 09d4ba4
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Oct 28 13:55:07 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Oct 28 13:55:07 2014 -0400

----------------------------------------------------------------------
 .../org/apache/usergrid/corepersistence/CpRelationManager.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/744e5a81/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 180d08c..d0da90f 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
@@ -1504,7 +1504,7 @@ public class CpRelationManager implements RelationManager {
         if ( query.getSortPredicates().isEmpty() ) {
 
             Query.SortPredicate asc = 
-                new Query.SortPredicate( PROPERTY_CREATED, Query.SortDirection.DESCENDING);
+                new Query.SortPredicate( PROPERTY_CREATED, Query.SortDirection.ASCENDING);
 
             query.addSort( asc );
         }


[38/45] git commit: apns null reference issue

Posted by to...@apache.org.
apns null reference issue


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

Branch: refs/heads/key-row-sharding
Commit: 77b8c59325c7cfbd0c04be2a66dfce3ce55ab1bd
Parents: 610eb2d
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Oct 29 13:12:20 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Oct 29 13:12:20 2014 -0600

----------------------------------------------------------------------
 .../notifications/apns/APNsAdapter.java         | 37 ++++++++++----------
 .../notifications/apns/EntityPushManager.java   |  5 +--
 2 files changed, 22 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/77b8c593/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
index 79a3b9e..a943bf5 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
@@ -64,6 +64,7 @@ public class APNsAdapter implements ProviderAdapter {
 
     private EntityManager entityManager;
     private EntityPushManager pushManager;
+    private LinkedBlockingQueue<SimpleApnsPushNotification> queue;
 
     public APNsAdapter(EntityManager entityManager, Notifier notifier){
         this.entityManager = entityManager;
@@ -76,13 +77,12 @@ public class APNsAdapter implements ProviderAdapter {
         try {
             CountDownLatch latch = new CountDownLatch(1);
             notification.setLatch(latch);
-            EntityPushManager pushManager = getPushManager(notifier);
-                addToQueue(pushManager, notification);
-                latch.await(10000,TimeUnit.MILLISECONDS);
-                if(notification.hasFailed()){
-                    // this is expected with a bad certificate (w/message: comes from failedconnectionlistener
-                    throw new ConnectionException("Bad certificate. Double-check your environment.",notification.getCause() != null ? notification.getCause() : new Exception("Bad certificate."));
-                }
+            addToQueue(notification);
+            latch.await(10000, TimeUnit.MILLISECONDS);
+            if (notification.hasFailed()) {
+                // this is expected with a bad certificate (w/message: comes from failedconnectionlistener
+                throw new ConnectionException("Bad certificate. Double-check your environment.", notification.getCause() != null ? notification.getCause() : new Exception("Bad certificate."));
+            }
                 notification.finished();
         } catch (Exception e) {
             notification.finished();
@@ -97,8 +97,8 @@ public class APNsAdapter implements ProviderAdapter {
         }
     }
 
-    private BlockingQueue<SimpleApnsPushNotification> addToQueue(PushManager<SimpleApnsPushNotification> pushManager, SimpleApnsPushNotification notification) throws InterruptedException {
-        BlockingQueue<SimpleApnsPushNotification> queue = pushManager.getQueue();
+    private BlockingQueue<SimpleApnsPushNotification> addToQueue(SimpleApnsPushNotification notification) throws Exception {
+        BlockingQueue<SimpleApnsPushNotification> queue = getPushManager(notifier).getQueue();
         queue.offer(notification,2500,TimeUnit.MILLISECONDS);
         return queue;
     }
@@ -107,9 +107,8 @@ public class APNsAdapter implements ProviderAdapter {
     public void sendNotification(String providerId, Object payload, Notification notification, TaskTracker tracker)
             throws Exception {
         APNsNotification apnsNotification = APNsNotification.create(providerId, payload.toString(), notification, tracker);
-        PushManager<SimpleApnsPushNotification> pushManager = getPushManager(notifier);
         try {
-            addToQueue(pushManager, apnsNotification);
+            addToQueue( apnsNotification);
             apnsNotification.messageSent();
         }catch (InterruptedException ie){
             apnsNotification.messageSendFailed(ie);
@@ -129,10 +128,12 @@ public class APNsAdapter implements ProviderAdapter {
     }
 
     private EntityPushManager getPushManager(Notifier notifier) throws ExecutionException {
-        if(pushManager != null &&  !pushManager.isStarted() && pushManager.isShutDown()){
+        if (pushManager == null || !pushManager.isStarted() || pushManager.isShutDown()) {
             PushManagerConfiguration config = new PushManagerConfiguration();
             config.setConcurrentConnectionCount(Runtime.getRuntime().availableProcessors() * 2);
-            EntityPushManager pushManager =  new EntityPushManager(notifier,entityManager, config);
+            queue = new LinkedBlockingQueue<SimpleApnsPushNotification>();
+
+            pushManager = new EntityPushManager(notifier, entityManager, queue, config);
             //only tested when a message is sent
             pushManager.registerRejectedNotificationListener(new RejectedAPNsListener());
             //this will get tested when start is called
@@ -144,10 +145,9 @@ public class APNsAdapter implements ProviderAdapter {
                 if (!pushManager.isStarted()) { //ensure manager is started
                     pushManager.start();
                 }
-            }catch(IllegalStateException ise){
-                logger.debug("failed to start",ise);//could have failed because its started
+            } catch (IllegalStateException ise) {
+                logger.debug("failed to start", ise);//could have failed because its started
             }
-            return pushManager;
         }
         return pushManager;
     }
@@ -189,8 +189,9 @@ public class APNsAdapter implements ProviderAdapter {
     @Override
     public void stop() {
         try {
-            if (!pushManager.isShutDown()) {
-                List<SimpleApnsPushNotification> notifications = pushManager.shutdown(3000);
+            EntityPushManager entityPushManager = getPushManager(notifier);
+            if (!entityPushManager.isShutDown()) {
+                List<SimpleApnsPushNotification> notifications = entityPushManager.shutdown(3000);
                 for (SimpleApnsPushNotification notification1 : notifications) {
                     try {
                         ((APNsNotification) notification1).messageSendFailed(new Exception("Cache Expired: Shutting down sender"));

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/77b8c593/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java
index d675081..c3790b8 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/EntityPushManager.java
@@ -32,6 +32,7 @@ import javax.net.ssl.SSLContext;
 import java.io.InputStream;
 import java.security.KeyStore;
 import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
 
 /**
  * Store notifier within PushManager so it can be retrieved later.  Need this for the async token listener
@@ -40,8 +41,8 @@ public class EntityPushManager extends PushManager<SimpleApnsPushNotification> {
     private final Notifier notifier;
     private final EntityManager entityManager;
 
-    public EntityPushManager( Notifier notifier, EntityManager entityManager, PushManagerConfiguration configuration) {
-        super(getApnsEnvironment(notifier), getSSLContext(notifier), null, null, new LinkedBlockingDeque<SimpleApnsPushNotification>(), configuration, notifier.getName());
+    public EntityPushManager( Notifier notifier, EntityManager entityManager, LinkedBlockingQueue<SimpleApnsPushNotification> queue, PushManagerConfiguration configuration) {
+        super(getApnsEnvironment(notifier), getSSLContext(notifier), null, null, queue, configuration, notifier.getName());
         this.notifier = notifier;
         this.entityManager = entityManager;
     }


[09/45] git commit: Update README.md

Posted by to...@apache.org.
Update README.md

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

Branch: refs/heads/key-row-sharding
Commit: 7947baed7b3d62b2ebfe321546d8377bde0f0e49
Parents: 6149bf1
Author: amuramoto <am...@users.noreply.github.com>
Authored: Mon Oct 27 10:10:19 2014 -0700
Committer: amuramoto <am...@users.noreply.github.com>
Committed: Mon Oct 27 10:10:19 2014 -0700

----------------------------------------------------------------------
 stack/loadtests/README.md | 52 ------------------------------------------
 1 file changed, 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7947baed/stack/loadtests/README.md
----------------------------------------------------------------------
diff --git a/stack/loadtests/README.md b/stack/loadtests/README.md
index 0c1774a..8b13789 100644
--- a/stack/loadtests/README.md
+++ b/stack/loadtests/README.md
@@ -1,53 +1 @@
-To make it easy for you to load test your instance of Usergrid, we have bundledin the Gatling load test tool, along with some pre-built tests of different functionality. To get started do the following:
 
-### Setting up Gatling
-1. Unzip loadtest.zip
-2. cd to the 'gatling' dir
-3. Run 'sh loadtest_setup.sh'. This will do the following:
-	- Add some handy options to gatling/bin/gatling.sh that will allow you to set certain test parameters using environment variables (more on this later)
-	- Run the PostUsersSimulation, which will load 5k users with geolocation data into a specified UG org/app. This is just to seed some data entities to make it easier to run some of the tests.
-4. Set the following environment variables:
-- GATLING_BASE_URL - Required. UG base url, e.g. http://api.usergrid.com/.
-- GATLING_ORG      - Required. UG organization name.
-- GATLING_APP      - Required. UG application name.
-
-- GATLING_NUMUSERS - Number of users in the simulation. Default is 100.
-- GATLING_DURATION - Duration of the simulation. Default is 300.
-- GATLING_RAMPTIME - Time period to inject the users over. Default is 0.
-- GATLING_THROTTLE - Requests per second the simulation to try to reach. Default is 50.
-
-- GATLING_NOTIFIER - Name of the notifier to use for PushNotificationSimulation.
-- GATLING_PROVIDER - Push notification provider that corresponds to the notifier, e.g. apple, google, etc.
-
-### Running load tests
-To run Gatling, do the following:
-1. Run 'gatling/bin/gatling.sh'
-2. Enter the number of the test you want to run from the list (see below for an explanation of each test)
-3. Optional. Set a identifier for the results of this run of the simulation
-4. Optional. Set a description for this run of the simulation
-
-### Viewing results
-Results of the test are output to the gatling/results. The output directory is shown once the test has successfully run. The location of the generated report is also shown.
-
-### Default tests
-The following default tests are available. Not that the GATLING_BASE_URL, GATLING_ORG, and GATLING_APP environment variables must be set before any tests can be run. Each test also requires certain additional env variables to be set.
-
-- PostUsersSimulation
-
-POSTs 5k entities with geolocation data to /users. Entities are named sequentially, i.e. user1, user2, etc.
-
-- GetEntitySimulation
-
-Performs simple GETs on the /users collection. You should run PostUsersSimulation or loadtest_Setup.sh first to load data into the collection.
-
-- PostDevicesSimulation
-
-POSTs a user-specified number of entities in the /devices collection. This is useful if you want to load test push notifications
-
-- PushTargetDeviceSimulation
-
-Creates users, devices, connects users with devices, then sends push notification to all user devices. To run this, you will need to do create a notifier, then set the GATLING_NOTIFIER environment variable to equal the name or UUID of the notifier. You'll also need to set GATLING_PROVIDER to match the provider in the notifier.
-
-- PushTargetDeviceSimulation
-
-Sends push notifications. To run this, you will need to do create a notifier, then set the GATLING_NOTIFIER environment variable to equal the name or UUID of the notifier. You'll also need to set GATLING_PROVIDER to match the provider in the notifier.
\ No newline at end of file


[04/45] git commit: fix build error

Posted by to...@apache.org.
fix build error


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

Branch: refs/heads/key-row-sharding
Commit: 19aa1a620ac40eddb7e663c5510b83aa6476da94
Parents: e1b2e73
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Oct 24 16:11:52 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Oct 24 16:11:52 2014 -0600

----------------------------------------------------------------------
 .../services/notifications/QueueListener.java       | 16 ++++++++++++----
 .../services/notifications/TestAdapter.java         |  4 +---
 2 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/19aa1a62/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
index 432ad7f..48c110b 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
@@ -144,6 +144,8 @@ public class QueueListener  {
         QueueScope queueScope = queueScopeFactory.getScope(smf.getManagementAppId(), queueName);
         QueueManager queueManager = TEST_QUEUE_MANAGER != null ? TEST_QUEUE_MANAGER : queueManagerFactory.getQueueManager(queueScope);
         // run until there are no more active jobs
+        long runCount = 0;
+        Map<UUID,ApplicationQueueManager> queueManagerMap = new ConcurrentHashMap<>(); //keep a cache of queuemangers then clear them at an interval
         while ( true ) {
             try {
 
@@ -152,7 +154,7 @@ public class QueueListener  {
                 LOG.info("retrieved batch of {} messages from queue {} ", messages.size(),queueName);
 
                 if (messages.size() > 0) {
-                    Map<UUID,ApplicationQueueManager> queueManagerMap = new ConcurrentHashMap<>();
+                    runCount++;
                     HashMap<UUID, List<QueueMessage>> messageMap = new HashMap<>(messages.size());
                     //group messages into hash map by app id
                     for (QueueMessage message : messages) {
@@ -197,9 +199,7 @@ public class QueueListener  {
                         merge.toBlocking().lastOrDefault(null);
                     }
                     queueManager.commitMessages(messages);
-                    for(ApplicationQueueManager applicationQueueManager : queueManagerMap.values()){
-                        applicationQueueManager.asyncCheckForInactiveDevices();
-                    }
+
                     meter.mark(messages.size());
                     LOG.info("sent batch {} messages duration {} ms", messages.size(),System.currentTimeMillis() - now);
 
@@ -207,6 +207,14 @@ public class QueueListener  {
                         LOG.info("sleep between rounds...sleep...{}", sleepBetweenRuns);
                         Thread.sleep(sleepBetweenRuns);
                     }
+                    if(runCount % 100 == 0){
+                        for(ApplicationQueueManager applicationQueueManager : queueManagerMap.values()){
+                            applicationQueueManager.asyncCheckForInactiveDevices();
+                        }
+                        //clear everything
+                        queueManagerMap.clear();
+                        runCount=0;
+                    }
                 }
                 else{
                     LOG.info("no messages...sleep...{}", sleepWhenNoneFound);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/19aa1a62/stack/services/src/main/java/org/apache/usergrid/services/notifications/TestAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/TestAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/TestAdapter.java
index 2f28364..b4eb767 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/TestAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/TestAdapter.java
@@ -89,10 +89,8 @@ public class TestAdapter implements ProviderAdapter {
     }
 
     @Override
-    public Map<String, Date> getInactiveDevices(Notifier notifier,
-            EntityManager em) throws Exception {
+    public void removeInactiveDevices(Notifier notifier, EntityManager em) throws Exception {
         log.debug("getInactiveDevices()");
-        return null;
     }
 
     @Override


[21/45] git commit: Restoring some semblance of my original formatting, take it easy with that auto-formatter folks!

Posted by to...@apache.org.
Restoring some semblance of my original formatting, take it easy with that auto-formatter folks!


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

Branch: refs/heads/key-row-sharding
Commit: 09d4ba444a20421316adfa3efd3e064d93a5fbb6
Parents: 3771e3f
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Oct 28 12:10:42 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Oct 28 12:10:42 2014 -0400

----------------------------------------------------------------------
 .../corepersistence/CpRelationManager.java      | 274 +++++++++----------
 1 file changed, 125 insertions(+), 149 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/09d4ba44/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 8c0d886..180d08c 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
@@ -186,10 +186,12 @@ public class CpRelationManager implements RelationManager {
     private ResultsLoaderFactory resultsLoaderFactory;
 
 
+
     public CpRelationManager() {}
 
 
-    public CpRelationManager init( EntityManager em,
+    public CpRelationManager init( 
+        EntityManager em, 
             CpEntityManagerFactory emf,
             UUID applicationId,
             EntityRef headEntity, 
@@ -223,7 +225,8 @@ public class CpRelationManager implements RelationManager {
         EntityCollectionManager ecm = managerCache.getEntityCollectionManager( headEntityScope );
         if ( logger.isDebugEnabled() ) {
             logger.debug( "Loading head entity {}:{} from scope\n   app {}\n   owner {}\n   name {}",
-                new Object[] { headEntity.getType(),
+                new Object[] {
+                    headEntity.getType(), 
                     headEntity.getUuid(),
                     headEntityScope.getApplication(),
                     headEntityScope.getOwner(),
@@ -233,7 +236,7 @@ public class CpRelationManager implements RelationManager {
 
         //TODO PERFORMANCE why are we loading this again here?
         this.cpHeadEntity = ecm.load( new SimpleId( 
-                headEntity.getUuid(), headEntity.getType() ) ).toBlocking() .lastOrDefault( null );
+            headEntity.getUuid(), headEntity.getType() )).toBlocking().lastOrDefault(null);
 
         // commented out because it is possible that CP entity has not been created yet
         Assert.notNull( cpHeadEntity, "cpHeadEntity cannot be null" );
@@ -248,18 +251,17 @@ public class CpRelationManager implements RelationManager {
     public Set<String> getCollectionIndexes( String collectionName ) throws Exception {
         final Set<String> indexes = new HashSet<String>();
 
-        GraphManager gm = managerCache.getGraphManager( applicationScope );
+        GraphManager gm = managerCache.getGraphManager(applicationScope);
 
         String edgeTypePrefix = CpNamingUtils.getEdgeTypeFromCollectionName( collectionName );
 
-        logger.debug( "getCollectionIndexes(): Searching for edge type prefix {} to target {}:{}",
-            new Object[] { edgeTypePrefix,
-                cpHeadEntity.getId().getType(),
-                cpHeadEntity.getId().getUuid() 
-            } ); 
+        logger.debug("getCollectionIndexes(): Searching for edge type prefix {} to target {}:{}", 
+            new Object[] {
+                edgeTypePrefix, cpHeadEntity.getId().getType(), cpHeadEntity.getId().getUuid()
+        });
 
-        Observable<String> types = gm.getEdgeTypesFromSource( 
-            new SimpleSearchEdgeType( cpHeadEntity.getId(), edgeTypePrefix, null ) );
+        Observable<String> types= gm.getEdgeTypesFromSource( 
+            new SimpleSearchEdgeType( cpHeadEntity.getId(), edgeTypePrefix,  null ));
 
         Iterator<String> iter = types.toBlockingObservable().getIterator();
         while ( iter.hasNext() ) {
@@ -297,7 +299,6 @@ public class CpRelationManager implements RelationManager {
 
     /**
      * Gets containing collections and/or connections depending on the edge type you pass in
-     *
      * @param limit Max number to return
      * @param edgeType Edge type, edge type prefix or null to allow any edge type
      * @param fromEntityType Only consider edges from entities of this type
@@ -306,35 +307,34 @@ public class CpRelationManager implements RelationManager {
 
         Map<EntityRef, Set<String>> results = new LinkedHashMap<EntityRef, Set<String>>();
 
-        GraphManager gm = managerCache.getGraphManager( applicationScope );
+        GraphManager gm = managerCache.getGraphManager(applicationScope);
 
         Iterator<String> edgeTypes = gm.getEdgeTypesToTarget( new SimpleSearchEdgeType( 
-                cpHeadEntity.getId(), edgeType, null ) ).toBlocking() .getIterator();
+            cpHeadEntity.getId(), edgeType, null) ).toBlocking().getIterator();
 
-        logger.debug( "getContainers(): "
+        logger.debug("getContainers(): "
                 + "Searched for edges of type {}\n   to target {}:{}\n   in scope {}\n   found: {}",
-            new Object[] { edgeType,
+            new Object[] {
+                edgeType,
                 cpHeadEntity.getId().getType(),
                 cpHeadEntity.getId().getUuid(),
                 applicationScope.getApplication(),
                 edgeTypes.hasNext() 
-            } );
+        });
 
         while ( edgeTypes.hasNext() ) {
 
             String etype = edgeTypes.next();
 
             Observable<Edge> edges = gm.loadEdgesToTarget( new SimpleSearchByEdgeType( 
-                cpHeadEntity.getId(), etype, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, null ) );
+                cpHeadEntity.getId(), etype, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, null ));
 
             Iterator<Edge> iter = edges.toBlockingObservable().getIterator();
             while ( iter.hasNext() ) {
                 Edge edge = iter.next();
 
-                if (     fromEntityType != null 
-                     && !fromEntityType.equals( edge.getSourceNode().getType() ) ) {
-                    logger.debug( "Ignoring edge from entity type {}", 
-                            edge.getSourceNode().getType() );
+                if ( fromEntityType != null && !fromEntityType.equals( edge.getSourceNode().getType() )) {
+                    logger.debug("Ignoring edge from entity type {}", edge.getSourceNode().getType());
                     continue;
                 }
 
@@ -342,10 +342,9 @@ public class CpRelationManager implements RelationManager {
                         edge.getSourceNode().getType(), edge.getSourceNode().getUuid() );
 
                 String name = null;
-                if ( CpNamingUtils.isConnectionEdgeType( edge.getType() ) ) {
+                if ( CpNamingUtils.isConnectionEdgeType( edge.getType() )) {
                     name = CpNamingUtils.getConnectionType( edge.getType() );
-                }
-                else {
+                } else {
                     name = CpNamingUtils.getCollectionName( edge.getType() );
                 }
                 addMapSet( results, eref, name );
@@ -366,11 +365,17 @@ public class CpRelationManager implements RelationManager {
 
         final GraphManager gm = managerCache.getGraphManager( applicationScope );
 
-        logger.debug( "updateContainingCollectionsAndCollections(): " + "Searched for edges to target {}:{}\n   in scope {}\n   found: {}",
-            new Object[] { cpHeadEntity.getId().getType(),
+        Iterator<String> edgeTypesToTarget = gm.getEdgeTypesToTarget( new SimpleSearchEdgeType( 
+            cpHeadEntity.getId(), null, null) ).toBlockingObservable().getIterator();
+
+        logger.debug("updateContainingCollectionsAndCollections(): "
+                + "Searched for edges to target {}:{}\n   in scope {}\n   found: {}", 
+            new Object[] {
+                cpHeadEntity.getId().getType(), 
                 cpHeadEntity.getId().getUuid(),
-                applicationScope.getApplication() 
-            } );
+                applicationScope.getApplication(),
+                edgeTypesToTarget.hasNext()
+        });
 
         // loop through all types of edge to target
 
@@ -444,13 +449,11 @@ public class CpRelationManager implements RelationManager {
 
         String edgeType = CpNamingUtils.getEdgeTypeFromConnectionType( connectionType );
 
-        logger.debug( "isConnectionMember(): Checking for edge type {} from {}:{} to {}:{}",
+        logger.debug("isConnectionMember(): Checking for edge type {} from {}:{} to {}:{}", 
             new Object[] { 
                 edgeType,
-                headEntity.getType(),
-                headEntity.getUuid(),
-                entity.getType(), entity.getUuid() 
-            } );
+                headEntity.getType(), headEntity.getUuid(), 
+                entity.getType(), entity.getUuid() });
 
         GraphManager gm = managerCache.getGraphManager( applicationScope );
         Observable<Edge> edges = gm.loadEdgeVersions( new SimpleSearchByEdge( 
@@ -474,13 +477,11 @@ public class CpRelationManager implements RelationManager {
 
         String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( collName );
 
-        logger.debug( "isCollectionMember(): Checking for edge type {} from {}:{} to {}:{}",
+        logger.debug("isCollectionMember(): Checking for edge type {} from {}:{} to {}:{}", 
             new Object[] { 
                 edgeType,
-                headEntity.getType(),
-                headEntity.getUuid(),
-                entity.getType(), entity.getUuid() 
-            } );
+                headEntity.getType(), headEntity.getUuid(), 
+                entity.getType(), entity.getUuid() });
 
         GraphManager gm = managerCache.getGraphManager( applicationScope );
         Observable<Edge> edges = gm.loadEdgeVersions( new SimpleSearchByEdge( 
@@ -709,8 +710,7 @@ public class CpRelationManager implements RelationManager {
     @Override
     @Metered( group = "core", name = "RelationManager_createItemInCollection" )
     public Entity createItemInCollection( 
-            String collName, String itemType, Map<String, Object> properties )
-            throws Exception {
+        String collName, String itemType, Map<String, Object> properties) throws Exception {
 
         if ( headEntity.getUuid().equals( applicationId ) ) {
             if ( itemType.equals( TYPE_ENTITY ) ) {
@@ -730,7 +730,6 @@ public class CpRelationManager implements RelationManager {
 
         else if ( headEntity.getType().equals( Group.ENTITY_TYPE ) 
                 && ( collName.equals( COLLECTION_ROLES ) ) ) {
-
             UUID groupId = headEntity.getUuid();
             String roleName = ( String ) properties.get( PROPERTY_NAME );
             return em.createGroupRole( groupId, roleName, ( Long ) properties.get( PROPERTY_INACTIVITY ) );
@@ -804,15 +803,17 @@ public class CpRelationManager implements RelationManager {
         final EntityIndexBatch batch = ei.createBatch();
 
         // remove item from collection index
-        IndexScope indexScope = new IndexScopeImpl( cpHeadEntity.getId(),
-                CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ) );
+        IndexScope indexScope = new IndexScopeImpl(
+            cpHeadEntity.getId(), 
+            CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ));
 
         batch.deindex( indexScope, memberEntity );
 
         // remove collection from item index 
-        IndexScope itemScope = new IndexScopeImpl( memberEntity.getId(), CpNamingUtils
-                .getCollectionScopeNameFromCollectionName(
-                        Schema.defaultCollectionName( cpHeadEntity.getId().getType() ) ) );
+        IndexScope itemScope = new IndexScopeImpl(
+            memberEntity.getId(), 
+            CpNamingUtils.getCollectionScopeNameFromCollectionName(
+                    Schema.defaultCollectionName( cpHeadEntity.getId().getType() ) ));
 
 
         batch.deindex( itemScope, cpHeadEntity );
@@ -857,8 +858,8 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    public void copyRelationships( String srcRelationName, EntityRef dstEntityRef, String dstRelationName )
-            throws Exception {
+    public void copyRelationships(String srcRelationName, EntityRef dstEntityRef, 
+            String dstRelationName) throws Exception {
 
         headEntity = em.validate( headEntity );
         dstEntityRef = em.validate( dstEntityRef );
@@ -903,15 +904,17 @@ public class CpRelationManager implements RelationManager {
 
         headEntity = em.validate( headEntity );
 
-        CollectionInfo collection = getDefaultSchema().getCollection( headEntity.getType(), collName );
+        CollectionInfo collection = 
+            getDefaultSchema().getCollection( headEntity.getType(), collName );
 
         if ( collection == null ) {
             throw new RuntimeException( "Cannot find collection-info for '" + collName 
                     + "' of " + headEntity.getType() + ":" + headEntity .getUuid() );
         }
 
-        IndexScope indexScope = new IndexScopeImpl( cpHeadEntity.getId(),
-                CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ) );
+        IndexScope indexScope = new IndexScopeImpl(
+            cpHeadEntity.getId(), 
+            CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ));
 
         EntityIndex ei = managerCache.getEntityIndex( applicationScope );
 
@@ -997,7 +1000,7 @@ public class CpRelationManager implements RelationManager {
         EntityCollectionManager targetEcm = managerCache.getEntityCollectionManager( targetScope );
 
         if ( logger.isDebugEnabled() ) {
-            logger.debug( "createConnection(): " 
+            logger.debug("createConnection(): "
                 + "Indexing connection type '{}'\n   from source {}:{}]\n"
                 + "   to target {}:{}\n   from scope\n   app {}\n   owner {}\n   name {}", 
                 new Object[] {
@@ -1009,7 +1012,7 @@ public class CpRelationManager implements RelationManager {
                     targetScope.getApplication(), 
                     targetScope.getOwner(), 
                     targetScope.getName()
-                } );
+            });
         }
 
         org.apache.usergrid.persistence.model.entity.Entity targetEntity = targetEcm.load( 
@@ -1335,8 +1338,9 @@ public class CpRelationManager implements RelationManager {
             final EntityIndex ei = managerCache.getEntityIndex( applicationScope );
 
 
-            logger.debug( "Searching connected entities from scope {}:{}", 
-                    indexScope.getOwner().toString(), indexScope.getName() );
+            logger.debug("Searching connected entities from scope {}:{}",
+                indexScope.getOwner().toString(),
+                indexScope.getName());
 
             query = adjustQuery( query );
             CandidateResults crs = ei.search( indexScope, query );
@@ -1422,8 +1426,9 @@ public class CpRelationManager implements RelationManager {
 
             EntityIndex ei = managerCache.getEntityIndex( applicationScope );
 
-            logger.debug( "Searching connections from the all-types scope {}:{}", 
-                    indexScope.getOwner().toString(), indexScope.getName() );
+            logger.debug("Searching connections from the all-types scope {}:{}",
+                indexScope.getOwner().toString(),
+                indexScope.getName());
 
             query = adjustQuery( query );
             CandidateResults crs = ei.search( indexScope, query );
@@ -1437,8 +1442,9 @@ public class CpRelationManager implements RelationManager {
             query.getConnectionType() ) );
         EntityIndex ei = managerCache.getEntityIndex( applicationScope );
         
-        logger.debug( "Searching connections from the scope {}:{}", 
-                indexScope.getOwner().toString(), indexScope.getName() );
+        logger.debug("Searching connections from the scope {}:{}",
+            indexScope.getOwner().toString(),
+            indexScope.getName());
 
         query = adjustQuery( query );
         CandidateResults crs = ei.search( indexScope, query );
@@ -1738,55 +1744,26 @@ public class CpRelationManager implements RelationManager {
 
 
     public IndexUpdate batchStartIndexUpdate( 
-            Mutator<ByteBuffer> batch,
-            Entity entity,
-            String entryName,
-            Object entryValue,
-            UUID timestampUuid,
-            boolean schemaHasProperty,
-            boolean isMultiValue,
-            boolean removeListEntry,
-            boolean fulltextIndexed )
+            Mutator<ByteBuffer> batch, Entity entity, String entryName,
+            Object entryValue, UUID timestampUuid, boolean schemaHasProperty,
+             boolean isMultiValue, boolean removeListEntry, boolean fulltextIndexed )
             throws Exception {
-
-        return batchStartIndexUpdate( 
-                batch,
-                entity,
-                entryName,
-                entryValue,
-                timestampUuid,
-                schemaHasProperty,
-                isMultiValue,
-                removeListEntry,
-                fulltextIndexed,
-                false );
+        return batchStartIndexUpdate( batch, entity, entryName, entryValue, timestampUuid, 
+                schemaHasProperty, isMultiValue, removeListEntry, fulltextIndexed, false );
     }
 
 
-    @Metered( group = "core", name = "RelationManager_batchStartIndexUpdate" )
+    @Metered(group = "core", name = "RelationManager_batchStartIndexUpdate")
     public IndexUpdate batchStartIndexUpdate( 
-            Mutator<ByteBuffer> batch,
-            Entity entity,
-            String entryName,
-            Object entryValue,
-            UUID timestampUuid,
-            boolean schemaHasProperty,
-            boolean isMultiValue,
-            boolean removeListEntry,
-            boolean fulltextIndexed,
+        Mutator<ByteBuffer> batch, Entity entity, String entryName,
+        Object entryValue, UUID timestampUuid, boolean schemaHasProperty,
+        boolean isMultiValue, boolean removeListEntry, boolean fulltextIndexed,
             boolean skipRead ) throws Exception {
 
         long timestamp = getTimestampInMicros( timestampUuid );
 
-        IndexUpdate indexUpdate = new IndexUpdate( 
-                batch,
-                entity,
-                entryName,
-                entryValue,
-                schemaHasProperty,
-                isMultiValue,
-                removeListEntry,
-                timestampUuid );
+        IndexUpdate indexUpdate = new IndexUpdate( batch, entity, entryName, entryValue, 
+                schemaHasProperty, isMultiValue, removeListEntry, timestampUuid );
 
         // entryName = entryName.toLowerCase();
 
@@ -1891,8 +1868,11 @@ public class CpRelationManager implements RelationManager {
 
             if ( isMultiValue ) {
                 addInsertToMutator( batch, ENTITY_INDEX_ENTRIES, entity.getUuid(),
-                    asList( entryName, indexValueCode( entryValue ), 
-                    toIndexableValue( entryValue ), indexUpdate.getTimestampUuid() ), null, timestamp );
+                        asList( entryName, 
+                            indexValueCode( entryValue ), 
+                            toIndexableValue( entryValue ),
+                            indexUpdate.getTimestampUuid() ),
+                        null, timestamp );
             }
             else {
                 // int i = 0;
@@ -1933,13 +1913,15 @@ public class CpRelationManager implements RelationManager {
      *
      * @throws Exception the exception
      */
-    @Metered( group = "core", name = "RelationManager_batchUpdateBackwardConnectionsDictionaryIndexes" )
-    public IndexUpdate batchUpdateBackwardConnectionsDictionaryIndexes( IndexUpdate indexUpdate ) throws Exception {
+    @Metered(group = "core", name = "RelationManager_batchUpdateBackwardConnectionsDictionaryIndexes")
+    public IndexUpdate batchUpdateBackwardConnectionsDictionaryIndexes( 
+            IndexUpdate indexUpdate ) throws Exception {
 
         logger.debug( "batchUpdateBackwardConnectionsListIndexes" );
 
         boolean entityHasDictionary = getDefaultSchema()
-                .isDictionaryIndexedInConnections( indexUpdate.getEntity().getType(), indexUpdate.getEntryName() );
+                .isDictionaryIndexedInConnections( 
+                        indexUpdate.getEntity().getType(), indexUpdate.getEntryName() );
 
         if ( !entityHasDictionary ) {
             return indexUpdate;
@@ -1951,8 +1933,8 @@ public class CpRelationManager implements RelationManager {
 
 
     /**
-     * Search each reverse connection type in the graph for connections. If one is found, update the index
-     * appropriately
+     * Search each reverse connection type in the graph for connections.  
+     * If one is found, update the index appropriately
      *
      * @param indexUpdate The index update to use
      *
@@ -1968,7 +1950,8 @@ public class CpRelationManager implements RelationManager {
 
         for ( String connectionType : connectionTypes ) {
 
-            PagingResultsIterator itr = getReversedConnectionsIterator( targetEntity, connectionType );
+            PagingResultsIterator itr = 
+                    getReversedConnectionsIterator( targetEntity, connectionType );
 
             for ( Object connection : itr ) {
 
@@ -1997,9 +1980,9 @@ public class CpRelationManager implements RelationManager {
      *
      * @throws Exception the exception
      */
-    @Metered( group = "core", name = "RelationManager_batchUpdateConnectionIndex" )
-    public IndexUpdate batchUpdateConnectionIndex( IndexUpdate indexUpdate, ConnectionRefImpl connection )
-            throws Exception {
+    @Metered(group = "core", name = "RelationManager_batchUpdateConnectionIndex")
+    public IndexUpdate batchUpdateConnectionIndex( 
+            IndexUpdate indexUpdate, ConnectionRefImpl connection ) throws Exception {
 
         logger.debug( "batchUpdateConnectionIndex" );
 
@@ -2015,17 +1998,12 @@ public class CpRelationManager implements RelationManager {
                 batchDeleteConnectionIndexEntries( indexUpdate, entry, connection, index_keys );
 
                 if ( "location.coordinates".equals( entry.getPath() ) ) {
-                    EntityLocationRef loc = new EntityLocationRef( 
-                        indexUpdate.getEntity(),
-                        entry.getTimestampUuid(),
+                    EntityLocationRef loc = 
+                        new EntityLocationRef( indexUpdate.getEntity(), entry.getTimestampUuid(),
                         entry.getValue().toString() );
                     batchDeleteLocationInConnectionsIndex( 
-                        indexUpdate.getBatch(),
-                        indexBucketLocator,
-                        applicationId,
-                        index_keys,
-                        entry.getPath(),
-                        loc );
+                        indexUpdate.getBatch(), indexBucketLocator, applicationId,
+                        index_keys, entry.getPath(), loc );
                 }
             }
             else {
@@ -2034,24 +2012,22 @@ public class CpRelationManager implements RelationManager {
         }
 
         if ( ( indexUpdate.getNewEntries().size() > 0 ) 
-                && ( !indexUpdate.isMultiValue() || ( indexUpdate.isMultiValue() && !indexUpdate.isRemoveListEntry() ) ) ) {
+                && ( !indexUpdate.isMultiValue() || ( indexUpdate.isMultiValue()
+                && !indexUpdate.isRemoveListEntry() ) ) ) {
 
             for ( IndexUpdate.IndexEntry indexEntry : indexUpdate.getNewEntries() ) {
 
                 batchAddConnectionIndexEntries( indexUpdate, indexEntry, connection, index_keys );
 
                 if ( "location.coordinates".equals( indexEntry.getPath() ) ) {
-                    EntityLocationRef loc = new EntityLocationRef( 
+                    EntityLocationRef loc =
+                            new EntityLocationRef( 
                         indexUpdate.getEntity(),
                         indexEntry.getTimestampUuid(),
                         indexEntry.getValue().toString() );
                     batchStoreLocationInConnectionsIndex( 
-                        indexUpdate.getBatch(),
-                            indexBucketLocator,
-                            applicationId,
-                            index_keys,
-                            indexEntry.getPath(),
-                            loc );
+                            indexUpdate.getBatch(), indexBucketLocator, applicationId,
+                            index_keys, indexEntry.getPath(), loc );
                 }
             }
 
@@ -2066,7 +2042,7 @@ public class CpRelationManager implements RelationManager {
 
         for ( String index : indexUpdate.getIndexesSet() ) {
             addInsertToMutator( indexUpdate.getBatch(), ENTITY_DICTIONARIES,
-                    key( connection.getConnectingIndexId(), Schema.DICTIONARY_INDEXES ), index, null,
+                    key( connection.getConnectingIndexId(), Schema.DICTIONARY_INDEXES), index, null,
                     indexUpdate.getTimestamp() );
         }
 
@@ -2098,12 +2074,11 @@ public class CpRelationManager implements RelationManager {
      * @param resultsLevel The results level to return
      */
     private Results getConnectingEntities( 
-        EntityRef targetEntity,
-            String connectionType,
-            String connectedEntityType,
+            EntityRef targetEntity, String connectionType, String connectedEntityType,
             Level resultsLevel ) throws Exception {
 
-        return getConnectingEntities( targetEntity, connectionType, connectedEntityType, resultsLevel, 0 );
+        return getConnectingEntities(
+                targetEntity, connectionType, connectedEntityType, resultsLevel, 0);
     }
 
 
@@ -2115,12 +2090,8 @@ public class CpRelationManager implements RelationManager {
      * @param connectedEntityType The connected entity type, if not specified all types are returned
      * @param count result limit
      */
-    private Results getConnectingEntities( 
-            EntityRef targetEntity,
-            String connectionType,
-            String connectedEntityType,
-            Level level,
-            int count ) throws Exception {
+    private Results getConnectingEntities( EntityRef targetEntity, String connectionType, 
+            String connectedEntityType, Level level, int count) throws Exception {
 
         Query query = new Query();
         query.setResultsLevel( level );
@@ -2200,9 +2171,11 @@ public class CpRelationManager implements RelationManager {
         logger.debug( "batchAddConnectionIndexEntries" );
 
         // entity_id,prop_name
-        Object property_index_key = key( index_keys[ConnectionRefImpl.ALL], INDEX_CONNECTIONS, entry.getPath(),
-                indexBucketLocator.getBucket( applicationId, IndexBucketLocator.IndexType.CONNECTION,
-                        index_keys[ConnectionRefImpl.ALL], entry.getPath() ) );
+        Object property_index_key = key( index_keys[ConnectionRefImpl.ALL], 
+                INDEX_CONNECTIONS, entry.getPath(),
+                indexBucketLocator.getBucket( applicationId, 
+                        IndexBucketLocator.IndexType.CONNECTION, index_keys[ConnectionRefImpl.ALL],
+                        entry.getPath() ) );
 
         // entity_id,entity_type,prop_name
         Object entity_type_prop_index_key =
@@ -2218,7 +2191,8 @@ public class CpRelationManager implements RelationManager {
 
         // entity_id,connection_type,entity_type,prop_name
         Object connection_type_and_entity_type_prop_index_key =
-                key( index_keys[ConnectionRefImpl.BY_CONNECTION_AND_ENTITY_TYPE], INDEX_CONNECTIONS, entry.getPath(),
+            key( index_keys[ConnectionRefImpl.BY_CONNECTION_AND_ENTITY_TYPE], 
+                INDEX_CONNECTIONS, entry.getPath(),
                         indexBucketLocator.getBucket( applicationId, IndexBucketLocator.IndexType.CONNECTION,
                                 index_keys[ConnectionRefImpl.BY_CONNECTION_AND_ENTITY_TYPE], entry.getPath() ) );
 
@@ -2229,17 +2203,19 @@ public class CpRelationManager implements RelationManager {
 
         // composite(property_value,connected_entity_id,connection_type,entry_timestamp)
         addInsertToMutator( indexUpdate.getBatch(), ENTITY_INDEX, entity_type_prop_index_key,
-                entry.getIndexComposite( conn.getConnectedEntityId(), conn.getConnectionType() ), conn.getUuid(),
-                indexUpdate.getTimestamp() );
+            entry.getIndexComposite( conn.getConnectedEntityId(), conn.getConnectionType() ),
+            conn.getUuid(), indexUpdate.getTimestamp() );
 
         // composite(property_value,connected_entity_id,entity_type,entry_timestamp)
         addInsertToMutator( indexUpdate.getBatch(), ENTITY_INDEX, connection_type_prop_index_key,
-                entry.getIndexComposite( conn.getConnectedEntityId(), conn.getConnectedEntityType() ), conn.getUuid(),
-                indexUpdate.getTimestamp() );
+            entry.getIndexComposite( conn.getConnectedEntityId(), conn.getConnectedEntityType() ),
+            conn.getUuid(), indexUpdate.getTimestamp() );
 
         // composite(property_value,connected_entity_id,entry_timestamp)
-        addInsertToMutator( indexUpdate.getBatch(), ENTITY_INDEX, connection_type_and_entity_type_prop_index_key,
-                entry.getIndexComposite( conn.getConnectedEntityId() ), conn.getUuid(), indexUpdate.getTimestamp() );
+        addInsertToMutator( indexUpdate.getBatch(), ENTITY_INDEX, 
+            connection_type_and_entity_type_prop_index_key,
+            entry.getIndexComposite( conn.getConnectedEntityId() ), conn.getUuid(),
+            indexUpdate.getTimestamp() );
 
         return indexUpdate.getBatch();
     }