You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/10/01 16:51:39 UTC
[03/35] git commit: removing unnecessary updates
removing unnecessary updates
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/05f56db1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/05f56db1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/05f56db1
Branch: refs/heads/two-dot-o-rebuildable-index
Commit: 05f56db1277c82d1032840bf5a98aaffc9febcfd
Parents: 05caf49
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Sep 26 13:29:17 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Sep 26 13:29:17 2014 -0600
----------------------------------------------------------------------
.../notifications/ApplicationQueueManager.java | 4 ++-
.../services/notifications/JobScheduler.java | 1 +
.../notifications/NotificationsService.java | 7 ++---
.../notifications/NotificationsTaskManager.java | 33 --------------------
.../notifications/SingleQueueTaskManager.java | 2 +-
.../services/notifications/TaskTracker.java | 4 +--
6 files changed, 9 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/05f56db1/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 766cb75..4bd0cde 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
@@ -91,6 +91,9 @@ public class ApplicationQueueManager implements QueueManager {
}
public void queueNotification(final Notification notification, final JobExecution jobExecution) throws Exception {
+ if(scheduleQueueJob(notification)){
+ return;
+ }
final Meter queueMeter = metricsFactory.getMeter(ApplicationQueueManager.class,"queue");
long startTime = System.currentTimeMillis();
@@ -171,7 +174,6 @@ public class ApplicationQueueManager implements QueueManager {
// update queued time
now = System.currentTimeMillis();
notification.setQueued(System.currentTimeMillis());
- em.update(notification);
LOG.info("ApplicationQueueMessage: notification {} device {} queue time set. duration "+(System.currentTimeMillis()-now)+" ms", notification.getUuid(), deviceRef.getUuid());
}
now = System.currentTimeMillis();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/05f56db1/stack/services/src/main/java/org/apache/usergrid/services/notifications/JobScheduler.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/JobScheduler.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/JobScheduler.java
index 6015a0a..a9acd95 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/JobScheduler.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/JobScheduler.java
@@ -74,6 +74,7 @@ public class JobScheduler{
SchedulerService scheduler = getSchedulerService();
scheduler.createJob("queueJob", scheduleAt, jobData);
LOG.info("notification {} scheduled for queuing", notification.getUuid());
+ em.update(notification);
}
return scheduled;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/05f56db1/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
index f45750c..4e5692e 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
@@ -143,15 +143,12 @@ public class NotificationsService extends AbstractCollectionService {
Map<String, Object> properties = new HashMap<String, Object>(2);
properties.put("started", notification.getStarted());
properties.put("state", notification.getState());
- em.updateProperties(notification, properties);
+ notification.addProperties(properties);
LOG.info("ApplicationQueueMessage: notification {} properties updated in duration {} ms", notification.getUuid(),System.currentTimeMillis() - now);
}
long now = System.currentTimeMillis();
- if(!notificationQueueManager.scheduleQueueJob(notification)){
- notificationQueueManager.queueNotification(notification, null);
- }
-
+ notificationQueueManager.queueNotification(notification, null);
LOG.info("NotificationService: notification {} post queue duration {} ms ", notification.getUuid(),System.currentTimeMillis() - now);
// future: somehow return 202?
return results;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/05f56db1/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsTaskManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsTaskManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsTaskManager.java
deleted file mode 100644
index 0869f73..0000000
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsTaskManager.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.services.notifications;
-
-import org.apache.usergrid.persistence.entities.Notifier;
-import org.apache.usergrid.persistence.entities.Receipt;
-
-import java.util.UUID;
-
-public interface NotificationsTaskManager {
-
- void completed(Notifier notifier, Receipt receipt, UUID deviceUUID,
- String newProviderId) throws Exception;
-
- void failed(Notifier notifier, Receipt receipt, UUID deviceUUID, Object code,
- String message) throws Exception;
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/05f56db1/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 f87f497..e89267d 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
@@ -30,7 +30,7 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
-public class SingleQueueTaskManager implements NotificationsTaskManager {
+public class SingleQueueTaskManager {
private static final Logger LOG = LoggerFactory
.getLogger(SingleQueueTaskManager.class);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/05f56db1/stack/services/src/main/java/org/apache/usergrid/services/notifications/TaskTracker.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/TaskTracker.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/TaskTracker.java
index 322c4bf..8dfa0dc 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/TaskTracker.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/TaskTracker.java
@@ -26,11 +26,11 @@ import java.util.UUID;
public class TaskTracker {
private Notifier notifier;
- private NotificationsTaskManager taskManager;
+ private SingleQueueTaskManager taskManager;
private Receipt receipt;
private UUID deviceId;
- public TaskTracker(Notifier notifier, NotificationsTaskManager taskManager, Receipt receipt, UUID deviceId) {
+ public TaskTracker(Notifier notifier, SingleQueueTaskManager taskManager, Receipt receipt, UUID deviceId) {
this.notifier = notifier;
this.taskManager = taskManager;
this.receipt = receipt;