valepakh commented on code in PR #3920:
URL: https://github.com/apache/ignite-3/pull/3920#discussion_r1642532578


##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientStreamerWithReceiverBatchSendRequest.java:
##########
@@ -102,7 +102,7 @@ public static CompletableFuture<Void> process(
 
     private static class ReceiverRunnerJob implements ComputeJob<List<Object>> 
{
         @Override
-        public @Nullable List<Object> execute(JobExecutionContext context, 
Object... args) {
+        public CompletableFuture<List<Object>> 
executeAsync(JobExecutionContext context, Object... args) {

Review Comment:
   Let's keep the nullable annotation here and return nullable value below



##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientStreamerWithReceiverBatchSendRequest.java:
##########
@@ -115,7 +115,7 @@ private static class ReceiverRunnerJob implements 
ComputeJob<List<Object>> {
 
             CompletableFuture<List<Object>> receiveFut = 
receiver.receive(receiverInfo.items(), receiverContext, receiverInfo.args());
 
-            return receiveFut == null ? null : receiveFut.join();
+            return receiveFut == null ? nullCompletedFuture() : receiveFut;

Review Comment:
   This could be simplified to `return receiver.receive(receiverInfo.items(), 
receiverContext, receiverInfo.args());`



##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientComputeTest.java:
##########
@@ -737,39 +745,47 @@ private List<ClusterNode> sortedNodes() {
 
     private static class NodeNameJob implements ComputeJob<String> {
         @Override
-        public String execute(JobExecutionContext context, Object... args) {
-            return context.ignite().name() + 
Arrays.stream(args).map(Object::toString).collect(Collectors.joining("_"));
+        public CompletableFuture<String> executeAsync(JobExecutionContext 
context, Object... args) {
+            return completedFuture(
+                    context.ignite().name() + 
Arrays.stream(args).map(Object::toString).collect(Collectors.joining("_")));
         }
     }
 
     private static class ConcatJob implements ComputeJob<String> {
         @Override
-        public String execute(JobExecutionContext context, Object... args) {
+        public CompletableFuture<String> executeAsync(JobExecutionContext 
context, Object... args) {
             if (args == null) {
-                return null;
+                return nullCompletedFuture();
             }
 
-            return Arrays.stream(args).map(o -> o == null ? "null" : 
o.toString()).collect(Collectors.joining("_"));
+            return completedFuture(
+                    Arrays.stream(args).map(o -> o == null ? "null" : 
o.toString()).collect(Collectors.joining("_")));
         }
     }
 
     private static class IgniteExceptionJob implements ComputeJob<String> {
         @Override
-        public String execute(JobExecutionContext context, Object... args) {
+        public CompletableFuture<String> executeAsync(JobExecutionContext 
context, Object... args) {
             throw new CustomException(TRACE_ID, COLUMN_ALREADY_EXISTS_ERR, 
"Custom job error", null);
         }
     }
 
     private static class ExceptionJob implements ComputeJob<String> {
         @Override
-        public String execute(JobExecutionContext context, Object... args) {
-            throw new ArithmeticException("math err");
+        public CompletableFuture<String> executeAsync(JobExecutionContext 
context, Object... args) {
+            boolean asyncJob = args.length > 0 && (Boolean) args[0];
+
+            if (asyncJob) {
+                return CompletableFuture.failedFuture(new 
ArithmeticException("math err"));

Review Comment:
   Static import for `failedFuture`?



##########
modules/client/src/test/java/org/apache/ignite/client/fakes/FakeCompute.java:
##########
@@ -104,11 +104,12 @@ public <R> JobExecution<R> executeAsyncWithFailover(
         }
 
         if (jobClassName.startsWith("org.apache.ignite")) {
-            Class<ComputeJob<Object>> jobClass = 
ComputeUtils.jobClass(this.getClass().getClassLoader(), jobClassName);
-            ComputeJob<Object> job = ComputeUtils.instantiateJob(jobClass);
-            Object jobRes = job.execute(new JobExecutionContextImpl(ignite, 
new AtomicBoolean(), this.getClass().getClassLoader()), args);
+            Class<ComputeJob<R>> jobClass = 
ComputeUtils.jobClass(this.getClass().getClassLoader(), jobClassName);
+            ComputeJob<R> job = ComputeUtils.instantiateJob(jobClass);
+            CompletableFuture<R> jobFut = job.executeAsync(
+                    new JobExecutionContextImpl(ignite, new AtomicBoolean(), 
this.getClass().getClassLoader()), args);
 
-            return jobExecution(completedFuture((R) jobRes));
+            return jobExecution(jobFut);

Review Comment:
   If you keep the `executeAsync` nullable, you should check the result here



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to