ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [66/92] [abbrv] incubator-ignite git commit: IGNITE-51 Fix review notes.
Date Fri, 06 Mar 2015 10:14:42 GMT
IGNITE-51 Fix review notes.


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

Branch: refs/heads/ignite-user-req
Commit: 9b92c3db3da5bda5c791710190e3c762e2422a85
Parents: 8d9724e
Author: nikolay_tikhonov <ntikhonov@gridgain.com>
Authored: Thu Mar 5 15:30:03 2015 +0300
Committer: nikolay_tikhonov <ntikhonov@gridgain.com>
Committed: Thu Mar 5 16:30:51 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/cache/CacheInterceptor.java   |   1 +
 .../processors/cache/CacheInvokeEntry.java      |   8 +-
 .../processors/cache/CacheLazyEntry.java        |   2 +-
 .../processors/cache/GridCacheMapEntry.java     |  22 +---
 .../dht/atomic/GridDhtAtomicCache.java          |  11 +-
 .../local/atomic/GridLocalAtomicCache.java      |  19 +--
 .../cache/transactions/IgniteTxAdapter.java     |   1 +
 .../transactions/IgniteTxLocalAdapter.java      |  10 +-
 .../GridCacheOnCopyFlagAbstractSelfTest.java    | 128 +------------------
 9 files changed, 33 insertions(+), 169 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b92c3db/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
index e10fc38..2484cb3 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.cache;
 
+import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.lang.*;
 import org.jetbrains.annotations.*;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b92c3db/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
index a49a67e..a0297a9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
@@ -32,7 +32,7 @@ public class CacheInvokeEntry<K, V> extends CacheLazyEntry<K, V>
implements Muta
     private Operation op = Operation.NONE;
 
     /** */
-    private V originVal;
+    private V oldVal;
 
     /**
      * @param cctx Cache context.
@@ -80,7 +80,7 @@ public class CacheInvokeEntry<K, V> extends CacheLazyEntry<K, V>
implements Muta
         if (val == null)
             throw new NullPointerException();
 
-        this.originVal = val;
+        this.oldVal = this.val;
 
         this.val = val;
 
@@ -90,8 +90,8 @@ public class CacheInvokeEntry<K, V> extends CacheLazyEntry<K, V>
implements Muta
     /**
      * @return Return origin value, before modification.
      */
