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/03/29 13:49:03 UTC

[2/2] activemq-artemis git commit: ARTEMIS-1079 CLI option for paging/blocking

ARTEMIS-1079 CLI option for paging/blocking


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

Branch: refs/heads/master
Commit: 6e56d2b3361502e40566910c2affcf3fc319aea3
Parents: 057b3b8
Author: Justin Bertram <jb...@apache.org>
Authored: Tue Mar 28 10:52:11 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Wed Mar 29 09:46:03 2017 -0400

----------------------------------------------------------------------
 .../activemq/artemis/cli/commands/Create.java   | 49 ++++++++++++++++----
 .../artemis/cli/commands/etc/broker.xml         |  2 +-
 2 files changed, 41 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6e56d2b3/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 5dae3c9..5407d99 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
@@ -188,6 +188,12 @@ public class Create extends InputAbstract {
    @Option(name = "--require-login", description = "This will configure security to require user / password, opposite of --allow-anonymous")
    Boolean requireLogin = null;
 
+   @Option(name = "--paging", description = "Page messages to disk when address becomes full, opposite of --blocking (Default: input)")
+   Boolean paging = null;
+
+   @Option(name = "--blocking", description = "Block producers when address becomes full, opposite of --paging (Default: input)")
+   Boolean blocking = null;
+
    @Option(name = "--no-autotune", description = "Disable auto tuning on the journal.")
    boolean noAutoTune;
 
@@ -245,6 +251,9 @@ 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: input)")
+   String globalMaxSize;
+
    boolean IS_WINDOWS;
 
    boolean IS_CYGWIN;
@@ -452,14 +461,20 @@ public class Create extends InputAbstract {
 
    public boolean isAllowAnonymous() {
       if (allowAnonymous == null) {
-         String value = input("--allow-anonymous | --require-login", "Allow anonymous access? (Y/N):", "Y");
-         allowAnonymous = Boolean.valueOf(value.toLowerCase().equals("y"));
+         allowAnonymous = inputBoolean("--allow-anonymous | --require-login", "Allow anonymous access?", true);
       }
-      return allowAnonymous.booleanValue();
+      return allowAnonymous;
    }
 
-   public void setAllowAnonymous(boolean allowGuest) {
-      this.allowAnonymous = Boolean.valueOf(allowGuest);
+   public boolean isPaging() {
+      if (paging == null) {
+         paging = inputBoolean("--paging | --blocking", "Page messages to disk when an address becomes full?", true);
+      }
+      return paging;
+   }
+
+   public void setAllowAnonymous(boolean allowAnonymous) {
+      this.allowAnonymous = Boolean.valueOf(allowAnonymous);
    }
 
    public Boolean getRequireLogin() {
@@ -510,6 +525,16 @@ public class Create extends InputAbstract {
       this.role = role;
    }
 
+   public String getGlobalMaxSize() {
+      if (globalMaxSize == null) {
+         globalMaxSize = input("--global-max-size", "Maximum amount of memory which message data may consume (typically 50% of your JVM's maximum heap size, e.g. 100Mb):", "100Mb");
+      }
+      return globalMaxSize;
+   }
+   public void setGlobalMaxSize(String globalMaxSize) {
+      this.globalMaxSize = globalMaxSize;
+   }
+
    public boolean isSlave() {
       return slave;
    }
@@ -577,11 +602,16 @@ public class Create extends InputAbstract {
 
       setupJournalType();
 
-      // requireLogin should set alloAnonymous=false, to avoid user's questions
+      // requireLogin should set allowAnonymous=false, to avoid user's questions
       if (requireLogin != null && requireLogin.booleanValue()) {
          allowAnonymous = Boolean.FALSE;
       }
 
+      // blocking should set paging=false, to avoid user's questions
+      if (blocking != null && blocking.booleanValue()) {
+         paging = Boolean.FALSE;
+      }
+
       context.out.println(String.format("Creating ActiveMQ Artemis instance at: %s", directory.getCanonicalPath()));
 
       HashMap<String, String> filters = new HashMap<>();
@@ -645,6 +675,7 @@ public class Create extends InputAbstract {
       filters.put("${user}", getUser());
       filters.put("${password}", getPassword());
       filters.put("${role}", getRole());
+      filters.put("${global-max-size}", getGlobalMaxSize());
 
       if (clustered) {
          filters.put("${host}", getHostForClustered());
@@ -755,10 +786,10 @@ public class Create extends InputAbstract {
          filters.put("${hornetq-acceptor}", applyFilters(readTextFile(ETC_HORNETQ_ACCEPTOR_TXT), filters));
       }
 
-      if (disablePersistence) {
-         filters.put("${full-policy}", "BLOCK");
-      } else {
+      if (isPaging()) {
          filters.put("${full-policy}", "PAGE");
+      } else {
+         filters.put("${full-policy}", "BLOCK");
       }
 
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6e56d2b3/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 497b10d..a3b3d8a 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
@@ -58,7 +58,7 @@ ${ping-config.settings}${journal-buffer.settings}${connector-config.settings}
 
       <!-- 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>100Mb</global-max-size>
+      <global-max-size>${global-max-size}</global-max-size>
 
       <acceptors>