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 2019/08/29 22:43:46 UTC

[activemq-artemis] branch master updated (84c4c2a -> 289e5b8)

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

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


    from 84c4c2a  This closes #2813
     new 90e4384  ARTEMIS-2424 Add option to override isReachable()
     new 60a15f3  ARTEMIS-2424 Testing functionality where we disable isReacheable if a ping custom command is used
     new 289e5b8  This closes #2817

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../artemis/core/server/NetworkHealthCheck.java    | 10 +++-
 .../activemq/artemis/utils/NetworkHealthTest.java  | 58 ++++++++++++++++++++++
 2 files changed, 67 insertions(+), 1 deletion(-)


[activemq-artemis] 03/03: This closes #2817

Posted by cl...@apache.org.
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

commit 289e5b8d449de74a93b7da3e56e90943e9c141f6
Merge: 84c4c2a 60a15f3
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Thu Aug 29 18:42:29 2019 -0400

    This closes #2817

 .../artemis/core/server/NetworkHealthCheck.java    | 10 +++-
 .../activemq/artemis/utils/NetworkHealthTest.java  | 58 ++++++++++++++++++++++
 2 files changed, 67 insertions(+), 1 deletion(-)


[activemq-artemis] 02/03: ARTEMIS-2424 Testing functionality where we disable isReacheable if a ping custom command is used

Posted by cl...@apache.org.
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

commit 60a15f3b5050fb7bfd2ae316f6ba6c1d280ec4a1
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Thu Aug 29 18:41:26 2019 -0400

    ARTEMIS-2424 Testing functionality where we disable isReacheable if a ping custom command is used
---
 .../artemis/core/server/NetworkHealthCheck.java    |  6 ++-
 .../activemq/artemis/utils/NetworkHealthTest.java  | 58 ++++++++++++++++++++++
 2 files changed, 63 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 1d02a44..446e150 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
@@ -331,7 +331,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
       }
 
       try {
-         if (!hasCustomPingCommand() && address.isReachable(networkInterface, 0, networkTimeout)) {
+         if (!hasCustomPingCommand() && isReachable(address)) {
             if (logger.isTraceEnabled()) {
                logger.tracef(address + " OK");
             }
@@ -345,6 +345,10 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
       }
    }
 
+   protected boolean isReachable(InetAddress address) throws IOException {
+      return address.isReachable(networkInterface, 0, networkTimeout);
+   }
+
    public boolean purePing(InetAddress address) throws IOException, InterruptedException {
       long timeout = Math.max(1, TimeUnit.MILLISECONDS.toSeconds(networkTimeout));
       // it did not work with a simple isReachable, it could be because there's no root access, so we will try ping executable
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 30e090c..221a97c 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
@@ -26,6 +26,7 @@ import java.net.URL;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import com.sun.net.httpserver.HttpExchange;
 import com.sun.net.httpserver.HttpHandler;
@@ -269,4 +270,61 @@ public class NetworkHealthTest {
 
    }
 
+
+   @Test
+   public void testValidateCommand() throws Throwable {
+      AtomicInteger purePing = new AtomicInteger(0);
+      AtomicInteger isReacheable = new AtomicInteger(0);
+      NetworkHealthCheck myCheck =
+         new NetworkHealthCheck() {
+            @Override
+            protected boolean isReachable(InetAddress address) throws IOException {
+               isReacheable.incrementAndGet();
+               return false;
+            }
+
+            @Override
+            public boolean purePing(InetAddress address) throws IOException, InterruptedException {
+               purePing.incrementAndGet();
+               return false;
+            }
+         };
+
+      myCheck.setIpv4Command("whatever");
+      myCheck.setIpv6Command("whatever");
+
+      myCheck.check(InetAddress.getByName("127.0.0.1"));
+
+      Assert.assertEquals(0, isReacheable.get());
+      Assert.assertEquals(1, purePing.get());
+   }
+
+   @Test
+   public void testValidateIsReachable() throws Throwable {
+      AtomicInteger purePing = new AtomicInteger(0);
+      AtomicInteger isReacheable = new AtomicInteger(0);
+      NetworkHealthCheck myCheck =
+         new NetworkHealthCheck() {
+            @Override
+            protected boolean isReachable(InetAddress address) throws IOException {
+               isReacheable.incrementAndGet();
+               return true;
+            }
+
+            @Override
+            public boolean purePing(InetAddress address) throws IOException, InterruptedException {
+               purePing.incrementAndGet();
+               return false;
+            }
+         };
+
+      //myCheck.setIpv4Command("whatever");
+      //myCheck.setIpv6Command("whatever");
+
+      myCheck.check(InetAddress.getByName("127.0.0.1"));
+
+      Assert.assertEquals(1, isReacheable.get());
+      Assert.assertEquals(0, purePing.get());
+   }
+
 }


[activemq-artemis] 01/03: ARTEMIS-2424 Add option to override isReachable()

Posted by cl...@apache.org.
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

commit 90e4384a4133915ab164724a25f1d756c9b48ce4
Author: Tom <to...@localhost.localdomain>
AuthorDate: Thu Aug 29 10:59:16 2019 -0400

    ARTEMIS-2424 Add option to override isReachable()
    
    Added check for non default ping command(s)
    Bypass InetAddress.isReachable() to allow exclusive use of user defined
    ping command(S).
---
 .../org/apache/activemq/artemis/core/server/NetworkHealthCheck.java | 6 +++++-
 1 file changed, 5 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 b3d3f71..1d02a44 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
@@ -331,7 +331,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
       }
 
       try {
-         if (address.isReachable(networkInterface, 0, networkTimeout)) {
+         if (!hasCustomPingCommand() && address.isReachable(networkInterface, 0, networkTimeout)) {
             if (logger.isTraceEnabled()) {
                logger.tracef(address + " OK");
             }
@@ -415,4 +415,8 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
    public boolean isEmpty() {
       return addresses.isEmpty() && urls.isEmpty();
    }
+
+   public boolean hasCustomPingCommand() {
+      return !getIpv4Command().equals(IPV4_DEFAULT_COMMAND) || !getIpv6Command().equals(IPV6_DEFAULT_COMMAND);
+   }
 }