summaryrefslogtreecommitdiff
path: root/java/broker-core/src
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2014-06-18 22:15:54 +0000
committerKeith Wall <kwall@apache.org>2014-06-18 22:15:54 +0000
commita06a3d04d8c2224faa9e34fea2d19e913f2f3a20 (patch)
treeed935c938f7a216242e55f6ec83ad9cf7275d817 /java/broker-core/src
parent27f61ee283eccbdc9159fea9ff9c239dbb805dc4 (diff)
downloadqpid-python-a06a3d04d8c2224faa9e34fea2d19e913f2f3a20.tar.gz
QPID-5822: [Java Broker] Replace low level BDB/JDBC attributes in fovour of context variables from the model
* BDB attributes environmentConfiguration/replicatedEnvironmentConfiguration removed. User can now specify context variables with the configuration keys that are understood by JE itself. * JDBC attributes bigIntType/bytesForBlob/varBinaryType/blobType are now context variables with names begining qpid.jdbcstore. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1603655 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/broker-core/src')
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java2
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java58
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java38
-rw-r--r--java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java3
4 files changed, 79 insertions, 22 deletions
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
index f94f669dfc..f568422d99 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
@@ -713,7 +713,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im
public Map<String,String> getContext()
{
- return _context == null ? null : Collections.unmodifiableMap(_context);
+ return _context == null ? Collections.<String,String>emptyMap() : Collections.unmodifiableMap(_context);
}
public State getDesiredState()
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java b/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java
index 7fff9151d9..6cc56d0e4d 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.store;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -233,7 +234,7 @@ public class BrokerStoreUpgraderAndRecoverer
addAttributeTransformer("storePath", copyAttribute()).
addAttributeTransformer("storeUnderfullSize", copyAttribute()).
addAttributeTransformer("storeOverfullSize", copyAttribute()).
- addAttributeTransformer("bdbEnvironmentConfig", mutateAttributeName("environmentConfiguration")));
+ addAttributeTransformer("bdbEnvironmentConfig", mutateAttributeName("context")));
put("JDBC", new AttributesTransformer().
addAttributeTransformer("id", copyAttribute()).
addAttributeTransformer("name", copyAttribute()).
@@ -242,13 +243,13 @@ public class BrokerStoreUpgraderAndRecoverer
addAttributeTransformer("storePath", mutateAttributeName("connectionURL")).
addAttributeTransformer("connectionURL", mutateAttributeName("connectionUrl")).
addAttributeTransformer("connectionPool", mutateAttributeName("connectionPoolType")).
- addAttributeTransformer("jdbcBigIntType", mutateAttributeName("bigIntType")).
- addAttributeTransformer("jdbcBytesForBlob", mutateAttributeName("bytesForBlob")).
- addAttributeTransformer("jdbcBlobType", mutateAttributeName("blobType")).
- addAttributeTransformer("jdbcVarbinaryType", mutateAttributeName("varbinaryType")).
- addAttributeTransformer("partitionCount", copyAttribute()).
- addAttributeTransformer("maxConnectionsPerPartition", copyAttribute()).
- addAttributeTransformer("minConnectionsPerPartition", copyAttribute()));
+ addAttributeTransformer("jdbcBigIntType", addContextVar("qpid.jdbcstore.bigIntType")).
+ addAttributeTransformer("jdbcBytesForBlob", addContextVar("qpid.jdbcstore.useBytesForBlob")).
+ addAttributeTransformer("jdbcBlobType", addContextVar("qpid.jdbcstore.blobType")).
+ addAttributeTransformer("jdbcVarbinaryType", addContextVar("qpid.jdbcstore.varBinaryType")).
+ addAttributeTransformer("partitionCount", addContextVar("qpid.jdbcstore.bonecp.partitionCount")).
+ addAttributeTransformer("maxConnectionsPerPartition", addContextVar("qpid.jdbcstore.bonecp.maxConnectionsPerPartition")).
+ addAttributeTransformer("minConnectionsPerPartition", addContextVar("qpid.jdbcstore.bonecp.minConnectionsPerPartition")));
put("BDB_HA", new AttributesTransformer().
addAttributeTransformer("id", copyAttribute()).
addAttributeTransformer("createdTime", copyAttribute()).
@@ -261,8 +262,8 @@ public class BrokerStoreUpgraderAndRecoverer
addAttributeTransformer("haHelperAddress", mutateAttributeName("helperAddress")).
addAttributeTransformer("haNodeAddress", mutateAttributeName("address")).
addAttributeTransformer("haDesignatedPrimary", mutateAttributeName("designatedPrimary")).
- addAttributeTransformer("haReplicationConfig", mutateAttributeName("replicatedEnvironmentConfiguration")).
- addAttributeTransformer("bdbEnvironmentConfig", mutateAttributeName("environmentConfiguration")));
+ addAttributeTransformer("haReplicationConfig", mutateAttributeName("context")).
+ addAttributeTransformer("bdbEnvironmentConfig", mutateAttributeName("context")));
}};
public ConfiguredObjectRecord upgrade(ConfiguredObjectRecord vhost)
@@ -300,7 +301,6 @@ public class BrokerStoreUpgraderAndRecoverer
Map<String, Object> nodeAttributes = nodeAttributeTransformer.upgrade(attributes);
nodeAttributes.put("type", type);
- nodeAttributes.put("messageStoreProvider", true);
return new ConfiguredObjectRecordImpl(vhost.getId(), "VirtualHostNode", nodeAttributes, vhost.getParents());
}
@@ -329,7 +329,7 @@ public class BrokerStoreUpgraderAndRecoverer
public Map<String, Object> upgrade(Map<String, Object> attributes)
{
- Map<String, Object> settings = new HashMap<String, Object>();
+ Map<String, Object> settings = new HashMap<>();
for (Map.Entry<String, List<AttributeTransformer>> entry : _transformers.entrySet())
{
String attributeName = entry.getKey();
@@ -349,7 +349,17 @@ public class BrokerStoreUpgraderAndRecoverer
}
if (newEntry != null)
{
- settings.put(newEntry.getKey(), newEntry.getValue());
+ if (settings.get(newEntry.getKey()) instanceof Map && newEntry.getValue() instanceof Map)
+ {
+ final Map newMap = (Map)newEntry.getValue();
+ final Map mergedMap = new HashMap((Map) settings.get(newEntry.getKey()));
+ mergedMap.putAll(newMap);
+ settings.put(newEntry.getKey(), mergedMap);
+ }
+ else
+ {
+ settings.put(newEntry.getKey(), newEntry.getValue());
+ }
}
}
}
@@ -367,6 +377,11 @@ public class BrokerStoreUpgraderAndRecoverer
return new MutateAttributeName(newName);
}
+ private static AttributeTransformer addContextVar(String newName)
+ {
+ return new AddContextVar(newName);
+ }
+
private static interface AttributeTransformer
{
MutableEntry transform(MutableEntry entry);
@@ -386,6 +401,23 @@ public class BrokerStoreUpgraderAndRecoverer
return entry;
}
}
+
+ private static class AddContextVar implements AttributeTransformer
+ {
+ private final String _newName;
+
+ public AddContextVar(String newName)
+ {
+ _newName = newName;
+ }
+
+ @Override
+ public MutableEntry transform(MutableEntry entry)
+ {
+ return new MutableEntry("context", Collections.singletonMap(_newName, entry.getValue()));
+ }
+ }
+
private static class MutateAttributeName implements AttributeTransformer
{
private final String _newName;
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java
index 7d37363c81..2c9583490a 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java
@@ -20,6 +20,7 @@
*/
package org.apache.qpid.server.store;
+import static org.mockito.Matchers.contains;
import static org.mockito.Mockito.mock;
import java.util.Collections;
@@ -77,6 +78,11 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
hostAttributes.put("partitionCount", 2);
hostAttributes.put("storeType", "jdbc");
hostAttributes.put("type", "STANDARD");
+ hostAttributes.put("jdbcBigIntType", "mybigint");
+ hostAttributes.put("jdbcBlobType", "myblob");
+ hostAttributes.put("jdbcVarbinaryType", "myvarbinary");
+ hostAttributes.put("jdbcBytesForBlob", true);
+
ConfiguredObjectRecord virtualHostRecord = new ConfiguredObjectRecordImpl(UUID.randomUUID(), "VirtualHost",
hostAttributes, Collections.<String,ConfiguredObjectRecord>singletonMap("Broker", _brokerRecord));
@@ -92,12 +98,20 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
expectedAttributes.put("connectionUrl", "jdbc:derby://localhost:1527/tmp/vh/test;create=true");
expectedAttributes.put("createdBy", "webadmin");
expectedAttributes.put("createdTime", 1401385905260l);
- expectedAttributes.put("maxConnectionsPerPartition", 7);
- expectedAttributes.put("minConnectionsPerPartition", 6);
- expectedAttributes.put("partitionCount", 2);
expectedAttributes.put("name", "test");
expectedAttributes.put("type", "JDBC");
- expectedAttributes.put("messageStoreProvider", true);
+
+ final Map<String, Object> context = new HashMap<>();
+ context.put("qpid.jdbcstore.bigIntType", "mybigint");
+ context.put("qpid.jdbcstore.varBinaryType", "myvarbinary");
+ context.put("qpid.jdbcstore.blobType", "myblob");
+ context.put("qpid.jdbcstore.useBytesForBlob", true);
+
+ context.put("qpid.jdbcstore.bonecp.maxConnectionsPerPartition", 7);
+ context.put("qpid.jdbcstore.bonecp.minConnectionsPerPartition", 6);
+ context.put("qpid.jdbcstore.bonecp.partitionCount", 2);
+ expectedAttributes.put("context", context);
+
assertEquals("Unexpected attributes", expectedAttributes, upgradedVirtualHostNodeRecord.getAttributes());
}
@@ -127,7 +141,6 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
expectedAttributes.put("createdTime", 1401385905260l);
expectedAttributes.put("name", "test");
expectedAttributes.put("type", "DERBY");
- expectedAttributes.put("messageStoreProvider", true);
assertEquals("Unexpected attributes", expectedAttributes, upgradedVirtualHostNodeRecord.getAttributes());
}
@@ -141,6 +154,8 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
hostAttributes.put("createdBy", "webadmin");
hostAttributes.put("createdTime", 1401385905260l);
hostAttributes.put("type", "STANDARD");
+ hostAttributes.put("bdbEnvironmentConfig", Collections.singletonMap("je.stats.collect", "false"));
+
ConfiguredObjectRecord virtualHostRecord = new ConfiguredObjectRecordImpl(UUID.randomUUID(), "VirtualHost",
hostAttributes, Collections.<String,ConfiguredObjectRecord>singletonMap("Broker", _brokerRecord));
@@ -157,7 +172,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
expectedAttributes.put("createdTime", 1401385905260l);
expectedAttributes.put("name", "test");
expectedAttributes.put("type", "BDB");
- expectedAttributes.put("messageStoreProvider", true);
+ expectedAttributes.put("context", Collections.singletonMap("je.stats.collect", "false"));
assertEquals("Unexpected attributes", expectedAttributes, upgradedVirtualHostNodeRecord.getAttributes());
}
@@ -176,6 +191,9 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
hostAttributes.put("haHelperAddress", "localhost:7000");
hostAttributes.put("haNodeAddress", "localhost:7000");
hostAttributes.put("haNodeName", "n1");
+ hostAttributes.put("haReplicationConfig", Collections.singletonMap("je.stats.collect", "false"));
+ hostAttributes.put("bdbEnvironmentConfig", Collections.singletonMap("je.rep.feederTimeout", "1 m"));
+
ConfiguredObjectRecord virtualHostRecord = new ConfiguredObjectRecordImpl(UUID.randomUUID(), "VirtualHost",
hostAttributes, Collections.<String,ConfiguredObjectRecord>singletonMap("Broker", _brokerRecord));
@@ -186,6 +204,10 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
ConfiguredObjectRecord upgradedVirtualHostNodeRecord = findRecordById(virtualHostRecord.getId(), records);
assertEquals("Unexpected type", "VirtualHostNode", upgradedVirtualHostNodeRecord.getType());
+ Map<String,Object> expectedContext = new HashMap<>();
+ expectedContext.put("je.stats.collect", "false");
+ expectedContext.put("je.rep.feederTimeout", "1 m");
+
Map<String,Object> expectedAttributes = new HashMap<>();
expectedAttributes.put("createdBy", "webadmin");
expectedAttributes.put("createdTime", 1401385905260l);
@@ -196,7 +218,8 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
expectedAttributes.put("address", "localhost:7000");
expectedAttributes.put("helperAddress", "localhost:7000");
expectedAttributes.put("name", "n1");
- expectedAttributes.put("messageStoreProvider", true);
+ expectedAttributes.put("context", expectedContext);
+
assertEquals("Unexpected attributes", expectedAttributes, upgradedVirtualHostNodeRecord.getAttributes());
}
@@ -224,7 +247,6 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
expectedAttributes.put("createdTime", 1401385905260l);
expectedAttributes.put("name", "test");
expectedAttributes.put("type", "Memory");
- expectedAttributes.put("messageStoreProvider", true);
assertEquals("Unexpected attributes", expectedAttributes, upgradedVirtualHostNodeRecord.getAttributes());
}
diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java b/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java
index 89fef15e7e..baab5dd6d3 100644
--- a/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java
+++ b/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java
@@ -50,6 +50,7 @@ public abstract class MessageStoreQuotaEventsTestBase extends QpidTestCase imple
protected abstract MessageStore createStore() throws Exception;
protected abstract Map<String, Object> createStoreSettings(String storeLocation);
+ protected abstract Map<String, String> createContextSettings();
protected abstract int getNumberOfMessagesToFillStore();
@Override
@@ -67,6 +68,8 @@ public abstract class MessageStoreQuotaEventsTestBase extends QpidTestCase imple
ConfiguredObject<?> parent = mock(ConfiguredObject.class);
when(parent.getName()).thenReturn("test");
+ when(parent.getContext()).thenReturn(createContextSettings());
+
_store.openMessageStore(parent, storeSettings);
_transactionResource = UUID.randomUUID();