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

2021-06-16 Thread nnag
This is an automated email from the ASF dual-hosted git repository.

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

commit a56883dd8777200f64ae7778c48e52399f49e011
Author: Barry Oglesby 
AuthorDate: Tue Jun 15 13:54:24 2021 -0700

GEODE-9295: Added dunit test

(cherry picked from commit c9d4f681d0700bd5344960f2da83ae960fc0b778)
---
 ...LatestLastAccessTimeMessageDistributedTest.java | 93 ++
 1 file changed, 93 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 000..098b572
--- /dev/null
+++ 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageDistributedTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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 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());
+
+// Assert the wait was successful
+assertThat(success).isTrue();
+
+// Assert the latest last accessed time is 0
+assertThat(replyProcessor.getLatestLastAccessTime()).isEqualTo(0L);
+  }
+}


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

2021-06-16 Thread nnag
This is an automated email from the ASF dual-hosted git repository.

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

commit 3a88dc11b08fc9ec18f2724568e950d61e77c84a
Author: Nabarun Nag 
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 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] branch support/1.13 updated (e2dc14d -> a56883d)

2021-06-16 Thread nnag
This is an automated email from the ASF dual-hosted git repository.

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


from e2dc14d  GEODE-9371: Change stress-new-test to non-required (#6602)
 new 3a88dc1  GEODE-9295: Reply sent always  while processing 
LatestLastAccessTimeMessage
 new a56883d  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 | 93 ++
 .../cache/LatestLastAccessTimeMessage.java | 48 +--
 .../cache/LatestLastAccessTimeMessageTest.java | 11 +++
 3 files changed, 128 insertions(+), 24 deletions(-)
 create mode 100644 
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageDistributedTest.java


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

2021-06-16 Thread nnag
This is an automated email from the ASF dual-hosted git repository.

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

commit 509c96b640d1d595103f6caecffa41c31194e995
Author: Barry Oglesby 
AuthorDate: Tue Jun 15 13:54:24 2021 -0700

GEODE-9295: Added dunit test

(cherry picked from commit c9d4f681d0700bd5344960f2da83ae960fc0b778)
---
 ...LatestLastAccessTimeMessageDistributedTest.java | 93 ++
 1 file changed, 93 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 000..098b572
--- /dev/null
+++ 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageDistributedTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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 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());
+
+// Assert the wait was successful
+assertThat(success).isTrue();
+
+// Assert the latest last accessed time is 0
+assertThat(replyProcessor.getLatestLastAccessTime()).isEqualTo(0L);
+  }
+}


[geode] branch support/1.14 updated (b246401 -> 509c96b)

2021-06-16 Thread nnag
This is an automated email from the ASF dual-hosted git repository.

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


from b246401  GEODE-9165: User Guide - Add "getting started with clients" 
(#6597)
 new b260850  GEODE-9295: Reply sent always  while processing 
LatestLastAccessTimeMessage
 new 509c96b  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 | 93 ++
 .../cache/LatestLastAccessTimeMessage.java | 48 +--
 .../cache/LatestLastAccessTimeMessageTest.java | 11 +++
 3 files changed, 128 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

2021-06-16 Thread nnag
This is an automated email from the ASF dual-hosted git repository.

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

commit b2608507bd86b86126ae0c415d65c9772932e00e
Author: Nabarun Nag 
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 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] branch feature/backport-GEODE-9180-1-13 created (now a3036ff)

2021-06-16 Thread burcham
This is an automated email from the ASF dual-hosted git repository.

