IGNITE-651 - Fixed system transactions test since marshaller cache is not transactional anymore.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/ca472ac5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/ca472ac5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/ca472ac5 Branch: refs/heads/ignite-sprint-3 Commit: ca472ac50c3e679a305bb9a01a56b180ac3fff82 Parents: 685209c Author: Alexey Goncharuk <agoncha...@gridgain.com> Authored: Tue Mar 31 18:46:45 2015 -0700 Committer: Alexey Goncharuk <agoncha...@gridgain.com> Committed: Tue Mar 31 18:46:45 2015 -0700 ---------------------------------------------------------------------- .../ignite/internal/MarshallerContextImpl.java | 2 +- .../transactions/IgniteTransactionsImpl.java | 4 +++ .../IgniteCacheSystemTransactionsSelfTest.java | 38 ++++++-------------- 3 files changed, 15 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ca472ac5/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java index 4a27222..e6ef192 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java @@ -158,7 +158,7 @@ public class MarshallerContextImpl extends MarshallerContextAdapter { @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends String>> events) throws CacheEntryListenerException { for (CacheEntryEvent<? extends Integer, ? extends String> evt : events) { - assert evt.getOldValue() == null; + assert evt.getOldValue() == null : "Received non-null old value for system marshaller cache: " + evt; File file = new File(workDir, evt.getKey() + ".classname"); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ca472ac5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java index afa2826..c3ad32b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.cache.transactions; +import org.apache.ignite.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; @@ -137,6 +138,9 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx { long timeout, int txSize, @Nullable GridCacheContext sysCacheCtx) { TransactionConfiguration cfg = cctx.gridConfig().getTransactionConfiguration(); + if (sysCacheCtx != null && !sysCacheCtx.transactional()) + throw new IgniteException("Failed to start transaction on non-transactional cache: " + sysCacheCtx.name()); + if (!cfg.isTxSerializableEnabled() && isolation == SERIALIZABLE) throw new IllegalArgumentException("SERIALIZABLE isolation level is disabled (to enable change " + "'txSerializableEnabled' configuration property)"); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ca472ac5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java index f06838a..d4c3a1b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java @@ -24,9 +24,11 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.testframework.*; import org.apache.ignite.transactions.*; import java.util.*; +import java.util.concurrent.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; import static org.apache.ignite.transactions.TransactionConcurrency.*; @@ -101,38 +103,18 @@ public class IgniteCacheSystemTransactionsSelfTest extends GridCacheAbstractSelf /** * @throws Exception If failed. */ - public void testSystemMarshallerTxInsideSystemTx() throws Exception { + public void testMarshallerCacheShouldNotStartTx() throws Exception { IgniteKernal ignite = (IgniteKernal)grid(0); - GridCacheAdapter<Object, Object> utilityCache = ignite.context().cache().utilityCache(); + final GridCacheAdapter<String,String> marshallerCache = (GridCacheAdapter<String, String>)(GridCacheAdapter) + ignite.context().cache().marshallerCache(); - try (IgniteInternalTx tx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) { - utilityCache.get("1"); - utilityCache.put("1", "11"); - - GridCacheAdapter<String,String> marshallerCache = (GridCacheAdapter<String, String>)(GridCacheAdapter)ignite.context().cache().marshallerCache(); - - marshallerCache.putIfAbsent("2", "2"); - - try (IgniteInternalTx itx = marshallerCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) { - assertEquals(null, marshallerCache.get("1")); - assertEquals("2", marshallerCache.get("2")); - assertEquals(null, marshallerCache.get("3")); - - marshallerCache.put("3", "3"); - - itx.commit(); + GridTestUtils.assertThrows(log, new Callable<Object>() { + @Override + public Object call() throws Exception { + return marshallerCache.txStartEx(PESSIMISTIC, REPEATABLE_READ); } - - utilityCache.put("2", "22"); - - tx.commit(); - } - - checkTransactionsCommitted(); - - checkEntries(CU.UTILITY_CACHE_NAME, 1, "11", 2, "22", 3, null); - checkEntries(CU.MARSH_CACHE_NAME, 1, null, 2, "2", 3, "3"); + }, IgniteException.class, null); } /**