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/07 21:33:18 UTC

[6/9] git commit: remove finished batch check

remove finished batch check


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

Branch: refs/heads/collection_multiget
Commit: c0c30a9163c01491809b125107167a618a8bb8a6
Parents: 4cb7a92
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Oct 6 15:26:25 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Oct 6 15:26:25 2014 -0600

----------------------------------------------------------------------
 .../services/notifications/TaskManager.java     | 58 ++++++++++----------
 1 file changed, 29 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0c30a91/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 6b5441e..755cb56 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
@@ -147,36 +147,36 @@ public class TaskManager {
         }
     }
 
-    public  void finishedBatch() throws Exception {
-        synchronized (this) {
-            long successes = this.successes.getAndSet(0); //reset counters
-            long failures = this.failures.getAndSet(0); //reset counters
-            this.hasFinished = true;
-
-            // refresh notification
-            Notification notification = em.get(this.notification.getUuid(), Notification.class);
-            notification.setModified(System.currentTimeMillis());
-
-            //and write them out again, this will produce the most accurate count
-            Map<String, Long> stats = new HashMap<>(2);
-            stats.put("sent", successes);
-            stats.put("errors", failures);
-            notification.updateStatistics(successes, failures);
-
-            //none of this is known and should you ever do this
-            if (notification.getExpectedCount() <= (notification.getStatistics().get("sent") + notification.getStatistics().get("errors"))) {
-                Map<String, Object> properties = new HashMap<>();
-                notification.setFinished(notification.getModified());
-                properties.put("finished", notification.getModified());
-                properties.put("state", notification.getState());
-                LOG.info("done sending to devices in {} ms", notification.getFinished() - notification.getStarted());
-                notification.addProperties(properties);
-            }
-
-            LOG.info("notification finished batch: {} of {} devices", notification.getUuid(), successes + failures);
-            em.update(notification);
+    public void finishedBatch() throws Exception {
+        long successes = this.successes.get(); //reset counters
+        long failures = this.failures.get(); //reset counters
+        for(int i = 0;i<successes;i++){this.successes.decrementAndGet();}
+        for(int i = 0;i<failures;i++){this.failures.decrementAndGet();}
+
+        this.hasFinished = true;
+
+        // refresh notification
+        Notification notification = em.get(this.notification.getUuid(), Notification.class);
+        notification.setModified(System.currentTimeMillis());
+
+        //and write them out again, this will produce the most accurate count
+        Map<String, Long> stats = new HashMap<>(2);
+        stats.put("sent", successes);
+        stats.put("errors", failures);
+        notification.updateStatistics(successes, failures);
+
+        long totals = (notification.getStatistics().get("sent") + notification.getStatistics().get("errors"));
+        //none of this is known and should you ever do this
+        Map<String, Object> properties = new HashMap<>();
+        notification.setFinished(notification.getModified());
+        properties.put("finished", notification.getModified());
+        properties.put("state", notification.getState());
+        LOG.info("done sending to devices in {} ms", notification.getFinished() - notification.getStarted());
+        notification.addProperties(properties);
+
+        LOG.info("notification finished batch: {} of {} devices", notification.getUuid(), totals);
+        em.update(notification);
 //        Set<Notifier> notifiers = new HashSet<>(proxy.getNotifierMap().values()); // remove dups
 //        proxy.asyncCheckForInactiveDevices(notifiers);
-        }
     }
 }
\ No newline at end of file