PakhomovAlexander commented on code in PR #2940:
URL: https://github.com/apache/ignite-3/pull/2940#discussion_r1422382771


##########
modules/api/src/main/java/org/apache/ignite/compute/JobExecution.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.compute;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Job control object, provides information about the job execution process 
and result, allows cancelling the job.
+ *
+ * @param <R> Job result type.
+ */
+public interface JobExecution<R> {
+    /**
+     * Returns job's execution result.
+     *
+     * @return Job's execution result future.
+     */
+    CompletableFuture<R> resultAsync();
+
+    /**
+     * Returns the current status of the job. The job status may be deleted 
and thus return {@code null} if the time for retaining job
+     * status has been exceeded.
+     *
+     * @return The current status of the job, or {@code null} if the job 
status no longer exists due to exceeding the retention time limit.

Review Comment:
   If it can return `null` that we have to annotate the method with `@Nullable`



##########
modules/compute/src/test/java/org/apache/ignite/internal/compute/queue/PriorityQueueExecutorTest.java:
##########
@@ -199,21 +196,142 @@ public void testQueueOverflow() {
         CountDownLatch latch2 = new CountDownLatch(1);
 
         //Submit task for executing
-        priorityQueueExecutor.submit(() -> {
+        submit(() -> {
             latch1.await();
             return 0;
         }, 1);
 
         //Submit task for executing, should be in queue
-        priorityQueueExecutor.submit(() -> {
+        submit(() -> {
             latch2.await();
             return 1;
         }, 1);
 
         //Submit task for execution should throw exception because queue is 
full.
         assertThat(
-                priorityQueueExecutor.submit(() -> null),
+                submit(() -> null),
                 willThrow(IgniteException.class, "Compute queue overflow")
         );
+
+        // Force the tasks to exit to minimize executor shutdown time
+        latch1.countDown();
+        latch2.countDown();
+    }
+
+    @Test
+    void taskCatchesInterruption() {
+        initExecutor(1);
+
+        CountDownLatch latch = new CountDownLatch(1);
+        QueueExecution<Object> execution = priorityQueueExecutor.submit(() -> {
+            while (true) {
+                try {
+                    latch.await();
+                } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();

Review Comment:
   Can we submit one more job to the single-threaded executor after this one is 
canceled? I think `Thread.currentThread().interrupt()` makes future executions 
impossible.



##########
modules/api/src/main/java/org/apache/ignite/compute/JobStatus.java:
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.compute;
+
+import java.time.Instant;
+import java.util.UUID;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Job status.
+ */
+public class JobStatus {

Review Comment:
   The ticket also requires the `ownership` field. If is to not needed anymore, 
add a comment to the ticket, please.



-- 
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