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:
[email protected]