ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [12/50] [abbrv] incubator-ignite git commit: # sprint-2 Use new API for cache load.
Date Wed, 18 Feb 2015 15:43:33 GMT
# sprint-2 Use new API for cache load.


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

Branch: refs/heads/ignite-224
Commit: 38e1389ac57a9737680b63d446e26f1666c45e5c
Parents: 41ffb81
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Tue Feb 17 17:20:51 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Tue Feb 17 17:20:51 2015 +0700

----------------------------------------------------------------------
 .../visor/cache/VisorCacheLoadTask.java         | 35 ++++++++------------
 1 file changed, 13 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/38e1389a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java
index 8643fd2..55e3f5e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java
@@ -18,14 +18,14 @@
 package org.apache.ignite.internal.visor.cache;
 
 import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
 import org.apache.ignite.internal.processors.task.*;
 import org.apache.ignite.internal.util.lang.*;
-import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.internal.visor.*;
 
+import javax.cache.expiry.*;
 import java.util.*;
+import java.util.concurrent.*;
 
 /**
  * Task to loads caches.
@@ -57,32 +57,23 @@ public class VisorCacheLoadTask extends
 
         /** {@inheritDoc} */
         @Override protected Map<String, Integer> run(GridTuple3<Set<String>,
Long, Object[]> arg) {
-            try {
-                Set<String> cacheNames = arg.get1();
-                Long ttl = arg.get2();
-                Object[] ldrArgs = arg.get3();
+            Set<String> cacheNames = arg.get1();
+            Long ttl = arg.get2();
+            Object[] ldrArgs = arg.get3();
 
-                Map<String, Integer> res = new HashMap<>();
+            Map<String, Integer> res = new HashMap<>();
 
-                for (GridCache c: ignite.cachesx()) {
-                    String cacheName = c.name();
+            ExpiryPolicy policy = new CreatedExpiryPolicy(new Duration(TimeUnit.MILLISECONDS,
ttl));
 
-                    if (cacheNames.contains(cacheName)) {
-                        c.loadCache(new P2<Object, Object>() {
-                            @Override public boolean apply(Object o, Object o2) {
-                                return true;
-                            }
-                        }, ttl, ldrArgs);
+            for (String cacheName: cacheNames) {
+                IgniteCache cache = ignite.jcache(cacheName).withExpiryPolicy(policy);
 
-                        res.put(cacheName, c.size()); // Put new key size for successfully
loaded cache.
-                    }
-                }
+                cache.loadCache(null, ldrArgs);
 
-                return res;
-            }
-            catch (IgniteCheckedException e) {
-                throw U.convertException(e);
+                res.put(cacheName, cache.size());
             }
+
+            return res;
         }
 
         /** {@inheritDoc} */


Mime
View raw message