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 2020/06/04 12:28:50 UTC

[activemq-artemis] branch master updated: ARTEMIS-2792 Fix default network pinger command for linux

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new 1ee0bbf  ARTEMIS-2792 Fix default network pinger command for linux
     new 1623c3f  This closes #3166
1ee0bbf is described below

commit 1ee0bbf34cd3a8b9ac5994bd9195fb2c0511cbdc
Author: brusdev <br...@gmail.com>
AuthorDate: Thu Jun 4 13:14:02 2020 +0200

    ARTEMIS-2792 Fix default network pinger command for linux
---
 .../activemq/artemis/core/server/NetworkHealthCheck.java       |  3 ++-
 .../org/apache/activemq/artemis/utils/NetworkHealthTest.java   | 10 ++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java
index 446e150..5c8fc82 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java
@@ -33,6 +33,7 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.artemis.logs.ActiveMQUtilLogger;
 import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;
+import org.apache.activemq.artemis.utils.Env;
 import org.apache.activemq.artemis.utils.collections.ConcurrentHashSet;
 import org.jboss.logging.Logger;
 
@@ -51,7 +52,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
 
    public static final String IPV6_DEFAULT_COMMAND = "ping6 -c 1 %2$s";
 
-   public static final String IPV4_DEFAULT_COMMAND = "ping -c 1 -t %d %s";
+   public static final String IPV4_DEFAULT_COMMAND = Env.isMacOs() ? "ping -c 1 -t %d %s" : "ping -c 1 -w %d %s";
 
    private String ipv4Command = IPV4_DEFAULT_COMMAND;
 
diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/NetworkHealthTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/NetworkHealthTest.java
index 156eb24..b790173 100644
--- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/NetworkHealthTest.java
+++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/NetworkHealthTest.java
@@ -326,4 +326,14 @@ public class NetworkHealthTest {
       Assert.assertEquals(0, purePing.get());
    }
 
+   @Test(timeout = 30_000)
+   public void testPurePingTimeout() throws Exception {
+      NetworkHealthCheck check = new NetworkHealthCheck(null, 100, 2000);
+
+      long time = System.currentTimeMillis();
+      //[RFC1166] reserves the address block 192.0.2.0/24 for test.
+      Assert.assertFalse(check.purePing(InetAddress.getByName("192.0.2.0")));
+      Assert.assertTrue(System.currentTimeMillis() - time >= 2000);
+   }
+
 }