ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject ignite git commit: Fixing binary objects tests.
Date Fri, 27 Nov 2015 15:35:10 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1.5 f3cb64e37 -> 292de51c7


Fixing binary objects tests.


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

Branch: refs/heads/ignite-1.5
Commit: 292de51c75dfd696459ef6569ee49beb8e7b10ec
Parents: f3cb64e
Author: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Authored: Fri Nov 27 18:34:56 2015 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Fri Nov 27 18:34:56 2015 +0300

----------------------------------------------------------------------
 .../ignite/cache/CacheKeyConfiguration.java     |  19 ++
 .../internal/portable/BinaryObjectExImpl.java   |   5 +-
 .../portable/PortableClassDescriptor.java       |   3 +-
 .../processors/cache/CacheLazyEntry.java        |   2 +-
 .../processors/cache/GridCacheAdapter.java      |   2 +-
 .../processors/cache/GridCacheContext.java      |  12 +-
 .../dht/atomic/GridDhtAtomicCache.java          |   4 +-
 .../distributed/near/GridNearGetFuture.java     |   4 +-
 .../GridCacheInternalKeyImpl.java               |   2 +-
 .../portable/BinaryMarshallerSelfTest.java      |  64 ++++++
 ...niteCacheCopyOnReadDisabledAbstractTest.java |   2 +
 .../dht/GridCacheDhtInternalEntrySelfTest.java  | 203 -------------------
 .../near/GridCacheNearTxForceKeyTest.java       |   2 +-
 ...achePartitionedPreloadLifecycleSelfTest.java |  71 ++++---
 .../testsuites/IgniteCacheTestSuite2.java       |   2 -
 15 files changed, 147 insertions(+), 250 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/292de51c/modules/core/src/main/java/org/apache/ignite/cache/CacheKeyConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheKeyConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/cache/CacheKeyConfiguration.java
index 767b44c..f117847 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheKeyConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheKeyConfiguration.java
@@ -18,6 +18,8 @@
 package org.apache.ignite.cache;
 
 import java.io.Serializable;
