This is an automated email from the ASF dual-hosted git repository.

ilyak pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 2230749  IGNITE-13653 Remove warning for unordered bulk operation on 
ATOMIC cache.
2230749 is described below

commit 223074926dab0ce0508eb0c32b941ed4419898c6
Author: Aleksey Plekhanov <plehanov.a...@gmail.com>
AuthorDate: Mon Nov 9 15:07:45 2020 +0300

    IGNITE-13653 Remove warning for unordered bulk operation on ATOMIC cache.
    
    Improve test coverage.
    Fixes #8414.
    
    Signed-off-by: Ilya Kasnacheev <ilya.kasnach...@gmail.com>
---
 .../processors/cache/GridCacheAdapter.java         |  6 +++
 .../GridCacheHashMapPutAllWarningsTest.java        | 48 +++++++++++++++++++++-
 ...acheAtomicConcurrentUnorderedUpdateAllTest.java | 23 +++++++----
 3 files changed, 68 insertions(+), 9 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 2a06f1a..a6fcee8 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -5214,6 +5214,9 @@ public abstract class GridCacheAdapter<K, V> implements 
IgniteInternalCache<K, V
      * @param m Map to examine.
      */
     protected void warnIfUnordered(Map<?, ?> m, BulkOperation op) {
+        if (ctx.atomic())
+            return;
+
         if (m == null || m.size() <= 1)
             return;
 
@@ -5238,6 +5241,9 @@ public abstract class GridCacheAdapter<K, V> implements 
IgniteInternalCache<K, V
      * @param coll Collection to examine.
      */
     protected void warnIfUnordered(Collection<?> coll, BulkOperation op) {
+        if (ctx.atomic())
+            return;
+
         if (coll == null || coll.size() <= 1)
             return;
 
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/GridCacheHashMapPutAllWarningsTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/GridCacheHashMapPutAllWarningsTest.java
index 1e49d90..9b59bd5 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/GridCacheHashMapPutAllWarningsTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/GridCacheHashMapPutAllWarningsTest.java
@@ -31,6 +31,7 @@ import javax.cache.processor.EntryProcessorResult;
 import javax.cache.processor.MutableEntry;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -41,6 +42,7 @@ import 
org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.apache.ignite.transactions.Transaction;
 import org.apache.ignite.transactions.TransactionConcurrency;
 import org.apache.ignite.transactions.TransactionIsolation;
+import org.junit.Assume;
 import org.junit.Test;
 
 /**
@@ -82,7 +84,8 @@ public class GridCacheHashMapPutAllWarningsTest extends 
GridCommonAbstractTest {
 
         Ignite ignite = startGrid(0);
 
-        IgniteCache<Integer, String> c = ignite.getOrCreateCache(new 
CacheConfiguration<>("exact"));
+        IgniteCache<Integer, String> c = ignite.getOrCreateCache(new 
CacheConfiguration<Integer, String>("exact")
+            .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
 
         HashMap<Integer, String> m = new HashMap<>();
 
@@ -150,6 +153,9 @@ public class GridCacheHashMapPutAllWarningsTest extends 
GridCommonAbstractTest {
      */
     @Test
     public void testHashMapInvokeAllLocal() throws Exception {
+        Assume.assumeFalse( "Local transactional caches not supported by MVCC",
+            
IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS,
 false));
+
         List<String> messages = Collections.synchronizedList(new 
ArrayList<>());
 
         testLog = new ListeningTestLogger(false, log());
@@ -162,7 +168,7 @@ public class GridCacheHashMapPutAllWarningsTest extends 
GridCommonAbstractTest {
         Ignite ignite = startGrid(0);
 
         IgniteCache<Integer, String> c = ignite.getOrCreateCache(new 
CacheConfiguration<Integer, String>("invoke")
-            .setCacheMode(CacheMode.LOCAL));
+            
.setCacheMode(CacheMode.LOCAL).setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
 
         c.put(1, "foo");
         c.put(2, "bar");
@@ -381,4 +387,42 @@ public class GridCacheHashMapPutAllWarningsTest extends 
GridCommonAbstractTest {
 
         assertEquals(1, found);
     }
+
+    /**
+     * @throws Exception If failed.
+     */
+    @Test
+    public void testHashMapAtomic() throws Exception {
+        List<String> messages = Collections.synchronizedList(new 
ArrayList<>());
+
+        testLog = new ListeningTestLogger(log());
+
+        testLog.registerListener((s) -> {
+            if (s.contains("deadlock"))
+                messages.add(s);
+        });
+
+        Ignite ignite = startGrid(0);
+
+        IgniteCache<Integer, String> c = ignite.getOrCreateCache(new 
CacheConfiguration<Integer, String>("atomic")
+            .setAtomicityMode(CacheAtomicityMode.ATOMIC));
+
+        HashMap<Integer, String> m = new HashMap<>();
+
+        m.put(1, "foo");
+        m.put(2, "bar");
+
+        c.putAll(m);
+        c.invokeAll(m.keySet(), (k, v) -> v);
+        c.removeAll(m.keySet());
+        c.removeAll();
+
+        assertEquals(0, c.size());
+
+        for (String message : messages) {
+            assertFalse(message.contains("Unordered "));
+
+            assertFalse(message.contains("operation on cache"));
+        }
+    }
 }
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicConcurrentUnorderedUpdateAllTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicConcurrentUnorderedUpdateAllTest.java
index 6863c949..be95c9e 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicConcurrentUnorderedUpdateAllTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicConcurrentUnorderedUpdateAllTest.java
@@ -29,6 +29,7 @@ import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.store.CacheStore;
 import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.junit.Test;
@@ -53,15 +54,16 @@ public class 
IgniteCacheAtomicConcurrentUnorderedUpdateAllTest extends GridCommo
     private static final int CACHE_SIZE = 1_000;
 
     /** Parameters. */
-    @Parameterized.Parameters(name = "cacheMode={0}, writeThrough={1}")
+    @Parameterized.Parameters(name = "cacheMode={0}, writeThrough={1}, 
near={2}")
     public static Iterable<Object[]> data() {
         return Arrays.asList(
-            new Object[] {CacheMode.PARTITIONED, Boolean.FALSE},
-            new Object[] {CacheMode.PARTITIONED, Boolean.TRUE},
-            new Object[] {CacheMode.REPLICATED, Boolean.FALSE},
-            new Object[] {CacheMode.REPLICATED, Boolean.TRUE},
-            new Object[] {CacheMode.LOCAL, Boolean.FALSE},
-            new Object[] {CacheMode.LOCAL, Boolean.TRUE}
+            new Object[] {CacheMode.PARTITIONED, Boolean.FALSE, Boolean.FALSE},
+            new Object[] {CacheMode.PARTITIONED, Boolean.TRUE, Boolean.FALSE},
+            new Object[] {CacheMode.PARTITIONED, Boolean.FALSE, Boolean.TRUE},
+            new Object[] {CacheMode.REPLICATED, Boolean.FALSE, Boolean.FALSE},
+            new Object[] {CacheMode.REPLICATED, Boolean.TRUE, Boolean.FALSE},
+            new Object[] {CacheMode.LOCAL, Boolean.FALSE, Boolean.FALSE},
+            new Object[] {CacheMode.LOCAL, Boolean.TRUE, Boolean.FALSE}
         );
     }
 
@@ -73,6 +75,10 @@ public class 
IgniteCacheAtomicConcurrentUnorderedUpdateAllTest extends GridCommo
     @Parameterized.Parameter(1)
     public Boolean writeThrough;
 
+    /** Near cache. */
+    @Parameterized.Parameter(2)
+    public Boolean near;
+
     /** {@inheritDoc} */
     @Override protected void afterTest() throws Exception {
         super.afterTest();
@@ -92,6 +98,7 @@ public class 
IgniteCacheAtomicConcurrentUnorderedUpdateAllTest extends GridCommo
 
         IgniteCache<Object, Object> cache = ignite.createCache(new 
CacheConfiguration<>(CACHE_NAME)
             
.setWriteThrough(writeThrough).setCacheStoreFactory(cacheStoreFactory)
+            .setNearConfiguration(near ? new NearCacheConfiguration<>() : null)
             .setCacheMode(cacheMode).setAtomicityMode(ATOMIC).setBackups(1));
 
         CyclicBarrier barrier = new CyclicBarrier(THREADS_CNT);
@@ -122,6 +129,8 @@ public class 
IgniteCacheAtomicConcurrentUnorderedUpdateAllTest extends GridCommo
 
                 cache0.putAll(map);
 
+                cache0.invokeAll(map.keySet(), (k, v) -> v);
+
                 cache0.removeAll(map.keySet());
 
                 log.info("Thread " + threadIdx + " iteration " + i + " 
finished");

Reply via email to