You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2017/01/19 15:32:51 UTC

[1/2] activemq-artemis git commit: ARTEMIS-873 support byte notation in XML config

Repository: activemq-artemis
Updated Branches:
  refs/heads/master fbc77b44c -> 4da561c7b


ARTEMIS-873 support byte notation in XML config


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

Branch: refs/heads/master
Commit: 113b28577c792a9fef5ac74abe6cd65bc08ffcf2
Parents: fbc77b4
Author: Justin Bertram <jb...@apache.org>
Authored: Wed Jan 18 15:33:32 2017 -0600
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Jan 19 10:32:38 2017 -0500

----------------------------------------------------------------------
 .../artemis/logs/ActiveMQUtilBundle.java        |  3 ++
 .../apache/activemq/artemis/utils/ByteUtil.java | 36 +++++++++++++
 .../activemq/artemis/utils/ByteUtilTest.java    | 39 +++++++++++++-
 .../client/ActiveMQClientMessageBundle.java     |  2 +-
 .../deployers/impl/FileConfigurationParser.java | 25 ++++-----
 .../artemis/utils/XMLConfigurationUtil.java     | 22 ++++++++
 .../resources/schema/artemis-configuration.xsd  | 53 +++++++++++---------
 .../core/config/impl/FileConfigurationTest.java |  7 +--
 .../resources/ConfigurationTest-full-config.xml |  7 +--
 9 files changed, 149 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/113b2857/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java