+import java.lang.reflect.Field;
+import org.apache.ignite.cache.affinity.AffinityKeyMapped;
 import org.apache.ignite.internal.util.typedef.internal.S;
 
 /**
@@ -41,6 +43,23 @@ public class CacheKeyConfiguration implements Serializable {
     }
 
     /**
+     * @param keyCls Key class.
+     */
+    public CacheKeyConfiguration(Class keyCls) {
+        typeName = keyCls.getName();
+
+        for (; keyCls != Object.class && keyCls != null; keyCls = keyCls.getSuperclass())
{
+            for (Field f : keyCls.getDeclaredFields()) {
+                if (f.getAnnotation(AffinityKeyMapped.class) != null) {
+                    affKeyFieldName = f.getName();
+
+                    return;
+                }
+            }
+        }
+    }
+
+    /**
      * Creates cache key configuration with given type name and affinity field name.
      *
      * @param typeName Type name.

http://git-wip-us.apache.org/repos/asf/ignite/blob/292de51c/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectExImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectExImpl.java
index 2ea71ec..a32329a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectExImpl.java
@@ -164,6 +164,7 @@ public abstract class BinaryObjectExImpl implements BinaryObjectEx {
      */
     private String toString(BinaryReaderHandles ctx, IdentityHashMap<BinaryObject, Integer>
handles) {
         int idHash = System.identityHashCode(this);
+        int hash = hashCode();
 
         BinaryType meta;
 
@@ -175,14 +176,14 @@ public abstract class BinaryObjectExImpl implements BinaryObjectEx {
         }
 
         if (meta == null)
-            return BinaryObject.class.getSimpleName() +  " [hash=" + idHash + ", typeId="
+ typeId() + ']';
+            return BinaryObject.class.getSimpleName() +  " [idHash=" + idHash + ", hash="
+ hash + ", typeId=" + typeId() + ']';
 
         handles.put(this, idHash);
 
         SB buf = new SB(meta.typeName());
 
         if (meta.fieldNames() != null) {
-            buf.a(" [hash=").a(idHash);
+            buf.a(" [idHash=").a(idHash).a(", hash=").a(hash);
 
             for (String name : meta.fieldNames()) {
                 Object val = field(ctx, name);

http://git-wip-us.apache.org/repos/asf/ignite/blob/292de51c/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index dba15f5..984f7c9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@ -249,7 +249,8 @@ public class PortableClassDescriptor {
                             String name = f.getName();
 
                             if (!names.add(name))
-                                throw new BinaryObjectException("Duplicate field name: "
+ name);
+                                throw new BinaryObjectException("Duplicate field name [fieldName="
+ name +
+                                    ", cls=" + cls.getName() + ']');
 
                             int fieldId = idMapper.fieldId(typeId, name);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/292de51c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
index 47ad30c..2b9efa3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
@@ -103,7 +103,7 @@ public class CacheLazyEntry<K, V> implements Cache.Entry<K, V>
{
     /** {@inheritDoc} */
     @Override public V getValue() {
         if (val == null)
-            val = (V)cctx.unwrapPortableIfNeeded(valObj, keepPortable);
+            val = (V)cctx.unwrapPortableIfNeeded(valObj, keepPortable, false);
 
         return val;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/292de51c/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 00f65f9..b5b8690 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
@@ -799,7 +799,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
             else
                 cacheVal = localCachePeek0(cacheKey, modes.heap, modes.offheap, modes.swap,
plc);
 
-            Object val = ctx.unwrapPortableIfNeeded(cacheVal, ctx.keepPortable());
+            Object val = ctx.unwrapPortableIfNeeded(cacheVal, ctx.keepPortable(), false);
 
             return (V)val;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/292de51c/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 73d966a..6e5f958 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
@@ -1743,12 +1743,22 @@ public class GridCacheContext<K, V> implements Externalizable
{
      * @param keepPortable Keep portable flag.
      * @return Unwrapped object.
      */
-    @SuppressWarnings("IfMayBeConditional")
     public Object unwrapPortableIfNeeded(Object o, boolean keepPortable) {
         return cacheObjCtx.unwrapPortableIfNeeded(o, keepPortable);
     }
 
     /**
+     * Unwraps object for binary.
+     *
+     * @param o Object to unwrap.
+     * @param keepPortable Keep portable flag.
+     * @return Unwrapped object.
+     */
+    public Object unwrapPortableIfNeeded(Object o, boolean keepPortable, boolean cpy) {
+        return cacheObjCtx.unwrapPortableIfNeeded(o, keepPortable, cpy);
+    }
+
+    /**
      * @return Cache object context.
      */
     public CacheObjectContext cacheObjectContext() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/292de51c/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 028f477..8fe1b3a 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
@@ -781,7 +781,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
 
                         if (invokeRes.result() != null)
                             res = CacheInvokeResult.fromResult((T)ctx.unwrapPortableIfNeeded(invokeRes.result(),
-                                keepBinary));
+                                keepBinary, false));
                     }
 
                     return res;
@@ -834,7 +834,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
 
                                 if (invokeRes.result() != null)
                                     res = CacheInvokeResult.fromResult((T)ctx.unwrapPortableIfNeeded(invokeRes.result(),
-                                        keepBinary));
+                                        keepBinary, false));
                             }
 
                             return res;

