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 <[email protected]> Authored: Fri Apr 7 13:57:17 2017 +0200 Committer: Clebert Suconic <[email protected]> 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;
