ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [18/50] [abbrv] ignite git commit: IGNITE-264 - Fixing tests WIP.
Date Thu, 03 Sep 2015 01:03:27 GMT
IGNITE-264 - Fixing tests WIP.


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

Branch: refs/heads/ignite-264
Commit: e7fa1b324dd569fa37d5bfc31a76c321fb5e80d3
Parents: 4bc5d50
Author: Alexey Goncharuk <agoncharuk@gridgain.com>
Authored: Mon Aug 10 17:19:49 2015 -0700
Committer: Alexey Goncharuk <agoncharuk@gridgain.com>
Committed: Mon Aug 10 17:19:49 2015 -0700

----------------------------------------------------------------------
 .../distributed/dht/GridDhtTxLocalAdapter.java  | 15 +++++++++++++-
 .../distributed/dht/GridDhtTxPrepareFuture.java | 15 ++++----------
 .../GridNearPessimisticTxPrepareFuture.java     |  3 +++
 .../cache/transactions/IgniteTxHandler.java     |  7 +++++--
 .../cache/IgniteOnePhaseCommitNearSelfTest.java |  6 ++++--
 .../dht/GridCacheTxNodeFailureSelfTest.java     | 21 ++++++++++++++++++--
 6 files changed, 49 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e7fa1b32/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
