Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-20645 Make ComputeJob.execute asynchronous #3920

Merged
merged 24 commits into from
Jun 17, 2024

Conversation

ptupitsyn
Copy link
Contributor

@ptupitsyn ptupitsyn commented Jun 14, 2024

  • Change R ComputeJob.execute(...) to CompletableFuture<R> ComputeJob.executeAsync(...)
  • Update cancellation logic to deal with the resulting future

@ptupitsyn ptupitsyn self-assigned this Jun 14, 2024
public interface ComputeJob<R> {
/**
* Executes the job on an Ignite node.
*
* @param context The execution context.
* @param args Job arguments.
* @return Job result.
* @return Job future. Can be null if the job is synchronous and does not return any result.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance reasons?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Very small performance improvement
  • A bit easier for the user at the expense of a one-line check in Ignite code

Do you think we should disallow nulls?

public interface ComputeJob<R> {
/**
* Executes the job on an Ignite node.
*
* @param context The execution context.
* @param args Job arguments.
* @return Job result.
* @return Job future. Can be null if the job is synchronous and does not return any result.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to have Nullable futute? Mby in this case user should have CF ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question from @isapego above. I don't have a strong opinion, we can require a non-null future.

user should have CF

CF?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CF=CompletableFuture

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user can return completedFuture() or null, it does not make any difference. Let's keep it this way.

# Conflicts:
#	modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientComputeTest.java
@@ -93,7 +93,8 @@ public TaskExecutionInternal(
splitExecution = executorService.submit(
() -> {
MapReduceTask<R> task = instantiateTask(taskClass);
return new SplitResult<>(task, task.split(context, args));

return completedFuture(new SplitResult<>(task, task.split(context, args)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also make MapReduceTask.split and reduce asynchronous?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Conflicts:
#	modules/compute/src/test/java/org/apache/ignite/internal/compute/executor/ComputeExecutorTest.java
@ptupitsyn ptupitsyn merged commit 9b59ef6 into apache:main Jun 17, 2024
1 check passed
@ptupitsyn ptupitsyn deleted the ignite-20645 branch June 17, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants