Repository: ignite Updated Branches: refs/heads/ignite-single-op-tx c91d8c7c7 -> 8c8c5b596
'Single' operations optimizations for tx cache. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8c8c5b59 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8c8c5b59 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8c8c5b59 Branch: refs/heads/ignite-single-op-tx Commit: 8c8c5b5962ebce61ecc9bc1667ed550b5d788816 Parents: c91d8c7 Author: sboikov <[email protected]> Authored: Fri Nov 13 16:42:29 2015 +0300 Committer: sboikov <[email protected]> Committed: Fri Nov 13 17:04:34 2015 +0300 ---------------------------------------------------------------------- .../GridDistributedTxRemoteAdapter.java | 14 ++ ...arOptimisticSerializableTxPrepareFuture.java | 2 - .../near/GridNearOptimisticTxPrepareFuture.java | 2 - ...ridNearOptimisticTxPrepareFutureAdapter.java | 2 - .../cache/transactions/IgniteTxAdapter.java | 16 +- .../IgniteTxImplicitSingleStateImpl.java | 151 +++++++++++++++++++ .../transactions/IgniteTxImplicitStateImpl.java | 151 ------------------- .../transactions/IgniteTxLocalAdapter.java | 15 +- .../transactions/IgniteTxRemoteStateImpl.java | 107 +++++++++++++ .../cache/transactions/IgniteTxState.java | 2 + 10 files changed, 288 insertions(+), 174 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/8c8c5b59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java index aa9a31e..bf37b3b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java @@ -45,6 +45,9 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteTxAdapter; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxRemoteEx; +import org.apache.ignite.internal.processors.cache.transactions.IgniteTxRemoteStateImpl; +import org.apache.ignite.internal.processors.cache.transactions.IgniteTxState; +import org.apache.ignite.internal.processors.cache.transactions.IgniteTxStateImpl; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.cache.version.GridCacheVersionConflictContext; import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException; @@ -109,6 +112,10 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter @GridToStringInclude private AtomicBoolean commitAllowed = new AtomicBoolean(false); + /** */ + @GridToStringInclude + protected IgniteTxState txState; + /** * Empty constructor required for {@link Externalizable}. */ @@ -166,6 +173,8 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter this.rmtThreadId = rmtThreadId; this.invalidate = invalidate; + txState = new IgniteTxRemoteStateImpl(); + commitVersion(commitVer); // Must set started flag after concurrency and isolation. @@ -173,6 +182,11 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter } /** {@inheritDoc} */ + @Override public IgniteTxState txState() { + return txState; + } + + /** {@inheritDoc} */ @Override public UUID eventNodeId() { return nodeId; } http://git-wip-us.apache.org/repos/asf/ignite/blob/8c8c5b59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java index 0ff8eae..53bd818 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java @@ -29,7 +29,6 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.cluster.ClusterTopologyException; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; -import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; @@ -57,7 +56,6 @@ import org.apache.ignite.internal.util.typedef.CI1; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.P1; import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; http://git-wip-us.apache.org/repos/asf/ignite/blob/8c8c5b59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java index 2a6d940..8574b28 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java @@ -28,7 +28,6 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.cluster.ClusterTopologyException; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; -import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; @@ -50,7 +49,6 @@ import org.apache.ignite.internal.util.typedef.C1; import org.apache.ignite.internal.util.typedef.CI1; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteClosure; http://git-wip-us.apache.org/repos/asf/ignite/blob/8c8c5b59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java index 92fbfec..6b7244a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java @@ -20,13 +20,11 @@ package org.apache.ignite.internal.processors.cache.distributed.near; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.util.lang.GridPlainRunnable; import org.apache.ignite.internal.util.typedef.CI1; -import org.apache.ignite.internal.util.typedef.internal.U; import org.jetbrains.annotations.Nullable; /** http://git-wip-us.apache.org/repos/asf/ignite/blob/8c8c5b59/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 d846ae1..0d62fcd 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 @@ -247,9 +247,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter @GridToStringExclude private TransactionProxyImpl proxy; - /** */ - protected IgniteTxState txState; - /** * Empty constructor required for {@link Externalizable}. */ @@ -313,8 +310,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter threadId = Thread.currentThread().getId(); - txState = implicitSingle ? new IgniteTxImplicitStateImpl() : new IgniteTxStateImpl(); - if (log == null) log = U.logger(cctx.kernalContext(), logRef, this); } @@ -364,18 +359,11 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implicit = false; loc = false; - txState = new IgniteTxStateImpl(); - if (log == null) log = U.logger(cctx.kernalContext(), logRef, this); } /** {@inheritDoc} */ - @Override public IgniteTxState txState() { - return txState; - } - - /** {@inheritDoc} */ @Override public boolean localResult() { assert originatingNodeId() != null; @@ -427,7 +415,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter /** {@inheritDoc} */ @Override public boolean storeUsed() { - return storeEnabled() && txState.storeUsed(cctx); + return storeEnabled() && txState().storeUsed(cctx); } @@ -614,7 +602,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter /** {@inheritDoc} */ @Override public boolean implicitSingle() { - return txState.implicitSingle(); + return txState().implicitSingle(); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/ignite/blob/8c8c5b59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java new file mode 100644 index 0000000..b71a045 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java @@ -0,0 +1,151 @@ +/* + * 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.transactions; + +import java.util.Collection; +import java.util.Collections; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture; +import org.apache.ignite.internal.processors.cache.store.CacheStoreManager; +import org.apache.ignite.internal.util.future.GridFutureAdapter; +import org.apache.ignite.internal.util.typedef.internal.CU; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.jetbrains.annotations.Nullable; + +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; + +/** + * + */ +public class IgniteTxImplicitSingleStateImpl extends IgniteTxStateAdapter { + /** */ + private GridCacheContext cacheCtx; + + /** {@inheritDoc} */ + @Override public void addActiveCache(GridCacheContext ctx, IgniteTxLocalAdapter tx) + throws IgniteCheckedException { + assert cacheCtx == null : "Cache already set [cur=" + cacheCtx.name() + ", new=" + ctx.name() + ']'; + + this.cacheCtx = ctx; + } + + /** {@inheritDoc} */ + @Nullable @Override public Integer firstCacheId() { + return cacheCtx != null ? cacheCtx.cacheId() : null; + } + + /** {@inheritDoc} */ + @Override public void awaitLastFut(GridCacheSharedContext ctx) { + if (cacheCtx == null) + return; + + cacheCtx.cache().awaitLastFut(); + } + + /** {@inheritDoc} */ + @Override public boolean implicitSingle() { + return true; + } + + /** {@inheritDoc} */ + @Override public IgniteCheckedException validateTopology(GridCacheSharedContext cctx, GridDhtTopologyFuture topFut) { + if (cacheCtx == null) + return null; + + Throwable err = topFut.validateCache(cacheCtx); + + if (err != null) { + return new IgniteCheckedException("Failed to perform cache operation (cache topology is not valid): " + + U.maskName(cacheCtx.name())); + } + + if (CU.affinityNodes(cacheCtx, topFut.topologyVersion()).isEmpty()) { + return new ClusterTopologyServerNotFoundException("Failed to map keys for cache (all " + + "partition nodes left the grid): " + cacheCtx.name()); + } + + return null; + } + + /** {@inheritDoc} */ + @Override public boolean sync(GridCacheSharedContext cctx) { + return cacheCtx != null && cacheCtx.config().getWriteSynchronizationMode() == FULL_SYNC; + } + + /** {@inheritDoc} */ + @Override public boolean hasNearCache(GridCacheSharedContext cctx) { + return cacheCtx != null && cacheCtx.isNear(); + } + + /** {@inheritDoc} */ + @Override public GridDhtTopologyFuture topologyReadLock(GridCacheSharedContext cctx, GridFutureAdapter<?> fut) { + if (cacheCtx == null || cacheCtx.isLocal()) + return cctx.exchange().lastTopologyFuture(); + + cacheCtx.topology().readLock(); + + if (cacheCtx.topology().stopping()) { + fut.onDone(new IgniteCheckedException("Failed to perform cache operation (cache is stopped): " + + cacheCtx.name())); + + return null; + } + + return cacheCtx.topology().topologyVersionFuture(); + } + + /** {@inheritDoc} */ + @Override public void topologyReadUnlock(GridCacheSharedContext cctx) { + if (cacheCtx == null || cacheCtx.isLocal()) + return; + + cacheCtx.topology().readUnlock(); + } + + /** {@inheritDoc} */ + @Override public boolean storeUsed(GridCacheSharedContext cctx) { + if (cacheCtx == null) + return false; + + CacheStoreManager store = cacheCtx.store(); + + return store.configured(); + } + + /** {@inheritDoc} */ + @Override public Collection<CacheStoreManager> stores(GridCacheSharedContext cctx) { + if (cacheCtx == null) + return null; + + CacheStoreManager store = cacheCtx.store(); + + if (store.configured()) + return Collections.singleton(store); + + return null; + } + + /** {@inheritDoc} */ + @Override public void onTxEnd(GridCacheSharedContext cctx, IgniteInternalTx tx, boolean commit) { + if (cacheCtx != null) + onTxEnd(cacheCtx, tx, commit); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/8c8c5b59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitStateImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitStateImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitStateImpl.java deleted file mode 100644 index 26d442b..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitStateImpl.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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.transactions; - -import java.util.Collection; -import java.util.Collections; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException; -import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture; -import org.apache.ignite.internal.processors.cache.store.CacheStoreManager; -import org.apache.ignite.internal.util.future.GridFutureAdapter; -import org.apache.ignite.internal.util.typedef.internal.CU; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; - -/** - * - */ -public class IgniteTxImplicitStateImpl extends IgniteTxStateAdapter { - /** */ - private GridCacheContext cacheCtx; - - /** {@inheritDoc} */ - @Override public void addActiveCache(GridCacheContext ctx, IgniteTxLocalAdapter tx) - throws IgniteCheckedException { - assert cacheCtx == null : "Cache already set [cur=" + cacheCtx.name() + ", new=" + ctx.name() + ']'; - - this.cacheCtx = ctx; - } - - /** {@inheritDoc} */ - @Nullable @Override public Integer firstCacheId() { - return cacheCtx != null ? cacheCtx.cacheId() : null; - } - - /** {@inheritDoc} */ - @Override public void awaitLastFut(GridCacheSharedContext ctx) { - if (cacheCtx == null) - return; - - cacheCtx.cache().awaitLastFut(); - } - - /** {@inheritDoc} */ - @Override public boolean implicitSingle() { - return true; - } - - /** {@inheritDoc} */ - @Override public IgniteCheckedException validateTopology(GridCacheSharedContext cctx, GridDhtTopologyFuture topFut) { - if (cacheCtx == null) - return null; - - Throwable err = topFut.validateCache(cacheCtx); - - if (err != null) { - return new IgniteCheckedException("Failed to perform cache operation (cache topology is not valid): " + - U.maskName(cacheCtx.name())); - } - - if (CU.affinityNodes(cacheCtx, topFut.topologyVersion()).isEmpty()) { - return new ClusterTopologyServerNotFoundException("Failed to map keys for cache (all " + - "partition nodes left the grid): " + cacheCtx.name()); - } - - return null; - } - - /** {@inheritDoc} */ - @Override public boolean sync(GridCacheSharedContext cctx) { - return cacheCtx != null && cacheCtx.config().getWriteSynchronizationMode() == FULL_SYNC; - } - - /** {@inheritDoc} */ - @Override public boolean hasNearCache(GridCacheSharedContext cctx) { - return cacheCtx != null && cacheCtx.isNear(); - } - - /** {@inheritDoc} */ - @Override public GridDhtTopologyFuture topologyReadLock(GridCacheSharedContext cctx, GridFutureAdapter<?> fut) { - if (cacheCtx == null || cacheCtx.isLocal()) - return cctx.exchange().lastTopologyFuture(); - - cacheCtx.topology().readLock(); - - if (cacheCtx.topology().stopping()) { - fut.onDone(new IgniteCheckedException("Failed to perform cache operation (cache is stopped): " + - cacheCtx.name())); - - return null; - } - - return cacheCtx.topology().topologyVersionFuture(); - } - - /** {@inheritDoc} */ - @Override public void topologyReadUnlock(GridCacheSharedContext cctx) { - if (cacheCtx == null || cacheCtx.isLocal()) - return; - - cacheCtx.topology().readUnlock(); - } - - /** {@inheritDoc} */ - @Override public boolean storeUsed(GridCacheSharedContext cctx) { - if (cacheCtx == null) - return false; - - CacheStoreManager store = cacheCtx.store(); - - return store.configured(); - } - - /** {@inheritDoc} */ - @Override public Collection<CacheStoreManager> stores(GridCacheSharedContext cctx) { - if (cacheCtx == null) - return null; - - CacheStoreManager store = cacheCtx.store(); - - if (store.configured()) - return Collections.singleton(store); - - return null; - } - - /** {@inheritDoc} */ - @Override public void onTxEnd(GridCacheSharedContext cctx, IgniteInternalTx tx, boolean commit) { - if (cacheCtx != null) - onTxEnd(cacheCtx, tx, commit); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/8c8c5b59/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 05b5ed0..25d5c22 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 @@ -66,9 +66,7 @@ import org.apache.ignite.internal.processors.dr.GridDrType; import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException; import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException; import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException; -import org.apache.ignite.internal.util.F0; import org.apache.ignite.internal.util.GridLeanMap; -import org.apache.ignite.internal.util.GridLeanSet; import org.apache.ignite.internal.util.future.GridEmbeddedFuture; import org.apache.ignite.internal.util.future.GridFinishedFuture; import org.apache.ignite.internal.util.future.GridFutureAdapter; @@ -165,6 +163,10 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter /** Flag indicating whether deployment is enabled for caches from this transaction or not. */ private boolean depEnabled; + /** */ + @GridToStringInclude + protected IgniteTxState txState; + /** * Empty constructor required for {@link Externalizable}. */ @@ -222,6 +224,13 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter ); minVer = xidVer; + + txState = implicitSingle ? new IgniteTxImplicitSingleStateImpl() : new IgniteTxStateImpl(); + } + + /** {@inheritDoc} */ + @Override public IgniteTxState txState() { + return txState; } /** @@ -3434,7 +3443,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter */ public boolean init() { if (txMap == null) { - txMap = new LinkedHashMap<>(txSize > 0 ? txSize : 16, 1.0f); + txMap = U.newLinkedHashMap(txSize > 0 ? txSize : 16); readView = new IgniteTxMap(txMap, CU.reads()); writeView = new IgniteTxMap(txMap, CU.writes()); http://git-wip-us.apache.org/repos/asf/ignite/blob/8c8c5b59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteStateImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteStateImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteStateImpl.java new file mode 100644 index 0000000..2a61d11 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteStateImpl.java @@ -0,0 +1,107 @@ +/* + * 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.transactions; + +import java.util.Collection; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture; +import org.apache.ignite.internal.processors.cache.store.CacheStoreManager; +import org.apache.ignite.internal.util.future.GridFutureAdapter; +import org.jetbrains.annotations.Nullable; + +/** + * + */ +public class IgniteTxRemoteStateImpl implements IgniteTxState { + /** {@inheritDoc} */ + @Override public boolean implicitSingle() { + return false; + } + + /** {@inheritDoc} */ + @Nullable @Override public Integer firstCacheId() { + assert false; + + return null; + } + + /** {@inheritDoc} */ + @Override public void awaitLastFut(GridCacheSharedContext cctx) { + assert false; + } + + /** {@inheritDoc} */ + @Override public IgniteCheckedException validateTopology(GridCacheSharedContext cctx, GridDhtTopologyFuture topFut) { + assert false; + + return null; + } + + /** {@inheritDoc} */ + @Override public boolean sync(GridCacheSharedContext cctx) { + assert false; + + return false; + } + + /** {@inheritDoc} */ + @Override public boolean hasNearCache(GridCacheSharedContext cctx) { + assert false; + + return false; + } + + /** {@inheritDoc} */ + @Override public void addActiveCache(GridCacheContext cacheCtx, IgniteTxLocalAdapter tx) + throws IgniteCheckedException { + assert false; + } + + /** {@inheritDoc} */ + @Override public GridDhtTopologyFuture topologyReadLock(GridCacheSharedContext cctx, GridFutureAdapter<?> fut) { + assert false; + + return null; + } + + /** {@inheritDoc} */ + @Override public void topologyReadUnlock(GridCacheSharedContext cctx) { + assert false; + } + + /** {@inheritDoc} */ + @Override public boolean storeUsed(GridCacheSharedContext cctx) { + assert false; + + return false; + } + + /** {@inheritDoc} */ + @Override public Collection<CacheStoreManager> stores(GridCacheSharedContext cctx) { + assert false; + + return null; + } + + /** {@inheritDoc} */ + @Override public void onTxEnd(GridCacheSharedContext cctx, IgniteInternalTx tx, boolean commit) { + assert false; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/8c8c5b59/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxState.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxState.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxState.java index 856ae04..5938453 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxState.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxState.java @@ -53,4 +53,6 @@ public interface IgniteTxState { public Collection<CacheStoreManager> stores(GridCacheSharedContext cctx); public void onTxEnd(GridCacheSharedContext cctx, IgniteInternalTx tx, boolean commit); + + // public IgniteTxEntry entry(IgniteTxKey key); }