index d9e85a5..30cee9d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
@@ -65,6 +65,9 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter
{
     /** */
     protected boolean explicitLock;
 
+    /** Flag indicating that originating node has near cache. */
+    private boolean nearOnOriginatingNode;
+
     /** Nodes where transactions were started on lock step. */
     private Set<ClusterNode> lockTxNodes;
 
@@ -144,6 +147,15 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter
{
     }
 
     /**
+     * Sets flag that indicates that originating node has a near cache that participates
in this transaction.
+     *
+     * @param hasNear Has near cache flag.
+     */
+    public void nearOnOriginatingNode(boolean hasNear) {
+        nearOnOriginatingNode = hasNear;
+    }
+
+    /**
      * @return {@code True} if explicit lock transaction.
      */
     public boolean explicitLock() {
@@ -803,13 +815,14 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter
{
      * @return {@code True} if transaction is finished on prepare step.
      */
     protected final boolean commitOnPrepare() {
-        return onePhaseCommit() && !near();
+        return onePhaseCommit() && !near() && !nearOnOriginatingNode;
     }
 
     /**
      * @param prepFut Prepare future.
      * @return If transaction if finished on prepare step returns future which is completed
after transaction finish.
      */
+    @SuppressWarnings("TypeMayBeWeakened")
     protected final IgniteInternalFuture<GridNearTxPrepareResponse> chainOnePhasePrepare(
         final GridDhtTxPrepareFuture prepFut) {
         if (commitOnPrepare()) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/e7fa1b32/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index 34f9b2a..dae49a1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -487,11 +487,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
         if (tx.optimistic())
             tx.clearPrepareFuture(this);
 
-        // Check if originating node has a near cache participating in transaction.
-        boolean hasNearCache = originatingNodeHasNearCache();
-
         // Do not commit one-phase commit transaction if originating node has near cache
enabled.
-        if (tx.onePhaseCommit() && !hasNearCache) {
+        if (tx.onePhaseCommit() && tx.commitOnPrepare()) {
             assert last;
 
             // Must create prepare response before transaction is committed to grab correct
return value.
@@ -620,13 +617,9 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
         if (node == null)
             return false;
 
-        GridCacheAttributes[] attrs = node.attribute(IgniteNodeAttributes.ATTR_CACHE);
-
-        for (GridCacheAttributes attr : attrs) {
-            if (attr.nearCacheEnabled()) {
-                if (tx.activeCacheIds().contains(CU.cacheId(attr.cacheName())))
-                    return true;
-            }
+        for (int cacheId : tx.activeCacheIds()) {
+            if (cctx.discovery().cacheNearNode(node, cctx.cacheContext(cacheId).name()))
+                return true;
         }
 
         return false;

http://git-wip-us.apache.org/repos/asf/ignite/blob/e7fa1b32/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
index f51b4b8..6de46f4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
@@ -320,6 +320,9 @@ public class GridNearPessimisticTxPrepareFuture extends GridNearTxPrepareFutureA
          * @param e Error.
          */
         void onNodeLeft(ClusterTopologyCheckedException e) {
+            if (tx.onePhaseCommit())
+                tx.markForBackupCheck();
+
             onError(e);
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/e7fa1b32/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
index 42e806c..643bbde 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
@@ -266,7 +266,7 @@ public class IgniteTxHandler {
             GridDhtPartitionTopology top = null;
 
             if (req.firstClientRequest()) {
-                assert req.concurrency().equals(OPTIMISTIC) : req;
+                assert req.concurrency() == OPTIMISTIC : req;
                 assert CU.clientNode(nearNode) : nearNode;
 
                 top = firstEntry.context().topology();
@@ -297,7 +297,7 @@ public class IgniteTxHandler {
                     try {
                         ctx.io().send(nearNode, res, req.policy());
                     }
-                    catch (ClusterTopologyCheckedException e) {
+                    catch (ClusterTopologyCheckedException ignored) {
                         if (log.isDebugEnabled())
                             log.debug("Failed to send client tx remap response, client node
failed " +
                                 "[node=" + nearNode + ", req=" + req + ']');
@@ -334,6 +334,9 @@ public class IgniteTxHandler {
                     req.taskNameHash()
                 );
 
+                if (req.near())
+                    tx.nearOnOriginatingNode(true);
+
                 tx = ctx.tm().onCreated(null, tx);
 
                 if (tx != null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/e7fa1b32/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearSelfTest.java
index 295d37b..87c160f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearSelfTest.java
@@ -28,6 +28,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.processors.cache.distributed.near.*;
 import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.lang.*;
 import org.apache.ignite.plugin.extensions.communication.*;
 import org.apache.ignite.spi.*;
 import org.apache.ignite.spi.communication.tcp.*;
@@ -221,7 +222,8 @@ public class IgniteOnePhaseCommitNearSelfTest extends GridCommonAbstractTest
{
      */
     private static class MessageCountingCommunicationSpi extends TcpCommunicationSpi {
         /** {@inheritDoc} */
-        @Override public void sendMessage(ClusterNode node, Message msg) throws IgniteSpiException
{
+        @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException>
ackClosure)
+            throws IgniteSpiException {
             if (msg instanceof GridIoMessage) {
                 GridIoMessage ioMsg = (GridIoMessage)msg;
 
@@ -235,7 +237,7 @@ public class IgniteOnePhaseCommitNearSelfTest extends GridCommonAbstractTest
{
                 cntr.incrementAndGet();
             }
 
-            super.sendMessage(node, msg);
+            super.sendMessage(node, msg, ackClosure);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/e7fa1b32/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
index ddb4316..43e2348 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
@@ -33,6 +33,9 @@ import org.apache.ignite.transactions.*;
 import java.util.*;
 import java.util.concurrent.*;
 
+import static org.apache.ignite.transactions.TransactionConcurrency.*;
+import static org.apache.ignite.transactions.TransactionIsolation.*;
+
 /**
  * Tests one-phase commit transactions when some of the nodes fail in the middle of the transaction.
  */
@@ -64,7 +67,21 @@ public class GridCacheTxNodeFailureSelfTest extends GridCommonAbstractTest
{
     /**
      * @throws Exception If failed.
      */
-    public void testPrimaryNodeFailureBackupCommit() throws Exception {
+    public void testPrimaryNodeFailureBackipCommitPessimistic() throws Exception {
+        checkPrimaryNodeFailureBackupCommit(PESSIMISTIC);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPrimaryNodeFailureBackupCommitOptimistic() throws Exception {
+        checkPrimaryNodeFailureBackupCommit(OPTIMISTIC);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void checkPrimaryNodeFailureBackupCommit(final TransactionConcurrency conc) throws
Exception {
         startGrids(gridCount());
         awaitPartitionMapExchange();
 
@@ -82,7 +99,7 @@ public class GridCacheTxNodeFailureSelfTest extends GridCommonAbstractTest
{
 
             IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>()
{
                 @Override public Object call() throws Exception {
-                    try (Transaction tx = ignite.transactions().txStart()) {
+                    try (Transaction tx = ignite.transactions().txStart(conc, REPEATABLE_READ))
{
                         cache.put(key, key);
 
                         Transaction asyncTx = (Transaction)tx.withAsync();


Mime
View raw message