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-new - Fixing withKeepBinary behavior
Date Mon, 02 Nov 2015 10:03:54 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-950-new fcaa1d5ad -> 63a7c54d4


IGNITE-950-new - Fixing withKeepBinary behavior


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

Branch: refs/heads/ignite-950-new
Commit: 63a7c54d4acf064f64769d0a5a6086a706bd1a1a
Parents: fcaa1d5
Author: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Authored: Mon Nov 2 13:03:34 2015 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Mon Nov 2 13:03:34 2015 +0300

----------------------------------------------------------------------
 .../swapspace/GridSwapSpaceManager.java         | 34 --------------------
 .../processors/cache/GridCacheSwapManager.java  | 16 ++++-----
 .../apache/ignite/spi/swapspace/SwapKey.java    |  9 ++++--
 .../file/GridFileSwapSpaceSpiSelfTest.java      | 11 +++++--
 4 files changed, 22 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/63a7c54d/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
index f90cf4f..437603a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java
@@ -221,22 +221,6 @@ public class GridSwapSpaceManager extends GridManagerAdapter<SwapSpaceSpi>
{
     }
 
     /**
-     * Writes value to swap.
-     *
-     * @param spaceName Space name.
-     * @param key Key.
-     * @param val Value.
-     * @param ldr Class loader (optional).
-     * @throws IgniteCheckedException If failed.
-     */
-    public void write(@Nullable String spaceName, Object key, @Nullable Object val, @Nullable
ClassLoader ldr)
-        throws IgniteCheckedException {
-        assert key != null;
-
-        write(spaceName, new SwapKey(key), marshal(val), ldr);
-    }
-
-    /**
      * Removes value from swap.
      *
      * @param spaceName Space name.
@@ -284,24 +268,6 @@ public class GridSwapSpaceManager extends GridManagerAdapter<SwapSpaceSpi>
{
     }
 
     /**
-     * Removes value from swap.
-     *
-     * @param spaceName Space name.
-     * @param key Key.
-     * @param c Optional closure that takes removed value and executes after actual
-     *      removing. If there was no value in storage the closure is executed given
-     *      {@code null} value as parameter.
-     * @param ldr Class loader (optional).
-     * @throws IgniteCheckedException If failed.
-     */
-    public void remove(@Nullable String spaceName, Object key, @Nullable IgniteInClosure<byte[]>
c,
-        @Nullable ClassLoader ldr) throws IgniteCheckedException {
-        assert key != null;
-
-        remove(spaceName, new SwapKey(key), c, ldr);
-    }
-
-    /**
      * Gets size in bytes for swap space.
      *
      * @param spaceName Space name.

http://git-wip-us.apache.org/repos/asf/ignite/blob/63a7c54d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
index 7d724d3..37b5e15 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
@@ -550,7 +550,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
             assert key != null;
 
             byte[] valBytes = swapMgr.read(spaceName,
-                new SwapKey(key.value(cctx.cacheObjectContext(), false), part, key.valueBytes(cctx.cacheObjectContext())),
+                new SwapKey(key, part, key.valueBytes(cctx.cacheObjectContext())),
                 cctx.deploy().globalLoader());
 
             if (cctx.config().isStatisticsEnabled())
@@ -616,7 +616,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
             assert key != null;
 
             byte[] bytes = swapMgr.read(spaceName,
-                new SwapKey(key.value(cctx.cacheObjectContext(), false), part, keyBytes),
+                new SwapKey(key, part, keyBytes),
                 cctx.deploy().globalLoader());
 
             if (bytes == null && lsnr != null)
@@ -691,7 +691,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
         final GridTuple<GridCacheSwapEntry> t = F.t1();
         final GridTuple<IgniteCheckedException> err = F.t1();
 
-        SwapKey swapKey = new SwapKey(key.value(cctx.cacheObjectContext(), false),
+        SwapKey swapKey = new SwapKey(key,
             part,
             key.valueBytes(cctx.cacheObjectContext()));
 
@@ -940,7 +940,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
                     if (unprocessedKeys == null)
                         unprocessedKeys = new ArrayList<>(keys.size());
 
-                    SwapKey swapKey = new SwapKey(key.value(cctx.cacheObjectContext(), false),
+                    SwapKey swapKey = new SwapKey(key,
                         cctx.affinity().partition(key),
                         key.valueBytes(cctx.cacheObjectContext()));
 
@@ -955,7 +955,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
             unprocessedKeys = new ArrayList<>(keys.size());
 
             for (KeyCacheObject key : keys) {
-                SwapKey swapKey = new SwapKey(key.value(cctx.cacheObjectContext(), false),
+                SwapKey swapKey = new SwapKey(key,
                     cctx.affinity().partition(key),
                     key.valueBytes(cctx.cacheObjectContext()));
 
@@ -1223,7 +1223,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
         }
 
         if (swapEnabled) {
-            SwapKey swapKey = new SwapKey(key.value(cctx.cacheObjectContext(), false),
+            SwapKey swapKey = new SwapKey(key,
                 part,
                 key.valueBytes(cctx.cacheObjectContext()));
 
@@ -1334,7 +1334,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
             Map<SwapKey, byte[]> batch = new LinkedHashMap<>();
 
             for (GridCacheBatchSwapEntry entry : swapped) {
-                SwapKey swapKey = new SwapKey(entry.key().value(cctx.cacheObjectContext(),
false),
+                SwapKey swapKey = new SwapKey(entry.key(),
                     entry.partition(),
                     entry.key().valueBytes(cctx.cacheObjectContext()));
 
@@ -1373,7 +1373,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
         checkIteratorQueue();
 
         swapMgr.write(spaceName,
-            new SwapKey(key.value(cctx.cacheObjectContext(), false), part, key.valueBytes(cctx.cacheObjectContext())),
+            new SwapKey(key, part, key.valueBytes(cctx.cacheObjectContext())),
             entry, cctx.deploy().globalLoader());
 
         if (cctx.config().isStatisticsEnabled())

http://git-wip-us.apache.org/repos/asf/ignite/blob/63a7c54d/modules/core/src/main/java/org/apache/ignite/spi/swapspace/SwapKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/SwapKey.java b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/SwapKey.java
index fb22be2..fb028b4 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/SwapKey.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/SwapKey.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.spi.swapspace;
 
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
@@ -44,7 +45,8 @@ public class SwapKey {
      * @param key Key.
      */
     public SwapKey(Object key) {
-        this(key, Integer.MAX_VALUE, null);
+        this.key = key;
+        part = Integer.MAX_VALUE;
     }
 
     /**
@@ -52,7 +54,8 @@ public class SwapKey {
      * @param part Partition.
      */
     public SwapKey(Object key, int part) {
-        this(key, part, null);
+        this.key = key;
+        this.part = part;
     }
 
     /**
@@ -60,7 +63,7 @@ public class SwapKey {
      * @param part Part.
      * @param keyBytes Key bytes.
      */
