ARTEMIS-873 support byte notation in XML config

This commit is contained in:
Justin Bertram 2017-01-18 15:33:32 -06:00 committed by Clebert Suconic
parent fbc77b44c2
commit 113b28577c
9 changed files with 149 additions and 45 deletions

View File

@ -45,4 +45,7 @@ public interface ActiveMQUtilBundle {
@Message(id = 209003, value = "Error instantiating codec {0}", format = Message.Format.MESSAGE_FORMAT) @Message(id = 209003, value = "Error instantiating codec {0}", format = Message.Format.MESSAGE_FORMAT)
IllegalArgumentException errorCreatingCodec(@Cause Exception e, String codecClassName); 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);
} }

View File

@ -17,11 +17,14 @@
package org.apache.activemq.artemis.utils; package org.apache.activemq.artemis.utils;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator; import io.netty.buffer.UnpooledByteBufAllocator;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.logs.ActiveMQUtilBundle;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
public class ByteUtil { public class ByteUtil {
@ -29,6 +32,12 @@ public class ByteUtil {
public static final String NON_ASCII_STRING = "@@@@@"; public static final String NON_ASCII_STRING = "@@@@@";
private static final char[] hexArray = "0123456789ABCDEF".toCharArray(); 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) { public static void debugFrame(Logger logger, String message, ByteBuf byteIn) {
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {
@ -163,4 +172,31 @@ public class ByteUtil {
return ret; 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);
}
}
} }

View File

@ -19,6 +19,10 @@ package org.apache.activemq.artemis.utils;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; 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 { public class ByteUtilTest {
@Test @Test
@ -32,8 +36,8 @@ public class ByteUtilTest {
@Test @Test
public void testNonASCII() { public void testNonASCII() {
Assert.assertEquals("aA", ByteUtil.toSimpleString(new byte[]{97, 0, 65, 0})); 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(ByteUtil.NON_ASCII_STRING, ByteUtil.toSimpleString(new byte[]{0, 97, 0, 65}));
System.out.println(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);
}
}
} }

View File

@ -212,7 +212,7 @@ public interface ActiveMQClientMessageBundle {
IllegalArgumentException mustBeInteger(Node elem, String value); 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) @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") @Message(id = 119056, value = "Failed to get decoder")
IllegalArgumentException failedToGetDecoder(@Cause Exception e); IllegalArgumentException failedToGetDecoder(@Cause Exception e);

View File

@ -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.security.Role;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.DivertConfigurationRoutingType; 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.JournalType;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.SecuritySettingPlugin; 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.cluster.impl.MessageLoadBalancingType;
import org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration; 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.core.settings.impl.SlowConsumerPolicy;
import org.apache.activemq.artemis.uri.AcceptorTransportConfigurationParser; import org.apache.activemq.artemis.uri.AcceptorTransportConfigurationParser;
import org.apache.activemq.artemis.uri.ConnectorTransportConfigurationParser; 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.ClassloadingUtil;
import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec; import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec;
import org.apache.activemq.artemis.utils.PasswordMaskingUtil; 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.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)); 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.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 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); 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)) { } else if (MAX_REDELIVERY_DELAY_NODE_NAME.equalsIgnoreCase(name)) {
addressSettings.setMaxRedeliveryDelay(XMLUtil.parseLong(child)); addressSettings.setMaxRedeliveryDelay(XMLUtil.parseLong(child));
} else if (MAX_SIZE_BYTES_NODE_NAME.equalsIgnoreCase(name)) { } 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)) { } 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)) { } else if (PAGE_MAX_CACHE_SIZE_NODE_NAME.equalsIgnoreCase(name)) {
addressSettings.setPageCacheMaxSize(XMLUtil.parseInt(child)); addressSettings.setPageCacheMaxSize(XMLUtil.parseInt(child));
} else if (MESSAGE_COUNTER_HISTORY_DAY_LIMIT_NODE_NAME.equalsIgnoreCase(name)) { } 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); 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); 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 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); 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); String transformerClassName = getString(brNode, "transformer-class-name", null, Validators.NO_CHECK);
// Default bridge conf // 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); 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); 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); long maxRetryInterval = getLong(brNode, "max-retry-interval", ActiveMQClient.DEFAULT_MAX_RETRY_INTERVAL, Validators.GT_ZERO);

View File

