This closes #226 on connections-allowed property

This commit is contained in:
Clebert Suconic 2015-05-05 15:06:44 -04:00
commit 59f35a400c
5 changed files with 18 additions and 6 deletions

View File

@ -37,7 +37,7 @@ public class InVMServerLocatorSchema extends AbstractServerLocatorSchema
@Override
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);
return URISchema.setData(uri, factory, query);
}

View File

@ -27,6 +27,11 @@ import java.util.Map;
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
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
{
List<TransportConfiguration> configurations = new ArrayList<>();
configurations.add(createTransportConfiguration(uri, name, getFactoryName()));
configurations.add(createTransportConfiguration(uri, query, name, getFactoryName()));
return configurations;
}
@ -52,10 +57,14 @@ public class InVMTransportConfigurationSchema extends AbstractTransportConfigura
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<>();
inVmTransportConfig.put("serverId", uri.getHost());
if (query.containsKey(CONNECTIONS_ALLOWED))
{
inVmTransportConfig.put(CONNECTIONS_ALLOWED, query.get(CONNECTIONS_ALLOWED));
}
return new TransportConfiguration(factoryName, inVmTransportConfig, name);
}
}

View File

@ -37,7 +37,7 @@ public class InVMSchema extends AbstractCFSchema
JMSConnectionOptions options = newConectionOptions(uri, query);
ActiveMQConnectionFactory factory =
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);
}

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.HAPolicyConfiguration;
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.server.JournalType;
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("44", ac.getParams().get("connectionTtl"));
Assert.assertEquals("92", ac.getParams().get(TransportConstants.CONNECTIONS_ALLOWED));
}
else
{
Assert.assertEquals("org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory",
ac.getFactoryClassName());
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>
</connectors>
<acceptors>
<acceptor>tcp://0.0.0.0:61616?tcpNoDelay=456;connectionTtl=44</acceptor>
<acceptor>vm://0?e1=z1;e2=567</acceptor>
<acceptor>tcp://0.0.0.0:61616?tcpNoDelay=456;connectionTtl=44;connectionsAllowed=92</acceptor>
<acceptor>vm://0?e1=z1;e2=567;connectionsAllowed=87</acceptor>
</acceptors>
<broadcast-groups>
<broadcast-group name="bg1">