ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkuliche...@apache.org
Subject [38/50] [abbrv] incubator-ignite git commit: # sprint-1 restored check that queue can not be used with atomic cache in CLOCK mode
Date Wed, 04 Mar 2015 01:32:08 GMT
# sprint-1 restored check that queue can not be used with atomic cache in CLOCK mode


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

Branch: refs/heads/master
Commit: 5926470450dfe799849f722dadf7e0a100fc6be0
Parents: f27a989
Author: sboikov <sboikov@gridgain.com>
Authored: Mon Feb 16 17:12:03 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Mon Feb 16 17:12:03 2015 +0300

----------------------------------------------------------------------
 .../datastructures/IgniteQueueExample.java      |  2 +-
 .../datastructures/DataStructuresProcessor.java | 15 ++++++-
 .../IgniteDataStructureUniqueNameTest.java      | 41 ++++++++++++++++++++
 3 files changed, 56 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/59264704/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteQueueExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteQueueExample.java
b/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteQueueExample.java
index 4219dd1..519d11a 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteQueueExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteQueueExample.java
@@ -36,7 +36,7 @@ import java.util.*;
  */
 public class IgniteQueueExample {
     /** Cache name. */
-    private static final String CACHE_NAME = "partitioned";
+    private static final String CACHE_NAME = "partitioned_tx";
 
     /** Number of retries */
     private static final int RETRIES = 20;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/59264704/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
index 2b55ec5..a2d69fb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
@@ -38,6 +38,7 @@ import java.io.*;
 import java.util.*;
 import java.util.concurrent.*;
 
+import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*;
 import static org.apache.ignite.internal.processors.cache.CacheFlag.*;
 import static org.apache.ignite.internal.processors.cache.GridCacheOperation.*;
 import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.DataStructureType.*;
@@ -690,6 +691,8 @@ public final class DataStructuresProcessor extends GridProcessorAdapter
{
 
             if (ctx.cache().publicCache(cfg.getCacheName()) == null)
                 throw new IgniteCheckedException("Cache for collection is not configured:
" + cfg.getCacheName());
+
+            checkSupportsQueue(ctx.cache().internalCache(cfg.getCacheName()).context());
         }
 
         DataStructureInfo dsInfo = new DataStructureInfo(name,
@@ -1191,6 +1194,16 @@ public final class DataStructuresProcessor extends GridProcessorAdapter
{
     }
 
     /**
+     * @param cctx Cache context.
+     * @throws IgniteCheckedException If {@link IgniteQueue} can with given cache.
+     */
+    private void checkSupportsQueue(GridCacheContext cctx) throws IgniteCheckedException
{
+        if (cctx.atomic() && !cctx.isLocal() && cctx.config().getAtomicWriteOrderMode()
== CLOCK)
+            throw new IgniteCheckedException("IgniteQueue can not be used with ATOMIC cache
with CLOCK write order mode" +
+                " (change write order mode to PRIMARY in configuration)");
+    }
+
+    /**
      *
      */
     static enum DataStructureType {
@@ -1261,7 +1274,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter
{
             // No-op.
         }
 
-        /*
+        /**
          * @param cacheName Collection cache name.
          * @param collocated Collocated flag.
          */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/59264704/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructureUniqueNameTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructureUniqueNameTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructureUniqueNameTest.java
index 92b88ff..7e5d603 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructureUniqueNameTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructureUniqueNameTest.java
@@ -28,13 +28,18 @@ import java.io.*;
 import java.util.*;
 import java.util.concurrent.*;
 
+import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*;
 import static org.apache.ignite.cache.CacheAtomicityMode.*;
 import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
 
 /**
  *
  */
 public class IgniteDataStructureUniqueNameTest extends IgniteCollectionAbstractTest {
+    /** */
+    private static final String ATOMIC_CLOCK_CACHE_NAME = "atomicClockCache";
+
     /** {@inheritDoc} */
     @Override protected int gridCount() {
         return 3;
@@ -61,12 +66,48 @@ public class IgniteDataStructureUniqueNameTest extends IgniteCollectionAbstractT
 
         cfg.setAtomicConfiguration(atomicCfg);
 
+        CacheConfiguration[] ccfgs = cfg.getCacheConfiguration();
+
+        assert ccfgs.length == 1 : ccfgs.length;
+
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        ccfg.setCacheMode(PARTITIONED);
+        ccfg.setName(ATOMIC_CLOCK_CACHE_NAME);
+        ccfg.setAtomicityMode(ATOMIC);
+        ccfg.setAtomicWriteOrderMode(CLOCK);
+        ccfg.setWriteSynchronizationMode(FULL_SYNC);
+
+        cfg.setCacheConfiguration(ccfgs[0], ccfg);
+
         return cfg;
     }
 
     /**
      * @throws Exception If failed.
      */
+    public void testQueueAtomicClockCache() throws Exception {
+        final String queueName = "testQueueAtomicClockCache";
+
+        GridTestUtils.assertThrows(log, new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                CollectionConfiguration colCfg = new CollectionConfiguration();
+
+                colCfg.setCacheName(ATOMIC_CLOCK_CACHE_NAME);
+
+                ignite(0).queue(queueName, 0, colCfg);
+
+                return null;
+            }
+        }, IgniteException.class, "IgniteQueue can not be used with ATOMIC cache with CLOCK
write order mode " +
+            "(change write order mode to PRIMARY in configuration)");
+
+        assertNull(ignite(0).queue(queueName, 0, null));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testUniqueNameMultithreaded() throws Exception {
         testUniqueName(true);
     }


Mime
View raw message