ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [16/49] incubator-ignite git commit: GG-9655 - Fixing tests after merge.
Date Sun, 15 Feb 2015 08:18:36 GMT
GG-9655 - Fixing tests after merge.


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

Branch: refs/heads/sprint-1
Commit: 9215a078875b1697a7cba600c00d3e5268ef37c1
Parents: 4fde8d3
Author: Alexey Goncharuk <agoncharuk@gridgain.com>
Authored: Fri Jan 30 19:45:09 2015 -0800
Committer: Alexey Goncharuk <agoncharuk@gridgain.com>
Committed: Fri Jan 30 19:45:09 2015 -0800

----------------------------------------------------------------------
 .../processors/cache/GridCacheReturn.java       | 47 ++++++++++++++++++++
 .../distributed/dht/GridDhtTxPrepareFuture.java |  4 +-
 .../dht/atomic/GridDhtAtomicCache.java          |  2 +-
 .../near/GridNearTxPrepareFuture.java           |  5 +--
 .../transactions/IgniteTxLocalAdapter.java      | 30 ++++++++++---
 .../cache/GridCacheAbstractFullApiSelfTest.java |  2 +-
 6 files changed, 77 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9215a078/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java
index cab1e36..09a566f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java
@@ -44,6 +44,9 @@ public class GridCacheReturn<V> implements Externalizable, IgniteOptimizedMarsha
     /** Success flag. */
     private volatile boolean success;
 
+    /** */
+    private volatile boolean invokeRes;
+
     /**
      * Empty constructor.
      */
@@ -70,6 +73,19 @@ public class GridCacheReturn<V> implements Externalizable, IgniteOptimizedMarsha
     }
 
     /**
+     *
+     * @param v Value.
+     * @param success Success flag.
+     */
+    public GridCacheReturn(V v, boolean success, boolean invokeRes) {
+        assert !invokeRes || v instanceof Map;
+
+        this.v = v;
+        this.success = success;
+        this.invokeRes = invokeRes;
+    }
+
+    /**
      * @return Value.
      */
     @Nullable public V value() {
@@ -86,6 +102,13 @@ public class GridCacheReturn<V> implements Externalizable, IgniteOptimizedMarsha
     }
 
     /**
+     * @return If return is invoke result.
+     */
+    public boolean invokeResult() {
+        return invokeRes;
+    }
+
+    /**
      * @param v Value.
      * @return This instance for chaining.
      */
@@ -134,6 +157,8 @@ public class GridCacheReturn<V> implements Externalizable, IgniteOptimizedMarsha
         assert key != null;
         assert res != null;
 
+        invokeRes = true;
+
         HashMap<Object, EntryProcessorResult> resMap = (HashMap<Object, EntryProcessorResult>)v;
 
         if (resMap == null) {
@@ -145,6 +170,26 @@ public class GridCacheReturn<V> implements Externalizable, IgniteOptimizedMarsha
         resMap.put(key, res);
     }
 
