You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/12/12 15:30:02 UTC
[03/50] [abbrv] incubator-usergrid git commit: remove queue manager
remove queue manager
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/461c1928
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/461c1928
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/461c1928
Branch: refs/heads/no-source-in-es
Commit: 461c1928beae05c78646ac727f20e0afe7d6f3fb
Parents: c4973e9
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Dec 8 11:03:48 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Dec 8 11:03:48 2014 -0700
----------------------------------------------------------------------
.../persistence/queue/DefaultQueueManager.java | 68 ++++++++++++++++++++
.../usergrid/services/TestQueueManager.java | 65 -------------------
.../apns/NotificationsServiceIT.java | 4 +-
.../gcm/NotificationsServiceIT.java | 4 +-
4 files changed, 72 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461c1928/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/DefaultQueueManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/DefaultQueueManager.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/DefaultQueueManager.java
new file mode 100644
index 0000000..354aa7b
--- /dev/null
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/DefaultQueueManager.java
@@ -0,0 +1,68 @@
+/*
+ *
+ * * 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 java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+/**
+ * Default queue manager implementation, uses in memory linked queue
+ */
+public class DefaultQueueManager implements QueueManager {
+ public ConcurrentLinkedQueue<QueueMessage> queue = new ConcurrentLinkedQueue<>();
+ @Override
+ public synchronized List<QueueMessage> getMessages(int limit, int transactionTimeout, int waitTime, Class klass) {
+ List<QueueMessage> returnQueue = new ArrayList<>();
+ for(int i=0;i<limit;i++){
+ if(!queue.isEmpty()){
+ returnQueue.add( queue.remove());
+ }else{
+ break;
+ }
+ }
+ return returnQueue;
+ }
+
+ @Override
+ public void commitMessage(QueueMessage queueMessage) {
+ }
+
+ @Override
+ public void commitMessages(List<QueueMessage> queueMessages) {
+ }
+
+ @Override
+ public synchronized void sendMessages(List bodies) throws IOException {
+ for(Object body : bodies){
+ String uuid = UUID.randomUUID().toString();
+ queue.add(new QueueMessage(uuid,"handle_"+uuid,body));
+ }
+ }
+
+ @Override
+ public synchronized void sendMessage(Object body) throws IOException {
+ String uuid = UUID.randomUUID().toString();
+ queue.add(new QueueMessage(uuid,"handle_"+uuid,body));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461c1928/stack/services/src/test/java/org/apache/usergrid/services/TestQueueManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/TestQueueManager.java b/stack/services/src/test/java/org/apache/usergrid/services/TestQueueManager.java
deleted file mode 100644
index 37fef40..0000000
--- a/stack/services/src/test/java/org/apache/usergrid/services/TestQueueManager.java
+++ /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.services;
-
-import org.apache.usergrid.persistence.queue.QueueManager;
-import org.apache.usergrid.persistence.queue.QueueMessage;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-
-public class TestQueueManager implements QueueManager {
- public ConcurrentLinkedQueue<QueueMessage> queue = new ConcurrentLinkedQueue<>();
- @Override
- public synchronized List<QueueMessage> getMessages(int limit, int transactionTimeout, int waitTime, Class klass) {
- List<QueueMessage> returnQueue = new ArrayList<>();
- for(int i=0;i<limit;i++){
- if(!queue.isEmpty()){
- returnQueue.add( queue.remove());
- }else{
- break;
- }
- }
- return returnQueue;
- }
-
- @Override
- public void commitMessage(QueueMessage queueMessage) {
- }
-
- @Override
- public void commitMessages(List<QueueMessage> queueMessages) {
- }
-
- @Override
- public synchronized void sendMessages(List bodies) throws IOException {
- for(Object body : bodies){
- String uuid = UUID.randomUUID().toString();
- queue.add(new QueueMessage(uuid,"handle_"+uuid,body));
- }
- }
-
- @Override
- public synchronized void sendMessage(Object body) throws IOException {
- String uuid = UUID.randomUUID().toString();
- queue.add(new QueueMessage(uuid,"handle_"+uuid,body));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461c1928/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 0a5375f..3f42777 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
@@ -21,7 +21,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.usergrid.persistence.*;
import org.apache.usergrid.persistence.entities.*;
import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.services.TestQueueManager;
+import org.apache.usergrid.persistence.queue.DefaultQueueManager;
import org.apache.usergrid.services.notifications.*;
import org.junit.*;
import org.slf4j.Logger;
@@ -121,7 +121,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
ns = getNotificationService();
- TestQueueManager qm = new TestQueueManager();
+ DefaultQueueManager qm = new DefaultQueueManager();
ns.TEST_QUEUE_MANAGER = qm;
app.getEntityManager().refreshIndex();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461c1928/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 5228464..4b41d13 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,7 +18,7 @@ package org.apache.usergrid.services.notifications.gcm;
import org.apache.usergrid.persistence.*;
import org.apache.usergrid.persistence.entities.*;
-import org.apache.usergrid.services.TestQueueManager;
+import org.apache.usergrid.persistence.queue.DefaultQueueManager;
import org.apache.usergrid.services.notifications.*;
import org.junit.*;
import org.slf4j.Logger;
@@ -93,7 +93,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
device2 = app.getEntityManager().get(e.getUuid(), Device.class);
ns = getNotificationService();
- TestQueueManager qm = new TestQueueManager();
+ DefaultQueueManager qm = new DefaultQueueManager();
ns.TEST_QUEUE_MANAGER = qm;
listener = new QueueListener(ns.getServiceManagerFactory(), ns.getEntityManagerFactory(),ns.getMetricsFactory(), new Properties());