-    public V originVal() {
-        return originVal == null ? val : originVal;
+    public V oldVal() {
+        return oldVal == null ? val : oldVal;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b92c3db/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 34a6001..a2b0bff 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
@@ -104,7 +104,7 @@ public class CacheLazyEntry<K, V> implements Cache.Entry<K, V>
{
     /**
      * @return Return value. This methods doesn't initialize value.
      */
-    public V val() {
+    public V value() {
         return val;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b92c3db/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 c4ffd0e..48462f0 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
@@ -966,8 +966,8 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
 
         boolean intercept = cctx.config().getInterceptor() != null;
 
+        Object key0 = null;
         Object val0 = null;
-        Object keyVal = null;
 
         synchronized (this) {
             checkObsolete();
@@ -1001,7 +1001,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx
{
                 Object interceptorVal = cctx.config().getInterceptor().onBeforePut(new CacheLazyEntry(cctx,
key, old),
                     val0);
 
-                keyVal = e.key();
+                key0 = e.key();
 
                 if (interceptorVal == null)
                     return new GridCacheUpdateTxResult(false, (CacheObject)cctx.unwrapTemporary(old));
@@ -1083,7 +1083,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx
{
             cctx.store().putToStore(tx, key, val, newVer);
 
         if (intercept)
-            cctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(cctx, key, keyVal,
val, val0));
+            cctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(cctx, key, key0,
val, val0));
 
         return valid ? new GridCacheUpdateTxResult(true, retval ? old : null) :
             new GridCacheUpdateTxResult(false, null);
@@ -1395,15 +1395,10 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx
{
                         updated0 = cctx.unwrapTemporary(entry.getValue());
 
                         updated = cctx.toCacheObject(updated0);
-
-                        old0 = entry.originVal();
                     }
-                    else {
+                    else
                         updated = old;
 
-                        old0 = entry.val();
-                    }
-
                     key0 = entry.key();
 
                     invokeRes = computed != null ? new CacheInvokeResult<>(cctx.unwrapTemporary(computed))
: null;
@@ -1454,7 +1449,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx
{
                 }
 
                 key0 = e.key();
-                old0 = e.val();
+                old0 = e.value();
             }
 
             boolean hadVal = hasValueUnlocked();
@@ -1855,15 +1850,10 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx
{
                     if (entry.modified()) {
                         updated0 = cctx.unwrapTemporary(entry.getValue());
                         updated = cctx.toCacheObject(updated0);
-
-                        old0 = entry.originVal();
                     }
-                    else {
+                    else
                         updated = oldVal;
 
-                        old0 = entry.val();
-                    }
-
                     key0 = entry.key();
 
                     if (computed != null)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b92c3db/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 9c627ec..7626a7d 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
@@ -1334,16 +1334,9 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
                     try {
                         Object computed = entryProcessor.process(invokeEntry, req.invokeArguments());
 
-                        if (invokeEntry.modified()) {
-                            updatedVal = ctx.unwrapTemporary(invokeEntry.getValue());
+                        updatedVal = ctx.unwrapTemporary(invokeEntry.getValue());
 
-                            updated = ctx.toCacheObject(updatedVal);
-                        }
-                        else {
-                            updated = old;
-
-                            oldVal = updatedVal = CU.value(old, ctx, false);
-                        }
+                        updated = ctx.toCacheObject(updatedVal);
 
                         if (computed != null)
                             invokeRes = new CacheInvokeDirectResult(entry.key(),

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b92c3db/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
index 0d47f63..4a1db42 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -1145,18 +1145,9 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K,
V> {
                         try {
                             Object computed = entryProcessor.process(invokeEntry, invokeArgs);
 
-                            if (invokeEntry.modified()) {
-                                updated = ctx.toCacheObject(updatedVal);
+                            updatedVal = ctx.unwrapTemporary(invokeEntry.getValue());
 
-                                oldVal = invokeEntry.originVal();
-
-                                updatedVal = ctx.unwrapTemporary(invokeEntry.getValue());
-                            }
-                            else {
-                                updated = old;
-
-                                updatedVal = oldVal = CU.value(old, ctx, false);
-                            }
+                            updated = ctx.toCacheObject(updatedVal);
 
                             if (computed != null)
                                 invokeRes = new CacheInvokeResult<>(ctx.unwrapTemporary(computed));
@@ -1206,8 +1197,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K,
V> {
                         else {
                             if (intercept) {
                                 Object interceptorVal = ctx.config().getInterceptor()
-                                        .onBeforePut(new CacheLazyEntry(ctx, entry.key(),
invokeEntry.getKey(),
-                                                old, oldVal), updatedVal);
+                                    .onBeforePut(new CacheLazyEntry(ctx, entry.key(), invokeEntry.getKey(),
+                                        old, oldVal), updatedVal);
 
                                 if (interceptorVal == null)
                                     continue;
@@ -1287,7 +1278,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K,
V> {
                                 null);
 
                             IgniteBiTuple<Boolean, ?> interceptorRes = ctx.config().getInterceptor()
-                                    .onBeforeRemove(new CacheLazyEntry(ctx, entry.key(),
old));
+                                .onBeforeRemove(new CacheLazyEntry(ctx, entry.key(), old));
 
                             if (ctx.cancelRemove(interceptorRes))
                                 continue;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b92c3db/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index ada429b..11a5eb5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -1226,6 +1226,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
                 boolean modified = false;
 
                 Object val = null;
+
                 Object key = null;
 
                 for (T2<EntryProcessor<Object, Object, Object>, Object[]> t :
txEntry.entryProcessors()) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b92c3db/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index c56220c..27fcc55 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -2476,11 +2476,17 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
 
                 res = entryProcessor.process(invokeEntry, t.get2());
 
-                val = invokeEntry.val();
+                val = invokeEntry.value();
+
+                keyVal = invokeEntry.key();
             }
 
-            if (res != null)
+            if (res != null) {
+                if (keyVal == null)
+                    keyVal = txEntry.key().value(ctx.cacheObjectContext(), true);
+                
                 ret.addEntryProcessResult(keyVal, new CacheInvokeResult<>(res));
+            }
         }
         catch (Exception e) {
             if (keyVal == null)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b92c3db/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 5f0b325..dd61b1d 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
@@ -67,7 +67,10 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
     @Override protected void afterTest() throws Exception {
         super.afterTest();
 
-        interceptor = new Interceptor();
+        interceptor.delegate(new CacheInterceptorAdapter<TestKey, TestValue>());
+        
+        for (int i = 0; i < gridCount(); i++)
+            cache(i, null).clearLocally();
     }
 
     /** {@inheritDoc} */
@@ -116,7 +119,6 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
             interceptor.delegate(new CacheInterceptorAdapter<TestKey, TestValue>()
{
                 @Override public void onAfterPut(Cache.Entry<TestKey, TestValue> entry)
{
                     assertNotSame(key, entry.getKey());
-                    assertNotSame(val, entry.getValue());
 
                     assertSame(entry.getValue(), entry.getValue());
                     assertSame(entry.getKey(), entry.getKey());
@@ -153,7 +155,6 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
 
                 @Override public void onAfterPut(Cache.Entry<TestKey, TestValue> entry)
{
                     assertNotSame(key, entry.getKey());
-                    assertNotSame(newTestVal, entry.getValue());
 
                     assertSame(entry.getValue(), entry.getValue());
                     assertSame(entry.getKey(), entry.getKey());
@@ -193,58 +194,6 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
     /**
      * @throws Exception If failed.
      */
-    public void testEntryProcessor() throws Exception {
-        IgniteCache<TestKey, TestValue> cache = grid(0).jcache(null);
-
-        Set<TestKey> keys = new LinkedHashSet<>();
-
-        for (int i = 0; i < ITER_CNT; i++) {
-            TestKey key = new TestKey(i, i);
-            keys.add(key);
-
-            cache.put(key, new TestValue(i));
-        }
-
-        for (int i = 0; i < ITER_CNT; i++) {
-            cache.invoke(new TestKey(i, i), new EntryProcessor<TestKey, TestValue, Object>()
{
-                @Override public Object process(MutableEntry<TestKey, TestValue> entry,
Object... arguments)
-                    throws EntryProcessorException {
-                    // Try change entry.
-                    entry.getKey().field(WRONG_VALUE);
-                    entry.getValue().val(WRONG_VALUE);
-   
-                    return -1;
-                }
-            });
-
-            // Check that internal entry isn't changed.
-            Cache.Entry<Object, Object> e = internalCache(0).entry(new TestKey(i, i));
-
-            assertEquals(i, ((TestKey)e.getKey()).field());
-            assertEquals(i, ((TestValue)e.getValue()).val());
-        }
-        
-        cache.invokeAll(keys, new EntryProcessor<TestKey, TestValue, Object>() {
-            @Override public Object process(MutableEntry<TestKey, TestValue> entry,
Object... arguments) 
-                throws EntryProcessorException {
-                // Try change entry.
-                entry.getKey().field(WRONG_VALUE);
-                entry.getValue().val(WRONG_VALUE);
-                
-                return -1;
-            }
-        });
-
-        // Check that entries weren't changed.
-        for (Cache.Entry<Object, Object> e : internalCache(0).entrySet()) {
-            assertNotEquals(WRONG_VALUE, ((TestKey)e.getKey()).field());
-            assertNotEquals(WRONG_VALUE, ((TestValue)e.getValue()).val());
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
     public void testInvokeAndInterceptor() throws Exception {
         IgniteCache<TestKey, TestValue> cache = grid(0).jcache(null);
 
@@ -255,7 +204,6 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
             @Override public TestValue onBeforePut(Cache.Entry<TestKey, TestValue>
entry, TestValue newVal) {
                 // Check that we have correct value and key.
                 assertEquals(entry.getKey().key(), entry.getKey().field());
-                assertEquals(entry.getKey().key(), entry.getValue().val());
 
                 // Try changed entry.
                 entry.getKey().field(WRONG_VALUE);
@@ -266,7 +214,6 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
 
             @Override public void onAfterPut(Cache.Entry<TestKey, TestValue> entry)
{
                 assertEquals(entry.getKey().key(), entry.getKey().field());
-                assertEquals(entry.getKey().key(), entry.getValue().val());
 
                 entry.getValue().val(WRONG_VALUE);
                 entry.getKey().field(WRONG_VALUE);
@@ -286,7 +233,7 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
                     // Try changed entry.
                     entry.getKey().field(WRONG_VALUE);
                     entry.getValue().val(WRONG_VALUE);
-                    
+
                     return -1;
                 }
             });
@@ -298,71 +245,6 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
         }
     }
 
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testInvokeAllAndInterceptor() throws Exception {
-        IgniteCache<TestKey, TestValue> cache = grid(0).jcache(null);
-
-        Set<TestKey> keys = new LinkedHashSet<>();
-        
-        for (int i = 0; i < ITER_CNT; i++) {
-            TestKey key = new TestKey(i, i);
-
-            keys.add(key);
-
-            cache.put(key, new TestValue(i));
-        }
-
-        interceptor.delegate(new CacheInterceptorAdapter<TestKey, TestValue>(){
-            @Override public TestValue onBeforePut(Cache.Entry<TestKey, TestValue>
entry, TestValue newVal) {
-                // Check that we have correct value and key.
-                assertEquals(entry.getKey().key(), entry.getKey().field());
-                assertEquals(entry.getKey().key(), entry.getValue().val());
-
-                // Try changed entry.
-                entry.getKey().field(WRONG_VALUE);
-                entry.getValue().val(WRONG_VALUE);
-
-                return super.onBeforePut(entry, newVal);
-            }
-
-            @Override public void onAfterPut(Cache.Entry<TestKey, TestValue> entry)
{
-                // Check that we have correct value and key.
-                assertEquals(entry.getKey().key(), entry.getKey().field());
-                assertEquals(entry.getKey().key(), entry.getValue().val());
-
-                // Try changed entry.
-                entry.getValue().val(WRONG_VALUE);
-                entry.getKey().field(WRONG_VALUE);
-
-                super.onAfterPut(entry);
-            }
-        });
-
-        cache.invokeAll(keys, new EntryProcessor<TestKey, TestValue, Object>() {
-            @Override public Object process(MutableEntry<TestKey, TestValue> entry,
Object... arguments)
-                throws EntryProcessorException {
-                // Check that we have correct value and key.
-                assertEquals(entry.getKey().key(), entry.getKey().field());
-                assertEquals(entry.getKey().key(), entry.getValue().val());
-
-                // Try changed entry.
-                entry.getKey().field(WRONG_VALUE);
-                entry.getValue().val(WRONG_VALUE);
-
-                return -1;
-            }
-        });
-
-        // Check that entries weren't changed.
-        for (Cache.Entry<Object, Object> e : internalCache(0).entrySet()) {
-            assertNotEquals(WRONG_VALUE, ((TestKey)e.getKey()).field());
-            assertNotEquals(WRONG_VALUE, ((TestValue)e.getValue()).val());
-        }
-    }
-
     /**
      * @throws Exception If failed.
      */


Mime
View raw message