From b71bbd227dfacaedaba411e908853b05e8fbd243 Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Sat, 26 Jul 2014 22:57:11 +0000 Subject: QPID-5165 : Change the Broker stores to use the generic ConfigurationStore implementations and remove old EntryStore implementations git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1613739 13f79535-47bb-0310-9956-ffa450edef68 --- .../store/derby/DerbyConfigurationStore.java | 17 ++++- .../qpid/server/store/derby/DerbySystemConfig.java | 39 ++++++++++ .../server/store/derby/DerbySystemConfigImpl.java | 78 ++++++++++++++++++++ .../derby/DerbyVirtualHostNodeImpl.java | 3 +- .../derby/DerbyMessageStoreConfigurationTest.java | 9 ++- .../store/jdbc/GenericJDBCConfigurationStore.java | 26 +++++-- .../qpid/server/store/jdbc/JDBCSystemConfig.java | 39 ++++++++++ .../server/store/jdbc/JDBCSystemConfigImpl.java | 86 ++++++++++++++++++++++ .../jdbc/JDBCVirtualHostNodeImpl.java | 3 +- .../server/store/MemoryConfigurationStore.java | 6 ++ .../qpid/server/store/MemoryMessageStore.java | 0 .../qpid/server/store/MemorySystemConfigImpl.java | 52 +++++++++++++ .../memory/MemoryVirtualHostNode.java | 3 +- 13 files changed, 347 insertions(+), 14 deletions(-) create mode 100644 qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbySystemConfig.java create mode 100644 qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbySystemConfigImpl.java create mode 100644 qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfig.java create mode 100644 qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfigImpl.java delete mode 100644 qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java create mode 100644 qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemorySystemConfigImpl.java (limited to 'qpid/java/broker-plugins') diff --git a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java index fdf08a9940..5866319985 100644 --- a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java +++ b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java @@ -48,9 +48,17 @@ public class DerbyConfigurationStore extends AbstractJDBCConfigurationStore private String _storeLocation; private ConfiguredObject _parent; + private final Class _rootClass; + + public DerbyConfigurationStore(final Class rootClass) + { + _rootClass = rootClass; + } @Override - public void openConfigurationStore(ConfiguredObject parent) + public void openConfigurationStore(ConfiguredObject parent, + final boolean overwrite, + final ConfiguredObjectRecord... initialRecords) throws StoreException { if (_configurationStoreOpen.compareAndSet(false, true)) @@ -62,7 +70,12 @@ public class DerbyConfigurationStore extends AbstractJDBCConfigurationStore _storeLocation = settings.getStorePath(); _connectionURL = DerbyUtils.createConnectionUrl(parent.getName(), _storeLocation); - createOrOpenConfigurationStoreDatabase(); + createOrOpenConfigurationStoreDatabase(overwrite); + + if(hasNoConfigurationEntries()) + { + update(true, initialRecords); + } } } diff --git a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbySystemConfig.java b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbySystemConfig.java new file mode 100644 index 0000000000..d3a1fa2bbc --- /dev/null +++ b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbySystemConfig.java @@ -0,0 +1,39 @@ +/* + * + * 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.store.derby; + +import org.apache.qpid.server.model.ManagedAttribute; +import org.apache.qpid.server.model.SystemConfig; +import org.apache.qpid.server.store.FileBasedSettings; +import org.apache.qpid.server.store.SizeMonitoringSettings; + +public interface DerbySystemConfig> extends SystemConfig, FileBasedSettings, + SizeMonitoringSettings +{ + @ManagedAttribute(mandatory = true) + String getStorePath(); + + @ManagedAttribute(mandatory = true, defaultValue = "0") + Long getStoreUnderfullSize(); + + @ManagedAttribute(mandatory = true, defaultValue = "0") + Long getStoreOverfullSize(); +} diff --git a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbySystemConfigImpl.java b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbySystemConfigImpl.java new file mode 100644 index 0000000000..32c5bcd541 --- /dev/null +++ b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbySystemConfigImpl.java @@ -0,0 +1,78 @@ +/* + * + * 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.store.derby; + +import org.apache.qpid.server.BrokerOptions; +import org.apache.qpid.server.configuration.updater.TaskExecutor; +import org.apache.qpid.server.logging.EventLogger; +import org.apache.qpid.server.logging.LogRecorder; +import org.apache.qpid.server.model.AbstractSystemConfig; +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ManagedAttributeField; +import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.SystemConfigFactoryConstructor; +import org.apache.qpid.server.store.DurableConfigurationStore; + +@ManagedObject(category = false, type = DerbySystemConfigImpl.SYSTEM_CONFIG_TYPE) +public class DerbySystemConfigImpl extends AbstractSystemConfig implements DerbySystemConfig +{ + public static final String SYSTEM_CONFIG_TYPE = "DERBY"; + + @ManagedAttributeField + private String _storePath; + @ManagedAttributeField + private Long _storeUnderfullSize; + @ManagedAttributeField + private Long _storeOverfullSize; + + @SystemConfigFactoryConstructor + public DerbySystemConfigImpl(final TaskExecutor taskExecutor, + final EventLogger eventLogger, + final LogRecorder logRecorder, + final BrokerOptions brokerOptions) + { + super(taskExecutor, eventLogger, logRecorder, brokerOptions); + } + + @Override + protected DurableConfigurationStore createStoreObject() + { + return new DerbyConfigurationStore(Broker.class); + } + + @Override + public String getStorePath() + { + return _storePath; + } + + @Override + public Long getStoreUnderfullSize() + { + return _storeUnderfullSize; + } + + @Override + public Long getStoreOverfullSize() + { + return _storeOverfullSize; + } +} diff --git a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java index ae440014c7..4bb3cc5376 100644 --- a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java +++ b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNodeImpl.java @@ -28,6 +28,7 @@ import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ManagedAttributeField; import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; +import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.server.store.derby.DerbyConfigurationStore; import org.apache.qpid.server.virtualhostnode.AbstractStandardVirtualHostNode; @@ -55,7 +56,7 @@ public class DerbyVirtualHostNodeImpl extends AbstractStandardVirtualHostNode _parent; + private final Class _rootClass; + + public GenericJDBCConfigurationStore(final Class rootClass) + { + _rootClass = rootClass; + } @Override - public void openConfigurationStore(ConfiguredObject parent) + public void openConfigurationStore(ConfiguredObject parent, + final boolean overwrite, + final ConfiguredObjectRecord... initialRecords) throws StoreException { if (_configurationStoreOpen.compareAndSet(false, true)) @@ -117,7 +129,11 @@ public class GenericJDBCConfigurationStore extends AbstractJDBCConfigurationStor _useBytesMethodsForBlob = details.isUseBytesMethodsForBlob(); _bigIntType = details.getBigintType(); - createOrOpenConfigurationStoreDatabase(); + createOrOpenConfigurationStoreDatabase(overwrite); + if(hasNoConfigurationEntries()) + { + update(true, initialRecords); + } } } diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfig.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfig.java new file mode 100644 index 0000000000..9fe64577bb --- /dev/null +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfig.java @@ -0,0 +1,39 @@ +/* + * + * 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.store.jdbc; + +import org.apache.qpid.server.model.ManagedAttribute; +import org.apache.qpid.server.model.SystemConfig; + +public interface JDBCSystemConfig> extends SystemConfig, JDBCSettings +{ + @ManagedAttribute(mandatory=true, defaultValue = "${systemConfig.connectionUrl}") + String getConnectionUrl(); + + @ManagedAttribute(defaultValue=DefaultConnectionProviderFactory.TYPE) + String getConnectionPoolType(); + + @ManagedAttribute(defaultValue = "${systemConfig.username}") + String getUsername(); + + @ManagedAttribute(secure=true, defaultValue = "${systemConfig.password}") + String getPassword(); +} diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfigImpl.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfigImpl.java new file mode 100644 index 0000000000..fd1cad7de4 --- /dev/null +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfigImpl.java @@ -0,0 +1,86 @@ +/* + * + * 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.store.jdbc; + +import org.apache.qpid.server.BrokerOptions; +import org.apache.qpid.server.configuration.updater.TaskExecutor; +import org.apache.qpid.server.logging.EventLogger; +import org.apache.qpid.server.logging.LogRecorder; +import org.apache.qpid.server.model.AbstractSystemConfig; +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ManagedAttributeField; +import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.SystemConfigFactoryConstructor; +import org.apache.qpid.server.store.DurableConfigurationStore; + +@ManagedObject( category = false, type = JDBCSystemConfigImpl.SYSTEM_CONFIG_TYPE) +public class JDBCSystemConfigImpl extends AbstractSystemConfig implements JDBCSystemConfig +{ + public static final String SYSTEM_CONFIG_TYPE = "JDBC"; + + @ManagedAttributeField + private String _connectionUrl; + @ManagedAttributeField + private String _connectionPoolType; + @ManagedAttributeField + private String _username; + @ManagedAttributeField + private String _password; + + @SystemConfigFactoryConstructor + public JDBCSystemConfigImpl(final TaskExecutor taskExecutor, + final EventLogger eventLogger, + final LogRecorder logRecorder, + final BrokerOptions brokerOptions) + { + super(taskExecutor, eventLogger, logRecorder, brokerOptions); + } + + @Override + protected DurableConfigurationStore createStoreObject() + { + return new GenericJDBCConfigurationStore(Broker.class); + } + + @Override + public String getConnectionUrl() + { + return _connectionUrl; + } + + @Override + public String getConnectionPoolType() + { + return _connectionPoolType; + } + + @Override + public String getUsername() + { + return _username; + } + + @Override + public String getPassword() + { + return _password; + } +} diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java index 01acb9e0b5..eab53e6744 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java @@ -26,6 +26,7 @@ import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ManagedAttributeField; import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; +import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.server.store.jdbc.GenericJDBCConfigurationStore; import org.apache.qpid.server.virtualhostnode.AbstractStandardVirtualHostNode; @@ -61,7 +62,7 @@ public class JDBCVirtualHostNodeImpl extends AbstractStandardVirtualHostNode rootClass) + { + super(rootClass); + } } diff --git a/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java b/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemorySystemConfigImpl.java b/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemorySystemConfigImpl.java new file mode 100644 index 0000000000..f644b8f46b --- /dev/null +++ b/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemorySystemConfigImpl.java @@ -0,0 +1,52 @@ +/* + * + * 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.store; + +import org.apache.qpid.server.BrokerOptions; +import org.apache.qpid.server.configuration.updater.TaskExecutor; +import org.apache.qpid.server.logging.EventLogger; +import org.apache.qpid.server.logging.LogRecorder; +import org.apache.qpid.server.model.AbstractSystemConfig; +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.SystemConfigFactoryConstructor; + + +@ManagedObject( category = false, type = MemorySystemConfigImpl.SYSTEM_CONFIG_TYPE ) +public class MemorySystemConfigImpl extends AbstractSystemConfig +{ + public static final String SYSTEM_CONFIG_TYPE = "Memory"; + + @SystemConfigFactoryConstructor + public MemorySystemConfigImpl(final TaskExecutor taskExecutor, + final EventLogger eventLogger, + final LogRecorder logRecorder, + final BrokerOptions brokerOptions) + { + super(taskExecutor, eventLogger, logRecorder, brokerOptions); + } + + @Override + protected DurableConfigurationStore createStoreObject() + { + return new MemoryConfigurationStore(Broker.class); + } +} diff --git a/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java b/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java index d9b564305c..f57c0df4c0 100644 --- a/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java +++ b/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java @@ -25,6 +25,7 @@ import java.util.Map; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; +import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.server.store.MemoryConfigurationStore; import org.apache.qpid.server.virtualhostnode.AbstractStandardVirtualHostNode; @@ -48,6 +49,6 @@ public class MemoryVirtualHostNode extends AbstractStandardVirtualHostNode