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/26 17:50:01 UTC

git commit: simpler statistics

Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o b9febe910 -> 83d12aaa5


simpler statistics


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

Branch: refs/heads/two-dot-o
Commit: 83d12aaa542c78d75325755380882522b270419d
Parents: b9febe9
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Sep 26 09:49:41 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Sep 26 09:49:41 2014 -0600

----------------------------------------------------------------------
 .../notifications/SingleQueueTaskManager.java   | 43 +++-----------------
 1 file changed, 6 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/83d12aaa/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 ff2c458..75b2212 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
@@ -123,7 +123,7 @@ public class SingleQueueTaskManager implements NotificationsTaskManager {
             receipt.setUuid(savedReceipt.getUuid());
 
             List<EntityRef> entities = Arrays.asList(notification, device);
-            em.addToCollections(entities, Notification.RECEIPTS_COLLECTION, savedReceipt);
+//            em.addToCollections(entities, Notification.RECEIPTS_COLLECTION, savedReceipt);
         } else {
             em.update(receipt);
         }
@@ -153,35 +153,9 @@ public class SingleQueueTaskManager implements NotificationsTaskManager {
         Notification notification = em.get(this.notification.getUuid(), Notification.class);
         notification.setModified(System.currentTimeMillis());
 
-        Map<String, Long> stats;
-        String statsKey = "statistics_batch";
-        Map<String, Object> properties;
-        //write out current results to a set so no overlap in multiple writes will occur
-        if (successes + failures > 0) {
-            properties = new HashMap<String, Object>(4);
-            stats = new HashMap<String, Long>(2);
-            stats.put("sent", successes);
-            stats.put("errors", failures);
-            properties.put(statsKey + "_" + System.currentTimeMillis(), stats);
-            properties.put("modified", notification.getModified());
-            notification.addProperties(properties);
-            em.update(notification);
-        }
-
-        //resum the stats
-        notification = em.get(this.notification.getUuid(), Notification.class); // re-read
-        properties = notification.getProperties();
-        long sent = 0;
-        long errors = 0;
-        for (String key : properties.keySet()) {
-            if (key.contains(statsKey)) {
-                stats = (Map<String, Long>) properties.get(key);
-                sent += stats.get("sent");
-                errors += stats.get("errors");
-            }
-        }
-
+        long sent = successes,errors = failures;
         //and write them out again, this will produce the most accurate count
+        Map<String, Long> stats;
         stats = new HashMap<String, Long>(2);
         stats.put("sent", sent);
         stats.put("errors", errors);
@@ -191,22 +165,17 @@ public class SingleQueueTaskManager implements NotificationsTaskManager {
 
         //none of this is known and should you ever do this
         if (notification.getExpectedCount() <= (errors + sent)) {
+            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: {}", notification.getUuid());
         em.update(notification);
 
-       // Set<Notifier> notifiers = new HashSet<Notifier>(proxy.getNotifierMap().values()); // remove dups
-        //proxy.asyncCheckForInactiveDevices(notifiers);
-    }
-
-
-    protected void hasFinished(boolean hasFinished) {
-        this.hasFinished = hasFinished;
+//        Set<Notifier> notifiers = new HashSet<>(proxy.getNotifierMap().values()); // remove dups
+//        proxy.asyncCheckForInactiveDevices(notifiers);
     }
 }
\ No newline at end of file