Repository: usergrid Updated Branches: refs/heads/master 61878c008 -> 9b12299cc
For tests, ensure we clear the in memory set of queues that exist as keyspaces get dropped w/o new class instantiation. Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/9b12299c Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/9b12299c Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/9b12299c Branch: refs/heads/master Commit: 9b12299cc46a0143bd9a646ee7031c61669b1718 Parents: 61878c0 Author: Michael Russo <mru...@apigee.com> Authored: Fri Nov 18 23:32:17 2016 -0800 Committer: Michael Russo <mru...@apigee.com> Committed: Fri Nov 18 23:32:17 2016 -0800 ---------------------------------------------------------------------- .../usergrid/persistence/CoreSchemaManager.java | 14 +++----------- .../persistence/qakka/core/impl/QueueManagerImpl.java | 7 +++++-- .../persistence/queue/LegacyQueueManager.java | 5 +++++ .../usergrid/persistence/queue/LegacyQueueScope.java | 6 ++---- .../usergrid/persistence/queue/LocalQueueManager.java | 14 ++++++++++++++ .../usergrid/persistence/queue/guice/QueueModule.java | 1 + .../persistence/queue/impl/LegacyQueueScopeImpl.java | 3 --- .../persistence/queue/impl/QakkaQueueManager.java | 9 +++++++-- .../persistence/queue/impl/SNSQueueManagerImpl.java | 5 +++++ .../usergrid/services/queues/ImportQueueManager.java | 5 +++++ 10 files changed, 47 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/usergrid/blob/9b12299c/stack/core/src/test/java/org/apache/usergrid/persistence/CoreSchemaManager.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CoreSchemaManager.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CoreSchemaManager.java index 28f2c9f..d5687cf 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/CoreSchemaManager.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CoreSchemaManager.java @@ -18,6 +18,7 @@ package org.apache.usergrid.persistence; import org.apache.usergrid.locking.LockManager; +import org.apache.usergrid.persistence.queue.impl.QakkaQueueManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -88,18 +89,9 @@ public class CoreSchemaManager implements SchemaManager { catch ( RuntimeException ire ) { //swallow if it just doesn't exist } - - - try { - cluster.dropKeyspace( CassandraService.getApplicationKeyspace() ); - } - catch ( RuntimeException ire ) { - //swallow if it just doesn't exist - } - logger.info( "keyspaces dropped" ); - - + SpringResource.getInstance().getBean( Injector.class ).getInstance( QakkaQueueManager.class ); + logger.info( "dropping indices" ); final EsProvider provider = SpringResource.getInstance().getBean( Injector.class ).getInstance( EsProvider.class ); http://git-wip-us.apache.org/repos/asf/usergrid/blob/9b12299c/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/qakka/core/impl/QueueManagerImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/qakka/core/impl/QueueManagerImpl.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/qakka/core/impl/QueueManagerImpl.java index 88d307c..5b00d53 100644 --- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/qakka/core/impl/QueueManagerImpl.java +++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/qakka/core/impl/QueueManagerImpl.java @@ -20,7 +20,6 @@ package org.apache.usergrid.persistence.qakka.core.impl; import com.google.inject.Inject; -import com.google.inject.spi.Message; import org.apache.commons.lang3.StringUtils; import org.apache.usergrid.persistence.actorsystem.ActorSystemFig; import org.apache.usergrid.persistence.qakka.core.QakkaUtils; @@ -34,12 +33,15 @@ import org.apache.usergrid.persistence.qakka.serialization.queues.DatabaseQueue; import org.apache.usergrid.persistence.qakka.serialization.queues.QueueSerialization; import org.apache.usergrid.persistence.qakka.serialization.sharding.Shard; import org.apache.usergrid.persistence.qakka.serialization.sharding.ShardSerialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; public class QueueManagerImpl implements QueueManager { + private static final Logger logger = LoggerFactory.getLogger( QueueManagerImpl.class ); private final ActorSystemFig actorSystemFig; private final QueueSerialization queueSerialization; private final DistributedQueueService distributedQueueService; @@ -65,8 +67,9 @@ public class QueueManagerImpl implements QueueManager { @Override public void createQueue(Queue queue) { - List<String> regions = new ArrayList<>(); + logger.info("Creating queue with name: {}", queue.getName()); + List<String> regions = new ArrayList<>(); if ( Regions.LOCAL.equals( queue.getRegions() ) || StringUtils.isEmpty( queue.getRegions() ) ) { regions.add( actorSystemFig.getRegionLocal() ); http://git-wip-us.apache.org/repos/asf/usergrid/blob/9b12299c/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/LegacyQueueManager.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/LegacyQueueManager.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/LegacyQueueManager.java index afe229d..117ce1c 100644 --- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/LegacyQueueManager.java +++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/LegacyQueueManager.java @@ -84,4 +84,9 @@ public interface LegacyQueueManager { * purge messages */ void deleteQueue(); + + /** + * Clears the in memory hash set of created and available queues ( useful for tests that drop data and start over ) + */ + void clearQueueNameCache(); } http://git-wip-us.apache.org/repos/asf/usergrid/blob/9b12299c/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/LegacyQueueScope.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/LegacyQueueScope.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/LegacyQueueScope.java index 1f932b2..3856738 100644 --- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/LegacyQueueScope.java +++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/LegacyQueueScope.java @@ -18,8 +18,6 @@ */ package org.apache.usergrid.persistence.queue; -import org.apache.usergrid.persistence.core.scope.ApplicationScope; - public interface LegacyQueueScope { @@ -36,10 +34,10 @@ public interface LegacyQueueScope { * Get the name of the the map * @return */ - public String getName(); + String getName(); /** * Get the Usergrid region enum */ - public RegionImplementation getRegionImplementation(); + RegionImplementation getRegionImplementation(); } http://git-wip-us.apache.org/repos/asf/usergrid/blob/9b12299c/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/LocalQueueManager.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/LocalQueueManager.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/LocalQueueManager.java index 90621c0..7a793b4 100644 --- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/LocalQueueManager.java +++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/LocalQueueManager.java @@ -20,6 +20,8 @@ package org.apache.usergrid.persistence.queue; +import com.google.inject.Inject; +import com.google.inject.assistedinject.Assisted; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,6 +42,13 @@ public class LocalQueueManager implements LegacyQueueManager { public ArrayBlockingQueue<LegacyQueueMessage> queue = new ArrayBlockingQueue<>(10000); + private LegacyQueueScope scope; + + @Inject + public LocalQueueManager(@Assisted LegacyQueueScope scope){ + this.scope = scope; + } + @Override public List<LegacyQueueMessage> getMessages(int limit, Class klass) { List<LegacyQueueMessage> returnQueue = new ArrayList<>(); @@ -104,6 +113,11 @@ public class LocalQueueManager implements LegacyQueueManager { @Override public void deleteQueue() { + //no-op + } + @Override + public void clearQueueNameCache(){ + //no-op } } http://git-wip-us.apache.org/repos/asf/usergrid/blob/9b12299c/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueModule.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueModule.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueModule.java index 949f1f2..b38eeb8 100644 --- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueModule.java +++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/guice/QueueModule.java @@ -22,6 +22,7 @@ import com.google.inject.AbstractModule; import com.google.inject.assistedinject.FactoryModuleBuilder; import org.apache.usergrid.persistence.qakka.QakkaModule; import org.apache.usergrid.persistence.queue.*; +import org.apache.usergrid.persistence.queue.impl.LegacyQueueScopeImpl; import org.apache.usergrid.persistence.queue.impl.QakkaQueueManager; import org.apache.usergrid.persistence.queue.impl.QueueManagerFactoryImpl; import org.apache.usergrid.persistence.queue.impl.SNSQueueManagerImpl; http://git-wip-us.apache.org/repos/asf/usergrid/blob/9b12299c/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/LegacyQueueScopeImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/LegacyQueueScopeImpl.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/LegacyQueueScopeImpl.java index 51d6c03..9dd0421 100644 --- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/LegacyQueueScopeImpl.java +++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/LegacyQueueScopeImpl.java @@ -29,9 +29,6 @@ public class LegacyQueueScopeImpl implements LegacyQueueScope { this.regionImpl = regionImpl; } - - - @Override public String getName() { return name; http://git-wip-us.apache.org/repos/asf/usergrid/blob/9b12299c/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QakkaQueueManager.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QakkaQueueManager.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QakkaQueueManager.java index bdcd452..264e99c 100644 --- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QakkaQueueManager.java +++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/QakkaQueueManager.java @@ -71,9 +71,8 @@ public class QakkaQueueManager implements LegacyQueueManager { Queue queue = new Queue( scope.getName() ); queueManager.createQueue( queue ); + queueNames.add( scope.getName() ); } - - queueNames.add( scope.getName() ); } @@ -192,4 +191,10 @@ public class QakkaQueueManager implements LegacyQueueManager { public void deleteQueue() { queueManager.deleteQueue( scope.getName() ); } + + + @Override + public void clearQueueNameCache(){ + queueNames.clear(); + } } http://git-wip-us.apache.org/repos/asf/usergrid/blob/9b12299c/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java index 853fcdd..b2a7680 100644 --- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java +++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java @@ -702,4 +702,9 @@ public class SNSQueueManagerImpl implements LegacyQueueManager { return sqs; } + + @Override + public void clearQueueNameCache(){ + //no-op + } } http://git-wip-us.apache.org/repos/asf/usergrid/blob/9b12299c/stack/services/src/main/java/org/apache/usergrid/services/queues/ImportQueueManager.java ---------------------------------------------------------------------- diff --git a/stack/services/src/main/java/org/apache/usergrid/services/queues/ImportQueueManager.java b/stack/services/src/main/java/org/apache/usergrid/services/queues/ImportQueueManager.java index 47758a3..c00575f 100644 --- a/stack/services/src/main/java/org/apache/usergrid/services/queues/ImportQueueManager.java +++ b/stack/services/src/main/java/org/apache/usergrid/services/queues/ImportQueueManager.java @@ -79,4 +79,9 @@ public class ImportQueueManager implements LegacyQueueManager { public void deleteQueue() { } + + @Override + public void clearQueueNameCache(){ + //no-op + } }