ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkuliche...@apache.org
Subject [2/4] incubator-ignite git commit: IGNITE-471 - Marshalling fixes
Date Fri, 13 Mar 2015 07:16:56 GMT
IGNITE-471 - Marshalling fixes


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

Branch: refs/heads/ignite-471
Commit: e585eaba7dfe567fa4a45fced81006cf0d83738a
Parents: 63ea212
Author: Valentin Kulichenko <vkulichenko@gridgain.com>
Authored: Thu Mar 12 23:52:51 2015 -0700
Committer: Valentin Kulichenko <vkulichenko@gridgain.com>
Committed: Thu Mar 12 23:52:51 2015 -0700

----------------------------------------------------------------------
 .../processors/cache/CacheObjectImpl.java       |   2 +-
 .../processors/cache/GridCacheContext.java      |   2 +-
 .../processors/cache/GridCacheProcessor.java    |   3 +-
 .../processors/cache/GridCacheSwapManager.java  |  12 +-
 .../processors/cache/KeyCacheObjectImpl.java    |   2 +-
 .../distributed/dht/GridDhtLocalPartition.java  |   3 +-
 .../cache/query/GridCacheQueryManager.java      |   2 +-
 ...GridUnsafeDataOutputArraySizingSelfTest.java | 161 -------------------
 .../IgniteMarshallerSelfTestSuite.java          |   2 -
 9 files changed, 14 insertions(+), 175 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e585eaba/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
