ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [13/50] [abbrv] incubator-ignite git commit: # ignite-157 wait for 'preparing' transactions in 'processCheckPreparedTxRequest'
Date Wed, 29 Apr 2015 00:28:39 GMT
# ignite-157 wait for 'preparing' transactions in 'processCheckPreparedTxRequest'


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

Branch: refs/heads/ignite-789
Commit: 26d20e7241b1af28f3cda586caa2af01285ef73f
Parents: 7b5f91a
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Apr 24 16:31:53 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Apr 24 16:35:23 2015 +0300

----------------------------------------------------------------------
 ...xOriginatingNodeFailureAbstractSelfTest.java | 85 +-------------------
 ...cOriginatingNodeFailureAbstractSelfTest.java |  7 +-
 ...itionedTxOriginatingNodeFailureSelfTest.java | 84 ++-----------------
 .../IgniteCacheFailoverTestSuite.java           |  7 +-
 4 files changed, 15 insertions(+), 168 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/26d20e72/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java
index 865f1f6..00bd43f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java
@@ -37,9 +37,7 @@ import org.apache.ignite.testframework.*;
 import java.util.*;
 import java.util.concurrent.*;
 
-import static org.apache.ignite.cache.CachePeekMode.*;
 import static org.apache.ignite.transactions.TransactionConcurrency.*;
-import static org.apache.ignite.transactions.TransactionIsolation.*;
 
 /**
  * Abstract test for originating node failure.
@@ -69,18 +67,6 @@ public abstract class IgniteTxOriginatingNodeFailureAbstractSelfTest extends
Gri
     /**
      * @throws Exception If failed.
      */
-    public void testPessimisticManyKeysCommit() throws Exception {
-        Collection<Integer> keys = new ArrayList<>(200);
-
-        for (int i = 0; i < 200; i++)
-            keys.add(i);
-
-        testPessimisticTxOriginatingNodeFails(keys);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
     public void testManyKeysRollback() throws Exception {
         Collection<Integer> keys = new ArrayList<>(200);
 
@@ -117,75 +103,6 @@ public abstract class IgniteTxOriginatingNodeFailureAbstractSelfTest
extends Gri
 
     /**
      * @param keys Keys to update.
-     * @throws Exception If failed.
-     */
-    protected void testPessimisticTxOriginatingNodeFails(Collection<Integer> keys)
throws Exception {
-        final Map<Integer, String> map = new HashMap<>();
-
-        final String initVal = "initialValue";
-
-        for (Integer key : keys) {
-            grid(originatingNode()).cache(null).put(key, initVal);
-
-            map.put(key, String.valueOf(key));
-        }
-
-        ClusterNode txNode = grid(originatingNode()).localNode();
-
-        final Ignite txIgniteNode = G.ignite(txNode.id());
-
-        info("Starting pessimistic tx " +
-            "[values=" + map + ", topVer=" + (grid(1)).context().discovery().topologyVersion()
+ ']');
-
-        GridTestUtils.runAsync(new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                IgniteCache<Integer, String> cache = txIgniteNode.cache(null);
-
-                assertNotNull(cache);
-
-                TransactionProxyImpl tx =
-                    (TransactionProxyImpl)txIgniteNode.transactions().txStart(PESSIMISTIC,
REPEATABLE_READ);
-
-                IgniteInternalTx txEx = GridTestUtils.getFieldValue(tx, "tx");
-
-                assertTrue(txEx.pessimistic());
-
-                cache.putAll(map);
-
-                return null;
-            }
-        }).get();
-
-        info("Stopping originating node " + txNode);
-
-        G.stop(G.ignite(txNode.id()).name(), true);
-
-        info("Stopped grid, waiting for transactions to complete.");
-
-        boolean txFinished = GridTestUtils.waitForCondition(new GridAbsPredicate() {
-            @Override public boolean apply() {
-                for (Ignite ignite : G.allGrids()) {
-                    IgniteKernal g = (IgniteKernal)ignite;
-
-                    GridCacheSharedContext<Object, Object> ctx = g.context().cache().context();
-
-                    int txNum = ctx.tm().idMapSize();
-
-                    if (txNum != 0)
-                        return false;
-                }
-
-                return true;
-            }
-        }, 10_000);
-
-        assertTrue(txFinished);
-
-        info("Transactions finished.");
-    }
-
-    /**
-     * @param keys Keys to update.
      * @param partial Flag indicating whether to simulate partial prepared state.
      * @throws Exception If failed.
      */
