ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject incubator-ignite git commit: # sprint-1 Fixed updates handling in CacheInvokeEntry to pass TCK
Date Thu, 12 Feb 2015 10:08:35 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/sprint-1 fb38190fe -> 78cc69e03


# sprint-1 Fixed updates handling in CacheInvokeEntry to pass TCK


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

Branch: refs/heads/sprint-1
Commit: 78cc69e03e6340cafb439e5c320175de50fe9f1b
Parents: fb38190
Author: sboikov <sboikov@gridgain.com>
Authored: Thu Feb 12 13:07:38 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Thu Feb 12 13:07:38 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/CacheInvokeEntry.java      | 35 +++++++++++++++++---
 .../processors/cache/EvictableEntryImpl.java    |  2 ++
 .../processors/cache/IgniteCacheProxy.java      |  6 ++--
 3 files changed, 35 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/78cc69e0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
index 541993c..3ef7e6d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
@@ -40,7 +40,10 @@ public class CacheInvokeEntry<K, V> implements MutableEntry<K,
V> {
     private V val;
 
     /** */
-    private boolean modified;
+    private final boolean hadVal;
+
+    /** */
+    private Operation op = Operation.NONE;
 
     /**
      * @param cctx Cache context.
@@ -54,6 +57,8 @@ public class CacheInvokeEntry<K, V> implements MutableEntry<K,
V> {
         this.cctx = cctx;
         this.key = key;
         this.val = val;
+
+        hadVal = val != null;
     }
 
     /** {@inheritDoc} */
@@ -65,7 +70,10 @@ public class CacheInvokeEntry<K, V> implements MutableEntry<K,
V> {
     @Override public void remove() {
         val = null;
 
-        modified = true;
+        if (op == Operation.CREATE)
+            op = Operation.NONE;
+        else
+            op = Operation.REMOVE;
     }
 
     /** {@inheritDoc} */
@@ -75,7 +83,7 @@ public class CacheInvokeEntry<K, V> implements MutableEntry<K,
V> {
 
         this.val = val;
 
-        modified = true;
+        op = hadVal ? Operation.UPDATE : Operation.CREATE;
     }
 
     /** {@inheritDoc} */
@@ -91,7 +99,7 @@ public class CacheInvokeEntry<K, V> implements MutableEntry<K,
V> {
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public <T> T unwrap(Class<T> cls) {
-        if (cls.equals(Ignite.class))
+        if (cls.isAssignableFrom(Ignite.class))
             return (T)cctx.kernalContext().grid();
         else if (cls.isAssignableFrom(getClass()))
             return cls.cast(this);
@@ -103,11 +111,28 @@ public class CacheInvokeEntry<K, V> implements MutableEntry<K,
V> {
      * @return {@code True} if {@link #setValue} or {@link #remove was called}.
      */
     public boolean modified() {
-        return modified;
+        return op != Operation.NONE;
     }
 
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(CacheInvokeEntry.class, this);
     }
+
+    /**
+     *
+     */
+    private static enum Operation {
+        /** */
+        NONE,
+
+        /** */
+        CREATE,
+
+        /** */
+        UPDATE,
+
+        /** */
+        REMOVE
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/78cc69e0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/EvictableEntryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/EvictableEntryImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/EvictableEntryImpl.java
index eec358b..9ca6c33 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/EvictableEntryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/EvictableEntryImpl.java
@@ -49,10 +49,12 @@ public class EvictableEntryImpl<K, V> implements EvictableEntry<K,
V> {
         return cached.key();
     }
 
+    /** {@inheritDoc} */
     @Override public boolean isCached() {
         return !cached.obsoleteOrDeleted();
     }
 
+    /** {@inheritDoc} */
     @Override public boolean evict() {
         GridCacheContext<K, V> ctx = cached.context();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/78cc69e0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index cb51846..9ef4716 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -884,12 +884,12 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K,
V
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public <T> T unwrap(Class<T> clazz) {
-        if (clazz.equals(IgniteCache.class))
+        if (clazz.isAssignableFrom(IgniteCache.class))
             return (T)this;
-        else if (clazz.equals(Ignite.class))
+        else if (clazz.isAssignableFrom(Ignite.class))
             return (T)ctx.grid();
 
-        throw new IllegalArgumentException("Unsupported class: " + clazz);
+        throw new IllegalArgumentException("Unwrapping to class is not supported: " + clazz);
     }
 
     /** {@inheritDoc} */


Mime
View raw message