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 49e55455fc..3468cbf9eb 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()); 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 1811365175..02478a179d 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. * 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 03df935483..e1126448c4 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); 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 a3b3d8a4d2..6276b76f21 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. --> 90 - - ${global-max-size} - +${global-max-section} 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 0000000000..2d029ac24b --- /dev/null +++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/global-max-default.txt @@ -0,0 +1,9 @@ + 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 0000000000..afea35b3ff --- /dev/null +++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/global-max-specified.txt @@ -0,0 +1,4 @@ + +