# IGNITE-55 Minor change of code flow - one return instead of two + execute sub 
jobs on cache nodes.


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

Branch: refs/heads/ignite-55-2
Commit: e8d4d6e8fc8ea22488a1a343b9ba324adbaaccd5
Parents: f4b6337
Author: AKuznetsov <akuznet...@gridgain.com>
Authored: Wed Feb 11 16:53:13 2015 +0700
Committer: AKuznetsov <akuznet...@gridgain.com>
Committed: Wed Feb 11 16:53:13 2015 +0700

----------------------------------------------------------------------
 .../visor/cache/VisorCacheClearTask.java        | 26 ++++++++++++--------
 1 file changed, 16 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d4d6e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
index 5d5605d..01c5246 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
@@ -54,6 +54,9 @@ public class VisorCacheClearTask extends 
VisorOneNodeTask<String, IgniteBiTuple<
         /** */
         private final IgniteFuture<Integer>[] futs = new IgniteFuture[3];
 
+        /** */
+        private final String cacheName;
+
         /**
          * Create job.
          *
@@ -63,6 +66,8 @@ public class VisorCacheClearTask extends 
VisorOneNodeTask<String, IgniteBiTuple<
         private VisorCacheClearJob(String cacheName, boolean debug) {
             super(cacheName, debug);
 
+            this.cacheName = cacheName;
+
             lsnr = new IgniteInClosure<IgniteFuture<Integer>>() {
                 @Override public void apply(IgniteFuture<Integer> f) {
                     assert futs[0].isDone();
@@ -79,7 +84,7 @@ public class VisorCacheClearTask extends 
VisorOneNodeTask<String, IgniteBiTuple<
          * @return {@code true} If subJob was not completed and this job 
should be suspended.
          */
         private boolean callAsync(IgniteCallable<Integer> subJob, int idx) {
-            IgniteCompute compute = 
ignite.compute(ignite.forLocal()).withAsync();
+            IgniteCompute compute = 
ignite.compute(ignite.forCacheNodes(cacheName)).withAsync();
 
             compute.call(subJob);
 
@@ -99,19 +104,20 @@ public class VisorCacheClearTask extends 
VisorOneNodeTask<String, IgniteBiTuple<
 
         /** {@inheritDoc} */
         @Override protected IgniteBiTuple<Integer, Integer> run(final String 
cacheName) {
-            if (futs[0] != null && futs[1] != null && futs[2] != null)
-                return new IgniteBiTuple<>(futs[0].get(), futs[2].get());
+            if (futs[0] == null || futs[1] == null || futs[2] == null) {
+                IgniteCache cache = ignite.jcache(cacheName);
 
-            IgniteCache cache = ignite.jcache(cacheName);
+                if (futs[0] == null && callAsync(new 
VisorCacheSizeCallable(cache), 0))
+                    return null;
 
-            if (futs[0] == null && callAsync(new 
VisorCacheSizeCallable(cache), 0))
-                return null;
+                if (futs[1] == null && callAsync(new 
VisorCacheClearCallable(cache), 1))
+                    return null;
 
-            if (futs[1] == null && callAsync(new 
VisorCacheClearCallable(cache), 1))
-                return null;
+                if (futs[2] == null && callAsync(new 
VisorCacheSizeCallable(cache), 2))
+                    return null;
+            }
 
-            if (futs[2] == null && callAsync(new 
VisorCacheSizeCallable(cache), 2))
-                return null;
+            assert futs[0].isDone() && futs[1].isDone() && futs[2].isDone();
 
             return new IgniteBiTuple<>(futs[0].get(), futs[2].get());
         }

Reply via email to