IGNITE-2200 - Fixed deployment. - Fixes #367.

Signed-off-by: Alexey Goncharuk <alexey.goncha...@gmail.com>


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

Branch: refs/heads/master
Commit: 16a9e6da2a8baca35d9b95bc0a28995d3f1c5780
Parents: 66b33bc
Author: Alexey Goncharuk <alexey.goncha...@gmail.com>
Authored: Wed Dec 23 14:52:28 2015 +0300
Committer: Alexey Goncharuk <alexey.goncha...@gmail.com>
Committed: Wed Dec 23 14:52:28 2015 +0300

----------------------------------------------------------------------
 .../query/GridCacheDistributedQueryManager.java |   6 +-
 ...iteCacheScanPredicateDeploymentSelfTest.java | 114 +++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite3.java       |   2 +
 .../p2p/CacheDeploymentAlwaysTruePredicate.java |  29 +++++
 4 files changed, 149 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/16a9e6da/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
index 7f63b4c..353fbd3 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
@@ -570,7 +570,8 @@ public class GridCacheDistributedQueryManager<K, V> extends 
GridCacheQueryManage
                 qry.query().subjectId(),
                 qry.query().taskHash(),
                 queryTopologyVersion(),
-                cctx.deploymentEnabled());
+                // Force deployment anyway if scan query is used.
+                cctx.deploymentEnabled() || (qry.query().scanFilter() != null 
&& cctx.gridDeploy().enabled()));
 
             addQueryFuture(req.id(), fut);
 
@@ -616,7 +617,8 @@ public class GridCacheDistributedQueryManager<K, V> extends 
GridCacheQueryManage
                 qry.subjectId(),
                 qry.taskHash(),
                 queryTopologyVersion(),
-                cctx.deploymentEnabled());
+                // Force deployment anyway if scan query is used.
+                cctx.deploymentEnabled() || (qry.scanFilter() != null && 
cctx.gridDeploy().enabled()));
 
             sendRequest(fut, req, nodes);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/16a9e6da/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheScanPredicateDeploymentSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheScanPredicateDeploymentSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheScanPredicateDeploymentSelfTest.java
new file mode 100644
index 0000000..e1fbb0d
--- /dev/null
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheScanPredicateDeploymentSelfTest.java
@@ -0,0 +1,114 @@
+/*
+ * 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.util.List;
+import javax.cache.Cache;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.lang.IgniteBiPredicate;
+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.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ *
+ */
+public class IgniteCacheScanPredicateDeploymentSelfTest extends 
GridCommonAbstractTest {
+    /** IP finder. */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new 
TcpDiscoveryVmIpFinder(true);
+
+    /** Test value. */
+    protected static final String TEST_PREDICATE = 
"org.apache.ignite.tests.p2p.CacheDeploymentAlwaysTruePredicate";
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        if (getTestGridName(3).equals(gridName))
+            cfg.setClassLoader(getExternalClassLoader());
+
+        cfg.setCacheConfiguration(cacheConfiguration());
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(disco);
+
+        cfg.setConnectorConfiguration(null);
+
+        return cfg;
+    }
+
+    /**
+     * @return Cache configuration.
+     * @throws Exception In case of error.
+     */
+    protected CacheConfiguration cacheConfiguration() throws Exception {
+        CacheConfiguration cfg = defaultCacheConfiguration();
+
+        cfg.setCacheMode(PARTITIONED);
+        cfg.setWriteSynchronizationMode(FULL_SYNC);
+        cfg.setRebalanceMode(SYNC);
+        cfg.setAtomicityMode(atomicityMode());
+        cfg.setBackups(1);
+
+        return cfg;
+    }
+
+    protected CacheAtomicityMode atomicityMode() {
+        return TRANSACTIONAL;
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testDeployScanPredicate() throws Exception {
+        startGrids(4);
+
+        awaitPartitionMapExchange();
+
+        try {
+            IgniteCache<Object, Object> cache = grid(3).cache(null);
+
+            // It is important that there are no too many keys.
+            for (int i = 0; i < 1; i++)
+                cache.put(i, i);
+
+            Class predCls = 
grid(3).configuration().getClassLoader().loadClass(TEST_PREDICATE);
+
+            IgniteBiPredicate<Object, Object> pred = 
(IgniteBiPredicate<Object, Object>)predCls.newInstance();
+
+            List<Cache.Entry<Object, Object>> all = cache.query(new 
ScanQuery<>(pred)).getAll();
+
+            assertEquals(1, all.size());
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/16a9e6da/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
index 176ab3f..b86a33d 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
@@ -33,6 +33,7 @@ import 
org.apache.ignite.internal.processors.cache.GridCacheValueConsistencyTran
 import 
org.apache.ignite.internal.processors.cache.GridCacheValueConsistencyTransactionalSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheVersionSelfTest;
 import 
org.apache.ignite.internal.processors.cache.IgniteCacheInterceptorSelfTestSuite;
+import 
org.apache.ignite.internal.processors.cache.IgniteCacheScanPredicateDeploymentSelfTest;
 import 
org.apache.ignite.internal.processors.cache.distributed.CacheAsyncOperationsTest;
 import 
org.apache.ignite.internal.processors.cache.distributed.GridCacheMixedModeSelfTest;
 import 
org.apache.ignite.internal.processors.cache.distributed.IgniteTxGetAfterStopTest;
@@ -127,6 +128,7 @@ public class IgniteCacheTestSuite3 extends TestSuite {
         suite.addTestSuite(GridCacheConditionalDeploymentSelfTest.class);
         
suite.addTestSuite(GridCacheAtomicEntryProcessorDeploymentSelfTest.class);
         
suite.addTestSuite(GridCacheTransactionalEntryProcessorDeploymentSelfTest.class);
+        suite.addTestSuite(IgniteCacheScanPredicateDeploymentSelfTest.class);
 
         suite.addTestSuite(GridCachePutArrayValueSelfTest.class);
         suite.addTestSuite(GridCacheReplicatedUnswapAdvancedSelfTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/16a9e6da/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentAlwaysTruePredicate.java
----------------------------------------------------------------------
diff --git 
a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentAlwaysTruePredicate.java
 
b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentAlwaysTruePredicate.java
new file mode 100644
index 0000000..100ab95
--- /dev/null
+++ 
b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentAlwaysTruePredicate.java
@@ -0,0 +1,29 @@
+/*
+ * 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.tests.p2p;
+
+import org.apache.ignite.lang.IgniteBiPredicate;
+
+/**
+ *
+ */
+public class CacheDeploymentAlwaysTruePredicate implements 
IgniteBiPredicate<Object, Object> {
+    /** */
+    @Override public boolean apply(Object o, Object o2) {
+        return true;
+    }
+}

Reply via email to