#IGNITE-722 Fixed warmup closure.

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

Branch: refs/heads/ignite-718
Commit: d0dddaaf5b758d59d77469c86d8a7f27254f3f40
Parents: 660ed78
Author: nikolay_tikhonov <ntikho...@gridgain.com>
Authored: Fri Apr 10 16:58:14 2015 +0300
Committer: nikolay_tikhonov <ntikho...@gridgain.com>
Committed: Fri Apr 10 16:58:14 2015 +0300

----------------------------------------------------------------------
 .../ignite/startup/BasicWarmupClosure.java      |  9 ++-
 .../cache/IgniteWarmupClosureSelfTest.java      | 82 ++++++++++++++++++++
 .../ignite/testsuites/IgniteCacheTestSuite.java |  4 +
 3 files changed, 92 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d0dddaaf/modules/core/src/main/java/org/apache/ignite/startup/BasicWarmupClosure.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/startup/BasicWarmupClosure.java 
b/modules/core/src/main/java/org/apache/ignite/startup/BasicWarmupClosure.java
index 08ec420..0cbc73c 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/startup/BasicWarmupClosure.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/startup/BasicWarmupClosure.java
@@ -244,8 +244,11 @@ public class BasicWarmupClosure implements 
IgniteInClosure<IgniteConfiguration>
         ExecutorService svc = Executors.newFixedThreadPool(threadCnt);
 
         try {
-            for (CacheConfiguration cc : 
first.configuration().getCacheConfiguration()) {
-                GridCache<Object, Object> cache0 = 
((IgniteKernal)first).getCache(cc.getName());
+            for (IgniteCacheProxy cache : ((IgniteKernal)first).caches()) {
+                if (!cache.context().userCache())
+                    continue;
+
+                GridCache<Object, Object> cache0 = cache.context().cache();
 
                 for (String warmupMethod : warmupMethods) {
                     Collection<Future> futs = new ArrayList<>(threadCnt);
@@ -303,7 +306,7 @@ public class BasicWarmupClosure implements 
IgniteInClosure<IgniteConfiguration>
                         futs.add(svc.submit(call));
                     }
 
-                    out("Running warmup [cacheName=" + 
U.maskName(cc.getName()) + ", method=" + warmupMethod + ']');
+                    out("Running warmup [cacheName=" + 
U.maskName(cache.getName()) + ", method=" + warmupMethod + ']');
 
                     for (Future fut : futs)
                         fut.get();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d0dddaaf/modules/core/src/test/java/org/apache/ignite/cache/IgniteWarmupClosureSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/cache/IgniteWarmupClosureSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/cache/IgniteWarmupClosureSelfTest.java
new file mode 100644
index 0000000..4d91347
--- /dev/null
+++ 
b/modules/core/src/test/java/org/apache/ignite/cache/IgniteWarmupClosureSelfTest.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache;
+
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.startup.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+/**
+ *
+ */
+public class IgniteWarmupClosureSelfTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new 
TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    public IgniteWarmupClosureSelfTest(){
+        super(false);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinder(IP_FINDER);
+
+        cfg.getTransactionConfiguration().setTxSerializableEnabled(true);
+
+        cfg.setDiscoverySpi(disco);
+
+        BasicWarmupClosure warmupClosure = new BasicWarmupClosure();
+
+        warmupClosure.setGridCount(2);
+        warmupClosure.setIterationCount(10);
+        warmupClosure.setKeyRange(10);
+
+        cfg.setWarmupClosure(warmupClosure);
+
+        CacheConfiguration<Integer, Integer> cacheCfg = new 
CacheConfiguration<>();
+
+        cacheCfg.setCacheMode(CacheMode.PARTITIONED);
+        cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
+        cacheCfg.setBackups(1);
+        cacheCfg.setName("test");
+
+        cfg.setCacheConfiguration(cacheCfg);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testWarmupClosure() throws Exception {
+        startGrid(1);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d0dddaaf/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 1f38e21..02f82ce 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -19,6 +19,7 @@ package org.apache.ignite.testsuites;
 
 import junit.framework.*;
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.affinity.fair.*;
 import org.apache.ignite.cache.store.*;
 import org.apache.ignite.cache.store.jdbc.*;
@@ -81,6 +82,9 @@ public class IgniteCacheTestSuite extends TestSuite {
         suite.addTestSuite(IgniteCachePrivateExecutionContextTest.class);
         suite.addTestSuite(IgniteCacheSharedExecutionContextTest.class);
 
+        // Warmup closure tests.
+        suite.addTestSuite(IgniteWarmupClosureSelfTest.class);
+
         // Affinity tests.
         suite.addTestSuite(GridFairAffinityFunctionNodesSelfTest.class);
         suite.addTestSuite(IgniteFairAffinityDynamicCacheSelfTest.class);

Reply via email to