http://git-wip-us.apache.org/repos/asf/ignite/blob/292de51c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
index 2ea31d5..3f61b2f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
@@ -542,9 +542,9 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
                             add(new GridFinishedFuture<>(Collections.singletonMap(key0,
val0)));
                         }
                         else {
-                            K key0 = (K)cctx.unwrapPortableIfNeeded(key, !deserializePortable);
+                            K key0 = (K)cctx.unwrapPortableIfNeeded(key, !deserializePortable,
false);
                             V val0 = !skipVals ? 
-                                (V)cctx.unwrapPortableIfNeeded(v, !deserializePortable) :

+                                (V)cctx.unwrapPortableIfNeeded(v, !deserializePortable, false)
:
                                 (V)Boolean.TRUE;
 
                             add(new GridFinishedFuture<>(Collections.singletonMap(key0,
val0)));

http://git-wip-us.apache.org/repos/asf/ignite/blob/292de51c/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheInternalKeyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheInternalKeyImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheInternalKeyImpl.java
index ff07754..6031f5e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheInternalKeyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheInternalKeyImpl.java
@@ -34,6 +34,7 @@ public class GridCacheInternalKeyImpl implements GridCacheInternalKey, Externali
     private static final long serialVersionUID = 0L;
 
     /** Name of cache data structure. */
+    @AffinityKeyMapped
     private String name;
 
     /**
@@ -55,7 +56,6 @@ public class GridCacheInternalKeyImpl implements GridCacheInternalKey, Externali
     }
 
     /** {@inheritDoc} */
-    @AffinityKeyMapped
     @Override public String name() {
         return name;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/292de51c/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
index 9f7822c..ad0dcf2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
@@ -17,6 +17,10 @@
 
 package org.apache.ignite.internal.portable;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import junit.framework.Assert;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.binary.BinaryIdMapper;
@@ -364,6 +368,23 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
     /**
      * @throws Exception If failed.
      */
+    public void testExternalizableHashCode() throws Exception {
+        SimpleExternalizable sim1 = new SimpleExternalizable("Simple");
+        SimpleExternalizable sim2 = new SimpleExternalizable("Simple");
+
+        BinaryMarshaller marsh = binaryMarshaller();
+
+        BinaryObjectImpl sim1Binary = marshal(sim1, marsh);
+        BinaryObjectImpl sim2Binary = marshal(sim2, marsh);
+
+        assertEquals(sim1.hashCode(), sim2.hashCode());
+        assertEquals(sim1.hashCode(), sim1Binary.hashCode());
+        assertEquals(sim2.hashCode(), sim2Binary.hashCode());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testMapEntry() throws Exception {
         Map.Entry<Integer, String> e = new GridMapEntry<>(1, "str1");
 
@@ -3621,6 +3642,49 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
     /**
      *
      */
+    public static class SimpleExternalizable implements Externalizable {
+        /** */
+        private String field;
+
+        /**
+         * @param field Field.
+         */
+        public SimpleExternalizable(String field) {
+            this.field = field;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(ObjectOutput out) throws IOException {
+            U.writeString(out, field);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
+            field = U.readString(in);
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+
+            if (o == null || getClass() != o.getClass())
+                return false;
+
+            SimpleExternalizable that = (SimpleExternalizable)o;
+
+            return field.equals(that.field);
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return field.hashCode();
+        }
+    }
+
+    /**
+     *
+     */
     private static class ParentPortable {
         /** */
         public String s;

http://git-wip-us.apache.org/repos/asf/ignite/blob/292de51c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCopyOnReadDisabledAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCopyOnReadDisabledAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCopyOnReadDisabledAbstractTest.java
index 1c08c0e..a3b362b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCopyOnReadDisabledAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCopyOnReadDisabledAbstractTest.java
@@ -57,6 +57,8 @@ public abstract class IgniteCacheCopyOnReadDisabledAbstractTest extends
GridCach
 
             TestValue val0 = cache.get(key);
 
+            assertSame(val0, cache.get(key));
+
             assertNotSame(val, val0); // Original user value is always copied.
 
             assertSame(val0, cache.localPeek(key));

http://git-wip-us.apache.org/repos/asf/ignite/blob/292de51c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtInternalEntrySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtInternalEntrySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtInternalEntrySelfTest.java
deleted file mode 100644
index 0f4fe5d..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtInternalEntrySelfTest.java
+++ /dev/null
@@ -1,203 +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.processors.cache.distributed.dht;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
-import org.apache.ignite.cache.affinity.Affinity;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.NearCacheConfiguration;
-import org.apache.ignite.internal.processors.cache.GridCacheAlwaysEvictionPolicy;
-import org.apache.ignite.internal.processors.datastructures.GridCacheInternalKeyImpl;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-import static org.apache.ignite.cache.CacheMode.PARTITIONED;
-import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
-
-/**
- * Tests for internal DHT entry.
- */
-public class GridCacheDhtInternalEntrySelfTest extends GridCommonAbstractTest {
-    /** IP finder. */
-    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
-    /** Grid count. */
-    private static final int GRID_CNT = 2;
-
-    /** Atomic long name. */
-    private static final String ATOMIC_LONG_NAME = "test.atomic.long";
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        TcpDiscoverySpi spi = new TcpDiscoverySpi();
-
-        spi.setIpFinder(IP_FINDER);
-
-        cfg.setDiscoverySpi(spi);
-
-        CacheConfiguration cacheCfg = defaultCacheConfiguration();
-
-        cacheCfg.setCacheMode(PARTITIONED);
-        cacheCfg.setRebalanceMode(SYNC);
-        cacheCfg.setAffinity(new RendezvousAffinityFunction(false, 2));
-        cacheCfg.setBackups(0);
-        cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-
-        NearCacheConfiguration nearCfg = new NearCacheConfiguration();
-        nearCfg.setNearEvictionPolicy(new GridCacheAlwaysEvictionPolicy());
-        cacheCfg.setNearConfiguration(nearCfg);
-
-        cacheCfg.setAtomicityMode(TRANSACTIONAL);
-
-        cfg.setCacheConfiguration(cacheCfg);
-
-        return cfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        startGridsMultiThreaded(GRID_CNT);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTestsStopped() throws Exception {
-        stopAllGrids();
-    }
-
-    /** @throws Exception If failed. */
-    public void testInternalKeyReaders() throws Exception {
-        IgniteBiTuple<ClusterNode, ClusterNode> nodes = getNodes(ATOMIC_LONG_NAME);
-
-        ClusterNode primary = nodes.get1();
-        ClusterNode other = nodes.get2();
-
-        // Create on non-primary node.
-        grid(other).cache(null).put(new GridCacheInternalKeyImpl(ATOMIC_LONG_NAME), 1);
-
-        check(primary, other, true);
-
-        // Update on primary.
-        grid(primary).cache(null).put(new GridCacheInternalKeyImpl(ATOMIC_LONG_NAME), 2);
-
-        // Check on non-primary.
-        assertEquals(2, grid(other).cache(null).get(new GridCacheInternalKeyImpl(ATOMIC_LONG_NAME)));
-
-        check(primary, other, true);
-
-        // Remove.
-        assert grid(other).cache(null).remove(new GridCacheInternalKeyImpl(ATOMIC_LONG_NAME));
-
-        check(primary, other, false);
-    }
-
-    /**
-     * @param primary Primary node.
-     * @param other Non-primary node.
-     * @param exists Whether entry is expected to exist.
-     * @throws Exception In case of error.
-     */
-    private void check(ClusterNode primary, ClusterNode other, boolean exists) throws Exception
{
-        if (exists) {
-            // Check primary node has entry in DHT cache.
-            assert peekNear(primary) == null;
-            assert peekDht(primary) != null;
-
-            // Check non-primary node has entry in near cache.
-            assert peekNear(other) != null;
-            assert peekDht(other) == null;
-
-            // Check primary node has reader for non-primary node.
-            assert peekDhtEntry(primary).readers().contains(other.id());
-        }
-        else {
-            assert peekGlobal(primary) == null;
-            assert peekGlobal(other) == null;
-        }
-    }
-
-    /**
-     * @param node Node.
-     * @return Atomic long value.
-     */
-    private Object peekGlobal(ClusterNode node) {
-        return grid(node).cache(null).localPeek(new GridCacheInternalKeyImpl(ATOMIC_LONG_NAME),
CachePeekMode.ONHEAP);
-    }
-
-    /**
-     * @param node Node.
-     * @return Atomic long value.
-     */
-    private Object peekNear(ClusterNode node) {
-        return grid(node).cache(null).localPeek(new GridCacheInternalKeyImpl(ATOMIC_LONG_NAME),
CachePeekMode.NEAR);
-    }
-
-    /**
-     * @param node Node.
-     * @return Atomic long value.
-     */
-    private Object peekDht(ClusterNode node) {
-        return grid(node).cache(null).localPeek(new GridCacheInternalKeyImpl(ATOMIC_LONG_NAME),
CachePeekMode.BACKUP,
-            CachePeekMode.PRIMARY);
-    }
-
-    /**
-     * @param node Node.
-     * @return DHT entry.
-     */
-    private GridDhtCacheEntry peekDhtEntry(ClusterNode node) {
-        return (GridDhtCacheEntry)dht(grid(node).cache(null)).peekEx(
-            new GridCacheInternalKeyImpl(ATOMIC_LONG_NAME));
-    }
-
-    /**
-     * @param key Key.
-     * @return Pair {primary node, some other node}.
-     */
-    private IgniteBiTuple<ClusterNode, ClusterNode> getNodes(String key) {
-        Affinity<Object> aff = grid(0).affinity(null);
-
-        ClusterNode primary = aff.mapKeyToNode(key);
-
-        assert primary != null;
-
-        Collection<ClusterNode> nodes = new ArrayList<>(grid(0).cluster().nodes());
-
-        nodes.remove(primary);
-
-        ClusterNode other = F.first(nodes);
-
-        assert other != null;
-
-        assert !F.eqNodes(primary, other);
-
-        return F.t(primary, other);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/292de51c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxForceKeyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxForceKeyTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxForceKeyTest.java
index 348597e..84886d3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxForceKeyTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxForceKeyTest.java
@@ -70,7 +70,7 @@ public class GridCacheNearTxForceKeyTest extends GridCommonAbstractTest
{
 
         Ignite ignite1 = startGrid(1);
 
-        final Integer key = 2;
+        final Integer key = primaryKey(ignite1.cache(null));
 
         assertNull(cache.getAndPut(key, key));
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/292de51c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java
index ca4f24e..e434b49 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java
@@ -182,39 +182,7 @@ public class GridCachePartitionedPreloadLifecycleSelfTest extends GridCachePrelo
 
                 CacheQuery<Map.Entry<Object, MyValue>> qry = c2.context().queries().createScanQuery(null,
null, false);
 
-                int totalCnt = F.sumInt(qry.execute(new IgniteReducer<Map.Entry<Object,
MyValue>, Integer>() {
-                    @IgniteInstanceResource
-                    private Ignite grid;
-
-                    private int cnt;
-
-                    @Override public boolean collect(Map.Entry<Object, MyValue> e)
{
-                        Object key = e.getKey();
-
-                        assertNotNull(e.getValue());
-
-                        try {
-                            Object v1 = e.getValue();
-                            Object v2 = grid.cache("one").get(key);
-
-                            assertNotNull(v2);
-                            assertEquals(v1, v2);
-                        }
-                        catch (CacheException e1) {
-                            e1.printStackTrace();
-
-                            assert false;
-                        }
-
-                        cnt++;
-
-                        return true;
-                    }
-
-                    @Override public Integer reduce() {
-                        return cnt;
-                    }
-                }).get());
+                int totalCnt = F.sumInt(qry.execute(new EntryIntegerIgniteReducer()).get());
 
                 info("Total entry count [grid=" + j + ", totalCnt=" + totalCnt + ']');
 
@@ -278,4 +246,41 @@ public class GridCachePartitionedPreloadLifecycleSelfTest extends GridCachePrelo
     public void testScanQuery4() throws Exception {
         checkScanQuery(keys(false, 500));
     }
+
+    /**
+     *
+     */
+    private static class EntryIntegerIgniteReducer implements IgniteReducer<Map.Entry<Object,
MyValue>, Integer> {
+        @IgniteInstanceResource
+        private Ignite grid;
+
+        private int cnt;
+
+        @Override public boolean collect(Map.Entry<Object, MyValue> e) {
+            Object key = e.getKey();
+
+            assertNotNull(e.getValue());
+
+            try {
+                Object v1 = e.getValue();
+                Object v2 = grid.cache("one").get(key);
+
+                assertNotNull(v2);
+                assertEquals(v1, v2);
+            }
+            catch (CacheException e1) {
+                e1.printStackTrace();
+
+                assert false;
+            }
+
+            cnt++;
+
+            return true;
+        }
+
+        @Override public Integer reduce() {
+            return cnt;
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/292de51c/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
index 5138dac..74b688f 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
@@ -53,7 +53,6 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtE
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtEvictionSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtEvictionsDisabledSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtExpiredEntriesPreloadSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtInternalEntrySelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtMappingSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtPreloadBigDataSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtPreloadDelayedSelfTest;
@@ -188,7 +187,6 @@ public class IgniteCacheTestSuite2 extends TestSuite {
         suite.addTest(new TestSuite(GridCachePartitionedTxTimeoutSelfTest.class));
         suite.addTest(new TestSuite(GridCacheFinishPartitionsSelfTest.class));
         suite.addTest(new TestSuite(GridCacheDhtEntrySelfTest.class));
-        suite.addTest(new TestSuite(GridCacheDhtInternalEntrySelfTest.class));
         suite.addTest(new TestSuite(GridCacheDhtMappingSelfTest.class));
         suite.addTest(new TestSuite(GridCachePartitionedTxMultiThreadedSelfTest.class));
         suite.addTest(new TestSuite(GridCachePartitionedNearDisabledTxMultiThreadedSelfTest.class));


Mime
View raw message