index ca987ec..7fedb30 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
@@ -77,7 +77,7 @@ public class CacheObjectImpl extends CacheObjectAdapter {
         if (valBytes == null)
             valBytes = ctx.processor().marshal(ctx, val);
 
-        return valBytes.slice();
+        return valBytes.duplicate();
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e585eaba/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 3e752c5..bf7074e 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
@@ -1770,7 +1770,7 @@ public class GridCacheContext<K, V> implements Externalizable
{
      * @return Cache key object.
      * @throws IgniteCheckedException If failed.
      */
-    public KeyCacheObject toCacheKeyObject(ByteBuffer bytes) throws IgniteCheckedException
{
+    public KeyCacheObject bytesToCacheKeyObject(ByteBuffer bytes) throws IgniteCheckedException
{
         Object obj = ctx.cacheObjects().unmarshal(cacheObjCtx, bytes, deploy().localLoader());
 
         return cacheObjects().toCacheKeyObject(cacheObjCtx, obj, false);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e585eaba/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 7deb1fe..48c1f71 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
@@ -51,6 +51,7 @@ import org.jetbrains.annotations.*;
 import javax.cache.configuration.*;
 import javax.cache.integration.*;
 import javax.management.*;
+import java.nio.*;
 import java.util.*;
 
 import static org.apache.ignite.IgniteSystemProperties.*;
@@ -1480,7 +1481,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
             if (qryMgr != null) {
                 try {
-                    KeyCacheObject key = cctx.toCacheKeyObject(keyBytes);
+                    KeyCacheObject key = cctx.bytesToCacheKeyObject(ByteBuffer.wrap(keyBytes));
 
                     qryMgr.remove(key.value(cctx.cacheObjectContext(), false));
                 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e585eaba/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 00e65ae..fa827f7 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(ByteBuffer.wrap(kb)), vb);
+                    writeToSwap(part, cctx.bytesToCacheKeyObject(ByteBuffer.wrap(kb)), vb);
                 }
                 catch (IgniteCheckedException e) {
                     log.error("Failed to unmarshal off-heap entry [part=" + part + ", hash="
+ hash + ']', e);
@@ -822,7 +822,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
                             if (entry == null)
                                 return;
 
-                            KeyCacheObject key = cctx.toCacheKeyObject(swapKey.keyBytes());
+                            KeyCacheObject key = cctx.bytesToCacheKeyObject(ByteBuffer.wrap(swapKey.keyBytes()));
 
                             GridCacheBatchSwapEntry unswapped = new GridCacheBatchSwapEntry(key,
                                 swapKey.partition(),
@@ -1283,7 +1283,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
 
             @Override protected void onRemove() throws IgniteCheckedException {
                 if (offheapFlag) {
-                    KeyCacheObject key = cctx.toCacheKeyObject(cur.getKey());
+                    KeyCacheObject key = cctx.bytesToCacheKeyObject(ByteBuffer.wrap(cur.getKey()));
 
                     int part = cctx.affinity().partition(key);
 
@@ -1411,7 +1411,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
                 cur = new Map.Entry<K, V>() {
                     @Override public K getKey() {
                         try {
-                            KeyCacheObject key = cctx.toCacheKeyObject(ByteBuffer.wrap(cur0.getKey()));
+                            KeyCacheObject key = cctx.bytesToCacheKeyObject(ByteBuffer.wrap(cur0.getKey()));
 
                             return key.value(cctx.cacheObjectContext(), false);
                         }
@@ -1505,7 +1505,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
 
             @Override protected KeyCacheObject onNext() {
                 try {
-                    cur = cctx.toCacheKeyObject(ByteBuffer.wrap(it.next().getKey()));
+                    cur = cctx.bytesToCacheKeyObject(ByteBuffer.wrap(it.next().getKey()));
 
                     return cur;
                 }
@@ -1601,7 +1601,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
             }
 
             @Override protected void onRemove() throws IgniteCheckedException {
-                KeyCacheObject key = cctx.toCacheKeyObject(cur.getKey());
+                KeyCacheObject key = cctx.bytesToCacheKeyObject(ByteBuffer.wrap(cur.getKey()));
 
                 int part = cctx.affinity().partition(key);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e585eaba/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 301cce3..fa218c9 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
@@ -61,7 +61,7 @@ public class KeyCacheObjectImpl extends CacheObjectAdapter implements KeyCacheOb
         if (valBytes == null)
             valBytes = ctx.processor().marshal(ctx, val);
 
-        return valBytes.slice();
+        return valBytes.duplicate();
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e585eaba/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 92c62d7..e4a52c3 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
@@ -32,6 +32,7 @@ import org.apache.ignite.lang.*;
 import org.jdk8.backport.*;
 import org.jetbrains.annotations.*;
 
+import java.nio.*;
 import java.util.*;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.*;
@@ -497,7 +498,7 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>
 
                     byte[] keyBytes = entry.getKey();
 
-                    KeyCacheObject key = cctx.toCacheKeyObject(keyBytes);
+                    KeyCacheObject key = cctx.bytesToCacheKeyObject(ByteBuffer.wrap(keyBytes));
 
                     cctx.swap().remove(key);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e585eaba/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 4fbfe34..e300309 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -2274,7 +2274,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                 if (key != null)
                     return key;
 
-                key = cctx.toCacheKeyObject(keyBytes()).value(cctx.cacheObjectContext(),
false);
+                key = cctx.bytesToCacheKeyObject(keyBytes()).value(cctx.cacheObjectContext(),
false);
 
                 return key;
             }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e585eaba/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutputArraySizingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutputArraySizingSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutputArraySizingSelfTest.java
deleted file mode 100644
index 56ffee4..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutputArraySizingSelfTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * 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.util.io;
-
-import org.apache.ignite.testframework.junits.common.*;
-
-import static org.apache.ignite.IgniteSystemProperties.*;
-
-/**
- * Test for {@link GridUnsafeDataOutput}.
- */
-public class GridUnsafeDataOutputArraySizingSelfTest extends GridCommonAbstractTest {
-    /** Small array. */
-    private static final byte[] SMALL = new byte[32];
-
-    /** Big array. */
-    private static final byte[] BIG = new byte[2048];
-
-    static {
-        System.setProperty(IGNITE_MARSHAL_BUFFERS_RECHECK, "1000");
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    @SuppressWarnings("BusyWait")
-    public void testSmall() throws Exception {
-        GridUnsafeDataOutput out = new GridUnsafeDataOutput(512);
-
-        for (int i = 0; i < 11; i++) {
-            Thread.sleep(100);
-
-            writeSmall(out);
-        }
-
-        assertEquals(256, out.internalArray().length);
-
-        for (int i = 0; i < 11; i++) {
-            Thread.sleep(100);
-
-            writeSmall(out);
-        }
-
-        assertEquals(128, out.internalArray().length);
-
-        for (int i = 0; i < 11; i++) {
-            Thread.sleep(100);
-
-            writeSmall(out);
-        }
-
-        assertEquals(64, out.internalArray().length);
-
-        for (int i = 0; i < 11; i++) {
-            Thread.sleep(100);
-
-            writeSmall(out);
-        }
-
-        assertEquals(64, out.internalArray().length);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testBig() throws Exception {
-        GridUnsafeDataOutput out = new GridUnsafeDataOutput(512);
-
-        writeBig(out);
-
-        assertEquals(4096, out.internalArray().length);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    @SuppressWarnings("BusyWait")
-    public void testChanged1() throws Exception {
-        GridUnsafeDataOutput out = new GridUnsafeDataOutput(512);
-
-        for (int i = 0; i < 100; i++) {
-            Thread.sleep(100);
-
-            writeSmall(out);
-            writeBig(out);
-        }
-
-        assertEquals(4096, out.internalArray().length);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    @SuppressWarnings("BusyWait")
-    public void testChanged2() throws Exception {
-        GridUnsafeDataOutput out = new GridUnsafeDataOutput(512);
-
-        for (int i = 0; i < 11; i++) {
-            Thread.sleep(100);
-
-            writeSmall(out);
-        }
-
-        assertEquals(256, out.internalArray().length);
-
-        writeBig(out);
-
-        assertEquals(4096, out.internalArray().length);
-
-        for (int i = 0; i < 11; i++) {
-            Thread.sleep(100);
-
-            writeSmall(out);
-        }
-
-        assertEquals(4096, out.internalArray().length);
-
-        for (int i = 0; i < 11; i++) {
-            Thread.sleep(100);
-
-            writeSmall(out);
-        }
-
-        assertEquals(2048, out.internalArray().length);
-    }
-
-    /**
-     * @param out Output.
-     * @throws Exception If failed.
-     */
-    private void writeSmall(GridUnsafeDataOutput out) throws Exception {
-        out.write(SMALL);
-
-        out.reset();
-    }
-
-    /**
-     * @param out Output.
-     * @throws Exception If failed.
-     */
-    private void writeBig(GridUnsafeDataOutput out) throws Exception {
-        out.write(BIG);
-
-        out.reset();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e585eaba/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
index f634ec1..df91a98 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.testsuites;
 
 import junit.framework.*;
-import org.apache.ignite.internal.util.io.*;
 import org.apache.ignite.marshaller.jdk.*;
 import org.apache.ignite.marshaller.optimized.*;
 
@@ -38,7 +37,6 @@ public class IgniteMarshallerSelfTestSuite extends TestSuite {
         suite.addTest(new TestSuite(OptimizedMarshallerSelfTest.class));
         suite.addTest(new TestSuite(OptimizedMarshallerTest.class));
         suite.addTest(new TestSuite(OptimizedObjectStreamSelfTest.class));
-        suite.addTest(new TestSuite(GridUnsafeDataOutputArraySizingSelfTest.class));
 
         return suite;
     }


Mime
View raw message