activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From martyntay...@apache.org
Subject [1/4] activemq-artemis git commit: NO-JIRA: Adding Acceptor and Connector utility
Date Mon, 03 Apr 2017 11:54:50 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 5f939cf61 -> 57bae51e8


NO-JIRA: Adding Acceptor and Connector utility


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/5b424747
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/5b424747
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/5b424747

Branch: refs/heads/master
Commit: 5b4247479c8f475f4fa3426bff97b1a101f9c8ba
Parents: 5f939cf
Author: Clebert Suconic <clebertsuconic@apache.org>
Authored: Sun Apr 2 19:20:27 2017 -0400
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Sun Apr 2 19:21:14 2017 -0400

----------------------------------------------------------------------
 .../config/ClusterConnectionConfiguration.java  |  5 +-
 .../artemis/core/config/ConfigurationUtils.java | 60 +++++++++++++++++++-
 .../core/config/impl/ConfigurationImpl.java     | 12 +---
 .../deployers/impl/FileConfigurationParser.java | 13 ++---
 .../server/impl/RemotingServiceImpl.java        |  6 +-
 .../artemis/uri/AcceptorParserTest.java         |  5 +-
 6 files changed, 71 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5b424747/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ClusterConnectionConfiguration.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ClusterConnectionConfiguration.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ClusterConnectionConfiguration.java
index 36a5cdf..0189d1a 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ClusterConnectionConfiguration.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ClusterConnectionConfiguration.java
@@ -29,7 +29,6 @@ import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
 import org.apache.activemq.artemis.uri.ClusterConnectionConfigurationParser;
