summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2008-09-03 16:26:38 +0000
committerMartin Ritchie <ritchiem@apache.org>2008-09-03 16:26:38 +0000
commitb7c6b894b1a1bebc578a1a478cddda6edc5255ac (patch)
tree7ccad027ab317df788d9acb346cd357a2f360b2d /java
parent2c82cdf278c35b61aaab5681f88269e36213a906 (diff)
downloadqpid-python-b7c6b894b1a1bebc578a1a478cddda6edc5255ac.tar.gz
QPID-1266 : Provided test for new stop() method. Updated RefCountExService to allow retrieval of the referenceCount. Updated AMQQueue to only perform stop() actions once, such as releasing the RefCountExService. Updated instances where new virtualhosts were not added to the VHostRegistry. See supplemental JIRA for removing the need for this.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@691661 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java13
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java7
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java7
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java1
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java5
-rw-r--r--java/common/src/main/java/org/apache/qpid/pool/ReferenceCountingExecutorService.java9
6 files changed, 35 insertions, 7 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java b/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
index 1184ba1d19..6631bc3559 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
@@ -117,6 +117,7 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener
private final AtomicLong _stateChangeCount = new AtomicLong(Long.MIN_VALUE);
private AtomicReference _asynchronousRunner = new AtomicReference(null);
private AtomicInteger _deliveredMessages = new AtomicInteger();
+ private AtomicBoolean _stopped = new AtomicBoolean(false);
protected SimpleAMQQueue(AMQShortString name, boolean durable, AMQShortString owner, boolean autoDelete, VirtualHost virtualHost)
throws AMQException
@@ -1110,7 +1111,17 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener
public void stop()
{
- ReferenceCountingExecutorService.getInstance().releaseExecutorService();
+ if (!_stopped.getAndSet(true))
+ {
+ ReferenceCountingExecutorService.getInstance().releaseExecutorService();
+ }
+ else
+ {
+ if(_logger.isDebugEnabled())
+ {
+ _logger.debug("Queue " + getName() + " already stopped");
+ }
+ }
}
public void deliverAsync()
diff --git a/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java b/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
index 71f6c8ed44..9229863c35 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
@@ -301,6 +301,10 @@ public class VirtualHost implements Accessable
public void close() throws Exception
{
+
+ //Stop Connections
+ _connectionRegistry.close();
+
//Stop the Queues processing
if (_queueRegistry != null)
{
@@ -316,9 +320,6 @@ public class VirtualHost implements Accessable
_houseKeepingTimer.cancel();
}
- //Stop Connections
- _connectionRegistry.close();
-
//Close MessageStore
if (_messageStore != null)
{
diff --git a/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java b/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java
index a592c9353a..aa25e207a9 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java
@@ -60,10 +60,15 @@ public class DestWildExchangeTest extends TestCase
_protocolSession = new InternalTestProtocolSession();
}
+ public void tearDown()
+ {
+ ApplicationRegistry.remove(1);
+ }
+
public void testNoRoute() throws AMQException
{
- AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(new AMQShortString("a*#b"), false, null, false, _vhost, null);
+ AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(new AMQShortString("a*#b"), false, null, false, _vhost, null);
_exchange.registerQueue(new AMQShortString("a.*.#.b"), queue, null);
diff --git a/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java b/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java
index 0524494bfd..dec4de4cc6 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java
@@ -102,6 +102,7 @@ public class MessageStoreTest extends TestCase
try
{
_virtualHost = new VirtualHost(virtualHostName, configuration, null);
+ ApplicationRegistry.getInstance().getVirtualHostRegistry().registerVirtualHost(_virtualHost);
}
catch (Exception e)
{
diff --git a/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java b/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java
index 67eb180dbf..28eab73995 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java
@@ -56,7 +56,8 @@ public class InternalBrokerBaseCase extends TestCase
super.setUp();
_registry = new TestApplicationRegistry();
ApplicationRegistry.initialise(_registry);
- _virtualHost = _registry.getVirtualHostRegistry().getVirtualHost("test");
+ _virtualHost = _registry.getVirtualHostRegistry().getVirtualHost("test");
+
_messageStore = _virtualHost.getMessageStore();
QUEUE_NAME = new AMQShortString("test");
@@ -80,7 +81,7 @@ public class InternalBrokerBaseCase extends TestCase
public void tearDown() throws Exception
{
- ApplicationRegistry.removeAll();
+ ApplicationRegistry.remove(1);
super.tearDown();
}
diff --git a/java/common/src/main/java/org/apache/qpid/pool/ReferenceCountingExecutorService.java b/java/common/src/main/java/org/apache/qpid/pool/ReferenceCountingExecutorService.java
index ce9c6ae4cb..20a30b3ed3 100644
--- a/java/common/src/main/java/org/apache/qpid/pool/ReferenceCountingExecutorService.java
+++ b/java/common/src/main/java/org/apache/qpid/pool/ReferenceCountingExecutorService.java
@@ -160,4 +160,13 @@ public class ReferenceCountingExecutorService
{
return _pool;
}
+
+ /**
+ * Return the ReferenceCount to this ExecutorService
+ * @return reference count
+ */
+ public int getReferenceCount()
+ {
+ return _refCount;
+ }
}