@@ -299,7 +216,7 @@ public abstract class IgniteTxOriginatingNodeFailureAbstractSelfTest extends
Gri
 
                         assertNotNull(cache);
 
-                        assertEquals(partial ? initVal : val, cache.localPeek(key, ONHEAP));
+                        assertEquals(partial ? initVal : val, cache.localPeek(key, CachePeekMode.ONHEAP));
 
                         return null;
                     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/26d20e72/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
index 706ab6e..13fadc4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
@@ -177,6 +177,8 @@ public abstract class IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest
 
                 Transaction tx = originatingNodeGrid.transactions().txStart();
 
+                assertEquals(PESSIMISTIC, tx.concurrency());
+
                 try {
                     cache.putAll(map);
 
@@ -315,8 +317,7 @@ public abstract class IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest
             nodeMap.put(key, nodes);
         }
 
-        info("Starting tx [values=" + map + ", topVer=" +
-            ((IgniteKernal)grid(1)).context().discovery().topologyVersion() + ']');
+        info("Starting tx [values=" + map + ", topVer=" + grid(1).context().discovery().topologyVersion()
+ ']');
 
         assertNotNull(cache);
 
@@ -330,6 +331,8 @@ public abstract class IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest
 
             IgniteInternalTx txEx = txProxy.tx();
 
