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 2014/09/21 00:30:41 UTC

[3/4] git commit: remove all synchronized blocks

remove all synchronized blocks


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

Branch: refs/heads/two-dot-o
Commit: eb0eef9234de0ab90afbbfec8dbdf713320e799f
Parents: d86e9d2
Author: Shawn Feldman <sf...@apache.org>
Authored: Sat Sep 20 16:27:35 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Sat Sep 20 16:27:35 2014 -0600

----------------------------------------------------------------------
 .../notifications/ApplicationQueueManager.java  |  9 ++++---
 .../services/notifications/QueueListener.java   | 25 ++++++++++----------
 .../notifications/SingleQueueTaskManager.java   |  8 +++----
 3 files changed, 20 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb0eef92/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 b54c9c6..ee988dc 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
@@ -311,12 +311,11 @@ public class ApplicationQueueManager implements QueueManager {
                         notificationMap.put(message.getNotificationId(), notification);
                     }
                     SingleQueueTaskManager taskManager;
-                    synchronized (taskMap) {
+                    taskManager = taskMap.get(message.getNotificationId());
+                    if (taskManager == null) {
+                        taskManager = new SingleQueueTaskManager(em, qm, proxy, notification);
+                        taskMap.putIfAbsent(message.getNotificationId(), taskManager);
                         taskManager = taskMap.get(message.getNotificationId());
-                        if (taskManager == null) {
-                            taskManager = new SingleQueueTaskManager(em, qm, proxy, notification);
-                            taskMap.put(message.getNotificationId(), taskManager);
-                        }
                     }
 
                     final Map<String, Object> payloads = notification.getPayloads();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb0eef92/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 51f8f79..65d99be 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
@@ -101,18 +101,17 @@ public class QueueListener  {
                 futures = new ArrayList<Future>(maxThreads);
                 while (threadCount++ < maxThreads) {
                     LOG.info("QueueListener: Starting thread {}.", threadCount);
-                    futures.add(
-                            pool.submit(new Runnable() {
-                                @Override
-                                public void run() {
-                                    try {
-                                        execute();
-                                    } catch (Exception e) {
-                                        LOG.error("failed to start push", e);
-                                    }
-                                }
-                            })
-                    );
+                    Runnable task = new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+                                execute();
+                            } catch (Exception e) {
+                                LOG.error("failed to start push", e);
+                            }
+                        }
+                    };
+                    futures.add( pool.submit(task));
                 }
             } catch (Exception e) {
                 LOG.error("QueueListener: failed to start:", e);
@@ -125,7 +124,7 @@ public class QueueListener  {
     }
 
     private void execute(){
-
+        Thread.currentThread().setName("Notifications_Processor"+UUID.randomUUID());
         svcMgr = smf.getServiceManager(smf.getManagementAppId());
         queueManager = svcMgr.getQueueManager();
         final AtomicInteger consecutiveExceptions = new AtomicInteger();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/eb0eef92/stack/services/src/main/java/org/apache/usergrid/services/notifications/SingleQueueTaskManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/SingleQueueTaskManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/SingleQueueTaskManager.java
index 5af0493..4b11974 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/SingleQueueTaskManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/SingleQueueTaskManager.java
@@ -145,7 +145,7 @@ public class SingleQueueTaskManager implements NotificationsTaskManager {
     }
 
     public void finishedBatch() throws Exception {
-        synchronized (this) { //avoid issues with counting
+        //synchronized (this) { //avoid issues with counting
             long successes = this.successes.getAndSet(0); //reset counters
             long failures = this.failures.getAndSet(0); //reset counters
             this.hasFinished = true;
@@ -200,10 +200,10 @@ public class SingleQueueTaskManager implements NotificationsTaskManager {
             LOG.info("notification finished batch: {}", notification.getUuid());
             em.updateProperties(notification, properties);
             em.update(notification);
-        }
+       // }
 
-        Set<Notifier> notifiers = new HashSet<Notifier>(proxy.getNotifierMap().values()); // remove dups
-        proxy.asyncCheckForInactiveDevices(notifiers);
+        //Set<Notifier> notifiers = new HashSet<Notifier>(proxy.getNotifierMap().values()); // remove dups
+       // proxy.asyncCheckForInactiveDevices(notifiers);
     }