ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: ignite-4705
Date Fri, 10 Mar 2017 08:37:11 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-4705-2 6e5333ea1 -> c117af4a2


ignite-4705


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

Branch: refs/heads/ignite-4705-2
Commit: c117af4a210eb004dff6bf0fd56dd2653f72bdf1
Parents: 6e5333e
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Mar 10 11:37:00 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Mar 10 11:37:00 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheMessage.java      | 11 +++++
 .../GridDhtAtomicAbstractUpdateRequest.java     | 49 ++++++++++++++++++--
 .../dht/atomic/GridDhtAtomicNearResponse.java   |  8 +++-
 .../GridDhtAtomicSingleUpdateRequest.java       | 14 ------
 .../GridNearAtomicAbstractUpdateFuture.java     | 34 ++++++++++++--
 .../GridNearAtomicAbstractUpdateRequest.java    | 30 +++++++++---
 .../atomic/GridNearAtomicFullUpdateRequest.java |  3 +-
 7 files changed, 117 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c117af4a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
index f3acf66..4de465c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
@@ -701,6 +701,17 @@ public abstract class GridCacheMessage implements Message {
         return reader.afterMessageRead(GridCacheMessage.class);
     }
 
+    /**
+     * @param str Bulder.
+     * @param name Flag name.
+     */
+    protected final void appendFlag(StringBuilder str, String name) {
+        if (str.length() > 0)
+            str.append('|');
+
+        str.append(name);
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridCacheMessage.class, this, "cacheId", cacheId);

http://git-wip-us.apache.org/repos/asf/ignite/blob/c117af4a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateRequest.java
index 11fe860..2826215 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateRequest.java
@@ -31,6 +31,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheMessage;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
 import org.apache.ignite.plugin.extensions.communication.MessageWriter;
 import org.jetbrains.annotations.NotNull;
@@ -41,19 +42,19 @@ import org.jetbrains.annotations.Nullable;
  */
 public abstract class GridDhtAtomicAbstractUpdateRequest extends GridCacheMessage implements
GridCacheDeployable {
     /** Skip store flag bit mask. */
-    static final int DHT_ATOMIC_SKIP_STORE_FLAG_MASK = 0x01;
+    private static final int DHT_ATOMIC_SKIP_STORE_FLAG_MASK = 0x01;
 
     /** Keep binary flag. */
-    static final int DHT_ATOMIC_KEEP_BINARY_FLAG_MASK = 0x02;
+    private static final int DHT_ATOMIC_KEEP_BINARY_FLAG_MASK = 0x02;
 
     /** Near cache key flag. */
-    static final int DHT_ATOMIC_NEAR_FLAG_MASK = 0x04;
+    private static final int DHT_ATOMIC_NEAR_FLAG_MASK = 0x04;
 
     /** */
     static final int DHT_ATOMIC_HAS_RESULT_MASK = 0x08;
 
     /** */
-    static final int DHT_ATOMIC_REPLY_WITHOUT_DELAY = 0x10;
+    private static final int DHT_ATOMIC_REPLY_WITHOUT_DELAY = 0x10;
 
     /** Message index. */
     public static final int CACHE_MSG_IDX = nextIndexId();
@@ -157,6 +158,13 @@ public abstract class GridDhtAtomicAbstractUpdateRequest extends GridCacheMessag
     }
 
     /**
+     * @return Result flag.
+     */
+    private boolean hasResult() {
+        return isFlag(DHT_ATOMIC_HAS_RESULT_MASK);
+    }
+
+    /**
      * @return Near node ID.
      */
     public UUID nearNodeId() {
@@ -412,6 +420,20 @@ public abstract class GridDhtAtomicAbstractUpdateRequest extends GridCacheMessag
     @Nullable public abstract Object[] invokeArguments();
 
     /**
+     * @return {@code True} if near cache update request.
+     */
+    protected final boolean near() {
+        return isFlag(DHT_ATOMIC_NEAR_FLAG_MASK);
+    }
+
+    /**
+     * @param near Near cache update flag.
+     */
+    protected final void near(boolean near) {
+        setFlag(near, DHT_ATOMIC_NEAR_FLAG_MASK);
+    }
+
+    /**
      * Sets flag mask.
      *
      * @param flag Set or clear.
@@ -601,4 +623,23 @@ public abstract class GridDhtAtomicAbstractUpdateRequest extends GridCacheMessag
 
         return reader.afterMessageRead(GridDhtAtomicAbstractUpdateRequest.class);
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        StringBuilder flags = new StringBuilder();
+
+        if (skipStore())
+            appendFlag(flags, "skipStore");
+        if (keepBinary())
+            appendFlag(flags, "keepBinary");
+        if (near())
+            appendFlag(flags, "near");
+        if (hasResult())
+            appendFlag(flags, "hasRes");
+        if (replyWithoutDelay())
+            appendFlag(flags, "resNoDelay");
+
+        return S.toString(GridDhtAtomicAbstractUpdateRequest.class, this,
+            "flags", flags.toString());
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/c117af4a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java
index 6821774..08a7e28 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java
@@ -303,8 +303,12 @@ public class GridDhtAtomicNearResponse extends GridCacheMessage {
 
     /** {@inheritDoc} */
     @Override public String toString() {
+        StringBuilder flags = new StringBuilder();
+
+        if (hasResult())
+            appendFlag(flags, "hasRes");
+
         return S.toString(GridDhtAtomicNearResponse.class, this,
-            "flags",
-            "res=" + isFlag(DHT_ATOMIC_HAS_RESULT_MASK));
+            "flags", flags.toString());
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/c117af4a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java
index 9494b79..6b92c02 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java
@@ -293,20 +293,6 @@ public class GridDhtAtomicSingleUpdateRequest extends GridDhtAtomicAbstractUpdat
         return null;
     }
 
