Repository: ignite
Updated Branches:
  refs/heads/ignite-1232 87464e230 -> 5c2add453


ignite-1232


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

Branch: refs/heads/ignite-1232
Commit: 5c2add453e521b7f3a6a31cf18922ff764e48493
Parents: 87464e2
Author: sboikov <[email protected]>
Authored: Thu Jul 14 16:18:01 2016 +0300
Committer: sboikov <[email protected]>
Committed: Thu Jul 14 17:43:43 2016 +0300

----------------------------------------------------------------------
 .../processors/query/GridQueryProcessor.java    |   7 +-
 .../query/h2/opt/GridH2CollocationModel.java    |  51 +++--
 .../query/h2/opt/GridH2IndexBase.java           |   2 +-
 .../IgniteCacheCrossCacheJoinRandomTest.java    |   4 +-
 ...acheDistributedJoinCollocatedAndNotTest.java |   6 +
 ...acheDistributedJoinCustomAffinityMapper.java | 203 +++++++++++++++++++
 .../query/IgniteSqlSplitterSelfTest.java        |  77 +++++++
 .../ignite/yardstick/IgniteBenchmarkUtils.java  |  35 +++-
 8 files changed, 357 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5c2add45/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 05fd052..3d8120d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -1664,7 +1664,7 @@ public class GridQueryProcessor extends 
