You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/03/22 10:48:32 UTC

[GitHub] [ignite-3] SammyVimes commented on a change in pull request #742: IGNITE-16677 Implement broadcast method of IgniteCompute interface

SammyVimes commented on a change in pull request #742:
URL: https://github.com/apache/ignite-3/pull/742#discussion_r832027136



##########
File path: modules/compute/src/main/java/org/apache/ignite/internal/compute/IgniteComputeImpl.java
##########
@@ -68,14 +86,25 @@ private boolean isLocal(ClusterNode targetNode) {
         return targetNode.equals(topologyService.localMember());
     }
 
-    private ClusterNode randomNode(Set<ClusterNode> nodes) {
-        int nodesToSkip = random.nextInt(nodes.size());
+    /** {@inheritDoc} */
+    @Override
+    public <R> Map<ClusterNode, CompletableFuture<R>> broadcast(
+            Set<ClusterNode> nodes,
+            Class<? extends ComputeJob<R>> jobClass,
+            Object... args
+    ) {
+        Map<ClusterNode, CompletableFuture<R>> resultMap = nodes.stream()
+                .collect(toMap(node -> node, node -> executeOnOneNode(node, jobClass, args)));

Review comment:
       You can use toUnmodifiableMap here

##########
File path: modules/compute/src/main/java/org/apache/ignite/internal/compute/IgniteComputeImpl.java
##########
@@ -68,14 +86,25 @@ private boolean isLocal(ClusterNode targetNode) {
         return targetNode.equals(topologyService.localMember());
     }
 
-    private ClusterNode randomNode(Set<ClusterNode> nodes) {
-        int nodesToSkip = random.nextInt(nodes.size());
+    /** {@inheritDoc} */
+    @Override
+    public <R> Map<ClusterNode, CompletableFuture<R>> broadcast(
+            Set<ClusterNode> nodes,
+            Class<? extends ComputeJob<R>> jobClass,
+            Object... args
+    ) {
+        Map<ClusterNode, CompletableFuture<R>> resultMap = nodes.stream()
+                .collect(toMap(node -> node, node -> executeOnOneNode(node, jobClass, args)));
 
-        Iterator<ClusterNode> iterator = nodes.iterator();
-        for (int i = 0; i < nodesToSkip; i++) {
-            iterator.next();
-        }
+        return Map.copyOf(resultMap);
+    }
 
-        return iterator.next();
+    /** {@inheritDoc} */
+    @Override
+    public <R> Map<ClusterNode, CompletableFuture<R>> broadcast(Set<ClusterNode> nodes, String jobClassName, Object... args) {
+        Map<ClusterNode, CompletableFuture<R>> resultMap = nodes.stream()
+                .collect(toMap(node -> node, node -> executeOnOneNode(node, jobClassName, args)));

Review comment:
       Same as above




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org