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/23 16:43:23 UTC
[1/2] git commit: Revert "simple stats"
Repository: incubator-usergrid
Updated Branches:
refs/heads/two-dot-o 483abcecd -> 2004ec994
Revert "simple stats"
This reverts commit d046ca1a0778fafdc0576c671d6a009cce6d8a37.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e3238ed9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e3238ed9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e3238ed9
Branch: refs/heads/two-dot-o
Commit: e3238ed958aa907885f32e9eb69f85f56b008d46
Parents: 483abce
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Sep 23 08:42:17 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Sep 23 08:42:17 2014 -0600
----------------------------------------------------------------------
.../notifications/SingleQueueTaskManager.java | 41 +++++++++++++++++---
1 file changed, 36 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e3238ed9/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 75b2212..2313853 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
@@ -153,9 +153,35 @@ public class SingleQueueTaskManager implements NotificationsTaskManager {
Notification notification = em.get(this.notification.getUuid(), Notification.class);
notification.setModified(System.currentTimeMillis());
- long sent = successes,errors = failures;
- //and write them out again, this will produce the most accurate count
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");
+ }
+ }
+
+ //and write them out again, this will produce the most accurate count
stats = new HashMap<String, Long>(2);
stats.put("sent", sent);
stats.put("errors", errors);
@@ -165,17 +191,22 @@ 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<>(proxy.getNotifierMap().values()); // remove dups
-// proxy.asyncCheckForInactiveDevices(notifiers);
+ // Set<Notifier> notifiers = new HashSet<Notifier>(proxy.getNotifierMap().values()); // remove dups
+ //proxy.asyncCheckForInactiveDevices(notifiers);
+ }
+
+
+ protected void hasFinished(boolean hasFinished) {
+ this.hasFinished = hasFinished;
}
}
\ No newline at end of file
[2/2] git commit: fix payload parsing
Posted by sf...@apache.org.
fix payload parsing
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/2004ec99
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/2004ec99
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/2004ec99
Branch: refs/heads/two-dot-o
Commit: 2004ec9945159e4ceb0bca07acf93d3b482526a6
Parents: e3238ed
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Sep 23 08:26:30 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Sep 23 08:42:38 2014 -0600
----------------------------------------------------------------------
.../usergrid/persistence/entities/Receipt.java | 20 +++++++++++++++++++-
.../notifications/ApplicationQueueManager.java | 2 +-
2 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2004ec99/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Receipt.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Receipt.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Receipt.java
index 1ffc351..1e145ac 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Receipt.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Receipt.java
@@ -20,8 +20,10 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.apache.usergrid.persistence.TypedEntity;
import javax.xml.bind.annotation.XmlRootElement;
+import java.util.HashMap;
import java.util.UUID;
import org.apache.usergrid.persistence.annotations.EntityProperty;
+import org.mortbay.util.ajax.JSON;
@XmlRootElement
public class Receipt extends TypedEntity {
@@ -66,7 +68,23 @@ public class Receipt extends TypedEntity {
public Receipt(UUID notificationUUID, String notifierId, Object payload,UUID deviceId) {
this.notificationUUID = notificationUUID;
this.notifierId = notifierId;
- this.payload = payload;
+ HashMap receiptPayload;
+ if(! (payload instanceof HashMap) ){
+ if(payload instanceof String){
+ try {
+ receiptPayload = (HashMap) JSON.parse((String) payload);
+ }catch (Exception e){
+ receiptPayload = new HashMap<>();
+ receiptPayload.put("payload", payload);
+ }
+ }else {
+ receiptPayload = new HashMap<>();
+ receiptPayload.put("payload", payload);
+ }
+ }else{
+ receiptPayload = (HashMap)payload;
+ }
+ this.payload = receiptPayload;
this.setDeviceId(deviceId);
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2004ec99/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 ee988dc..d110b95 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
@@ -353,7 +353,7 @@ public class ApplicationQueueManager implements QueueManager {
}
} catch (Exception e) {
- LOG.error("Failure unknown",e);
+ LOG.error("Failure while sending",e);
}
return message;
}