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/04/07 14:35:01 UTC

[1/3] activemq-artemis git commit: ARTEMIS-1099 Force Netty EPOLL to be available only on Linux 64bit platforms

Repository: activemq-artemis
Updated Branches:
  refs/heads/master 9e41489aa -> a41a1316d


ARTEMIS-1099 Force Netty EPOLL to be available only on Linux 64bit platforms


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

Branch: refs/heads/master
Commit: a0f369af05978aff9b2b81cfe6c6cfebc9c0632c
Parents: 9e41489
Author: Francesco Nigro <ni...@gmail.com>
Authored: Fri Apr 7 13:57:17 2017 +0200
Committer: Clebert Suconic <cl...@apache.org>
Committed: Fri Apr 7 10:28:22 2017 -0400

----------------------------------------------------------------------
 .../org/apache/activemq/artemis/utils/Env.java  | 56 ++++++++++++++++++++
 .../artemis/core/remoting/impl/netty/Epoll.java | 44 +++++++++++++++
 .../remoting/impl/netty/NettyConnector.java     |  1 -
 .../core/remoting/impl/netty/NettyAcceptor.java |  1 -
 4 files changed, 100 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0f369af/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
new file mode 100644
index 0000000..cb94d1c
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Env.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.utils;
+
+/**
+ * Utility that detects various properties specific to the current runtime
+ * environment, such as JVM bitness and OS type.
+ */
+public final class Env {
+
+   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();
+
+   private Env() {
+
+   }
+
+   public static boolean isLinuxOs() {
+      return IS_LINUX == true;
+   }
+
+   public static boolean is64BitJvm() {
+      return IS_64BIT;
+   }
+
+   private static boolean checkIs64bit() {
+      //check the more used JVMs
+      String systemProp;
+      systemProp = System.getProperty("com.ibm.vm.bitmode");
+      if (systemProp != null) {
+         return "64".equals(systemProp);
+      }
+      systemProp = System.getProperty("sun.arch.data.model");
+      if (systemProp != null) {
+         return "64".equals(systemProp);
+      }
+      systemProp = System.getProperty("java.vm.version");
+      return systemProp != null && systemProp.contains("_64");
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0f369af/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/Epoll.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/Epoll.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/Epoll.java
new file mode 100644
index 0000000..96af017
--- /dev/null
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/Epoll.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.core.remoting.impl.netty;
+
+import org.apache.activemq.artemis.utils.Env;
+
+/**
+ * Tells if <a href="http://netty.io/wiki/native-transports.html">{@code netty-transport-native-epoll}</a> is supported.
+ */
+public final class Epoll {
+
+   private static final boolean IS_AVAILABLE_EPOLL;
+
+   static {
+      if (Env.is64BitJvm() && Env.isLinuxOs()) {
+         IS_AVAILABLE_EPOLL = io.netty.channel.epoll.Epoll.isAvailable();
+      } else {
+         IS_AVAILABLE_EPOLL = false;
+      }
+   }
+
+   private Epoll() {
+
+   }
+
+   public static boolean isAvailable() {
+      return IS_AVAILABLE_EPOLL;
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0f369af/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
index ad78908..15c048b 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
@@ -59,7 +59,6 @@ import io.netty.channel.ChannelPromise;
 import io.netty.channel.EventLoopGroup;
 import io.netty.channel.SimpleChannelInboundHandler;
 import io.netty.channel.WriteBufferWaterMark;
-import io.netty.channel.epoll.Epoll;
 import io.netty.channel.epoll.EpollEventLoopGroup;
 import io.netty.channel.epoll.EpollSocketChannel;
 import io.netty.channel.group.ChannelGroup;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0f369af/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
index 4f248f5..a428f04 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
@@ -45,7 +45,6 @@ import io.netty.channel.ChannelPipeline;
 import io.netty.channel.EventLoopGroup;
 import io.netty.channel.ServerChannel;
 import io.netty.channel.WriteBufferWaterMark;
-import io.netty.channel.epoll.Epoll;
 import io.netty.channel.epoll.EpollEventLoopGroup;
 import io.netty.channel.epoll.EpollServerSocketChannel;
 import io.netty.channel.group.ChannelGroup;


[3/3] activemq-artemis git commit: This closes #1184

Posted by cl...@apache.org.
This closes #1184


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

Branch: refs/heads/master
Commit: a41a1316d5d3c82da306b70d8d8181e4f9154b22
Parents: 9e41489 dbe1976
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri Apr 7 10:34:20 2017 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Fri Apr 7 10:34:20 2017 -0400

----------------------------------------------------------------------
 .../org/apache/activemq/artemis/utils/Env.java  | 71 ++++++++++++++++++++
 .../artemis/core/remoting/impl/netty/Epoll.java | 44 ++++++++++++
 .../remoting/impl/netty/NettyConnection.java    |  9 +++
 .../remoting/impl/netty/NettyConnector.java     |  1 -
 .../core/config/impl/ConfigurationImpl.java     |  7 +-
 .../core/remoting/impl/netty/NettyAcceptor.java |  1 -
 .../artemis/core/server/impl/QueueImpl.java     |  4 +-
 .../artemis/tests/util/ActiveMQTestBase.java    |  3 +-
 8 files changed, 130 insertions(+), 10 deletions(-)
----------------------------------------------------------------------



[2/3] activemq-artemis git commit: NO-JIRA: Using Env as the source of isTestEnv

Posted by cl...@apache.org.
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 <cl...@apache.org>
Authored: Fri Apr 7 10:28:48 2017 -0400
Committer: Clebert Suconic <cl...@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);