ignite-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [ignite] pavlukhin commented on a change in pull request #6595: IGNITE-11685 Java thin client: Handle multiple async requests in parallel
Date Fri, 05 Jul 2019 15:41:43 GMT
pavlukhin commented on a change in pull request #6595: IGNITE-11685 Java thin client: Handle
multiple async requests in parallel
URL: https://github.com/apache/ignite/pull/6595#discussion_r300729842
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
 ##########
 @@ -114,76 +118,51 @@
     }
 
     /**
-     * Send request and handle response. The method is synchronous and single-threaded.
+     * Send request and handle response.
      */
     public <T> T service(
         ClientOperation op,
-        Consumer<BinaryOutputStream> payloadWriter,
-        Function<BinaryInputStream, T> payloadReader
+        Consumer<PayloadOutputChannel> payloadWriter,
+        Function<PayloadInputChannel, T> payloadReader
     ) throws ClientException {
         ClientConnectionException failure = null;
 
-        T res = null;
-
-        int totalSrvs = 1 + backups.size();
-
-        svcLock.lock();
-        try {
-            for (int i = 0; i < totalSrvs; i++) {
-                try {
-                    if (ch == null)
-                        ch = chFactory.apply(new ClientChannelConfiguration(clientCfg).setAddress(primary)).get();
-
-                    long id = ch.send(op, payloadWriter);
-
-                    res = ch.receive(op, id, payloadReader);
+        for (int i = 0; i < srvCnt; i++) {
+            ClientChannel ch = null;
 
-                    failure = null;
+            try {
+                ch = channel();
 
-                    break;
-                }
-                catch (ClientConnectionException e) {
-                    if (failure == null)
-                        failure = e;
-                    else
-                        failure.addSuppressed(e);
+                return ch.service(op, payloadWriter, payloadReader);
+            }
+            catch (ClientConnectionException e) {
+                if (failure == null)
+                    failure = e;
+                else
+                    failure.addSuppressed(e);
 
-                    changeServer();
-                }
+                changeServer(ch);
 
 Review comment:
   I can imagine 2 concurrent threads having `ch == null` and `this.ch == null` as well. If
so a server list will be rolled twice. In certain configurations (e.g. 2 servers) it can lead
to situation when the same (currently down) address will be chosen again. Currently I have
only one thought (not very pleasant) how it can be resolved using the same `channel() ...
changeServer()` structure. It is using special `BrokenChannel` objects instead of `null` to
indicate that channel was invalidated.
   
   Correct me if I was totally wrong.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message