index 91744c3..c32bc67 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java
@@ -45,4 +45,7 @@ public interface ActiveMQUtilBundle {
 
    @Message(id = 209003, value = "Error instantiating codec {0}", format = Message.Format.MESSAGE_FORMAT)
    IllegalArgumentException errorCreatingCodec(@Cause Exception e, String codecClassName);
+
+   @Message(id = 209004, value = "Failed to parse long value from {0}", format = Message.Format.MESSAGE_FORMAT)
+   IllegalArgumentException failedToParseLong(String value);
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/113b2857/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java
index c22f37e..bee8790 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java
@@ -17,11 +17,14 @@
 package org.apache.activemq.artemis.utils;
 
 import java.nio.ByteBuffer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.UnpooledByteBufAllocator;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.logs.ActiveMQUtilBundle;
 import org.jboss.logging.Logger;
 
 public class ByteUtil {
@@ -29,6 +32,12 @@ public class ByteUtil {
    public static final String NON_ASCII_STRING = "@@@@@";
 
    private static final char[] hexArray = "0123456789ABCDEF".toCharArray();
+   private static final String prefix = "^\\s*(\\d+)\\s*";
+   private static final String suffix = "(b)?\\s*$";
+   private static final Pattern ONE = Pattern.compile(prefix + suffix, Pattern.CASE_INSENSITIVE);
+   private static final Pattern KILO = Pattern.compile(prefix + "k" + suffix, Pattern.CASE_INSENSITIVE);
+   private static final Pattern MEGA = Pattern.compile(prefix + "m" + suffix, Pattern.CASE_INSENSITIVE);
+   private static final Pattern GIGA = Pattern.compile(prefix + "g" + suffix, Pattern.CASE_INSENSITIVE);
 
    public static void debugFrame(Logger logger, String message, ByteBuf byteIn) {
       if (logger.isTraceEnabled()) {
@@ -163,4 +172,31 @@ public class ByteUtil {
       return ret;
    }
 
+   public static long convertTextBytes(final String text) {
+      try {
+         Matcher m = ONE.matcher(text);
+         if (m.matches()) {
+            return Long.valueOf(Long.parseLong(m.group(1)));
+         }
+
+         m = KILO.matcher(text);
+         if (m.matches()) {
+            return Long.valueOf(Long.parseLong(m.group(1)) * 1024);
+         }
+
+         m = MEGA.matcher(text);
+         if (m.matches()) {
+            return Long.valueOf(Long.parseLong(m.group(1)) * 1024 * 1024);
+         }
+
+         m = GIGA.matcher(text);
+         if (m.matches()) {
+            return Long.valueOf(Long.parseLong(m.group(1)) * 1024 * 1024 * 1024);
+         }
+
+         return Long.parseLong(text);
+      } catch (NumberFormatException e) {
+         throw ActiveMQUtilBundle.BUNDLE.failedToParseLong(text);
+      }
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/113b2857/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ByteUtilTest.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ByteUtilTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ByteUtilTest.java
index feebae1..de18598 100644
--- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ByteUtilTest.java
+++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ByteUtilTest.java
@@ -19,6 +19,10 @@ package org.apache.activemq.artemis.utils;
 import org.junit.Assert;
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 public class ByteUtilTest {
 
    @Test
@@ -32,8 +36,8 @@ public class ByteUtilTest {
 
    @Test
    public void testNonASCII() {
-      Assert.assertEquals("aA", ByteUtil.toSimpleString(new byte[]{97, 0, 65, 0}));
-      Assert.assertEquals(ByteUtil.NON_ASCII_STRING, ByteUtil.toSimpleString(new byte[]{0, 97, 0, 65}));
+      assertEquals("aA", ByteUtil.toSimpleString(new byte[]{97, 0, 65, 0}));
+      assertEquals(ByteUtil.NON_ASCII_STRING, ByteUtil.toSimpleString(new byte[]{0, 97, 0, 65}));
 
       System.out.println(ByteUtil.toSimpleString(new byte[]{0, 97, 0, 65}));
    }
@@ -50,4 +54,35 @@ public class ByteUtilTest {
       }
    }
 
+   @Test
+   public void testTextBytesToLongBytes() {
+      long[] factor = new long[] {1, 5, 10};
+      String[] type = new String[]{"", "b", "k", "m", "g"};
+      long[] size = new long[]{1, 1, 1024, 1024 * 1024, 1024 * 1024 * 1024};
+
+      for (int i = 0; i < 3; i++) {
+         for (int j = 0; j < type.length; j++) {
+            assertEquals(factor[i] * size[j], ByteUtil.convertTextBytes(factor[i] + type[j]));
+            assertEquals(factor[i] * size[j], ByteUtil.convertTextBytes(factor[i] + " " + type[j]));
+            assertEquals(factor[i] * size[j], ByteUtil.convertTextBytes(factor[i] + type[j].toUpperCase()));
+            assertEquals(factor[i] * size[j], ByteUtil.convertTextBytes(factor[i] + " " + type[j].toUpperCase()));
+            if (j >= 2) {
+               assertEquals(factor[i] * size[j], ByteUtil.convertTextBytes(factor[i] + type[j] + "b"));
+               assertEquals(factor[i] * size[j], ByteUtil.convertTextBytes(factor[i] + " " + type[j] + "b"));
+               assertEquals(factor[i] * size[j], ByteUtil.convertTextBytes(factor[i] + type[j].toUpperCase() + "B"));
+               assertEquals(factor[i] * size[j], ByteUtil.convertTextBytes(factor[i] + " " + type[j].toUpperCase() + "B"));
+            }
+         }
+      }
+   }
+
+   @Test
+   public void testTextBytesToLongBytesNegative() {
+      try {
+         ByteUtil.convertTextBytes("x");
+         fail();
+      } catch (Exception e) {
+         assertTrue(e instanceof IllegalArgumentException);
+      }
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/113b2857/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java
index 4a4a9a3..583acc3 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java
@@ -212,7 +212,7 @@ public interface ActiveMQClientMessageBundle {
    IllegalArgumentException mustBeInteger(Node elem, String value);
 
    @Message(id = 119055, value = "Element {0} requires a valid Long value, but ''{1}'' cannot be parsed as a Long", format = Message.Format.MESSAGE_FORMAT)
-   IllegalArgumentException mustBeLong(Node elem, String value);
+   IllegalArgumentException mustBeLong(Node element, String value);
 
    @Message(id = 119056, value = "Failed to get decoder")
    IllegalArgumentException failedToGetDecoder(@Cause Exception e);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/113b2857/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 2721214..d589416 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
@@ -62,8 +62,8 @@ import org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory;
 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.RoutingType;
 import org.apache.activemq.artemis.core.server.JournalType;
+import org.apache.activemq.artemis.core.server.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;
@@ -73,6 +73,7 @@ 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;
 import org.apache.activemq.artemis.utils.PasswordMaskingUtil;
@@ -316,7 +317,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
 
       config.setConfigurationFileRefreshPeriod(getLong(e, "configuration-file-refresh-period", config.getConfigurationFileRefreshPeriod(), Validators.GT_ZERO));
 
-      config.setGlobalMaxSize(getLong(e, GLOBAL_MAX_SIZE, config.getGlobalMaxSize(), Validators.MINUS_ONE_OR_GT_ZERO));
+      config.setGlobalMaxSize(getTextBytesAsLongBytes(e, GLOBAL_MAX_SIZE, config.getGlobalMaxSize(), Validators.MINUS_ONE_OR_GT_ZERO));
 
       config.setMaxDiskUsage(getInteger(e, MAX_DISK_USAGE, config.getMaxDiskUsage(), Validators.PERCENTAGE));
 
@@ -522,11 +523,11 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
 
       config.setJournalSyncNonTransactional(getBoolean(e, "journal-sync-non-transactional", config.isJournalSyncNonTransactional()));
 
-      config.setJournalFileSize(getInteger(e, "journal-file-size", config.getJournalFileSize(), Validators.GT_ZERO));
+      config.setJournalFileSize(getTextBytesAsIntBytes(e, "journal-file-size", config.getJournalFileSize(), Validators.GT_ZERO));
 
       int journalBufferTimeout = getInteger(e, "journal-buffer-timeout", config.getJournalType() == JournalType.ASYNCIO ? ArtemisConstants.DEFAULT_JOURNAL_BUFFER_TIMEOUT_AIO : ArtemisConstants.DEFAULT_JOURNAL_BUFFER_TIMEOUT_NIO, Validators.GT_ZERO);
 
-      int journalBufferSize = getInteger(e, "journal-buffer-size", config.getJournalType() == JournalType.ASYNCIO ? ArtemisConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO : ArtemisConstants.DEFAULT_JOURNAL_BUFFER_SIZE_NIO, Validators.GT_ZERO);
+      int journalBufferSize = getTextBytesAsIntBytes(e, "journal-buffer-size", config.getJournalType() == JournalType.ASYNCIO ? ArtemisConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO : ArtemisConstants.DEFAULT_JOURNAL_BUFFER_SIZE_NIO, Validators.GT_ZERO);
 
       int journalMaxIO = getInteger(e, "journal-max-io", config.getJournalType() == JournalType.ASYNCIO ? ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio() : ActiveMQDefaultConfiguration.getDefaultJournalMaxIoNio(), Validators.GT_ZERO);
 
@@ -836,9 +837,9 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
          } else if (MAX_REDELIVERY_DELAY_NODE_NAME.equalsIgnoreCase(name)) {
             addressSettings.setMaxRedeliveryDelay(XMLUtil.parseLong(child));
          } else if (MAX_SIZE_BYTES_NODE_NAME.equalsIgnoreCase(name)) {
-            addressSettings.setMaxSizeBytes(XMLUtil.parseLong(child));
+            addressSettings.setMaxSizeBytes(ByteUtil.convertTextBytes(getTrimmedTextContent(child)));
          } else if (PAGE_SIZE_BYTES_NODE_NAME.equalsIgnoreCase(name)) {
-            addressSettings.setPageSizeBytes(XMLUtil.parseLong(child));
+            addressSettings.setPageSizeBytes(ByteUtil.convertTextBytes(getTrimmedTextContent(child)));
          } else if (PAGE_MAX_CACHE_SIZE_NODE_NAME.equalsIgnoreCase(name)) {
             addressSettings.setPageCacheMaxSize(XMLUtil.parseInt(child));
          } else if (MESSAGE_COUNTER_HISTORY_DAY_LIMIT_NODE_NAME.equalsIgnoreCase(name)) {
@@ -1428,7 +1429,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
 
       double retryIntervalMultiplier = getDouble(e, "retry-interval-multiplier", ActiveMQDefaultConfiguration.getDefaultClusterRetryIntervalMultiplier(), Validators.GT_ZERO);
 
-      int minLargeMessageSize = getInteger(e, "min-large-message-size", ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, Validators.GT_ZERO);
+      int minLargeMessageSize = getTextBytesAsIntBytes(e, "min-large-message-size", ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, Validators.GT_ZERO);
 
       long maxRetryInterval = getLong(e, "max-retry-interval", ActiveMQDefaultConfiguration.getDefaultClusterMaxRetryInterval(), Validators.GT_ZERO);
 
@@ -1436,9 +1437,9 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
 
       int reconnectAttempts = getInteger(e, "reconnect-attempts", ActiveMQDefaultConfiguration.getDefaultClusterReconnectAttempts(), Validators.MINUS_ONE_OR_GE_ZERO);
 
-      int confirmationWindowSize = getInteger(e, "confirmation-window-size", ActiveMQDefaultConfiguration.getDefaultClusterConfirmationWindowSize(), Validators.GT_ZERO);
+      int confirmationWindowSize = getTextBytesAsIntBytes(e, "confirmation-window-size", ActiveMQDefaultConfiguration.getDefaultClusterConfirmationWindowSize(), Validators.GT_ZERO);
 
-      int producerWindowSize = getInteger(e, "producer-window-size", ActiveMQDefaultConfiguration.getDefaultBridgeProducerWindowSize(), Validators.MINUS_ONE_OR_GT_ZERO);
+      int producerWindowSize = getTextBytesAsIntBytes(e, "producer-window-size", ActiveMQDefaultConfiguration.getDefaultBridgeProducerWindowSize(), Validators.MINUS_ONE_OR_GT_ZERO);
 
       long clusterNotificationInterval = getLong(e, "notification-interval", ActiveMQDefaultConfiguration.getDefaultClusterNotificationInterval(), Validators.GT_ZERO);
 
@@ -1499,9 +1500,9 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
       String transformerClassName = getString(brNode, "transformer-class-name", null, Validators.NO_CHECK);
 
       // Default bridge conf
-      int confirmationWindowSize = getInteger(brNode, "confirmation-window-size", ActiveMQDefaultConfiguration.getDefaultBridgeConfirmationWindowSize(), Validators.GT_ZERO);
+      int confirmationWindowSize = getTextBytesAsIntBytes(brNode, "confirmation-window-size", ActiveMQDefaultConfiguration.getDefaultBridgeConfirmationWindowSize(), Validators.GT_ZERO);
 
-      int producerWindowSize = getInteger(brNode, "producer-window-size", ActiveMQDefaultConfiguration.getDefaultBridgeConfirmationWindowSize(), Validators.GT_ZERO);
+      int producerWindowSize = getTextBytesAsIntBytes(brNode, "producer-window-size", ActiveMQDefaultConfiguration.getDefaultBridgeConfirmationWindowSize(), Validators.GT_ZERO);
 
       long retryInterval = getLong(brNode, "retry-interval", ActiveMQClient.DEFAULT_RETRY_INTERVAL, Validators.GT_ZERO);
 
@@ -1509,7 +1510,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
 
       long connectionTTL = getLong(brNode, "connection-ttl", ActiveMQClient.DEFAULT_CONNECTION_TTL, Validators.GT_ZERO);
 
-      int minLargeMessageSize = getInteger(brNode, "min-large-message-size", ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, Validators.GT_ZERO);
+      int minLargeMessageSize = getTextBytesAsIntBytes(brNode, "min-large-message-size", ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, Validators.GT_ZERO);
 
       long maxRetryInterval = getLong(brNode, "max-retry-interval", ActiveMQClient.DEFAULT_MAX_RETRY_INTERVAL, Validators.GT_ZERO);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/113b2857/artemis-server/src/main/java/org/apache/activemq/artemis/utils/XMLConfigurationUtil.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/utils/XMLConfigurationUtil.java b/artemis-server/src/main/java/org/apache/activemq/artemis/utils/XMLConfigurationUtil.java
index 79dcd1d..7ce5280 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/utils/XMLConfigurationUtil.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/utils/XMLConfigurationUtil.java
@@ -79,6 +79,21 @@ public class XMLConfigurationUtil {
       }
    }
 
+   public static final Long getTextBytesAsLongBytes(final Element e,
+                                    final String name,
+                                    final long def,
+                                    final Validators.Validator validator) {
+      NodeList nl = e.getElementsByTagName(name);
+      if (nl.getLength() > 0) {
+         long val = ByteUtil.convertTextBytes(nl.item(0).getTextContent().trim());
+         validator.validate(name, val);
+         return val;
+      } else {
+         validator.validate(name, def);
+         return def;
+      }
+   }
+
    public static final Integer getInteger(final Element e,
                                           final String name,
                                           final int def,
@@ -94,6 +109,13 @@ public class XMLConfigurationUtil {
       }
    }
 
+   public static final Integer getTextBytesAsIntBytes(final Element e,
+                                          final String name,
+                                          final int def,
+                                          final Validators.Validator validator) {
+      return getTextBytesAsLongBytes(e, name, def, validator).intValue();
+   }
+
    public static final Boolean getBoolean(final Element e, final String name, final boolean def) {
       NodeList nl = e.getElementsByTagName(name);
       if (nl.getLength() > 0) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/113b2857/artemis-server/src/main/resources/schema/artemis-configuration.xsd
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/resources/schema/artemis-configuration.xsd b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
index c23a2ea..66739fe 100644
--- a/artemis-server/src/main/resources/schema/artemis-configuration.xsd
+++ b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
@@ -597,10 +597,11 @@
             </xsd:annotation>
          </xsd:element>
 
-         <xsd:element name="journal-buffer-size" type="xsd:long" default="501760" maxOccurs="1" minOccurs="0">
+         <xsd:element name="journal-buffer-size" type="xsd:string" default="501760" maxOccurs="1" minOccurs="0">
             <xsd:annotation>
                <xsd:documentation>
-                  The size of the internal buffer on the journal in KiB.
+                  The size (in bytes) of the internal buffer on the journal. Supports byte notation like "K", "Mb",
+                  "GB", etc.
                </xsd:documentation>
             </xsd:annotation>
          </xsd:element>
@@ -631,10 +632,10 @@
             </xsd:annotation>
          </xsd:element>
 
-         <xsd:element name="journal-file-size" default="10485760" type="xsd:int" maxOccurs="1" minOccurs="0">
+         <xsd:element name="journal-file-size" default="10485760" type="xsd:string" maxOccurs="1" minOccurs="0">
             <xsd:annotation>
                <xsd:documentation>
-                  the size (in bytes) of each journal file
+                  The size (in bytes) of each journal file. Supports byte notation like "K", "Mb", "GB", etc.
                </xsd:documentation>
             </xsd:annotation>
          </xsd:element>
@@ -704,11 +705,11 @@
             </xsd:annotation>
          </xsd:element>
 
-         <xsd:element name="global-max-size" type="xsd:long" default="-1" maxOccurs="1" minOccurs="0">
+         <xsd:element name="global-max-size" type="xsd:string" default="-1" maxOccurs="1" minOccurs="0">
             <xsd:annotation>
                <xsd:documentation>
-                  Global Max Size before all addresses will enter into their Full Policy configured upon messages being
-                  produced.
+                  Size (in bytes) before all addresses will enter into their Full Policy configured upon messages being
+                  produced. Supports byte notation like "K", "Mb", "GB", etc.
                </xsd:documentation>
             </xsd:annotation>
          </xsd:element>
@@ -1168,11 +1169,11 @@
             </xsd:annotation>
          </xsd:element>
 
-         <xsd:element name="min-large-message-size" type="xsd:int" default="102400" maxOccurs="1" minOccurs="0">
+         <xsd:element name="min-large-message-size" type="xsd:string" default="102400" maxOccurs="1" minOccurs="0">
             <xsd:annotation>
                <xsd:documentation>
-                  Any message larger than this size is considered a large message (to be sent in
-                  chunks)
+                  Any message larger than this size (in bytes) is considered a large message (to be sent in
+                  chunks). Supports byte notation like "K", "Mb", "GB", etc.
                </xsd:documentation>
             </xsd:annotation>
          </xsd:element>
@@ -1251,18 +1252,19 @@
             </xsd:annotation>
          </xsd:element>
 
-         <xsd:element name="confirmation-window-size" type="xsd:int" maxOccurs="1" minOccurs="0" default="1048576">
+         <xsd:element name="confirmation-window-size" type="xsd:string" maxOccurs="1" minOccurs="0" default="1048576">
             <xsd:annotation>
                <xsd:documentation>
-                  Once the bridge has received this many bytes, it sends a confirmation
+                  Once the bridge has received this many bytes, it sends a confirmation. Supports byte notation like
+                  "K", "Mb", "GB", etc.
                </xsd:documentation>
             </xsd:annotation>
          </xsd:element>
 
-         <xsd:element name="producer-window-size" type="xsd:int" maxOccurs="1" minOccurs="0" default="-1">
+         <xsd:element name="producer-window-size" type="xsd:string" maxOccurs="1" minOccurs="0" default="-1">
             <xsd:annotation>
                <xsd:documentation>
-                  Producer flow control
+                  Producer flow control. Supports byte notation like "K", "Mb", "GB", etc.
                </xsd:documentation>
             </xsd:annotation>
          </xsd:element>
@@ -1388,10 +1390,11 @@
             </xsd:annotation>
          </xsd:element>
 
-         <xsd:element name="min-large-message-size" type="xsd:int" maxOccurs="1" minOccurs="0">
+         <xsd:element name="min-large-message-size" type="xsd:string" maxOccurs="1" minOccurs="0">
             <xsd:annotation>
                <xsd:documentation>
-                  Messages larger than this are considered large-messages
+                  Messages larger than this are considered large-messages. Supports byte notation like
+                  "K", "Mb", "GB", etc.
                </xsd:documentation>
             </xsd:annotation>
          </xsd:element>
@@ -1485,18 +1488,19 @@
             </xsd:annotation>
          </xsd:element>
 
-         <xsd:element name="confirmation-window-size" type="xsd:int" default="1048576" maxOccurs="1" minOccurs="0">
+         <xsd:element name="confirmation-window-size" type="xsd:string" default="1048576" maxOccurs="1" minOccurs="0">
             <xsd:annotation>
                <xsd:documentation>
-                  The size (in bytes) of the window used for confirming data from the server connected to.
+                  The size (in bytes) of the window used for confirming data from the server connected to. Supports
+                  byte notation like "K", "Mb", "GB", etc.
                </xsd:documentation>
             </xsd:annotation>
          </xsd:element>
 
-         <xsd:element name="producer-window-size" type="xsd:int" maxOccurs="1" minOccurs="0" default="-1">
+         <xsd:element name="producer-window-size" type="xsd:string" maxOccurs="1" minOccurs="0" default="-1">
             <xsd:annotation>
                <xsd:documentation>
-                  Producer flow control
+                  Producer flow control. Supports byte notation like "K", "Mb", "GB", etc.
                </xsd:documentation>
             </xsd:annotation>
          </xsd:element>
@@ -2365,11 +2369,11 @@
                </xsd:annotation>
             </xsd:element>
 
-            <xsd:element name="max-size-bytes" type="xsd:long" default="-1" maxOccurs="1" minOccurs="0">
+            <xsd:element name="max-size-bytes" type="xsd:string" default="-1" maxOccurs="1" minOccurs="0">
                <xsd:annotation>
                   <xsd:documentation>
                      the maximum size (in bytes) for an address (-1 means no limits). This is used in PAGING, BLOCK and
-                     FAIL policies.
+                     FAIL policies. Supports byte notation like "K", "Mb", "GB", etc.
                   </xsd:documentation>
                </xsd:annotation>
             </xsd:element>
@@ -2385,10 +2389,11 @@
                </xsd:annotation>
             </xsd:element>
 
-            <xsd:element name="page-size-bytes" type="xsd:long" default="10485760" maxOccurs="1" minOccurs="0">
+            <xsd:element name="page-size-bytes" type="xsd:string" default="10485760" maxOccurs="1" minOccurs="0">
                <xsd:annotation>
                   <xsd:documentation>
-                     the page size (in bytes) to use for an address
+                     The page size (in bytes) to use for an address. Supports byte notation like "K", "Mb",
+                     "GB", etc.
                   </xsd:documentation>
                </xsd:annotation>
             </xsd:element>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/113b2857/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
index 29f8ed6..1124614 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
@@ -215,7 +215,7 @@ public class FileConfigurationTest extends ConfigurationImplTest {
          if (bc.getName().equals("bridge1")) {
             Assert.assertEquals("bridge1", bc.getName());
             Assert.assertEquals("queue1", bc.getQueueName());
-            Assert.assertEquals("minLargeMessageSize", 4, bc.getMinLargeMessageSize());
+            Assert.assertEquals("minLargeMessageSize", 4194304, bc.getMinLargeMessageSize());
             assertEquals("check-period", 31, bc.getClientFailureCheckPeriod());
             assertEquals("connection time-to-live", 370, bc.getConnectionTTL());
             Assert.assertEquals("bridge-forwarding-address1", bc.getForwardingAddress());
@@ -229,6 +229,7 @@ public class FileConfigurationTest extends ConfigurationImplTest {
             Assert.assertEquals("connector1", bc.getStaticConnectors().get(0));
             Assert.assertEquals(null, bc.getDiscoveryGroupName());
             Assert.assertEquals(444, bc.getProducerWindowSize());
+            Assert.assertEquals(1073741824, bc.getConfirmationWindowSize());
          } else {
             Assert.assertEquals("bridge2", bc.getName());
             Assert.assertEquals("queue2", bc.getQueueName());
@@ -237,7 +238,7 @@ public class FileConfigurationTest extends ConfigurationImplTest {
             Assert.assertEquals(null, bc.getTransformerClassName());
             Assert.assertEquals(null, bc.getStaticConnectors());
             Assert.assertEquals("dg1", bc.getDiscoveryGroupName());
-            Assert.assertEquals(555, bc.getProducerWindowSize());
+            Assert.assertEquals(568320, bc.getProducerWindowSize());
          }
       }
 
@@ -294,7 +295,7 @@ public class FileConfigurationTest extends ConfigurationImplTest {
       assertEquals("a1.1", conf.getAddressesSettings().get("a1").getDeadLetterAddress().toString());
       assertEquals("a1.2", conf.getAddressesSettings().get("a1").getExpiryAddress().toString());
       assertEquals(1, conf.getAddressesSettings().get("a1").getRedeliveryDelay());
-      assertEquals(81781728121878L, conf.getAddressesSettings().get("a1").getMaxSizeBytes());
+      assertEquals(856686592L, conf.getAddressesSettings().get("a1").getMaxSizeBytes());
       assertEquals(81738173872337L, conf.getAddressesSettings().get("a1").getPageSizeBytes());
       assertEquals(10, conf.getAddressesSettings().get("a1").getPageCacheMaxSize());
       assertEquals(4, conf.getAddressesSettings().get("a1").getMessageCounterHistoryDayLimit());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/113b2857/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
index 65047ac..9ed5584 100644
--- a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
+++ b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
@@ -140,7 +140,7 @@
             <forwarding-address>bridge-forwarding-address1</forwarding-address>
             <filter string="sku > 1"/>
             <transformer-class-name>org.foo.BridgeTransformer</transformer-class-name>
-            <min-large-message-size>4</min-large-message-size>
+            <min-large-message-size>4M</min-large-message-size>
             <check-period>31</check-period>
             <connection-ttl>370</connection-ttl>
             <retry-interval>3</retry-interval>
@@ -149,6 +149,7 @@
             <reconnect-attempts>2</reconnect-attempts>
             <failover-on-server-shutdown>false</failover-on-server-shutdown>
             <use-duplicate-detection>true</use-duplicate-detection>
+            <confirmation-window-size>1G</confirmation-window-size>
             <producer-window-size>444</producer-window-size>
             <static-connectors>
                <connector-ref>connector1</connector-ref>
@@ -157,7 +158,7 @@
          <bridge name="bridge2">
             <queue-name>queue2</queue-name>
             <forwarding-address>bridge-forwarding-address2</forwarding-address>
-            <producer-window-size>555</producer-window-size>
+            <producer-window-size>555k</producer-window-size>
             <discovery-group-ref discovery-group-name="dg1"/>
          </bridge>
       </bridges>
@@ -257,7 +258,7 @@
             <dead-letter-address>a1.1</dead-letter-address>
             <expiry-address>a1.2</expiry-address>
             <redelivery-delay>1</redelivery-delay>
-            <max-size-bytes>81781728121878</max-size-bytes>
+            <max-size-bytes>817M</max-size-bytes>
             <page-size-bytes>81738173872337</page-size-bytes>
             <page-max-cache-size>10</page-max-cache-size>
             <message-counter-history-day-limit>4</message-counter-history-day-limit>


[2/2] activemq-artemis git commit: This closes #971

Posted by cl...@apache.org.
This closes #971


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

Branch: refs/heads/master
Commit: 4da561c7b0fdb95189d93d177706eec6bb1ea95c
Parents: fbc77b4 113b285
Author: Clebert Suconic <cl...@apache.org>
Authored: Thu Jan 19 10:32:39 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Jan 19 10:32:39 2017 -0500

----------------------------------------------------------------------
 .../artemis/logs/ActiveMQUtilBundle.java        |  3 ++
 .../apache/activemq/artemis/utils/ByteUtil.java | 36 +++++++++++++
 .../activemq/artemis/utils/ByteUtilTest.java    | 39 +++++++++++++-
 .../client/ActiveMQClientMessageBundle.java     |  2 +-
 .../deployers/impl/FileConfigurationParser.java | 25 ++++-----
 .../artemis/utils/XMLConfigurationUtil.java     | 22 ++++++++
 .../resources/schema/artemis-configuration.xsd  | 53 +++++++++++---------
 .../core/config/impl/FileConfigurationTest.java |  7 +--
 .../resources/ConfigurationTest-full-config.xml |  7 +--
 9 files changed, 149 insertions(+), 45 deletions(-)
----------------------------------------------------------------------