ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [30/50] [abbrv] incubator-ignite git commit: # ignite-51
Date Wed, 11 Mar 2015 10:22:12 GMT
# 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/1b54b7f4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/1b54b7f4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/1b54b7f4

Branch: refs/heads/sprint-2
Commit: 1b54b7f452c3bcd600319affc775a891ab68f6a8
Parents: 7719749
Author: sboikov <sboikov@gridgain.com>
Authored: Tue Mar 10 13:16:33 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Tue Mar 10 14:22:50 2015 +0300

----------------------------------------------------------------------
 .../internal/processors/cache/CacheObject.java  |  6 ++
 .../processors/cache/CacheObjectAdapter.java    |  6 --
 .../cache/CacheObjectByteArrayImpl.java         |  2 +-
 .../processors/cache/GridCacheContext.java      |  2 +-
 .../processors/cache/GridCacheMapEntry.java     |  4 +-
 .../processors/cache/GridCacheSwapManager.java  |  4 +-
 .../IgniteCacheObjectProcessorImpl.java         |  7 +-
 .../cache/GridCacheAbstractFullApiSelfTest.java | 87 --------------------
 .../GridCacheOnCopyFlagAbstractSelfTest.java    | 85 +++++++++++++++++++
 9 files changed, 100 insertions(+), 103 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b54b7f4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
