ignite-656: implemented get() for transactional mode
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/3a86d7aa Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/3a86d7aa Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/3a86d7aa Branch: refs/heads/ignite-sprint-4 Commit: 3a86d7aa5fb71a85054f6d2c66240532117cad41 Parents: 8d18956 Author: Denis Magda <dma...@gridgain.com> Authored: Wed Apr 15 14:46:11 2015 +0300 Committer: Denis Magda <dma...@gridgain.com> Committed: Wed Apr 15 14:46:11 2015 +0300 ---------------------------------------------------------------------- .../distributed/GridDistributedLockRequest.java | 35 ++++++++++++-------- .../distributed/dht/GridDhtLockFuture.java | 8 ++--- .../distributed/dht/GridDhtLockRequest.java | 13 ++++---- .../dht/GridDhtTransactionalCacheAdapter.java | 5 +-- .../distributed/dht/GridDhtTxLocalAdapter.java | 6 +++- .../colocated/GridDhtColocatedLockFuture.java | 6 ++-- .../distributed/near/GridNearLockFuture.java | 6 ++-- .../distributed/near/GridNearLockRequest.java | 12 ++++--- .../near/GridNearTransactionalCache.java | 2 +- .../cache/transactions/IgniteTxEntry.java | 2 +- .../cache/GridCacheAbstractFullApiSelfTest.java | 12 +++---- 11 files changed, 61 insertions(+), 46 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3a86d7aa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java index 87532e1..51eec3f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java @@ -88,10 +88,10 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage { private boolean partLock; /** - * Arrays with flags. Each flag corresponds to key from keys list. - * Bit 1 in a flag holds skipStore value. + * Additional flags. + * Bit 1 - for skipStore flag value. */ - private byte[] flags; + private byte flags; /** * Empty constructor. @@ -116,6 +116,7 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage { * @param grpLockKey Group lock key if this is a group-lock transaction. * @param partLock {@code True} if this is a group-lock transaction request and whole partition is * locked. + * @param skipStore Skip store flag. */ public GridDistributedLockRequest( int cacheId, @@ -132,7 +133,8 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage { int keyCnt, int txSize, @Nullable IgniteTxKey grpLockKey, - boolean partLock + boolean partLock, + boolean skipStore ) { super(lockVer, keyCnt); @@ -155,7 +157,8 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage { this.partLock = partLock; retVals = new boolean[keyCnt]; - flags = new byte[keyCnt]; + + skipStore(skipStore); } /** @@ -225,10 +228,18 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage { } /** - * @param idx Key index. + * Sets skip store flag value. + * + * @param skipStore Skip store flag. + */ + private void skipStore(boolean skipStore){ + flags = skipStore ? (byte)(flags | 0x1) : (byte)(flags & 0xFE); + } + + /** * @return Skip store flag. */ - public boolean skipStore(int idx) { return (flags[idx] & 0x1) == 1; } + public boolean skipStore() { return (flags & 0x1) == 1; }; /** * @return Transaction isolation or <tt>null</tt> if not in transaction. @@ -251,15 +262,13 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage { * @param retVal Flag indicating whether value should be returned. * @param cands Candidates. * @param ctx Context. - * @param skipStore Skip store for the key. * @throws IgniteCheckedException If failed. */ public void addKeyBytes( KeyCacheObject key, boolean retVal, @Nullable Collection<GridCacheMvccCandidate> cands, - GridCacheContext ctx, - boolean skipStore + GridCacheContext ctx ) throws IgniteCheckedException { if (keys == null) keys = new ArrayList<>(keysCount()); @@ -270,8 +279,6 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage { retVals[idx] = retVal; - flags[idx] = skipStore ? (byte)(flags[idx] | 0x1) : (byte)(flags[idx] & 0xFE); - idx++; } @@ -351,7 +358,7 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage { switch (writer.state()) { case 8: - if (!writer.writeByteArray("flags", flags)) + if (!writer.writeByte("flags", flags)) return false; writer.incrementState(); @@ -457,7 +464,7 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage { switch (reader.state()) { case 8: - flags = reader.readByteArray("flags"); + flags = reader.readByte("flags"); if (!reader.isLastRead()) return false; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3a86d7aa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java index 1d9b415..8a654b5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java @@ -830,7 +830,8 @@ public final class GridDhtLockFuture<K, V> extends GridCompoundIdentityFuture<Bo inTx() && tx.partitionLock(), inTx() ? tx.subjectId() : null, inTx() ? tx.taskNameHash() : 0, - read ? accessTtl : -1L); + read ? accessTtl : -1L, + cctx.skipStore()); try { for (ListIterator<GridDhtCacheEntry> it = dhtMapping.listIterator(); it.hasNext();) { @@ -867,8 +868,7 @@ public final class GridDhtLockFuture<K, V> extends GridCompoundIdentityFuture<Bo req.addDhtKey( e.key(), invalidateRdr, - cctx, - e.context().skipStore()); + cctx); if (needVal) { // Mark last added key as needed to be preloaded. @@ -957,7 +957,7 @@ public final class GridDhtLockFuture<K, V> extends GridCompoundIdentityFuture<Bo final GridCacheVersion ver = version(); for (GridDhtCacheEntry entry : entries) { - if (!entry.hasValue()) + if (!entry.hasValue() && !tx.entry(entry.txKey()).skipStore()) loadMap.put(entry.key(), entry); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3a86d7aa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index 5d77d5b..5309bd6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -106,6 +106,7 @@ public class GridDhtLockRequest extends GridDistributedLockRequest { * @param subjId Subject ID. * @param taskNameHash Task name hash code. * @param accessTtl TTL for read operation. + * @param skipStore Skip store flag. */ public GridDhtLockRequest( int cacheId, @@ -128,7 +129,8 @@ public class GridDhtLockRequest extends GridDistributedLockRequest { boolean partLock, @Nullable UUID subjId, int taskNameHash, - long accessTtl + long accessTtl, + boolean skipStore ) { super(cacheId, nodeId, @@ -144,7 +146,8 @@ public class GridDhtLockRequest extends GridDistributedLockRequest { dhtCnt == 0 ? nearCnt : dhtCnt, txSize, grpLockKey, - partLock); + partLock, + skipStore); this.topVer = topVer; @@ -217,18 +220,16 @@ public class GridDhtLockRequest extends GridDistributedLockRequest { * @param key Key. * @param invalidateEntry Flag indicating whether node should attempt to invalidate reader. * @param ctx Context. - * @param skipStore Skip store for the key. * @throws IgniteCheckedException If failed. */ public void addDhtKey( KeyCacheObject key, boolean invalidateEntry, - GridCacheContext ctx, - boolean skipStore + GridCacheContext ctx ) throws IgniteCheckedException { invalidateEntries.set(idx, invalidateEntry); - addKeyBytes(key, false, null, ctx, skipStore); + addKeyBytes(key, false, null, ctx); } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3a86d7aa/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 e481c75..a144b02 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 @@ -221,7 +221,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach null, null, req.accessTtl(), - req.skipStore(i)); + req.skipStore()); if (req.groupLock()) tx.groupLockKey(txKey); @@ -841,7 +841,8 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach req.messageId(), req.txRead(), req.needReturnValue(), - req.accessTtl()); + req.accessTtl(), + req.skipStore()); final GridDhtTxLocal t = tx; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3a86d7aa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java index 8b70f59..1bfc3d1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java @@ -530,6 +530,7 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter { * @param msgId Message ID. * @param read Read flag. * @param accessTtl TTL for read operation. + * @param skipStore Skip store flag. * @return Lock future. */ @SuppressWarnings("ForLoopReplaceableByForEach") @@ -540,7 +541,8 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter { long msgId, final boolean read, final boolean needRetVal, - long accessTtl + long accessTtl, + boolean skipStore ) { try { checkValid(); @@ -593,6 +595,8 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter { -1L, null); + txEntry.skipStore(skipStore); + if (read) txEntry.ttl(accessTtl); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3a86d7aa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java index 515e5f7..bb464d6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java @@ -732,7 +732,8 @@ public final class GridDhtColocatedLockFuture<K, V> extends GridCompoundIdentity inTx() && tx.partitionLock(), inTx() ? tx.subjectId() : null, inTx() ? tx.taskNameHash() : 0, - read ? accessTtl : -1L); + read ? accessTtl : -1L, + cctx.skipStore()); mapping.request(req); } @@ -746,8 +747,7 @@ public final class GridDhtColocatedLockFuture<K, V> extends GridCompoundIdentity key, retval, dhtVer, // Include DHT version to match remote DHT entry. - cctx, - entry.context().skipStore()); + cctx); } explicit = inTx() && cand == null; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3a86d7aa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java index 68d98e7..01ce307 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java @@ -868,7 +868,8 @@ public final class GridNearLockFuture<K, V> extends GridCompoundIdentityFuture<B inTx() && tx.partitionLock(), inTx() ? tx.subjectId() : null, inTx() ? tx.taskNameHash() : 0, - read ? accessTtl : -1L); + read ? accessTtl : -1L, + cctx.skipStore()); mapping.request(req); } @@ -882,8 +883,7 @@ public final class GridNearLockFuture<K, V> extends GridCompoundIdentityFuture<B key, retval && dhtVer == null, dhtVer, // Include DHT version to match remote DHT entry. - cctx, - entry.context().skipStore()); + cctx); } if (cand.reentry()) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3a86d7aa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java index 8f9a81f..2d1b233 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java @@ -110,6 +110,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest { * @param subjId Subject ID. * @param taskNameHash Task name hash code. * @param accessTtl TTL for read operation. + * @param skipStore Skip store flag. */ public GridNearLockRequest( int cacheId, @@ -133,7 +134,8 @@ public class GridNearLockRequest extends GridDistributedLockRequest { boolean partLock, @Nullable UUID subjId, int taskNameHash, - long accessTtl + long accessTtl, + boolean skipStore ) { super( cacheId, @@ -150,7 +152,8 @@ public class GridNearLockRequest extends GridDistributedLockRequest { keyCnt, txSize, grpLockKey, - partLock); + partLock, + skipStore); assert topVer.compareTo(AffinityTopologyVersion.ZERO) > 0; @@ -287,13 +290,12 @@ public class GridNearLockRequest extends GridDistributedLockRequest { KeyCacheObject key, boolean retVal, @Nullable GridCacheVersion dhtVer, - GridCacheContext ctx, - boolean skipStore + GridCacheContext ctx ) throws IgniteCheckedException { dhtVers[idx] = dhtVer; // Delegate to super. - addKeyBytes(key, retVal, (Collection<GridCacheMvccCandidate>)null, ctx, skipStore); + addKeyBytes(key, retVal, (Collection<GridCacheMvccCandidate>)null, ctx); } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3a86d7aa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java index 26183fd..7071597 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java @@ -316,7 +316,7 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V> GridCacheOperation.NOOP, null /*Value.*/, null /*dr version*/, - req.skipStore(i)); + req.skipStore()); } // Add remote candidate before reordering. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3a86d7aa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java index 6e8d3cc..05d660c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java @@ -422,7 +422,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message { * * @param skipStore Skip store flag. */ - private void skipStore(boolean skipStore){ + public void skipStore(boolean skipStore){ flags = skipStore ? (byte)(flags | 0x1) : (byte)(flags & 0xFE); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3a86d7aa/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 684b5b5..767e1d1 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 @@ -4426,19 +4426,19 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assertTrue(map.size() == 0); if (atomicityMode() == CacheAtomicityMode.TRANSACTIONAL) { - /*checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, TransactionConcurrency.OPTIMISTIC, + checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED); checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ); checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, TransactionConcurrency.OPTIMISTIC, - TransactionIsolation.SERIALIZABLE);*/ + TransactionIsolation.SERIALIZABLE); - //checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, TransactionConcurrency.PESSIMISTIC, - // TransactionIsolation.READ_COMMITTED); + checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, TransactionConcurrency.PESSIMISTIC, + TransactionIsolation.READ_COMMITTED); checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ); - //checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, TransactionConcurrency.PESSIMISTIC, - // TransactionIsolation.SERIALIZABLE); + checkSkipStoreWithTransaction(cache, cacheSkipStore, data, keys, TransactionConcurrency.PESSIMISTIC, + TransactionIsolation.SERIALIZABLE); } }