You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by nn...@apache.org on 2021/06/28 23:02:31 UTC

[geode] branch support/1.12 updated (2d50e49 -> 63a8fb1)

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

nnag pushed a change to branch support/1.12
in repository https://gitbox.apache.org/repos/asf/geode.git.


    from 2d50e49  GEODE-9380: Replace sleep()s from Nio.SslEngine replace with yields
     new 2d3e1f2  GEODE-9295: Reply sent always  while processing LatestLastAccessTimeMessage
     new 63a8fb1  GEODE-9295: Added dunit test

The 2 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:
 ...LatestLastAccessTimeMessageDistributedTest.java | 94 ++++++++++++++++++++++
 .../cache/LatestLastAccessTimeMessage.java         | 48 +++++------
 .../cache/LatestLastAccessTimeMessageTest.java     | 11 +++
 3 files changed, 129 insertions(+), 24 deletions(-)
 create mode 100644 geode-core/src/distributedTest/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageDistributedTest.java

[geode] 01/02: GEODE-9295: Reply sent always while processing LatestLastAccessTimeMessage

Posted by nn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nnag pushed a commit to branch support/1.12
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 2d3e1f209c27037776fd5c3678d1e70a8a0234ea
Author: Nabarun Nag <na...@cs.wisc.edu>
AuthorDate: Mon Jun 14 22:17:36 2021 -0700

    GEODE-9295: Reply sent always  while processing LatestLastAccessTimeMessage
    
    	* Even if there any any exception, a reply will be sent back to the sender so that the sender's threads are not stuck.
    
    (cherry picked from commit 31bb9b986ed5b1a8013af35b277147e28cd74d12)
