ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject ignite git commit: Ignite-950 - Fixing tests.
Date Tue, 27 Oct 2015 15:52:28 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-950-new 72d1393fc -> 52ac93b24


Ignite-950 - Fixing tests.


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

Branch: refs/heads/ignite-950-new
Commit: 52ac93b24ddf6a87857faf3da46f80721625a421
Parents: 72d1393
Author: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Authored: Tue Oct 27 18:52:14 2015 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Tue Oct 27 18:52:14 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/CacheObjectContext.java    | 52 +++++++++++---------
 .../dht/atomic/GridDhtAtomicCache.java          | 11 +++--
 2 files changed, 37 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/52ac93b2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
index 2cb446e..5b50818 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.cache;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import org.apache.ignite.cache.affinity.AffinityKeyMapper;
@@ -27,12 +26,11 @@ import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.portable.PortableUtils;
 import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
 import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.portable.PortableObject;
 
 /**
  *
  */
-public class CacheObjectContext {
+@SuppressWarnings("TypeMayBeWeakened") public class CacheObjectContext {
     /** */
     private GridKernalContext kernalCtx;
 
@@ -62,11 +60,11 @@ public class CacheObjectContext {
         boolean cpyOnGet,
         boolean storeVal) {
         this.kernalCtx = kernalCtx;
-        this.p2pEnabled = kernalCtx.config().isPeerClassLoadingEnabled();
         this.dfltAffMapper = dfltAffMapper;
         this.cpyOnGet = cpyOnGet;
         this.storeVal = storeVal;
 
+        p2pEnabled = kernalCtx.config().isPeerClassLoadingEnabled();
         proc = kernalCtx.cacheObjects();
     }
 
@@ -114,24 +112,34 @@ public class CacheObjectContext {
 
     /** {@inheritDoc} */
     public Object unwrapPortableIfNeeded(Object o, boolean keepPortable) {
+        return unwrapPortableIfNeeded(o, keepPortable, true);
+    }
+
+    /** {@inheritDoc} */
+    public Object unwrapPortableIfNeeded(Object o, boolean keepPortable, boolean cpy) {
         if (o == null)
             return null;
 
-        return unwrapPortable(o, keepPortable);
+        return unwrapPortable(o, keepPortable, cpy);
     }
 
     /** {@inheritDoc} */
     public Collection<Object> unwrapPortablesIfNeeded(Collection<Object> col,
boolean keepPortable) {
+        return unwrapPortablesIfNeeded(col, keepPortable, true);
+    }
+
+    /** {@inheritDoc} */
+    public Collection<Object> unwrapPortablesIfNeeded(Collection<Object> col,
boolean keepPortable, boolean cpy) {
         if (col instanceof ArrayList)
-            return unwrapPortables((ArrayList<Object>)col, keepPortable);
+            return unwrapPortables((ArrayList<Object>)col, keepPortable, cpy);
 
         if (col instanceof Set)
-            return unwrapPortables((Set<Object>)col, keepPortable);
+            return unwrapPortables((Set<Object>)col, keepPortable, cpy);
 
         Collection<Object> col0 = new ArrayList<>(col.size());
 
         for (Object obj : col)
-            col0.add(unwrapPortable(obj, keepPortable));
+            col0.add(unwrapPortable(obj, keepPortable, cpy));
 
         return col0;
     }
@@ -143,14 +151,14 @@ public class CacheObjectContext {
      * @param keepPortable Keep portable flag.
      * @return Unwrapped collection.
      */
-    public Map<Object, Object> unwrapPortablesIfNeeded(Map<Object, Object> map,
boolean keepPortable) {
+    private Map<Object, Object> unwrapPortablesIfNeeded(Map<Object, Object> map,
boolean keepPortable, boolean cpy) {
         if (keepPortable)
             return map;
 
         Map<Object, Object> map0 = PortableUtils.newMap(map);
 
         for (Map.Entry<Object, Object> e : map.entrySet())
-            map0.put(unwrapPortable(e.getKey(), keepPortable), unwrapPortable(e.getValue(),
keepPortable));
+            map0.put(unwrapPortable(e.getKey(), keepPortable, cpy), unwrapPortable(e.getValue(),
keepPortable, cpy));
 
         return map0;
     }
@@ -161,13 +169,13 @@ public class CacheObjectContext {
      * @param col List to unwrap.
      * @return Unwrapped list.
      */
-    private Collection<Object> unwrapPortables(ArrayList<Object> col, boolean
keepPortable) {
+    private Collection<Object> unwrapPortables(ArrayList<Object> col, boolean
keepPortable, boolean cpy) {
         int size = col.size();
 
         for (int i = 0; i < size; i++) {
             Object o = col.get(i);
 
-            Object unwrapped = unwrapPortable(o, keepPortable);
+            Object unwrapped = unwrapPortable(o, keepPortable, cpy);
 
             if (o != unwrapped)
                 col.set(i, unwrapped);
@@ -182,13 +190,11 @@ public class CacheObjectContext {
      * @param set Set to unwrap.
      * @return Unwrapped set.
      */
-    private Set<Object> unwrapPortables(Set<Object> set, boolean keepPortable)
{
+    private Set<Object> unwrapPortables(Set<Object> set, boolean keepPortable,
boolean cpy) {
         Set<Object> set0 = PortableUtils.newSet(set);
 
-        Iterator<Object> iter = set.iterator();
-
-        while (iter.hasNext())
-            set0.add(unwrapPortable(iter.next(), keepPortable));
+        for (Object obj : set)
+            set0.add(unwrapPortable(obj, keepPortable, cpy));
 
         return set0;
     }
@@ -197,29 +203,29 @@ public class CacheObjectContext {
      * @param o Object to unwrap.
      * @return Unwrapped object.
      */
-    private Object unwrapPortable(Object o, boolean keepPortable) {
+    private Object unwrapPortable(Object o, boolean keepPortable, boolean cpy) {
         if (o instanceof Map.Entry) {
             Map.Entry entry = (Map.Entry)o;
 
             Object key = entry.getKey();
 
-            Object uKey = unwrapPortable(key, keepPortable);
+            Object uKey = unwrapPortable(key, keepPortable, cpy);
 
             Object val = entry.getValue();
 
-            Object uVal = unwrapPortable(val, keepPortable);
+            Object uVal = unwrapPortable(val, keepPortable, cpy);
 
             return (key != uKey || val != uVal) ? F.t(uKey, uVal) : o;
         }
         else if (o instanceof Collection)
-            return unwrapPortablesIfNeeded((Collection<Object>)o, keepPortable);
+            return unwrapPortablesIfNeeded((Collection<Object>)o, keepPortable, cpy);
         else if (o instanceof Map)
-            return unwrapPortablesIfNeeded((Map<Object, Object>)o, keepPortable);
+            return unwrapPortablesIfNeeded((Map<Object, Object>)o, keepPortable, cpy);
         else if (o instanceof CacheObject) {
             CacheObject co = (CacheObject)o;
 
             if (!keepPortable || co.isPlatformType())
-                return unwrapPortable(co.value(this, true), keepPortable);
+                return unwrapPortable(co.value(this, true), keepPortable, cpy);
         }
 
         return o;

http://git-wip-us.apache.org/repos/asf/ignite/blob/52ac93b2/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 259b4c9..ad8775e 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
@@ -2146,9 +2146,14 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
             res.addFailedKeys(putMap != null ? putMap.keySet() : rmvKeys, e, ctx);
         }
 
-        // TODO ignite-950
-//        if (storeErr != null)
-//            res.addFailedKeys(storeErr.failedKeys(), storeErr.getCause(), ctx);
+        if (storeErr != null) {
+            ArrayList<KeyCacheObject> failed = new ArrayList<>(storeErr.failedKeys().size());
+
+            for (Object failedKey : storeErr.failedKeys())
+                failed.add(ctx.toCacheKeyObject(failedKey));
+
+            res.addFailedKeys(failed, storeErr.getCause(), ctx);
+        }
 
         return dhtFut;
     }


Mime
View raw message