You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ai...@apache.org on 2009/04/03 18:36:14 UTC
svn commit: r761721 - in /qpid/trunk/qpid/java/broker/src:
main/java/org/apache/qpid/server/configuration/
main/java/org/apache/qpid/server/queue/
test/java/org/apache/qpid/server/configuration/
test/java/org/apache/qpid/server/queue/
Author: aidan
Date: Fri Apr 3 16:36:14 2009
New Revision: 761721
URL: http://svn.apache.org/viewvc?rev=761721&view=rev
Log:
QPID-1730: make it easy to configure queues, fix inheriting settings from the virtualhost.
AMQQueue.configure: new method
AMQQueueFactory: use AMQQueue.configure, don't set things directly
SimpleAMQQueue.configure, MockAMQQueue.configure: implement new method from the interface
QueueConfiguration: use VirtualHostConfiguration for default values if they're unset
VirtualHostConfiguration: if a queue doesn't exist, give it a default configuration. Add methods to get default settings for configuration items
QueueConfigurationTest: test case, checks that inheritance and defaults work along with explicitly set values.
Added:
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java
Modified:
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java
Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java?rev=761721&r1=761720&r2=761721&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java Fri Apr 3 16:36:14 2009
@@ -21,30 +21,26 @@
package org.apache.qpid.server.configuration;
import java.util.List;
-import java.io.File;
import org.apache.commons.configuration.Configuration;
-import org.apache.qpid.server.registry.ApplicationRegistry;
public class QueueConfiguration
{
-
- // FIXME AIDAN XXX -- deal with defaults
private Configuration _config;
private String _name;
- private VirtualHostConfiguration _virtualHostConfiguration;
+ private VirtualHostConfiguration _vHostConfig;
public QueueConfiguration(String name, Configuration config, VirtualHostConfiguration virtualHostConfiguration)
{
- _virtualHostConfiguration = virtualHostConfiguration;
+ _vHostConfig = virtualHostConfiguration;
_config = config;
_name = name;
}
public VirtualHostConfiguration getVirtualHostConfiguration()
{
- return _virtualHostConfiguration;
+ return _vHostConfig;
}
public boolean getDurable()
@@ -87,29 +83,29 @@
return _name;
}
- public long getMaximumMessageAge()
+ public int getMaximumMessageAge()
{
- return _config.getLong("maximumMessageAge", 0);
+ return _config.getInt("maximumMessageAge", _vHostConfig.getMaximumMessageAge());
}
public long getMaximumQueueDepth()
{
- return _config.getLong("maximumQueueDepth", 0);
+ return _config.getLong("maximumQueueDepth", _vHostConfig.getMaximumQueueDepth());
}
public long getMaximumMessageSize()
{
- return _config.getLong("maximumMessageSize", 0);
+ return _config.getLong("maximumMessageSize", _vHostConfig.getMaximumMessageSize());
}
public long getMaximumMessageCount()
{
- return _config.getLong("maximumMessageCount", 0);
+ return _config.getLong("maximumMessageCount", _vHostConfig.getMaximumMessageCount());
}
public long getMinimumAlertRepeatGap()
{
- return _config.getLong("minimumAlertRepeatGap", 0);
+ return _config.getLong("minimumAlertRepeatGap", _vHostConfig.getMinimumAlertRepeatGap());
}
public long getMemoryUsageMaximum()
Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java?rev=761721&r1=761720&r2=761721&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java Fri Apr 3 16:36:14 2009
@@ -142,7 +142,16 @@
public QueueConfiguration getQueueConfiguration(String queueName)
{
- return _queues.get(queueName);
+ // We might be asked for the config for a queue we don't know about,
+ // such as one that's been dynamically created. Those get the defaults by default.
+ if (_queues.containsKey(queueName))
+ {
+ return _queues.get(queueName);
+ }
+ else
+ {
+ return new QueueConfiguration(queueName, new PropertiesConfiguration(), this);
+ }
}
public long getMemoryUsageMaximum()
@@ -166,4 +175,29 @@
return _config.getString(FLOW_TO_DISK_PATH, getServerConfiguration().getQpidWork());
}
+ public int getMaximumMessageAge()
+ {
+ return _config.getInt("queues.maximumMessageAge", 0);
+ }
+
+ public Long getMaximumQueueDepth()
+ {
+ return _config.getLong("queues.maximumQueueDepth", 0);
+ }
+
+ public Long getMaximumMessageSize()
+ {
+ return _config.getLong("queues.maximumMessageSize", 0);
+ }
+
+ public Long getMaximumMessageCount()
+ {
+ return _config.getLong("queues.maximumMessageCount", 0);
+ }
+
+ public Long getMinimumAlertRepeatGap()
+ {
+ return _config.getLong("queues.minimumAlertRepeatGap", 0);
+ }
+
}
Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java?rev=761721&r1=761720&r2=761721&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java Fri Apr 3 16:36:14 2009
@@ -215,4 +215,6 @@
{
public void doTask(AMQQueue queue) throws AMQException;
}
+
+ void configure(QueueConfiguration config);
}
Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java?rev=761721&r1=761720&r2=761721&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java Fri Apr 3 16:36:14 2009
@@ -134,13 +134,7 @@
}
AMQQueue q = createAMQQueueImpl(queueName, durable, owner, autodelete, host, arguments);
- q.setMaximumMessageAge(config.getMaximumMessageAge());
- q.setMaximumQueueDepth(config.getMaximumQueueDepth());
- q.setMaximumMessageSize(config.getMaximumMessageSize());
- q.setMaximumMessageCount(config.getMaximumMessageCount());
- q.setMinimumAlertRepeatGap(config.getMinimumAlertRepeatGap());
- q.setMemoryUsageMaximum(config.getMemoryUsageMaximum());
- q.setMemoryUsageMinimum(config.getMemoryUsageMinimum());
+ q.configure(config);
return q;
}
}
Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java?rev=761721&r1=761720&r2=761721&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java Fri Apr 3 16:36:14 2009
@@ -19,6 +19,7 @@
import org.apache.qpid.framing.FieldTable;
import org.apache.qpid.pool.ReadWriteRunnable;
import org.apache.qpid.pool.ReferenceCountingExecutorService;
+import org.apache.qpid.server.configuration.QueueConfiguration;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.management.ManagedObject;
import org.apache.qpid.server.output.ProtocolOutputConverter;
@@ -1627,4 +1628,18 @@
{
return getType() + "[Owner:" + _owner + "][Durable:" + _durable + "]";
}
+
+ public void configure(QueueConfiguration config)
+ {
+ if (config != null)
+ {
+ setMaximumMessageAge(config.getMaximumMessageAge());
+ setMaximumQueueDepth(config.getMaximumQueueDepth());
+ setMaximumMessageSize(config.getMaximumMessageSize());
+ setMaximumMessageCount(config.getMaximumMessageCount());
+ setMinimumAlertRepeatGap(config.getMinimumAlertRepeatGap());
+ setMemoryUsageMaximum(config.getMemoryUsageMaximum());
+ setMemoryUsageMinimum(config.getMemoryUsageMinimum());
+ }
+ }
}
Added: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java?rev=761721&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java (added)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java Fri Apr 3 16:36:14 2009
@@ -0,0 +1,139 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.configuration;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+
+public class QueueConfigurationTest extends TestCase
+{
+
+ private VirtualHostConfiguration _emptyConf;
+ private PropertiesConfiguration _env;
+ private ServerConfiguration _fullServerConf;
+ private VirtualHostConfiguration _fullHostConf;
+
+ public void setUp() throws Exception
+ {
+ _env = new PropertiesConfiguration();
+ ServerConfiguration emptyServerConfig;
+ emptyServerConfig = new ServerConfiguration(_env);
+ _emptyConf = new VirtualHostConfiguration("test", _env, emptyServerConfig);
+
+ PropertiesConfiguration fullEnv = new PropertiesConfiguration();
+ fullEnv.setProperty("queues.maximumMessageAge", 1);
+ fullEnv.setProperty("queues.maximumQueueDepth", 1);
+ fullEnv.setProperty("queues.maximumMessageSize", 1);
+ fullEnv.setProperty("queues.maximumMessageCount", 1);
+ fullEnv.setProperty("queues.minimumAlertRepeatGap", 1);
+
+ _fullServerConf = new ServerConfiguration(fullEnv);
+ _fullHostConf = new VirtualHostConfiguration("test", fullEnv, _fullServerConf);
+
+ }
+
+ public void testGetMaximumMessageAge()
+ {
+ // Check default value
+ QueueConfiguration qConf = new QueueConfiguration("test", _env, _emptyConf);
+ assertEquals(0, qConf.getMaximumMessageAge());
+
+ // Check explicit value
+ PropertiesConfiguration fullEnv = new PropertiesConfiguration();
+ fullEnv.setProperty("maximumMessageAge", 2);
+ qConf = new QueueConfiguration("test", fullEnv, _fullHostConf);
+ assertEquals(2, qConf.getMaximumMessageAge());
+
+ // Check inherited value
+ qConf = new QueueConfiguration("test", _env, _fullHostConf);
+ assertEquals(1, qConf.getMaximumMessageAge());
+ }
+
+ public void testGetMaximumQueueDepth()
+ {
+ // Check default value
+ QueueConfiguration qConf = new QueueConfiguration("test", _env, _emptyConf);
+ assertEquals(0, qConf.getMaximumQueueDepth());
+
+ // Check explicit value
+ PropertiesConfiguration fullEnv = new PropertiesConfiguration();
+ fullEnv.setProperty("maximumQueueDepth", 2);
+ qConf = new QueueConfiguration("test", fullEnv, _fullHostConf);
+ assertEquals(2, qConf.getMaximumQueueDepth());
+
+ // Check inherited value
+ qConf = new QueueConfiguration("test", _env, _fullHostConf);
+ assertEquals(1, qConf.getMaximumQueueDepth());
+ }
+
+ public void testGetMaximumMessageSize()
+ {
+ // Check default value
+ QueueConfiguration qConf = new QueueConfiguration("test", _env, _emptyConf);
+ assertEquals(0, qConf.getMaximumMessageSize());
+
+ // Check explicit value
+ PropertiesConfiguration fullEnv = new PropertiesConfiguration();
+ fullEnv.setProperty("maximumMessageSize", 2);
+ qConf = new QueueConfiguration("test", fullEnv, _fullHostConf);
+ assertEquals(2, qConf.getMaximumMessageSize());
+
+ // Check inherited value
+ qConf = new QueueConfiguration("test", _env, _fullHostConf);
+ assertEquals(1, qConf.getMaximumMessageSize());
+ }
+
+ public void testGetMaximumMessageCount()
+ {
+ // Check default value
+ QueueConfiguration qConf = new QueueConfiguration("test", _env, _emptyConf);
+ assertEquals(0, qConf.getMaximumMessageCount());
+
+ // Check explicit value
+ PropertiesConfiguration fullEnv = new PropertiesConfiguration();
+ fullEnv.setProperty("maximumMessageCount", 2);
+ qConf = new QueueConfiguration("test", fullEnv, _fullHostConf);
+ assertEquals(2, qConf.getMaximumMessageCount());
+
+ // Check inherited value
+ qConf = new QueueConfiguration("test", _env, _fullHostConf);
+ assertEquals(1, qConf.getMaximumMessageCount());
+ }
+
+ public void testGetMinimumAlertRepeatGap()
+ {
+ // Check default value
+ QueueConfiguration qConf = new QueueConfiguration("test", _env, _emptyConf);
+ assertEquals(0, qConf.getMinimumAlertRepeatGap());
+
+ // Check explicit value
+ PropertiesConfiguration fullEnv = new PropertiesConfiguration();
+ fullEnv.setProperty("minimumAlertRepeatGap", 2);
+ qConf = new QueueConfiguration("test", fullEnv, _fullHostConf);
+ assertEquals(2, qConf.getMinimumAlertRepeatGap());
+
+ // Check inherited value
+ qConf = new QueueConfiguration("test", _env, _fullHostConf);
+ assertEquals(1, qConf.getMinimumAlertRepeatGap());
+ }
+
+}
Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java?rev=761721&r1=761720&r2=761721&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java (original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java Fri Apr 3 16:36:14 2009
@@ -24,6 +24,7 @@
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.server.configuration.QueueConfiguration;
import org.apache.qpid.server.configuration.ServerConfiguration;
import org.apache.qpid.server.configuration.VirtualHostConfiguration;
import org.apache.qpid.server.exchange.Exchange;
@@ -358,4 +359,9 @@
}
+ public void configure(QueueConfiguration config)
+ {
+
+ }
+
}
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org