@ -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, public static final Integer getInteger(final Element e,
final String name, final String name,
final int def, 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) { public static final Boolean getBoolean(final Element e, final String name, final boolean def) {
NodeList nl = e.getElementsByTagName(name); NodeList nl = e.getElementsByTagName(name);
if (nl.getLength() > 0) { if (nl.getLength() > 0) {

View File

@ -597,10 +597,11 @@
</xsd:annotation> </xsd:annotation>
</xsd:element> </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:annotation>
<xsd:documentation> <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:documentation>
</xsd:annotation> </xsd:annotation>
</xsd:element> </xsd:element>
@ -631,10 +632,10 @@
</xsd:annotation> </xsd:annotation>
</xsd:element> </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:annotation>
<xsd:documentation> <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:documentation>
</xsd:annotation> </xsd:annotation>
</xsd:element> </xsd:element>
@ -704,11 +705,11 @@
</xsd:annotation> </xsd:annotation>
</xsd:element> </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:annotation>
<xsd:documentation> <xsd:documentation>
Global Max Size before all addresses will enter into their Full Policy configured upon messages being Size (in bytes) before all addresses will enter into their Full Policy configured upon messages being
produced. produced. Supports byte notation like "K", "Mb", "GB", etc.
</xsd:documentation> </xsd:documentation>
</xsd:annotation> </xsd:annotation>
</xsd:element> </xsd:element>
@ -1168,11 +1169,11 @@
</xsd:annotation> </xsd:annotation>
</xsd:element> </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:annotation>
<xsd:documentation> <xsd:documentation>
Any message larger than this size is considered a large message (to be sent in Any message larger than this size (in bytes) is considered a large message (to be sent in
chunks) chunks). Supports byte notation like "K", "Mb", "GB", etc.
</xsd:documentation> </xsd:documentation>
</xsd:annotation> </xsd:annotation>
</xsd:element> </xsd:element>
@ -1251,18 +1252,19 @@
</xsd:annotation> </xsd:annotation>
</xsd:element> </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:annotation>
<xsd:documentation> <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:documentation>
</xsd:annotation> </xsd:annotation>
</xsd:element> </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:annotation>
<xsd:documentation> <xsd:documentation>
Producer flow control Producer flow control. Supports byte notation like "K", "Mb", "GB", etc.
</xsd:documentation> </xsd:documentation>
</xsd:annotation> </xsd:annotation>
</xsd:element> </xsd:element>
@ -1388,10 +1390,11 @@
</xsd:annotation> </xsd:annotation>
</xsd:element> </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:annotation>
<xsd:documentation> <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:documentation>
</xsd:annotation> </xsd:annotation>
</xsd:element> </xsd:element>
@ -1485,18 +1488,19 @@
</xsd:annotation> </xsd:annotation>
</xsd:element> </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:annotation>
<xsd:documentation> <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:documentation>
</xsd:annotation> </xsd:annotation>
</xsd:element> </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:annotation>
<xsd:documentation> <xsd:documentation>
Producer flow control Producer flow control. Supports byte notation like "K", "Mb", "GB", etc.
</xsd:documentation> </xsd:documentation>
</xsd:annotation> </xsd:annotation>
</xsd:element> </xsd:element>
@ -2365,11 +2369,11 @@
</xsd:annotation> </xsd:annotation>
</xsd:element> </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:annotation>
<xsd:documentation> <xsd:documentation>
the maximum size (in bytes) for an address (-1 means no limits). This is used in PAGING, BLOCK and 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:documentation>
</xsd:annotation> </xsd:annotation>
</xsd:element> </xsd:element>
@ -2385,10 +2389,11 @@
</xsd:annotation> </xsd:annotation>
</xsd:element> </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:annotation>
<xsd:documentation> <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:documentation>
</xsd:annotation> </xsd:annotation>
</xsd:element> </xsd:element>

View File

@ -215,7 +215,7 @@ public class FileConfigurationTest extends ConfigurationImplTest {
if (bc.getName().equals("bridge1")) { if (bc.getName().equals("bridge1")) {
Assert.assertEquals("bridge1", bc.getName()); Assert.assertEquals("bridge1", bc.getName());
Assert.assertEquals("queue1", bc.getQueueName()); Assert.assertEquals("queue1", bc.getQueueName());
Assert.assertEquals("minLargeMessageSize", 4, bc.getMinLargeMessageSize()); Assert.assertEquals("minLargeMessageSize", 4194304, bc.getMinLargeMessageSize());
assertEquals("check-period", 31, bc.getClientFailureCheckPeriod()); assertEquals("check-period", 31, bc.getClientFailureCheckPeriod());
assertEquals("connection time-to-live", 370, bc.getConnectionTTL()); assertEquals("connection time-to-live", 370, bc.getConnectionTTL());
Assert.assertEquals("bridge-forwarding-address1", bc.getForwardingAddress()); 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("connector1", bc.getStaticConnectors().get(0));
Assert.assertEquals(null, bc.getDiscoveryGroupName()); Assert.assertEquals(null, bc.getDiscoveryGroupName());
Assert.assertEquals(444, bc.getProducerWindowSize()); Assert.assertEquals(444, bc.getProducerWindowSize());
Assert.assertEquals(1073741824, bc.getConfirmationWindowSize());
} else { } else {
Assert.assertEquals("bridge2", bc.getName()); Assert.assertEquals("bridge2", bc.getName());
Assert.assertEquals("queue2", bc.getQueueName()); Assert.assertEquals("queue2", bc.getQueueName());
@ -237,7 +238,7 @@ public class FileConfigurationTest extends ConfigurationImplTest {
Assert.assertEquals(null, bc.getTransformerClassName()); Assert.assertEquals(null, bc.getTransformerClassName());
Assert.assertEquals(null, bc.getStaticConnectors()); Assert.assertEquals(null, bc.getStaticConnectors());
Assert.assertEquals("dg1", bc.getDiscoveryGroupName()); 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.1", conf.getAddressesSettings().get("a1").getDeadLetterAddress().toString());
assertEquals("a1.2", conf.getAddressesSettings().get("a1").getExpiryAddress().toString()); assertEquals("a1.2", conf.getAddressesSettings().get("a1").getExpiryAddress().toString());
assertEquals(1, conf.getAddressesSettings().get("a1").getRedeliveryDelay()); 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(81738173872337L, conf.getAddressesSettings().get("a1").getPageSizeBytes());
assertEquals(10, conf.getAddressesSettings().get("a1").getPageCacheMaxSize()); assertEquals(10, conf.getAddressesSettings().get("a1").getPageCacheMaxSize());
assertEquals(4, conf.getAddressesSettings().get("a1").getMessageCounterHistoryDayLimit()); assertEquals(4, conf.getAddressesSettings().get("a1").getMessageCounterHistoryDayLimit());

View File

@ -140,7 +140,7 @@
<forwarding-address>bridge-forwarding-address1</forwarding-address> <forwarding-address>bridge-forwarding-address1</forwarding-address>
<filter string="sku > 1"/> <filter string="sku > 1"/>
<transformer-class-name>org.foo.BridgeTransformer</transformer-class-name> <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> <check-period>31</check-period>
<connection-ttl>370</connection-ttl> <connection-ttl>370</connection-ttl>
<retry-interval>3</retry-interval> <retry-interval>3</retry-interval>
@ -149,6 +149,7 @@
<reconnect-attempts>2</reconnect-attempts> <reconnect-attempts>2</reconnect-attempts>
<failover-on-server-shutdown>false</failover-on-server-shutdown> <failover-on-server-shutdown>false</failover-on-server-shutdown>
<use-duplicate-detection>true</use-duplicate-detection> <use-duplicate-detection>true</use-duplicate-detection>
<confirmation-window-size>1G</confirmation-window-size>
<producer-window-size>444</producer-window-size> <producer-window-size>444</producer-window-size>
<static-connectors> <static-connectors>
<connector-ref>connector1</connector-ref> <connector-ref>connector1</connector-ref>
@ -157,7 +158,7 @@
<bridge name="bridge2"> <bridge name="bridge2">
<queue-name>queue2</queue-name> <queue-name>queue2</queue-name>
<forwarding-address>bridge-forwarding-address2</forwarding-address> <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"/> <discovery-group-ref discovery-group-name="dg1"/>
</bridge> </bridge>
</bridges> </bridges>
@ -257,7 +258,7 @@
<dead-letter-address>a1.1</dead-letter-address> <dead-letter-address>a1.1</dead-letter-address>
<expiry-address>a1.2</expiry-address> <expiry-address>a1.2</expiry-address>
<redelivery-delay>1</redelivery-delay> <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-size-bytes>81738173872337</page-size-bytes>
<page-max-cache-size>10</page-max-cache-size> <page-max-cache-size>10</page-max-cache-size>
<message-counter-history-day-limit>4</message-counter-history-day-limit> <message-counter-history-day-limit>4</message-counter-history-day-limit>