diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2014-07-26 22:57:11 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2014-07-26 22:57:11 +0000 |
| commit | b71bbd227dfacaedaba411e908853b05e8fbd243 (patch) | |
| tree | 34c186991ae516bef5e0322558aae4843a8545b2 /qpid/java/broker-plugins/derby-store | |
| parent | 151622bd91d7eb031498ff598a31a295af27799b (diff) | |
| download | qpid-python-b71bbd227dfacaedaba411e908853b05e8fbd243.tar.gz | |
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
Diffstat (limited to 'qpid/java/broker-plugins/derby-store')
5 files changed, 139 insertions, 7 deletions
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<? extends ConfiguredObject> _rootClass; + + public DerbyConfigurationStore(final Class<? extends ConfiguredObject> 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<X extends DerbySystemConfig<X>> extends SystemConfig<X>, 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<DerbySystemConfigImpl> implements DerbySystemConfig<DerbySystemConfigImpl> +{ + 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<De @Override protected DurableConfigurationStore createConfigurationStore() { - return new DerbyConfigurationStore(); + return new DerbyConfigurationStore(VirtualHost.class); } @Override diff --git a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java index 849bd066c7..4a71fe2faf 100644 --- a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java +++ b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java @@ -20,14 +20,15 @@ */ package org.apache.qpid.server.store.derby; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import org.apache.qpid.server.model.ConfiguredObjectFactory; +import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.model.VirtualHostNode; import org.apache.qpid.server.store.AbstractDurableConfigurationStoreTestCase; import org.apache.qpid.server.virtualhostnode.derby.DerbyVirtualHostNode; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - public class DerbyMessageStoreConfigurationTest extends AbstractDurableConfigurationStoreTestCase { @@ -42,7 +43,7 @@ public class DerbyMessageStoreConfigurationTest extends AbstractDurableConfigura @Override protected DerbyConfigurationStore createConfigStore() throws Exception { - return new DerbyConfigurationStore(); + return new DerbyConfigurationStore(VirtualHost.class); } } |
