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-22435 Add JobTarget interface #3950

Merged
merged 55 commits into from
Jun 20, 2024
Merged

Conversation

ptupitsyn
Copy link
Contributor

@ptupitsyn ptupitsyn commented Jun 19, 2024

Reduce the number of overloads in IgniteCompute and make the API more readable with new JobTarget interface:

public interface JobTarget {
    static JobTarget node(ClusterNode node);
    static JobTarget anyNode(Collection<ClusterNode> nodes);
    static JobTarget colocated(String tableName, Tuple key);
    static <K> JobTarget colocated(String tableName, K key, Mapper<K> keyMapper);
}

Usage Example

String result = entryNode.compute().execute(
        JobTarget.anyNode(node1, node2),
        JobDescriptor.builder(MyJob.class).units(units()).build(),
        "arg");

JobExecution<String> execution = entryNode.compute().submit(
        JobTarget.colocated("My-table", Tuple.create(Map.of("k", 1))),
        JobDescriptor.builder(MyColocatedJob.class).build());
  • Broadcast methods are not affected because of different return type

@ptupitsyn ptupitsyn requested a review from korlov42 June 19, 2024 09:29
@ptupitsyn ptupitsyn marked this pull request as ready for review June 19, 2024 09:30
Comment on lines 41 to 59
/**
* Creates a job target for any node from the provided collection.
*
* @param nodes Collection of nodes.
* @return Job target.
*/
static JobTarget anyNode(ClusterNode... nodes) {
return new NodesJobTarget(Set.of(nodes));
}

/**
* Creates a job target for any node from the provided collection.
*
* @param nodes Collection of nodes.
* @return Job target.
*/
static JobTarget anyNode(Collection<ClusterNode> nodes) {
return new NodesJobTarget(new HashSet<>(nodes));
}
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 mention that the collection of nodes is treated as a Set (duplicates are ignored)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think this matters with "any node" semantics because we don't explain how a node is picked from the provided collection. There is no guarantee of fairness or randomness on the API level.

ptupitsyn and others added 7 commits June 20, 2024 08:15
…/compute/ClientCompute.java

Co-authored-by: Vadim Pakhnushev <8614891+valepakh@users.noreply.github.com>
…keCompute.java

Co-authored-by: Vadim Pakhnushev <8614891+valepakh@users.noreply.github.com>
…ernal/compute/ItComputeBaseTest.java

Co-authored-by: Vadim Pakhnushev <8614891+valepakh@users.noreply.github.com>
…te/IgniteComputeImpl.java

Co-authored-by: Vadim Pakhnushev <8614891+valepakh@users.noreply.github.com>
Copy link
Contributor

@korlov42 korlov42 left a comment

Choose a reason for hiding this comment

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

the changes in API module looks good in general. I left a few suggestions on how to improve javadoc though

ptupitsyn and others added 14 commits June 20, 2024 11:39
…java

Co-authored-by: korlov42 <korlov@gridgain.com>
…java

Co-authored-by: korlov42 <korlov@gridgain.com>
…java

Co-authored-by: korlov42 <korlov@gridgain.com>
…java

Co-authored-by: korlov42 <korlov@gridgain.com>
…java

Co-authored-by: korlov42 <korlov@gridgain.com>
…java

Co-authored-by: korlov42 <korlov@gridgain.com>
…java

Co-authored-by: korlov42 <korlov@gridgain.com>
…/compute/ClientCompute.java

Co-authored-by: Vadim Pakhnushev <8614891+valepakh@users.noreply.github.com>
@ptupitsyn ptupitsyn merged commit 3d83c35 into apache:main Jun 20, 2024
1 check passed
@ptupitsyn ptupitsyn deleted the ignite-22435 branch June 20, 2024 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants