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 07:44:39 UTC

[GitHub] [ignite-3] rpuch opened a new pull request #742: IGNITE-16677 Implement broadcast method of IgniteCompute interface

rpuch opened a new pull request #742:
URL: https://github.com/apache/ignite-3/pull/742


   https://issues.apache.org/jira/browse/IGNITE-16677


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



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

Posted by GitBox <gi...@apache.org>.
rpuch commented on a change in pull request #742:
URL: https://github.com/apache/ignite-3/pull/742#discussion_r832049416



##########
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:
       Fixed

##########
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:
       Fixed




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



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

Posted by GitBox <gi...@apache.org>.
SammyVimes commented on pull request #742:
URL: https://github.com/apache/ignite-3/pull/742#issuecomment-1075103056


   Merged to the main branch


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



[GitHub] [ignite-3] SammyVimes closed pull request #742: IGNITE-16677 Implement broadcast method of IgniteCompute interface

Posted by GitBox <gi...@apache.org>.
SammyVimes closed pull request #742:
URL: https://github.com/apache/ignite-3/pull/742


   


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



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

Posted by GitBox <gi...@apache.org>.
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