usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [2/2] git commit: adding notification expiration message
Date Mon, 08 Sep 2014 15:50:57 GMT
adding notification expiration message


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

Branch: refs/heads/two-dot-o
Commit: e1ddd47c3762cec531f5ba778d44445a06d633e8
Parents: 1f1b264
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Mon Sep 8 09:34:10 2014 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Mon Sep 8 09:34:10 2014 -0600

----------------------------------------------------------------------
 .../notifications/apns/APNsAdapter.java         | 26 +++++++++++---------
 1 file changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e1ddd47c/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
index ded9ac7..82cd4b9 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
@@ -102,10 +102,6 @@ public class APNsAdapter implements ProviderAdapter {
     public void sendNotification(String providerId, Notifier notifier,
             Object payload, Notification notification, TaskTracker tracker)
             throws Exception {
-        if(isMock(notifier)){
-            tracker.completed("Mocked!");
-            return;
-        }
         APNsNotification apnsNotification = APNsNotification.create(providerId, payload.toString(),
notification, tracker);
         PushManager<SimpleApnsPushNotification> pushManager = getPushManager(notifier);
         try {
@@ -168,27 +164,35 @@ public class APNsAdapter implements ProviderAdapter {
 
     //cache to retrieve push manager, cached per notifier, so many notifications will get
same push manager
     private static LoadingCache<Notifier, PushManager<SimpleApnsPushNotification>>
apnsServiceMap = CacheBuilder
-            .newBuilder().expireAfterAccess(10, TimeUnit.MINUTES)
+            .newBuilder()
+            .expireAfterAccess(10, TimeUnit.MINUTES)
             .removalListener(new RemovalListener<Notifier, PushManager<SimpleApnsPushNotification>>()
{
                 @Override
                 public void onRemoval(
                         RemovalNotification<Notifier, PushManager<SimpleApnsPushNotification>>
notification) {
                     try {
                         PushManager<SimpleApnsPushNotification> manager = notification.getValue();
-                        if(!manager.isShutDown()){
-                            notification.getValue().shutdown();
+                        if (!manager.isShutDown()) {
+                            List<SimpleApnsPushNotification> notifications = manager.shutdown(3000);
+                            for (SimpleApnsPushNotification notification1 : notifications)
{
+                                try {
+                                    ((APNsNotification) notification1).messageSendFailed(new
Exception("Cache Expired: Shutting down sender"));
+                                }catch (Exception e){
+                                    logger.error("Failed to mark notification",e);
+                                }
+                            }
                         }
                     } catch (Exception ie) {
-                        logger.error("Failed to shutdown from cache",ie);
+                        logger.error("Failed to shutdown from cache", ie);
                     }
                 }
             }).build(new CacheLoader<Notifier, PushManager<SimpleApnsPushNotification>>()
{
                 @Override
                 public PushManager<SimpleApnsPushNotification> load(Notifier notifier)
{
-                    try{
+                    try {
                         return createApnsService(notifier);
-                    }catch (KeyStoreException ke){
-                        logger.error("Could not instantiate pushmanager",ke);
+                    } catch (KeyStoreException ke) {
+                        logger.error("Could not instantiate pushmanager", ke);
                         return null;
                     }
                 }


Mime
View raw message