Key and val are no longer collections.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/61bdf4cb Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/61bdf4cb Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/61bdf4cb Branch: refs/heads/ignite-2926 Commit: 61bdf4cb888a3359fd46a5c7a02e152b34a95f9a Parents: b80cc29 Author: vozerov-gridgain <[email protected]> Authored: Fri Apr 15 12:33:45 2016 +0300 Committer: vozerov-gridgain <[email protected]> Committed: Fri Apr 15 12:33:45 2016 +0300 ---------------------------------------------------------------------- .../GridNearAtomicSingleUpdateFuture.java | 87 ++++++-------------- 1 file changed, 26 insertions(+), 61 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/61bdf4cb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java index d4c904f..6c1a402 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java @@ -17,13 +17,6 @@ package org.apache.ignite.internal.processors.cache.distributed.dht.atomic; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.Map; -import java.util.UUID; -import javax.cache.expiry.ExpiryPolicy; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.cluster.ClusterNode; @@ -40,7 +33,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheTryPutFailedExceptio import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearAtomicCache; -import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.future.GridFinishedFuture; import org.apache.ignite.internal.util.future.GridFutureAdapter; @@ -54,6 +46,13 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.jetbrains.annotations.Nullable; +import javax.cache.expiry.ExpiryPolicy; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.UUID; + import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.CLOCK; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_ASYNC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC; @@ -64,11 +63,11 @@ import static org.apache.ignite.internal.processors.cache.GridCacheOperation.TRA */ public class GridNearAtomicSingleUpdateFuture extends GridAbstractNearAtomicUpdateFuture { /** Keys */ - private Collection<?> keys; + private Object keys; /** Values. */ @SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"}) - private Collection<?> vals; + private Object vals; /** Optional arguments for entry processor. */ private Object[] invokeArgs; @@ -107,8 +106,8 @@ public class GridNearAtomicSingleUpdateFuture extends GridAbstractNearAtomicUpda GridDhtAtomicCache cache, CacheWriteSynchronizationMode syncMode, GridCacheOperation op, - Collection<?> keys, - @Nullable Collection<?> vals, + Object keys, + @Nullable Object vals, @Nullable Object[] invokeArgs, final boolean retval, final boolean rawRetval, @@ -124,7 +123,6 @@ public class GridNearAtomicSingleUpdateFuture extends GridAbstractNearAtomicUpda super(cctx, cache, syncMode, op, retval, rawRetval, expiryPlc, filter, subjId, taskNameHash, skipStore, keepBinary, waitTopFut); - assert vals == null || vals.size() == keys.size(); assert subjId != null; this.keys = keys; @@ -660,8 +658,6 @@ public class GridNearAtomicSingleUpdateFuture extends GridAbstractNearAtomicUpda GridNearAtomicUpdateRequest singleReq0 = null; Map<UUID, GridNearAtomicUpdateRequest> mappings0 = null; - int size = keys.size(); - GridCacheVersion futVer = cctx.versions().next(topVer); GridCacheVersion updVer; @@ -681,7 +677,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridAbstractNearAtomicUpda updVer = null; try { - if (size == 1 && !fastMap) { + if (!fastMap) { assert remapKeys == null || remapKeys.size() == 1; singleReq0 = mapSingleUpdate(topVer, futVer, updVer); @@ -707,7 +703,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridAbstractNearAtomicUpda else mappings0 = pendingMappings; - assert !mappings0.isEmpty() || size == 0 : this; + assert !mappings0.isEmpty() : this; } } @@ -751,10 +747,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridAbstractNearAtomicUpda else { assert mappings0 != null; - if (size == 0) - onDone(new GridCacheReturn(cctx, true, true, null, true)); - else - doUpdate(mappings0); + doUpdate(mappings0); } } @@ -796,37 +789,19 @@ public class GridNearAtomicSingleUpdateFuture extends GridAbstractNearAtomicUpda GridCacheVersion futVer, @Nullable GridCacheVersion updVer, @Nullable Collection<KeyCacheObject> remapKeys) throws Exception { - Iterator<?> it = null; - - if (vals != null) - it = vals.iterator(); - Map<UUID, GridNearAtomicUpdateRequest> pendingMappings = U.newHashMap(topNodes.size()); - // Create mappings first, then send messages. - for (Object key : keys) { - if (key == null) - throw new NullPointerException("Null key."); - - Object val; - - if (vals != null) { - val = it.next(); - - if (val == null) - throw new NullPointerException("Null value."); - } - else - val = null; + if (keys == null) + throw new NullPointerException("Null key."); - if (val == null && op != GridCacheOperation.DELETE) - continue; + Object val = this.vals; - KeyCacheObject cacheKey = cctx.toCacheKeyObject(key); + if (val == null && op != GridCacheOperation.DELETE) + throw new NullPointerException("Null value."); - if (remapKeys != null && !remapKeys.contains(cacheKey)) - continue; + KeyCacheObject cacheKey = cctx.toCacheKeyObject(keys); + if (remapKeys == null || remapKeys.contains(cacheKey)) { if (op != TRANSFORM) val = cctx.toCacheObject(val); @@ -868,7 +843,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridAbstractNearAtomicUpda keepBinary, cctx.kernalContext().clientNode(), cctx.deploymentEnabled(), - keys.size()); + 1); pendingMappings.put(nodeId, mapped); } @@ -892,25 +867,15 @@ public class GridNearAtomicSingleUpdateFuture extends GridAbstractNearAtomicUpda private GridNearAtomicUpdateRequest mapSingleUpdate(AffinityTopologyVersion topVer, GridCacheVersion futVer, @Nullable GridCacheVersion updVer) throws Exception { - Object key = F.first(keys); - - Object val; - - if (vals != null) - // Regular PUT. - val = F.first(vals); - else - // Regular REMOVE. - val = null; - - // We still can get here if user pass map with single element. - if (key == null) + if (keys == null) throw new NullPointerException("Null key."); + Object val = this.vals; + if (val == null && op != GridCacheOperation.DELETE) throw new NullPointerException("Null value."); - KeyCacheObject cacheKey = cctx.toCacheKeyObject(key); + KeyCacheObject cacheKey = cctx.toCacheKeyObject(keys); if (op != TRANSFORM) val = cctx.toCacheObject(val);
