ptupitsyn commented on a change in pull request #8174:
URL: https://github.com/apache/ignite/pull/8174#discussion_r494133243
##########
File path:
modules/core/src/main/java/org/apache/ignite/client/ClientCompute.java
##########
@@ -55,9 +55,25 @@
* @return A Future representing pending completion of the task.
* @throws ClientException If task failed.
* @see ComputeTask for information about task execution.
+ * @deprecated Use {@link #executeAsync2(String, Object)} instead.
+ * This method calls {@link #executeAsync2(String, Object)} internally,
but returns a more limited
+ * Future interface.
*/
+ @Deprecated
Review comment:
As I understand, this still breaks binary compatibility, so we have to
create a new method.
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientComputeImpl.java
##########
@@ -115,6 +119,11 @@
return executeAsync0(taskName, arg, dfltGrp, (byte)0, 0L);
}
+ /** {@inheritDoc} */
+ @Override public <T, R> IgniteClientFuture<R> executeAsync2(String
taskName, @Nullable T arg) throws ClientException {
Review comment:
See above, I think we do, because of binary compatibility.
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
##########
@@ -210,14 +213,95 @@
throw failure;
}
+ /**
+ * Send request and handle response asynchronously.
+ */
+ public <T> IgniteClientFuture<T> serviceAsync(
+ ClientOperation op,
+ Consumer<PayloadOutputChannel> payloadWriter,
+ Function<PayloadInputChannel, T> payloadReader
+ ) throws ClientException, ClientError {
+ CompletableFuture<T> fut = new CompletableFuture<>();
+
+ ClientChannel ch = channel();
+
+ ch.serviceAsync(op, payloadWriter, payloadReader).handle((res, err) ->
+ handleServiceAsync(op, payloadWriter, payloadReader, fut,
null, null, ch, res, err));
+
+ return new IgniteClientFutureImpl<>(fut);
+ }
+
+ /**
+ * Handles serviceAsync results and retries as needed.
+ */
+ private <T> Object handleServiceAsync(ClientOperation op,
+ Consumer<PayloadOutputChannel>
payloadWriter,
+ Function<PayloadInputChannel, T>
payloadReader,
+ CompletableFuture<T> fut,
+ ClientConnectionException failure,
+ AtomicInteger chIdx,
+ ClientChannel ch,
+ T res,
+ Throwable err) {
+ if (err == null) {
+ fut.complete(res);
+ return null;
+ }
+
+ if (err instanceof ClientConnectionException) {
Review comment:
I agree, but this behavior is consistent with sync API, I don't think we
should have different behavior for sync and async API.
----------------------------------------------------------------
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:
[email protected]