You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by es...@apache.org on 2018/04/12 16:50:29 UTC
[geode] branch develop updated: GEODE-5046: Handle RegionDestroyedException in RemotePutMessage to re… (#1773)
This is an automated email from the ASF dual-hosted git repository.
eshu11 pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 2203273 GEODE-5046: Handle RegionDestroyedException in RemotePutMessage to re… (#1773)
2203273 is described below
commit 2203273307a8695dafc3b617cac9979ff0305f9b
Author: pivotal-eshu <es...@pivotal.io>
AuthorDate: Thu Apr 12 09:50:26 2018 -0700
GEODE-5046: Handle RegionDestroyedException in RemotePutMessage to re… (#1773)
* GEODE-5046: Handle RegionDestroyedException in RemotePutMessage to retry another member.
---
.../geode/internal/cache/tx/RemotePutMessage.java | 6 +-
.../internal/cache/tx/RemotePutMessageTest.java | 69 ++++++++++++++++++++++
2 files changed, 73 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..63bab9a
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tx/RemotePutMessageTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.PowerMockIgnore;
+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;
+
+@Category(UnitTest.class)
+@PowerMockIgnore("*.UnitTest")
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(RemotePutMessage.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
eshu11@apache.org.