ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject [02/50] [abbrv] incubator-ignite git commit: ignite-sql-tests - test
Date Wed, 18 Mar 2015 03:23:51 GMT
ignite-sql-tests - test


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

Branch: refs/heads/ignite-375
Commit: 334b668085c9393fa6d011dd2878afdf59f742f2
Parents: 9bd2887
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Wed Mar 11 02:53:41 2015 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Wed Mar 11 02:53:41 2015 +0300

----------------------------------------------------------------------
 ...gniteCacheSqlQueryMultiThreadedSelfTest.java | 63 +++++++++++++++++++-
 1 file changed, 62 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/334b6680/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryMultiThreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryMultiThreadedSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryMultiThreadedSelfTest.java
index bc41f55..88183c7 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryMultiThreadedSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryMultiThreadedSelfTest.java
@@ -21,6 +21,9 @@ import org.apache.ignite.*;
 import org.apache.ignite.cache.query.*;
 import org.apache.ignite.cache.query.annotations.*;
 import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.util.*;
+import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
@@ -29,7 +32,9 @@ import org.apache.ignite.testframework.junits.common.*;
 
 import javax.cache.*;
 import java.io.*;
+import java.util.*;
 import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.*;
 import static org.apache.ignite.cache.CacheDistributionMode.*;
@@ -89,6 +94,8 @@ public class IgniteCacheSqlQueryMultiThreadedSelfTest extends GridCommonAbstract
     public void testQuery() throws Exception {
         final IgniteCache<Integer, Person> cache = grid(0).jcache(null);
 
+        cache.clear();
+
         for (int i = 0; i < 2000; i++)
             cache.put(i, new Person(i));
 
@@ -112,11 +119,65 @@ public class IgniteCacheSqlQueryMultiThreadedSelfTest extends GridCommonAbstract
     }
 
     /**
+     * Test put and parallel query.
+     * @throws Exception If failed.
+     */
+    public void testQueryPut() throws Exception {
+        final IgniteCache<Integer, Person> cache = grid(0).jcache(null);
+
+        cache.clear();
+
+        final AtomicBoolean stop = new AtomicBoolean();
+
+        IgniteInternalFuture<?> fut1 = multithreadedAsync(new Callable<Void>()
{
+            @Override public Void call() throws Exception {
+                Random rnd = new GridRandom();
+
+                while (!stop.get()) {
+                    List<List<?>> res = cache.queryFields(
+                        new SqlFieldsQuery("select avg(age) from Person where age > 0")).getAll();
+
+                    assertEquals(1, res.size());
+
+                    if (res.get(0).get(0) == null)
+                        continue;
+
+                    int avgAge = ((Number)res.get(0).get(0)).intValue();
+
+                    if (rnd.nextInt(300) == 0)
+                        X.println("__ " + avgAge);
+                }
+
+                return null;
+            }
+        }, 20);
+
+        IgniteInternalFuture<?> fut2 = multithreadedAsync(new Callable<Void>()
{
+            @Override public Void call() throws Exception {
+                Random rnd = new GridRandom();
+                Random age = new GridRandom();
+
+                while (!stop.get())
+                    cache.put(rnd.nextInt(2000), new Person(age.nextInt(3000) - 1000));
+
+                return null;
+            }
+        }, 20);
+
+        Thread.sleep(30 * 1000);
+
+        stop.set(true);
+
+        fut2.get(10 * 1000);
+        fut1.get(10 * 1000);
+    }
+
+    /**
      *
      */
     private static class Person implements Serializable {
         /** */
-        @QuerySqlField
+        @QuerySqlField(index = true)
         private int age;
 
         /**


Mime
View raw message