ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntikho...@apache.org
Subject ignite git commit: IGNITE-2454 Added tests, fixed.
Date Wed, 27 Jan 2016 13:38:20 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-2454 [created] 0fe1fa69d


IGNITE-2454 Added tests, fixed.


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

Branch: refs/heads/ignite-2454
Commit: 0fe1fa69d370c4a16d3cfd0de792d94d746bdc86
Parents: 4edc7bd
Author: Tikhonov Nikolay <tikhonovnicolay@gmail.com>
Authored: Wed Jan 27 11:32:09 2016 +0300
Committer: Tikhonov Nikolay <tikhonovnicolay@gmail.com>
Committed: Wed Jan 27 11:32:09 2016 +0300

----------------------------------------------------------------------
 .../continuous/CacheContinuousQueryHandler.java |  9 ++++
 ...ontinuousQueryReplicatedOneNodeSelfTest.java | 56 ++++++++++++++++++++
 2 files changed, 65 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0fe1fa69/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index fa54a6b..7e66ad3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -754,6 +754,15 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
             List<CacheContinuousQueryEntry> entries;
 
             synchronized (pendingEvts) {
+                // Received first event.
+                if (curTop == AffinityTopologyVersion.NONE) {
+                    lastFiredEvt = entry.updateCounter();
+
+                    curTop = entry.topologyVersion();
+
+                    return F.asList(entry);
+                }
+
                 if (curTop.compareTo(entry.topologyVersion()) < 0) {
                     if (entry.updateCounter() == 1L && !entry.isBackup()) {
                         entries = new ArrayList<>(pendingEvts.size());

http://git-wip-us.apache.org/repos/asf/ignite/blob/0fe1fa69/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java
index 8152b2a..592999e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java
@@ -38,6 +38,7 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 /**
  * Test for replicated cache with one node.
  */
+@SuppressWarnings("Duplicates")
 public class GridCacheContinuousQueryReplicatedOneNodeSelfTest extends GridCommonAbstractTest
{
     /** IP finder. */
     private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
@@ -80,6 +81,20 @@ public class GridCacheContinuousQueryReplicatedOneNodeSelfTest extends
GridCommo
     /**
      * @throws Exception If failed.
      */
+    public void testLocalOneNode() throws Exception {
+        doTestOneNode(true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDistributedOneNode() throws Exception {
+        doTestOneNode(false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     private void doTest(boolean loc) throws Exception {
         try {
             IgniteCache<String, Integer> cache = startGrid(0).cache(null);
@@ -117,4 +132,45 @@ public class GridCacheContinuousQueryReplicatedOneNodeSelfTest extends
GridCommo
             stopAllGrids();
         }
     }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void doTestOneNode(boolean loc) throws Exception {
+        try {
+            IgniteCache<String, Integer> cache = startGrid(0).cache(null);
+
+            ContinuousQuery<String, Integer> qry = new ContinuousQuery<>();
+
+            final AtomicInteger cnt = new AtomicInteger();
+            final CountDownLatch latch = new CountDownLatch(10);
+
+            for (int i = 0; i < 10; i++)
+                cache.put("key" + i, i);
+
+            cache.clear();
+
+            qry.setLocalListener(new CacheEntryUpdatedListener<String, Integer>() {
+                @Override public void onUpdated(Iterable<CacheEntryEvent<? extends
String, ? extends Integer>> evts)
+                        throws CacheEntryListenerException {
+                    for (CacheEntryEvent<? extends String, ? extends Integer> evt :
evts) {
+                        cnt.incrementAndGet();
+                        latch.countDown();
+                    }
+                }
+            });
+
+            cache.query(qry.setLocal(loc));
+
+            for (int i = 0; i < 10; i++)
+                cache.put("key" + i, i);
+
+            assert latch.await(5000, TimeUnit.MILLISECONDS);
+
+            assertEquals(10, cnt.get());
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
 }


Mime
View raw message