index 6db4c84..2f77e86 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
@@ -25,6 +25,12 @@ import org.jetbrains.annotations.*;
  *
  */
 public interface CacheObject extends Message {
+    /** */
+    public static final byte TYPE_REGULAR = 1;
+
+    /** */
+    public static final byte TYPE_BYTE_ARR = 2;
+
     /**
      * @param ctx Context.
      * @param cpy If {@code true} need to copy value.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b54b7f4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
index 923fd6b..173483d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
@@ -30,12 +30,6 @@ import java.nio.*;
  */
 public abstract class CacheObjectAdapter implements CacheObject, Externalizable {
     /** */
-    public static final byte TYPE_REGULAR = 1;
-
-    /** */
-    public static final byte TYPE_BYTE_ARR = 2;
-
-    /** */
     @GridToStringInclude
     @GridDirectTransient
     protected Object val;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b54b7f4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
index 7f92483..333f6dc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
@@ -69,7 +69,7 @@ public class CacheObjectByteArrayImpl implements CacheObject, Externalizable
{
 
     /** {@inheritDoc} */
     @Override public byte type() {
-        return CacheObjectAdapter.TYPE_BYTE_ARR;
+        return TYPE_BYTE_ARR;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b54b7f4/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 51098b2..3d9d8aa 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
@@ -1785,7 +1785,7 @@ public class GridCacheContext<K, V> implements Externalizable
{
     @Nullable public CacheObject unswapCacheObject(byte type, byte[] bytes, @Nullable IgniteUuid
clsLdrId)
         throws IgniteCheckedException
     {
-        if (ctx.config().isPeerClassLoadingEnabled() && type != CacheObjectAdapter.TYPE_BYTE_ARR)
{
+        if (ctx.config().isPeerClassLoadingEnabled() && type != CacheObject.TYPE_BYTE_ARR)
{
             ClassLoader ldr = clsLdrId != null ? deploy().getClassLoader(clsLdrId) : deploy().localLoader();
 
             if (ldr == null)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b54b7f4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 565d8ec..cd02ef2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -212,7 +212,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
                 if (cctx.kernalContext().config().isPeerClassLoadingEnabled()) {
                     Object val0 = null;
 
-                    if (val != null && val.type() != CacheObjectAdapter.TYPE_BYTE_ARR)
{
+                    if (val != null && val.type() != CacheObject.TYPE_BYTE_ARR) {
                         val0 = cctx.cacheObjects().unmarshal(cctx.cacheObjectContext(),
                             val.valueBytes(cctx.cacheObjectContext()), cctx.deploy().globalLoader());
 
@@ -265,7 +265,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
         if (valBytes == null)
             return 0;
 
-        return valBytes.get1().length - (((valBytes.get2() == CacheObjectAdapter.TYPE_BYTE_ARR)
? 0 : 6));
+        return valBytes.get1().length - (((valBytes.get2() == CacheObject.TYPE_BYTE_ARR)
? 0 : 6));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b54b7f4/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 b572ad9..91f9d23 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
@@ -1104,7 +1104,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
             cctx.deploy().globalLoader());
 
         if (cctx.events().isRecordable(EVT_CACHE_OBJECT_SWAPPED))
-            cctx.events().addEvent(part, key, cctx.nodeId(), (IgniteUuid)null, null,
+            cctx.events().addEvent(part, key, cctx.nodeId(), (IgniteUuid) null, null,
                 EVT_CACHE_OBJECT_SWAPPED, null, false, null, true, null, null, null);
     }
 
@@ -1731,7 +1731,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
                             else {
                                 if (valLdrId == null &&
                                     swapEntry.value() == null &&
-                                    swapEntry.type() != CacheObjectAdapter.TYPE_BYTE_ARR)
{
+                                    swapEntry.type() != CacheObject.TYPE_BYTE_ARR) {
                                     // We need value here only for classloading purposes.
                                     Object val =  cctx.cacheObjects().unmarshal(cctx.cacheObjectContext(),
                                         swapEntry.valueBytes(),

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b54b7f4/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index 8f9ce16..c05d343 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -24,7 +24,6 @@ import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.*;
 import org.apache.ignite.internal.processors.cache.*;
-import org.apache.ignite.internal.processors.cacheobject.*;
 import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
@@ -158,7 +157,7 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter
impleme
 
         if (ctx.kernalContext().config().isPeerClassLoadingEnabled() &&
             ctx.offheapTiered() &&
-            type != CacheObjectAdapter.TYPE_BYTE_ARR) {
+            type != CacheObject.TYPE_BYTE_ARR) {
             IgniteUuid valClsLdrId = U.readGridUuid(valPtr + 5 + size);
 
             ClassLoader ldr =
@@ -173,10 +172,10 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter
impleme
     /** {@inheritDoc} */
     @Override public CacheObject toCacheObject(CacheObjectContext ctx, byte type, byte[]
bytes) {
         switch (type) {
-            case CacheObjectAdapter.TYPE_BYTE_ARR:
+            case CacheObject.TYPE_BYTE_ARR:
                 return new CacheObjectByteArrayImpl(bytes);
 
-            case CacheObjectAdapter.TYPE_REGULAR:
+            case CacheObject.TYPE_REGULAR:
                 return new CacheObjectImpl(null, bytes);
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b54b7f4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 28b2b59..42dc850 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -3929,93 +3929,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
     }
 
     /**
-     *
-     */
-    public void _testCopyOnGet() {
-        IgniteCache<Integer, TestMutableObj> mutObjCache = ignite(0).jcache(null);
-        IgniteCache<Integer, TestImmutableObj> immObjCache = ignite(0).jcache(null);
-
-        CacheConfiguration cfg = mutObjCache.getConfiguration(CacheConfiguration.class);
-
-        boolean cpyOnGet = cfg.isCopyOnGet();
-
-        CacheAffinity<Integer> aff = ignite(0).affinity(null);
-
-        boolean near = cfg.getDistributionMode() == CacheDistributionMode.NEAR_PARTITIONED
||
-            cfg.getDistributionMode() == CacheDistributionMode.NEAR_ONLY;
-
-        ClusterNode locNode = ignite(0).cluster().localNode();
-
-        for (int i = 0; i < 100; i++) {
-            boolean primary = aff.isPrimary(locNode, i);
-            boolean backup = aff.isBackup(locNode, i);
-            boolean loc = near || primary || backup;
-
-            TestMutableObj putObj0 = new TestMutableObj(i);
-
-            mutObjCache.put(i, putObj0);
-
-            TestMutableObj getObj0 = mutObjCache.get(i);
-
-            assertEquals(i, getObj0.val);
-
-            if (!cpyOnGet && loc)
-                assertSame(putObj0, getObj0);
-            else
-                assertNotSame(putObj0, getObj0);
-
-            TestImmutableObj putObj1 = new TestImmutableObj(i);
-
-            immObjCache.put(i, putObj1);
-
-            TestImmutableObj getObj1 = immObjCache.get(i);
-
-            assertEquals(i, getObj1.val);
-
-            if (loc && !offHeapValues())
-                assertSame("Same expected [key=" + i + ", primary=" + primary + ", backup="
+ backup + ']',
-                    putObj1,
-                    getObj1);
-            else
-                assertNotSame(
-                        "Not same expected [key=" + i + ", primary=" + primary + ", backup="
+ backup + ']',
-                        putObj1,
-                        getObj1);
-        }
-    }
-
-    /**
-     *
-     */
-    public static class TestMutableObj {
-       /** */
-       public int val;
-
-        /**
-         * @param val Value.
-         */
-        public TestMutableObj(int val) {
-            this.val = val;
-        }
-    }
-
-    /**
-     *
-     */
-    @IgniteImmutable
-    public static class TestImmutableObj {
-       /** */
-       public int val;
-
-        /**
-         * @param val Value.
-         */
-        public TestImmutableObj(int val) {
-            this.val = val;
-        }
-    }
-
-    /**
      * If hasNext() is called repeatedly, it should return the same result.
      */
     private void checkIteratorHasNext() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b54b7f4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
index 4042546..3d03d72 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
@@ -353,6 +353,54 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testPutGetImmutable() throws Exception {
+        noInterceptor = true;
+
+        IgniteCache<TestImmutableKey, TestImmutableValue> cache = grid(0).jcache(null);
+
+        Map<TestImmutableKey, TestImmutableValue> map = new HashMap<>();
+
+        for (int i = 0; i < ITER_CNT; i++) {
+            TestImmutableKey key = new TestImmutableKey(i, i);
+            TestImmutableValue val = new TestImmutableValue(i);
+
+            cache.put(key, val);
+
+            map.put(key, val);
+        }
+
+        GridCacheAdapter cache0 = internalCache(cache);
+
+        GridCacheContext cctx = cache0.context();
+
+        for (Map.Entry<TestImmutableKey, TestImmutableValue> e : map.entrySet()) {
+            GridCacheEntryEx entry = cache0.peekEx(e.getKey());
+
+            assertNotNull("No entry for key: " + e.getKey(), entry);
+
+            TestKey key0 = entry.key().value(cctx.cacheObjectContext(), false);
+
+            assertSame(key0, e.getKey());
+
+            TestKey key1 = entry.key().value(cctx.cacheObjectContext(), true);
+
+            assertSame(key0, key1);
+
+            TestImmutableValue val0 = entry.rawGet().value(cctx.cacheObjectContext(), false);
+
+            assertSame(val0, e.getValue());
+
+            TestImmutableValue val1 = entry.rawGet().value(cctx.cacheObjectContext(), true);
+
+            assertSame(val0, val1);
+
+            assertSame(e.getValue(), cache.get(e.getKey()));
+        }
+    }
+
+    /**
      *
      */
     public static class TestKey implements Externalizable {
@@ -552,4 +600,41 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
             this.delegate = delegate;
         }
     }
+
+    /**
+     *
+     */
+    @IgniteImmutable
+    public static class TestImmutableKey extends TestKey {
+        /**
+         *
+         */
+        public TestImmutableKey() {
+            // No-op.
+        }
+
+        /**
+         * @param key Key.
+         * @param field Field.
+         */
+        public TestImmutableKey(int key, int field) {
+            super(key, field);
+        }
+    }
+
+    /**
+     *
+     */
+    @IgniteImmutable
+    public static class TestImmutableValue {
+        /** */
+        public int val;
+
+        /**
+         * @param val Value.
+         */
+        public TestImmutableValue(int val) {
+            this.val = val;
+        }
+    }
 }


Mime
View raw message