ARTEMIS-3786 - ensure named properties config from routerConfiguration can be created from string property value
This commit is contained in:
parent
32c5f9d268
commit
f9f70aeb4c
|
@ -72,6 +72,7 @@ import org.apache.activemq.artemis.core.config.StoreConfiguration;
|
|||
import org.apache.activemq.artemis.core.config.WildcardConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.routing.NamedPropertyConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
|
||||
|
@ -527,6 +528,17 @@ public class ConfigurationImpl implements Configuration, Serializable {
|
|||
return (T) SimpleString.toSimpleString(value.toString());
|
||||
}
|
||||
}, SimpleString.class);
|
||||
|
||||
beanUtils.getConvertUtils().register(new Converter() {
|
||||
@Override
|
||||
public <T> T convert(Class<T> type, Object value) {
|
||||
NamedPropertyConfiguration instance = new NamedPropertyConfiguration();
|
||||
instance.setName(value.toString());
|
||||
instance.setProperties(new HashMap<>());
|
||||
return (T) instance;
|
||||
}
|
||||
}, NamedPropertyConfiguration.class);
|
||||
|
||||
// support 25K or 25m etc like xml config
|
||||
beanUtils.getConvertUtils().register(new Converter() {
|
||||
@Override
|
||||
|
|
|
@ -20,8 +20,11 @@ import java.io.File;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
@ -40,6 +43,7 @@ import org.apache.activemq.artemis.core.server.JournalType;
|
|||
import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
|
||||
import org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin;
|
||||
import org.apache.activemq.artemis.core.server.routing.KeyType;
|
||||
import org.apache.activemq.artemis.core.server.routing.policies.ConsistentHashModuloPolicy;
|
||||
import org.apache.activemq.artemis.core.settings.impl.ResourceLimitSettings;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.utils.RandomUtil;
|
||||
|
@ -604,6 +608,35 @@ public class ConfigurationImplTest extends ActiveMQTestBase {
|
|||
Assert.assertEquals(4321, configuration.getGlobalMaxSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetConnectionRoutersPolicyConfiguration() throws Throwable {
|
||||
ConfigurationImpl configuration = new ConfigurationImpl();
|
||||
|
||||
Properties insertionOrderedProperties = new Properties() {
|
||||
final LinkedHashMap<Object, Object> orderedMap = new LinkedHashMap<>();
|
||||
|
||||
@Override
|
||||
public Object put(Object key, Object value) {
|
||||
return orderedMap.put(key.toString(), value.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Map.Entry<Object, Object>> entrySet() {
|
||||
return orderedMap.entrySet();
|
||||
}
|
||||
};
|
||||
insertionOrderedProperties.put("connectionRouters.autoShard.localTargetFilter", "NULL|$STATEFUL_SET_ORDINAL");
|
||||
insertionOrderedProperties.put("connectionRouters.autoShard.keyType", KeyType.CLIENT_ID);
|
||||
insertionOrderedProperties.put("connectionRouters.autoShard.policyConfiguration", ConsistentHashModuloPolicy.NAME);
|
||||
insertionOrderedProperties.put("connectionRouters.autoShard.policyConfiguration.properties." + ConsistentHashModuloPolicy.MODULO, 2);
|
||||
|
||||
configuration.parsePrefixedProperties(insertionOrderedProperties, null);
|
||||
|
||||
Assert.assertEquals(1, configuration.getConnectionRouters().size());
|
||||
Assert.assertEquals(KeyType.CLIENT_ID, configuration.getConnectionRouters().get(0).getKeyType());
|
||||
Assert.assertEquals("2", configuration.getConnectionRouters().get(0).getPolicyConfiguration().getProperties().get(ConsistentHashModuloPolicy.MODULO));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetNestedPropertyOnCollections() throws Throwable {
|
||||
ConfigurationImpl configuration = new ConfigurationImpl();
|
||||
|
|
Loading…
Reference in New Issue