ARTEMIS-1096 Changing Global Max Size's default
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/cbe36214 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/cbe36214 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/cbe36214 Branch: refs/heads/master Commit: cbe3621431184c767501869fb53af1691b8d56a0 Parents: 0c1c56c Author: Clebert Suconic <[email protected]> Authored: Thu Apr 6 15:03:25 2017 -0400 Committer: Justin Bertram <[email protected]> Committed: Thu Apr 6 19:55:09 2017 -0500 ---------------------------------------------------------------------- .../activemq/artemis/cli/commands/Create.java | 17 ++++++++++++++--- .../apache/activemq/artemis/cli/commands/Run.java | 12 ------------ .../activemq/artemis/integration/FileBroker.java | 10 ++++++++++ .../activemq/artemis/cli/commands/etc/broker.xml | 5 +---- .../cli/commands/etc/global-max-default.txt | 9 +++++++++ .../cli/commands/etc/global-max-specified.txt | 4 ++++ .../activemq/cli/test/StreamClassPathTest.java | 2 ++ .../api/config/ActiveMQDefaultConfiguration.java | 2 +- .../core/config/impl/ConfigurationImpl.java | 8 ++++++-- .../artemis/core/server/ActiveMQServerLogger.java | 7 +++++++ docs/user-manual/en/configuration-index.md | 2 +- docs/user-manual/en/paging.md | 2 ++ 12 files changed, 57 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbe36214/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java ---------------------------------------------------------------------- diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java index 49e5545..3468cbf 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java @@ -101,6 +101,9 @@ public class Create extends InputAbstract { public static final String ETC_PING_TXT = "etc/ping-settings.txt"; public static final String ETC_COMMENTED_PING_TXT = "etc/commented-ping-settings.txt"; + public static final String ETC_GLOBAL_MAX_SPECIFIED_TXT = "etc/global-max-specified.txt"; + public static final String ETC_GLOBAL_MAX_DEFAULT_TXT = "etc/global-max-default.txt"; + @Arguments(description = "The instance directory to hold the broker's configuration and data. Path must be writable.", required = true) File directory; @@ -251,8 +254,8 @@ public class Create extends InputAbstract { @Option(name = "--no-fsync", description = "Disable usage of fdatasync (channel.force(false) from java nio) on the journal") boolean noJournalSync; - @Option(name = "--global-max-size", description = "Maximum amount of memory which message data may consume (Default: 100Mb)") - String globalMaxSize = "100Mb"; + @Option(name = "--global-max-size", description = "Maximum amount of memory which message data may consume (Default: Undefined, half of the system's memory)") + String globalMaxSize; boolean IS_WINDOWS; @@ -661,7 +664,15 @@ public class Create extends InputAbstract { filters.put("${user}", getUser()); filters.put("${password}", getPassword()); filters.put("${role}", role); - filters.put("${global-max-size}", globalMaxSize); + + + if (globalMaxSize == null || globalMaxSize.trim().equals("")) { + filters.put("${global-max-section}", readTextFile(ETC_GLOBAL_MAX_DEFAULT_TXT)); + } else { + filters.put("${global-max-size}", globalMaxSize); + filters.put("${global-max-section}", applyFilters(readTextFile(ETC_GLOBAL_MAX_SPECIFIED_TXT), filters)); + } + if (clustered) { filters.put("${host}", getHostForClustered()); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbe36214/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java ---------------------------------------------------------------------- diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java index 1811365..02478a1 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java @@ -25,7 +25,6 @@ import io.airlift.airline.Option; import org.apache.activemq.artemis.cli.Artemis; import org.apache.activemq.artemis.cli.commands.tools.LockAbstract; import org.apache.activemq.artemis.components.ExternalComponent; -import org.apache.activemq.artemis.core.config.impl.FileConfiguration; import org.apache.activemq.artemis.dto.BrokerDTO; import org.apache.activemq.artemis.dto.ComponentDTO; import org.apache.activemq.artemis.factory.BrokerFactory; @@ -61,12 +60,8 @@ public class Run extends LockAbstract { public Object execute(ActionContext context) throws Exception { super.execute(context); - FileConfiguration fileConfiguration = getFileConfiguration(); - Artemis.printBanner(); - createDirectories(getFileConfiguration()); - BrokerDTO broker = getBrokerDTO(); addShutdownHook(broker.server.getConfigurationFile().getParentFile()); @@ -91,13 +86,6 @@ public class Run extends LockAbstract { return null; } - private void createDirectories(FileConfiguration fileConfiguration) { - fileConfiguration.getPagingLocation().mkdirs(); - fileConfiguration.getJournalLocation().mkdirs(); - fileConfiguration.getBindingsLocation().mkdirs(); - fileConfiguration.getLargeMessagesLocation().mkdirs(); - } - /** * Add a simple shutdown hook to stop the server. * http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbe36214/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java ---------------------------------------------------------------------- diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java index 03df935..e112644 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java @@ -67,6 +67,8 @@ public class FileBroker implements Broker { fileDeploymentManager.addDeployable(configuration).addDeployable(jmsConfiguration); fileDeploymentManager.readConfiguration(); + createDirectories(configuration); + /** * This is a bit of a hack for backwards config compatibility since we no longer want to start the broker * using the JMSServerManager which would normally deploy JMS destinations. Here we take the JMS destination @@ -112,6 +114,14 @@ public class FileBroker implements Broker { } + + private void createDirectories(FileConfiguration fileConfiguration) { + fileConfiguration.getPagingLocation().mkdirs(); + fileConfiguration.getJournalLocation().mkdirs(); + fileConfiguration.getBindingsLocation().mkdirs(); + fileConfiguration.getLargeMessagesLocation().mkdirs(); + } + @Override public void stop() throws Exception { stop(false); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbe36214/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml ---------------------------------------------------------------------- diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml index a3b3d8a..6276b76 100644 --- a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml +++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml @@ -56,10 +56,7 @@ ${ping-config.settings}${journal-buffer.settings}${connector-config.settings} that won't support flow control. --> <max-disk-usage>90</max-disk-usage> - <!-- the system will enter into page mode once you hit this limit. - This is an estimate in bytes of how much the messages are using in memory --> - <global-max-size>${global-max-size}</global-max-size> - +${global-max-section} <acceptors> <!-- useEpoll means: it will use Netty epoll if you are on a system (Linux) that supports it --> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbe36214/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/global-max-default.txt ---------------------------------------------------------------------- diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/global-max-default.txt b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/global-max-default.txt new file mode 100644 index 0000000..2d029ac --- /dev/null +++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/global-max-default.txt @@ -0,0 +1,9 @@ + <!-- the system will enter into page mode once you hit this limit. + This is an estimate in bytes of how much the messages are using in memory + + The system will use half of the available memory (-Xmx) by default for the global-max-size. + You may specify a different value here if you need to customize it to your needs. + + <global-max-size>100Mb</global-max-size> + + --> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbe36214/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/global-max-specified.txt ---------------------------------------------------------------------- diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/global-max-specified.txt b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/global-max-specified.txt new file mode 100644 index 0000000..afea35b --- /dev/null +++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/global-max-specified.txt @@ -0,0 +1,4 @@ + <!-- the system will enter into page mode once you hit this limit. + This is an estimate in bytes of how much the messages are using in memory --> + <!-- + <global-max-size>${global-max-size}</global-max-size> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbe36214/artemis-cli/src/test/java/org/apache/activemq/cli/test/StreamClassPathTest.java ---------------------------------------------------------------------- diff --git a/artemis-cli/src/test/java/org/apache/activemq/cli/test/StreamClassPathTest.java b/artemis-cli/src/test/java/org/apache/activemq/cli/test/StreamClassPathTest.java index f6d1fb3..c7fe76b 100644 --- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/StreamClassPathTest.java +++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/StreamClassPathTest.java @@ -56,6 +56,8 @@ public class StreamClassPathTest { openStream(Create.ETC_STOMP_ACCEPTOR_TXT); openStream(Create.ETC_PING_TXT); openStream(Create.ETC_COMMENTED_PING_TXT); + openStream(Create.ETC_GLOBAL_MAX_SPECIFIED_TXT); + openStream(Create.ETC_GLOBAL_MAX_DEFAULT_TXT); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbe36214/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java index c0d9db6..6d3cb81 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java @@ -435,7 +435,7 @@ public final class ActiveMQDefaultConfiguration { // Default period to wait between configuration file checks public static final long DEFAULT_CONFIGURATION_FILE_REFRESH_PERIOD = 5000; - public static final long DEFAULT_GLOBAL_MAX_SIZE = -1; + public static final long DEFAULT_GLOBAL_MAX_SIZE = Runtime.getRuntime().maxMemory() / 2; public static final int DEFAULT_MAX_DISK_USAGE = 100; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbe36214/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 9372451..f230fb5 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 @@ -253,7 +253,7 @@ public class ConfigurationImpl implements Configuration, Serializable { private long configurationFileRefreshPeriod = ActiveMQDefaultConfiguration.getDefaultConfigurationFileRefreshPeriod(); - private long globalMaxSize = ActiveMQDefaultConfiguration.getDefaultMaxGlobalSize(); + private Long globalMaxSize; private int maxDiskUsage = ActiveMQDefaultConfiguration.getDefaultMaxDiskUsage(); @@ -351,6 +351,10 @@ public class ConfigurationImpl implements Configuration, Serializable { @Override public long getGlobalMaxSize() { + if (globalMaxSize == null) { + this.globalMaxSize = ActiveMQDefaultConfiguration.getDefaultMaxGlobalSize(); + ActiveMQServerLogger.LOGGER.usingDefaultPaging(globalMaxSize); + } return globalMaxSize; } @@ -1792,7 +1796,7 @@ public class ConfigurationImpl implements Configuration, Serializable { if (journalDatasync != other.journalDatasync) { return false; } - if (globalMaxSize != other.globalMaxSize) { + if (globalMaxSize != null && !globalMaxSize.equals(other.globalMaxSize)) { return false; } if (maxDiskUsage != other.maxDiskUsage) { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbe36214/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java index 56a4d32..df576b2 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java @@ -332,6 +332,13 @@ public interface ActiveMQServerLogger extends BasicLogger { format = Message.Format.MESSAGE_FORMAT) void reloadingConfiguration(String module); + @LogMessage(level = Logger.Level.INFO) + @Message(id = 221057, value = "Global Max Size is being adjusted to 1/2 of the JVM max size (-Xmx). being defined as {0}", + format = Message.Format.MESSAGE_FORMAT) + void usingDefaultPaging(long bytes); + + + @LogMessage(level = Logger.Level.WARN) @Message(id = 222000, value = "ActiveMQServer is being finalized and has not been stopped. Please remember to stop the server before letting it go out of scope", format = Message.Format.MESSAGE_FORMAT) http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbe36214/docs/user-manual/en/configuration-index.md ---------------------------------------------------------------------- diff --git a/docs/user-manual/en/configuration-index.md b/docs/user-manual/en/configuration-index.md index d66b8b0..720cb38 100644 --- a/docs/user-manual/en/configuration-index.md +++ b/docs/user-manual/en/configuration-index.md @@ -61,7 +61,7 @@ Name | Description [discovery-groups](clusters.md "Clusters") | [a list of discovery-group](#discovery-group-type) [disk-scan-period](paging.md#max-disk-usage) | The interval where the disk is scanned for percentual usage. Default=5000 ms. [diverts](diverts.md "Diverting and Splitting Message Flows") | [a list of diverts to use](#divert-type) -[global-max-size](paging.md#global-max-size) | The amount in bytes before all addresses are considered full +[global-max-size](paging.md#global-max-size) | The amount in bytes before all addresses are considered full. Default is half of the memory used by the JVM (-Xmx argument). [graceful-shutdown-enabled](graceful-shutdown.md "Graceful Server Shutdown") | true means that graceful shutdown is enabled. Default=true [graceful-shutdown-timeout](graceful-shutdown.md "Graceful Server Shutdown") | Timeout on waitin for clients to disconnect before server shutdown. Default=-1 [grouping-handler](message-grouping.md "Message Grouping") | Message Group configuration http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cbe36214/docs/user-manual/en/paging.md ---------------------------------------------------------------------- diff --git a/docs/user-manual/en/paging.md b/docs/user-manual/en/paging.md index 9f46287..8336435 100644 --- a/docs/user-manual/en/paging.md +++ b/docs/user-manual/en/paging.md @@ -126,6 +126,8 @@ Beyond the max-size-bytes on the address you can also set the global-max-size on When you have more messages than what is configured global-max-size any new produced message will make that destination to go through its paging policy. +global-max-size is calculated as half of the max memory available to the Java Virtual Machine, unless specified on the broker.xml configuration. + ## Dropping messages Instead of paging messages when the max size is reached, an address can
