You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2020/11/12 17:32:49 UTC

[GitHub] [geode] bschuchardt opened a new pull request #5739: GEODE-8697: Propagate ForcedDisconnectException to the user application

bschuchardt opened a new pull request #5739:
URL: https://github.com/apache/geode/pull/5739


   avoid setting MemberDisconnectedException as a rootCause in
   ClusterDistributionManager, even temporarily, as it's an internal
   exception that should not be exposed to applications.
   
   @kamilla1201 
   
   Thank you for submitting a contribution to Apache Geode.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically `develop`)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   - [ ] Does `gradlew build` run cleanly?
   
   - [ ] Have you written or updated unit tests to verify your changes?
   
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   
   ### Note:
   Please ensure that once the PR is submitted, check Concourse for build issues and
   submit an update to your PR as soon as possible. If you need help, please send an
   email to dev@geode.apache.org.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] kohlmu-pivotal commented on a change in pull request #5739: GEODE-8697: Propagate ForcedDisconnectException to the user application

Posted by GitBox <gi...@apache.org>.
kohlmu-pivotal commented on a change in pull request #5739:
URL: https://github.com/apache/geode/pull/5739#discussion_r523840254



##########
File path: geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterDistributionManager.java
##########
@@ -2293,26 +2298,25 @@ public Distribution getDistribution() {
 
     @Override
     public void membershipFailure(String reason, Throwable t) {
-      exceptionInThreads = true;
-      rootCause = t;
-      if (rootCause != null && !(rootCause instanceof ForcedDisconnectException)) {
-        logger.info("cluster membership failed due to ", rootCause);
-        rootCause = new ForcedDisconnectException(rootCause.getMessage());
+      dm.exceptionInThreads = true;

Review comment:
       Can we please start renaming back variables to something more meaningful. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] bschuchardt merged pull request #5739: GEODE-8697: Propagate ForcedDisconnectException to the user application

Posted by GitBox <gi...@apache.org>.
bschuchardt merged pull request #5739:
URL: https://github.com/apache/geode/pull/5739


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] bschuchardt commented on a change in pull request #5739: GEODE-8697: Propagate ForcedDisconnectException to the user application

Posted by GitBox <gi...@apache.org>.
bschuchardt commented on a change in pull request #5739:
URL: https://github.com/apache/geode/pull/5739#discussion_r522353145



##########
File path: geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterDistributionManager.java
##########
@@ -2357,9 +2361,9 @@ public void memberDeparted(InternalDistributedMember theId, boolean crashed, Str
           message.setIgnoreAlertListenerRemovalFailure(true); // we don't know if it was a listener
                                                               // so
           // don't issue a warning
-          message.setRecipient(localAddress);
+          message.setRecipient(dm.getDistributionManagerId());
           message.setReason(reason); // added for #37950

Review comment:
       I'll just delete that comment




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] echobravopapa commented on a change in pull request #5739: GEODE-8697: Propagate ForcedDisconnectException to the user application

Posted by GitBox <gi...@apache.org>.
echobravopapa commented on a change in pull request #5739:
URL: https://github.com/apache/geode/pull/5739#discussion_r522303266



##########
File path: geode-dunit/src/main/java/org/apache/geode/test/greplogs/ExpectedStrings.java
##########
@@ -79,6 +79,7 @@ public static boolean skipLogMsgs(String type) {
     expected.add(Pattern.compile("SystemAlertManager: A simple Alert."));
 
     expected.add(Pattern.compile("org.apache.geode.management.DependenciesNotFoundException"));
+    expected.add(Pattern.compile("EntryNotFoundException"));

Review comment:
       How is this connected to this issue?

##########
File path: geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterDistributionManager.java
##########
@@ -2293,26 +2298,25 @@ public Distribution getDistribution() {
 
     @Override
     public void membershipFailure(String reason, Throwable t) {
-      exceptionInThreads = true;
-      rootCause = t;
-      if (rootCause != null && !(rootCause instanceof ForcedDisconnectException)) {
-        logger.info("cluster membership failed due to ", rootCause);
-        rootCause = new ForcedDisconnectException(rootCause.getMessage());
+      dm.exceptionInThreads = true;
+      Throwable cause = t;
+      if (cause != null && !(cause instanceof ForcedDisconnectException)) {
+        logger.info("cluster membership failed due to ", cause);
+        cause = new ForcedDisconnectException(cause.getMessage());
       }
+      dm.setRootCause(cause);

Review comment:
       this line is the crucial part of the fix, no?

##########
File path: geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterDistributionManager.java
##########
@@ -2357,9 +2361,9 @@ public void memberDeparted(InternalDistributedMember theId, boolean crashed, Str
           message.setIgnoreAlertListenerRemovalFailure(true); // we don't know if it was a listener
                                                               // so
           // don't issue a warning
-          message.setRecipient(localAddress);
+          message.setRecipient(dm.getDistributionManagerId());
           message.setReason(reason); // added for #37950

Review comment:
       extra credit: could the comment "// added for #37950" be converted into some words; i.e. whatever that old issue was/fixed etc...




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] bschuchardt commented on a change in pull request #5739: GEODE-8697: Propagate ForcedDisconnectException to the user application

Posted by GitBox <gi...@apache.org>.
bschuchardt commented on a change in pull request #5739:
URL: https://github.com/apache/geode/pull/5739#discussion_r522348301



##########
File path: geode-dunit/src/main/java/org/apache/geode/test/greplogs/ExpectedStrings.java
##########
@@ -79,6 +79,7 @@ public static boolean skipLogMsgs(String type) {
     expected.add(Pattern.compile("SystemAlertManager: A simple Alert."));
 
     expected.add(Pattern.compile("org.apache.geode.management.DependenciesNotFoundException"));
+    expected.add(Pattern.compile("EntryNotFoundException"));

Review comment:
       oops - that was left over from some debugging on another ticket.  I'll get rid of that.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] kohlmu-pivotal commented on pull request #5739: GEODE-8697: Propagate ForcedDisconnectException to the user application

Posted by GitBox <gi...@apache.org>.
kohlmu-pivotal commented on pull request #5739:
URL: https://github.com/apache/geode/pull/5739#issuecomment-727675133


   Whilst I cannot comment on the logic that, I do always wonder why we keep on supporting test code inside of production classes. Thinking about it, the whole "testHook" logic should live in a test class that extends the `ClusterDistributionManager`. In this test, there would be no problem doing this. Whilst it would require some refactoring of the root class to allow for the extension, I don't think it would be that significant that this cannot be achieved.
   
   Also, given the fact that there is only one location where a `ClusterDistributionManager` is created, I imagine it would be only a small refactor to have an ability to pass in a DistributionManager into the `InternalDistributedSystem` in order to have the ability to switch to another DistributionManager. It might actually even simplify some of the logic in the `InternalDistributedSystem`.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] bschuchardt commented on a change in pull request #5739: GEODE-8697: Propagate ForcedDisconnectException to the user application

Posted by GitBox <gi...@apache.org>.
bschuchardt commented on a change in pull request #5739:
URL: https://github.com/apache/geode/pull/5739#discussion_r522349760



##########
File path: geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterDistributionManager.java
##########
@@ -2293,26 +2298,25 @@ public Distribution getDistribution() {
 
     @Override
     public void membershipFailure(String reason, Throwable t) {
-      exceptionInThreads = true;
-      rootCause = t;
-      if (rootCause != null && !(rootCause instanceof ForcedDisconnectException)) {
-        logger.info("cluster membership failed due to ", rootCause);
-        rootCause = new ForcedDisconnectException(rootCause.getMessage());
+      dm.exceptionInThreads = true;
+      Throwable cause = t;
+      if (cause != null && !(cause instanceof ForcedDisconnectException)) {
+        logger.info("cluster membership failed due to ", cause);
+        cause = new ForcedDisconnectException(cause.getMessage());
       }
+      dm.setRootCause(cause);

Review comment:
       yes.  The rest is a small refactor to make DMListener testable




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [geode] Bill commented on a change in pull request #5739: GEODE-8697: Propagate ForcedDisconnectException to the user application

Posted by GitBox <gi...@apache.org>.
Bill commented on a change in pull request #5739:
URL: https://github.com/apache/geode/pull/5739#discussion_r523286184



##########
File path: geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterDistributionManager.java
##########
@@ -2283,7 +2288,7 @@ public Distribution getDistribution() {
    * This is the listener implementation for responding from events from the Membership Manager.
    *
    */
-  private class DMListener implements
+  static class DMListener implements

Review comment:
       Good improvement making this inner class static ✓

##########
File path: geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterDistributionManager.java
##########
@@ -2209,6 +2209,11 @@ private void removeAllHealthMonitors() {
     }
   }
 
+  private List<MembershipTestHook> getMembershipTestHooks() {
+    return membershipTestHooks;
+  }

Review comment:
       `DMListener` needs an accessor now ok

##########
File path: geode-core/src/test/java/org/apache/geode/distributed/internal/ClusterDistributionManagerTest.java
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.geode.distributed.internal;
+
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import org.junit.Test;
+
+import org.apache.geode.ForcedDisconnectException;
+import org.apache.geode.distributed.internal.membership.api.MemberDisconnectedException;
+
+public class ClusterDistributionManagerTest {
+
+  @Test
+  public void membershipFailureProcessingCreatesForcedDisconnectException() {
+    ClusterDistributionManager manager = mock(ClusterDistributionManager.class);

Review comment:
       It's a little bit surprising that the `ClusterDistributionManager` test, mocks the `ClusterDistributionManager` ;-) But I get it and it's ok. It's really a test of the inner `DMListener` ✓

##########
File path: geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterDistributionManager.java
##########
@@ -2293,26 +2298,25 @@ public Distribution getDistribution() {
 
     @Override
     public void membershipFailure(String reason, Throwable t) {
-      exceptionInThreads = true;
-      rootCause = t;
-      if (rootCause != null && !(rootCause instanceof ForcedDisconnectException)) {
-        logger.info("cluster membership failed due to ", rootCause);
-        rootCause = new ForcedDisconnectException(rootCause.getMessage());
+      dm.exceptionInThreads = true;
+      Throwable cause = t;
+      if (cause != null && !(cause instanceof ForcedDisconnectException)) {
+        logger.info("cluster membership failed due to ", cause);
+        cause = new ForcedDisconnectException(cause.getMessage());
       }
+      dm.setRootCause(cause);
       try {
-        if (membershipTestHooks != null) {
-          List<MembershipTestHook> l = membershipTestHooks;
-          for (final MembershipTestHook aL : l) {
-            MembershipTestHook dml = aL;
-            dml.beforeMembershipFailure(reason, rootCause);
+        List<MembershipTestHook> testHooks = dm.getMembershipTestHooks();

Review comment:
       ah now that this inner class is static we have to use an accessor to get at the test hooks ✓




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org