You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/09/28 13:05:21 UTC

[02/15] ignite git commit: IGNITE-3983 Fixed wrong cache load optimization. Test added.

IGNITE-3983 Fixed wrong cache load optimization. Test added.


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

Branch: refs/heads/ignite-3601p
Commit: c188c3c4a96eacb85ea8e08f0634288332432c1c
Parents: 2bfa06d
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Wed Sep 28 08:46:23 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Wed Sep 28 08:46:23 2016 +0700

----------------------------------------------------------------------
 .../store/jdbc/CacheAbstractJdbcStore.java      |  4 +-
 .../CacheJdbcPojoStoreAbstractSelfTest.java     | 55 +++++++++++++-------
 ...heJdbcPojoStoreBinaryMarshallerSelfTest.java | 12 ++---
 3 files changed, 43 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c188c3c4/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
index a9a8ce1..f316676 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
@@ -893,9 +893,9 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
                                 }
 
                                 futs.add(pool.submit(loadCacheRange(em, clo, upperBound, null, 0)));
-                            }
 
-                            continue;
+                                continue;
+                            }
                         }
                         catch (SQLException e) {
                             log.warning("Failed to load entries from db in multithreaded mode, will try in single thread " +

http://git-wip-us.apache.org/repos/asf/ignite/blob/c188c3c4/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
index 83065f1..368a28e 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
@@ -50,31 +50,34 @@ import static org.apache.ignite.cache.CacheMode.PARTITIONED;
  */
 public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstractTest {
     /** IP finder. */
-    protected static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
 
     /** DB connection URL. */
-    protected static final String DFLT_CONN_URL = "jdbc:h2:mem:TestDatabase;DB_CLOSE_DELAY=-1";
+    private static final String DFLT_CONN_URL = "jdbc:h2:mem:TestDatabase;DB_CLOSE_DELAY=-1";
 
     /** Organization count. */
-    protected static final int ORGANIZATION_CNT = 1000;
+    private static final int ORGANIZATION_CNT = 1000;
 
     /** Person count. */
-    protected static final int PERSON_CNT = 100000;
+    private static final int PERSON_CNT = 100000;
 
     /** Test cache name. */
-    protected static final String CACHE_NAME = "test-cache";
+    private static final String CACHE_NAME = "test-cache";
 
     /** Flag indicating that tests should use transactional cache. */
-    protected static boolean transactional;
+    private static boolean transactional;
 
     /** Flag indicating that tests should use primitive classes like java.lang.Integer for keys. */
     protected static boolean builtinKeys;
 
     /** Flag indicating that classes for keys available on class path or not. */
-    protected static boolean noKeyClasses;
+    private static boolean noKeyClasses;
 
     /** Flag indicating that classes for values available on class path or not. */
-    protected static boolean noValClasses;
+    private static boolean noValClasses;
+
+    /** Batch size to load in parallel. */
+    private static int parallelLoadThreshold;
 
     /**
      * @return Flag indicating that all internal SQL queries should use escaped identifiers.
@@ -221,6 +224,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
         storeFactory.setTypes(storeTypes());
         storeFactory.setDataSourceFactory(new H2DataSourceFactory()); // H2 DataSource factory.
         storeFactory.setSqlEscapeAll(sqlEscapeAll());
+        storeFactory.setParallelLoadCacheMinimumThreshold(parallelLoadThreshold);
 
         cc.setCacheStoreFactory(storeFactory);
         cc.setReadThrough(true);
@@ -285,13 +289,15 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
      * @param noKeyCls {@code True} if keys classes are not on class path.
      * @param noValCls {@code True} if values classes are not on class path.
      * @param trn {@code True} if cache should be started in transactional mode.
+     * @param threshold Load batch size.
      * @throws Exception If failed to start grid.
      */
-    protected void startTestGrid(boolean builtin, boolean noKeyCls, boolean noValCls, boolean trn) throws Exception {
+    protected void startTestGrid(boolean builtin, boolean noKeyCls, boolean noValCls, boolean trn, int threshold) throws Exception {
         builtinKeys = builtin;
         noKeyClasses = noKeyCls;
         noValClasses = noValCls;
         transactional = trn;
+        parallelLoadThreshold = threshold;
 
         startGrid();
     }
@@ -322,7 +328,16 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
      * @throws Exception If failed.
      */
     public void testLoadCache() throws Exception {
-        startTestGrid(false, false, false, false);
+        startTestGrid(false, false, false, false, 512);
+
+        checkCacheLoad();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLoadCacheAll() throws Exception {
+        startTestGrid(false, false, false, false, ORGANIZATION_CNT + PERSON_CNT + 1);
 
         checkCacheLoad();
     }
@@ -331,7 +346,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
      * @throws Exception If failed.
      */
     public void testLoadCacheWithSql() throws Exception {
-        startTestGrid(false, false, false, false);
+        startTestGrid(false, false, false, false, 512);
 
         checkCacheLoadWithSql();
     }
@@ -340,7 +355,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
      * @throws Exception If failed.
      */
     public void testLoadCacheTx() throws Exception {
-        startTestGrid(false, false, false, true);
+        startTestGrid(false, false, false, true, 512);
 
         checkCacheLoad();
     }
@@ -349,7 +364,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
      * @throws Exception If failed.
      */
     public void testLoadCacheWithSqlTx() throws Exception {
-        startTestGrid(false, false, false, true);
+        startTestGrid(false, false, false, true, 512);
 
         checkCacheLoadWithSql();
     }
@@ -358,7 +373,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
      * @throws Exception If failed.
      */
     public void testLoadCachePrimitiveKeys() throws Exception {
-        startTestGrid(true, false, false, false);
+        startTestGrid(true, false, false, false, 512);
 
         checkCacheLoad();
     }
@@ -367,7 +382,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
      * @throws Exception If failed.
      */
     public void testLoadCachePrimitiveKeysTx() throws Exception {
-        startTestGrid(true, false, false, true);
+        startTestGrid(true, false, false, true, 512);
 
         checkCacheLoad();
     }
@@ -448,7 +463,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
      * @throws Exception If failed.
      */
     public void testPutRemoveBuiltIn() throws Exception {
-        startTestGrid(true, false, false, false);
+        startTestGrid(true, false, false, false, 512);
 
         checkPutRemove();
     }
@@ -457,7 +472,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
      * @throws Exception If failed.
      */
     public void testPutRemove() throws Exception {
-        startTestGrid(false, false, false, false);
+        startTestGrid(false, false, false, false, 512);
 
         checkPutRemove();
     }
@@ -466,7 +481,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
      * @throws Exception If failed.
      */
     public void testPutRemoveTxBuiltIn() throws Exception {
-        startTestGrid(true, false, false, true);
+        startTestGrid(true, false, false, true, 512);
 
         checkPutRemove();
     }
@@ -475,7 +490,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
      * @throws Exception If failed.
      */
     public void testPutRemoveTx() throws Exception {
-        startTestGrid(false, false, false, true);
+        startTestGrid(false, false, false, true, 512);
 
         checkPutRemove();
     }
@@ -484,7 +499,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
      * @throws Exception If failed.
      */
     public void testLoadNotRegisteredType() throws Exception {
-        startTestGrid(false, false, false, false);
+        startTestGrid(false, false, false, false, 512);
 
         IgniteCache<Object, Object> c1 = grid().cache(CACHE_NAME);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/c188c3c4/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerSelfTest.java
index 14c743c..b6d6fe1 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerSelfTest.java
@@ -33,7 +33,7 @@ public class CacheJdbcPojoStoreBinaryMarshallerSelfTest extends CacheJdbcPojoSto
      * @throws Exception If failed.
      */
     public void testLoadCacheNoKeyClasses() throws Exception {
-        startTestGrid(false, true, false, false);
+        startTestGrid(false, true, false, false, 512);
 
         checkCacheLoad();
     }
@@ -42,7 +42,7 @@ public class CacheJdbcPojoStoreBinaryMarshallerSelfTest extends CacheJdbcPojoSto
      * @throws Exception If failed.
      */
     public void testLoadCacheNoKeyClassesTx() throws Exception {
-        startTestGrid(false, true, false, true);
+        startTestGrid(false, true, false, true, 512);
 
         checkCacheLoad();
     }
@@ -51,7 +51,7 @@ public class CacheJdbcPojoStoreBinaryMarshallerSelfTest extends CacheJdbcPojoSto
      * @throws Exception If failed.
      */
     public void testLoadCacheNoValueClasses() throws Exception {
-        startTestGrid(false, false, true, false);
+        startTestGrid(false, false, true, false, 512);
 
         checkCacheLoad();
     }
@@ -60,7 +60,7 @@ public class CacheJdbcPojoStoreBinaryMarshallerSelfTest extends CacheJdbcPojoSto
      * @throws Exception If failed.
      */
     public void testLoadCacheNoValueClassesTx() throws Exception {
-        startTestGrid(false, false, true, true);
+        startTestGrid(false, false, true, true, 512);
 
         checkCacheLoad();
     }
@@ -69,7 +69,7 @@ public class CacheJdbcPojoStoreBinaryMarshallerSelfTest extends CacheJdbcPojoSto
      * @throws Exception If failed.
      */
     public void testLoadCacheNoKeyAndValueClasses() throws Exception {
-        startTestGrid(false, true, true, false);
+        startTestGrid(false, true, true, false, 512);
 
         checkCacheLoad();
     }
@@ -78,7 +78,7 @@ public class CacheJdbcPojoStoreBinaryMarshallerSelfTest extends CacheJdbcPojoSto
      * @throws Exception If failed.
      */
     public void testLoadCacheNoKeyAndValueClassesTx() throws Exception {
-        startTestGrid(false, true, true, true);
+        startTestGrid(false, true, true, true, 512);
 
         checkCacheLoad();
     }