usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject [1/7] usergrid git commit: Cherrypicking first of the changes to account for future possible instances of the class cast exception
Date Tue, 07 Jun 2016 16:32:32 GMT
Repository: usergrid
Updated Branches:
  refs/heads/release-2.1.1 38909adaa -> 3df07791c


Cherrypicking first of the changes to account for future possible instances of the class cast
exception


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

Branch: refs/heads/release-2.1.1
Commit: c46e1b6871516009edeb4ab1a35603850f3645d8
Parents: 6b195a0
Author: George Reyes <grey@apache.org>
Authored: Fri May 6 15:36:11 2016 -0700
Committer: George Reyes <grey@apache.org>
Committed: Fri May 6 15:36:11 2016 -0700

----------------------------------------------------------------------
 .../persistence/entities/Notification.java      | 37 +++++++++-----
 .../impl/ApplicationQueueManagerImpl.java       | 52 +++++++++++++++-----
 .../AbstractServiceNotificationIT.java          | 26 ++++------
 3 files changed, 75 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/c46e1b68/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
index d4f3529..bb2e03f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
@@ -17,18 +17,28 @@
 package org.apache.usergrid.persistence.entities;
 
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
 import javax.xml.bind.annotation.XmlRootElement;
-import java.util.*;
 
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import org.apache.usergrid.persistence.*;
+import org.apache.usergrid.persistence.EntityRef;
+import org.apache.usergrid.persistence.PathQuery;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.SimpleEntityRef;
+import org.apache.usergrid.persistence.TypedEntity;
 import org.apache.usergrid.persistence.annotations.EntityCollection;
 import org.apache.usergrid.persistence.annotations.EntityProperty;
 import org.apache.usergrid.persistence.index.query.Identifier;
 import org.apache.usergrid.utils.InflectionUtils;
 
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
 /**
  * The entity class for representing Notifications.
  */
@@ -112,7 +122,7 @@ public class Notification extends TypedEntity {
 
     /** Map containing a count for "sent" and "errors" */
     @EntityProperty
-    protected Map<String, Long> statistics;
+    protected Map<String, Object> statistics;
 
     @EntityProperty
     protected Map<String, Object> filters;
@@ -275,11 +285,11 @@ public class Notification extends TypedEntity {
     }
 
     @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-    public Map<String, Long> getStatistics() {
+    public Map<String, Object> getStatistics() {
         return statistics;
     }
 
-    public void setStatistics(Map<String, Long> statistics) {
+    public void setStatistics(Map<String, Object> statistics) {
         this.statistics = statistics;
     }
 
@@ -294,13 +304,18 @@ public class Notification extends TypedEntity {
 
     public void updateStatistics(long sent, long errors) {
         if (this.statistics == null) {
-            this.statistics = new HashMap<String, Long>(2);
+            this.statistics = new HashMap<String, Object>(2);
             this.statistics.put("sent", sent);
             this.statistics.put("errors", errors);
         } else {
-            this.statistics.put("sent", sent + this.statistics.get("sent"));
-            this.statistics.put("errors",
-                    errors + this.statistics.get("errors"));
+            if(this.statistics.get( "sent" ) instanceof Integer){
+                this.statistics.put( "sent", sent + (Integer) this.statistics.get( "sent"
) );
+                this.statistics.put( "errors", errors + (Integer) this.statistics.get( "errors"
) );
+            }
+            else if (this.statistics.get( "sent" ) instanceof Long ) {
+                this.statistics.put( "sent", sent + (Long) this.statistics.get( "sent" )
);
+                this.statistics.put( "errors", errors + (Long) this.statistics.get( "errors"
) );
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/c46e1b68/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
b/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
index eb5d794..23b21f2 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
@@ -16,29 +16,55 @@
  */
 package org.apache.usergrid.services.notifications.impl;
 
-import com.codahale.metrics.Meter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.usergrid.batch.JobExecution;
-import org.apache.usergrid.persistence.*;
-import org.apache.usergrid.persistence.core.executor.TaskExecutorFactory;
-import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
-import org.apache.usergrid.persistence.entities.*;
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.EntityRef;
+import org.apache.usergrid.persistence.PathQuery;
 import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.SimpleEntityRef;
+import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
+import org.apache.usergrid.persistence.entities.Device;
+import org.apache.usergrid.persistence.entities.Notification;
+import org.apache.usergrid.persistence.entities.Notifier;
+import org.apache.usergrid.persistence.entities.Receipt;
+import org.apache.usergrid.persistence.entities.User;
 import org.apache.usergrid.persistence.index.utils.UUIDUtils;
 import org.apache.usergrid.persistence.queue.QueueManager;
 import org.apache.usergrid.persistence.queue.QueueMessage;
-import org.apache.usergrid.services.notifications.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.usergrid.services.notifications.ApplicationQueueManager;
+import org.apache.usergrid.services.notifications.ApplicationQueueMessage;
+import org.apache.usergrid.services.notifications.JobScheduler;
+import org.apache.usergrid.services.notifications.NotificationsService;
+import org.apache.usergrid.services.notifications.ProviderAdapter;
+import org.apache.usergrid.services.notifications.ProviderAdapterFactory;
+import org.apache.usergrid.services.notifications.TaskManager;
+import org.apache.usergrid.services.notifications.TaskTracker;
+
+import com.codahale.metrics.Meter;
+
 import rx.Observable;
-import rx.Scheduler;
 import rx.Subscriber;
 import rx.functions.Func1;
 import rx.schedulers.Schedulers;
 
-import java.io.IOException;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicInteger;
 
 
 public class ApplicationQueueManagerImpl implements ApplicationQueueManager {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/c46e1b68/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
b/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
index 91b94b2..775827e 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
@@ -16,24 +16,18 @@
  */
 package org.apache.usergrid.services.notifications;
 
-import org.apache.usergrid.persistence.*;
-import org.apache.usergrid.persistence.entities.Notification;
-import org.apache.usergrid.persistence.entities.Receipt;
-import org.apache.usergrid.persistence.Query;
-import org.apache.usergrid.services.ServiceManagerFactory;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.usergrid.persistence.EntityRef;
+import org.apache.usergrid.persistence.PathQuery;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.SimpleEntityRef;
+import org.apache.usergrid.persistence.entities.Notification;
+import org.apache.usergrid.persistence.entities.Receipt;
 import org.apache.usergrid.services.AbstractServiceIT;
-import org.springframework.beans.factory.annotation.Autowired;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -106,17 +100,17 @@ public abstract class AbstractServiceNotificationIT extends AbstractServiceIT
{
     }
 
     protected void checkStatistics(Notification notification, long sent,  long errors) throws
Exception{
-        Map<String, Long> statistics = null;
+        Map<String, Object> statistics = null;
         long timeout = System.currentTimeMillis() + 10000;
         while (System.currentTimeMillis() < timeout) {
             Thread.sleep(200);
             statistics = app.getEntityManager().get(notification.getUuid(), Notification.class).getStatistics();
-            if (statistics.get("sent")==sent && statistics.get("errors")==errors)
{
+            if ((Long)statistics.get("sent")==sent && (Long)statistics.get("errors")==errors)
{
                 break;
             }
         }
-        assertEquals(sent, statistics.get("sent").longValue());
-        assertEquals(errors, statistics.get("errors").longValue());
+        assertEquals(sent, ((Long)statistics.get("sent")).longValue());
+        assertEquals(errors, ((Long)statistics.get("errors")).longValue());
     }
 
 }


Mime
View raw message