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/10/07 19:29:11 UTC
[1/3] git commit: one less update in the case of no devices
Repository: incubator-usergrid
Updated Branches:
refs/heads/two-dot-o bdb979583 -> ba47088b9
one less update in the case of no devices
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/ef8a8c6e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/ef8a8c6e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/ef8a8c6e
Branch: refs/heads/two-dot-o
Commit: ef8a8c6e34aa41b7d47395405b4a469a0771a474
Parents: bdb9795
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Oct 7 11:15:24 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Oct 7 11:15:24 2014 -0600
----------------------------------------------------------------------
.../services/notifications/ApplicationQueueManager.java | 11 +++++------
.../usergrid/services/notifications/TaskManager.java | 8 ++++++--
2 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ef8a8c6e/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 5d2e554..b36d1fe 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
@@ -223,7 +223,6 @@ public class ApplicationQueueManager {
notification.addProperties(properties);
long now = System.currentTimeMillis();
- em.update(notification);
LOG.info("notification {} updated notification duration {} ms", notification.getUuid(),System.currentTimeMillis() - now);
@@ -231,13 +230,13 @@ public class ApplicationQueueManager {
if (deviceCount.get() <= 0) {
TaskManager taskManager = new TaskManager(em, this, notification);
//if i'm in a test value will be false, do not mark finished for test orchestration, not ideal need real tests
- taskManager.finishedBatch();
+ taskManager.finishedBatch(false);
}
- if (LOG.isInfoEnabled()) {
- long elapsed = notification.getQueued() != null ? notification.getQueued() - startTime : 0;
- LOG.info("notification {} done queuing to {} devices in "+elapsed+" ms",notification.getUuid().toString(),deviceCount.get());
- }
+ em.update(notification);
+
+ long elapsed = notification.getQueued() != null ? notification.getQueued() - startTime : 0;
+ LOG.info("notification {} done queuing to {} devices in " + elapsed + " ms", notification.getUuid().toString(), deviceCount.get());
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ef8a8c6e/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 ecbda93..0baa17f 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
@@ -134,8 +134,10 @@ public class TaskManager {
}
}
}
-
public void finishedBatch() throws Exception {
+ finishedBatch(true);
+ }
+ public void finishedBatch(boolean update) throws Exception {
long successes = this.successes.get(); //reset counters
long failures = this.failures.get(); //reset counters
for (int i = 0; i < successes; i++) {
@@ -167,7 +169,9 @@ public class TaskManager {
notification.addProperties(properties);
LOG.info("notification finished batch: {} of {} devices", notification.getUuid(), totals);
- em.update(notification);
+ if (update){
+ em.update(notification);
+ }
// Set<Notifier> notifiers = new HashSet<>(proxy.getNotifierMap().values()); // remove dups
// proxy.asyncCheckForInactiveDevices(notifiers);
}
[2/3] git commit: adding metrics
Posted by sf...@apache.org.
adding metrics
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/9c1e4aba
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/9c1e4aba
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/9c1e4aba
Branch: refs/heads/two-dot-o
Commit: 9c1e4aba92b6b1ac960feff031580182d19e5381
Parents: ef8a8c6
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Oct 7 11:22:02 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Oct 7 11:22:02 2014 -0600
----------------------------------------------------------------------
.../usergrid/services/notifications/QueueListener.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9c1e4aba/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 c5419c4..a69afe2 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
@@ -16,10 +16,11 @@
*/
package org.apache.usergrid.services.notifications;
+import com.codahale.metrics.*;
+import com.codahale.metrics.Timer;
import org.apache.usergrid.corepersistence.CpSetup;
import org.apache.usergrid.metrics.MetricsFactory;
-import org.apache.usergrid.mq.QueueResults;
import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.EntityManagerFactory;
@@ -31,7 +32,6 @@ import org.apache.usergrid.services.ServiceManager;
import org.apache.usergrid.services.ServiceManagerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import rx.Observable;
import javax.annotation.PostConstruct;
import java.util.*;
@@ -126,11 +126,13 @@ public class QueueListener {
}
private void execute(){
-// Thread.currentThread().setDaemon(true);
+ Thread.currentThread().setDaemon(true);
Thread.currentThread().setName("Notifications_Processor"+UUID.randomUUID());
final AtomicInteger consecutiveExceptions = new AtomicInteger();
LOG.info("QueueListener: Starting execute process.");
+ Meter meter = metricsService.getMeter(QueueListener.class, "queue");
+ com.codahale.metrics.Timer timer = metricsService.getTimer(QueueListener.class, "dequeue");
// run until there are no more active jobs
while ( true ) {
@@ -139,10 +141,12 @@ public class QueueListener {
LOG.info("getting from queue {} ", queueName);
QueueScope queueScope = new QueueScopeImpl(new SimpleId(smf.getManagementAppId(),"notifications"),queueName);
QueueManager queueManager = TEST_QUEUE_MANAGER != null ? TEST_QUEUE_MANAGER : queueManagerFactory.getQueueManager(queueScope);
+ Timer.Context timerContext = timer.time();
List<QueueMessage> messages = queueManager.getMessages(getBatchSize(), MESSAGE_TRANSACTION_TIMEOUT, 5000, ApplicationQueueMessage.class);
LOG.info("retrieved batch of {} messages from queue {} ", messages.size(),queueName);
if (messages.size() > 0) {
+
HashMap<UUID, List<QueueMessage>> messageMap = new HashMap<>(messages.size());
//group messages into hash map by app id
for (QueueMessage message : messages) {
@@ -183,6 +187,7 @@ public class QueueListener {
merge.toBlocking().lastOrDefault(null);
}
queueManager.commitMessages(messages);
+ meter.mark(messages.size());
LOG.info("sent batch {} messages duration {} ms", messages.size(),System.currentTimeMillis() - now);
if(sleepBetweenRuns > 0) {
@@ -194,6 +199,7 @@ public class QueueListener {
LOG.info("no messages...sleep...{}", sleepWhenNoneFound);
Thread.sleep(sleepWhenNoneFound);
}
+ timerContext.stop();
//send to the providers
consecutiveExceptions.set(0);
}catch (Exception ex){
[3/3] git commit: fixing tests
Posted by sf...@apache.org.
fixing tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/ba47088b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/ba47088b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/ba47088b
Branch: refs/heads/two-dot-o
Commit: ba47088b9efed03eaca1a480a58e4e33b93a4e2b
Parents: 9c1e4ab
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Oct 7 11:28:57 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Oct 7 11:28:57 2014 -0600
----------------------------------------------------------------------
.../services/notifications/ApplicationQueueManager.java | 2 +-
.../apache/usergrid/services/notifications/QueueListener.java | 4 +++-
.../apache/usergrid/services/notifications/TaskManager.java | 7 ++++---
3 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ba47088b/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 b36d1fe..7728111 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
@@ -230,7 +230,7 @@ public class ApplicationQueueManager {
if (deviceCount.get() <= 0) {
TaskManager taskManager = new TaskManager(em, this, notification);
//if i'm in a test value will be false, do not mark finished for test orchestration, not ideal need real tests
- taskManager.finishedBatch(false);
+ taskManager.finishedBatch(false,false);
}
em.update(notification);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ba47088b/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 a69afe2..cfeebf5 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
@@ -126,7 +126,9 @@ public class QueueListener {
}
private void execute(){
- Thread.currentThread().setDaemon(true);
+ if(Thread.currentThread().isDaemon()) {
+ Thread.currentThread().setDaemon(true);
+ }
Thread.currentThread().setName("Notifications_Processor"+UUID.randomUUID());
final AtomicInteger consecutiveExceptions = new AtomicInteger();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ba47088b/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 0baa17f..4b55e95 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
@@ -135,9 +135,9 @@ public class TaskManager {
}
}
public void finishedBatch() throws Exception {
- finishedBatch(true);
+ finishedBatch(true,true);
}
- public void finishedBatch(boolean update) throws Exception {
+ public void finishedBatch(boolean update, boolean fetch) throws Exception {
long successes = this.successes.get(); //reset counters
long failures = this.failures.get(); //reset counters
for (int i = 0; i < successes; i++) {
@@ -150,7 +150,8 @@ public class TaskManager {
this.hasFinished = true;
// refresh notification
- Notification notification = em.get(this.notification.getUuid(), Notification.class);
+ if(fetch)
+ notification = em.get(this.notification.getUuid(), Notification.class);
notification.setModified(System.currentTimeMillis());
//and write them out again, this will produce the most accurate count