Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-51 99b215a05 -> 736158dac


# ignite-51


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

Branch: refs/heads/ignite-51
Commit: 736158dacc3a20b1925e26d67bcea918e6cc8b78
Parents: 99b215a
Author: sboikov <sboi...@gridgain.com>
Authored: Tue Mar 3 11:37:43 2015 +0300
Committer: sboikov <sboi...@gridgain.com>
Committed: Tue Mar 3 12:10:54 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java      |   2 +-
 .../processors/cache/GridCacheContext.java      |  10 +-
 .../processors/cache/GridCacheProcessor.java    |   2 +-
 .../processors/cache/GridCacheSwapManager.java  |  12 +-
 .../processors/cache/KeyCacheObjectImpl.java    |   5 +-
 .../cache/KeyCacheObjectTransferImpl.java       | 119 +++++++++++++++++++
 .../distributed/dht/GridDhtLocalPartition.java  |   2 +-
 .../preloader/GridDhtPartitionSupplyPool.java   |   1 +
 .../GridCacheValueBytesPreloadingSelfTest.java  |   1 +
 9 files changed, 142 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736158da/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 58e21f5..cd8052d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -963,7 +963,7 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
                 if (peek != null) {
                     CacheObject v = peek.get();
 
-                    Object val0 = v.value(ctx, true);
+                    Object val0 = CU.value(v, ctx, true);
 
                     if (ctx.portableEnabled())
                         val0 = ctx.unwrapPortableIfNeeded(v, 
ctx.keepPortable());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736158da/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index e42cb76..bcf0f0c 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -1800,15 +1800,21 @@ public class GridCacheContext<K, V> implements 
Externalizable {
     /**
      * @param obj Object.
      * @param bytes Key bytes.
+     * @param transferOnly If {@code true} creates temporary object which is 
valid only for marshalling.
      * @return Cache object.
      * @throws IgniteCheckedException If failed.
      */
-    public KeyCacheObject toCacheKeyObject(Object obj, byte[] bytes) throws 
IgniteCheckedException {
+    public KeyCacheObject toCacheKeyObject(Object obj, byte[] bytes, boolean 
transferOnly)
+        throws IgniteCheckedException {
         // TODO IGNITE-51 move to processor.
         assert obj != null || bytes != null;
 
-        if (obj == null)
+        if (obj == null) {
+            if (transferOnly)
+                return new KeyCacheObjectTransferImpl(bytes);
+
             obj = marshaller().unmarshal(bytes, deploy().globalLoader());
+        }
 
         return new KeyCacheObjectImpl(obj, bytes);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736158da/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 48cab9a..92fa623 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -1507,7 +1507,7 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
 
             if (qryMgr != null) {
                 try {
-                    KeyCacheObject key = cctx.toCacheKeyObject(null, keyBytes);
+                    KeyCacheObject key = cctx.toCacheKeyObject(null, keyBytes, 
false);
 
                     qryMgr.remove(key.value(cctx, false));
                 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736158da/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 ef04a8c..6d1ae6f 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
@@ -119,7 +119,7 @@ public class GridCacheSwapManager extends 
GridCacheManagerAdapter {
                     if (!firstEvictWarn)
                         warnFirstEvict();
 
-                    writeToSwap(part, cctx.toCacheKeyObject(null, kb), vb);
+                    writeToSwap(part, cctx.toCacheKeyObject(null, kb, false), 
vb);
                 }
                 catch (IgniteCheckedException e) {
                     log.error("Failed to unmarshal off-heap entry [part=" + 
part + ", hash=" + hash + ']', e);
@@ -841,7 +841,7 @@ public class GridCacheSwapManager extends 
GridCacheManagerAdapter {
                             if (entry == null)
                                 return;
 
-                            KeyCacheObject key = 
cctx.toCacheKeyObject(swapKey.key(), swapKey.keyBytes());
+                            KeyCacheObject key = 
cctx.toCacheKeyObject(swapKey.key(), swapKey.keyBytes(), false);
 
                             GridCacheBatchSwapEntry unswapped = new 
GridCacheBatchSwapEntry(key,
                                 swapKey.partition(),
@@ -1291,7 +1291,7 @@ public class GridCacheSwapManager extends 
GridCacheManagerAdapter {
 
             @Override protected void onRemove() throws IgniteCheckedException {
                 if (offheapFlag) {
-                    KeyCacheObject key = cctx.toCacheKeyObject(null, 
cur.getKey());
+                    KeyCacheObject key = cctx.toCacheKeyObject(null, 
cur.getKey(), false);
 
                     int part = cctx.affinity().partition(key);
 
@@ -1419,7 +1419,7 @@ public class GridCacheSwapManager extends 
GridCacheManagerAdapter {
                 cur = new Map.Entry<K, V>() {
                     @Override public K getKey() {
                         try {
-                            KeyCacheObject key = cctx.toCacheKeyObject(null, 
cur0.getKey());
+                            KeyCacheObject key = cctx.toCacheKeyObject(null, 
cur0.getKey(), false);
 
                             return key.value(cctx, false);
                         }
@@ -1513,7 +1513,7 @@ public class GridCacheSwapManager extends 
GridCacheManagerAdapter {
 
             @Override protected KeyCacheObject onNext() {
                 try {
-                    cur = cctx.toCacheKeyObject(null, it.next().getKey());
+                    cur = cctx.toCacheKeyObject(null, it.next().getKey(), 
false);
 
                     return cur;
                 }
@@ -1611,7 +1611,7 @@ public class GridCacheSwapManager extends 
GridCacheManagerAdapter {
             }
 
             @Override protected void onRemove() throws IgniteCheckedException {
-                KeyCacheObject key = cctx.toCacheKeyObject(cur.getKey(), 
cur.getKey());
+                KeyCacheObject key = cctx.toCacheKeyObject(cur.getKey(), 
cur.getKey(), false);
 
                 int part = cctx.affinity().partition(key);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736158da/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java
index 8ab6dec..9dff5d8 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java
@@ -28,6 +28,9 @@ import java.nio.*;
  *
  */
 public class KeyCacheObjectImpl extends CacheObjectAdapter implements 
KeyCacheObject, Comparable<KeyCacheObjectImpl> {
+    /** */
+    static final int DIRECT_TYPE = 90;
+
     /**
      *
      */
@@ -150,7 +153,7 @@ public class KeyCacheObjectImpl extends CacheObjectAdapter 
implements KeyCacheOb
 
     /** {@inheritDoc} */
     @Override public byte directType() {
-        return 90;
+        return DIRECT_TYPE;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736158da/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectTransferImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectTransferImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectTransferImpl.java
new file mode 100644
index 0000000..267b957
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectTransferImpl.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.*;
+import org.apache.ignite.plugin.extensions.communication.*;
+import org.jetbrains.annotations.*;
+
+import java.nio.*;
+
+/**
+ *
+ */
+public class KeyCacheObjectTransferImpl implements KeyCacheObject {
+    /** */
+    private final byte[] valBytes;
+
+    /**
+     * @param valBytes Value bytes.
+     */
+    public KeyCacheObjectTransferImpl(byte[] valBytes) {
+        assert valBytes != null;
+
+        this.valBytes = valBytes;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean internal() {
+        throw new IllegalStateException();
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public <T> T value(GridCacheContext ctx, boolean cpy) {
+        throw new IllegalStateException();
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public <T> T getField(String name) {
+        throw new IllegalStateException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void prepareMarshal(CacheObjectContext ctx) throws 
IgniteCheckedException {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean byteArray() {
+        throw new IllegalStateException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public byte[] valueBytes(GridCacheContext ctx) throws 
IgniteCheckedException {
+        throw new IllegalStateException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void finishUnmarshal(GridCacheContext ctx, ClassLoader 
ldr) throws IgniteCheckedException {
+        throw new IllegalStateException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheObject prepareForCache(GridCacheContext ctx) {
+        throw new IllegalStateException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
+        writer.setBuffer(buf);
+
+        if (!writer.isHeaderWritten()) {
+            if (!writer.writeHeader(directType(), fieldsCount()))
+                return false;
+
+            writer.onHeaderWritten();
+        }
+
+        switch (writer.state()) {
+            case 0:
+                if (!writer.writeByteArray("valBytes", valBytes))
+                    return false;
+
+                writer.incrementState();
+
+        }
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
+        throw new IllegalStateException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public byte directType() {
+        return KeyCacheObjectImpl.DIRECT_TYPE;
+    }
+
+    /** {@inheritDoc} */
+    @Override public byte fieldsCount() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736158da/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
index 9b34f68..5f0e7b0 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
@@ -497,7 +497,7 @@ public class GridDhtLocalPartition implements 
Comparable<GridDhtLocalPartition>
 
                     byte[] keyBytes = entry.getKey();
 
-                    KeyCacheObject key = cctx.toCacheKeyObject(null, keyBytes);
+                    KeyCacheObject key = cctx.toCacheKeyObject(null, keyBytes, 
false);
 
                     cctx.swap().remove(key);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736158da/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyPool.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyPool.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyPool.java
index 6a3e48d..2131de9 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyPool.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyPool.java
@@ -366,6 +366,7 @@ class GridDhtPartitionSupplyPool<K, V> {
 
                                         GridCacheEntryInfo info = new 
GridCacheEntryInfo();
 
+                                        info.key(cctx.toCacheKeyObject(null, 
e.getKey(), true));
                                         info.ttl(swapEntry.ttl());
                                         
info.expireTime(swapEntry.expireTime());
                                         info.version(swapEntry.version());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736158da/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytesPreloadingSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytesPreloadingSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytesPreloadingSelfTest.java
index f8fa6b8..85bceb4 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytesPreloadingSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytesPreloadingSelfTest.java
@@ -36,6 +36,7 @@ public class GridCacheValueBytesPreloadingSelfTest extends 
GridCommonAbstractTes
     /** Memory mode. */
     private CacheMemoryMode memMode;
 
+    /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 

Reply via email to