GridProcessorAdapter {
             res = clo.apply();
 
             if (res instanceof CacheQueryFuture) {
-                CacheQueryFuture fut = (CacheQueryFuture) res;
+                CacheQueryFuture fut = (CacheQueryFuture)res;
 
                 err = fut.error();
             }
@@ -1676,6 +1676,11 @@ public class GridQueryProcessor extends 
GridProcessorAdapter {
 
             throw (IgniteCheckedException)err;
         }
+        catch (CacheException e) {
+            err = e;
+
+            throw e;
+        }
         catch (Exception e) {
             err = e;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5c2add45/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2CollocationModel.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2CollocationModel.java
 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2CollocationModel.java
index d93cab4..aec5920 100644
--- 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2CollocationModel.java
+++ 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2CollocationModel.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.query.h2.opt;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import javax.cache.CacheException;
 import org.h2.command.dml.Query;
 import org.h2.command.dml.Select;
 import org.h2.command.dml.SelectUnion;
@@ -77,15 +78,19 @@ public final class GridH2CollocationModel {
     /** */
     private Select select;
 
+    /** */
+    private final boolean validate;
+
     /**
      * @param upper Upper.
      * @param filter Filter.
      * @param view This model will be a subquery (or top level query) and must 
contain child filters.
      */
-    private GridH2CollocationModel(GridH2CollocationModel upper, int filter, 
boolean view) {
+    private GridH2CollocationModel(GridH2CollocationModel upper, int filter, 
boolean view, boolean validate) {
         this.upper = upper;
         this.filter = filter;
         this.view = view;
+        this.validate = validate;
     }
 
     /**
@@ -95,9 +100,12 @@ public final class GridH2CollocationModel {
      * @param view This model will be a subquery (or top level query) and must 
contain child filters.
      * @return Created child collocation model.
      */
-    private static GridH2CollocationModel 
createChildModel(GridH2CollocationModel upper, int filter,
-        List<GridH2CollocationModel> unions, boolean view) {
-        GridH2CollocationModel child = new GridH2CollocationModel(upper, 
filter, view);
+    private static GridH2CollocationModel 
createChildModel(GridH2CollocationModel upper,
+        int filter,
+        List<GridH2CollocationModel> unions,
+        boolean view,
+        boolean validate) {
+        GridH2CollocationModel child = new GridH2CollocationModel(upper, 
filter, view, validate);
 
         if (unions != null) {
             // Bind created child to unions.
@@ -198,6 +206,9 @@ public final class GridH2CollocationModel {
 
                 Type t = child.type(true);
 
+                if (child.multiplier == MULTIPLIER_REPLICATED_NOT_LAST)
+                    maxMultiplier = child.multiplier;
+
                 if (t.isPartitioned()) {
                     partitioned = true;
 
@@ -496,13 +507,13 @@ public final class GridH2CollocationModel {
             if (f.getTable().isView()) {
                 if (f.getIndex() == null) {
                     // If we don't have view index yet, then we just creating 
empty model and it must be filled later.
-                    child = createChildModel(this, i, null, true);
+                    child = createChildModel(this, i, null, true, validate);
                 }
                 else
-                    child = buildCollocationModel(this, i, getSubQuery(f), 
null);
+                    child = buildCollocationModel(this, i, getSubQuery(f), 
null, validate);
             }
             else
-                child = createChildModel(this, i, null, false);
+                child = createChildModel(this, i, null, false, validate);
 
             assert child != null;
             assert children[i] == child;
@@ -540,19 +551,19 @@ public final class GridH2CollocationModel {
      * @return Collocation.
      */
     public static GridH2CollocationModel 
buildCollocationModel(GridH2QueryContext qctx, SubQueryInfo info,
-        TableFilter[] filters, int filter) {
+        TableFilter[] filters, int filter, boolean validate) {
         GridH2CollocationModel cm;
 
         if (info != null) {
             // Go up until we reach the root query.
-            cm = buildCollocationModel(qctx, info.getUpper(), 
info.getFilters(), info.getFilter());
+            cm = buildCollocationModel(qctx, info.getUpper(), 
info.getFilters(), info.getFilter(), validate);
         }
         else {
             // We are at the root query.
             cm = qctx.queryCollocationModel();
 
             if (cm == null) {
-                cm = createChildModel(null, -1, null, true);
+                cm = createChildModel(null, -1, null, true, validate);
 
                 qctx.queryCollocationModel(cm);
             }
@@ -581,7 +592,7 @@ public final class GridH2CollocationModel {
 
             // Nothing was found, need to create new child in union.
             if (cm.select != select)
-                cm = createChildModel(cm.upper, cm.filter, unions, true);
+                cm = createChildModel(cm.upper, cm.filter, unions, true, 
validate);
         }
 
         cm.childFilters(filters);
@@ -594,10 +605,14 @@ public final class GridH2CollocationModel {
      * @return {@code true} If the query is collocated.
      */
     public static boolean isCollocated(Query qry) {
-        GridH2CollocationModel mdl = buildCollocationModel(null, -1, qry, 
null);
+        GridH2CollocationModel mdl = buildCollocationModel(null, -1, qry, 
null, true);
 
         Type type = mdl.type(true);
 
+        if (!type.isCollocated() && mdl.multiplier == 
MULTIPLIER_REPLICATED_NOT_LAST)
+            throw new CacheException("Failed to execute query: for distributed 
join, " +
+                "all REPLICATED caches must be at the end of the joined tables 
list.");
+
         return type.isCollocated();
     }
 
@@ -609,15 +624,15 @@ public final class GridH2CollocationModel {
      * @return Built model.
      */
     private static GridH2CollocationModel 
buildCollocationModel(GridH2CollocationModel upper, int filter, Query qry,
-        List<GridH2CollocationModel> unions) {
+        List<GridH2CollocationModel> unions, boolean validate) {
         if (qry.isUnion()) {
             if (unions == null)
                 unions = new ArrayList<>();
 
             SelectUnion union = (SelectUnion)qry;
 
-            GridH2CollocationModel left = buildCollocationModel(upper, filter, 
union.getLeft(), unions);
-            GridH2CollocationModel right = buildCollocationModel(upper, 
filter, union.getRight(), unions);
+            GridH2CollocationModel left = buildCollocationModel(upper, filter, 
union.getLeft(), unions, validate);
+            GridH2CollocationModel right = buildCollocationModel(upper, 
filter, union.getRight(), unions, validate);
 
             assert left != null;
             assert right != null;
@@ -634,7 +649,7 @@ public final class GridH2CollocationModel {
 
         TableFilter[] filters = list.toArray(new TableFilter[list.size()]);
 
-        GridH2CollocationModel cm = createChildModel(upper, filter, unions, 
true);
+        GridH2CollocationModel cm = createChildModel(upper, filter, unions, 
true, validate);
 
         cm.childFilters(filters);
 
@@ -642,9 +657,9 @@ public final class GridH2CollocationModel {
             TableFilter f = filters[i];
 
             if (f.getTable().isView())
-                buildCollocationModel(cm, i, getSubQuery(f), null);
+                buildCollocationModel(cm, i, getSubQuery(f), null, validate);
             else if (f.getTable() instanceof GridH2Table)
-                createChildModel(cm, i, null, false);
+                createChildModel(cm, i, null, false, validate);
         }
 
         return upper != null ? upper : cm;

http://git-wip-us.apache.org/repos/asf/ignite/blob/5c2add45/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
index 3dd23b4..ff3e463 100644
--- 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
+++ 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
@@ -151,7 +151,7 @@ public abstract class GridH2IndexBase extends BaseIndex {
 
         assert filters != null;
 
-        GridH2CollocationModel c = buildCollocationModel(qctx, 
ses.getSubQueryInfo(), filters, filter);
+        GridH2CollocationModel c = buildCollocationModel(qctx, 
ses.getSubQueryInfo(), filters, filter, false);
 
         return c.calculateMultiplier();
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/5c2add45/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCrossCacheJoinRandomTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCrossCacheJoinRandomTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCrossCacheJoinRandomTest.java
index 1c48e41..2fa9f4c 100644
--- 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCrossCacheJoinRandomTest.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCrossCacheJoinRandomTest.java
@@ -213,14 +213,14 @@ public class IgniteCacheCrossCacheJoinRandomTest extends 
AbstractH2CompareQueryT
     /**
      * @throws Exception If failed.
      */
-    public void testJoin4Caches() throws Exception {
+    public void _testJoin4Caches() throws Exception {
         testJoin(4, MODES_1);
     }
 
     /**
      * @throws Exception If failed.
      */
-    public void testJoin5Caches() throws Exception {
+    public void _testJoin5Caches() throws Exception {
         testJoin(5, MODES_2);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5c2add45/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCollocatedAndNotTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCollocatedAndNotTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCollocatedAndNotTest.java
index 9d3d329..725e886 100644
--- 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCollocatedAndNotTest.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCollocatedAndNotTest.java
@@ -23,6 +23,7 @@ import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheKeyConfiguration;
 import org.apache.ignite.cache.QueryEntity;
 import org.apache.ignite.cache.QueryIndex;
 import org.apache.ignite.cache.affinity.Affinity;
@@ -32,6 +33,7 @@ import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.GridBinaryAffinityKeySelfTest;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -66,6 +68,10 @@ public class IgniteCacheDistributedJoinCollocatedAndNotTest 
extends GridCommonAb
     @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
+        CacheKeyConfiguration keyCfg = new 
CacheKeyConfiguration(PersonKey.class.getName(), "affKey");
+
+        cfg.setCacheKeyConfiguration(keyCfg);
+
         TcpDiscoverySpi spi = ((TcpDiscoverySpi)cfg.getDiscoverySpi());
 
         spi.setIpFinder(IP_FINDER);

http://git-wip-us.apache.org/repos/asf/ignite/blob/5c2add45/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCustomAffinityMapper.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCustomAffinityMapper.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCustomAffinityMapper.java
new file mode 100644
index 0000000..c50b531
--- /dev/null
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCustomAffinityMapper.java
@@ -0,0 +1,203 @@
+/*
+ * 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.internal.processors.cache;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.cache.affinity.AffinityKeyMapper;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ *
+ */
+public class IgniteCacheDistributedJoinCustomAffinityMapper extends 
GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new 
TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private static final String PERSON_CACHE = "person";
+
+    /** */
+    private static final String ORG_CACHE = "org";
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+        List<CacheConfiguration> ccfgs = new ArrayList<>();
+
+        {
+            CacheConfiguration ccfg = configuration(PERSON_CACHE);
+
+            QueryEntity entity = new QueryEntity();
+            entity.setKeyType(Integer.class.getName());
+            entity.setValueType(Person.class.getName());
+            entity.addQueryField("orgId", Integer.class.getName(), null);
+            entity.addQueryField("orgName", String.class.getName(), null);
+            entity.setIndexes(F.asList(new QueryIndex("orgId"), new 
QueryIndex("orgName")));
+
+            ccfg.setQueryEntities(F.asList(entity));
+
+            ccfgs.add(ccfg);
+        }
+
+        {
+            CacheConfiguration ccfg = configuration(ORG_CACHE);
+
+            QueryEntity entity = new QueryEntity();
+            entity.setKeyType(Integer.class.getName());
+            entity.setValueType(Organization.class.getName());
+            entity.addQueryField("name", String.class.getName(), null);
+            entity.setIndexes(F.asList(new QueryIndex("name")));
+
+            ccfg.setQueryEntities(F.asList(entity));
+
+            ccfgs.add(ccfg);
+        }
+
+        cfg.setCacheConfiguration(ccfgs.toArray(new 
CacheConfiguration[ccfgs.size()]));
+
+        return cfg;
+    }
+
+    /**
+     * @param name Cache name.
+     * @return Cache configuration.
+     */
+    private CacheConfiguration configuration(String name) {
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        ccfg.setName(name);
+        ccfg.setWriteSynchronizationMode(FULL_SYNC);
+        ccfg.setAtomicWriteOrderMode(PRIMARY);
+        ccfg.setAtomicityMode(ATOMIC);
+        ccfg.setBackups(0);
+
+        return ccfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        startGridsMultiThreaded(3);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+
+        super.afterTestsStopped();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testJoinCustomAffinityMapper() throws Exception {
+        Ignite ignite = ignite(0);
+
+        IgniteCache<Object, Object> cache = ignite.cache(PERSON_CACHE);
+
+        SqlFieldsQuery qry = new SqlFieldsQuery("select o.name, p._key, 
p.orgName " +
+            "from \"org\".Organization o, \"person\".Person p");
+
+        qry.setDistributedJoins(true);
+
+        log.info("Plan: " + queryPlan(cache, qry));
+
+        cache.query(qry).getAll();
+    }
+
+    /**
+     *
+     */
+    static class TestMapper implements AffinityKeyMapper {
+        /** {@inheritDoc} */
+        @Override public Object affinityKey(Object key) {
+            return key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void reset() {
+            // No-op.
+        }
+    }
+    /**
+     *
+     */
+    private static class Person implements Serializable {
+        /** */
+        int orgId;
+
+        /** */
+        String orgName;
+
+        /**
+         * @param orgId Organization ID.
+         * @param orgName Organization name.
+         */
+        public Person(int orgId, String orgName) {
+            this.orgId = orgId;
+            this.orgName = orgName;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(Person.class, this);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class Organization implements Serializable {
+        /** */
+        String name;
+
+        /**
+         * @param name Name.
+         */
+        public Organization(String name) {
+            this.name = name;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(Organization.class, this);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5c2add45/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
index f018ff8..53f4522 100644
--- 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
@@ -24,9 +24,12 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Random;
+import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicLong;
+import javax.cache.CacheException;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheKeyConfiguration;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.cache.affinity.AffinityKeyMapped;
@@ -40,6 +43,7 @@ import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.springframework.util.StringUtils;
 
@@ -55,6 +59,10 @@ public class IgniteSqlSplitterSelfTest extends 
GridCommonAbstractTest {
     @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
+        CacheKeyConfiguration keyCfg = new 
CacheKeyConfiguration(TestKey.class.getName(), "affKey");
+
+        cfg.setCacheKeyConfiguration(keyCfg);
+
         cfg.setPeerClassLoadingEnabled(false);
 
         TcpDiscoverySpi disco = new TcpDiscoverySpi();
@@ -634,6 +642,75 @@ public class IgniteSqlSplitterSelfTest extends 
GridCommonAbstractTest {
                 ignite(0).destroyCache(cache.getName());
         }
     }
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDistributedJoinsEnforceReplicatedNotLast() throws 
Exception {
+        List<IgniteCache<Object, Object>> caches = new ArrayList<>();
+
+        IgniteCache<Object, Object> persPart =
+            ignite(0).createCache(cacheConfig("persPart", true, Integer.class, 
Person2.class));
+        caches.add(persPart);
+
+        IgniteCache<Object, Object> persPartAff =
+            ignite(0).createCache(cacheConfig("persPartAff", true, 
TestKey.class, Person2.class));
+        caches.add(persPartAff);
+
+        IgniteCache<Object, Object> orgRepl =
+            ignite(0).createCache(cacheConfig("orgRepl", false, Integer.class, 
Organization.class));
+        caches.add(orgRepl);
+
+        try {
+            checkQueryFails(persPart, "select p1._key k1, p2._key k2, o._key 
k3 " +
+                "from \"orgRepl\".Organization o, \"persPartAff\".Person2 p1, 
\"persPart\".Person2 p2 " +
+                "where p1._key=p2._key and p2.orgId = o._key", true);
+
+            checkQueryFails(persPart, "select p1._key k1, p2._key k2, o._key 
k3 " +
+                "from \"persPartAff\".Person2 p1, \"orgRepl\".Organization o, 
\"persPart\".Person2 p2 " +
+                "where p1._key=p2._key and p2.orgId = o._key", true);
+
+            checkQueryFails(persPart, "select p1._key k1, p2._key k2, o._key 
k3 " +
+                "from \"persPartAff\".Person2 p1, (select * from 
\"orgRepl\".Organization) o, \"persPart\".Person2 p2 " +
+                "where p1._key=p2._key and p2.orgId = o._key", true);
+
+            checkQueryPlanContains(persPart,
+                true,
+                0,
+                "select p._key k1, o._key k2 from \"orgRepl\".Organization o, 
\"persPart\".Person2 p");
+
+            checkQueryPlanContains(persPart,
+                true,
+                0,
+                "select p._key k1, o._key k2 from \"orgRepl\".Organization o, 
\"persPart\".Person2 p union " +
+                    "select p._key k1, o._key k2 from \"persPart\".Person2 p, 
\"orgRepl\".Organization o");
+        }
+        finally {
+            for (IgniteCache<Object, Object> cache : caches)
+                ignite(0).destroyCache(cache.getName());
+        }
+    }
+
+    /**
+     * @param cache Cache.
+     * @param sql SQL.
+     * @param enforceJoinOrder Enforce join order flag.
+     */
+    private void checkQueryFails(final IgniteCache<Object, Object> cache,
+        String sql,
+        boolean enforceJoinOrder) {
+        final SqlFieldsQuery qry = new SqlFieldsQuery(sql);
+
+        qry.setDistributedJoins(true);
+        qry.setEnforceJoinOrder(enforceJoinOrder);
+
+        GridTestUtils.assertThrows(log, new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                cache.query(qry);
+
+                return null;
+            }
+        }, CacheException.class, null);
+    }
 
     /**
      * @param cache Query cache.

http://git-wip-us.apache.org/repos/asf/ignite/blob/5c2add45/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkUtils.java
----------------------------------------------------------------------
diff --git 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkUtils.java
 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkUtils.java
index c44e940..af060d4 100644
--- 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkUtils.java
+++ 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkUtils.java
@@ -26,8 +26,10 @@ import org.apache.ignite.transactions.TransactionConcurrency;
 import org.apache.ignite.transactions.TransactionIsolation;
 import org.apache.ignite.transactions.TransactionOptimisticException;
 import org.apache.ignite.transactions.TransactionRollbackException;
+import org.apache.ignite.yardstick.cache.IgniteSqlQueryBenchmark;
 import 
org.apache.ignite.yardstick.cache.IgniteSqlQueryDistributedJoinBenchmark;
 import org.yardstickframework.BenchmarkDriverStartUp;
+import org.yardstickframework.BenchmarkServerStartUp;
 
 /**
  * Utils.
@@ -75,6 +77,26 @@ public class IgniteBenchmarkUtils {
         }
     }
 
+//    /**
+//     * Starts driver for quick benchmarks testing.
+//     *
+//     * @param args Command line arguments.
+//     * @throws Exception If failed.
+//     */
+//    public static void main(String[] args) throws Exception {
+//        String[] args0 = {
+//            "-t", "1",
+//            "-w", "5",
+//            "-d", "5",
+//            "-dn", 
IgniteSqlQueryDistributedJoinBenchmark.class.getSimpleName(),
+//            "-r", "100",
+//            "-sn", "IgniteNode",
+//            "-bcj",
+//            "-cfg", "modules/yardstick/config/ignite-localhost-config.xml"};
+//
+//        BenchmarkDriverStartUp.main(args0);
+//    }
+
     /**
      * Starts driver for quick benchmarks testing.
      *
@@ -83,13 +105,14 @@ public class IgniteBenchmarkUtils {
      */
     public static void main(String[] args) throws Exception {
         String[] args0 = {
-            "-t", "1",
-            "-w", "5",
-            "-d", "5",
-            "-dn", 
IgniteSqlQueryDistributedJoinBenchmark.class.getSimpleName(),
-            "-r", "100",
+            "-t", "15",
+            "-w", "30",
+            "-d", "60",
+            "-cl",
+            "-pr", "ThroughputLatencyProbe",
+            "-dn", IgniteSqlQueryBenchmark.class.getSimpleName(),
+            "-r", "100000",
             "-sn", "IgniteNode",
-            "-bcj",
             "-cfg", "modules/yardstick/config/ignite-localhost-config.xml"};
 
         BenchmarkDriverStartUp.main(args0);

Reply via email to