Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 344801077D for ; Tue, 23 Dec 2014 00:07:01 +0000 (UTC) Received: (qmail 78507 invoked by uid 500); 23 Dec 2014 00:07:01 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 78477 invoked by uid 500); 23 Dec 2014 00:07:01 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 78468 invoked by uid 99); 23 Dec 2014 00:07:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Dec 2014 00:07:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_FILL_THIS_FORM_SHORT,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 23 Dec 2014 00:06:39 +0000 Received: (qmail 65259 invoked by uid 99); 22 Dec 2014 23:59:36 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Dec 2014 23:59:36 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 4BDD1A33E05; Mon, 22 Dec 2014 23:59:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agoncharuk@apache.org To: commits@ignite.incubator.apache.org Date: Tue, 23 Dec 2014 00:00:12 -0000 Message-Id: <4be24898e1734b258d0f9b63bf3670e3@git.apache.org> In-Reply-To: <26feadb5eea944938f598249aa42f8a1@git.apache.org> References: <26feadb5eea944938f598249aa42f8a1@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [38/50] [abbrv] incubator-ignite git commit: GG-9141 - Renaming. X-Virus-Checked: Checked by ClamAV on apache.org http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd46f567/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareFuture.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareFuture.java index 8b6a693..5dfcf2a 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareFuture.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareFuture.java @@ -17,6 +17,7 @@ import org.gridgain.grid.kernal.managers.discovery.*; import org.gridgain.grid.kernal.processors.cache.*; import org.gridgain.grid.kernal.processors.cache.distributed.*; import org.gridgain.grid.kernal.processors.cache.distributed.dht.*; +import org.gridgain.grid.kernal.processors.cache.transactions.*; import org.gridgain.grid.util.future.*; import org.gridgain.grid.util.lang.*; import org.gridgain.grid.util.tostring.*; @@ -36,8 +37,8 @@ import static org.gridgain.grid.kernal.processors.cache.GridCacheOperation.*; /** * */ -public final class GridNearTxPrepareFuture extends GridCompoundIdentityFuture> - implements GridCacheMvccFuture> { +public final class GridNearTxPrepareFuture extends GridCompoundIdentityFuture> + implements GridCacheMvccFuture> { /** */ private static final long serialVersionUID = 0L; @@ -79,12 +80,12 @@ public final class GridNearTxPrepareFuture extends GridCompoundIdentityFut * @param tx Transaction. */ public GridNearTxPrepareFuture(GridCacheSharedContext cctx, final GridNearTxLocal tx) { - super(cctx.kernalContext(), new IgniteReducer, GridCacheTxEx>() { - @Override public boolean collect(GridCacheTxEx e) { + super(cctx.kernalContext(), new IgniteReducer, IgniteTxEx>() { + @Override public boolean collect(IgniteTxEx e) { return true; } - @Override public GridCacheTxEx reduce() { + @Override public IgniteTxEx reduce() { // Nothing to aggregate. return tx; } @@ -202,11 +203,11 @@ public final class GridNearTxPrepareFuture extends GridCompoundIdentityFut * @return {@code True} if all locks are owned. */ private boolean checkLocks() { - Collection> checkEntries = tx.groupLock() ? + Collection> checkEntries = tx.groupLock() ? Collections.singletonList(tx.groupLockEntry()) : tx.writeEntries(); - for (GridCacheTxEntry txEntry : checkEntries) { + for (IgniteTxEntry txEntry : checkEntries) { // Wait for near locks only. if (!txEntry.context().isNear()) continue; @@ -251,7 +252,7 @@ public final class GridNearTxPrepareFuture extends GridCompoundIdentityFut */ public void onResult(UUID nodeId, GridNearTxPrepareResponse res) { if (!isDone()) { - for (IgniteFuture> fut : pending()) { + for (IgniteFuture> fut : pending()) { if (isMini(fut)) { MiniFuture f = (MiniFuture)fut; @@ -266,7 +267,7 @@ public final class GridNearTxPrepareFuture extends GridCompoundIdentityFut } /** {@inheritDoc} */ - @Override public boolean onDone(GridCacheTxEx t, Throwable err) { + @Override public boolean onDone(IgniteTxEx t, Throwable err) { // If locks were not acquired yet, delay completion. if (isDone() || (err == null && !checkLocks())) return false; @@ -434,7 +435,7 @@ public final class GridNearTxPrepareFuture extends GridCompoundIdentityFut try { prepare( - tx.optimistic() && tx.serializable() ? tx.readEntries() : Collections.>emptyList(), + tx.optimistic() && tx.serializable() ? tx.readEntries() : Collections.>emptyList(), tx.writeEntries()); markInitialized(); @@ -450,8 +451,8 @@ public final class GridNearTxPrepareFuture extends GridCompoundIdentityFut * @throws IgniteCheckedException If transaction is group-lock and some key was mapped to to the local node. */ private void prepare( - Iterable> reads, - Iterable> writes + Iterable> reads, + Iterable> writes ) throws IgniteCheckedException { assert tx.optimistic(); @@ -482,7 +483,7 @@ public final class GridNearTxPrepareFuture extends GridCompoundIdentityFut // Assign keys to primary nodes. GridDistributedTxMapping cur = null; - for (GridCacheTxEntry read : reads) { + for (IgniteTxEntry read : reads) { GridDistributedTxMapping updated = map(read, topVer, cur); if (cur != updated) { @@ -499,7 +500,7 @@ public final class GridNearTxPrepareFuture extends GridCompoundIdentityFut } } - for (GridCacheTxEntry write : writes) { + for (IgniteTxEntry write : writes) { GridDistributedTxMapping updated = map(write, topVer, cur); if (cur != updated) { @@ -565,7 +566,7 @@ public final class GridNearTxPrepareFuture extends GridCompoundIdentityFut tx.subjectId(), tx.taskNameHash()); - for (GridCacheTxEntry txEntry : m.writes()) { + for (IgniteTxEntry txEntry : m.writes()) { if (txEntry.op() == TRANSFORM) req.addDhtVersion(txEntry.txKey(), null); } @@ -589,21 +590,21 @@ public final class GridNearTxPrepareFuture extends GridCompoundIdentityFut // At this point, if any new node joined, then it is // waiting for this transaction to complete, so // partition reassignments are not possible here. - IgniteFuture> fut = cctx.tm().txHandler().prepareTx(n.id(), tx, req); + IgniteFuture> fut = cctx.tm().txHandler().prepareTx(n.id(), tx, req); // Add new future. add(new GridEmbeddedFuture<>( cctx.kernalContext(), fut, - new C2, Exception, GridCacheTxEx>() { - @Override public GridCacheTxEx apply(GridCacheTxEx t, Exception ex) { + new C2, Exception, IgniteTxEx>() { + @Override public IgniteTxEx apply(IgniteTxEx t, Exception ex) { if (ex != null) { onError(n.id(), mappings, ex); return t; } - GridCacheTxLocalEx dhtTx = (GridCacheTxLocalEx)t; + IgniteTxLocalEx dhtTx = (IgniteTxLocalEx)t; Collection invalidParts = dhtTx.invalidPartitions(); @@ -616,7 +617,7 @@ public final class GridNearTxPrepareFuture extends GridCompoundIdentityFut GridCacheVersion min = dhtTx.minVersion(); - GridCacheTxManager tm = cctx.tm(); + IgniteTxManager tm = cctx.tm(); tx.readyNearLocks(m, Collections.emptyList(), tm.committedVersions(min), tm.rolledbackVersions(min)); @@ -657,7 +658,7 @@ public final class GridNearTxPrepareFuture extends GridCompoundIdentityFut * @throws IgniteCheckedException If transaction is group-lock and local node is not primary for key. * @return Mapping. */ - private GridDistributedTxMapping map(GridCacheTxEntry entry, long topVer, + private GridDistributedTxMapping map(IgniteTxEntry entry, long topVer, GridDistributedTxMapping cur) throws IgniteCheckedException { GridCacheContext cacheCtx = entry.context(); @@ -725,7 +726,7 @@ public final class GridNearTxPrepareFuture extends GridCompoundIdentityFut * Mini-future for get operations. Mini-futures are only waiting on a single * node as opposed to multiple nodes. */ - private class MiniFuture extends GridFutureAdapter> { + private class MiniFuture extends GridFutureAdapter> { /** */ private static final long serialVersionUID = 0L; @@ -831,8 +832,8 @@ public final class GridNearTxPrepareFuture extends GridCompoundIdentityFut else { assert F.isEmpty(res.invalidPartitions()); - for (Map.Entry, GridTuple3> entry : res.ownedValues().entrySet()) { - GridCacheTxEntry txEntry = tx.entry(entry.getKey()); + for (Map.Entry, GridTuple3> entry : res.ownedValues().entrySet()) { + IgniteTxEntry txEntry = tx.entry(entry.getKey()); assert txEntry != null; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd46f567/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java index 431e134..46e1b8a 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java @@ -13,6 +13,7 @@ import org.apache.ignite.lang.*; import org.gridgain.grid.kernal.*; import org.gridgain.grid.kernal.processors.cache.*; import org.gridgain.grid.kernal.processors.cache.distributed.*; +import org.gridgain.grid.kernal.processors.cache.transactions.*; import org.gridgain.grid.util.direct.*; import org.gridgain.grid.util.typedef.*; import org.gridgain.grid.util.typedef.internal.*; @@ -79,10 +80,10 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequ public GridNearTxPrepareRequest( IgniteUuid futId, long topVer, - GridCacheTxEx tx, - Collection> reads, - Collection> writes, - GridCacheTxKey grpLockKey, + IgniteTxEx tx, + Collection> reads, + Collection> writes, + IgniteTxKey grpLockKey, boolean partLock, boolean near, Map> txNodes, @@ -182,13 +183,13 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequ * @param c Collection of entries to clone. * @return Cloned collection. */ - private Collection> cloneEntries(Collection> c) { + private Collection> cloneEntries(Collection> c) { if (F.isEmpty(c)) return c; - Collection> cp = new ArrayList<>(c.size()); + Collection> cp = new ArrayList<>(c.size()); - for (GridCacheTxEntry e : c) { + for (IgniteTxEntry e : c) { GridCacheContext cacheCtx = e.context(); // Clone only if it is a near cache. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd46f567/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareResponse.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareResponse.java index 08d7967..e453388 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareResponse.java @@ -14,6 +14,7 @@ import org.apache.ignite.lang.*; import org.gridgain.grid.kernal.*; import org.gridgain.grid.kernal.processors.cache.*; import org.gridgain.grid.kernal.processors.cache.distributed.*; +import org.gridgain.grid.kernal.processors.cache.transactions.*; import org.gridgain.grid.util.direct.*; import org.gridgain.grid.util.lang.*; import org.gridgain.grid.util.tostring.*; @@ -53,7 +54,7 @@ public class GridNearTxPrepareResponse extends GridDistributedTxPrepareRes /** Map of owned values to set on near node. */ @GridToStringInclude @GridDirectTransient - private Map, GridTuple3> ownedVals; + private Map, GridTuple3> ownedVals; /** Marshalled owned bytes. */ @GridToStringExclude @@ -136,7 +137,7 @@ public class GridNearTxPrepareResponse extends GridDistributedTxPrepareRes * @param val Value. * @param valBytes Value bytes. */ - public void addOwnedValue(GridCacheTxKey key, GridCacheVersion ver, V val, byte[] valBytes) { + public void addOwnedValue(IgniteTxKey key, GridCacheVersion ver, V val, byte[] valBytes) { if (ownedVals == null) ownedVals = new HashMap<>(); @@ -146,8 +147,8 @@ public class GridNearTxPrepareResponse extends GridDistributedTxPrepareRes /** * @return Owned values map. */ - public Map, GridTuple3> ownedValues() { - return ownedVals == null ? Collections., GridTuple3>emptyMap() : + public Map, GridTuple3> ownedValues() { + return ownedVals == null ? Collections., GridTuple3>emptyMap() : Collections.unmodifiableMap(ownedVals); } @@ -155,7 +156,7 @@ public class GridNearTxPrepareResponse extends GridDistributedTxPrepareRes * @param key Key. * @return {@code True} if response has owned value for given key. */ - public boolean hasOwnedValue(GridCacheTxKey key) { + public boolean hasOwnedValue(IgniteTxKey key) { return ownedVals != null && ownedVals.containsKey(key); } @@ -174,7 +175,7 @@ public class GridNearTxPrepareResponse extends GridDistributedTxPrepareRes if (ownedVals != null && ownedValsBytes == null) { ownedValsBytes = new ArrayList<>(ownedVals.size()); - for (Map.Entry, GridTuple3> entry : ownedVals.entrySet()) { + for (Map.Entry, GridTuple3> entry : ownedVals.entrySet()) { GridTuple3 tup = entry.getValue(); boolean rawBytes = false; @@ -204,7 +205,7 @@ public class GridNearTxPrepareResponse extends GridDistributedTxPrepareRes ownedVals = new HashMap<>(); for (byte[] bytes : ownedValsBytes) { - GridTuple4, GridCacheVersion, byte[], Boolean> tup = ctx.marshaller().unmarshal(bytes, ldr); + GridTuple4, GridCacheVersion, byte[], Boolean> tup = ctx.marshaller().unmarshal(bytes, ldr); V val = tup.get4() ? (V)tup.get3() : ctx.marshaller().unmarshal(tup.get3(), ldr); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd46f567/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxRemote.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxRemote.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxRemote.java index 99d17eb..fbec6dd 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxRemote.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxRemote.java @@ -13,6 +13,7 @@ import org.apache.ignite.*; import org.apache.ignite.transactions.*; import org.gridgain.grid.kernal.processors.cache.*; import org.gridgain.grid.kernal.processors.cache.distributed.*; +import org.gridgain.grid.kernal.processors.cache.transactions.*; import org.gridgain.grid.util.*; import org.gridgain.grid.util.tostring.*; import org.gridgain.grid.util.typedef.*; @@ -32,7 +33,7 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter private static final long serialVersionUID = 0L; /** Evicted keys. */ - private Collection> evicted = new LinkedList<>(); + private Collection> evicted = new LinkedList<>(); /** Near node ID. */ private UUID nearNodeId; @@ -41,7 +42,7 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter private GridCacheVersion nearXidVer; /** Owned versions. */ - private Map, GridCacheVersion> owned; + private Map, GridCacheVersion> owned; /** Group lock flag. */ private boolean grpLock; @@ -86,9 +87,9 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter IgniteTxIsolation isolation, boolean invalidate, long timeout, - Collection> writeEntries, + Collection> writeEntries, int txSize, - @Nullable GridCacheTxKey grpLockKey, + @Nullable IgniteTxKey grpLockKey, @Nullable UUID subjId, int taskNameHash ) throws IgniteCheckedException { @@ -105,7 +106,7 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter writeEntries != null ? Math.max(txSize, writeEntries.size()) : txSize, 1.0f); if (writeEntries != null) - for (GridCacheTxEntry entry : writeEntries) { + for (IgniteTxEntry entry : writeEntries) { entry.unmarshal(ctx, true, ldr); addEntry(entry); @@ -144,7 +145,7 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter boolean invalidate, long timeout, int txSize, - @Nullable GridCacheTxKey grpLockKey, + @Nullable IgniteTxKey grpLockKey, @Nullable UUID subjId, int taskNameHash ) { @@ -176,7 +177,7 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter } /** {@inheritDoc} */ - @Override public GridCacheVersion ownedVersion(GridCacheTxKey key) { + @Override public GridCacheVersion ownedVersion(IgniteTxKey key) { return owned == null ? null : owned.get(key); } @@ -205,7 +206,7 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter * * @param vers Map of owned versions. */ - public void ownedVersions(Map, GridCacheVersion> vers) { + public void ownedVersions(Map, GridCacheVersion> vers) { if (F.isEmpty(vers)) return; @@ -230,7 +231,7 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter /** * @return Evicted keys. */ - public Collection> evicted() { + public Collection> evicted() { return evicted; } @@ -239,7 +240,7 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter * * @param key Evicted key. */ - public void addEvicted(GridCacheTxKey key) { + public void addEvicted(IgniteTxKey key) { evicted.add(key); } @@ -250,8 +251,8 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter * @param entries Entries to add. * @throws IgniteCheckedException If failed. */ - public void addEntries(ClassLoader ldr, Iterable> entries) throws IgniteCheckedException { - for (GridCacheTxEntry entry : entries) { + public void addEntries(ClassLoader ldr, Iterable> entries) throws IgniteCheckedException { + for (IgniteTxEntry entry : entries) { entry.unmarshal(cctx, true, ldr); addEntry(entry); @@ -263,7 +264,7 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter * @throws IgniteCheckedException If failed. * @return {@code True} if entry was enlisted. */ - private boolean addEntry(GridCacheTxEntry entry) throws IgniteCheckedException { + private boolean addEntry(IgniteTxEntry entry) throws IgniteCheckedException { checkInternal(entry.txKey()); GridCacheContext cacheCtx = entry.context(); @@ -320,7 +321,7 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter */ public boolean addEntry( GridCacheContext cacheCtx, - GridCacheTxKey key, + IgniteTxKey key, byte[] keyBytes, GridCacheOperation op, V val, @@ -348,7 +349,7 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter return false; } else { - GridCacheTxEntry txEntry = new GridCacheTxEntry<>(cacheCtx, this, op, val, 0L, -1L, cached, + IgniteTxEntry txEntry = new IgniteTxEntry<>(cacheCtx, this, op, val, 0L, -1L, cached, drVer); txEntry.keyBytes(keyBytes); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd46f567/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/GridCacheDrManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/GridCacheDrManager.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/GridCacheDrManager.java index 439a575..8915fc1 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/GridCacheDrManager.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/GridCacheDrManager.java @@ -11,6 +11,7 @@ package org.gridgain.grid.kernal.processors.cache.dr; import org.apache.ignite.*; import org.gridgain.grid.kernal.processors.cache.*; +import org.gridgain.grid.kernal.processors.cache.transactions.*; import org.gridgain.grid.kernal.processors.dr.*; import org.jetbrains.annotations.*; @@ -64,7 +65,7 @@ public interface GridCacheDrManager extends GridCacheManager { */ public GridDrResolveResult resolveTx( GridCacheEntryEx e, - GridCacheTxEntry txEntry, + IgniteTxEntry txEntry, GridCacheVersion newVer, GridCacheOperation op, V newVal, http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd46f567/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/os/GridOsCacheDrManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/os/GridOsCacheDrManager.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/os/GridOsCacheDrManager.java index cb3f407..702dd33 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/os/GridOsCacheDrManager.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/dr/os/GridOsCacheDrManager.java @@ -12,6 +12,7 @@ package org.gridgain.grid.kernal.processors.cache.dr.os; import org.apache.ignite.*; import org.gridgain.grid.kernal.processors.cache.*; import org.gridgain.grid.kernal.processors.cache.dr.*; +import org.gridgain.grid.kernal.processors.cache.transactions.*; import org.gridgain.grid.kernal.processors.dr.*; import org.jetbrains.annotations.*; @@ -80,7 +81,7 @@ public class GridOsCacheDrManager implements GridCacheDrManager { /** {@inheritDoc} */ @Override public GridDrResolveResult resolveTx(GridCacheEntryEx e, - GridCacheTxEntry txEntry, + IgniteTxEntry txEntry, GridCacheVersion newVer, GridCacheOperation op, V newVal, http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd46f567/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalCache.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalCache.java index 66fffae..9ea91b9 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalCache.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalCache.java @@ -14,6 +14,7 @@ import org.apache.ignite.lang.*; import org.apache.ignite.transactions.*; import org.gridgain.grid.cache.*; import org.gridgain.grid.kernal.processors.cache.*; +import org.gridgain.grid.kernal.processors.cache.transactions.*; import org.gridgain.grid.util.future.*; import org.gridgain.grid.util.typedef.*; import org.jetbrains.annotations.*; @@ -86,7 +87,7 @@ public class GridLocalCache extends GridCacheAdapter { /** {@inheritDoc} */ @Override public IgniteFuture txLockAsync(Collection keys, long timeout, - GridCacheTxLocalEx tx, boolean isRead, + IgniteTxLocalEx tx, boolean isRead, boolean retval, IgniteTxIsolation isolation, boolean invalidate, IgnitePredicate>[] filter) { return lockAllAsync(keys, timeout, tx, filter); @@ -95,7 +96,7 @@ public class GridLocalCache extends GridCacheAdapter { /** {@inheritDoc} */ @Override public IgniteFuture lockAllAsync(Collection keys, long timeout, IgnitePredicate>[] filter) { - GridCacheTxLocalEx tx = ctx.tm().localTx(); + IgniteTxLocalEx tx = ctx.tm().localTx(); return lockAllAsync(keys, timeout, tx, filter); } @@ -108,7 +109,7 @@ public class GridLocalCache extends GridCacheAdapter { * @return Future. */ public IgniteFuture lockAllAsync(Collection keys, long timeout, - @Nullable GridCacheTxLocalEx tx, IgnitePredicate>[] filter) { + @Nullable IgniteTxLocalEx tx, IgnitePredicate>[] filter) { if (F.isEmpty(keys)) return new GridFinishedFuture<>(ctx.kernalContext(), true); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd46f567/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalCacheEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalCacheEntry.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalCacheEntry.java index f5ff9aa..58b4cf0 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalCacheEntry.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalCacheEntry.java @@ -10,6 +10,7 @@ package org.gridgain.grid.kernal.processors.cache.local; import org.gridgain.grid.kernal.processors.cache.*; +import org.gridgain.grid.kernal.processors.cache.transactions.*; import org.jetbrains.annotations.*; import static org.apache.ignite.events.IgniteEventType.*; @@ -170,7 +171,7 @@ public class GridLocalCacheEntry extends GridCacheMapEntry { } /** {@inheritDoc} */ - @Override public boolean tmLock(GridCacheTxEx tx, long timeout) throws GridCacheEntryRemovedException { + @Override public boolean tmLock(IgniteTxEx tx, long timeout) throws GridCacheEntryRemovedException { GridCacheMvccCandidate cand = addLocal( tx.threadId(), tx.xidVersion(), @@ -266,7 +267,7 @@ public class GridLocalCacheEntry extends GridCacheMapEntry { * * @param tx Transaction to unlock. */ - @Override public void txUnlock(GridCacheTxEx tx) throws GridCacheEntryRemovedException { + @Override public void txUnlock(IgniteTxEx tx) throws GridCacheEntryRemovedException { removeLock(tx.xidVersion()); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd46f567/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalLockFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalLockFuture.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalLockFuture.java index 09bb220..25a13c5 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalLockFuture.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalLockFuture.java @@ -12,9 +12,9 @@ package org.gridgain.grid.kernal.processors.cache.local; import org.apache.ignite.*; import org.apache.ignite.cluster.*; import org.apache.ignite.lang.*; -import org.gridgain.grid.*; import org.gridgain.grid.cache.*; import org.gridgain.grid.kernal.processors.cache.*; +import org.gridgain.grid.kernal.processors.cache.transactions.*; import org.gridgain.grid.kernal.processors.timeout.*; import org.gridgain.grid.util.typedef.internal.*; import org.gridgain.grid.util.future.*; @@ -76,7 +76,7 @@ public final class GridLocalLockFuture extends GridFutureAdapter private IgnitePredicate>[] filter; /** Transaction. */ - private GridCacheTxLocalEx tx; + private IgniteTxLocalEx tx; /** Trackable flag. */ private boolean trackable = true; @@ -99,7 +99,7 @@ public final class GridLocalLockFuture extends GridFutureAdapter GridLocalLockFuture( GridCacheContext cctx, Collection keys, - GridCacheTxLocalEx tx, + IgniteTxLocalEx tx, GridLocalCache cache, long timeout, IgnitePredicate>[] filter) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd46f567/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalTx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalTx.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalTx.java index 8ceb402..0226ff2 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalTx.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalTx.java @@ -13,6 +13,7 @@ import org.apache.ignite.*; import org.apache.ignite.lang.*; import org.apache.ignite.transactions.*; import org.gridgain.grid.kernal.processors.cache.*; +import org.gridgain.grid.kernal.processors.cache.transactions.*; import org.gridgain.grid.util.future.*; import org.gridgain.grid.util.tostring.*; import org.jetbrains.annotations.*; @@ -26,7 +27,7 @@ import static org.apache.ignite.transactions.IgniteTxState.*; /** * Local cache transaction. */ -class GridLocalTx extends GridCacheTxLocalAdapter { +class GridLocalTx extends IgniteTxLocalAdapter { /** */ private static final long serialVersionUID = 0L; @@ -65,7 +66,7 @@ class GridLocalTx extends GridCacheTxLocalAdapter { } /** {@inheritDoc} */ - @Override public IgniteFuture> future() { + @Override public IgniteFuture> future() { return fut.get(); } @@ -103,11 +104,11 @@ class GridLocalTx extends GridCacheTxLocalAdapter { } /** {@inheritDoc} */ - @Override public IgniteFuture> prepareAsync() { + @Override public IgniteFuture> prepareAsync() { try { prepare(); - return new GridFinishedFuture>(cctx.kernalContext(), this); + return new GridFinishedFuture>(cctx.kernalContext(), this); } catch (IgniteCheckedException e) { return new GridFinishedFuture<>(cctx.kernalContext(), e); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd46f567/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalTxFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalTxFuture.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalTxFuture.java index e588cba..ff1682d 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalTxFuture.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/GridLocalTxFuture.java @@ -14,6 +14,7 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.lang.*; import org.apache.ignite.transactions.*; import org.gridgain.grid.kernal.processors.cache.*; +import org.gridgain.grid.kernal.processors.cache.transactions.*; import org.gridgain.grid.util.typedef.internal.*; import org.gridgain.grid.util.future.*; import org.gridgain.grid.util.tostring.*; @@ -27,8 +28,8 @@ import static org.apache.ignite.transactions.IgniteTxState.*; /** * Replicated cache transaction future. */ -final class GridLocalTxFuture extends GridFutureAdapter> - implements GridCacheMvccFuture> { +final class GridLocalTxFuture extends GridFutureAdapter> + implements GridCacheMvccFuture> { /** */ private static final long serialVersionUID = 0L; @@ -177,7 +178,7 @@ final class GridLocalTxFuture extends GridFutureAdapter txEntry : tx.writeMap().values()) { + for (IgniteTxEntry txEntry : tx.writeMap().values()) { while (true) { try { GridCacheEntryEx entry = txEntry.cached(); @@ -226,7 +227,7 @@ final class GridLocalTxFuture extends GridFutureAdapter tx = (GridCacheTxEx)cctx.tm().userTx(); + IgniteTxEx tx = (IgniteTxEx)cctx.tm().userTx(); if (tx != null) throw new IllegalStateException("Failed to start new transaction " + @@ -194,7 +194,7 @@ public class IgniteTransactionsImpl implements IgniteTransactionsEx { throw new IllegalStateException("Failed to start new transaction " + "(current thread already has a transaction): " + tx); - GridCacheTxLocalAdapter tx0 = cctx.tm().newTx( + IgniteTxLocalAdapter tx0 = cctx.tm().newTx( false, false, sys, http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd46f567/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java new file mode 100644 index 0000000..a9d28f4 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java @@ -0,0 +1,1523 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.kernal.processors.cache.transactions; + +import org.apache.ignite.*; +import org.apache.ignite.cluster.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.transactions.*; +import org.gridgain.grid.kernal.processors.cache.*; +import org.gridgain.grid.kernal.processors.cache.distributed.near.*; +import org.gridgain.grid.util.*; +import org.gridgain.grid.util.typedef.*; +import org.gridgain.grid.util.typedef.internal.*; +import org.gridgain.grid.util.future.*; +import org.gridgain.grid.util.lang.*; +import org.gridgain.grid.util.tostring.*; +import org.jetbrains.annotations.*; + +import java.io.*; +import java.util.*; +import java.util.concurrent.atomic.*; +import java.util.concurrent.locks.*; + +import static org.apache.ignite.events.IgniteEventType.*; +import static org.gridgain.grid.kernal.processors.cache.GridCacheUtils.*; +import static org.apache.ignite.transactions.IgniteTxConcurrency.*; +import static org.apache.ignite.transactions.IgniteTxIsolation.*; +import static org.apache.ignite.transactions.IgniteTxState.*; +import static org.gridgain.grid.kernal.processors.cache.GridCacheOperation.*; + +/** + * Managed transaction adapter. + */ +public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter + implements IgniteTxEx, Externalizable { + /** */ + private static final long serialVersionUID = 0L; + + /** Static logger to avoid re-creation. */ + private static final AtomicReference logRef = new AtomicReference<>(); + + /** Logger. */ + protected static IgniteLogger log; + + /** Transaction ID. */ + @GridToStringInclude + protected GridCacheVersion xidVer; + + /** Entries write version. */ + @GridToStringInclude + protected GridCacheVersion writeVer; + + /** Implicit flag. */ + @GridToStringInclude + protected boolean implicit; + + /** Implicit with one key flag. */ + @GridToStringInclude + protected boolean implicitSingle; + + /** Local flag. */ + @GridToStringInclude + protected boolean loc; + + /** Thread ID. */ + @GridToStringInclude + protected long threadId; + + /** Transaction start time. */ + @GridToStringInclude + protected long startTime = U.currentTimeMillis(); + + /** Node ID. */ + @GridToStringInclude + protected UUID nodeId; + + /** Transaction counter value at the start of transaction. */ + @GridToStringInclude + protected GridCacheVersion startVer; + + /** Cache registry. */ + @GridToStringExclude + protected GridCacheSharedContext cctx; + + /** + * End version (a.k.a. 'tnc' or 'transaction number counter') + * assigned to this transaction at the end of write phase. + */ + @GridToStringInclude + protected GridCacheVersion endVer; + + /** Isolation. */ + @GridToStringInclude + protected IgniteTxIsolation isolation = READ_COMMITTED; + + /** Concurrency. */ + @GridToStringInclude + protected IgniteTxConcurrency concurrency = PESSIMISTIC; + + /** Transaction timeout. */ + @GridToStringInclude + protected long timeout; + + /** Invalidate flag. */ + protected volatile boolean invalidate; + + /** Invalidation flag for system invalidations (not user-based ones). */ + private boolean sysInvalidate; + + /** Internal flag. */ + protected boolean internal; + + /** System transaction flag. */ + private boolean sys; + + /** */ + protected boolean onePhaseCommit; + + /** */ + protected boolean syncCommit; + + /** */ + protected boolean syncRollback; + + /** If this transaction contains transform entries. */ + protected boolean transform; + + /** Commit version. */ + private AtomicReference commitVer = new AtomicReference<>(null); + + /** Done marker. */ + protected final AtomicBoolean isDone = new AtomicBoolean(false); + + /** */ + private AtomicReference finalizing = new AtomicReference<>(FinalizationStatus.NONE); + + /** Preparing flag. */ + private AtomicBoolean preparing = new AtomicBoolean(); + + /** */ + private Set invalidParts = new GridLeanSet<>(); + + /** Recover writes. */ + private Collection> recoveryWrites; + + /** + * Transaction state. Note that state is not protected, as we want to + * always use {@link #state()} and {@link #state(IgniteTxState)} + * methods. + */ + @GridToStringInclude + private volatile IgniteTxState state = ACTIVE; + + /** Timed out flag. */ + private volatile boolean timedOut; + + /** */ + protected int txSize; + + /** Group lock key, if any. */ + protected IgniteTxKey grpLockKey; + + /** */ + @GridToStringExclude + private AtomicReference> finFut = new AtomicReference<>(); + + /** Topology version. */ + private AtomicLong topVer = new AtomicLong(-1); + + /** Mutex. */ + private final Lock lock = new ReentrantLock(); + + /** Lock condition. */ + private final Condition cond = lock.newCondition(); + + /** Subject ID initiated this transaction. */ + protected UUID subjId; + + /** Task name hash code. */ + protected int taskNameHash; + + /** Task name. */ + protected String taskName; + + /** Store used flag. */ + protected boolean storeEnabled = true; + + /** + * Empty constructor required for {@link Externalizable}. + */ + protected IgniteTxAdapter() { + // No-op. + } + + /** + * @param cctx Cache registry. + * @param xidVer Transaction ID. + * @param implicit Implicit flag. + * @param implicitSingle Implicit with one key flag. + * @param loc Local flag. + * @param sys System transaction flag. + * @param concurrency Concurrency. + * @param isolation Isolation. + * @param timeout Timeout. + * @param txSize Transaction size. + * @param grpLockKey Group lock key if this is group-lock transaction. + */ + protected IgniteTxAdapter( + GridCacheSharedContext cctx, + GridCacheVersion xidVer, + boolean implicit, + boolean implicitSingle, + boolean loc, + boolean sys, + IgniteTxConcurrency concurrency, + IgniteTxIsolation isolation, + long timeout, + boolean invalidate, + boolean storeEnabled, + int txSize, + @Nullable IgniteTxKey grpLockKey, + @Nullable UUID subjId, + int taskNameHash + ) { + assert xidVer != null; + assert cctx != null; + + this.cctx = cctx; + this.xidVer = xidVer; + this.implicit = implicit; + this.implicitSingle = implicitSingle; + this.loc = loc; + this.sys = sys; + this.concurrency = concurrency; + this.isolation = isolation; + this.timeout = timeout; + this.invalidate = invalidate; + this.storeEnabled = storeEnabled; + this.txSize = txSize; + this.grpLockKey = grpLockKey; + this.subjId = subjId; + this.taskNameHash = taskNameHash; + + startVer = cctx.versions().last(); + + nodeId = cctx.discovery().localNode().id(); + + threadId = Thread.currentThread().getId(); + + log = U.logger(cctx.kernalContext(), logRef, this); + } + + /** + * @param cctx Cache registry. + * @param nodeId Node ID. + * @param xidVer Transaction ID. + * @param startVer Start version mark. + * @param threadId Thread ID. + * @param sys System transaction flag. + * @param concurrency Concurrency. + * @param isolation Isolation. + * @param timeout Timeout. + * @param txSize Transaction size. + * @param grpLockKey Group lock key if this is group-lock transaction. + */ + protected IgniteTxAdapter( + GridCacheSharedContext cctx, + UUID nodeId, + GridCacheVersion xidVer, + GridCacheVersion startVer, + long threadId, + boolean sys, + IgniteTxConcurrency concurrency, + IgniteTxIsolation isolation, + long timeout, + int txSize, + @Nullable IgniteTxKey grpLockKey, + @Nullable UUID subjId, + int taskNameHash + ) { + this.cctx = cctx; + this.nodeId = nodeId; + this.threadId = threadId; + this.xidVer = xidVer; + this.startVer = startVer; + this.sys = sys; + this.concurrency = concurrency; + this.isolation = isolation; + this.timeout = timeout; + this.txSize = txSize; + this.grpLockKey = grpLockKey; + this.subjId = subjId; + this.taskNameHash = taskNameHash; + + implicit = false; + implicitSingle = false; + loc = false; + + log = U.logger(cctx.kernalContext(), logRef, this); + } + + /** + * Acquires lock. + */ + @SuppressWarnings({"LockAcquiredButNotSafelyReleased"}) + protected final void lock() { + lock.lock(); + } + + /** + * Releases lock. + */ + protected final void unlock() { + lock.unlock(); + } + + /** + * Signals all waiters. + */ + protected final void signalAll() { + cond.signalAll(); + } + + /** + * Waits for signal. + * + * @throws InterruptedException If interrupted. + */ + protected final void awaitSignal() throws InterruptedException { + cond.await(); + } + + /** + * Checks whether near cache should be updated. + * + * @return Flag indicating whether near cache should be updated. + */ + protected boolean updateNearCache(GridCacheContext cacheCtx, K key, long topVer) { + return false; + } + + /** {@inheritDoc} */ + @Override public Collection> optimisticLockEntries() { + assert optimistic(); + + if (!groupLock()) + return writeEntries(); + else { + if (!F.isEmpty(invalidParts)) { + assert invalidParts.size() == 1 : "Only one partition expected for group lock transaction " + + "[tx=" + this + ", invalidParts=" + invalidParts + ']'; + assert groupLockEntry() == null : "Group lock key should be rejected " + + "[tx=" + this + ", groupLockEntry=" + groupLockEntry() + ']'; + assert F.isEmpty(writeMap()) : "All entries should be rejected for group lock transaction " + + "[tx=" + this + ", writes=" + writeMap() + ']'; + + return Collections.emptyList(); + } + + IgniteTxEntry grpLockEntry = groupLockEntry(); + + assert grpLockEntry != null || (near() && !local()): + "Group lock entry was not enlisted into transaction [tx=" + this + + ", grpLockKey=" + groupLockKey() + ']'; + + return grpLockEntry == null ? + Collections.>emptyList() : + Collections.singletonList(grpLockEntry); + } + } + + /** + * @param recoveryWrites Recover write entries. + */ + public void recoveryWrites(Collection> recoveryWrites) { + this.recoveryWrites = recoveryWrites; + } + + /** + * @return Recover write entries. + */ + @Override public Collection> recoveryWrites() { + return recoveryWrites; + } + + /** {@inheritDoc} */ + @Override public boolean storeEnabled() { + return storeEnabled; + } + + /** + * @param storeEnabled Store enabled flag. + */ + public void storeEnabled(boolean storeEnabled) { + this.storeEnabled = storeEnabled; + } + + /** {@inheritDoc} */ + @Override public boolean system() { + return sys; + } + + /** {@inheritDoc} */ + @Override public boolean storeUsed() { + return storeEnabled() && store() != null; + } + + /** + * Store manager for current transaction. + * + * @return Store manager. + */ + protected GridCacheStoreManager store() { + if (!activeCacheIds().isEmpty()) { + int cacheId = F.first(activeCacheIds()); + + GridCacheStoreManager store = cctx.cacheContext(cacheId).store(); + + return store.configured() ? store : null; + } + + return null; + } + + /** + * This method uses unchecked assignment to cast group lock key entry to transaction generic signature. + * + * @return Group lock tx entry. + */ + @SuppressWarnings("unchecked") + public IgniteTxEntry groupLockEntry() { + return ((IgniteTxAdapter)this).entry(groupLockKey()); + } + + /** {@inheritDoc} */ + @Override public UUID otherNodeId() { + return null; + } + + /** {@inheritDoc} */ + @Override public UUID subjectId() { + if (subjId != null) + return subjId; + + return originatingNodeId(); + } + + /** {@inheritDoc} */ + @Override public int taskNameHash() { + return taskNameHash; + } + + /** {@inheritDoc} */ + @Override public long topologyVersion() { + long res = topVer.get(); + + if (res == -1) + return cctx.exchange().topologyVersion(); + + return res; + } + + /** {@inheritDoc} */ + @Override public long topologyVersion(long topVer) { + this.topVer.compareAndSet(-1, topVer); + + return this.topVer.get(); + } + + /** {@inheritDoc} */ + @Override public boolean hasTransforms() { + return transform; + } + + /** {@inheritDoc} */ + @Override public boolean markPreparing() { + return preparing.compareAndSet(false, true); + } + + /** + * @return {@code True} if marked. + */ + @Override public boolean markFinalizing(FinalizationStatus status) { + boolean res; + + switch (status) { + case USER_FINISH: + res = finalizing.compareAndSet(FinalizationStatus.NONE, FinalizationStatus.USER_FINISH); + + break; + + case RECOVERY_WAIT: + finalizing.compareAndSet(FinalizationStatus.NONE, FinalizationStatus.RECOVERY_WAIT); + + FinalizationStatus cur = finalizing.get(); + + res = cur == FinalizationStatus.RECOVERY_WAIT || cur == FinalizationStatus.RECOVERY_FINISH; + + break; + + case RECOVERY_FINISH: + FinalizationStatus old = finalizing.get(); + + res = old != FinalizationStatus.USER_FINISH && finalizing.compareAndSet(old, status); + + break; + + default: + throw new IllegalArgumentException("Cannot set finalization status: " + status); + + } + + if (res) { + if (log.isDebugEnabled()) + log.debug("Marked transaction as finalized: " + this); + } + else { + if (log.isDebugEnabled()) + log.debug("Transaction was not marked finalized: " + this); + } + + return res; + } + + /** + * @return Finalization status. + */ + protected FinalizationStatus finalizationStatus() { + return finalizing.get(); + } + + /** + * @return {@code True} if transaction has at least one key enlisted. + */ + public abstract boolean isStarted(); + + /** {@inheritDoc} */ + @Override public boolean groupLock() { + return grpLockKey != null; + } + + /** {@inheritDoc} */ + @Override public IgniteTxKey groupLockKey() { + return grpLockKey; + } + + /** {@inheritDoc} */ + @Override public int size() { + return txSize; + } + + /** + * @return Logger. + */ + protected IgniteLogger log() { + return log; + } + + /** {@inheritDoc} */ + @Override public boolean near() { + return false; + } + + /** {@inheritDoc} */ + @Override public boolean implicit() { + return implicit; + } + + /** {@inheritDoc} */ + @Override public boolean implicitSingle() { + return implicitSingle; + } + + /** {@inheritDoc} */ + @Override public boolean local() { + return loc; + } + + /** {@inheritDoc} */ + @Override public final boolean user() { + return !implicit() && local() && !dht() && !internal(); + } + + /** {@inheritDoc} */ + @Override public boolean dht() { + return false; + } + + /** {@inheritDoc} */ + @Override public boolean colocated() { + return false; + } + + /** {@inheritDoc} */ + @Override public boolean replicated() { + return false; + } + + /** {@inheritDoc} */ + @Override public boolean enforceSerializable() { + return true; + } + + /** {@inheritDoc} */ + @Override public boolean syncCommit() { + return syncCommit; + } + + /** {@inheritDoc} */ + @Override public boolean syncRollback() { + return syncRollback; + } + + /** + * @param syncCommit Synchronous commit flag. + */ + public void syncCommit(boolean syncCommit) { + this.syncCommit = syncCommit; + } + + /** + * @param syncRollback Synchronous rollback flag. + */ + public void syncRollback(boolean syncRollback) { + this.syncRollback = syncRollback; + } + + /** {@inheritDoc} */ + @Override public IgniteUuid xid() { + return xidVer.asGridUuid(); + } + + /** {@inheritDoc} */ + @Override public Set invalidPartitions() { + return invalidParts; + } + + /** {@inheritDoc} */ + @Override public void addInvalidPartition(GridCacheContext cacheCtx, int part) { + invalidParts.add(part); + + if (log.isDebugEnabled()) + log.debug("Added invalid partition for transaction [part=" + part + ", tx=" + this + ']'); + } + + /** {@inheritDoc} */ + @Override public GridCacheVersion ownedVersion(IgniteTxKey key) { + return null; + } + + /** {@inheritDoc} */ + @Override public long startTime() { + return startTime; + } + + /** + * Gets remaining allowed transaction time. + * + * @return Remaining transaction time. + */ + @Override public long remainingTime() { + if (timeout() <= 0) + return -1; + + long timeLeft = timeout() - (U.currentTimeMillis() - startTime()); + + if (timeLeft < 0) + return 0; + + return timeLeft; + } + + /** + * @return Lock timeout. + */ + protected long lockTimeout() { + long timeout = remainingTime(); + + return timeout < 0 ? 0 : timeout == 0 ? -1 : timeout; + } + + /** {@inheritDoc} */ + @Override public GridCacheVersion xidVersion() { + return xidVer; + } + + /** {@inheritDoc} */ + @Override public long threadId() { + return threadId; + } + + /** {@inheritDoc} */ + @Override public UUID nodeId() { + return nodeId; + } + + /** {@inheritDoc} */ + @Override public IgniteTxIsolation isolation() { + return isolation; + } + + /** {@inheritDoc} */ + @Override public IgniteTxConcurrency concurrency() { + return concurrency; + } + + /** {@inheritDoc} */ + @Override public long timeout() { + return timeout; + } + + /** {@inheritDoc} */ + @Override public long timeout(long timeout) { + if (isStarted()) + throw new IllegalStateException("Cannot change timeout after transaction has started: " + this); + + long old = this.timeout; + + this.timeout = timeout; + + return old; + } + + /** {@inheritDoc} */ + @SuppressWarnings("SimplifiableIfStatement") + @Override public boolean ownsLock(GridCacheEntryEx entry) throws GridCacheEntryRemovedException { + GridCacheContext cacheCtx = entry.context(); + + IgniteTxEntry txEntry = entry(entry.txKey()); + + GridCacheVersion explicit = txEntry == null ? null : txEntry.explicitVersion(); + + assert !txEntry.groupLockEntry() || groupLock() : "Can not have group-locked tx entries in " + + "non-group-lock transactions [txEntry=" + txEntry + ", tx=" + this + ']'; + + return local() && !cacheCtx.isDht() ? + entry.lockedByThread(threadId()) || (explicit != null && entry.lockedBy(explicit)) : + // If candidate is not there, then lock was explicit. + // Otherwise, check if entry is owned by version. + !entry.hasLockCandidate(xidVersion()) || entry.lockedBy(xidVersion()); + } + + /** {@inheritDoc} */ + @SuppressWarnings("SimplifiableIfStatement") + @Override public boolean ownsLockUnsafe(GridCacheEntryEx entry) { + GridCacheContext cacheCtx = entry.context(); + + IgniteTxEntry txEntry = entry(entry.txKey()); + + GridCacheVersion explicit = txEntry == null ? null : txEntry.explicitVersion(); + + assert !txEntry.groupLockEntry() || groupLock() : "Can not have group-locked tx entries in " + + "non-group-lock transactions [txEntry=" + txEntry + ", tx=" + this + ']'; + + return local() && !cacheCtx.isDht() ? + entry.lockedByThreadUnsafe(threadId()) || (explicit != null && entry.lockedByUnsafe(explicit)) : + // If candidate is not there, then lock was explicit. + // Otherwise, check if entry is owned by version. + !entry.hasLockCandidateUnsafe(xidVersion()) || entry.lockedByUnsafe(xidVersion()); + } + + /** {@inheritDoc} */ + @Override public IgniteTxState state() { + return state; + } + + /** {@inheritDoc} */ + @Override public boolean setRollbackOnly() { + return state(MARKED_ROLLBACK); + } + + /** + * @return {@code True} if rollback only flag is set. + */ + @Override public boolean isRollbackOnly() { + return state == MARKED_ROLLBACK || state == ROLLING_BACK || state == ROLLED_BACK; + } + + /** {@inheritDoc} */ + @Override public boolean done() { + return isDone.get(); + } + + /** + * @return Commit version. + */ + @Override public GridCacheVersion commitVersion() { + initCommitVersion(); + + return commitVer.get(); + } + + /** + * @param commitVer Commit version. + * @return {@code True} if set to not null value. + */ + @Override public boolean commitVersion(GridCacheVersion commitVer) { + return commitVer != null && this.commitVer.compareAndSet(null, commitVer); + } + + /** + * + */ + public void initCommitVersion() { + if (commitVer.get() == null) + commitVer.compareAndSet(null, xidVer); + } + + /** + * + */ + @Override public void close() throws IgniteCheckedException { + IgniteTxState state = state(); + + if (state != ROLLING_BACK && state != ROLLED_BACK && state != COMMITTING && state != COMMITTED) + rollback(); + + awaitCompletion(); + } + + /** {@inheritDoc} */ + @Override public boolean needsCompletedVersions() { + return false; + } + + /** {@inheritDoc} */ + @Override public void completedVersions(GridCacheVersion base, Collection committed, + Collection txs) { + /* No-op. */ + } + + /** + * Awaits transaction completion. + * + * @throws IgniteCheckedException If waiting failed. + */ + protected void awaitCompletion() throws IgniteCheckedException { + lock(); + + try { + while (!done()) + awaitSignal(); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + + if (!done()) + throw new IgniteCheckedException("Got interrupted while waiting for transaction to complete: " + this, e); + } + finally { + unlock(); + } + } + + /** {@inheritDoc} */ + @Override public boolean internal() { + return internal; + } + + /** + * @param key Key. + * @return {@code True} if key is internal. + */ + protected boolean checkInternal(IgniteTxKey key) { + if (key.key() instanceof GridCacheInternal) { + internal = true; + + return true; + } + + return false; + } + + /** + * @param onePhaseCommit {@code True} if transaction commit should be performed in short-path way. + */ + public void onePhaseCommit(boolean onePhaseCommit) { + this.onePhaseCommit = onePhaseCommit; + } + + /** + * @return Fast commit flag. + */ + @Override public boolean onePhaseCommit() { + return onePhaseCommit; + } + + /** {@inheritDoc} */ + @Override public boolean optimistic() { + return concurrency == OPTIMISTIC; + } + + /** {@inheritDoc} */ + @Override public boolean pessimistic() { + return concurrency == PESSIMISTIC; + } + + /** {@inheritDoc} */ + @Override public boolean serializable() { + return isolation == SERIALIZABLE; + } + + /** {@inheritDoc} */ + @Override public boolean repeatableRead() { + return isolation == REPEATABLE_READ; + } + + /** {@inheritDoc} */ + @Override public boolean readCommitted() { + return isolation == READ_COMMITTED; + } + + /** {@inheritDoc} */ + @Override public boolean state(IgniteTxState state) { + return state(state, false); + } + + /** {@inheritDoc} */ + @SuppressWarnings("ExternalizableWithoutPublicNoArgConstructor") + @Override public IgniteFuture finishFuture() { + GridFutureAdapter fut = finFut.get(); + + if (fut == null) { + fut = new GridFutureAdapter(cctx.kernalContext()) { + @Override public String toString() { + return S.toString(GridFutureAdapter.class, this, "tx", IgniteTxAdapter.this); + } + }; + + if (!finFut.compareAndSet(null, fut)) + fut = finFut.get(); + } + + assert fut != null; + + if (isDone.get()) + fut.onDone(this); + + return fut; + } + + /** + * + * @param state State to set. + * @param timedOut Timeout flag. + * @return {@code True} if state changed. + */ + @SuppressWarnings({"TooBroadScope"}) + private boolean state(IgniteTxState state, boolean timedOut) { + boolean valid = false; + + IgniteTxState prev; + + boolean notify = false; + + lock(); + + try { + prev = this.state; + + switch (state) { + case ACTIVE: { + valid = false; + + break; + } // Active is initial state and cannot be transitioned to. + case PREPARING: { + valid = prev == ACTIVE; + + break; + } + case PREPARED: { + valid = prev == PREPARING; + + break; + } + case COMMITTING: { + valid = prev == PREPARED; + + break; + } + + case UNKNOWN: { + if (isDone.compareAndSet(false, true)) + notify = true; + + valid = prev == ROLLING_BACK || prev == COMMITTING; + + break; + } + + case COMMITTED: { + if (isDone.compareAndSet(false, true)) + notify = true; + + valid = prev == COMMITTING; + + break; + } + + case ROLLED_BACK: { + if (isDone.compareAndSet(false, true)) + notify = true; + + valid = prev == ROLLING_BACK; + + break; + } + + case MARKED_ROLLBACK: { + valid = prev == ACTIVE || prev == PREPARING || prev == PREPARED || prev == COMMITTING; + + break; + } + + case ROLLING_BACK: { + valid = + prev == ACTIVE || prev == MARKED_ROLLBACK || prev == PREPARING || + prev == PREPARED || (prev == COMMITTING && local() && !dht()); + + break; + } + } + + if (valid) { + this.state = state; + this.timedOut = timedOut; + + if (log.isDebugEnabled()) + log.debug("Changed transaction state [prev=" + prev + ", new=" + this.state + ", tx=" + this + ']'); + + // Notify of state change. + signalAll(); + } + else { + if (log.isDebugEnabled()) + log.debug("Invalid transaction state transition [invalid=" + state + ", cur=" + this.state + + ", tx=" + this + ']'); + } + } + finally { + unlock(); + } + + if (notify) { + GridFutureAdapter fut = finFut.get(); + + if (fut != null) + fut.onDone(this); + } + + if (valid) { + // Seal transactions maps. + if (state != ACTIVE) + seal(); + + cctx.tm().onTxStateChange(prev, state, this); + } + + return valid; + } + + /** {@inheritDoc} */ + @Override public GridCacheVersion startVersion() { + return startVer; + } + + /** {@inheritDoc} */ + @Override public GridCacheVersion endVersion() { + return endVer; + } + + /** {@inheritDoc} */ + @Override public void endVersion(GridCacheVersion endVer) { + this.endVer = endVer; + } + + /** {@inheritDoc} */ + @Override public GridCacheVersion writeVersion() { + return writeVer == null ? commitVersion() : writeVer; + } + + /** {@inheritDoc} */ + @Override public void writeVersion(GridCacheVersion writeVer) { + this.writeVer = writeVer; + } + + /** {@inheritDoc} */ + @Override public IgniteUuid timeoutId() { + return xidVer.asGridUuid(); + } + + /** {@inheritDoc} */ + @Override public long endTime() { + long endTime = timeout == 0 ? Long.MAX_VALUE : startTime + timeout; + + return endTime > 0 ? endTime : endTime < 0 ? Long.MAX_VALUE : endTime; + } + + /** {@inheritDoc} */ + @Override public void onTimeout() { + state(MARKED_ROLLBACK, true); + } + + /** {@inheritDoc} */ + @Override public boolean timedOut() { + return timedOut; + } + + /** {@inheritDoc} */ + @Override public void invalidate(boolean invalidate) { + if (isStarted() && !dht()) + throw new IllegalStateException("Cannot change invalidation flag after transaction has started: " + this); + + this.invalidate = invalidate; + } + + /** {@inheritDoc} */ + @Override public boolean isInvalidate() { + return invalidate; + } + + /** {@inheritDoc} */ + @Override public boolean isSystemInvalidate() { + return sysInvalidate; + } + + /** {@inheritDoc} */ + @Override public void systemInvalidate(boolean sysInvalidate) { + this.sysInvalidate = sysInvalidate; + } + + /** {@inheritDoc} */ + @Nullable @Override public Map> transactionNodes() { + return null; + } + + /** {@inheritDoc} */ + @Nullable @Override public GridCacheVersion nearXidVersion() { + return null; + } + + /** + * @param txEntry Entry to process. + * @param metrics {@code True} if metrics should be updated. + * @return Tuple containing transformation results. + * @throws IgniteCheckedException If failed to get previous value for transform. + * @throws GridCacheEntryRemovedException If entry was concurrently deleted. + */ + protected GridTuple3 applyTransformClosures(IgniteTxEntry txEntry, + boolean metrics) throws GridCacheEntryRemovedException, IgniteCheckedException { + GridCacheContext cacheCtx = txEntry.context(); + + assert cacheCtx != null; + + if (isSystemInvalidate()) + return F.t(cacheCtx.isStoreEnabled() ? RELOAD : DELETE, null, null); + if (F.isEmpty(txEntry.transformClosures())) + return F.t(txEntry.op(), txEntry.value(), txEntry.valueBytes()); + else { + try { + boolean recordEvt = cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_READ); + + V val = txEntry.hasValue() ? txEntry.value() : + txEntry.cached().innerGet(this, + /*swap*/false, + /*read through*/false, + /*fail fast*/true, + /*unmarshal*/true, + /*metrics*/metrics, + /*event*/recordEvt, + /*temporary*/true, + /*subjId*/subjId, + /**closure name */recordEvt ? F.first(txEntry.transformClosures()) : null, + resolveTaskName(), + CU.empty()); + + try { + for (IgniteClosure clos : txEntry.transformClosures()) + val = clos.apply(val); + } + catch (Throwable e) { + throw new IgniteException("Transform closure must not throw any exceptions " + + "(transaction will be invalidated)", e); + } + + GridCacheOperation op = val == null ? DELETE : UPDATE; + + return F.t(op, (V)cacheCtx.unwrapTemporary(val), null); + } + catch (GridCacheFilterFailedException e) { + assert false : "Empty filter failed for innerGet: " + e; + + return null; + } + } + } + + /** + * @return Resolves task name. + */ + public String resolveTaskName() { + if (taskName != null) + return taskName; + + return (taskName = cctx.kernalContext().task().resolveTaskName(taskNameHash)); + } + + /** + * @param e Transaction entry. + * @param primaryOnly Flag to include backups into check or not. + * @return {@code True} if entry is locally mapped as a primary or back up node. + */ + protected boolean isNearLocallyMapped(IgniteTxEntry e, boolean primaryOnly) { + GridCacheContext cacheCtx = e.context(); + + if (!cacheCtx.isNear()) + return false; + + // Try to take either entry-recorded primary node ID, + // or transaction node ID from near-local transactions. + UUID nodeId = e.nodeId() == null ? local() ? this.nodeId : null : e.nodeId(); + + if (nodeId != null && nodeId.equals(cctx.localNodeId())) + return true; + + GridCacheEntryEx cached = e.cached(); + + int part = cached != null ? cached.partition() : cacheCtx.affinity().partition(e.key()); + + List affNodes = cacheCtx.affinity().nodes(part, topologyVersion()); + + e.locallyMapped(F.contains(affNodes, cctx.localNode())); + + if (primaryOnly) { + ClusterNode primary = F.first(affNodes); + + if (primary == null && !isAffinityNode(cacheCtx.config())) + return false; + + assert primary != null : "Primary node is null for affinity nodes: " + affNodes; + + return primary.isLocal(); + } + else + return e.locallyMapped(); + } + + /** + * @param e Entry to evict if it qualifies for eviction. + * @param primaryOnly Flag to try to evict only on primary node. + * @return {@code True} if attempt was made to evict the entry. + * @throws IgniteCheckedException If failed. + */ + protected boolean evictNearEntry(IgniteTxEntry e, boolean primaryOnly) throws IgniteCheckedException { + assert e != null; + + if (isNearLocallyMapped(e, primaryOnly)) { + GridCacheEntryEx cached = e.cached(); + + assert cached instanceof GridNearCacheEntry : "Invalid cache entry: " + e; + + if (log.isDebugEnabled()) + log.debug("Evicting dht-local entry from near cache [entry=" + cached + ", tx=" + this + ']'); + + if (cached != null && cached.markObsolete(xidVer)) + return true; + } + + return false; + } + + /** {@inheritDoc} */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + writeExternalMeta(out); + + out.writeObject(xidVer); + out.writeBoolean(invalidate); + out.writeLong(timeout); + out.writeLong(threadId); + out.writeLong(startTime); + + U.writeUuid(out, nodeId); + + out.write(isolation.ordinal()); + out.write(concurrency.ordinal()); + out.write(state().ordinal()); + } + + /** {@inheritDoc} */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + readExternalMeta(in); + + xidVer = (GridCacheVersion)in.readObject(); + invalidate = in.readBoolean(); + timeout = in.readLong(); + threadId = in.readLong(); + startTime = in.readLong(); + + nodeId = U.readUuid(in); + + isolation = IgniteTxIsolation.fromOrdinal(in.read()); + concurrency = IgniteTxConcurrency.fromOrdinal(in.read()); + + state = IgniteTxState.fromOrdinal(in.read()); + } + + /** + * Reconstructs object on unmarshalling. + * + * @return Reconstructed object. + * @throws ObjectStreamException Thrown in case of unmarshalling error. + */ + protected Object readResolve() throws ObjectStreamException { + return new TxShadow( + xidVer.asGridUuid(), + nodeId, + threadId, + startTime, + isolation, + concurrency, + invalidate, + implicit, + timeout, + state(), + isRollbackOnly() + ); + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + return o == this || (o instanceof IgniteTxAdapter && xidVer.equals(((IgniteTxAdapter)o).xidVer)); + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + return xidVer.hashCode(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return GridToStringBuilder.toString(IgniteTxAdapter.class, this, + "duration", (U.currentTimeMillis() - startTime) + "ms", "grpLock", groupLock(), + "onePhaseCommit", onePhaseCommit); + } + + /** + * Transaction shadow class to be used for deserialization. + */ + private static class TxShadow extends GridMetadataAwareAdapter implements IgniteTx { + /** */ + private static final long serialVersionUID = 0L; + + /** Xid. */ + private final IgniteUuid xid; + + /** Node ID. */ + private final UUID nodeId; + + /** Thread ID. */ + private final long threadId; + + /** Start time. */ + private final long startTime; + + /** Transaction isolation. */ + private final IgniteTxIsolation isolation; + + /** Concurrency. */ + private final IgniteTxConcurrency concurrency; + + /** Invalidate flag. */ + private final boolean invalidate; + + /** Timeout. */ + private final long timeout; + + /** State. */ + private final IgniteTxState state; + + /** Rollback only flag. */ + private final boolean rollbackOnly; + + /** Implicit flag. */ + private final boolean implicit; + + /** + * @param xid Xid. + * @param nodeId Node ID. + * @param threadId Thread ID. + * @param startTime Start time. + * @param isolation Isolation. + * @param concurrency Concurrency. + * @param invalidate Invalidate flag. + * @param implicit Implicit flag. + * @param timeout Transaction timeout. + * @param state Transaction state. + * @param rollbackOnly Rollback-only flag. + */ + TxShadow(IgniteUuid xid, UUID nodeId, long threadId, long startTime, IgniteTxIsolation isolation, + IgniteTxConcurrency concurrency, boolean invalidate, boolean implicit, long timeout, + IgniteTxState state, boolean rollbackOnly) { + this.xid = xid; + this.nodeId = nodeId; + this.threadId = threadId; + this.startTime = startTime; + this.isolation = isolation; + this.concurrency = concurrency; + this.invalidate = invalidate; + this.implicit = implicit; + this.timeout = timeout; + this.state = state; + this.rollbackOnly = rollbackOnly; + } + + /** {@inheritDoc} */ + @Override public IgniteUuid xid() { + return xid; + } + + /** {@inheritDoc} */ + @Override public UUID nodeId() { + return nodeId; + } + + /** {@inheritDoc} */ + @Override public long threadId() { + return threadId; + } + + /** {@inheritDoc} */ + @Override public long startTime() { + return startTime; + } + + /** {@inheritDoc} */ + @Override public IgniteTxIsolation isolation() { + return isolation; + } + + /** {@inheritDoc} */ + @Override public IgniteTxConcurrency concurrency() { + return concurrency; + } + + /** {@inheritDoc} */ + @Override public boolean isInvalidate() { + return invalidate; + } + + /** {@inheritDoc} */ + @Override public boolean implicit() { + return implicit; + } + + /** {@inheritDoc} */ + @Override public long timeout() { + return timeout; + } + + /** {@inheritDoc} */ + @Override public IgniteTxState state() { + return state; + } + + /** {@inheritDoc} */ + @Override public boolean isRollbackOnly() { + return rollbackOnly; + } + + /** {@inheritDoc} */ + @Override public long timeout(long timeout) { + throw new IllegalStateException("Deserialized transaction can only be used as read-only."); + } + + /** {@inheritDoc} */ + @Override public boolean setRollbackOnly() { + throw new IllegalStateException("Deserialized transaction can only be used as read-only."); + } + + /** {@inheritDoc} */ + @Override public void commit() { + throw new IllegalStateException("Deserialized transaction can only be used as read-only."); + } + + /** {@inheritDoc} */ + @Override public void close() { + throw new IllegalStateException("Deserialized transaction can only be used as read-only."); + } + + /** {@inheritDoc} */ + @Override public IgniteFuture commitAsync() { + throw new IllegalStateException("Deserialized transaction can only be used as read-only."); + } + + /** {@inheritDoc} */ + @Override public void rollback() { + throw new IllegalStateException("Deserialized transaction can only be used as read-only."); + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + return this == o || o instanceof IgniteTx && xid.equals(((IgniteTx)o).xid()); + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + return xid.hashCode(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(TxShadow.class, this); + } + } +}