ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject [21/50] [abbrv] ignite git commit: Fixed IgniteTxRemoteState to properly process invalid partitions.
Date Mon, 30 Nov 2015 13:35:25 GMT
Fixed IgniteTxRemoteState to properly process invalid partitions.


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

Branch: refs/heads/ignite-1270
Commit: 3080f61ae9ca1481d65f18f7a84f8bbc9d682f79
Parents: 722fe14
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Nov 27 15:24:32 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Nov 27 15:24:32 2015 +0300

----------------------------------------------------------------------
 .../cache/distributed/dht/GridDhtTxRemote.java  | 15 +-----------
 .../IgniteTxRemoteSingleStateImpl.java          | 16 ++++++-------
 .../cache/transactions/IgniteTxRemoteState.java |  5 ++++
 .../transactions/IgniteTxRemoteStateImpl.java   | 24 ++++++++++++++++++++
 4 files changed, 37 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3080f61a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
index e0929ad..85a5759 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
@@ -279,20 +279,7 @@ public class GridDhtTxRemote extends GridDistributedTxRemoteAdapter {
     @Override public void addInvalidPartition(GridCacheContext cacheCtx, int part) {
         super.addInvalidPartition(cacheCtx, part);
 
-        Map<IgniteTxKey, IgniteTxEntry> writeMap = txState.writeMap();
-
-        for (Iterator<IgniteTxEntry> it = writeMap.values().iterator(); it.hasNext();)
{
-            IgniteTxEntry e = it.next();
-
-            GridCacheEntryEx cached = e.cached();
-
-            if (cached != null) {
-                if (cached.partition() == part)
-                    it.remove();
-            }
-            else if (cacheCtx.affinity().partition(e.key()) == part)
-                it.remove();
-        }
+        txState.invalidPartition(part);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/3080f61a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteSingleStateImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteSingleStateImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteSingleStateImpl.java
index 90af517..a68006b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteSingleStateImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteSingleStateImpl.java
@@ -65,15 +65,7 @@ public class IgniteTxRemoteSingleStateImpl extends IgniteTxRemoteStateAdapter
{
 
     /** {@inheritDoc} */
     @Override public Set<IgniteTxKey> writeSet() {
-        if (entry != null) {
-            HashSet<IgniteTxKey> set = new HashSet<>(3, 0.75f);
-
-            set.add(entry.txKey());
-
-            return set;
-        }
-        else
-            return Collections.<IgniteTxKey>emptySet();
+        return entry != null ? Collections.singleton(entry.txKey()) : Collections.<IgniteTxKey>emptySet();
     }
 
     /** {@inheritDoc} */
@@ -113,6 +105,12 @@ public class IgniteTxRemoteSingleStateImpl extends IgniteTxRemoteStateAdapter
{
     }
 
     /** {@inheritDoc} */
+    @Override public void invalidPartition(int part) {
+        if (entry != null && entry.context().affinity().partition(entry.key()) ==
part)
+            entry = null;
+    }
+
+    /** {@inheritDoc} */
     public String toString() {
         return S.toString(IgniteTxRemoteSingleStateImpl.class, this);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3080f61a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteState.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteState.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteState.java
index b8290a1..77fc97e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteState.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteState.java
@@ -31,4 +31,9 @@ public interface IgniteTxRemoteState extends IgniteTxState {
      * @param key Entry key.
      */
     public void clearEntry(IgniteTxKey key);
+
+    /**
+     * @param part Partition number.
+     */
+    public void invalidPartition(int part);
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3080f61a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteStateImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteStateImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteStateImpl.java
index 32bc646..3335b44 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteStateImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteStateImpl.java
@@ -18,8 +18,12 @@
 package org.apache.ignite.internal.processors.cache.transactions;
 
 import java.util.Collection;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
+
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
@@ -118,6 +122,26 @@ public class IgniteTxRemoteStateImpl extends IgniteTxRemoteStateAdapter
{
     }
 
     /** {@inheritDoc} */
+    @Override public void invalidPartition(int part) {
+        if (writeMap != null) {
+            for (Iterator<IgniteTxEntry> it = writeMap.values().iterator(); it.hasNext();)
{
+                IgniteTxEntry e = it.next();
+
+                GridCacheContext cacheCtx = e.context();
+
+                GridCacheEntryEx cached = e.cached();
+
+                if (cached != null) {
+                    if (cached.partition() == part)
+                        it.remove();
+                }
+                else if (cacheCtx.affinity().partition(e.key()) == part)
+                    it.remove();
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
     public String toString() {
         return S.toString(IgniteTxRemoteStateImpl.class, this);
     }


Mime
View raw message