ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject ignite git commit: 8446
Date Fri, 01 Jun 2018 11:07:34 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-8446 fa5c130a5 -> 87269063a


8446


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

Branch: refs/heads/ignite-8446
Commit: 87269063a583070a9adc4d570700c14efff451d9
Parents: fa5c130
Author: Anton Vinogradov <av@apache.org>
Authored: Fri Jun 1 14:07:22 2018 +0300
Committer: Anton Vinogradov <av@apache.org>
Committed: Fri Jun 1 14:07:22 2018 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/events/EventType.java     | 15 +++++-
 .../cache/transactions/IgniteTxAdapter.java     |  3 ++
 .../transactions/TxStateChangeEventTest.java    | 51 +++++++++++++-------
 3 files changed, 51 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/87269063/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 a6ab962..e11f697 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
@@ -841,6 +841,18 @@ public interface EventType {
     public static final int EVT_TX_RESUMED = 133;
 
     /**
+     * Built-in event type: Transaction has been prepared.
+     * <p>
+     * Fired for each prepared 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.
+     *
+     * @see TransactionStateChangedEvent
+     */
+    public static final int EVT_TX_PREPARED = 134;
+
+    /**
      * All checkpoint events. This array can be directly passed into
      * {@link IgniteEvents#localListen(IgnitePredicate, int...)} method to
      * subscribe to all checkpoint events.
@@ -1050,7 +1062,8 @@ public interface EventType {
         EVT_TX_COMMITTED,
         EVT_TX_ROLLED_BACK,
         EVT_TX_SUSPENDED,
-        EVT_TX_RESUMED
+        EVT_TX_RESUMED,
+        EVT_TX_PREPARED
     };
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/87269063/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 8422bb5..e8e06d7 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
@@ -93,6 +93,7 @@ import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ;
 import static org.apache.ignite.events.EventType.EVT_TX_COMMITTED;
+import static org.apache.ignite.events.EventType.EVT_TX_PREPARED;
 import static org.apache.ignite.events.EventType.EVT_TX_RESUMED;
 import static org.apache.ignite.events.EventType.EVT_TX_ROLLED_BACK;
 import static org.apache.ignite.events.EventType.EVT_TX_SUSPENDED;
@@ -1043,6 +1044,8 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
implement
                 case PREPARED: {
                     valid = prev == PREPARING;
 
+                    evtType = EVT_TX_PREPARED;
+
                     break;
                 }
                 case COMMITTING: {

http://git-wip-us.apache.org/repos/asf/ignite/blob/87269063/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxStateChangeEventTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxStateChangeEventTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxStateChangeEventTest.java
index ea96ee7..989ceca 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxStateChangeEventTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxStateChangeEventTest.java
@@ -33,6 +33,7 @@ import org.apache.ignite.transactions.TransactionState;
 
 import static org.apache.ignite.events.EventType.EVTS_TX;
 import static org.apache.ignite.events.EventType.EVT_TX_COMMITTED;
+import static org.apache.ignite.events.EventType.EVT_TX_PREPARED;
 import static org.apache.ignite.events.EventType.EVT_TX_RESUMED;
 import static org.apache.ignite.events.EventType.EVT_TX_ROLLED_BACK;
 import static org.apache.ignite.events.EventType.EVT_TX_STARTED;
@@ -63,6 +64,9 @@ public class TxStateChangeEventTest extends GridCommonAbstractTest {
     /** Resume. */
     private AtomicBoolean resume = new AtomicBoolean();
 
+    /** Prepare. */
+    private AtomicBoolean prepare = new AtomicBoolean();
+
     /**
      *
      */
@@ -106,7 +110,7 @@ public class TxStateChangeEventTest extends GridCommonAbstractTest {
                 },
                 EVTS_TX);
 
-        IgniteCache cache = ignite.getOrCreateCache(DEFAULT_CACHE_NAME);
+        IgniteCache cache = ignite.getOrCreateCache(defaultCacheConfiguration().setBackups(2));
 
         // create & commit
         try (Transaction tx = ignite.transactions().withLabel(lb).txStart(
@@ -118,10 +122,11 @@ public class TxStateChangeEventTest extends GridCommonAbstractTest {
 
         assertTrue(
             creation.get() &&
-            commit.get() &&
-            !rollback.get() &&
-            !suspend.get() &&
-            !resume.get());
+                commit.get() &&
+                !rollback.get() &&
+                !suspend.get() &&
+                !resume.get() &&
+                prepare.get());
 
         clear();
 
@@ -141,10 +146,11 @@ public class TxStateChangeEventTest extends GridCommonAbstractTest {
 
         assertTrue(
             creation.get() &&
-            commit.get() &&
-            !rollback.get() &&
-            suspend.get() &&
-            resume.get());
+                commit.get() &&
+                !rollback.get() &&
+                suspend.get() &&
+                resume.get()&&
+                prepare.get());
 
         clear();
 
@@ -156,10 +162,11 @@ public class TxStateChangeEventTest extends GridCommonAbstractTest {
 
         assertTrue(
             creation.get() &&
-            !commit.get() &&
-            rollback.get() &&
-            !suspend.get() &&
-            !resume.get());
+                !commit.get() &&
+                rollback.get() &&
+                !suspend.get() &&
+                !resume.get()&&
+                !prepare.get());
     }
 
     /**
@@ -171,6 +178,7 @@ public class TxStateChangeEventTest extends GridCommonAbstractTest {
         rollback.set(false);
         suspend.set(false);
         resume.set(false);
+        prepare.set(false);
     }
 
     /**
@@ -179,21 +187,20 @@ public class TxStateChangeEventTest extends GridCommonAbstractTest {
     private void checkEvent(TransactionStateChangedEvent evt) {
         Transaction tx = evt.tx();
 
-        assertEquals(tx.timeout(), timeout);
+        assertTrue(tx.timeout() > 0); // Remote tx has relative timeout
 
         switch (evt.type()) {
             case EVT_TX_STARTED: {
+                assertEquals(lb, tx.label());
                 assertFalse(creation.get());
                 assertEquals(tx.state(), TransactionState.ACTIVE);
 
-                if (lb.equals(tx.label()))
-                    creation.set(true);
+                creation.set(true);
 
                 break;
             }
 
             case EVT_TX_COMMITTED: {
-                assertFalse(commit.get());
                 assertEquals(tx.state(), TransactionState.COMMITTED);
 
                 commit.set(true);
@@ -211,6 +218,7 @@ public class TxStateChangeEventTest extends GridCommonAbstractTest {
             }
 
             case EVT_TX_SUSPENDED: {
+                assertEquals(lb, tx.label());
                 assertFalse(commit.get());
                 assertEquals(tx.state(), TransactionState.SUSPENDED);
 
@@ -220,6 +228,7 @@ public class TxStateChangeEventTest extends GridCommonAbstractTest {
             }
 
             case EVT_TX_RESUMED: {
+                assertEquals(lb, tx.label());
                 assertFalse(commit.get());
                 assertEquals(tx.state(), TransactionState.ACTIVE);
 
@@ -227,6 +236,14 @@ public class TxStateChangeEventTest extends GridCommonAbstractTest {
 
                 break;
             }
+
+            case EVT_TX_PREPARED: {
+                assertEquals(tx.state(), TransactionState.PREPARED);
+
+                prepare.set(true);
+
+                break;
+            }
         }
     }
 


Mime
View raw message