+    /**
+     * @param other Other result to merge with.
+     */
+    public synchronized void mergeEntryProcessResults(GridCacheReturn<V> other) {
+        assert invokeRes || v == null : "Invalid state to merge: " + this;
+        assert other.invokeRes;
+
+        invokeRes = true;
+
+        HashMap<Object, EntryProcessorResult> resMap = (HashMap<Object, EntryProcessorResult>)v;
+
+        if (resMap == null) {
+            resMap = new HashMap<>();
+
+            v = (V)resMap;
+        }
+
+        resMap.putAll((Map<Object, EntryProcessorResult>)other.v);
+    }
+
     /** {@inheritDoc} */
     @Override public Object ggClassId() {
         return GG_CLASS_ID;
@@ -154,6 +199,7 @@ public class GridCacheReturn<V> implements Externalizable, IgniteOptimizedMarsha
     @Override public void writeExternal(ObjectOutput out) throws IOException {
         out.writeBoolean(success);
         out.writeObject(v);
+        out.writeBoolean(invokeRes);
     }
 
     /** {@inheritDoc} */
@@ -161,6 +207,7 @@ public class GridCacheReturn<V> implements Externalizable, IgniteOptimizedMarsha
     @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
         success = in.readBoolean();
         v = (V)in.readObject();
+        invokeRes = in.readBoolean();
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9215a078/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index fd97fd0..903de41 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -265,7 +265,7 @@ public final class GridDhtTxPrepareFuture<K, V> extends GridCompoundIdentityFutu
     /**
      *
      */
-    private void checkFilters() {
+    private void onEntriesLocked() {
         ret = new GridCacheReturn<>(null, true);
 
         for (IgniteTxEntry<K, V> txEntry : tx.optimisticLockEntries()) {
@@ -769,7 +769,7 @@ public final class GridDhtTxPrepareFuture<K, V> extends GridCompoundIdentityFutu
             // We are holding transaction-level locks for entries here, so we can get next
write version.
             tx.writeVersion(cctx.versions().next(tx.topologyVersion()));
 
-            checkFilters();
+            onEntriesLocked();
 
             {
                 Map<UUID, GridDistributedTxMapping<K, V>> futDhtMap = new HashMap<>();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9215a078/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 9b7c788..9ee8eaa 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
@@ -1805,7 +1805,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
                         if (retVal == null) {
                             computedMap = U.newHashMap(keys.size());
 
-                            retVal = new GridCacheReturn<>((Object)computedMap, updRes.success());
+                            retVal = new GridCacheReturn<>((Object)computedMap, updRes.success(),
true);
                         }
 
                         computedMap.put(k, updRes.computedResult());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9215a078/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFuture.java
index 4d9dadf..ee22b3e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFuture.java
@@ -230,7 +230,7 @@ public final class GridNearTxPrepareFuture<K, V> extends GridCompoundIdentityFut
                 log.debug("Still waiting for locks [fut=" + this + ", keys=" + lockKeys +
']');
         }
 
-        return true;
+        return locked;
     }
 
     /**
@@ -1046,8 +1046,7 @@ public final class GridNearTxPrepareFuture<K, V> extends GridCompoundIdentityFut
                         }
                     }
 
-                    if (tx.implicitSingle())
-                        tx.implicitSingleResult(res.returnValue());
+                    tx.implicitSingleResult(res.returnValue());
 
                     for (IgniteTxKey<K> key : res.filterFailedKeys()) {
                         IgniteTxEntry<K, V> txEntry = tx.entry(key);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9215a078/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 e190023..400daff 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
@@ -282,7 +282,10 @@ public abstract class IgniteTxLocalAdapter<K, V> extends IgniteTxAdapter<K,
V>
      * @param ret Result.
      */
     public void implicitSingleResult(GridCacheReturn<V> ret) {
-        implicitRes = ret;
+        if (ret.invokeResult())
+            implicitRes.mergeEntryProcessResults(ret);
+        else
+            implicitRes = ret;
     }
 
     /**
@@ -730,17 +733,32 @@ public abstract class IgniteTxLocalAdapter<K, V> extends IgniteTxAdapter<K,
V>
 
                                     boolean evt = !isNearLocallyMapped(txEntry, false);
 
+                                    if (!F.isEmpty(txEntry.entryProcessors()) || !F.isEmpty(txEntry.filters()))
+                                        txEntry.cached().unswap(true, false);
+
+                                    GridTuple3<GridCacheOperation, V, byte[]> res =
applyTransformClosures(txEntry,
+                                        true);
+
                                     // For near local transactions we must record DHT version
                                     // in order to keep near entries on backup nodes until
                                     // backup remote transaction completes.
-                                    if (cacheCtx.isNear())
+                                    if (cacheCtx.isNear()) {
                                         ((GridNearCacheEntry<K, V>)cached).recordDhtVersion(txEntry.dhtVersion());
 
-                                    if (!F.isEmpty(txEntry.entryProcessors()) || !F.isEmpty(txEntry.filters()))
-                                        txEntry.cached().unswap(true, false);
+                                        if (txEntry.op() == CREATE || txEntry.op() == UPDATE
&& txEntry.drExpireTime() == -1L) {
+                                            ExpiryPolicy expiry = txEntry.expiry();
 
-                                    GridTuple3<GridCacheOperation, V, byte[]> res =
applyTransformClosures(txEntry,
-                                        true);
+                                            if (expiry == null)
+                                                expiry = cacheCtx.expiry();
+
+                                            if (expiry != null) {
+                                                Duration duration = cached.hasValue() ?
+                                                    expiry.getExpiryForUpdate() : expiry.getExpiryForCreation();
+
+                                                txEntry.ttl(CU.toTtl(duration));
+                                            }
+                                        }
+                                    }
 
                                     GridCacheOperation op = res.get1();
                                     V val = res.get2();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9215a078/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 d71b78d..3056a44 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
@@ -5392,7 +5392,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
 
         assertFalse(cache.iterator().hasNext());
 
-        final int SIZE = 20000;
+        final int SIZE = 5000;
 
         Map<String, Integer> entries = new HashMap<>();
 


Mime
View raw message