ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [05/10] ignite git commit: wip
Date Fri, 17 Mar 2017 15:04:50 GMT
wip


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

Branch: refs/heads/ignite-4680-sb
Commit: 855c66b11b8eded1f3ff3e4ff1df587c724c5c70
Parents: f33235d
Author: Konstantin Dudkov <kdudkov@ya.ru>
Authored: Thu Mar 16 13:44:38 2017 +0300
Committer: Konstantin Dudkov <kdudkov@ya.ru>
Committed: Thu Mar 16 13:44:38 2017 +0300

----------------------------------------------------------------------
 .../dht/atomic/GridDhtAtomicCache.java          |  6 ++-
 .../dht/atomic/NearAtomicResponseHelper.java    | 55 +++++++++-----------
 2 files changed, 30 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/855c66b1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 05d85ad..e68d72d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -214,8 +214,10 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
             @Override public void apply(GridNearAtomicAbstractUpdateRequest req, GridNearAtomicUpdateResponse
res) {
                 if (req.writeSynchronizationMode() != FULL_ASYNC) {
                     if (req.responseHelper() != null) {
-                        if (req.responseHelper().addResponse(res))
-                            sendNearUpdateReply(res.nodeId(), req.responseHelper().response());
+                        GridNearAtomicUpdateResponse res0 = req.responseHelper().addResponse(res);
+
+                        if (res0 != null)
+                            sendNearUpdateReply(res.nodeId(), res0);
                     }
                     else
                         sendNearUpdateReply(res.nodeId(), res);

http://git-wip-us.apache.org/repos/asf/ignite/blob/855c66b1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/NearAtomicResponseHelper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/NearAtomicResponseHelper.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/NearAtomicResponseHelper.java
index 9e35e8f..00c9f6c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/NearAtomicResponseHelper.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/NearAtomicResponseHelper.java
@@ -42,45 +42,42 @@ public class NearAtomicResponseHelper {
      * @param res Response.
      * @return {@code true} if all responses added.
      */
-    public boolean addResponse(GridNearAtomicUpdateResponse res) {
+    public GridNearAtomicUpdateResponse addResponse(GridNearAtomicUpdateResponse res) {
         synchronized (this) {
-            if (res.stripe() == -1) {
-                this.res = res;
-                this.res.stripe(-1);
-
-                return true;
-            }
+            if (res.stripe() == -1)
+                return res;
 
             if (stripes.remove(res.stripe())) {
-                if (this.res == null)
-                    this.res = res;
-                else {
-                    if (res.nearValuesIndexes() != null)
-                        for (int i = 0; i < res.nearValuesIndexes().size(); i++)
-                            this.res.addNearValue(
-                                res.nearValuesIndexes().get(i),
-                                res.nearValue(i),
-                                res.nearTtl(i),
-                                res.nearExpireTime(i)
-                            );
+                mergeResponse(res);
 
-                    if (res.failedKeys() != null)
-                        this.res.addFailedKeys(res.failedKeys(), null);
-
-                    if (res.skippedIndexes() != null)
-                        this.res.skippedIndexes().addAll(res.skippedIndexes());
-                }
-                return stripes.isEmpty();
+                return stripes.isEmpty() ? this.res : null;
             }
 
-            return false;
+            return null;
         }
     }
 
     /**
-     * @return Response.
+     * @param res Response.
      */
-    public GridNearAtomicUpdateResponse response() {
-        return res;
+    private void mergeResponse(GridNearAtomicUpdateResponse res) {
+        if (this.res == null)
+            this.res = res;
+        else {
+            if (res.nearValuesIndexes() != null)
+                for (int i = 0; i < res.nearValuesIndexes().size(); i++)
+                    this.res.addNearValue(
+                        res.nearValuesIndexes().get(i),
+                        res.nearValue(i),
+                        res.nearTtl(i),
+                        res.nearExpireTime(i)
+                    );
+
+            if (res.failedKeys() != null)
+                this.res.addFailedKeys(res.failedKeys(), null);
+
+            if (res.skippedIndexes() != null)
+                this.res.skippedIndexes().addAll(res.skippedIndexes());
+        }
     }
 }


Mime
View raw message