diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2014-04-04 22:34:26 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2014-04-04 22:34:26 +0000 |
| commit | 7344c8879c319c4ca6ab57963e6147d878a4e154 (patch) | |
| tree | 230bbd0d3b9aa28b0a6298ae5156a40c996ddcdb /qpid/java/bdbstore/src | |
| parent | db86d03af2ce0f704398c2a9392e91e9637154ec (diff) | |
| download | qpid-python-7344c8879c319c4ca6ab57963e6147d878a4e154.tar.gz | |
QPID-5615 : [Java Broker] Migrate broker config store to use same API as VirtualHost config store
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1584931 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/bdbstore/src')
6 files changed, 134 insertions, 25 deletions
diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostAdapter.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostAdapter.java new file mode 100644 index 0000000000..6d249ddc34 --- /dev/null +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostAdapter.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.berkeleydb; + +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.adapter.VirtualHostAdapter; + +import java.util.Map; +import java.util.UUID; + +@ManagedObject( category = false, type = "BDB_HA" ) +public class BDBHAVirtualHostAdapter extends VirtualHostAdapter<BDBHAVirtualHostAdapter> +{ + public BDBHAVirtualHostAdapter(final UUID id, + final Map<String, Object> attributes, + final Broker<?> broker) + { + super(id, attributes, broker); + } +} diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostAdapterFactory.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostAdapterFactory.java new file mode 100644 index 0000000000..7d1d6ea664 --- /dev/null +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostAdapterFactory.java @@ -0,0 +1,51 @@ +/* + * + * 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.berkeleydb; + +import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ConfiguredObject; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +public class BDBHAVirtualHostAdapterFactory extends AbstractConfiguredObjectTypeFactory<BDBHAVirtualHostAdapter> +{ + + public BDBHAVirtualHostAdapterFactory() + { + super(BDBHAVirtualHostAdapter.class); + } + + @Override + public BDBHAVirtualHostAdapter createInstance(final Map<String, Object> attributes, + final ConfiguredObject<?>... parents) + { + Map<String,Object> attributesWithoutId = new HashMap<String, Object>(attributes); + Object idObj = attributesWithoutId.remove(ConfiguredObject.ID); + UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString()); + final Broker broker = getParent(Broker.class, parents); + return new BDBHAVirtualHostAdapter(id, attributesWithoutId, broker); + } + + +} diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeFactory.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeFactory.java index 8216cfc484..05944632b0 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeFactory.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeFactory.java @@ -20,15 +20,14 @@ */ package org.apache.qpid.server.store.berkeleydb.replication; -import java.util.Map; - +import com.sleepycat.je.Durability; +import com.sleepycat.je.Durability.ReplicaAckPolicy; +import com.sleepycat.je.Durability.SyncPolicy; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.store.berkeleydb.EnvironmentFacade; import org.apache.qpid.server.store.berkeleydb.EnvironmentFacadeFactory; -import com.sleepycat.je.Durability; -import com.sleepycat.je.Durability.ReplicaAckPolicy; -import com.sleepycat.je.Durability.SyncPolicy; +import java.util.Map; public class ReplicatedEnvironmentFacadeFactory implements EnvironmentFacadeFactory { diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom7To8.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom7To8.java index 413acc90c4..e5e1201c6a 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom7To8.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgradeFrom7To8.java @@ -28,6 +28,7 @@ import com.sleepycat.bind.tuple.TupleOutput; import com.sleepycat.je.*; import org.apache.qpid.server.model.ConfiguredObject; + import org.apache.qpid.server.store.ConfiguredObjectRecord; import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.store.berkeleydb.BDBConfiguredObjectRecord; diff --git a/qpid/java/bdbstore/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory b/qpid/java/bdbstore/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory new file mode 100644 index 0000000000..ab12289814 --- /dev/null +++ b/qpid/java/bdbstore/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory @@ -0,0 +1,19 @@ +# +# 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. +# +org.apache.qpid.server.store.berkeleydb.BDBHAVirtualHostAdapterFactory diff --git a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/VirtualHostTest.java b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/VirtualHostTest.java index 2caf85966c..c702e557c2 100644 --- a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/VirtualHostTest.java +++ b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/VirtualHostTest.java @@ -20,33 +20,32 @@ */ package org.apache.qpid.server.store.berkeleydb; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.apache.qpid.server.configuration.ConfigurationEntry; +import com.sleepycat.je.rep.ReplicatedEnvironment; +import com.sleepycat.je.rep.ReplicationConfig; import org.apache.qpid.server.configuration.ConfigurationEntryStore; import org.apache.qpid.server.configuration.RecovererProvider; -import org.apache.qpid.server.configuration.startup.VirtualHostRecoverer; import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectFactory; import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.VirtualHost; +import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory; import org.apache.qpid.server.stats.StatisticsGatherer; import org.apache.qpid.server.store.MessageStore; -import org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade; import org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacadeFactory; import org.apache.qpid.server.util.BrokerTestHelper; import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.util.FileUtils; -import com.sleepycat.je.rep.ReplicatedEnvironment; -import com.sleepycat.je.rep.ReplicationConfig; +import java.io.File; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class VirtualHostTest extends QpidTestCase { @@ -139,18 +138,19 @@ public class VirtualHostTest extends QpidTestCase assertEquals(helperHostPort, replicationConfig.getHelperHosts()); assertEquals(durability, environment.getConfig().getDurability().toString()); assertEquals("Unexpected JE replication stream timeout", repStreamTimeout, replicationConfig.getConfigParam(ReplicationConfig.REP_STREAM_TIMEOUT)); - } private VirtualHost<?> createHost(Map<String, Object> attributes) { - ConfigurationEntry entry = new ConfigurationEntry(UUID.randomUUID(), VirtualHost.class.getSimpleName(), attributes, - Collections.<UUID>emptySet(), _store); - - return new VirtualHostRecoverer(_statisticsGatherer).create(_recovererProvider, entry, _broker); + ConfiguredObjectFactory factory = new ConfiguredObjectFactory(); + ConfiguredObjectTypeFactory vhostFactory = + factory.getConfiguredObjectTypeFactory(VirtualHost.class, attributes); + attributes = new HashMap<String, Object>(attributes); + attributes.put(ConfiguredObject.ID, UUID.randomUUID()); + return (VirtualHost<?>) vhostFactory.create(attributes,_broker); } } -
\ No newline at end of file + |
