ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [8/8] ignite git commit: fixing tests
Date Thu, 22 Oct 2015 15:39:18 GMT
fixing tests


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

Branch: refs/heads/ignite-1.4-slow-server-debug
Commit: 7fe0d041487ab533a4dc85c41886f68c816e8fed
Parents: 806d3e5
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Thu Oct 22 18:39:25 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Thu Oct 22 18:39:25 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheMvccManager.java  |   8 +-
 .../near/GridNearTxFinishFuture.java            | 105 ++++++++++---------
 .../cache/distributed/near/GridNearTxLocal.java |   3 +-
 .../transactions/IgniteTxLocalAdapter.java      |   1 -
 4 files changed, 61 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7fe0d041/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
index 7b65218..61ec785 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
@@ -345,12 +345,8 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter
{
      * @param err Error.
      */
     private void cancelClientFutures(IgniteCheckedException err) {
-        for (Collection<GridCacheFuture<?>> futures : futs.values()) {
-            synchronized (futures) {
-                for (GridCacheFuture<?> future : futures)
-                    ((GridFutureAdapter)future).onDone(err);
-            }
-        }
+        for (GridCacheFuture<?> fut : activeFutures())
+            ((GridFutureAdapter)fut).onDone(err);
 
         for (GridCacheAtomicFuture<?> future : atomicFuts.values())
             ((GridFutureAdapter)future).onDone(err);

http://git-wip-us.apache.org/repos/asf/ignite/blob/7fe0d041/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
index bcfbc0d..119bbe4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
@@ -87,15 +87,15 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
     /** Commit flag. */
     private boolean commit;
 
-    /** Error. */
-    private AtomicReference<Throwable> err = new AtomicReference<>(null);
-
     /** Node mappings. */
     private Map<UUID, GridDistributedTxMapping> mappings;
 
     /** Trackable flag. */
     private boolean trackable = true;
 
+    /** */
+    private boolean finishOnePhaseCalled;
+
     /**
      * @param cctx Context.
      * @param tx Transaction.
@@ -214,10 +214,16 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
 
     /** {@inheritDoc} */
     @Override public boolean onDone(IgniteInternalTx tx0, Throwable err) {
-        if (err != null) {
-            tx.commitError(err);
+        if (isDone())
+            return false;
+
+        synchronized (this) {
+            if (isDone())
+                return false;
+
+            if (err != null) {
+                tx.commitError(err);
 
-            if (this.err.compareAndSet(null, err)) {
                 boolean marked = tx.setRollbackOnly();
 
                 if (err instanceof IgniteTxRollbackCheckedException) {
@@ -239,62 +245,60 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
                     }
                 }
             }
-        }
 
-        if ((initialized() || err != null) && !isDone()) {
-            if (tx.needCheckBackup()) {
-                assert tx.onePhaseCommit();
+            if (initialized() || err != null) {
+                if (tx.needCheckBackup()) {
+                    assert tx.onePhaseCommit();
 
-                if (err != null)
-                    err = new TransactionRollbackException("Failed to commit transaction.",
err);
-
-                try {
-                    tx.finish(err == null);
-                }
-                catch (IgniteCheckedException e) {
                     if (err != null)
-                        err.addSuppressed(e);
-                    else
-                        err = e;
-                }
-            }
+                        err = new TransactionRollbackException("Failed to commit transaction.",
err);
 
-            if (tx.onePhaseCommit()) {
-                finishOnePhase();
+                    try {
+                        tx.finish(err == null);
+                    }
+                    catch (IgniteCheckedException e) {
+                        if (err != null)
+                            err.addSuppressed(e);
+                        else
+                            err = e;
+                    }
+                }
 
-                tx.tmFinish(commit && err == null);
-            }
+                if (tx.onePhaseCommit()) {
+                    finishOnePhase();
 
-            Throwable th = this.err.get();
+                    tx.tmFinish(commit && err == null);
+                }
 
-            if (super.onDone(tx0, th != null ? th : err)) {
-                if (error() instanceof IgniteTxHeuristicCheckedException) {
-                    AffinityTopologyVersion topVer = tx.topologyVersion();
+                if (super.onDone(tx0, err)) {
+                    if (error() instanceof IgniteTxHeuristicCheckedException) {
+                        AffinityTopologyVersion topVer = tx.topologyVersion();
 
-                    for (IgniteTxEntry e : tx.writeMap().values()) {
-                        GridCacheContext cacheCtx = e.context();
+                        for (IgniteTxEntry e : tx.writeMap().values()) {
+                            GridCacheContext cacheCtx = e.context();
 
-                        try {
-                            if (e.op() != NOOP && !cacheCtx.affinity().localNode(e.key(),
topVer)) {
-                                GridCacheEntryEx entry = cacheCtx.cache().peekEx(e.key());
+                            try {
+                                if (e.op() != NOOP && !cacheCtx.affinity().localNode(e.key(),
topVer)) {
+                                    GridCacheEntryEx entry = cacheCtx.cache().peekEx(e.key());
 
-                                if (entry != null)
-                                    entry.invalidate(null, tx.xidVersion());
+                                    if (entry != null)
+                                        entry.invalidate(null, tx.xidVersion());
+                                }
                             }
-                        }
-                        catch (Throwable t) {
-                            U.error(log, "Failed to invalidate entry.", t);
+                            catch (Throwable t) {
+                                U.error(log, "Failed to invalidate entry.", t);
 
-                            if (t instanceof Error)
-                                throw (Error)t;
+                                if (t instanceof Error)
+                                    throw (Error)t;
+                            }
                         }
                     }
-                }
 
-                // Don't forget to clean up.
-                cctx.mvcc().removeFuture(this);
+                    // Don't forget to clean up.
+                    cctx.mvcc().removeFuture(this);
 
-                return true;
+                    return true;
+                }
             }
         }
 
@@ -313,7 +317,7 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
      * Completeness callback.
      */
     private void onComplete() {
-        onDone(tx, err.get());
+        onDone(tx);
     }
 
     /**
@@ -506,6 +510,13 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
      *
      */
     private void finishOnePhase() {
+        assert Thread.holdsLock(this);
+
+        if (finishOnePhaseCalled)
+            return;
+
+        finishOnePhaseCalled = true;
+
         // No need to send messages as transaction was already committed on remote node.
         // Finish local mapping only as we need send commit message to backups.
         for (GridDistributedTxMapping m : mappings.values()) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/7fe0d041/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
index f7dbcc7..61af518 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
@@ -23,7 +23,6 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
-import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicReference;
 import javax.cache.expiry.ExpiryPolicy;
 import org.apache.ignite.IgniteCheckedException;
@@ -87,7 +86,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
     private static final long serialVersionUID = 0L;
 
     /** DHT mappings. */
-    private Map<UUID, GridDistributedTxMapping> mappings = new HashMap<>();
+    private Map<UUID, GridDistributedTxMapping> mappings = new ConcurrentHashMap8<>();
 
     /** Future. */
     @GridToStringExclude

http://git-wip-us.apache.org/repos/asf/ignite/blob/7fe0d041/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index b0c70fd..f0c1588 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -116,7 +116,6 @@ import static org.apache.ignite.transactions.TransactionState.UNKNOWN;
 
 /**
  * Transaction adapter for cache transactions.
- * TODO scytheout
  */
 public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
     implements IgniteTxLocalEx {


Mime
View raw message