Repository: ignite
Updated Branches:
  refs/heads/ignite-8446 de0b1a70d -> 0b8cdfdfa


IGNITE-8446 Ability to check and completely fill transactions on creation

Signed-off-by: Anton Vinogradov <[email protected]>


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

Branch: refs/heads/ignite-8446
Commit: 0b8cdfdfa5816545cf865882b2bf13ba71638001
Parents: de0b1a7
Author: Anton Vinogradov <[email protected]>
Authored: Thu May 31 18:47:01 2018 +0300
Committer: Anton Vinogradov <[email protected]>
Committed: Thu May 31 18:47:01 2018 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/events/EventType.java     | 10 +++---
 .../cache/transactions/IgniteTxAdapter.java     |  5 ++-
 .../cache/transactions/IgniteTxManager.java     |  1 +
 .../TxRollbackOnIncorrectParamsTest.java        | 37 +++++++++++++++++++-
 4 files changed, 44 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0b8cdfdf/modules/core/src/main/java/org/apache/ignite/events/EventType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/events/EventType.java 
b/modules/core/src/main/java/org/apache/ignite/events/EventType.java
index 9181539..a6ab962 100644
--- a/modules/core/src/main/java/org/apache/ignite/events/EventType.java
+++ b/modules/core/src/main/java/org/apache/ignite/events/EventType.java
@@ -783,7 +783,7 @@ public interface EventType {
     /**
      * Built-in event type: Transaction has been started.
      * <p>
-     * Fired for each started transactions except system transactions.
+     * Fired for each started transaction except system transactions.
      * <p>
      * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
      * internal Ignite events and should not be used by user-defined events.
@@ -795,7 +795,7 @@ public interface EventType {
     /**
      * Built-in event type: Transaction has been committed.
      * <p>
-     * Fired for each committed transactions except system transactions.
+     * Fired for each committed transaction except system transactions.
      * <p>
      * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
      * internal Ignite events and should not be used by user-defined events.
@@ -807,7 +807,7 @@ public interface EventType {
     /**
      * Built-in event type: Transaction has been rolled back.
      * <p>
-     * Fired for each rolled back transactions except system transactions.
+     * Fired for each rolled back transaction except system transactions.
      * <p>
      * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
      * internal Ignite events and should not be used by user-defined events.
@@ -819,7 +819,7 @@ public interface EventType {
     /**
      * Built-in event type: Transaction has been suspended.
      * <p>
-     * Fired for each started suspended except system transactions.
+     * Fired for each suspended transaction except system transactions.
      * <p>
      * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
      * internal Ignite events and should not be used by user-defined events.
@@ -831,7 +831,7 @@ public interface EventType {
     /**
      * Built-in event type: Transaction has been resumed.
      * <p>
-     * Fired for each resumed transactions except system transactions.
+     * Fired for each resumed transaction except system transactions.
      * <p>
      * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
      * internal Ignite events and should not be used by user-defined events.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0b8cdfdf/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index 9956d9d..93c941f 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -1184,12 +1184,11 @@ public abstract class IgniteTxAdapter extends 
GridMetadataAwareAdapter implement
     /**
      * @param type Event type.
      */
-    public void recordStateChangedEvent(int type){
+    protected void recordStateChangedEvent(int type){
         GridEventStorageManager evt = cctx.gridEvents();
 
         if (!system() /* ignoring system tx */ && evt.isRecordable(type))
-            evt.record(new TransactionStateChangedEvent(
-                cctx.discovery().localNode(), null, type, proxy()));
+            evt.record(new 
TransactionStateChangedEvent(cctx.discovery().localNode(), null, type, 
proxy()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/0b8cdfdf/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index 4dbbe85..dd7f14d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -534,6 +534,7 @@ public class IgniteTxManager extends 
GridCacheSharedManagerAdapter {
                         sysThreadMap.put(new TxThreadKey(tx.threadId(), 
cacheCtx.cacheId()), tx);
                 }
 
+                // tx.state(newState) does not cover tx start case.
                 ((GridNearTxLocal)tx).recordStateChangedEvent(EVT_TX_STARTED);
             }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0b8cdfdf/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnIncorrectParamsTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnIncorrectParamsTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnIncorrectParamsTest.java
index 40916b8..5587ff0 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnIncorrectParamsTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnIncorrectParamsTest.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.cache.transactions;
 
 import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteEvents;
 import org.apache.ignite.events.Event;
 import org.apache.ignite.events.TransactionStateChangedEvent;
@@ -32,7 +33,7 @@ import static org.apache.ignite.events.EventType.EVTS_TX;
 import static org.apache.ignite.events.EventType.EVT_TX_STARTED;
 
 /**
- * Tests transaction timeout.
+ * Tests transaction rollback on incorrect tx params.
  */
 public class TxRollbackOnIncorrectParamsTest extends GridCommonAbstractTest {
     /**
@@ -58,13 +59,19 @@ public class TxRollbackOnIncorrectParamsTest extends 
GridCommonAbstractTest {
             return true;
         }, EVT_TX_STARTED);
 
+        IgniteCache cache = ignite.getOrCreateCache(DEFAULT_CACHE_NAME);
+
         try (Transaction tx = ignite.transactions().txStart(
             TransactionConcurrency.OPTIMISTIC, 
TransactionIsolation.REPEATABLE_READ, 200, 2)) {
+            cache.put(1,1);
+
             tx.commit();
         }
 
         try (Transaction tx = ignite.transactions().txStart(
             TransactionConcurrency.OPTIMISTIC, 
TransactionIsolation.REPEATABLE_READ, 100, 2)) {
+            cache.put(1,2);
+
             tx.commit();
 
             fail("Should fail prior this line.");
@@ -74,6 +81,8 @@ public class TxRollbackOnIncorrectParamsTest extends 
GridCommonAbstractTest {
         }
 
         try (Transaction tx = ignite.transactions().txStart()) {
+            cache.put(1,3);
+
             tx.commit();
 
             fail("Should fail prior this line.");
@@ -106,11 +115,17 @@ public class TxRollbackOnIncorrectParamsTest extends 
GridCommonAbstractTest {
             return true;
         }, EVT_TX_STARTED);
 
+        IgniteCache cache = ignite.getOrCreateCache(DEFAULT_CACHE_NAME);
+
         try (Transaction tx = 
ignite.transactions().withLabel("test").txStart()) {
+            cache.put(1,1);
+
             tx.commit();
         }
 
         try (Transaction tx = ignite.transactions().txStart()) {
+            cache.put(1,2);
+
             tx.commit();
 
             fail("Should fail prior this line.");
@@ -146,15 +161,23 @@ public class TxRollbackOnIncorrectParamsTest extends 
GridCommonAbstractTest {
             },
             EVT_TX_STARTED);
 
+        IgniteCache cache = ignite.getOrCreateCache(DEFAULT_CACHE_NAME);
+
         try (Transaction tx = 
ignite.transactions().withLabel("test").txStart()) {
+            cache.put(1,1);
+
             tx.commit();
         }
 
         try (Transaction tx = 
remote.transactions().withLabel("test").txStart()) {
+            cache.put(1,2);
+
             tx.commit();
         }
 
         try (Transaction tx = ignite.transactions().txStart()) {
+            cache.put(1,3);
+
             tx.commit();
 
             fail("Should fail prior this line.");
@@ -164,6 +187,8 @@ public class TxRollbackOnIncorrectParamsTest extends 
GridCommonAbstractTest {
         }
 
         try (Transaction tx = remote.transactions().txStart()) {
+            cache.put(1,4);
+
             tx.commit();
 
             fail("Should fail prior this line.");
@@ -199,17 +224,25 @@ public class TxRollbackOnIncorrectParamsTest extends 
GridCommonAbstractTest {
             },
             EVT_TX_STARTED);
 
+        IgniteCache cache = ignite.getOrCreateCache(DEFAULT_CACHE_NAME);
+
         try (Transaction tx = ignite.transactions().txStart(
             TransactionConcurrency.OPTIMISTIC, 
TransactionIsolation.REPEATABLE_READ, 100, 2)) {
+            cache.put(1,1);
+
             tx.commit();
         }
 
         try (Transaction tx = remote.transactions().txStart(
             TransactionConcurrency.OPTIMISTIC, 
TransactionIsolation.REPEATABLE_READ, 100, 2)) {
+            cache.put(1,2);
+
             tx.commit();
         }
 
         try (Transaction tx = ignite.transactions().txStart()) {
+            cache.put(1,3);
+
             tx.commit();
 
             fail("Should fail prior this line.");
@@ -219,6 +252,8 @@ public class TxRollbackOnIncorrectParamsTest extends 
GridCommonAbstractTest {
         }
 
         try (Transaction tx = remote.transactions().txStart()) {
+            cache.put(1,4);
+
             tx.commit();
 
             fail("Should fail prior this line.");

Reply via email to