ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: ignite-1811 Optimized cache 'get' on affinity node.
Date Wed, 13 Jan 2016 11:13:43 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1811 e817363bf -> 71165dc7b


ignite-1811 Optimized cache 'get' on affinity node.


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

Branch: refs/heads/ignite-1811
Commit: 71165dc7bbd50260f98685e0314247a4480ea2ef
Parents: e817363
Author: sboikov <sboikov@gridgain.com>
Authored: Wed Jan 13 12:15:13 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Wed Jan 13 13:54:15 2016 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheContext.java      |   2 +-
 .../dht/GridClientPartitionTopology.java        |   2 +
 .../dht/GridPartitionedGetFuture.java           |   9 +-
 .../dht/GridPartitionedSingleGetFuture.java     |   3 +
 .../distributed/near/GridNearGetFuture.java     |   6 +-
 ...eDynamicCacheStartNoExchangeTimeoutTest.java |   9 +-
 .../distributed/IgniteCacheGetRestartTest.java  | 129 +++++++++++++++++++
 .../IgniteCacheSingleGetMessageTest.java        |  20 ++-
 8 files changed, 169 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/71165dc7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index 31252e1..09de5ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -1979,7 +1979,7 @@ public class GridCacheContext<K, V> implements Externalizable
{
      * @return {@code True} if partition is available locally.
      */
     private boolean hasPartition(int part, List<ClusterNode> affNodes, AffinityTopologyVersion
topVer) {
-        return topology().rebalanceFinished(topVer) && (isReplicated() || affNodes.contains(locNode))
+        return (topology().rebalanceFinished(topVer) && (isReplicated() || affNodes.contains(locNode)))
             || partitionOwned(part);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/71165dc7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
index 8aef5ad..f0c4c90 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
@@ -882,6 +882,8 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology
{
 
     /** {@inheritDoc} */
     @Override public boolean rebalanceFinished(AffinityTopologyVersion topVer) {
+        assert false;
+
         return false;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/71165dc7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
index 982c6d3..be50384 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
@@ -507,7 +507,14 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
                 boolean topStable = cctx.isReplicated() || topVer.equals(cctx.topology().topologyVersion());
 
                 // Entry not found, do not continue search if topology did not change and
there is no store.
-                return !cctx.store().configured() && (topStable || partitionOwned(part));
+                if (!cctx.store().configured() && (topStable || partitionOwned(part)))
{
+                    if (!skipVals && cctx.config().isStatisticsEnabled())
+                        cache.metrics0().onRead(false);
+
+                    return true;
+                }
+
+                return false;
             }
             catch (GridCacheEntryRemovedException ignored) {
                 // No-op, will retry.

http://git-wip-us.apache.org/repos/asf/ignite/blob/71165dc7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
index ed5cf92..0731eee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
@@ -445,6 +445,9 @@ public class GridPartitionedSingleGetFuture extends GridFutureAdapter<Object>
im
 
                 // Entry not found, complete future with null result if topology did not
change and there is no store.
                 if (!cctx.store().configured() && (topStable || partitionOwned(part)))
{
+                    if (!skipVals && cctx.config().isStatisticsEnabled())
+                        colocated.metrics0().onRead(false);
+
                     if (skipVals)
                         setSkipValueResult(false, null);
                     else

http://git-wip-us.apache.org/repos/asf/ignite/blob/71165dc7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
index 0cb130a..4802539 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
@@ -476,11 +476,9 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
                     ClusterNode affNode = affinityNode(affNodes);
 
                     if (affNode == null) {
-                        if (affNode == null) {
-                            onDone(serverNotFoundError(topVer));
+                        onDone(serverNotFoundError(topVer));
 
-                            return saved;
-                        }
+                        return saved;
                     }
 
                     if (cctx.cache().configuration().isStatisticsEnabled() && !skipVals
&& !affNode.isLocal())

http://git-wip-us.apache.org/repos/asf/ignite/blob/71165dc7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartNoExchangeTimeoutTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartNoExchangeTimeoutTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartNoExchangeTimeoutTest.java
index 9acc4b5..7b1b6f1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartNoExchangeTimeoutTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartNoExchangeTimeoutTest.java
@@ -46,6 +46,7 @@ import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
 import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
 
 /**
  *
@@ -325,7 +326,7 @@ public class IgniteDynamicCacheStartNoExchangeTimeoutTest extends GridCommonAbst
             for (int i = 0; i < 100; i++) {
                 cache.put(key, key);
 
-                assertEquals(key, cache.get(key));
+                assertEquals("Invalid value for node: " + ignite.name(), key, cache.get(key));
 
                 key++;
             }
@@ -344,6 +345,7 @@ public class IgniteDynamicCacheStartNoExchangeTimeoutTest extends GridCommonAbst
             ccfg.setName("cache-1");
             ccfg.setAtomicityMode(ATOMIC);
             ccfg.setBackups(0);
+            ccfg.setWriteSynchronizationMode(FULL_SYNC);
 
             res.add(ccfg);
         }
@@ -354,6 +356,7 @@ public class IgniteDynamicCacheStartNoExchangeTimeoutTest extends GridCommonAbst
             ccfg.setName("cache-2");
             ccfg.setAtomicityMode(ATOMIC);
             ccfg.setBackups(1);
+            ccfg.setWriteSynchronizationMode(FULL_SYNC);
 
             res.add(ccfg);
         }
@@ -365,6 +368,7 @@ public class IgniteDynamicCacheStartNoExchangeTimeoutTest extends GridCommonAbst
             ccfg.setAtomicityMode(ATOMIC);
             ccfg.setBackups(1);
             ccfg.setAffinity(new FairAffinityFunction());
+            ccfg.setWriteSynchronizationMode(FULL_SYNC);
 
             res.add(ccfg);
         }
@@ -375,6 +379,7 @@ public class IgniteDynamicCacheStartNoExchangeTimeoutTest extends GridCommonAbst
             ccfg.setName("cache-4");
             ccfg.setAtomicityMode(TRANSACTIONAL);
             ccfg.setBackups(0);
+            ccfg.setWriteSynchronizationMode(FULL_SYNC);
 
             res.add(ccfg);
         }
@@ -385,6 +390,7 @@ public class IgniteDynamicCacheStartNoExchangeTimeoutTest extends GridCommonAbst
             ccfg.setName("cache-5");
             ccfg.setAtomicityMode(TRANSACTIONAL);
             ccfg.setBackups(1);
+            ccfg.setWriteSynchronizationMode(FULL_SYNC);
 
             res.add(ccfg);
         }
@@ -396,6 +402,7 @@ public class IgniteDynamicCacheStartNoExchangeTimeoutTest extends GridCommonAbst
             ccfg.setAtomicityMode(TRANSACTIONAL);
             ccfg.setBackups(1);
             ccfg.setAffinity(new FairAffinityFunction());
+            ccfg.setWriteSynchronizationMode(FULL_SYNC);
 
             res.add(ccfg);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/71165dc7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java
new file mode 100644
index 0000000..82e534b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java
@@ -0,0 +1,129 @@
+/*
+ * 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.distributed;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+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.CacheRebalanceMode.*;
+
+/**
+ *
+ */
+public class IgniteCacheGetRestartTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private static final long TEST_TIME = 10_000;
+
+    /** */
+    private static final int SRVS = 3;
+
+    /** */
+    private static final int CLIENTS = 1;
+
+    /** */
+    private static final int KEYS = 100_000;
+
+    /** */
+    private ThreadLocal<Boolean> client = new ThreadLocal<>();
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+        Boolean clientMode = client.get();
+
+        if (clientMode != null) {
+            cfg.setClientMode(clientMode);
+
+            client.remove();
+        }
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        startGrids(SRVS);
+
+        for (int i = 0; i < CLIENTS; i++) {
+            client.set(true);
+
+            Ignite client = startGrid(SRVS);
+
+            assertTrue(client.configuration().isClientMode());
+        }
+    }
+
+    /**
+     * @param ccfg Cache configuration.
+     * @param restartCnt Number of nodes to restart.
+     * @throws Exception If failed.
+     */
+    private void checkRestart(CacheConfiguration ccfg, int restartCnt) throws Exception {
+        ignite(0).createCache(ccfg);
+
+        if (ccfg.getNearConfiguration() != null)
+            ignite(SRVS).createNearCache(ccfg.getName(), new NearCacheConfiguration<>());
+
+        try (IgniteDataStreamer<Object, Object> streamer = ignite(0).dataStreamer(ccfg.getName()))
{
+            for (int i = 0; i < KEYS; i++)
+                streamer.addData(i, i);
+        }
+
+        long stopTime = System.currentTimeMillis() + TEST_TIME;
+    }
+
+
+    /**
+     * @param cacheMode Cache mode.
+     * @param backups Number of backups.
+     * @param near If {@code true} near cache is enabled.
+     * @return Cache configuration.
+     */
+    private CacheConfiguration<Object, Object> cacheConfiguration(CacheMode cacheMode,
int backups, boolean near) {
+        CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>();
+
+        ccfg.setCacheMode(cacheMode);
+
+        if (cacheMode != CacheMode.REPLICATED)
+            ccfg.setBackups(backups);
+
+        if (near)
+            ccfg.setNearConfiguration(new NearCacheConfiguration<>());
+
+        ccfg.setRebalanceMode(SYNC);
+
+        return ccfg;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/71165dc7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSingleGetMessageTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSingleGetMessageTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSingleGetMessageTest.java
index 42b5ee3..722ee83 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSingleGetMessageTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSingleGetMessageTest.java
@@ -170,11 +170,17 @@ public class IgniteCacheSingleGetMessageTest extends GridCommonAbstractTest
{
 
         assertNull(cache.get(key));
 
-        checkMessages(spi, primarySpi);
+        if (backup)
+            checkNoMessages(spi, primarySpi);
+        else
+            checkMessages(spi, primarySpi);
 
         assertFalse(cache.containsKey(key));
 
-        checkMessages(spi, primarySpi);
+        if (backup)
+            checkNoMessages(spi, primarySpi);
+        else
+            checkMessages(spi, primarySpi);
 
         cache.put(key, 1);
 
@@ -201,7 +207,10 @@ public class IgniteCacheSingleGetMessageTest extends GridCommonAbstractTest
{
                 tx.commit();
             }
 
-            checkMessages(spi, primarySpi);
+            if (backup)
+                checkNoMessages(spi, primarySpi);
+            else
+                checkMessages(spi, primarySpi);
 
             try (Transaction tx = node.transactions().txStart(OPTIMISTIC, REPEATABLE_READ))
{
                 assertFalse(cache.containsKey(key));
@@ -209,7 +218,10 @@ public class IgniteCacheSingleGetMessageTest extends GridCommonAbstractTest
{
                 tx.commit();
             }
 
-            checkMessages(spi, primarySpi);
+            if (backup)
+                checkNoMessages(spi, primarySpi);
+            else
+                checkMessages(spi, primarySpi);
 
             cache.put(key, 1);
 


Mime
View raw message