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

eshu11 pushed a commit to branch feature/GEODE-5046
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/feature/GEODE-5046 by this 
push:
     new c971fec  GEODE-5046: Handle RegionDestroyedException in 
RemotePutMessage to retry another member.
c971fec is described below

commit c971fec127ae5d116766c6e6214f568d2b55fb13
Author: eshu <e...@pivotal.io>
AuthorDate: Wed Apr 11 12:09:36 2018 -0700

    GEODE-5046: Handle RegionDestroyedException in RemotePutMessage to retry 
another member.
---
 .../geode/internal/cache/tx/RemotePutMessage.java  |  6 +-
 .../internal/cache/tx/RemotePutMessageTest.java    | 67 ++++++++++++++++++++++
 2 files changed, 71 insertions(+), 2 deletions(-)

diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/tx/RemotePutMessage.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/tx/RemotePutMessage.java
index 06418da..843034a 100755
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/tx/RemotePutMessage.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/tx/RemotePutMessage.java
@@ -33,6 +33,7 @@ import org.apache.geode.cache.CacheException;
 import org.apache.geode.cache.CacheWriterException;
 import org.apache.geode.cache.EntryExistsException;
 import org.apache.geode.cache.Operation;
+import org.apache.geode.cache.RegionDestroyedException;
 import org.apache.geode.cache.TransactionDataNotColocatedException;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.internal.ClusterDistributionManager;
@@ -311,10 +312,11 @@ public class RemotePutMessage extends 
RemoteOperationMessageWithDirectReply
         }
         successful = true; // not a cancel-exception, so don't complain any 
more about it
 
-      } catch (RemoteOperationException e) {
+      } catch (RegionDestroyedException | RemoteOperationException e) {
         if (logger.isTraceEnabled(LogMarker.DM_VERBOSE)) {
           logger.trace(LogMarker.DM_VERBOSE,
-              "RemotePutMessage caught an unexpected exception during 
distribution", e);
+              "RemotePutMessage caught an exception during distribution; 
retrying to another member",
+              e);
         }
       }
     }
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/cache/tx/RemotePutMessageTest.java
 
b/geode-core/src/test/java/org/apache/geode/internal/cache/tx/RemotePutMessageTest.java
new file mode 100644
index 0000000..5c302e06
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/internal/cache/tx/RemotePutMessageTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.internal.cache.tx;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import org.apache.geode.cache.RegionDestroyedException;
+import 
org.apache.geode.distributed.internal.membership.InternalDistributedMember;
+import org.apache.geode.internal.cache.CacheDistributionAdvisor;
+import org.apache.geode.internal.cache.DistributedRegion;
+import org.apache.geode.internal.cache.EntryEventImpl;
+import org.apache.geode.internal.cache.RemoteOperationException;
+import org.apache.geode.test.junit.categories.UnitTest;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(RemotePutMessage.class)
+@Category(UnitTest.class)
+public class RemotePutMessageTest {
+  @Test
+  public void testDistributeNotFailWithRegionDestroyedException() throws 
RemoteOperationException {
+    EntryEventImpl event = mock(EntryEventImpl.class);
+    DistributedRegion region = mock(DistributedRegion.class);
+    CacheDistributionAdvisor advisor = mock(CacheDistributionAdvisor.class);
+    InternalDistributedMember member = mock(InternalDistributedMember.class);
+    Set<InternalDistributedMember> replicates = new 
HashSet<>(Arrays.asList(member));
+    RemotePutMessage.RemotePutResponse response = 
mock(RemotePutMessage.RemotePutResponse.class);
+    Object expectedOldValue = new Object();
+
+    when(event.getRegion()).thenReturn(region);
+    when(region.getCacheDistributionAdvisor()).thenReturn(advisor);
+    when(advisor.adviseInitializedReplicates()).thenReturn(replicates);
+    when(response.waitForResult()).thenThrow(new RegionDestroyedException("", 
""));
+
+    PowerMockito.mockStatic(RemotePutMessage.class);
+    PowerMockito
+        .when(RemotePutMessage.distribute(event, 1, false, false, 
expectedOldValue, false, false))
+        .thenCallRealMethod();
+    PowerMockito.when(RemotePutMessage.send(member, region, event, 1, false, 
false,
+        expectedOldValue, false, false, false)).thenReturn(response);
+
+    RemotePutMessage.distribute(event, 1, false, false, expectedOldValue, 
false, false);
+  }
+}

-- 
To stop receiving notification emails like this one, please contact
esh...@apache.org.

Reply via email to