-    public SwapKey(Object key, int part, @Nullable byte[] keyBytes) {
+    public SwapKey(KeyCacheObject key, int part, @Nullable byte[] keyBytes) {
         assert key != null;
         assert part >= 0;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/63a7c54d/modules/core/src/test/java/org/apache/ignite/spi/swapspace/file/GridFileSwapSpaceSpiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/swapspace/file/GridFileSwapSpaceSpiSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/file/GridFileSwapSpaceSpiSelfTest.java
index c7d6899..64652b1 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/swapspace/file/GridFileSwapSpaceSpiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/file/GridFileSwapSpaceSpiSelfTest.java
@@ -28,6 +28,8 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl;
 import org.apache.ignite.internal.util.typedef.CIX1;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiInClosure;
@@ -111,7 +113,7 @@ public class GridFileSwapSpaceSpiSelfTest extends GridSwapSpaceSpiAbstractSelfTe
      * @return Swap key.
      */
     private SwapKey key(int i) {
-        return new SwapKey(i, i % 11, U.intToBytes(i));
+        return new SwapKey(new KeyCacheObjectImpl(i, U.intToBytes(i)), i % 11, U.intToBytes(i));
     }
 
     /**
@@ -354,8 +356,11 @@ public class GridFileSwapSpaceSpiSelfTest extends GridSwapSpaceSpiAbstractSelfTe
 
         assertEquals(cnt, spi.count(space));
 
-        for (Map.Entry<SwapKey, byte[]> entry : map.entrySet())
-            hash1 += (Integer)entry.getKey().key() * Arrays.hashCode(entry.getValue());
+        for (Map.Entry<SwapKey, byte[]> entry : map.entrySet()) {
+            KeyCacheObject key = (KeyCacheObject)entry.getKey().key();
+
+            hash1 += (Integer)key.value(null, false) * Arrays.hashCode(entry.getValue());
+        }
 
         assertEquals(hash0, hash1);
     }


Mime
View raw message