activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/3] activemq-artemis git commit: NO-JIRA: Using Env as the source of isTestEnv
Date Fri, 07 Apr 2017 14:35:02 GMT
NO-JIRA: Using Env as the source of isTestEnv


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

Branch: refs/heads/master
Commit: dbe1976b47a15cea30f6dededcd68140b765c61f
Parents: a0f369a
Author: Clebert Suconic <clebertsuconic@apache.org>
Authored: Fri Apr 7 10:28:48 2017 -0400
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Fri Apr 7 10:31:03 2017 -0400

----------------------------------------------------------------------
 .../java/org/apache/activemq/artemis/utils/Env.java  | 15 +++++++++++++++
 .../core/remoting/impl/netty/NettyConnection.java    |  9 +++++++++
 .../artemis/core/config/impl/ConfigurationImpl.java  |  7 ++-----
 .../activemq/artemis/core/server/impl/QueueImpl.java |  4 ++--
 .../artemis/tests/util/ActiveMQTestBase.java         |  3 ++-
 5 files changed, 30 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dbe1976b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Env.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Env.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Env.java
index cb94d1c..d7fc48a 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Env.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Env.java
@@ -23,6 +23,13 @@ package org.apache.activemq.artemis.utils;
  */
 public final class Env {
 
+   /** The system will change a few logs and semantics to be suitable to
+    *  run a long testsuite.
+    *  Like a few log entries that are only valid during a production system.
+    *  or a few cases we need to know as warn on the testsuite and as log in production.
*/
+   private static boolean testEnv = false;
+
+
    private static final String OS = System.getProperty("os.name").toLowerCase();
    private static final boolean IS_LINUX = OS.startsWith("linux");
    private static final boolean IS_64BIT = checkIs64bit();
@@ -31,6 +38,14 @@ public final class Env {
 
    }
 
+   public static boolean isTestEnv() {
+      return testEnv;
+   }
+
+   public static void setTestEnv(boolean testEnv) {
+      Env.testEnv = testEnv;
+   }
+
    public static boolean isLinuxOs() {
       return IS_LINUX == true;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dbe1976b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
index 373c2f7..2181643 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
@@ -41,6 +41,7 @@ import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.spi.core.remoting.BaseConnectionLifeCycleListener;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
 import org.apache.activemq.artemis.spi.core.remoting.ReadyListener;
+import org.apache.activemq.artemis.utils.Env;
 import org.apache.activemq.artemis.utils.IPV6Util;
 import org.jboss.logging.Logger;
 
@@ -295,6 +296,14 @@ public class NettyConnection implements Connection {
    public final boolean blockUntilWritable(final int requiredCapacity, final long timeout,
final TimeUnit timeUnit) {
       final boolean isAllowedToBlock = isAllowedToBlock();
       if (!isAllowedToBlock) {
+
+         if (Env.isTestEnv()) {
+            // this will only show when inside the testsuite.
+            // we may great the log for FAILURE
+            logger.warn("FAILURE! The code is using blockUntilWritable inside a Netty worker,
which would block. " +
+                           "The code will probably need fixing!", new Exception("trace"));
+         }
+
          if (logger.isDebugEnabled()) {
             logger.debug("Calling blockUntilWritable using a thread where it's not allowed");
          }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dbe1976b/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 f3455d0..3ab7468 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
@@ -65,6 +65,7 @@ import org.apache.activemq.artemis.core.server.SecuritySettingPlugin;
 import org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.core.settings.impl.ResourceLimitSettings;
+import org.apache.activemq.artemis.utils.Env;
 import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader;
 import org.apache.activemq.artemis.utils.uri.BeanSupport;
 import org.jboss.logging.Logger;
@@ -74,10 +75,6 @@ public class ConfigurationImpl implements Configuration, Serializable {
 
    private static final Logger logger = Logger.getLogger(ConfigurationImpl.class);
 
-   // We want to turn of a few log.infos from the testsuite as they would be too verbose
for tests
-   // Only the testsuite should set this one up
-   public static boolean TEST_MODE = false;
-
    public static final JournalType DEFAULT_JOURNAL_TYPE = JournalType.ASYNCIO;
 
    private static final long serialVersionUID = 4077088945050267843L;
@@ -357,7 +354,7 @@ public class ConfigurationImpl implements Configuration, Serializable
{
    public long getGlobalMaxSize() {
       if (globalMaxSize == null) {
          this.globalMaxSize = ActiveMQDefaultConfiguration.getDefaultMaxGlobalSize();
-         if (!TEST_MODE) {
+         if (!Env.isTestEnv()) {
             ActiveMQServerLogger.LOGGER.usingDefaultPaging(globalMaxSize);
          }
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dbe1976b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
index 3901a84..dc4b090 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
@@ -47,7 +47,6 @@ import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.management.CoreNotificationType;
 import org.apache.activemq.artemis.api.core.management.ManagementHelper;
-import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.io.IOCallback;
 import org.apache.activemq.artemis.core.paging.cursor.PagePosition;
@@ -86,6 +85,7 @@ import org.apache.activemq.artemis.core.transaction.impl.BindingsTransactionImpl
 import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.utils.ConcurrentHashSet;
+import org.apache.activemq.artemis.utils.Env;
 import org.apache.activemq.artemis.utils.FutureLatch;
 import org.apache.activemq.artemis.utils.LinkedListIterator;
 import org.apache.activemq.artemis.utils.PriorityLinkedList;
@@ -3122,7 +3122,7 @@ public class QueueImpl implements Queue {
    }
 
    private void checkDeadLetterAddressAndExpiryAddress(final AddressSettings settings) {
-      if (!ConfigurationImpl.TEST_MODE) {
+      if (!Env.isTestEnv()) {
          if (settings.getDeadLetterAddress() == null) {
             ActiveMQServerLogger.LOGGER.AddressSettingsNoDLA(name);
          }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dbe1976b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
index 0ffb386..774b5f5 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
@@ -136,6 +136,7 @@ import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager
 import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
 import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule;
 import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;
+import org.apache.activemq.artemis.utils.Env;
 import org.apache.activemq.artemis.utils.FileUtil;
 import org.apache.activemq.artemis.utils.OrderedExecutorFactory;
 import org.apache.activemq.artemis.utils.RandomUtil;
@@ -158,7 +159,7 @@ import org.junit.runner.Description;
 public abstract class ActiveMQTestBase extends Assert {
 
    static {
-      ConfigurationImpl.TEST_MODE = true;
+      Env.setTestEnv(true);
    }
 
    private static final Logger logger = Logger.getLogger(ActiveMQTestBase.class);


Mime
View raw message