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

timoninmaxim pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 8bf906fd083 IGNITE-23200 Fix attempts limit in java thin client for 
Ignite cluster request (#11660)
8bf906fd083 is described below

commit 8bf906fd0833f06bd3de79319a93033a324a3c76
Author: Popov Aleksandr <[email protected]>
AuthorDate: Fri Dec 6 11:01:26 2024 +0300

    IGNITE-23200 Fix attempts limit in java thin client for Ignite cluster 
request (#11660)
---
 .../internal/client/thin/ReliableChannel.java      |  9 +++++++-
 .../org/apache/ignite/client/ReliabilityTest.java  | 27 ++++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
index 1d0115630a5..a4f1d5c42c5 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
@@ -817,7 +817,14 @@ final class ReliableChannel implements AutoCloseable {
         ClientOperation op,
         @Nullable List<ClientConnectionException> failures
     ) {
-        while (attemptsLimit > (failures == null ? 0 : failures.size())) {
+        int fixedAttemptsLimit = attemptsLimit;
+
+        // An additional attempt is needed because N+1 channels might be used 
for sending a message - first a random
+        // one, then each one from #channels in sequence.
+        if (partitionAwarenessEnabled && channelsCnt.get() > 1)
+            fixedAttemptsLimit++;
+
+        while (fixedAttemptsLimit > (failures == null ? 0 : failures.size())) {
             ClientChannelHolder hld = null;
             ClientChannel c = null;
 
diff --git 
a/modules/core/src/test/java/org/apache/ignite/client/ReliabilityTest.java 
b/modules/core/src/test/java/org/apache/ignite/client/ReliabilityTest.java
index 6803f3c2d47..ce07b247840 100644
--- a/modules/core/src/test/java/org/apache/ignite/client/ReliabilityTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/client/ReliabilityTest.java
@@ -51,6 +51,7 @@ import org.apache.ignite.failure.FailureHandler;
 import org.apache.ignite.internal.client.thin.AbstractThinClientTest;
 import org.apache.ignite.internal.client.thin.ClientOperation;
 import org.apache.ignite.internal.client.thin.ClientServerError;
+import org.apache.ignite.internal.client.thin.ServicesTest;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.services.Service;
@@ -677,6 +678,32 @@ public class ReliabilityTest extends 
AbstractThinClientTest {
         }
     }
 
+    /**
+     * Tests service proxy failover.
+     */
+    @Test
+    public void testServiceProxyFailover() throws Exception {
+        Assume.assumeTrue(partitionAware);
+
+        final int CLUSTER_SIZE = 3;
+
+        try (LocalIgniteCluster cluster = 
LocalIgniteCluster.start(CLUSTER_SIZE);
+             IgniteClient client = 
Ignition.startClient(getClientConfiguration()
+                 .setAddresses(cluster.clientAddresses().toArray(new 
String[CLUSTER_SIZE]))
+             )) {
+
+            
Ignition.allGrids().get(0).services().deployClusterSingleton(SERVICE_NAME, new 
ServicesTest.TestNodeIdService());
+
+            Ignition.allGrids().get(0).close();
+            Ignition.allGrids().get(1).close();
+
+            ServicesTest.TestNodeIdServiceInterface svc = 
client.services().serviceProxy(SERVICE_NAME,
+                ServicesTest.TestNodeIdServiceInterface.class);
+
+            svc.nodeId();
+        }
+    }
+
     /**
      * Performs cache put.
      *

Reply via email to