-import org.apache.activemq.artemis.uri.ConnectorTransportConfigurationParser;
 import org.apache.activemq.artemis.utils.uri.URISupport;
 
 public final class ClusterConnectionConfiguration implements Serializable {
@@ -375,14 +374,12 @@ public final class ClusterConnectionConfiguration implements Serializable
{
    public TransportConfiguration[] getTransportConfigurations(Configuration configuration)
throws Exception {
 
       if (getCompositeMembers() != null) {
-         ConnectorTransportConfigurationParser connectorTransportConfigurationParser = new
ConnectorTransportConfigurationParser();
-
          URI[] members = getCompositeMembers().getComponents();
 
          List<TransportConfiguration> list = new LinkedList<>();
 
          for (URI member : members) {
-            list.addAll(connectorTransportConfigurationParser.newObject(member, null));
+            list.addAll(ConfigurationUtils.parseConnectorURI(null, member));
          }
 
          return list.toArray(new TransportConfiguration[list.size()]);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5b424747/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ConfigurationUtils.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ConfigurationUtils.java
index eefd9b1..f2f2fba 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ConfigurationUtils.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ConfigurationUtils.java
@@ -16,7 +16,11 @@
  */
 package org.apache.activemq.artemis.core.config;
 
+import java.net.URI;
+import java.util.List;
+
 import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException;
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.core.config.ha.ColocatedPolicyConfiguration;
 import org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration;
 import org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration;
@@ -35,6 +39,8 @@ import org.apache.activemq.artemis.core.server.cluster.ha.ReplicatedPolicy;
 import org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy;
 import org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreMasterPolicy;
 import org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy;
+import org.apache.activemq.artemis.uri.AcceptorTransportConfigurationParser;
+import org.apache.activemq.artemis.uri.ConnectorTransportConfigurationParser;
 
 public final class ConfigurationUtils {
 
@@ -53,7 +59,8 @@ public final class ConfigurationUtils {
       throw new ActiveMQIllegalStateException("Missing cluster-configuration for replication-clustername
'" + replicationCluster + "'.");
    }
 
-   public static HAPolicy getHAPolicy(HAPolicyConfiguration conf, ActiveMQServer server)
throws ActiveMQIllegalStateException {
+   public static HAPolicy getHAPolicy(HAPolicyConfiguration conf,
+                                      ActiveMQServer server) throws ActiveMQIllegalStateException
{
       if (conf == null) {
          return new LiveOnlyPolicy();
       }
@@ -131,6 +138,57 @@ public final class ConfigurationUtils {
       compareTTLWithCheckPeriod(configuration);
    }
 
+   public static List<TransportConfiguration> parseAcceptorURI(String name, String
uri) {
+      try {
+         AcceptorTransportConfigurationParser parser = new AcceptorTransportConfigurationParser();
+
+         List<TransportConfiguration> configurations = parser.newObject(parser.expandURI(uri),
name);
+
+         return configurations;
+      } catch (Exception e) {
+         throw new RuntimeException(e.getMessage(), e);
+      }
+   }
+
+   public static List<TransportConfiguration> parseAcceptorURI(String name, URI uri)
 {
+      try {
+         AcceptorTransportConfigurationParser parser = new AcceptorTransportConfigurationParser();
+
+         List<TransportConfiguration> configurations = parser.newObject(uri, name);
+
+         return configurations;
+      } catch (Exception e) {
+         throw new RuntimeException(e.getMessage(), e);
+      }
+
+   }
+
+   public static List<TransportConfiguration> parseConnectorURI(String name, String
uri) {
+
+      try {
+         ConnectorTransportConfigurationParser parser = new ConnectorTransportConfigurationParser();
+
+         List<TransportConfiguration> configurations = parser.newObject(parser.expandURI(uri),
name);
+
+         return configurations;
+      } catch (Exception e) {
+         throw new RuntimeException(e.getMessage(), e);
+      }
+   }
+
+   public static List<TransportConfiguration> parseConnectorURI(String name, URI uri)
{
+      try {
+         ConnectorTransportConfigurationParser parser = new ConnectorTransportConfigurationParser();
+
+         List<TransportConfiguration> configurations = parser.newObject(uri, name);
+
+         return configurations;
+      } catch (Exception e) {
+         throw new RuntimeException(e.getMessage(), e);
+      }
+
+   }
+
    private static void compareTTLWithCheckPeriod(Configuration configuration) {
       for (ClusterConnectionConfiguration c : configuration.getClusterConfigurations())
          compareTTLWithCheckPeriod(c.getName(), c.getConnectionTTL(), configuration.getConnectionTTLOverride(),
c.getClientFailureCheckPeriod());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5b424747/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
index 329f654..9372451 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
@@ -47,6 +47,7 @@ import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.core.config.BridgeConfiguration;
 import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
 import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.ConfigurationUtils;
 import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration;
 import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
 import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
@@ -64,8 +65,6 @@ import org.apache.activemq.artemis.core.server.SecuritySettingPlugin;
 import org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.core.settings.impl.ResourceLimitSettings;
-import org.apache.activemq.artemis.uri.AcceptorTransportConfigurationParser;
-import org.apache.activemq.artemis.uri.ConnectorTransportConfigurationParser;
 import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader;
 import org.apache.activemq.artemis.utils.uri.BeanSupport;
 import org.jboss.logging.Logger;
@@ -493,10 +492,7 @@ public class ConfigurationImpl implements Configuration, Serializable
{
 
    @Override
    public ConfigurationImpl addAcceptorConfiguration(final String name, final String uri)
throws Exception {
-
-      AcceptorTransportConfigurationParser parser = new AcceptorTransportConfigurationParser();
-
-      List<TransportConfiguration> configurations = parser.newObject(parser.expandURI(uri),
name);
+      List<TransportConfiguration> configurations = ConfigurationUtils.parseAcceptorURI(name,
uri);
 
       for (TransportConfiguration config : configurations) {
          addAcceptorConfiguration(config);
@@ -531,9 +527,7 @@ public class ConfigurationImpl implements Configuration, Serializable
{
    @Override
    public ConfigurationImpl addConnectorConfiguration(final String name, final String uri)
throws Exception {
 
-      ConnectorTransportConfigurationParser parser = new ConnectorTransportConfigurationParser();
-
-      List<TransportConfiguration> configurations = parser.newObject(parser.expandURI(uri),
name);
+      List<TransportConfiguration> configurations = ConfigurationUtils.parseConnectorURI(name,
uri);
 
       for (TransportConfiguration config : configurations) {
          addConnectorConfiguration(name, config);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5b424747/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
index 4055b5c..03a8605 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
@@ -35,6 +35,7 @@ import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration;
 import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
 import org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory;
 import org.apache.activemq.artemis.api.core.Pair;
+import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory;
@@ -42,6 +43,7 @@ import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
 import org.apache.activemq.artemis.core.config.BridgeConfiguration;
 import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
 import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.ConfigurationUtils;
 import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration;
 import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
 import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
@@ -63,7 +65,6 @@ import org.apache.activemq.artemis.core.security.Role;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.DivertConfigurationRoutingType;
 import org.apache.activemq.artemis.core.server.JournalType;
-import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.core.server.SecuritySettingPlugin;
 import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
 import org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration;
@@ -71,8 +72,6 @@ import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.core.settings.impl.ResourceLimitSettings;
 import org.apache.activemq.artemis.core.settings.impl.SlowConsumerPolicy;
-import org.apache.activemq.artemis.uri.AcceptorTransportConfigurationParser;
-import org.apache.activemq.artemis.uri.ConnectorTransportConfigurationParser;
 import org.apache.activemq.artemis.utils.ByteUtil;
 import org.apache.activemq.artemis.utils.ClassloadingUtil;
 import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec;
@@ -995,9 +994,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil
{
 
       String uri = e.getChildNodes().item(0).getNodeValue();
 
-      AcceptorTransportConfigurationParser parser = new AcceptorTransportConfigurationParser();
-
-      List<TransportConfiguration> configurations = parser.newObject(parser.expandURI(uri),
name);
+      List<TransportConfiguration> configurations = ConfigurationUtils.parseAcceptorURI(name,
uri);
 
       Map<String, Object> params = configurations.get(0).getParams();
 
@@ -1020,9 +1017,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil
{
 
       String uri = e.getChildNodes().item(0).getNodeValue();
 
-      ConnectorTransportConfigurationParser parser = new ConnectorTransportConfigurationParser();
-
-      List<TransportConfiguration> configurations = parser.newObject(parser.expandURI(uri),
name);
+      List<TransportConfiguration> configurations = ConfigurationUtils.parseConnectorURI(name,
uri);
 
       Map<String, Object> params = configurations.get(0).getParams();
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5b424747/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
index 9a227bb..e0e5b52 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
@@ -45,6 +45,7 @@ import org.apache.activemq.artemis.api.core.BaseInterceptor;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.ConfigurationUtils;
 import org.apache.activemq.artemis.core.protocol.core.CoreRemotingConnection;
 import org.apache.activemq.artemis.core.protocol.core.impl.CoreProtocolManagerFactory;
 import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
@@ -68,7 +69,6 @@ import org.apache.activemq.artemis.spi.core.remoting.AcceptorFactory;
 import org.apache.activemq.artemis.spi.core.remoting.BufferHandler;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
 import org.apache.activemq.artemis.spi.core.remoting.ServerConnectionLifeCycleListener;
-import org.apache.activemq.artemis.uri.AcceptorTransportConfigurationParser;
 import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;
 import org.apache.activemq.artemis.utils.ConfigurationHelper;
 import org.apache.activemq.artemis.utils.ReusableLatch;
@@ -227,9 +227,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
 
    @Override
    public Acceptor createAcceptor(String name, String uri) throws Exception {
-      AcceptorTransportConfigurationParser parser = new AcceptorTransportConfigurationParser();
-
-      List<TransportConfiguration> configurations = parser.newObject(parser.expandURI(uri),
name);
+      List<TransportConfiguration> configurations = ConfigurationUtils.parseAcceptorURI(name,
uri);
 
       return createAcceptor(configurations.get(0));
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5b424747/artemis-server/src/test/java/org/apache/activemq/artemis/uri/AcceptorParserTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/uri/AcceptorParserTest.java
b/artemis-server/src/test/java/org/apache/activemq/artemis/uri/AcceptorParserTest.java
index be26473..b85cca6 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/uri/AcceptorParserTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/uri/AcceptorParserTest.java
@@ -17,10 +17,10 @@
 
 package org.apache.activemq.artemis.uri;
 
-import java.net.URI;
 import java.util.List;
 
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
+import org.apache.activemq.artemis.core.config.ConfigurationUtils;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -28,8 +28,7 @@ public class AcceptorParserTest {
 
    @Test
    public void testAcceptor() throws Exception {
-      AcceptorTransportConfigurationParser parser = new AcceptorTransportConfigurationParser();
-      List<TransportConfiguration> configs = parser.newObject(new URI("tcp://localhost:8080?tcpSendBufferSize=1048576&tcpReceiveBufferSize=1048576&protocols=openwire&banana=x"),
"test");
+      List<TransportConfiguration> configs = ConfigurationUtils.parseAcceptorURI("test",
"tcp://localhost:8080?tcpSendBufferSize=1048576&tcpReceiveBufferSize=1048576&protocols=openwire&banana=x");
 
       for (TransportConfiguration config : configs) {
          System.out.println("config:" + config);


Mime
View raw message