ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptupit...@apache.org
Subject [3/5] ignite git commit: ignite-1232 Added possibility to test distributedJoins in IgniteCacheRandomOperationBenchmark
Date Wed, 27 Jul 2016 12:27:17 GMT
ignite-1232 Added possibility to test distributedJoins in IgniteCacheRandomOperationBenchmark


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

Branch: refs/heads/master
Commit: 2f36ae559a83dc9d294de100e11fb4bbf3bae248
Parents: 77781e9
Author: sboikov <sboikov@gridgain.com>
Authored: Wed Jul 27 14:56:31 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Wed Jul 27 14:56:31 2016 +0300

----------------------------------------------------------------------
 modules/yardstick/config/queries.sql            |  1 +
 .../IgniteCacheRandomOperationBenchmark.java    | 71 ++++++++++++++++----
 2 files changed, 60 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2f36ae55/modules/yardstick/config/queries.sql
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/queries.sql b/modules/yardstick/config/queries.sql
index 8271100..7326b31 100644
--- a/modules/yardstick/config/queries.sql
+++ b/modules/yardstick/config/queries.sql
@@ -1,2 +1,3 @@
 SELECT Person.firstName  FROM "query".Person, "orgCache".Organization WHERE Person.orgId
= Organization.id AND lower(Organization.name) = lower('Organization 55')
 SELECT Organization.name  FROM "orgCache".Organization WHERE lower(Organization.name) LIKE
lower('%55%')
+SELECT Person.firstName  FROM "query".Person, "orgCache".Organization WHERE Person.orgId
= Organization.id AND lower(Organization.name) = lower('Organization 55') #distributedJoins

http://git-wip-us.apache.org/repos/asf/ignite/blob/2f36ae55/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java
index e62df45..d37cdca 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java
@@ -61,6 +61,7 @@ import org.apache.ignite.cache.query.SqlQuery;
 import org.apache.ignite.cluster.ClusterGroup;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.lang.IgniteRunnable;
 import org.apache.ignite.resources.IgniteInstanceResource;
@@ -110,7 +111,7 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark
     private Map<String, List<SqlCacheDescriptor>> cacheSqlDescriptors;
 
     /** List of SQL queries. */
-    private List<String> queries;
+    private List<TestQuery> queries;
 
     /** List of allowed cache operations which will be executed. */
     private List<Operation> allowedLoadTestOps;
@@ -237,7 +238,7 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark
                                     throw new IgniteException("Class is unknown for the load
test. Make sure you " +
                                         "specified its full name [clsName=" + queryEntity.getKeyType()
+ ']');
 
-                                cofigureCacheSqlDescriptor(cacheName, queryEntity, valCls);
+                                configureCacheSqlDescriptor(cacheName, queryEntity, valCls);
                             }
                         } catch (ClassNotFoundException e) {
                             BenchmarkUtils.println(e.getMessage());
@@ -307,11 +308,13 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark
      */
     private void loadAllowedOperations() {
         allowedLoadTestOps = new ArrayList<>();
+
         if (args.allowedLoadTestOps().isEmpty())
             Collections.addAll(allowedLoadTestOps, Operation.values());
-        else
+        else {
             for (String opName : args.allowedLoadTestOps())
                 allowedLoadTestOps.add(Operation.valueOf(opName.toUpperCase()));
+        }
     }
 
     /**
@@ -330,7 +333,24 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark
                         if (line.trim().isEmpty())
                             continue;
 
-                        queries.add(line.trim());
+                        boolean distributedJoins = false;
+
+                        int commentIdx = line.lastIndexOf('#');
+
+                        if (commentIdx >= 0) {
+                            if (line.toUpperCase().indexOf("DISTRIBUTEDJOINS", commentIdx)
> 0)
+                                distributedJoins = true;
+
+                            line = line.substring(0, commentIdx);
+                        }
+
+                        line = line.trim();
+
+                        TestQuery qry = new TestQuery(line, distributedJoins);
+
+                        queries.add(qry);
+
+                        BenchmarkUtils.println("Loaded query: " + qry);
                     }
                 }
             }
@@ -343,7 +363,7 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark
      * @param valCls Class of value.
      * @throws ClassNotFoundException If fail.
      */
-    private void cofigureCacheSqlDescriptor(String cacheName, QueryEntity qryEntity, Class
valCls)
+    private void configureCacheSqlDescriptor(String cacheName, QueryEntity qryEntity, Class
valCls)
         throws ClassNotFoundException {
         List<SqlCacheDescriptor> descs = cacheSqlDescriptors.get(cacheName);
 
@@ -883,9 +903,13 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark
                 }
             }
             else {
-                String sql = rendomizeSql();
+                TestQuery qry = queries.get(nextRandom(queries.size()));
+
+                String sql = randomizeSql(qry.sql);
 
                 sq = new SqlFieldsQuery(sql);
+
+                ((SqlFieldsQuery)sq).setDistributedJoins(qry.distributedJoin);
             }
 
             if (sq != null)
@@ -900,14 +924,12 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark
     /**
      * @return SQL string.
      */
-    private String rendomizeSql() {
-        String sql = queries.get(nextRandom(queries.size()));
-
-        int count = StringUtils.countOccurrencesOf(sql, "%s");
+    private String randomizeSql(String sql) {
+        int cnt = StringUtils.countOccurrencesOf(sql, "%s");
 
-        Integer[] sub = new Integer[count];
+        Integer[] sub = new Integer[cnt];
 
-        for (int i=0; i<count; i++)
+        for (int i = 0; i< cnt; i++)
             sub[i] = nextRandom(args.range());
 
         sql = String.format(sql, sub);
@@ -1196,4 +1218,29 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark
             return values()[num];
         }
     }
+
+    /**
+     *
+     */
+    private static class TestQuery {
+        /** */
+        private final String sql;
+
+        /** */
+        private final boolean distributedJoin;
+
+        /**
+          * @param sql SQL.
+         * @param distributedJoin Distributed join flag.
+         */
+        public TestQuery(String sql, boolean distributedJoin) {
+            this.sql = sql;
+            this.distributedJoin = distributedJoin;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(TestQuery.class, this);
+        }
+    }
 }


Mime
View raw message