burcham pushed a change to branch feature/backport-GEODE-9180-1-13
in repository https://gitbox.apache.org/repos/asf/geode.git.


  at a3036ff  GEODE-9180: warn when heartbeat thread oversleeps (#6360)

This branch includes the following new commits:

 new a3036ff  GEODE-9180: warn when heartbeat thread oversleeps (#6360)

The 1 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.



[geode] 01/01: GEODE-9180: warn when heartbeat thread oversleeps (#6360)

2021-06-16 Thread burcham
This is an automated email from the ASF dual-hosted git repository.

burcham pushed a commit to branch feature/backport-GEODE-9180-1-13
in repository https://gitbox.apache.org/repos/asf/geode.git

commit a3036ffb5c79a3ea6def7600efd519b8206aa16c
Author: Bill Burcham 
AuthorDate: Wed Apr 28 10:22:16 2021 -0700

GEODE-9180: warn when heartbeat thread oversleeps (#6360)

* heartbeat producer logs warning when it oversleeps by a period or more

(cherry picked from commit f8b07a007ac93c323cd888cbc53dc3914336077f)
---
 .../gms/fd/GMSHealthMonitorJUnitTest.java  |  47 +
 .../membership/gms/fd/GMSHealthMonitor.java| 190 -
 2 files changed, 161 insertions(+), 76 deletions(-)

diff --git 
a/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
 
b/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
index 2aaf2f5..81e132a 100644
--- 
a/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
+++ 
b/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
@@ -48,6 +48,7 @@ import java.util.Timer;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
+import java.util.function.LongUnaryOperator;
 
 import org.junit.After;
 import org.junit.Assert;
@@ -952,6 +953,52 @@ public class GMSHealthMonitorJUnitTest {
 executeTestDoTCPCheck(GMSHealthMonitor.ERROR + 100, false);
   }
 
+  @Test
+  public void heartbeatOversleepCausesWarning() {
+testHeartbeatSleepScenario(sleepLimit -> sleepLimit + 1,
+"Failure detection heartbeat-generation thread overslept by more than 
a full period. Asleep time: 1,000,000,001 nanoseconds. Period: 500,000,000 
nanoseconds.");
+  }
+
+  @Test
+  public void heartbeatOnTimeWakeupCausesNoWarning() {
+testHeartbeatSleepScenario(sleepLimit -> sleepLimit,
+null);
+  }
+
+  private void testHeartbeatSleepScenario(final LongUnaryOperator 
actualSleepPeriod,
+  final String expectedLogWarning) {
+
+/*
+ * Creating a class here because it's a convenient to provide (mutable) 
variables needed
+ * by the lambdas. Without the class, each of them would have to be arrays 
or atomics
+ * or some other kind of "holder object". By creating a class they can 
simply be fields.
+ */
+new Runnable() {
+  // the thing we're testing
+  final GMSHealthMonitor.Heart heart = gmsHealthMonitor.new Heart();
+  int periodNumber = 0; // index into times
+  String capturedMessage; // warning message (if any) generated by heart
+
+  @Override
+  public void run() {
+heart.sendPeriodicHeartbeats(sleepMillis -> {
+},
+() -> {
+  switch (periodNumber++) {
+case 0:
+  return 0L;
+case 1:
+default:
+  gmsHealthMonitor.stop();
+  return actualSleepPeriod.applyAsLong(heart.sleepLimitNanos);
+  }
+},
+msg -> capturedMessage = msg);
+assertThat(capturedMessage).isEqualTo(expectedLogWarning);
+  }
+}.run();
+  }
+
   private void executeTestDoTCPCheck(int receivedStatus, boolean 
expectedResult) throws Exception {
 MemberIdentifier otherMember =
 createGMSMember(Version.CURRENT_ORDINAL, 0, 1, 1);
diff --git 
a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
 
b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
index 2590e23..7457557 100644
--- 
a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
+++ 
b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
@@ -750,82 +750,7 @@ public class GMSHealthMonitor 
implements HealthMoni
* process
*/
   private void startHeartbeatThread() {
-checkExecutor.execute(new Runnable() {
-  @Override
-  public void run() {
-Thread.currentThread().setName("Geode Heartbeat Sender");
-sendPeriodicHeartbeats();
-  }
-
-  private void sendPeriodicHeartbeats() {
-while (!isStopping && 
!services.getCancelCriterion().isCancelInProgress()) {
-  try {
-Thread.sleep(memberTimeout / LOGICAL_INTERVAL);
-  } catch (InterruptedException e) {
-return;
-  }
-  GMSMembershipView v = currentView;
-  if (v != null) {
-List mbrs = v.getMembers();
-int index = mbrs.indexOf(localAddress);
-if (index < 0 || mbrs.size() < 2) {
-  

[geode] 01/02: GEODE-9141: (1 of 2) rename ByteBufferSharingImpl to ByteBuferVendor

2021-06-16 Thread burcham
This is an automated email from the ASF dual-hosted git repository.

burcham pushed a commit to branch features/back-port-geode-9141-to-1-13
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 79c1abb6c54262387bebda264b6d806b39edd17a
Author: Bill Burcham 
AuthorDate: Sat Apr 17 13:15:53 2021 -0700

GEODE-9141: (1 of 2) rename ByteBufferSharingImpl to ByteBuferVendor

(cherry picked from commit 38a3540583a1d0a402b026ee0d33ae4b0a2907d3)
(cherry picked from commit e0fa01dd9ec9c61504d517e77d1620f8e7975b73)
---
 .../apache/geode/internal/net/ByteBufferSharingNoOp.java |  2 +-
 ...{ByteBufferSharingImpl.java => ByteBufferVendor.java} |  6 +++---
 .../java/org/apache/geode/internal/net/NioSslEngine.java | 10 +-
 .../geode/internal/net/ByteBufferConcurrencyTest.java| 16 
 ...ferSharingImplTest.java => ByteBufferVendorTest.java} |  6 +++---
 .../org/apache/geode/internal/net/NioSslEngineTest.java  |  4 ++--
 6 files changed, 22 insertions(+), 22 deletions(-)

diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/net/ByteBufferSharingNoOp.java
 
b/geode-core/src/main/java/org/apache/geode/internal/net/ByteBufferSharingNoOp.java
index bd707e3..4a8bc49 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/net/ByteBufferSharingNoOp.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/net/ByteBufferSharingNoOp.java
@@ -27,7 +27,7 @@ import java.nio.ByteBuffer;
  * meant for use with the {@link NioPlainEngine} only, since that engine keeps 
no buffers and so,
  * needs no reference counting on buffers, nor any synchronization around 
access to buffers.
  *
- * See also {@link ByteBufferSharingImpl}
+ * See also {@link ByteBufferVendor}
  */
 class ByteBufferSharingNoOp implements ByteBufferSharing {
 
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/net/ByteBufferSharingImpl.java
 b/geode-core/src/main/java/org/apache/geode/internal/net/ByteBufferVendor.java
similarity index 96%
rename from 
geode-core/src/main/java/org/apache/geode/internal/net/ByteBufferSharingImpl.java
rename to 
geode-core/src/main/java/org/apache/geode/internal/net/ByteBufferVendor.java
index b083d09..4933247 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/net/ByteBufferSharingImpl.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/net/ByteBufferVendor.java
@@ -31,7 +31,7 @@ import org.apache.geode.internal.net.BufferPool.BufferType;
  * {@link ByteBuffer}) is available (for reading and modification) in the 
scope of the
  * try-with-resources.
  */
-class ByteBufferSharingImpl implements ByteBufferSharing {
+class ByteBufferVendor implements ByteBufferSharing {
 
   static class OpenAttemptTimedOut extends Exception {
   }
@@ -53,8 +53,8 @@ class ByteBufferSharingImpl implements ByteBufferSharing {
* This constructor acquires no lock. The reference count will be 1 after 
this constructor
* completes.
*/
-  ByteBufferSharingImpl(final ByteBuffer buffer, final BufferType bufferType,
-  final BufferPool bufferPool) {
+  ByteBufferVendor(final ByteBuffer buffer, final BufferType bufferType,
+   final BufferPool bufferPool) {
 this.buffer = buffer;
 this.bufferType = bufferType;
 this.bufferPool = bufferPool;
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/net/NioSslEngine.java 
b/geode-core/src/main/java/org/apache/geode/internal/net/NioSslEngine.java
index 8969ecc..fc91a31 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/net/NioSslEngine.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/net/NioSslEngine.java
@@ -42,7 +42,7 @@ import org.apache.logging.log4j.Logger;
 import org.apache.geode.GemFireIOException;
 import org.apache.geode.annotations.VisibleForTesting;
 import org.apache.geode.internal.net.BufferPool.BufferType;
-import org.apache.geode.internal.net.ByteBufferSharingImpl.OpenAttemptTimedOut;
+import org.apache.geode.internal.net.ByteBufferVendor.OpenAttemptTimedOut;
 import org.apache.geode.logging.internal.log4j.api.LogService;
 
 
@@ -62,12 +62,12 @@ public class NioSslEngine implements NioFilter {
   /**
* holds bytes wrapped by the SSLEngine; a.k.a. myNetData
*/
-  private final ByteBufferSharingImpl outputSharing;
+  private final ByteBufferVendor outputSharing;
 
   /**
* holds the last unwrapped data from a peer; a.k.a. peerAppData
*/
-  private final ByteBufferSharingImpl inputSharing;
+  private final ByteBufferVendor inputSharing;
 
   NioSslEngine(SSLEngine engine, BufferPool bufferPool) {
 SSLSession session = engine.getSession();
@@ -77,10 +77,10 @@ public class NioSslEngine implements NioFilter {
 this.engine = engine;
 this.bufferPool = bufferPool;
 outputSharing =
-new 
ByteBufferSharingImpl(bufferPool.acquireDirectSenderBuffer(packetBufferSize),
+new 
ByteBufferVendor(bufferPool.acquireDirectSenderBuffer(packetBufferSize),
 TRACKED_SENDER, 

[geode] branch features/back-port-geode-9141-to-1-13 created (now c4730de)

2021-06-16 Thread burcham
This is an automated email from the ASF dual-hosted git repository.

burcham pushed a change to branch features/back-port-geode-9141-to-1-13
in repository https://gitbox.apache.org/repos/asf/geode.git.


  at c4730de  GEODE-9141: (2 of 2) Handle in-buffer concurrency * 
Connection uses a ByteBufferVendor to mediate access to inputBuffer * Prevent 
return to pool before socket closer is finished

This branch includes the following new commits:

 new 79c1abb  GEODE-9141: (1 of 2) rename ByteBufferSharingImpl to 
ByteBuferVendor
 new c4730de  GEODE-9141: (2 of 2) Handle in-buffer concurrency * 
Connection uses a ByteBufferVendor to mediate access to inputBuffer * Prevent 
return to pool before socket closer is finished

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.



[geode] 02/02: GEODE-9141: (2 of 2) Handle in-buffer concurrency * Connection uses a ByteBufferVendor to mediate access to inputBuffer * Prevent return to pool before socket closer is finished

2021-06-16 Thread burcham
This is an automated email from the ASF dual-hosted git repository.

burcham pushed a commit to branch features/back-port-geode-9141-to-1-13
in repository https://gitbox.apache.org/repos/asf/geode.git

commit c4730deed48bb4513bd04486d4e8c09cdd3bb5a9
Author: Bill Burcham 
AuthorDate: Sat Apr 17 09:12:13 2021 -0700

GEODE-9141: (2 of 2) Handle in-buffer concurrency
* Connection uses a ByteBufferVendor to mediate access to inputBuffer
* Prevent return to pool before socket closer is finished

(cherry picked from commit 9d0d4d1d33794d0f6a21c3bcae71e965cbbd7fbd)
(cherry picked from commit 9e8b3972fcf449eed4d41c254cf3f553e517eaa1)
---
 ...LSocketHostNameVerificationIntegrationTest.java |   6 +-
 .../internal/net/SSLSocketIntegrationTest.java |   3 +-
 .../apache/geode/codeAnalysis/excludedClasses.txt  |   2 +-
 .../geode/internal/net/ByteBufferSharing.java  |  15 ++
 .../geode/internal/net/ByteBufferSharingNoOp.java  |   5 +
 .../geode/internal/net/ByteBufferVendor.java   | 144 ++
 .../apache/geode/internal/net/NioSslEngine.java|  50 ++--
 .../apache/geode/internal/net/SocketCreator.java   |   5 +-
 .../org/apache/geode/internal/tcp/Connection.java  | 299 ++---
 .../geode/internal/net/ByteBufferVendorTest.java   |  36 +--
 .../geode/internal/net/NioSslEngineTest.java   |  41 +--
 .../apache/geode/internal/tcp/ConnectionTest.java  |   1 +
 12 files changed, 340 insertions(+), 267 deletions(-)

diff --git 
a/geode-core/src/integrationTest/java/org/apache/geode/internal/net/SSLSocketHostNameVerificationIntegrationTest.java
 
b/geode-core/src/integrationTest/java/org/apache/geode/internal/net/SSLSocketHostNameVerificationIntegrationTest.java
index a70f3b1..e86bfea 100755
--- 
a/geode-core/src/integrationTest/java/org/apache/geode/internal/net/SSLSocketHostNameVerificationIntegrationTest.java
+++ 
b/geode-core/src/integrationTest/java/org/apache/geode/internal/net/SSLSocketHostNameVerificationIntegrationTest.java
@@ -103,6 +103,9 @@ public class SSLSocketHostNameVerificationIntegrationTest {
 
   @Before
   public void setUp() throws Exception {
+
+SocketCreatorFactory.close(); // to clear socket creators made in previous 
tests
+
 IgnoredException.addIgnoredException("javax.net.ssl.SSLException: Read 
timed out");
 
 this.localHost = InetAddress.getLoopbackAddress();
@@ -172,7 +175,7 @@ public class SSLSocketHostNameVerificationIntegrationTest {
 
 try {
   this.socketCreator.handshakeSSLSocketChannel(clientSocket.getChannel(),
-  sslEngine, 0, true,
+  sslEngine, 0,
   ByteBuffer.allocate(sslEngine.getSession().getPacketBufferSize()),
   new BufferPool(mock(DMStats.class)));
 
@@ -205,7 +208,6 @@ public class SSLSocketHostNameVerificationIntegrationTest {
 sc.handshakeSSLSocketChannel(socket.getChannel(),
 sslEngine,
 timeoutMillis,
-false,
 
ByteBuffer.allocate(sslEngine.getSession().getPacketBufferSize()),
 new BufferPool(mock(DMStats.class)));
   } catch (Throwable throwable) {
diff --git 
a/geode-core/src/integrationTest/java/org/apache/geode/internal/net/SSLSocketIntegrationTest.java
 
b/geode-core/src/integrationTest/java/org/apache/geode/internal/net/SSLSocketIntegrationTest.java
index add6b9a..5415f4e 100755
--- 
a/geode-core/src/integrationTest/java/org/apache/geode/internal/net/SSLSocketIntegrationTest.java
+++ 
b/geode-core/src/integrationTest/java/org/apache/geode/internal/net/SSLSocketIntegrationTest.java
@@ -227,7 +227,7 @@ public class SSLSocketIntegrationTest {
 clientSocket = clientChannel.socket();
 NioSslEngine engine =
 
clusterSocketCreator.handshakeSSLSocketChannel(clientSocket.getChannel(),
-clusterSocketCreator.createSSLEngine("localhost", 1234, true), 0, 
true,
+clusterSocketCreator.createSSLEngine("localhost", 1234, true), 0,
 ByteBuffer.allocate(65535), new BufferPool(mock(DMStats.class)));
 clientChannel.configureBlocking(true);
 
@@ -279,7 +279,6 @@ public class SSLSocketIntegrationTest {
 engine =
 sc.handshakeSSLSocketChannel(socket.getChannel(), sslEngine,
 timeoutMillis,
-false,
 ByteBuffer.allocate(65535),
 new BufferPool(mock(DMStats.class)));
 final List serverNames = 
sslEngine.getSSLParameters().getServerNames();
diff --git 
a/geode-core/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
 
b/geode-core/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
index 33f43c3..a96907f 100644
--- 
a/geode-core/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
+++ 
b/geode-core/src/integrationTest/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
@@ -104,4 +104,4 @@ org/apache/geode/cache/query/internal/xml/ElementType
 

[geode] branch feature/GEODE-9346 updated (c445f45 -> 6bb24d4)

2021-06-16 Thread zhouxj
This is an automated email from the ASF dual-hosted git repository.

zhouxj pushed a change to branch feature/GEODE-9346
in repository https://gitbox.apache.org/repos/asf/geode.git.


from c445f45  fix
 add 6bb24d4  change test case

No new revisions were added by this update.

Summary of changes:
 .../query/dunit/PdxMultiThreadQueryDUnitTest.java  | 27 --
 1 file changed, 10 insertions(+), 17 deletions(-)


[geode] branch feature/GEODE-9346 updated (8030e06 -> c445f45)

2021-06-16 Thread zhouxj
This is an automated email from the ASF dual-hosted git repository.

zhouxj pushed a change to branch feature/GEODE-9346
in repository https://gitbox.apache.org/repos/asf/geode.git.


from 8030e06  fix
 add c445f45  fix

No new revisions were added by this update.

Summary of changes:
 .../apache/geode/cache/query/dunit/PdxMultiThreadQueryDUnitTest.java| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


[geode-benchmarks] branch develop updated: Add key range support to more benchmarks.

2021-06-16 Thread jbarrett
This is an automated email from the ASF dual-hosted git repository.

jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-benchmarks.git


The following commit(s) were added to refs/heads/develop by this push:
 new 4bb07d4  Add key range support to more benchmarks.
4bb07d4 is described below

commit 4bb07d41105f1a9bc460a22da5ca514406c1ab33
Author: Jacob Barrett 
AuthorDate: Tue Jun 8 11:00:33 2021 -0700

Add key range support to more benchmarks.
---
 .../apache/geode/benchmark/tests/P2pPartitionedGetBenchmark.java| 6 +-
 .../apache/geode/benchmark/tests/P2pPartitionedPutBenchmark.java| 6 +-
 .../geode/benchmark/tests/P2pPartitionedPutBytesBenchmark.java  | 6 +-
 .../geode/benchmark/tests/P2pPartitionedPutLongBenchmark.java   | 6 +-
 4 files changed, 20 insertions(+), 4 deletions(-)

diff --git 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/P2pPartitionedGetBenchmark.java
 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/P2pPartitionedGetBenchmark.java
index 9a4e48f..b42eeb1 100644
--- 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/P2pPartitionedGetBenchmark.java
+++ 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/P2pPartitionedGetBenchmark.java
@@ -18,8 +18,11 @@
 package org.apache.geode.benchmark.tests;
 
 
+import static java.lang.Long.getLong;
 import static org.apache.geode.benchmark.Config.before;
 import static org.apache.geode.benchmark.Config.workload;
+import static org.apache.geode.benchmark.tests.GeodeBenchmark.WITH_MAX_KEY;
+import static org.apache.geode.benchmark.tests.GeodeBenchmark.WITH_MIN_KEY;
 import static org.apache.geode.benchmark.topology.Roles.SERVER;
 
 import org.junit.jupiter.api.Test;
@@ -36,7 +39,8 @@ import org.apache.geode.perftest.TestRunners;
  */
 public class P2pPartitionedGetBenchmark extends AbstractPerformanceTest {
 
-  private LongRange keyRange = new LongRange(0, 100);
+  private LongRange keyRange =
+  new LongRange(getLong(WITH_MIN_KEY, 0), getLong(WITH_MAX_KEY, 
1_000_000));
 
   @Test
   public void run() throws Exception {
diff --git 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/P2pPartitionedPutBenchmark.java
 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/P2pPartitionedPutBenchmark.java
index 92ac8fc..a53374e 100644
--- 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/P2pPartitionedPutBenchmark.java
+++ 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/P2pPartitionedPutBenchmark.java
@@ -17,8 +17,11 @@
 
 package org.apache.geode.benchmark.tests;
 
+import static java.lang.Long.getLong;
 import static org.apache.geode.benchmark.Config.before;
 import static org.apache.geode.benchmark.Config.workload;
+import static org.apache.geode.benchmark.tests.GeodeBenchmark.WITH_MAX_KEY;
+import static org.apache.geode.benchmark.tests.GeodeBenchmark.WITH_MIN_KEY;
 import static org.apache.geode.benchmark.topology.Roles.SERVER;
 
 import org.junit.jupiter.api.Test;
@@ -35,7 +38,8 @@ import org.apache.geode.perftest.TestRunners;
  */
 public class P2pPartitionedPutBenchmark extends AbstractPerformanceTest {
 
-  private LongRange keyRange = new LongRange(0, 1_000_000);
+  private LongRange keyRange =
+  new LongRange(getLong(WITH_MIN_KEY, 0), getLong(WITH_MAX_KEY, 
1_000_000));
 
   public P2pPartitionedPutBenchmark() {}
 
diff --git 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/P2pPartitionedPutBytesBenchmark.java
 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/P2pPartitionedPutBytesBenchmark.java
index 44a377f..6f4cf3b 100644
--- 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/P2pPartitionedPutBytesBenchmark.java
+++ 
b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/P2pPartitionedPutBytesBenchmark.java
@@ -17,8 +17,11 @@
 
 package org.apache.geode.benchmark.tests;
 
+import static java.lang.Long.getLong;
 import static org.apache.geode.benchmark.Config.before;
 import static org.apache.geode.benchmark.Config.workload;
+import static org.apache.geode.benchmark.tests.GeodeBenchmark.WITH_MAX_KEY;
+import static org.apache.geode.benchmark.tests.GeodeBenchmark.WITH_MIN_KEY;
 import static org.apache.geode.benchmark.topology.Roles.SERVER;
 
 import org.junit.jupiter.api.Test;
@@ -35,7 +38,8 @@ import org.apache.geode.perftest.TestRunners;
  */
 public class P2pPartitionedPutBytesBenchmark extends AbstractPerformanceTest {
 
-  private LongRange keyRange = new LongRange(0, 100);
+  private LongRange keyRange =
+  new LongRange(getLong(WITH_MIN_KEY, 0), getLong(WITH_MAX_KEY, 
1_000_000));
 
   public P2pPartitionedPutBytesBenchmark() {}
 
diff --git 
a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/P2pPartitionedPutLongBenchmark.java