You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2022/04/25 21:17:18 UTC

[GitHub] [geode] pivotal-jbarrett commented on a diff in pull request #7515: GEODE-10020: For Ping task avoid registering new destination endpoint

pivotal-jbarrett commented on code in PR #7515:
URL: https://github.com/apache/geode/pull/7515#discussion_r858032157


##########
geode-assembly/src/acceptanceTest/java/org/apache/geode/cache/wan/SeveralGatewayReceiversWithSamePortAndHostnameForSendersTest.java:
##########
@@ -214,6 +215,56 @@ public void testTwoSendersWithSameIdShouldUseSameValueForEnforceThreadsConnectTo
 
   }
 
+
+  /**
+   * The aim of this test is verify that when several gateway receivers in a remote site share the
+   * same port and hostname-for-senders, the pings sent from the gateway senders reach the right
+   * gateway receiver and not just any of the receivers. Check that only one destination will be
+   * pinged.
+   */
+  @Test
+  public void testPingsToReceiversWithSamePortAndHostnameForSendersReachTheRightReceiver()
+      throws InterruptedException {
+    String senderId = "ln";
+    String regionName = "region-wan";
+    final int remoteLocPort = docker.getExternalPortForService("haproxy", 20334);
+
+    int locPort = createLocator(VM.getVM(0), 1, remoteLocPort);
+
+    VM vm1 = VM.getVM(1);
+    createCache(vm1, locPort);
+
+    // We use one dispatcher thread. With just one dispatcher thread, only one
+    // connection will be created by the sender towards one of the receivers and it will be
+    // monitored by the one ping thread for that remote receiver.
+    createGatewaySender(vm1, senderId, 2, true, 5,
+        1, GatewaySender.DEFAULT_ORDER_POLICY);
+
+    createPartitionedRegion(vm1, regionName, senderId, 0, 10);
+
+    int NUM_PUTS = 1;
+
+    putKeyValues(vm1, NUM_PUTS, regionName);
+
+    await().untilAsserted(() -> assertThat(getQueuedEvents(vm1, senderId)).isEqualTo(0));
+
+
+    // Wait longer than the value set in the receivers for
+    // maximum-time-between-pings: 10000 (see geode-starter-create.gfsh)
+    // to verify that connections are not closed
+    // by the receivers because each has received the pings timely.
+    int maxTimeBetweenPingsInReceiver = 15000;
+    Thread.sleep(maxTimeBetweenPingsInReceiver);
+
+    int senderPoolDisconnects = getSenderPoolDisconnects(vm1, senderId);
+    assertEquals(0, senderPoolDisconnects);

Review Comment:
   When asserting on stats that come from the `Statistics` type system you need to `await` on the results. This system is not thread synchronized for getting some values and may take time for all threads to agree on the expected value.



##########
geode-core/src/main/java/org/apache/geode/distributed/internal/ServerLocation.java:
##########
@@ -57,15 +57,24 @@ public class ServerLocation implements DataSerializable, Comparable<ServerLocati
   /**
    * For DataSerializer
    */
-  public ServerLocation() {
-
-  }
+  public ServerLocation() {}
 
   public ServerLocation(String hostName, int port) {
     this.hostName = hostName;
     this.port = port;
   }
 
+  public ServerLocation(ServerLocation other) {

Review Comment:
   There is no unit test for this new constructor. 



##########
geode-core/src/main/java/org/apache/geode/cache/client/internal/OpExecutorImpl.java:
##########
@@ -319,11 +320,12 @@ protected Object executeOnServer(ServerLocation server, Op op, boolean accessed,
     if (op instanceof PingOp.PingOpImpl) {
       // currently for pings we prefer to queue clientToServer cnx so that we will
       // not create a pooled cnx when all we have is queue connections.
+      final ServerLocationAndMemberId slAndMId = new ServerLocationAndMemberId(server,

Review Comment:
   Please don't use abbreviations in variable names.



##########
geode-core/src/main/java/org/apache/geode/cache/client/internal/ConnectionImpl.java:
##########
@@ -111,7 +113,16 @@ public ServerQueueStatus connect(EndpointManager endpointManager, ServerLocation
     }
     theSocket.setSoTimeout(readTimeout);
 
-    endpoint = endpointManager.referenceEndpoint(location, status.getMemberId());
+    if (location instanceof ServerLocationExtension) {

Review Comment:
   It may make sense to make this its own method and unit test it.



##########
geode-core/src/main/java/org/apache/geode/distributed/internal/ServerLocationExtension.java:
##########
@@ -0,0 +1,35 @@
+/*
+ * 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;
+
+
+/**
+ * Represents the ServerLocation extension to pass ServerLocationAndMemberId info
+ *
+ *
+ */
+public class ServerLocationExtension extends ServerLocation {

Review Comment:
   There is no unit test for this new type.



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

To unsubscribe, e-mail: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org