-    /**
-     * @return {@code True} if near cache update request.
-     */
-    private boolean near() {
-        return isFlag(DHT_ATOMIC_NEAR_FLAG_MASK);
-    }
-
-    /**
-     * @param near Near cache update flag.
-     */
-    private void near(boolean near) {
-        setFlag(near, DHT_ATOMIC_NEAR_FLAG_MASK);
-    }
-
     /** {@inheritDoc} */
     @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException
{
         super.prepareMarshal(ctx);

http://git-wip-us.apache.org/repos/asf/ignite/blob/c117af4a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
index 13bace4..39abb73 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
@@ -212,6 +212,9 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridFutureAdapt
         return null;
     }
 
+    /**
+     * @param req Request.
+     */
     void sendCheckUpdateRequest(GridNearAtomicCheckUpdateRequest req) {
         try {
             cctx.io().send(req.updateRequest().nodeId(), req, cctx.ioPolicy());
@@ -399,7 +402,7 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridFutureAdapt
      * @param req Request.
      * @param e Error.
      */
-    final void onSendError(GridNearAtomicCheckUpdateRequest req, IgniteCheckedException e)
{
+    private void onSendError(GridNearAtomicCheckUpdateRequest req, IgniteCheckedException
e) {
         GridNearAtomicUpdateResponse res = new GridNearAtomicUpdateResponse(cctx.cacheId(),
             req.updateRequest().nodeId(),
             req.futureId(),
@@ -460,10 +463,16 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridFutureAdapt
             }
         }
 
+        /**
+         * @return Primary node ID.
+         */
         UUID primaryId() {
             return req.nodeId();
         }
 
+        /**
+         * @param nodes Nodes.
+         */
         void addMapping(List<ClusterNode> nodes) {
             assert req.initMappingLocally();
 
@@ -471,6 +480,10 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridFutureAdapt
                 dhtNodes.add(nodes.get(i).id());
         }
 
+        /**
+         * @param cctx Context.
+         * @return Check result.
+         */
         DhtLeftResult checkDhtNodes(GridCacheContext cctx) {
             assert req.initMappingLocally() : req;
 
@@ -519,6 +532,10 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridFutureAdapt
             if (finished())
                 return null;
 
+            /*
+             * When primary failed, even if primary response is received, it is possible
it failed to send
+             * request to backup(s), need remap operation.
+             */
             if (req.fullSync() && !req.nodeFailedResponse()) {
                 req.resetResponse();
 
@@ -530,6 +547,7 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridFutureAdapt
 
         /**
          * @param nodeId Node ID.
+         * @param res Response.
          * @return Request if need process primary response, {@code null} otherwise.
          */
         @Nullable GridNearAtomicAbstractUpdateRequest processPrimaryResponse(UUID nodeId,
GridNearAtomicUpdateResponse res) {
@@ -616,6 +634,10 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridFutureAdapt
             return finished();
         }
 
+        /**
+         * @param nodeIds Node IDs.
+         * @param cctx Context.
+         */
         private void initDhtNodes(List<UUID> nodeIds, GridCacheContext cctx) {
             assert dhtNodes == null || req.initMappingLocally();
 
@@ -656,13 +678,17 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridFutureAdapt
      *
      */
     enum DhtLeftResult {
-        /** */
+        /** All responses and operation result are received. */
         DONE,
 
-        /** */
+        /** Not all responses are received. */
         NOT_DONE,
 
-        /** */
+        /**
+         * All backups failed and response from primary is not required,
+         * in this case in FULL_SYNC mode need send additional request
+         * on primary to ensure FULL_SYNC guarantee.
+         */
         ALL_RCVD_CHECK_PRIMARY
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/c117af4a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateRequest.java
index 23301c0..a43bfb0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateRequest.java
@@ -85,7 +85,7 @@ public abstract class GridNearAtomicAbstractUpdateRequest extends GridCacheMessa
     /** Task name hash. */
     protected int taskNameHash;
 
-    /** Compressed boolean flags. */
+    /** Compressed boolean flags. Make sure 'toString' is updated when add new flag. */
     @GridToStringExclude
     protected byte flags;
 
@@ -113,6 +113,7 @@ public abstract class GridNearAtomicAbstractUpdateRequest extends GridCacheMessa
      * @param retval Return value required flag.
      * @param subjId Subject ID.
      * @param taskNameHash Task name hash code.
+     * @param needPrimaryRes {@code True} if near node waits for primary response.
      * @param skipStore Skip write-through to a persistent storage.
      * @param keepBinary Keep binary flag.
      * @param addDepInfo Deployment info flag.
@@ -145,16 +146,12 @@ public abstract class GridNearAtomicAbstractUpdateRequest extends GridCacheMessa
 
         if (needPrimaryRes)
             needPrimaryResponse(true);
-
         if (topLocked)
             topologyLocked(true);
-
         if (retval)
             returnValue(true);
-
         if (skipStore)
             skipStore(true);
-
         if (keepBinary)
             keepBinary(true);
     }
@@ -265,6 +262,9 @@ public abstract class GridNearAtomicAbstractUpdateRequest extends GridCacheMessa
         return false;
     }
 
+    /**
+     *
+     */
     void resetResponse() {
         this.res = null;
     }
@@ -276,6 +276,9 @@ public abstract class GridNearAtomicAbstractUpdateRequest extends GridCacheMessa
         return res;
     }
 
+    /**
+     * @return {@code True} if received notification about primary fail.
+     */
     boolean nodeFailedResponse() {
         return res != null && res.nodeLeftResponse();
     }
@@ -290,7 +293,7 @@ public abstract class GridNearAtomicAbstractUpdateRequest extends GridCacheMessa
     /**
      * @param val {@code True} if topology is locked on near node.
      */
-    final void topologyLocked(boolean val) {
+    private void topologyLocked(boolean val) {
         setFlag(val, TOP_LOCKED_FLAG_MASK);
     }
 
@@ -602,7 +605,20 @@ public abstract class GridNearAtomicAbstractUpdateRequest extends GridCacheMessa
 
     /** {@inheritDoc} */
     @Override public String toString() {
+        StringBuilder flags = new StringBuilder();
+
+        if (needPrimaryResponse())
+            appendFlag(flags, "needRes");
+        if (topologyLocked())
+            appendFlag(flags, "topLock");
+        if (skipStore())
+            appendFlag(flags, "skipStore");
+        if (keepBinary())
+            appendFlag(flags, "keepBinary");
+        if (returnValue())
+            appendFlag(flags, "retVal");
+
         return S.toString(GridNearAtomicAbstractUpdateRequest.class, this,
-            "flags", "needRes=" + isFlag(NEED_PRIMARY_RES_FLAG_MASK) + "|retVal=" + isFlag(RET_VAL_FLAG_MASK));
+            "flags", flags.toString());
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/c117af4a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java
index b8bd81a..c381333 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java
@@ -616,7 +616,8 @@ public class GridNearAtomicFullUpdateRequest extends GridNearAtomicAbstractUpdat
 
     /** {@inheritDoc} */
     @Override public String toString() {
-        return S.toString(GridNearAtomicFullUpdateRequest.class, this, "filter", Arrays.toString(filter),
+        return S.toString(GridNearAtomicFullUpdateRequest.class, this,
+            "filter", Arrays.toString(filter),
             "parent", super.toString());
     }
 }


Mime
View raw message