You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by nt...@apache.org on 2016/04/12 12:37:30 UTC
[1/3] ignite git commit: ignite-2645: Fixed assertion error in ATOMIC
cache for invokeAll and cache store (cherry picked from commit 18e355b)
Repository: ignite
Updated Branches:
refs/heads/ignite-2004 2f1856bd7 -> 35abc3342
ignite-2645: Fixed assertion error in ATOMIC cache for invokeAll and cache store (cherry picked from commit 18e355b)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bfba2a3d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bfba2a3d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bfba2a3d
Branch: refs/heads/ignite-2004
Commit: bfba2a3dbd2c3d2f32cb139d6a67572c9e23a3ca
Parents: b912754
Author: ashutak <as...@gridgain.com>
Authored: Mon Apr 11 19:48:00 2016 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Mon Apr 11 19:58:52 2016 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheAdapter.java | 7 +-
.../processors/cache/GridCacheEntryEx.java | 10 +-
.../processors/cache/GridCacheMapEntry.java | 65 ++---
.../dht/GridDhtTransactionalCacheAdapter.java | 4 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 1 +
.../dht/GridPartitionedGetFuture.java | 5 +-
.../dht/GridPartitionedSingleGetFuture.java | 5 +-
.../dht/atomic/GridDhtAtomicCache.java | 55 ++--
.../dht/colocated/GridDhtColocatedCache.java | 5 +-
.../distributed/near/GridNearGetFuture.java | 10 +-
.../local/atomic/GridLocalAtomicCache.java | 17 +-
.../cache/transactions/IgniteTxAdapter.java | 4 +-
.../transactions/IgniteTxLocalAdapter.java | 34 ++-
.../EntryVersionConsistencyReadThroughTest.java | 265 +++++++++++++++++++
.../processors/cache/GridCacheTestEntryEx.java | 5 +-
.../testsuites/IgniteCacheTestSuite5.java | 4 +-
16 files changed, 417 insertions(+), 79 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfba2a3d/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 58fce3d..d807e26 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
@@ -1876,7 +1876,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
try {
- T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(null,
+ T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
+ null,
+ null,
ctx.isSwapOrOffheapEnabled(),
/*unmarshal*/true,
/*update-metrics*/!skipVals,
@@ -2321,7 +2323,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
throws IgniteCheckedException {
Map<? extends K, EntryProcessor<K, V, Object>> invokeMap = F.viewAsMap(keys,
new C1<K, EntryProcessor<K, V, Object>>() {
- @Override public EntryProcessor apply(K k) {
+ @Override public EntryProcessor apply(K k) {
return entryProcessor;
}
});
@@ -4809,6 +4811,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
{
CacheObject val = entry.innerGet(
null,
+ null,
false,
false,
false,
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfba2a3d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
index 3a7b5ec..d6d7335 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
@@ -273,6 +273,7 @@ public interface GridCacheEntryEx {
public boolean partitionValid();
/**
+ * @param ver Cache version to set. The version will be used on updating entry instead of generated one.
* @param tx Ongoing transaction (possibly null).
* @param readSwap Flag indicating whether to check swap memory.
* @param readThrough Flag indicating whether to read through.
@@ -288,11 +289,13 @@ public interface GridCacheEntryEx {
* @param transformClo Transform closure to record event.
* @param taskName Task name.
* @param expiryPlc Expiry policy.
+ * @param keepBinary Keep binary flag.
* @return Cached value.
* @throws IgniteCheckedException If loading value failed.
* @throws GridCacheEntryRemovedException If entry was removed.
*/
- @Nullable public CacheObject innerGet(@Nullable IgniteInternalTx tx,
+ @Nullable public CacheObject innerGet(@Nullable GridCacheVersion ver,
+ @Nullable IgniteInternalTx tx,
boolean readSwap,
boolean readThrough,
boolean failFast,
@@ -308,6 +311,7 @@ public interface GridCacheEntryEx {
throws IgniteCheckedException, GridCacheEntryRemovedException;
/**
+ * @param ver Cache version to set. The version will be used on updating entry instead of generated one.
* @param tx Cache transaction.
* @param readSwap Flag indicating whether to check swap memory.
* @param unmarshal Unmarshal flag.
@@ -317,11 +321,13 @@ public interface GridCacheEntryEx {
* @param transformClo Transform closure to record event.
* @param taskName Task name.
* @param expiryPlc Expiry policy.
+ * @param keepBinary Keep binary flag.
* @return Cached value and entry version.
* @throws IgniteCheckedException If loading value failed.
* @throws GridCacheEntryRemovedException If entry was removed.
*/
@Nullable public T2<CacheObject, GridCacheVersion> innerGetVersioned(
+ @Nullable GridCacheVersion ver,
IgniteInternalTx tx,
boolean readSwap,
boolean unmarshal,
@@ -354,6 +360,7 @@ public interface GridCacheEntryEx {
* @param ttl Time to live.
* @param evt Flag to signal event notification.
* @param metrics Flag to signal metrics update.
+ * @param keepBinary Keep binary flag.
* @param topVer Topology version.
* @param filter Filter.
* @param drType DR type.
@@ -397,6 +404,7 @@ public interface GridCacheEntryEx {
* @param retval {@code True} if value should be returned (and unmarshalled if needed).
* @param evt Flag to signal event notification.
* @param metrics Flag to signal metrics notification.
+ * @param keepBinary Keep binary flag.
* @param topVer Topology version.
* @param filter Filter.
* @param drType DR type.
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfba2a3d/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 1a052f2..735e20a 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
@@ -668,7 +668,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
/** {@inheritDoc} */
- @Nullable @Override public final CacheObject innerGet(@Nullable IgniteInternalTx tx,
+ @Nullable @Override public final CacheObject innerGet(@Nullable GridCacheVersion ver,
+ @Nullable IgniteInternalTx tx,
boolean readSwap,
boolean readThrough,
boolean failFast,
@@ -682,7 +683,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
@Nullable IgniteCacheExpiryPolicy expirePlc,
boolean keepBinary)
throws IgniteCheckedException, GridCacheEntryRemovedException {
- return (CacheObject)innerGet0(tx,
+ return (CacheObject)innerGet0(ver,
+ tx,
readSwap,
readThrough,
evt,
@@ -699,6 +701,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
/** {@inheritDoc} */
@Nullable @Override public T2<CacheObject, GridCacheVersion> innerGetVersioned(
+ @Nullable GridCacheVersion ver,
IgniteInternalTx tx,
boolean readSwap,
boolean unmarshal,
@@ -710,7 +713,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
@Nullable IgniteCacheExpiryPolicy expiryPlc,
boolean keepBinary)
throws IgniteCheckedException, GridCacheEntryRemovedException {
- return (T2<CacheObject, GridCacheVersion>)innerGet0(tx,
+ return (T2<CacheObject, GridCacheVersion>)innerGet0(ver,
+ tx,
readSwap,
false,
evt,
@@ -727,7 +731,9 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
/** {@inheritDoc} */
@SuppressWarnings({"unchecked", "RedundantTypeArguments", "TooBroadScope"})
- private Object innerGet0(IgniteInternalTx tx,
+ private Object innerGet0(
+ GridCacheVersion nextVer,
+ IgniteInternalTx tx,
boolean readSwap,
boolean readThrough,
boolean evt,
@@ -943,7 +949,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
// Detach value before index update.
ret = cctx.kernalContext().cacheObjects().prepareForCache(ret, cctx);
- GridCacheVersion nextVer = nextVersion();
+ nextVer = nextVer != null ? nextVer : nextVersion();
CacheObject prevVal = rawGetOrUnmarshalUnlocked(false);
@@ -955,7 +961,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
boolean hadValPtr = hasOffHeapPointer();
- // Don't change version for read-through.
update(ret, expTime, ttl, nextVer, true);
if (hadValPtr && cctx.offheapTiered())
@@ -1840,32 +1845,32 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
@SuppressWarnings("unchecked")
@Override public GridCacheUpdateAtomicResult innerUpdate(
GridCacheVersion newVer,
- UUID evtNodeId,
- UUID affNodeId,
+ final UUID evtNodeId,
+ final UUID affNodeId,
GridCacheOperation op,
@Nullable Object writeObj,
- @Nullable Object[] invokeArgs,
- boolean writeThrough,
- boolean readThrough,
- boolean retval,
- boolean keepBinary,
- @Nullable IgniteCacheExpiryPolicy expiryPlc,
- boolean evt,
- boolean metrics,
- boolean primary,
- boolean verCheck,
- AffinityTopologyVersion topVer,
- @Nullable CacheEntryPredicate[] filter,
- GridDrType drType,
- long explicitTtl,
- long explicitExpireTime,
+ @Nullable final Object[] invokeArgs,
+ final boolean writeThrough,
+ final boolean readThrough,
+ final boolean retval,
+ final boolean keepBinary,
+ @Nullable final IgniteCacheExpiryPolicy expiryPlc,
+ final boolean evt,
+ final boolean metrics,
+ final boolean primary,
+ final boolean verCheck,
+ final AffinityTopologyVersion topVer,
+ @Nullable final CacheEntryPredicate[] filter,
+ final GridDrType drType,
+ final long explicitTtl,
+ final long explicitExpireTime,
@Nullable GridCacheVersion conflictVer,
- boolean conflictResolve,
- boolean intercept,
- @Nullable UUID subjId,
- String taskName,
- @Nullable CacheObject prevVal,
- @Nullable Long updateCntr
+ final boolean conflictResolve,
+ final boolean intercept,
+ @Nullable final UUID subjId,
+ final String taskName,
+ @Nullable final CacheObject prevVal,
+ @Nullable final Long updateCntr
) throws IgniteCheckedException, GridCacheEntryRemovedException, GridClosureException {
assert cctx.atomic();
@@ -2105,7 +2110,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
else
assert isNew() || ATOMIC_VER_COMPARATOR.compare(ver, newVer, ignoreTime) <= 0 :
- "Invalid version for inner update [entry=" + this + ", newVer=" + newVer + ']';
+ "Invalid version for inner update [isNew=" + isNew() + ", entry=" + this + ", newVer=" + newVer + ']';
}
// Prepare old value and value bytes.
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfba2a3d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
index f19980b..9d277b9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
@@ -1126,7 +1126,9 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
CacheObject val = null;
if (ret)
- val = e.innerGet(tx,
+ val = e.innerGet(
+ null,
+ tx,
/*swap*/true,
/*read-through*/false,
/*fail-fast.*/false,
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfba2a3d/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 df0068a..b8fee2d 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
@@ -363,6 +363,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
final boolean keepBinary = txEntry.keepBinary();
CacheObject val = cached.innerGet(
+ null,
tx,
/*swap*/true,
readThrough,
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfba2a3d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
index 5d80306..e9873b7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
@@ -451,6 +451,7 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
if (needVer) {
T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
null,
+ null,
/*swap*/true,
/*unmarshal*/true,
/**update-metrics*/false,
@@ -467,7 +468,9 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
}
}
else {
- v = entry.innerGet(null,
+ v = entry.innerGet(
+ null,
+ null,
/*swap*/true,
/*read-through*/false,
/*fail-fast*/true,
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfba2a3d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
index 739e5ab..62c287a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
@@ -375,6 +375,7 @@ public class GridPartitionedSingleGetFuture extends GridFutureAdapter<Object> im
if (needVer) {
T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
null,
+ null,
/*swap*/true,
/*unmarshal*/true,
/**update-metrics*/false,
@@ -391,7 +392,9 @@ public class GridPartitionedSingleGetFuture extends GridFutureAdapter<Object> im
}
}
else {
- v = entry.innerGet(null,
+ v = entry.innerGet(
+ null,
+ null,
/*swap*/true,
/*read-through*/false,
/*fail-fast*/true,
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfba2a3d/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 fc1424c..81109e3 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
@@ -1297,6 +1297,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
if (needVer) {
T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
null,
+ null,
/*swap*/true,
/*unmarshal*/true,
/**update-metrics*/false,
@@ -1314,6 +1315,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
}
else {
v = entry.innerGet(null,
+ null,
/*swap*/true,
/*read-through*/false,
/*fail-fast*/true,
@@ -1656,18 +1658,18 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
*/
@SuppressWarnings("unchecked")
private UpdateBatchResult updateWithBatch(
- ClusterNode node,
- boolean hasNear,
- GridNearAtomicUpdateRequest req,
- GridNearAtomicUpdateResponse res,
- List<GridDhtCacheEntry> locked,
- GridCacheVersion ver,
+ final ClusterNode node,
+ final boolean hasNear,
+ final GridNearAtomicUpdateRequest req,
+ final GridNearAtomicUpdateResponse res,
+ final List<GridDhtCacheEntry> locked,
+ final GridCacheVersion ver,
@Nullable GridDhtAtomicUpdateFuture dhtFut,
- CI2<GridNearAtomicUpdateRequest, GridNearAtomicUpdateResponse> completionCb,
- boolean replicate,
- String taskName,
- @Nullable IgniteCacheExpiryPolicy expiry,
- boolean sndPrevVal
+ final CI2<GridNearAtomicUpdateRequest, GridNearAtomicUpdateResponse> completionCb,
+ final boolean replicate,
+ final String taskName,
+ @Nullable final IgniteCacheExpiryPolicy expiry,
+ final boolean sndPrevVal
) throws GridCacheEntryRemovedException {
assert !ctx.dr().receiveEnabled(); // Cannot update in batches during DR due to possible conflicts.
assert !req.returnValue() || req.operation() == TRANSFORM; // Should not request return values for putAll.
@@ -1741,6 +1743,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
EntryProcessor<Object, Object, Object> entryProcessor = req.entryProcessor(i);
CacheObject old = entry.innerGet(
+ ver,
null,
/*read swap*/true,
/*read through*/true,
@@ -1898,6 +1901,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
if (intercept) {
CacheObject old = entry.innerGet(
null,
+ null,
/*read swap*/true,
/*read through*/ctx.loadPreviousValue(),
/*fail fast*/false,
@@ -1937,6 +1941,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
if (intercept) {
CacheObject old = entry.innerGet(
null,
+ null,
/*read swap*/true,
/*read through*/ctx.loadPreviousValue(),
/*fail fast*/false,
@@ -2326,24 +2331,24 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
*/
@SuppressWarnings("ForLoopReplaceableByForEach")
@Nullable private GridDhtAtomicUpdateFuture updatePartialBatch(
- boolean hasNear,
- int firstEntryIdx,
- List<GridDhtCacheEntry> entries,
+ final boolean hasNear,
+ final int firstEntryIdx,
+ final List<GridDhtCacheEntry> entries,
final GridCacheVersion ver,
- ClusterNode node,
- @Nullable List<CacheObject> writeVals,
- @Nullable Map<KeyCacheObject, CacheObject> putMap,
- @Nullable Collection<KeyCacheObject> rmvKeys,
- @Nullable Map<KeyCacheObject, EntryProcessor<Object, Object, Object>> entryProcessorMap,
+ final ClusterNode node,
+ @Nullable final List<CacheObject> writeVals,
+ @Nullable final Map<KeyCacheObject, CacheObject> putMap,
+ @Nullable final Collection<KeyCacheObject> rmvKeys,
+ @Nullable final Map<KeyCacheObject, EntryProcessor<Object, Object, Object>> entryProcessorMap,
@Nullable GridDhtAtomicUpdateFuture dhtFut,
- CI2<GridNearAtomicUpdateRequest, GridNearAtomicUpdateResponse> completionCb,
+ final CI2<GridNearAtomicUpdateRequest, GridNearAtomicUpdateResponse> completionCb,
final GridNearAtomicUpdateRequest req,
final GridNearAtomicUpdateResponse res,
- boolean replicate,
- UpdateBatchResult batchRes,
- String taskName,
- @Nullable IgniteCacheExpiryPolicy expiry,
- boolean sndPrevVal
+ final boolean replicate,
+ final UpdateBatchResult batchRes,
+ final String taskName,
+ @Nullable final IgniteCacheExpiryPolicy expiry,
+ final boolean sndPrevVal
) {
assert putMap == null ^ rmvKeys == null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfba2a3d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index 216338f..9c699fa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -487,6 +487,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
if (needVer) {
T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
null,
+ null,
/*swap*/true,
/*unmarshal*/true,
/**update-metrics*/false,
@@ -503,7 +504,9 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
}
}
else {
- v = entry.innerGet(null,
+ v = entry.innerGet(
+ null,
+ null,
/*swap*/true,
/*read-through*/false,
/*fail-fast*/true,
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfba2a3d/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 c3d75c2..1b30afb 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
@@ -441,6 +441,7 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
if (needVer) {
T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
null,
+ null,
/*swap*/true,
/*unmarshal*/true,
/**update-metrics*/true,
@@ -457,7 +458,9 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
}
}
else {
- v = entry.innerGet(tx,
+ v = entry.innerGet(
+ null,
+ tx,
/*swap*/false,
/*read-through*/false,
/*fail-fast*/true,
@@ -580,6 +583,7 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
if (needVer) {
T2<CacheObject, GridCacheVersion> res = dhtEntry.innerGetVersioned(
null,
+ null,
/*swap*/true,
/*unmarshal*/true,
/**update-metrics*/false,
@@ -596,7 +600,9 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
}
}
else {
- v = dhtEntry.innerGet(tx,
+ v = dhtEntry.innerGet(
+ null,
+ tx,
/*swap*/true,
/*read-through*/false,
/*fail-fast*/true,
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfba2a3d/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 1632112..3e0e2c2 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
@@ -535,6 +535,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
if (needVer) {
T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
null,
+ null,
/*swap*/swapOrOffheap,
/*unmarshal*/true,
/**update-metrics*/false,
@@ -562,7 +563,9 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
success = false;
}
else {
- v = entry.innerGet(null,
+ v = entry.innerGet(
+ null,
+ null,
/*swap*/swapOrOffheap,
/*read-through*/false,
/*fail-fast*/false,
@@ -1121,7 +1124,9 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
EntryProcessor<Object, Object, Object> entryProcessor =
(EntryProcessor<Object, Object, Object>)val;
- CacheObject old = entry.innerGet(null,
+ CacheObject old = entry.innerGet(
+ null,
+ null,
/*swap*/true,
/*read-through*/true,
/*fail-fast*/false,
@@ -1243,7 +1248,9 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
CacheObject cacheVal = ctx.toCacheObject(val);
if (intercept) {
- CacheObject old = entry.innerGet(null,
+ CacheObject old = entry.innerGet(
+ null,
+ null,
/*swap*/true,
/*read-through*/ctx.loadPreviousValue(),
/*fail-fast*/false,
@@ -1278,7 +1285,9 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
assert op == DELETE;
if (intercept) {
- CacheObject old = entry.innerGet(null,
+ CacheObject old = entry.innerGet(
+ null,
+ null,
/*swap*/true,
/*read-through*/ctx.loadPreviousValue(),
/*fail-fast*/false,
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfba2a3d/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 50598c1..17bed0b 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
@@ -1245,7 +1245,9 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
final boolean keepBinary = txEntry.keepBinary();
CacheObject cacheVal = txEntry.hasValue() ? txEntry.value() :
- txEntry.cached().innerGet(this,
+ txEntry.cached().innerGet(
+ null,
+ this,
/*swap*/false,
/*read through*/false,
/*fail fast*/true,
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfba2a3d/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 ef69ad9..71f74a8 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
@@ -441,7 +441,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
continue;
try {
- T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(this,
+ T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
+ null,
+ this,
/*readSwap*/true,
/*unmarshal*/true,
/*update-metrics*/!skipVals,
@@ -1443,6 +1445,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
if (needVer) {
T2<CacheObject, GridCacheVersion> res = txEntry.cached().innerGetVersioned(
+ null,
this,
/*swap*/true,
/*unmarshal*/true,
@@ -1460,7 +1463,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
}
}
else {
- val = txEntry.cached().innerGet(this,
+ val = txEntry.cached().innerGet(
+ null,
+ this,
/*swap*/true,
/*read-through*/false,
/*fail fast*/true,
@@ -1525,7 +1530,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
if (needReadVer) {
T2<CacheObject, GridCacheVersion> res = primaryLocal(entry) ?
- entry.innerGetVersioned(this,
+ entry.innerGetVersioned(
+ null,
+ this,
/*swap*/true,
/*unmarshal*/true,
/*metrics*/true,
@@ -1542,7 +1549,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
}
}
else {
- val = entry.innerGet(this,
+ val = entry.innerGet(
+ null,
+ this,
/*swap*/true,
/*no read-through*/false,
/*fail-fast*/true,
@@ -1865,6 +1874,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
if (needVer) {
T2<CacheObject, GridCacheVersion> res = cached.innerGetVersioned(
+ null,
IgniteTxLocalAdapter.this,
/*swap*/cacheCtx.isSwapOrOffheapEnabled(),
/*unmarshal*/true,
@@ -1882,7 +1892,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
}
}
else{
- val = cached.innerGet(IgniteTxLocalAdapter.this,
+ val = cached.innerGet(
+ null,
+ IgniteTxLocalAdapter.this,
cacheCtx.isSwapOrOffheapEnabled(),
/*read-through*/false,
/*fail-fast*/true,
@@ -2576,7 +2588,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
try {
if (needReadVer) {
T2<CacheObject, GridCacheVersion> res = primaryLocal(entry) ?
- entry.innerGetVersioned(this,
+ entry.innerGetVersioned(
+ null,
+ this,
/*swap*/false,
/*unmarshal*/retval || needVal,
/*metrics*/retval,
@@ -2593,7 +2607,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
}
}
else {
- old = entry.innerGet(this,
+ old = entry.innerGet(
+ null,
+ this,
/*swap*/false,
/*read-through*/false,
/*fail-fast*/false,
@@ -2897,7 +2913,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
boolean readThrough =
(invoke || cacheCtx.loadPreviousValue()) && !txEntry.skipStore();
- v = cached.innerGet(this,
+ v = cached.innerGet(
+ null,
+ this,
/*swap*/true,
readThrough,
/*failFast*/false,
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfba2a3d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/EntryVersionConsistencyReadThroughTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/EntryVersionConsistencyReadThroughTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/EntryVersionConsistencyReadThroughTest.java
new file mode 100644
index 0000000..4216b5e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/EntryVersionConsistencyReadThroughTest.java
@@ -0,0 +1,265 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import javax.cache.Cache.Entry;
+import javax.cache.configuration.Factory;
+import javax.cache.configuration.FactoryBuilder;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ * Tests consistency of entry's versions after invokeAll.
+ */
+public class EntryVersionConsistencyReadThroughTest extends GridCommonAbstractTest {
+ /** */
+ private static final int NODES_CNT = 5;
+
+ /** */
+ private boolean client;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setClientMode(client);
+
+ return cfg;
+ }
+
+ /**
+ * @param atomicityMode Atomicity mode.
+ * @return Cache configuration.
+ */
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ private CacheConfiguration<String, List<Double>> createCacheConfiguration(CacheAtomicityMode atomicityMode) {
+ CacheConfiguration<String, List<Double>> cc = new CacheConfiguration<>();
+
+ cc.setCacheMode(PARTITIONED);
+ cc.setAtomicityMode(atomicityMode);
+ cc.setAtomicWriteOrderMode(PRIMARY);
+ cc.setWriteSynchronizationMode(FULL_SYNC);
+
+ cc.setReadThrough(true);
+ cc.setWriteThrough(true);
+
+ Factory cacheStoreFactory = new FactoryBuilder.SingletonFactory(new DummyCacheStore());
+
+ cc.setCacheStoreFactory(cacheStoreFactory);
+
+ cc.setBackups(2);
+
+ return cc;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGridsMultiThreaded(NODES_CNT - 1);
+
+ client = true;
+
+ startGrid(NODES_CNT - 1);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAllTransactionalCache() throws Exception {
+ check(false, createCacheConfiguration(TRANSACTIONAL));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAllAtomicCache() throws Exception {
+ check(false, createCacheConfiguration(ATOMIC));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAtomicCache() throws Exception {
+ check(true, createCacheConfiguration(ATOMIC));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeTransactionalCache() throws Exception {
+ check(true, createCacheConfiguration(TRANSACTIONAL));
+ }
+
+ /**
+ * Tests entry's versions consistency after invokeAll.
+ *
+ * @param single Single invoke or invokeAll.
+ * @param cc Cache configuration.
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("serial")
+ private void check(boolean single, CacheConfiguration cc) throws Exception {
+ grid(0).getOrCreateCache(cc);
+
+ try {
+ final int cnt = 100;
+
+ for (int i = 0; i < NODES_CNT; i++) {
+ final int iter = i;
+
+ final Set<String> keys = new LinkedHashSet<String>() {{
+ for (int i = 0; i < cnt; i++)
+ add("key-" + iter + "-" + i);
+ }};
+
+ IgniteEx grid = grid(i);
+
+ final IgniteCache<String, Integer> cache = grid.cache(null);
+
+ if (single)
+ for (String key : keys)
+ cache.invoke(key, new DummyEntryProcessor());
+ else
+ cache.invokeAll(keys, new DummyEntryProcessor());
+
+ // Check entry versions consistency.
+ for (String key : keys) {
+ Collection<ClusterNode> nodes = grid.affinity(null).mapKeyToPrimaryAndBackups(key);
+
+ List<IgniteEx> grids = grids(nodes);
+
+ GridCacheVersion ver0 = null;
+ Object val0 = null;
+
+ for (IgniteEx g : grids) {
+ GridCacheAdapter<Object, Object> cx = g.context().cache().internalCache();
+
+ GridCacheEntryEx e = cx.peekEx(key);
+
+ assertNotNull("Failed to find entry on primary/backup node.", e);
+
+ GridCacheVersion ver = e.version();
+ Object val = e.rawGet().value(cx.context().cacheObjectContext(), true);
+
+ if (ver0 == null) {
+ ver0 = ver;
+ val0 = val;
+ }
+
+ assertEquals("Invalid version for key: " + key, ver0, ver);
+
+ assertNotNull("No value for key: " + key, val);
+ assertEquals("Invalid value for key: " + key, val0, val);
+ }
+ }
+ }
+ }
+ finally {
+ grid(0).destroyCache(null);
+ }
+ }
+
+ /**
+ * @param nodes Nodes.
+ * @return Grids.
+ */
+ private List<IgniteEx> grids(Collection<ClusterNode> nodes) {
+ List<IgniteEx> grids = new ArrayList<>();
+
+ for (ClusterNode node : nodes) {
+ for (int i = 0; i < NODES_CNT; i++) {
+ if (grid(i).cluster().localNode().id().equals(node.id())) {
+ grids.add(grid(i));
+
+ break;
+ }
+ }
+ }
+
+ return grids;
+ }
+
+ /**
+ *
+ */
+ private static class DummyEntryProcessor implements EntryProcessor<String, Integer, Integer> {
+ /** {@inheritDoc} */
+ @Override public Integer process(MutableEntry<String, Integer> entry, Object... arguments) {
+ Integer currVal = entry.getValue();
+
+ if (currVal == null)
+ entry.setValue(0);
+ else
+ entry.setValue(currVal + 1);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings("serial")
+ private static class DummyCacheStore extends CacheStoreAdapter<String, Integer> implements Serializable {
+ /** {@inheritDoc} */
+ @Override public Integer load(String key) throws CacheLoaderException {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Entry<? extends String, ? extends Integer> entry) throws CacheWriterException {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void delete(Object key) throws CacheWriterException {
+ // No-op.
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfba2a3d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
index 82b3f4b..6e404b4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
@@ -426,7 +426,9 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
}
/** @inheritDoc */
- @Override public CacheObject innerGet(@Nullable IgniteInternalTx tx,
+ @Override public CacheObject innerGet(
+ @Nullable GridCacheVersion ver,
+ @Nullable IgniteInternalTx tx,
boolean readSwap,
boolean readThrough,
boolean failFast,
@@ -444,6 +446,7 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
/** @inheritDoc */
@Nullable @Override public T2<CacheObject, GridCacheVersion> innerGetVersioned(
+ @Nullable GridCacheVersion ver,
IgniteInternalTx tx,
boolean readSwap,
boolean unmarshal,
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfba2a3d/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
index 35c599e..bb05a70 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
@@ -21,6 +21,7 @@ import junit.framework.TestSuite;
import org.apache.ignite.internal.processors.cache.CacheNearReaderUpdateTest;
import org.apache.ignite.internal.processors.cache.CacheSerializableTransactionsTest;
import org.apache.ignite.internal.processors.cache.GridCacheSwapSpaceSpiConsistencySelfTest;
+import org.apache.ignite.internal.processors.cache.EntryVersionConsistencyReadThroughTest;
import org.apache.ignite.internal.processors.cache.IgniteCachePutStackOverflowSelfTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheStoreCollectionTest;
import org.apache.ignite.internal.processors.cache.distributed.CacheLateAffinityAssignmentFairAffinityTest;
@@ -49,7 +50,8 @@ public class IgniteCacheTestSuite5 extends TestSuite {
suite.addTestSuite(CacheLateAffinityAssignmentTest.class);
suite.addTestSuite(CacheLateAffinityAssignmentFairAffinityTest.class);
suite.addTestSuite(CacheLateAffinityAssignmentNodeJoinValidationTest.class);
+ suite.addTestSuite(EntryVersionConsistencyReadThroughTest.class);
return suite;
}
-}
\ No newline at end of file
+}
[2/3] ignite git commit: Fixed service proxy failure in case of
client reconnect
Posted by nt...@apache.org.
Fixed service proxy failure in case of client reconnect
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/222f9c13
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/222f9c13
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/222f9c13
Branch: refs/heads/ignite-2004
Commit: 222f9c13c98bcc2169d5cf7cd73adbcc6a94cb9f
Parents: bfba2a3
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Mon Apr 11 16:07:39 2016 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Mon Apr 11 16:07:39 2016 -0700
----------------------------------------------------------------------
.../affinity/GridAffinityProcessor.java | 6 +-
.../service/GridServiceProcessor.java | 2 +-
.../processors/service/GridServiceProxy.java | 5 +-
...GridServiceProxyClientReconnectSelfTest.java | 124 +++++++++++++++++++
.../GridServiceProxyNodeStopSelfTest.java | 2 +-
.../testsuites/IgniteKernalSelfTestSuite.java | 2 +
6 files changed, 133 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/222f9c13/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
index 6b289e1..0d3d36d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
@@ -30,6 +30,7 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentMap;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cache.affinity.AffinityFunction;
@@ -38,7 +39,6 @@ import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.events.Event;
-import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
@@ -66,7 +66,7 @@ import static org.apache.ignite.cache.CacheMode.LOCAL;
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
import static org.apache.ignite.events.EventType.EVT_NODE_JOINED;
import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
-import static org.apache.ignite.internal.GridClosureCallMode.BALANCE;
+import static org.apache.ignite.internal.GridClosureCallMode.BROADCAST;
import static org.apache.ignite.internal.processors.affinity.GridAffinityUtils.affinityJob;
import static org.apache.ignite.internal.processors.affinity.GridAffinityUtils.unmarshall;
@@ -422,7 +422,7 @@ public class GridAffinityProcessor extends GridProcessorAdapter {
private AffinityInfo affinityInfoFromNode(@Nullable String cacheName, AffinityTopologyVersion topVer, ClusterNode n)
throws IgniteCheckedException {
GridTuple3<GridAffinityMessage, GridAffinityMessage, GridAffinityAssignment> t = ctx.closure()
- .callAsyncNoFailover(BALANCE, affinityJob(cacheName, topVer), F.asList(n), true/*system pool*/).get();
+ .callAsyncNoFailover(BROADCAST, affinityJob(cacheName, topVer), F.asList(n), true/*system pool*/).get();
AffinityFunction f = (AffinityFunction)unmarshall(ctx, n.id(), t.get1());
AffinityKeyMapper m = (AffinityKeyMapper)unmarshall(ctx, n.id(), t.get2());
http://git-wip-us.apache.org/repos/asf/ignite/blob/222f9c13/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index 8aa69a7..eded5e1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -573,7 +573,7 @@ public class GridServiceProcessor extends GridProcessorAdapter {
if (node.version().compareTo(ServiceTopologyCallable.SINCE_VER) >= 0) {
return ctx.closure().callAsyncNoFailover(
- GridClosureCallMode.BALANCE,
+ GridClosureCallMode.BROADCAST,
new ServiceTopologyCallable(name),
Collections.singletonList(node),
false
http://git-wip-us.apache.org/repos/asf/ignite/blob/222f9c13/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
index 62ad7ff..578c549 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
@@ -38,6 +38,7 @@ import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.GridClosureCallMode;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
@@ -49,8 +50,6 @@ import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.jsr166.ThreadLocalRandom8;
-import static org.apache.ignite.internal.GridClosureCallMode.BALANCE;
-
/**
* Wrapper for making {@link org.apache.ignite.services.Service} class proxies.
*/
@@ -164,7 +163,7 @@ public class GridServiceProxy<T> implements Serializable {
else {
// Execute service remotely.
return ctx.closure().callAsyncNoFailover(
- BALANCE,
+ GridClosureCallMode.BROADCAST,
new ServiceProxyCallable(mtd.getName(), name, mtd.getParameterTypes(), args),
Collections.singleton(node),
false
http://git-wip-us.apache.org/repos/asf/ignite/blob/222f9c13/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java
new file mode 100644
index 0000000..2488e7a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java
@@ -0,0 +1,124 @@
+/*
+ * 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.service;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.events.EventType;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceContext;
+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;
+
+/**
+ * Service proxy test with client reconnect.
+ */
+public class GridServiceProxyClientReconnectSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));
+
+ cfg.setClientMode(gridName.contains("client"));
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClientReconnect() throws Exception {
+ startGrid("server");
+
+ Ignite client = startGrid("client");
+
+ client.services().deployClusterSingleton("my-service", new MyServiceImpl());
+
+ MyService proxy = client.services().serviceProxy("my-service", MyService.class, false);
+
+ assertEquals(42, proxy.hello());
+
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ client.events().localListen(new IgnitePredicate<Event>() {
+ @Override public boolean apply(Event event) {
+ latch.countDown();
+
+ return true;
+ }
+ }, EventType.EVT_CLIENT_NODE_RECONNECTED);
+
+ stopGrid("server");
+
+ startGrid("server");
+
+ assert latch.await(2000, TimeUnit.MILLISECONDS);
+
+ client.services().deployClusterSingleton("my-service", new MyServiceImpl());
+
+ assertEquals(42, proxy.hello());
+ }
+
+ /**
+ */
+ private interface MyService extends Service {
+ /**
+ * @return Response.
+ */
+ public int hello();
+ }
+
+ /**
+ */
+ private static class MyServiceImpl implements MyService {
+ /** {@inheritDoc} */
+ @Override public int hello() {
+ return 42;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void cancel(ServiceContext ctx) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void init(ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void execute(ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/222f9c13/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyNodeStopSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyNodeStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyNodeStopSelfTest.java
index 3afe04b..39d311f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyNodeStopSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyNodeStopSelfTest.java
@@ -46,7 +46,7 @@ public class GridServiceProxyNodeStopSelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
+ @Override protected void afterTest() throws Exception {
stopAllGrids();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/222f9c13/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
index a8d6e5c..05d33d7 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
@@ -54,6 +54,7 @@ import org.apache.ignite.internal.processors.service.GridServiceProcessorMultiNo
import org.apache.ignite.internal.processors.service.GridServiceProcessorProxySelfTest;
import org.apache.ignite.internal.processors.service.GridServiceProcessorSingleNodeSelfTest;
import org.apache.ignite.internal.processors.service.GridServiceProcessorStopSelfTest;
+import org.apache.ignite.internal.processors.service.GridServiceProxyClientReconnectSelfTest;
import org.apache.ignite.internal.processors.service.GridServiceProxyNodeStopSelfTest;
import org.apache.ignite.internal.processors.service.GridServiceReassignmentSelfTest;
import org.apache.ignite.internal.processors.service.GridServiceSerializationSelfTest;
@@ -129,6 +130,7 @@ public class IgniteKernalSelfTestSuite extends TestSuite {
suite.addTestSuite(GridServicePackagePrivateSelfTest.class);
suite.addTestSuite(GridServiceSerializationSelfTest.class);
suite.addTestSuite(GridServiceProxyNodeStopSelfTest.class);
+ suite.addTestSuite(GridServiceProxyClientReconnectSelfTest.class);
return suite;
}
[3/3] ignite git commit: Merge branch 'master' into ignite-2004
Posted by nt...@apache.org.
Merge branch 'master' into ignite-2004
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/35abc334
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/35abc334
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/35abc334
Branch: refs/heads/ignite-2004
Commit: 35abc3342c87c8ec6f7041d583cbc103fcdf52b2
Parents: 2f1856b 222f9c1
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Tue Apr 12 13:36:36 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Tue Apr 12 13:36:36 2016 +0300
----------------------------------------------------------------------
.../affinity/GridAffinityProcessor.java | 6 +-
.../processors/cache/GridCacheAdapter.java | 7 +-
.../processors/cache/GridCacheEntryEx.java | 10 +-
.../processors/cache/GridCacheMapEntry.java | 65 ++---
.../dht/GridDhtTransactionalCacheAdapter.java | 4 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 1 +
.../dht/GridPartitionedGetFuture.java | 5 +-
.../dht/GridPartitionedSingleGetFuture.java | 5 +-
.../dht/atomic/GridDhtAtomicCache.java | 55 ++--
.../dht/colocated/GridDhtColocatedCache.java | 5 +-
.../distributed/near/GridNearGetFuture.java | 10 +-
.../local/atomic/GridLocalAtomicCache.java | 17 +-
.../cache/transactions/IgniteTxAdapter.java | 4 +-
.../transactions/IgniteTxLocalAdapter.java | 34 ++-
.../service/GridServiceProcessor.java | 2 +-
.../processors/service/GridServiceProxy.java | 5 +-
.../EntryVersionConsistencyReadThroughTest.java | 265 +++++++++++++++++++
.../processors/cache/GridCacheTestEntryEx.java | 5 +-
...GridServiceProxyClientReconnectSelfTest.java | 124 +++++++++
.../GridServiceProxyNodeStopSelfTest.java | 2 +-
.../testsuites/IgniteCacheTestSuite5.java | 4 +-
.../testsuites/IgniteKernalSelfTestSuite.java | 2 +
22 files changed, 550 insertions(+), 87 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/35abc334/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/35abc334/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 122b7b5,735e20a..94cbb30
--- 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
@@@ -1844,33 -1845,32 +1849,33 @@@ public abstract class GridCacheMapEntr
@SuppressWarnings("unchecked")
@Override public GridCacheUpdateAtomicResult innerUpdate(
GridCacheVersion newVer,
- UUID evtNodeId,
- UUID affNodeId,
+ final UUID evtNodeId,
+ final UUID affNodeId,
GridCacheOperation op,
@Nullable Object writeObj,
- @Nullable Object[] invokeArgs,
- boolean writeThrough,
- boolean readThrough,
- boolean retval,
- boolean keepBinary,
- @Nullable IgniteCacheExpiryPolicy expiryPlc,
- boolean evt,
- boolean metrics,
- boolean primary,
- boolean verCheck,
- AffinityTopologyVersion topVer,
- @Nullable CacheEntryPredicate[] filter,
- GridDrType drType,
- long explicitTtl,
- long explicitExpireTime,
+ @Nullable final Object[] invokeArgs,
+ final boolean writeThrough,
+ final boolean readThrough,
+ final boolean retval,
+ final boolean keepBinary,
+ @Nullable final IgniteCacheExpiryPolicy expiryPlc,
+ final boolean evt,
+ final boolean metrics,
+ final boolean primary,
+ final boolean verCheck,
+ final AffinityTopologyVersion topVer,
+ @Nullable final CacheEntryPredicate[] filter,
+ final GridDrType drType,
+ final long explicitTtl,
+ final long explicitExpireTime,
@Nullable GridCacheVersion conflictVer,
- boolean conflictResolve,
- boolean intercept,
- @Nullable UUID subjId,
- String taskName,
- @Nullable CacheObject prevVal,
- @Nullable Long updateCntr,
+ final boolean conflictResolve,
+ final boolean intercept,
+ @Nullable final UUID subjId,
+ final String taskName,
+ @Nullable final CacheObject prevVal,
+ @Nullable final Long updateCntr
+ @Nullable GridDhtAtomicUpdateFuture fut
) throws IgniteCheckedException, GridCacheEntryRemovedException, GridClosureException {
assert cctx.atomic();
http://git-wip-us.apache.org/repos/asf/ignite/blob/35abc334/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/35abc334/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
----------------------------------------------------------------------