ACTIVEMQ6-96 ensure connectionsAllowed work on invm acceptor URI

This commit is contained in:
jbertram 2015-05-05 10:39:36 -05:00
parent 7707a9c962
commit 03d1a9df8b
5 changed files with 18 additions and 6 deletions

View File

@ -37,7 +37,7 @@ public class InVMServerLocatorSchema extends AbstractServerLocatorSchema
@Override @Override
protected ServerLocator internalNewObject(URI uri, Map<String, String> query, String name) throws Exception protected ServerLocator internalNewObject(URI uri, Map<String, String> query, String name) throws Exception
{ {
TransportConfiguration tc = InVMTransportConfigurationSchema.createTransportConfiguration(uri, name, "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory"); TransportConfiguration tc = InVMTransportConfigurationSchema.createTransportConfiguration(uri, query, name, "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory");
ServerLocator factory = ActiveMQClient.createServerLocatorWithoutHA(tc); ServerLocator factory = ActiveMQClient.createServerLocatorWithoutHA(tc);
return URISchema.setData(uri, factory, query); return URISchema.setData(uri, factory, query);
} }

View File

@ -27,6 +27,11 @@ import java.util.Map;
public class InVMTransportConfigurationSchema extends AbstractTransportConfigurationSchema public class InVMTransportConfigurationSchema extends AbstractTransportConfigurationSchema
{ {
/* This is the same as org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.CONNECTIONS_ALLOWED,
* but this Maven module can't see that class.
*/
public static final String CONNECTIONS_ALLOWED = "connectionsAllowed";
@Override @Override
public String getSchemaName() public String getSchemaName()
{ {
@ -37,7 +42,7 @@ public class InVMTransportConfigurationSchema extends AbstractTransportConfigura
protected List<TransportConfiguration> internalNewObject(URI uri, Map<String, String> query, String name) throws Exception protected List<TransportConfiguration> internalNewObject(URI uri, Map<String, String> query, String name) throws Exception
{ {
List<TransportConfiguration> configurations = new ArrayList<>(); List<TransportConfiguration> configurations = new ArrayList<>();
configurations.add(createTransportConfiguration(uri, name, getFactoryName())); configurations.add(createTransportConfiguration(uri, query, name, getFactoryName()));
return configurations; return configurations;
} }
@ -52,10 +57,14 @@ public class InVMTransportConfigurationSchema extends AbstractTransportConfigura
return "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory"; return "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory";
} }
public static TransportConfiguration createTransportConfiguration(URI uri, String name, String factoryName) public static TransportConfiguration createTransportConfiguration(URI uri, Map<String, String> query, String name, String factoryName)
{ {
Map<String, Object> inVmTransportConfig = new HashMap<>(); Map<String, Object> inVmTransportConfig = new HashMap<>();
inVmTransportConfig.put("serverId", uri.getHost()); inVmTransportConfig.put("serverId", uri.getHost());
if (query.containsKey(CONNECTIONS_ALLOWED))
{
inVmTransportConfig.put(CONNECTIONS_ALLOWED, query.get(CONNECTIONS_ALLOWED));
}
return new TransportConfiguration(factoryName, inVmTransportConfig, name); return new TransportConfiguration(factoryName, inVmTransportConfig, name);
} }
} }

View File

@ -37,7 +37,7 @@ public class InVMSchema extends AbstractCFSchema
JMSConnectionOptions options = newConectionOptions(uri, query); JMSConnectionOptions options = newConectionOptions(uri, query);
ActiveMQConnectionFactory factory = ActiveMQConnectionFactory factory =
ActiveMQJMSClient.createConnectionFactoryWithoutHA(options.getFactoryTypeEnum(), ActiveMQJMSClient.createConnectionFactoryWithoutHA(options.getFactoryTypeEnum(),
InVMTransportConfigurationSchema.createTransportConfiguration(uri, name, "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory")); InVMTransportConfigurationSchema.createTransportConfiguration(uri, query, name, "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory"));
return setData(uri, factory, query); return setData(uri, factory, query);
} }

View File

@ -36,6 +36,7 @@ import org.apache.activemq.artemis.core.config.DivertConfiguration;
import org.apache.activemq.artemis.core.config.FileDeploymentManager; import org.apache.activemq.artemis.core.config.FileDeploymentManager;
import org.apache.activemq.artemis.core.config.HAPolicyConfiguration; import org.apache.activemq.artemis.core.config.HAPolicyConfiguration;
import org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration; import org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration;
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
import org.apache.activemq.artemis.core.security.Role; import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.core.server.JournalType; import org.apache.activemq.artemis.core.server.JournalType;
import org.apache.activemq.artemis.core.settings.impl.SlowConsumerPolicy; import org.apache.activemq.artemis.core.settings.impl.SlowConsumerPolicy;
@ -130,12 +131,14 @@ public class FileConfigurationTest extends ConfigurationImplTest
{ {
Assert.assertEquals("456", ac.getParams().get("tcpNoDelay")); Assert.assertEquals("456", ac.getParams().get("tcpNoDelay"));
Assert.assertEquals("44", ac.getParams().get("connectionTtl")); Assert.assertEquals("44", ac.getParams().get("connectionTtl"));
Assert.assertEquals("92", ac.getParams().get(TransportConstants.CONNECTIONS_ALLOWED));
} }
else else
{ {
Assert.assertEquals("org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory", Assert.assertEquals("org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory",
ac.getFactoryClassName()); ac.getFactoryClassName());
Assert.assertEquals("0", ac.getParams().get("serverId")); Assert.assertEquals("0", ac.getParams().get("serverId"));
Assert.assertEquals("87", ac.getParams().get(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.CONNECTIONS_ALLOWED));
} }
} }

View File

@ -64,8 +64,8 @@
<connector name="connector2">vm://5</connector> <connector name="connector2">vm://5</connector>
</connectors> </connectors>
<acceptors> <acceptors>
<acceptor>tcp://0.0.0.0:61616?tcpNoDelay=456;connectionTtl=44</acceptor> <acceptor>tcp://0.0.0.0:61616?tcpNoDelay=456;connectionTtl=44;connectionsAllowed=92</acceptor>
<acceptor>vm://0?e1=z1;e2=567</acceptor> <acceptor>vm://0?e1=z1;e2=567;connectionsAllowed=87</acceptor>
</acceptors> </acceptors>
<broadcast-groups> <broadcast-groups>
<broadcast-group name="bg1"> <broadcast-group name="bg1">