You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2015/06/03 18:36:38 UTC
incubator-usergrid git commit: new queue manager impl
Repository: incubator-usergrid
Updated Branches:
refs/heads/two-dot-o-dev 429e1454a -> 68c65f070
new queue manager impl
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/68c65f07
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/68c65f07
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/68c65f07
Branch: refs/heads/two-dot-o-dev
Commit: 68c65f0701aa9b1b3a253b19ac8e3b156a2ba53e
Parents: 429e145
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Jun 3 10:36:19 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Jun 3 10:36:19 2015 -0600
----------------------------------------------------------------------
.../usergrid/persistence/queue/QueueFig.java | 4 ++
.../queue/QueueManagerInternalFactory.java | 28 ++++++++++++
.../persistence/queue/guice/QueueModule.java | 5 ++-
.../queue/impl/QueueManagerFactoryImpl.java | 47 ++++++++++++++++++++
.../apache/usergrid/rest/NotificationsIT.java | 3 --
.../resources/usergrid-custom-test.properties | 1 +
.../notifications/NotificationsService.java | 4 +-
.../apns/NotificationsServiceIT.java | 1 -
.../gcm/NotificationsServiceIT.java | 4 --
.../resources/usergrid-custom-test.properties | 2 +-
10 files changed, 87 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/68c65f07/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 056982c..0f572af 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
@@ -43,4 +43,8 @@ public interface QueueFig extends GuicyFig {
@Key( "usergrid.queue.deliveryLimit" )
@Default("5")
public String getQueueDeliveryLimit();
+
+ @Key("usergrid.use.default.queue")
+ @Default("false")
+ public boolean overrideQueueForDefault();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/68c65f07/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManagerInternalFactory.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManagerInternalFactory.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManagerInternalFactory.java
new file mode 100644
index 0000000..119c064
--- /dev/null
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/QueueManagerInternalFactory.java
@@ -0,0 +1,28 @@
+/*
+ *
+ * * 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;
+
+/**
+ * QueueManagerInternal guice factory
+ */
+public interface QueueManagerInternalFactory {
+ QueueManager getQueueManager( final QueueScope scope );
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/68c65f07/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 9224d7d..dd1fe16 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
@@ -18,6 +18,8 @@
package org.apache.usergrid.persistence.queue.guice;
+import org.apache.usergrid.persistence.queue.QueueManagerInternalFactory;
+import org.apache.usergrid.persistence.queue.impl.QueueManagerFactoryImpl;
import org.apache.usergrid.persistence.queue.impl.SNSQueueManagerImpl;
import org.safehaus.guicyfig.GuicyFigModule;
@@ -43,8 +45,9 @@ public class QueueModule extends AbstractModule {
install(new GuicyFigModule(QueueFig.class));
+ bind(QueueManagerFactory.class).to(QueueManagerFactoryImpl.class);
install(new FactoryModuleBuilder().implement(QueueManager.class, SNSQueueManagerImpl.class)
- .build(QueueManagerFactory.class));
+ .build(QueueManagerInternalFactory.class));
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/68c65f07/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerFactoryImpl.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerFactoryImpl.java
new file mode 100644
index 0000000..2f9e7b1
--- /dev/null
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QueueManagerFactoryImpl.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.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+import org.apache.usergrid.persistence.queue.*;
+
+/**
+ * manages whether we take in an external in memory override for queues.
+ */
+@Singleton
+public class QueueManagerFactoryImpl implements QueueManagerFactory {
+
+
+ private final QueueFig queueFig;
+ private final QueueManagerInternalFactory queuemanagerInternalFactory;
+
+ @Inject
+ public QueueManagerFactoryImpl(final QueueFig queueFig, final QueueManagerInternalFactory queuemanagerInternalFactory){
+ this.queueFig = queueFig;
+ this.queuemanagerInternalFactory = queuemanagerInternalFactory;
+ }
+ @Override
+ public QueueManager getQueueManager(QueueScope scope) {
+ return queueFig.overrideQueueForDefault() ? new DefaultQueueManager() : queuemanagerInternalFactory.getQueueManager(scope);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/68c65f07/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
index 474bb37..cf6edb0 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
@@ -74,9 +74,6 @@ public class NotificationsIT extends org.apache.usergrid.rest.test.resource2poin
@Test
public void testPaging() throws Exception {
- Token adminToken = clientSetup.getRestClient().management().token().post(Token.class, new Token( clientSetup.getUsername(), clientSetup.getPassword() ) );
- clientSetup.getRestClient().management().token().setToken( adminToken );
-
// create notifier
Entity notifier = new Entity().chainPut("name", "mynotifier").chainPut("provider", "noop");
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/68c65f07/stack/rest/src/test/resources/usergrid-custom-test.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/usergrid-custom-test.properties b/stack/rest/src/test/resources/usergrid-custom-test.properties
index 34ce9c2..4939608 100644
--- a/stack/rest/src/test/resources/usergrid-custom-test.properties
+++ b/stack/rest/src/test/resources/usergrid-custom-test.properties
@@ -42,5 +42,6 @@ usergrid.sysadmin.login.email=superuser@usergrid.com
usergrid.sysadmin.login.password=superpassword
usergrid.sysadmin.login.allowed=true
elasticsearch.index_prefix=rest_tests
+usergrid.use.default.queue=true
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/68c65f07/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 9fd0683..0f13c6d 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
@@ -23,6 +23,7 @@ import java.util.Map;
import java.util.Properties;
import java.util.UUID;
+import org.apache.usergrid.persistence.queue.DefaultQueueManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -76,7 +77,6 @@ public class NotificationsService extends AbstractCollectionService {
private static final int PAGE = 100;
private static final Logger LOG = LoggerFactory.getLogger(NotificationsService.class);
//need a mocking framework, this is to substitute for no mocking
- public static QueueManager TEST_QUEUE_MANAGER = null;
static final String MESSAGE_PROPERTY_DEVICE_UUID = "deviceUUID";
@@ -110,7 +110,7 @@ public class NotificationsService extends AbstractCollectionService {
String name = ApplicationQueueManagerImpl.getQueueNames( props );
QueueScope queueScope = new QueueScopeImpl( name );
queueManagerFactory = getApplicationContext().getBean( Injector.class ).getInstance(QueueManagerFactory.class);
- QueueManager queueManager = TEST_QUEUE_MANAGER !=null ? TEST_QUEUE_MANAGER : queueManagerFactory.getQueueManager(queueScope);
+ QueueManager queueManager = queueManagerFactory.getQueueManager(queueScope);
notificationQueueManager = new ApplicationQueueManagerImpl(jobScheduler,em,queueManager,metricsService,props);
gracePeriod = jobScheduler.SCHEDULER_GRACE_PERIOD;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/68c65f07/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 8f1ae04..9c2385f 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
@@ -120,7 +120,6 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
ns = getNotificationService();
DefaultQueueManager qm = new DefaultQueueManager();
- ns.TEST_QUEUE_MANAGER = qm;
setup.getEntityIndex().refresh();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/68c65f07/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 c0c86ad..8dafddd 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
@@ -98,12 +98,8 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
device2 = app.getEntityManager().get(e.getUuid(), Device.class);
ns = getNotificationService();
- DefaultQueueManager qm = new DefaultQueueManager();
- ns.TEST_QUEUE_MANAGER = qm;
-
listener = new QueueListener(ns.getServiceManagerFactory(), ns.getEntityManagerFactory(), new Properties());
listener.DEFAULT_SLEEP = 200;
- listener.TEST_QUEUE_MANAGER = qm;
listener.start();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/68c65f07/stack/services/src/test/resources/usergrid-custom-test.properties
----------------------------------------------------------------------
diff --git a/stack/services/src/test/resources/usergrid-custom-test.properties b/stack/services/src/test/resources/usergrid-custom-test.properties
index d01231f..fa39224 100644
--- a/stack/services/src/test/resources/usergrid-custom-test.properties
+++ b/stack/services/src/test/resources/usergrid-custom-test.properties
@@ -33,6 +33,6 @@ elasticsearch.index_prefix=services_tests
elasticsearch.buffer_timeout=1
elasticsearch.queue_impl.resolution=true
-
+usergrid.use.default.queue=true