ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject [1/3] incubator-ignite git commit: # IGNITE-22 Refactoring: GridClosureProcessor.JobMapper should take integer instead of map.
Date Tue, 17 Feb 2015 14:18:12 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-22 [created] 5e33254c4


# IGNITE-22 Refactoring: GridClosureProcessor.JobMapper should take integer instead of map.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/6ea50c7e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/6ea50c7e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/6ea50c7e

Branch: refs/heads/ignite-22
Commit: 6ea50c7ee207ee0e36c91f39fdef71db51e6afb4
Parents: 41ffb81
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Tue Feb 17 13:22:30 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Tue Feb 17 13:22:30 2015 +0300

----------------------------------------------------------------------
 .../closure/GridClosureProcessor.java           | 45 ++++++++------------
 1 file changed, 18 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6ea50c7e/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
index 84e2a8f..891b71b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
@@ -217,9 +217,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
         try {
             if (!F.isEmpty(jobs) && !F.isEmpty(nodes)) {
-                Map<ComputeJob, ClusterNode> map = new HashMap<>(jobs.size(),
1);
-
-                JobMapper mapper = new JobMapper(map);
+                JobMapper mapper = new JobMapper(jobs.size());
 
                 switch (mode) {
                     case BROADCAST: {
@@ -241,7 +239,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
                     }
                 }
 
-                return map;
+                return mapper.map();
             }
             else
                 return Collections.emptyMap();
@@ -271,9 +269,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
         try {
             if (!F.isEmpty(jobs) && !F.isEmpty(nodes)) {
-                Map<ComputeJob, ClusterNode> map = new HashMap<>(jobs.size(),
1);
-
-                JobMapper mapper = new JobMapper(map);
+                JobMapper mapper = new JobMapper(jobs.size());
 
                 switch (mode) {
                     case BROADCAST: {
@@ -295,7 +291,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
                     }
                 }
 
-                return map;
+                return mapper.map();
             }
             else
                 return Collections.emptyMap();
@@ -1026,13 +1022,10 @@ public class GridClosureProcessor extends GridProcessorAdapter {
         private boolean hadLocNode;
 
         /**
-         * @param map Jobs map.
+         * @param expJobCnt Expected Jobs count.
          */
-        private JobMapper(Map<ComputeJob, ClusterNode> map) {
-            assert map != null;
-            assert map.isEmpty();
-
-            this.map = map;
+        private JobMapper(int expJobCnt) {
+            map = IgniteUtils.newHashMap(expJobCnt);
         }
 
         /**
@@ -1056,6 +1049,10 @@ public class GridClosureProcessor extends GridProcessorAdapter {
 
             map.put(job, node);
         }
+
+        public Map<ComputeJob, ClusterNode> map() {
+            return map;
+        }
     }
 
     /**
@@ -1427,9 +1424,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
         /** {@inheritDoc} */
         @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode>
subgrid, @Nullable Void arg) {
             try {
-                Map<ComputeJob, ClusterNode> map = new HashMap<>(args.size(),
1);
-
-                JobMapper mapper = new JobMapper(map);
+                JobMapper mapper = new JobMapper(args.size());
 
                 for (T jobArg : args) {
                     ComputeJob job = job(this.job, jobArg);
@@ -1437,7 +1432,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
                     mapper.map(job, lb.getBalancedNode(job, null));
                 }
 
-                return map;
+                return mapper.map();
             }
             catch (IgniteCheckedException e) {
                 throw new IgniteException(e);
@@ -1485,9 +1480,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
         /** {@inheritDoc} */
         @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode>
subgrid, @Nullable Void arg) {
             try {
-                Map<ComputeJob, ClusterNode> map = new HashMap<>(args.size(),
1);
-
-                JobMapper mapper = new JobMapper(map);
+                JobMapper mapper = new JobMapper(args.size());
 
                 for (T jobArg : args) {
                     ComputeJob job = job(this.job, jobArg);
@@ -1495,7 +1488,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
                     mapper.map(job, lb.getBalancedNode(job, null));
                 }
 
-                return map;
+                return mapper.map();
             }
             catch (IgniteCheckedException e) {
                 throw new IgniteException(e);
@@ -1548,14 +1541,12 @@ public class GridClosureProcessor extends GridProcessorAdapter {
                 return Collections.emptyMap();
 
             try {
-                Map<ComputeJob, ClusterNode> map = new HashMap<>(subgrid.size(),
1);
-
-                JobMapper mapper = new JobMapper(map);
+                JobMapper mapper = new JobMapper(subgrid.size());
 
                 for (ClusterNode n : subgrid)
                     mapper.map(job(job, this.arg), n);
 
-                return map;
+                return mapper.map();
             }
             catch (IgniteCheckedException e) {
                 throw new IgniteException(e);
@@ -1593,7 +1584,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
          * @param job Job.
          * @param arg Argument.
          */
-        public C1(IgniteClosure<T, R> job, T arg) {
+        C1(IgniteClosure<T, R> job, T arg) {
             this.job = job;
             this.arg = arg;
         }


Mime
View raw message