---
 .../cache/LatestLastAccessTimeMessage.java         | 48 +++++++++++-----------
 .../cache/LatestLastAccessTimeMessageTest.java     | 11 +++++
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessage.java b/geode-core/src/main/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessage.java
index 46bb749..d90be52 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessage.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessage.java
@@ -62,34 +62,34 @@ public class LatestLastAccessTimeMessage<K> extends PooledDistributionMessage
 
   @Override
   protected void process(ClusterDistributionManager dm) {
-    final InternalCache cache = dm.getCache();
-    if (cache == null) {
-      sendReply(dm, 0);
-      return;
-    }
-    final InternalDistributedRegion region =
-        (InternalDistributedRegion) cache.getRegion(this.regionName);
-    if (region == null) {
-      sendReply(dm, 0);
-      return;
-    }
-    final RegionEntry entry = region.getRegionEntry(this.key);
-    if (entry == null) {
-      sendReply(dm, 0);
-      return;
-    }
     long lastAccessed = 0L;
-    // noinspection SynchronizationOnLocalVariableOrMethodParameter
-    synchronized (entry) {
-      if (!entry.isInvalidOrRemoved()) {
-        try {
-          lastAccessed = entry.getLastAccessed();
-        } catch (InternalStatisticsDisabledException ignored) {
-          // last access time is not available
+    try {
+      final InternalCache cache = dm.getCache();
+      if (cache == null) {
+        return;
+      }
+      final InternalDistributedRegion region =
+          (InternalDistributedRegion) cache.getRegion(this.regionName);
+      if (region == null) {
+        return;
+      }
+      final RegionEntry entry = region.getRegionEntry(this.key);
+      if (entry == null) {
+        return;
+      }
+      // noinspection SynchronizationOnLocalVariableOrMethodParameter
+      synchronized (entry) {
+        if (!entry.isInvalidOrRemoved()) {
+          try {
+            lastAccessed = entry.getLastAccessed();
+          } catch (InternalStatisticsDisabledException ignored) {
+            // last access time is not available
+          }
         }
       }
+    } finally {
+      sendReply(dm, lastAccessed);
     }
-    sendReply(dm, lastAccessed);
   }
 
   @VisibleForTesting
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageTest.java
index 380006e..9f5062c 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageTest.java
@@ -14,6 +14,7 @@
  */
 package org.apache.geode.internal.cache;
 
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
@@ -78,6 +79,16 @@ public class LatestLastAccessTimeMessageTest {
   }
 
   @Test
+  public void replyIsSentEvenIfThereIsAnException() {
+    setupMessage();
+    when(dm.getCache()).thenThrow(new RuntimeException());
+    assertThatThrownBy(() -> {
+      lastAccessTimeMessage.process(dm);
+    }).isExactlyInstanceOf(RuntimeException.class);
+    verify(lastAccessTimeMessage).sendReply(dm, 0);
+  }
+
+  @Test
   public void processWithNullRegionRepliesZero() {
     setupMessage();
     setupRegion(false, false);

[geode] 02/02: GEODE-9295: Added dunit test

Posted by nn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nnag pushed a commit to branch support/1.12
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 63a8fb1a7ab847f908f83a74b274e8d8fd55ccdc
Author: Barry Oglesby <bo...@pivotal.io>
AuthorDate: Tue Jun 15 13:54:24 2021 -0700

    GEODE-9295: Added dunit test
    
    (cherry picked from commit c9d4f681d0700bd5344960f2da83ae960fc0b778)
---
 ...LatestLastAccessTimeMessageDistributedTest.java | 94 ++++++++++++++++++++++
 1 file changed, 94 insertions(+)

diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageDistributedTest.java
new file mode 100644
index 0000000..c622701
--- /dev/null
+++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageDistributedTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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;
+
+import static org.apache.geode.test.awaitility.GeodeAwaitility.getTimeout;
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+
+import java.io.Serializable;
+import java.util.Objects;
+import java.util.Set;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.cache.partition.PartitionRegionHelper;
+import org.apache.geode.distributed.internal.DistributionManager;
+import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
+
+public class LatestLastAccessTimeMessageDistributedTest implements Serializable {
+
+  @Rule
+  public ClusterStartupRule cluster = new ClusterStartupRule();
+
+  @Rule
+  public SerializableTestName testName = new SerializableTestName();
+
+  @Test
+  public void testSendLatestLastAccessTimeMessageToMemberWithNoRegion() {
+    // Start Locator
+    MemberVM locator = cluster.startLocatorVM(0);
+
+    // Start servers
+    int locatorPort = locator.getPort();
+    MemberVM server1 =
+        cluster.startServerVM(1, s -> s.withConnectionToLocator(locatorPort).withRegion(
+            RegionShortcut.PARTITION_REDUNDANT, testName.getMethodName()));
+    cluster.startServerVM(2, s -> s.withConnectionToLocator(locatorPort));
+
+    // Assign buckets to create the BucketRegions
+    server1.invoke(this::assignBucketsToPartitions);
+
+    // Send LastAccessTimeMessage from server1 to server2
+    server1.invoke(this::sendLastAccessTimeMessage);
+  }
+
+  private void assignBucketsToPartitions() {
+    Cache cache = Objects.requireNonNull(ClusterStartupRule.getCache());
+    PartitionedRegion pr = (PartitionedRegion) cache.getRegion(testName.getMethodName());
+    PartitionRegionHelper.assignBucketsToPartitions(pr);
+  }
+
+  private void sendLastAccessTimeMessage() throws InterruptedException {
+    // Get a BucketRegion
+    Cache cache = Objects.requireNonNull(ClusterStartupRule.getCache());
+    PartitionedRegion pr = (PartitionedRegion) cache.getRegion(testName.getMethodName());
+    BucketRegion br = pr.getBucketRegion(0);
+
+    // Get the recipients
+    DistributionManager dm = br.getDistributionManager();
+    Set<InternalDistributedMember> recipients = dm.getOtherNormalDistributionManagerIds();
+
+    // Create and sent the LatestLastAccessTimeMessage
+    LatestLastAccessTimeReplyProcessor replyProcessor =
+        new LatestLastAccessTimeReplyProcessor(dm, recipients);
+    dm.putOutgoing(new LatestLastAccessTimeMessage<>(replyProcessor, recipients, br, (Object) 0));
+
+    // Wait for the reply. Timeout if no reply is received.
+    // boolean success = replyProcessor.waitForReplies(getTimeout().toMillis());
+    boolean success = replyProcessor.waitForReplies(getTimeout().getValueInMS());
+
+    // Assert the wait was successful
+    assertThat(success).isTrue();
+
+    // Assert the latest last accessed time is 0
+    assertThat(replyProcessor.getLatestLastAccessTime()).isEqualTo(0L);
+  }
+}