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 +-- 5 files changed, 139 insertions(+), 7 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 (limited to 'qpid/java/broker-plugins/derby-store') 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