You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2015/03/04 18:25:13 UTC
[04/14] incubator-usergrid git commit: changing app delete logic in
test
changing app delete logic in test
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/f0b11c62
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/f0b11c62
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/f0b11c62
Branch: refs/heads/two-dot-o
Commit: f0b11c62101db82b41a0614224d52e53342c276b
Parents: 9f521c7
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Mar 2 11:00:39 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Mar 2 11:00:39 2015 -0700
----------------------------------------------------------------------
.../cassandra/EntityManagerFactoryImplIT.java | 55 ++++++++++++--------
.../services/notifications/QueueListener.java | 10 ++--
.../resources/usergrid-custom-test.properties | 3 ++
3 files changed, 43 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f0b11c62/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
index c3bc020..20bf7eb 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
@@ -39,6 +39,7 @@ import org.apache.usergrid.persistence.cassandra.util.TraceTagManager;
import org.apache.usergrid.persistence.cassandra.util.TraceTagReporter;
import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import org.apache.usergrid.setup.ConcurrentProcessSingleton;
+import rx.functions.Func0;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -97,7 +98,7 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
// create an application with a collection and an entity
- UUID applicationId = setup.createApplication( "test-org-" + rand, "test-app-" + rand );
+ final UUID applicationId = setup.createApplication( "test-org-" + rand, "test-app-" + rand );
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -122,16 +123,35 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
em.refreshIndex();
+ Func0<Boolean> func0 = new Func0<Boolean>() {
+ @Override
+ public Boolean call() {
+ try {
+ boolean found = false;
+ Map<String, UUID> deletedApps = emf.getDeletedApplications();
+ for (String appName : deletedApps.keySet()) {
+ UUID appId = deletedApps.get(appName);
+ if (appId.equals(applicationId)) {
+ found = true;
+ break;
+ }
+ }
+ return found;
+ }catch (Exception e){
+ throw new RuntimeException(e);
+ }
+ }
+ };
+
boolean found = false;
- Map<String, UUID> deletedApps = emf.getDeletedApplications();
- for ( String appName : deletedApps.keySet() ) {
- UUID appId = deletedApps.get( appName );
- if ( appId.equals( applicationId )) {
- found = true;
+ for(int i=0;i<5;i++){
+ found = func0.call();
+ if(found){
break;
+ } else{
+ Thread.sleep(100);
}
}
-
assertTrue("Deleted app not found in deleted apps collection", found );
// attempt to get entities in application's collections in various ways should all fail
@@ -159,26 +179,17 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
// test to see that app now works and is happy
// it should not be found in the deleted apps collection
- found = false;
- deletedApps = emf.getDeletedApplications();
- for ( String appName : deletedApps.keySet() ) {
- UUID appId = deletedApps.get( appName );
- if ( appId.equals( applicationId )) {
- found = true;
+ for(int i=0;i<5;i++){
+ found = func0.call();
+ if(!found){
break;
+ } else{
+ Thread.sleep(100);
}
}
assertFalse("Restored app found in deleted apps collection", found);
- found = false;
- appMap = setup.getEmf().getApplications();
- for ( String appName : appMap.keySet() ) {
- UUID appId = appMap.get( appName );
- if ( appId.equals( applicationId )) {
- found = true;
- break;
- }
- }
+ found = func0.call();
assertTrue("Restored app not found in apps collection", found);
// TODO: this assertion should work!
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f0b11c62/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 5247a25..df27d2b 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
@@ -41,7 +41,9 @@ import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
-
+/**
+ * Singleton listens for notifications queue messages
+ */
public class QueueListener {
public final int MESSAGE_TRANSACTION_TIMEOUT = 25 * 1000;
private final QueueManagerFactory queueManagerFactory;
@@ -83,10 +85,8 @@ public class QueueListener {
this.metricsService = smf.getApplicationContext().getBean( Injector.class ).getInstance(MetricsFactory.class);
this.properties = props;
this.queueScopeFactory = smf.getApplicationContext().getBean( Injector.class ).getInstance(QueueScopeFactory.class);
-
}
-
/**
* Start the service and begin consuming messages
*/
@@ -99,6 +99,10 @@ public class QueueListener {
int threadCount = 0;
try {
+ boolean shouldRun = new Boolean(properties.getProperty("usergrid.notifications.listener.run","true"));
+ if(!shouldRun){
+ return;
+ }
sleepBetweenRuns = new Long(properties.getProperty("usergrid.notifications.listener.sleep.between", ""+sleepBetweenRuns)).longValue();
sleepWhenNoneFound = new Long(properties.getProperty("usergrid.notifications.listener.sleep.after", ""+DEFAULT_SLEEP)).longValue();
batchSize = new Integer(properties.getProperty("usergrid.notifications.listener.batchSize", (""+batchSize)));
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f0b11c62/stack/services/src/test/resources/usergrid-custom-test.properties
----------------------------------------------------------------------
diff --git a/stack/services/src/test/resources/usergrid-custom-test.properties b/stack/services/src/test/resources/usergrid-custom-test.properties
index 60e06a1..1ddfead 100644
--- a/stack/services/src/test/resources/usergrid-custom-test.properties
+++ b/stack/services/src/test/resources/usergrid-custom-test.properties
@@ -27,3 +27,6 @@ notification.concurrent.batches=2
hystrix.threadpool.graph_user.coreSize=50
hystrix.threadpool.graph_async.coreSize=50
usergrid.scheduler.job.timeout=300000
+
+usergrid.notifications.listener.run=false
+