ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [40/45] ignite git commit: ignite-1232
Date Wed, 20 Jul 2016 09:29:51 GMT
ignite-1232


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

Branch: refs/heads/ignite-1232-1
Commit: 7677cde9ddc036c08522a476318d5c164cbcdb06
Parents: 53e1a79
Author: sboikov <sboikov@gridgain.com>
Authored: Wed Jul 20 10:50:08 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Wed Jul 20 10:55:40 2016 +0300

----------------------------------------------------------------------
 .../query/h2/twostep/GridMapQueryExecutor.java  |   4 +-
 ...QueryNodeRestartDistributedJoinSelfTest.java | 118 ++++++++++++++++---
 2 files changed, 103 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7677cde9/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
index 7d85ddc..90776e3 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
@@ -552,11 +552,13 @@ public class GridMapQueryExecutor {
                 // Run queries.
                 int i = 0;
 
+                boolean evt = ctx.event().isRecordable(EVT_CACHE_QUERY_EXECUTED);
+
                 for (GridCacheSqlQuery qry : qrys) {
                     ResultSet rs = h2.executeSqlQueryWithTimer(mainCctx.name(), conn, qry.query(),
                         F.asList(qry.parameters()), true);
 
-                    if (ctx.event().isRecordable(EVT_CACHE_QUERY_EXECUTED)) {
+                    if (evt) {
                         ctx.event().record(new CacheQueryExecutedEvent<>(
                             node,
                             "SQL query executed.",

http://git-wip-us.apache.org/repos/asf/ignite/blob/7677cde9/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartDistributedJoinSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartDistributedJoinSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartDistributedJoinSelfTest.java
index de00a2b..0e6806f 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartDistributedJoinSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartDistributedJoinSelfTest.java
@@ -58,12 +58,24 @@ public class IgniteCacheQueryNodeRestartDistributedJoinSelfTest extends
GridComm
         "group by co._key order by cnt desc, co._key";
 
     /** */
+    private static final String QRY_0_BROADCAST = "select co._key, count(*) cnt\n" +
+        "from \"co\".Company co, \"pr\".Product pr, \"pu\".Purchase pu, \"pe\".Person pe
\n" +
+        "where pe._key = pu.personId and pu.productId = pr._key and pr.companyId = co._key
\n" +
+        "group by co._key order by cnt desc, co._key";
+
+    /** */
     private static final String QRY_1 = "select pr._key, co._key\n" +
         "from \"pr\".Product pr, \"co\".Company co\n" +
         "where pr.companyId = co._key\n" +
         "order by co._key, pr._key ";
 
     /** */
+    private static final String QRY_1_BROADCAST = "select pr._key, co._key\n" +
+        "from \"co\".Company co, \"pr\".Product pr \n" +
+        "where pr.companyId = co._key\n" +
+        "order by co._key, pr._key ";
+
+    /** */
     private static final int GRID_CNT = 6;
 
     /** */
@@ -145,6 +157,15 @@ public class IgniteCacheQueryNodeRestartDistributedJoinSelfTest extends
GridComm
         return c;
     }
 
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        startGridsMultiThreaded(GRID_CNT);
+
+        fillCaches();
+    }
+
     /**
      *
      */
@@ -175,36 +196,66 @@ public class IgniteCacheQueryNodeRestartDistributedJoinSelfTest extends
GridComm
             pu.put(i, new Purchase(persId, prodId));
         }
     }
-
     /**
      * @throws Exception If failed.
      */
     public void testRestarts() throws Exception {
+        restarts(false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRestartsBroadcast() throws Exception {
+        restarts(true);
+    }
+
+    /**
+     * @param broadcastQry If {@code true} tests broadcast query.
+     * @throws Exception If failed.
+     */
+    private void restarts(final boolean broadcastQry) throws Exception {
         int duration = 90 * 1000;
         int qryThreadNum = 4;
         int restartThreadsNum = 2; // 4 + 2 = 6 nodes
         final int nodeLifeTime = 4000;
-        final int logFreq = 1;
-
-        startGridsMultiThreaded(GRID_CNT);
+        final int logFreq = 100;
 
         final AtomicIntegerArray locks = new AtomicIntegerArray(GRID_CNT);
 
-        fillCaches();
+        SqlFieldsQuery qry0 ;
+
+        if (broadcastQry)
+            qry0 = new SqlFieldsQuery(QRY_0_BROADCAST).setDistributedJoins(true).setEnforceJoinOrder(true);
+        else
+            qry0 = new SqlFieldsQuery(QRY_0).setDistributedJoins(true);
 
-        X.println("Plan: " + grid(0).cache("pu").query(new SqlFieldsQuery("explain " + QRY_0)
-            .setDistributedJoins(true)).getAll());
+        String plan = queryPlan(grid(0).cache("pu"), qry0);
 
-        final List<List<?>> pRes = grid(0).cache("pu").query(new SqlFieldsQuery(QRY_0)
-            .setDistributedJoins(true)).getAll();
+        X.println("Plan1: " + plan);
+
+        assertEquals(broadcastQry, plan.contains("batched:broadcast"));
+
+        final List<List<?>> pRes = grid(0).cache("pu").query(qry0).getAll();
 
         Thread.sleep(3000);
 
-        assertEquals(pRes, grid(0).cache("pu").query(new SqlFieldsQuery(QRY_0)
-            .setDistributedJoins(true)).getAll());
+        assertEquals(pRes, grid(0).cache("pu").query(qry0).getAll());
+
+        final SqlFieldsQuery qry1;
+
+        if (broadcastQry)
+            qry1 = new SqlFieldsQuery(QRY_1_BROADCAST).setDistributedJoins(true).setEnforceJoinOrder(true);
+        else
+            qry1 = new SqlFieldsQuery(QRY_1).setDistributedJoins(true);
+
+        plan = queryPlan(grid(0).cache("co"), qry1);
 
-        final List<List<?>> rRes = grid(0).cache("co").query(new SqlFieldsQuery(QRY_1)
-            .setDistributedJoins(true)).getAll();
+        X.println("Plan2: " + plan);
+
+        assertEquals(broadcastQry, plan.contains("batched:broadcast"));
+
+        final List<List<?>> rRes = grid(0).cache("co").query(qry1).getAll();
 
         assertFalse(pRes.isEmpty());
         assertFalse(rRes.isEmpty());
@@ -225,9 +276,14 @@ public class IgniteCacheQueryNodeRestartDistributedJoinSelfTest extends
GridComm
                     while (!locks.compareAndSet(g, 0, 1));
 
                     if (rnd.nextBoolean()) {
-                        IgniteCache<?,?> cache = grid(g).cache("pu");
+                        IgniteCache<?, ?> cache = grid(g).cache("pu");
+
+                        SqlFieldsQuery qry;
 
-                        SqlFieldsQuery qry = new SqlFieldsQuery(QRY_0).setDistributedJoins(true);
+                        if (broadcastQry)
+                            qry = new SqlFieldsQuery(QRY_0_BROADCAST).setDistributedJoins(true).setEnforceJoinOrder(true);
+                        else
+                            qry = new SqlFieldsQuery(QRY_0).setDistributedJoins(true);
 
                         boolean smallPageSize = rnd.nextBoolean();
 
@@ -261,10 +317,16 @@ public class IgniteCacheQueryNodeRestartDistributedJoinSelfTest extends
GridComm
                         }
                     }
                     else {
-                        IgniteCache<?,?> cache = grid(g).cache("co");
+                        IgniteCache<?, ?> cache = grid(g).cache("co");
+
+                        SqlFieldsQuery qry;
+
+                        if (broadcastQry)
+                            qry = new SqlFieldsQuery(QRY_1_BROADCAST).setDistributedJoins(true).setEnforceJoinOrder(true);
+                        else
+                            qry = new SqlFieldsQuery(QRY_1).setDistributedJoins(true);
 
-                        assertEquals(rRes, cache.query(new SqlFieldsQuery(QRY_1)
-                            .setDistributedJoins(true)).getAll());
+                        assertEquals(rRes, cache.query(qry1).getAll());
                     }
 
                     locks.set(g, 0);
@@ -340,9 +402,13 @@ public class IgniteCacheQueryNodeRestartDistributedJoinSelfTest extends
GridComm
      *
      */
     private static class Person implements Serializable {
+        /** */
         @QuerySqlField(index = true)
         int id;
 
+        /**
+         * @param id ID.
+         */
         Person(int id) {
             this.id = id;
         }
@@ -352,12 +418,18 @@ public class IgniteCacheQueryNodeRestartDistributedJoinSelfTest extends
GridComm
      *
      */
     private static class Purchase implements Serializable {
+        /** */
         @QuerySqlField(index = true)
         int personId;
 
+        /** */
         @QuerySqlField(index = true)
         int productId;
 
+        /**
+         * @param personId Person ID.
+         * @param productId Product ID.
+         */
         Purchase(int personId, int productId) {
             this.personId = personId;
             this.productId = productId;
@@ -368,9 +440,13 @@ public class IgniteCacheQueryNodeRestartDistributedJoinSelfTest extends
GridComm
      *
      */
     private static class Company implements Serializable {
+        /** */
         @QuerySqlField(index = true)
         int id;
 
+        /**
+         * @param id ID.
+         */
         Company(int id) {
             this.id = id;
         }
@@ -380,12 +456,18 @@ public class IgniteCacheQueryNodeRestartDistributedJoinSelfTest extends
GridComm
      *
      */
     private static class Product implements Serializable {
+        /** */
         @QuerySqlField(index = true)
         int id;
 
+        /** */
         @QuerySqlField(index = true)
         int companyId;
 
+        /**
+         * @param id ID.
+         * @param companyId Company ID.
+         */
         Product(int id, int companyId) {
             this.id = id;
             this.companyId = companyId;


Mime
View raw message