ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [13/50] [abbrv] incubator-ignite git commit: # ignite-1 Skip update if entry processor did not modify entry
Date Wed, 21 Jan 2015 07:16:07 GMT
# ignite-1 Skip update if entry processor did not modify entry


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

Branch: refs/heads/ignite-35
Commit: 9e7f69625463409ab9a41349f1805e38fdc32f92
Parents: fb0b20a
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Jan 16 14:10:12 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Jan 16 14:10:12 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/CacheInvokeEntry.java      | 14 +++++++++++++
 .../processors/cache/GridCacheMapEntry.java     | 15 +++++++++++++
 .../cache/transactions/IgniteTxAdapter.java     | 22 ++++++++++++++++++--
 3 files changed, 49 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9e7f6962/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheInvokeEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheInvokeEntry.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheInvokeEntry.java
index c9ca244..ab7dfc4 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheInvokeEntry.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheInvokeEntry.java
@@ -26,6 +26,9 @@ public class CacheInvokeEntry<K, V> implements MutableEntry<K,
V> {
     @GridToStringInclude
     private V val;
 
+    /** */
+    private boolean modified;
+
     /**
      * @param key Key.
      * @param val Value.
@@ -43,6 +46,8 @@ public class CacheInvokeEntry<K, V> implements MutableEntry<K,
V> {
     /** {@inheritDoc} */
     @Override public void remove() {
         val = null;
+
+        modified = true;
     }
 
     /** {@inheritDoc} */
@@ -51,6 +56,8 @@ public class CacheInvokeEntry<K, V> implements MutableEntry<K,
V> {
             throw new NullPointerException();
 
         this.val = val;
+
+        modified = true;
     }
 
     /** {@inheritDoc} */
@@ -68,6 +75,13 @@ public class CacheInvokeEntry<K, V> implements MutableEntry<K,
V> {
         throw new IllegalArgumentException();
     }
 
+    /**
+     * @return {@code True} if {@link #setValue} or {@link #remove was called}.
+     */
+    public boolean modified() {
+        return modified;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(CacheInvokeEntry.class, this);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9e7f6962/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
index d4987e3..9b8945a 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
@@ -1473,6 +1473,9 @@ public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K,
V>
 
                     invokeRes = new CacheInvokeResult<>(e);
                 }
+
+                if (!entry.modified())
+                    return new GridTuple3<>(false, null, invokeRes);
             }
             else
                 updated = (V)writeObj;
@@ -1826,6 +1829,18 @@ public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K,
V>
 
                     valBytes = oldBytes.getIfMarshaled();
                 }
+
+                if (!entry.modified()) {
+                    return new GridCacheUpdateAtomicResult<>(false,
+                        retval ? old : null,
+                        null,
+                        invokeRes,
+                        -1L,
+                        -1L,
+                        null,
+                        null,
+                        false);
+                }
             }
             else
                 updated = (V)writeObj;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9e7f6962/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java
index d9b4d5c..6ab424a 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java
@@ -31,6 +31,7 @@ import org.gridgain.grid.util.lang.*;
 import org.gridgain.grid.util.tostring.*;
 import org.jetbrains.annotations.*;
 
+import javax.cache.processor.*;
 import java.io.*;
 import java.util.*;
 import java.util.concurrent.atomic.*;
@@ -1207,9 +1208,26 @@ public abstract class IgniteTxAdapter<K, V> extends GridMetadataAwareAdapter
                         CU.<K, V>empty(),
                         null);
 
-                val = txEntry.applyEntryProcessors(val);
+                boolean modified = false;
 
-                GridCacheOperation op = val == null ? DELETE : UPDATE;
+                for (T2<EntryProcessor<K, V, ?>, Object[]> t : txEntry.entryProcessors())
{
+                    CacheInvokeEntry<K, V> invokeEntry = new CacheInvokeEntry<>(txEntry.key(),
val);
+
+                    try {
+                        EntryProcessor processor = t.get1();
+
+                        processor.process(invokeEntry, t.get2());
+
+                        val = invokeEntry.getValue();
+                    }
+                    catch (Exception ignore) {
+                        // No-op.
+                    }
+
+                    modified |= invokeEntry.modified();
+                }
+
+                GridCacheOperation op = modified ? (val == null ? DELETE : UPDATE) : NOOP;
 
                 return F.t(op, (V)cacheCtx.<V>unwrapTemporary(val), null);
             }


Mime
View raw message