Repository: incubator-ignite Updated Branches: refs/heads/ignite-55 14ce68f3e -> 3fc0cb5f3
# IGNITE-55 Minor changes. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/0fd4ea64 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/0fd4ea64 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/0fd4ea64 Branch: refs/heads/ignite-55 Commit: 0fd4ea64989f2d5ad10951169fd6d070eed9fce4 Parents: 14ce68f Author: AKuznetsov <[email protected]> Authored: Wed Feb 11 10:27:03 2015 +0700 Committer: AKuznetsov <[email protected]> Committed: Wed Feb 11 10:27:03 2015 +0700 ---------------------------------------------------------------------- .../visor/cache/VisorCacheClearTask.java | 40 ++++++++++++++------ 1 file changed, 29 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0fd4ea64/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 cfbddd6..5d5605d 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 @@ -65,19 +65,23 @@ public class VisorCacheClearTask extends VisorOneNodeTask<String, IgniteBiTuple< lsnr = new IgniteInClosure<IgniteFuture<Integer>>() { @Override public void apply(IgniteFuture<Integer> f) { + assert futs[0].isDone(); + assert futs[1] == null || futs[1].isDone(); + assert futs[2] == null || futs[2].isDone(); + jobCtx.callcc(); } }; } /** - * - * @param compute - * @param job - * @return + * @param subJob Sub job to execute asynchronously. + * @return {@code true} If subJob was not completed and this job should be suspended. */ - private boolean fut(IgniteCompute compute, IgniteCallable<Integer> job, int idx) { - compute.call(job); + private boolean callAsync(IgniteCallable<Integer> subJob, int idx) { + IgniteCompute compute = ignite.compute(ignite.forLocal()).withAsync(); + + compute.call(subJob); IgniteFuture<Integer> fut = compute.future(); @@ -100,15 +104,13 @@ public class VisorCacheClearTask extends VisorOneNodeTask<String, IgniteBiTuple< IgniteCache cache = ignite.jcache(cacheName); - IgniteCompute compute = ignite.compute(ignite.forLocal()).withAsync(); - - if (futs[0] == null && fut(compute, new VisorCacheSizeCallable(cache), 0)) + if (futs[0] == null && callAsync(new VisorCacheSizeCallable(cache), 0)) return null; - if (futs[2] == null && fut(compute, new VisorCacheClearCallable(cache), 1)) + if (futs[1] == null && callAsync(new VisorCacheClearCallable(cache), 1)) return null; - if (futs[3] == null && fut(compute, new VisorCacheSizeCallable(cache), 3)) + if (futs[2] == null && callAsync(new VisorCacheSizeCallable(cache), 2)) return null; return new IgniteBiTuple<>(futs[0].get(), futs[2].get()); @@ -120,9 +122,17 @@ public class VisorCacheClearTask extends VisorOneNodeTask<String, IgniteBiTuple< } } + /** + * Callable to get cache size. + */ + @GridInternal private static class VisorCacheSizeCallable implements IgniteCallable<Integer> { + /** */ private final IgniteCache cache; + /** + * @param cache Cache to take size from. + */ private VisorCacheSizeCallable(IgniteCache cache) { this.cache = cache; } @@ -133,9 +143,17 @@ public class VisorCacheClearTask extends VisorOneNodeTask<String, IgniteBiTuple< } } + /** + * Callable to clear cache. + */ + @GridInternal private static class VisorCacheClearCallable implements IgniteCallable<Integer> { + /** */ private final IgniteCache cache; + /** + * @param cache Cache to clear. + */ private VisorCacheClearCallable(IgniteCache cache) { this.cache = cache; }
