You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2015/10/17 17:53:43 UTC
[1/2] ignite git commit: ignite-1698 SqlFieldsQuery works incorrectly
in case of topology changes - Fixes #162.
Repository: ignite
Updated Branches:
refs/heads/master 02b59e433 -> bc6bf5fcd
ignite-1698 SqlFieldsQuery works incorrectly in case of topology changes - Fixes #162.
Signed-off-by: S.Vladykin <sv...@gridgain.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7d3621b6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7d3621b6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7d3621b6
Branch: refs/heads/master
Commit: 7d3621b6907ca4fadae6134593e6a67dd389ff54
Parents: 02b59e4
Author: agura <ag...@gridgain.com>
Authored: Sat Oct 17 18:22:55 2015 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Sat Oct 17 18:22:55 2015 +0300
----------------------------------------------------------------------
.../cache/SqlFieldsQuerySelfTest.java | 166 +++++++++++++++++++
1 file changed, 166 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7d3621b6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
new file mode 100644
index 0000000..7b1c87c
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
@@ -0,0 +1,166 @@
+/*
+ * 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.Collections;
+import java.util.List;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class SqlFieldsQuerySelfTest extends GridCommonAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setLocalHost("127.0.0.1");
+
+ cfg.setPeerClassLoadingEnabled(true);
+
+ TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+ ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));
+
+ TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+ discoSpi.setIpFinder(ipFinder);
+
+ cfg.setDiscoverySpi(discoSpi);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If error.
+ */
+ public void testSqlFieldsQuery() throws Exception {
+ startGrids(2);
+
+ createAndFillCache();
+
+ executeQuery();
+ }
+
+ /**
+ * @throws Exception If error.
+ */
+ public void testSqlFieldsQueryWithTopologyChanges() throws Exception {
+ startGrid(0);
+
+ createAndFillCache();
+
+ startGrid(1);
+
+ executeQuery();
+ }
+
+ /**
+ *
+ */
+ private void executeQuery() {
+ IgniteCache<?, ?> cache = grid(1).cache("person");
+
+ SqlFieldsQuery qry = new SqlFieldsQuery("select name, age from person where age > 10");
+
+ QueryCursor<List<?>> qryCursor = cache.query(qry);
+
+ assertEquals(2, qryCursor.getAll().size());
+ }
+
+
+ /**
+ *
+ */
+ private IgniteCache<Integer, Person> createAndFillCache() {
+ CacheConfiguration<Integer, Person> cacheConf = new CacheConfiguration<>();
+
+ cacheConf.setIndexedTypes(Integer.class, Person.class);
+
+ cacheConf.setName("person");
+
+ IgniteCache<Integer, Person> cache = grid(0).createCache(cacheConf);
+
+ cache.put(1, new Person("sun", 100));
+ cache.put(2, new Person("moon", 50));
+
+ return cache;
+ }
+
+ /**
+ *
+ */
+ public static class Person implements Serializable {
+ /** Name. */
+ @QuerySqlField
+ private String name;
+
+ /** Age. */
+ @QuerySqlField
+ private int age;
+
+ /**
+ * @param name Name.
+ * @param age Age.
+ */
+ public Person(String name, int age) {
+ this.name = name;
+ this.age = age;
+ }
+
+ /**
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name Name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ *
+ */
+ public int getAge() {
+ return age;
+ }
+
+ /**
+ * @param age Age.
+ */
+ public void setAge(int age) {
+ this.age = age;
+ }
+ }
+}
[2/2] ignite git commit: ignite-1698 - test
Posted by se...@apache.org.
ignite-1698 - test
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bc6bf5fc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bc6bf5fc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bc6bf5fc
Branch: refs/heads/master
Commit: bc6bf5fcd2c6fd996c3f3d2b1731afed26338091
Parents: 7d3621b
Author: S.Vladykin <sv...@gridgain.com>
Authored: Sat Oct 17 18:53:16 2015 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Sat Oct 17 18:53:16 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java | 4 ++++
.../apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java | 2 ++
2 files changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/bc6bf5fc/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
index 7b1c87c..a8c8388 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
@@ -21,6 +21,7 @@ import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
@@ -102,6 +103,9 @@ public class SqlFieldsQuerySelfTest extends GridCommonAbstractTest {
private IgniteCache<Integer, Person> createAndFillCache() {
CacheConfiguration<Integer, Person> cacheConf = new CacheConfiguration<>();
+ cacheConf.setCacheMode(CacheMode.PARTITIONED);
+ cacheConf.setBackups(0);
+
cacheConf.setIndexedTypes(Integer.class, Person.class);
cacheConf.setName("person");
http://git-wip-us.apache.org/repos/asf/ignite/blob/bc6bf5fc/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index fe54b63..6cb1a52 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -45,6 +45,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheQueryMultiThreaded
import org.apache.ignite.internal.processors.cache.IgniteCacheQueryOffheapEvictsMultiThreadedSelfTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheQueryOffheapMultiThreadedSelfTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheSqlQueryMultiThreadedSelfTest;
+import org.apache.ignite.internal.processors.cache.SqlFieldsQuerySelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicFieldsQuerySelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledFieldsQuerySelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledQuerySelfTest;
@@ -137,6 +138,7 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
suite.addTestSuite(CacheScanPartitionQueryFallbackSelfTest.class);
// Fields queries.
+ suite.addTestSuite(SqlFieldsQuerySelfTest.class);
suite.addTestSuite(IgniteCacheLocalFieldsQuerySelfTest.class);
suite.addTestSuite(IgniteCacheReplicatedFieldsQuerySelfTest.class);
suite.addTestSuite(IgniteCacheReplicatedFieldsQueryP2PEnabledSelfTest.class);