mivanac commented on code in PR #7381:
URL: https://github.com/apache/geode/pull/7381#discussion_r861239308


##########
geode-core/src/main/java/org/apache/geode/internal/tcp/TCPConduit.java:
##########
@@ -909,6 +906,104 @@ public Connection getConnection(InternalDistributedMember 
memberAddress,
     }
   }
 
+
+  /**
+   * Return a connection to the given member. This method performs quick scan 
for connection.
+   * Only one attempt to create a connection to the given member .
+   *
+   * @param memberAddress the IDS associated with the remoteId
+   * @param preserveOrder whether this is an ordered or unordered connection
+   * @param startTime the time this operation started
+   * @param ackTimeout the ack-wait-threshold * 1000 for the operation to be 
transmitted (or zero)
+   * @param ackSATimeout the ack-severe-alert-threshold * 1000 for the 
operation to be transmitted
+   *        (or zero)
+   *
+   * @return the connection
+   */
+  public Connection getFirstScanForConnection(InternalDistributedMember 
memberAddress,
+      final boolean preserveOrder, long startTime, long ackTimeout,
+      long ackSATimeout) throws IOException, 
DistributedSystemDisconnectedException {
+    if (stopped) {
+      throw new DistributedSystemDisconnectedException("The conduit is 
stopped");
+    }
+
+    Connection connection = null;
+    stopper.checkCancelInProgress(null);
+    boolean interrupted = Thread.interrupted();
+    try {
+      // If this is the second time through this loop, we had problems.
+      // Tear down the connection so that it gets rebuilt.
+
+      Exception problem = null;
+      try {
+        // Get (or regenerate) the connection
+        // this could generate a ConnectionException, so it must be caught and 
retried
+        boolean retryForOldConnection;
+        boolean debugRetry = false;
+        do {
+          retryForOldConnection = false;
+          connection = getConTable().get(memberAddress, preserveOrder, 
startTime, ackTimeout,
+              ackSATimeout, true);
+          if (connection == null) {
+            // conduit may be closed - otherwise an ioexception would be thrown
+            problem = new IOException(
+                String.format("Unable to reconnect to server; possible 
shutdown: %s",
+                    memberAddress));
+          } else if (connection.isClosing()
+              || !connection.getRemoteAddress().equals(memberAddress)) {
+            if (logger.isDebugEnabled()) {
+              logger.debug("Got an old connection for {}: {}@{}", 
memberAddress, connection,
+                  connection.hashCode());
+            }
+            connection.closeOldConnection("closing old connection");
+            connection = null;
+            retryForOldConnection = true;

Review Comment:
   Thanks for comments. This is reused code from getConnection() method, so 
that is the reason it has wrong comments, and lots of loops. I will optimize it.



-- 
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-unsubscr...@geode.apache.org

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

Reply via email to