+            assertTrue(txEx.pessimistic());
+
             if (commmit) {
                 txEx.prepare();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/26d20e72/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedTxOriginatingNodeFailureSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedTxOriginatingNodeFailureSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedTxOriginatingNodeFailureSelfTest.java
index fc1c403..734e4e4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedTxOriginatingNodeFailureSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedTxOriginatingNodeFailureSelfTest.java
@@ -25,8 +25,6 @@ import org.apache.ignite.internal.processors.cache.distributed.near.*;
 
 import java.util.*;
 
-import static org.apache.ignite.cache.CacheMode.*;
-
 /**
  * Tests transaction consistency when originating node fails.
  */
@@ -37,7 +35,7 @@ public class GridCachePartitionedTxOriginatingNodeFailureSelfTest extends
 
     /** {@inheritDoc} */
     @Override protected CacheMode cacheMode() {
-        return PARTITIONED;
+        return CacheMode.PARTITIONED;
     }
 
     /** {@inheritDoc} */
@@ -58,21 +56,6 @@ public class GridCachePartitionedTxOriginatingNodeFailureSelfTest extends
      * @throws Exception If failed.
      */
     public void testTxFromPrimary() throws Exception {
-        txFromPrimary(true);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testPessimisticTxFromPrimary() throws Exception {
-        txFromPrimary(false);
-    }
-
-    /**
-     * @param optimistic If {@code true} tests optimistic transaction.
-     * @throws Exception If failed.
-     */
-    private void txFromPrimary(boolean optimistic) throws Exception {
         ClusterNode txNode = grid(originatingNode()).localNode();
 
         Integer key = null;
@@ -87,31 +70,13 @@ public class GridCachePartitionedTxOriginatingNodeFailureSelfTest extends
 
         assertNotNull(key);
 
-        if (optimistic)
-            testTxOriginatingNodeFails(Collections.singleton(key), false);
-        else
-            testPessimisticTxOriginatingNodeFails(Collections.singleton(key));
+        testTxOriginatingNodeFails(Collections.singleton(key), false);
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testTxFromBackup() throws Exception {
-        txFromBackup(true);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testPessimisticTxFromBackup() throws Exception {
-        txFromBackup(false);
-    }
-
-    /**
-     * @param optimistic If {@code true} tests optimistic transaction.
-     * @throws Exception If failed.
-     */
-    private void txFromBackup(boolean optimistic) throws Exception {
         ClusterNode txNode = grid(originatingNode()).localNode();
 
         Integer key = null;
@@ -126,31 +91,13 @@ public class GridCachePartitionedTxOriginatingNodeFailureSelfTest extends
 
         assertNotNull(key);
 
-        if (optimistic)
-            testTxOriginatingNodeFails(Collections.singleton(key), false);
-        else
-            testPessimisticTxOriginatingNodeFails(Collections.singleton(key));
+        testTxOriginatingNodeFails(Collections.singleton(key), false);
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testTxFromNotColocated() throws Exception {
-        txFromNotColocated(true);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testPessimisticTxFromNotColocated() throws Exception {
-        txFromNotColocated(false);
-    }
-
-    /**
-     * @param optimistic If {@code true} tests optimistic transaction.
-     * @throws Exception If failed.
-     */
-    private void txFromNotColocated(boolean optimistic) throws Exception {
         ClusterNode txNode = grid(originatingNode()).localNode();
 
         Integer key = null;
@@ -166,31 +113,13 @@ public class GridCachePartitionedTxOriginatingNodeFailureSelfTest extends
 
         assertNotNull(key);
 
-        if (optimistic)
-            testTxOriginatingNodeFails(Collections.singleton(key), false);
-        else
-            testPessimisticTxOriginatingNodeFails(Collections.singleton(key));
+        testTxOriginatingNodeFails(Collections.singleton(key), false);
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testTxAllNodes() throws Exception {
-        txAllNodes(true);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testPessimisticTxAllNodes() throws Exception {
-        txAllNodes(false);
-    }
-
-    /**
-     * @param optimistic If {@code true} tests optimistic transaction.
-     * @throws Exception If failed.
-     */
-    private void txAllNodes(boolean optimistic) throws Exception {
         List<ClusterNode> allNodes = new ArrayList<>(GRID_CNT);
 
         for (int i = 0; i < GRID_CNT; i++)
@@ -214,9 +143,6 @@ public class GridCachePartitionedTxOriginatingNodeFailureSelfTest extends
 
         assertEquals(GRID_CNT, keys.size());
 
-        if (optimistic)
-            testTxOriginatingNodeFails(keys, false);
-        else
-            testPessimisticTxOriginatingNodeFails(keys);
+        testTxOriginatingNodeFails(keys, false);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/26d20e72/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
index 64f6ce4..2acd6a3 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
@@ -23,6 +23,7 @@ import org.apache.ignite.internal.processors.cache.distributed.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.*;
 import org.apache.ignite.internal.processors.cache.distributed.near.*;
+import org.apache.ignite.internal.processors.cache.distributed.replicated.*;
 
 /**
  * Test suite.
@@ -53,9 +54,9 @@ public class IgniteCacheFailoverTestSuite extends TestSuite {
         suite.addTestSuite(GridCacheAtomicPrimaryWriteOrderFailoverSelfTest.class);
         suite.addTestSuite(GridCacheAtomicReplicatedFailoverSelfTest.class);
 
-        //suite.addTestSuite(GridCachePartitionedFailoverSelfTest.class);  TODO IGNITE-631.
-        //suite.addTestSuite(GridCacheColocatedFailoverSelfTest.class); TODO IGNITE-631.
-        //suite.addTestSuite(GridCacheReplicatedFailoverSelfTest.class); TODO IGNITE-631.
+        suite.addTestSuite(GridCachePartitionedFailoverSelfTest.class);
+        suite.addTestSuite(GridCacheColocatedFailoverSelfTest.class);
+        suite.addTestSuite(GridCacheReplicatedFailoverSelfTest.class);
 
         suite.addTestSuite(IgniteCacheAtomicNodeJoinTest.class);
         suite.addTestSuite(IgniteCacheTxNodeJoinTest.class);


Mime
View raw message