This is an automated email from the ASF dual-hosted git repository. av pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push: new a2053f11cb2 IGNITE-21888 Remove MvccVersion and MvccUpdateVersionAware (#11320) a2053f11cb2 is described below commit a2053f11cb22af2a6d9bf6f154807104ab84ff73 Author: Julia Bakulina <96814257+j-bak...@users.noreply.github.com> AuthorDate: Mon Apr 22 16:26:57 2024 +0300 IGNITE-21888 Remove MvccVersion and MvccUpdateVersionAware (#11320) --- .../communication/GridIoMessageFactory.java | 2 - .../processors/cache/GridCacheEntryEx.java | 13 +- .../processors/cache/GridCacheMapEntry.java | 13 - .../cache/distributed/dht/GridDhtLockFuture.java | 2 - .../distributed/dht/GridDhtTxPrepareFuture.java | 2 - .../dht/preloader/GridDhtForceKeysFuture.java | 2 - .../dht/preloader/GridDhtPartitionDemander.java | 2 - .../processors/cache/mvcc/MvccSnapshot.java | 2 +- .../cache/mvcc/MvccSnapshotWithoutTxs.java | 15 - .../cache/mvcc/MvccUpdateVersionAware.java | 76 --- .../internal/processors/cache/mvcc/MvccUtils.java | 681 --------------------- .../processors/cache/mvcc/MvccVersion.java | 48 -- .../processors/cache/mvcc/MvccVersionImpl.java | 192 ------ .../processors/cache/mvcc/txlog/TxState.java | 3 - .../persistence/tree/io/AbstractDataPageIO.java | 17 - .../cache/persistence/tree/io/DataPageIO.java | 90 --- .../IgniteTxAlreadyCompletedCheckedException.java | 36 -- .../IgniteTxSerializationCheckedException.java | 35 -- .../IgniteTxUnexpectedStateCheckedException.java | 45 -- .../apache/ignite/internal/util/IgniteUtils.java | 16 - .../main/resources/META-INF/classnames.properties | 4 - .../processors/cache/GridCacheTestEntryEx.java | 3 - .../snapshot/IgniteClusterSnapshotCheckTest.java | 2 - 23 files changed, 3 insertions(+), 1298 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java index fa54ad5fa72..f3ee72314c9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java @@ -111,7 +111,6 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPr import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearUnlockRequest; import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshotWithoutTxs; -import org.apache.ignite.internal.processors.cache.mvcc.MvccVersionImpl; import org.apache.ignite.internal.processors.cache.persistence.snapshot.IncrementalSnapshotAwareMessage; import org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotFilesFailureMessage; import org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotFilesRequestMessage; @@ -317,7 +316,6 @@ public class GridIoMessageFactory implements MessageFactoryProvider { factory.register((short)133, ClusterMetricsUpdateMessage::new); factory.register((short)134, ContinuousRoutineStartResultMessage::new); factory.register((short)135, LatchAckMessage::new); - factory.register((short)148, MvccVersionImpl::new); factory.register((short)150, MvccSnapshotWithoutTxs::new); factory.register((short)157, PartitionUpdateCountersMessage::new); factory.register((short)158, GridDhtPartitionSupplyMessageV2::new); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java index a3bbd564bd0..9c57ab854e2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java @@ -26,7 +26,6 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockCancelledException; import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicAbstractUpdateFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; -import org.apache.ignite.internal.processors.cache.mvcc.MvccVersion; import org.apache.ignite.internal.processors.cache.mvcc.txlog.TxState; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; @@ -619,7 +618,7 @@ public interface GridCacheEntryEx { GridDrType drType, boolean fromStore, boolean primary) throws IgniteCheckedException, GridCacheEntryRemovedException { - return initialValue(val, ver, null, null, TxState.NA, TxState.NA, + return initialValue(val, ver, TxState.NA, TxState.NA, ttl, expireTime, preload, topVer, drType, fromStore, primary); } @@ -628,8 +627,6 @@ public interface GridCacheEntryEx { * * @param val New value. * @param ver Version to use. - * @param mvccVer Mvcc version. - * @param newMvccVer New mvcc version. * @param mvccTxState Tx state hint for mvcc version. * @param newMvccTxState Tx state hint for new mvcc version. * @param ttl Time to live. @@ -645,8 +642,6 @@ public interface GridCacheEntryEx { */ default boolean initialValue(CacheObject val, GridCacheVersion ver, - @Nullable MvccVersion mvccVer, - @Nullable MvccVersion newMvccVer, byte mvccTxState, byte newMvccTxState, long ttl, @@ -656,7 +651,7 @@ public interface GridCacheEntryEx { GridDrType drType, boolean fromStore, boolean primary) throws IgniteCheckedException, GridCacheEntryRemovedException { - return initialValue(val, ver, null, null, TxState.NA, TxState.NA, + return initialValue(val, ver, TxState.NA, TxState.NA, ttl, expireTime, preload, topVer, drType, fromStore, primary, null); } @@ -665,8 +660,6 @@ public interface GridCacheEntryEx { * * @param val New value. * @param ver Version to use. - * @param mvccVer Mvcc version. - * @param newMvccVer New mvcc version. * @param mvccTxState Tx state hint for mvcc version. * @param newMvccTxState Tx state hint for new mvcc version. * @param ttl Time to live. @@ -683,8 +676,6 @@ public interface GridCacheEntryEx { */ public boolean initialValue(CacheObject val, GridCacheVersion ver, - @Nullable MvccVersion mvccVer, - @Nullable MvccVersion newMvccVer, byte mvccTxState, byte newMvccTxState, long ttl, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java index e1b4b4c636e..14defe52743 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java @@ -54,7 +54,6 @@ import org.apache.ignite.internal.processors.cache.extras.GridCacheEntryExtras; import org.apache.ignite.internal.processors.cache.extras.GridCacheMvccEntryExtras; import org.apache.ignite.internal.processors.cache.extras.GridCacheObsoleteEntryExtras; import org.apache.ignite.internal.processors.cache.extras.GridCacheTtlEntryExtras; -import org.apache.ignite.internal.processors.cache.mvcc.MvccVersion; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter; import org.apache.ignite.internal.processors.cache.persistence.DataRegion; @@ -74,7 +73,6 @@ import org.apache.ignite.internal.processors.dr.GridDrType; import org.apache.ignite.internal.processors.platform.PlatformProcessor; import org.apache.ignite.internal.processors.query.schema.SchemaIndexCacheVisitorClosure; import org.apache.ignite.internal.processors.security.SecurityUtils; -import org.apache.ignite.internal.transactions.IgniteTxSerializationCheckedException; import org.apache.ignite.internal.util.IgniteTree; import org.apache.ignite.internal.util.lang.GridClosureException; import org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter; @@ -2499,8 +2497,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme @Override public boolean initialValue( CacheObject val, GridCacheVersion ver, - MvccVersion mvccVer, - MvccVersion newMvccVer, byte mvccTxState, byte newMvccTxState, long ttl, @@ -5414,15 +5410,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme } } - /** - * @return Common serialization error. - */ - private static IgniteTxSerializationCheckedException serializationError() { - return new IgniteTxSerializationCheckedException( - "Cannot serialize transaction due to write conflict (transaction is marked for rollback)" - ); - } - /** * Invokes platform cache update callback, if applicable. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java index d937006ce13..35183fc301e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java @@ -1349,8 +1349,6 @@ public final class GridDhtLockFuture extends GridCacheCompoundIdentityFuture<Boo try { if (entry.initialValue(info.value(), info.version(), - null, - null, TxState.NA, TxState.NA, info.ttl(), diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java index 9eee87b3845..280a8600cad 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java @@ -1974,8 +1974,6 @@ public final class GridDhtTxPrepareFuture extends GridCacheCompoundFuture<Ignite try { if (entry.initialValue(info.value(), info.version(), - null, - null, TxState.NA, TxState.NA, info.ttl(), diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java index 9a42bb00296..8cb91b5588b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java @@ -534,8 +534,6 @@ public final class GridDhtForceKeysFuture<K, V> extends GridCompoundFuture<Objec if (entry.initialValue( info.value(), info.version(), - null, - null, TxState.NA, TxState.NA, info.ttl(), diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java index 19a582474f4..3e1bb80addb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java @@ -823,8 +823,6 @@ public class GridDhtPartitionDemander { if (cached.initialValue( row.value(), row.version(), - null, - null, TxState.NA, TxState.NA, TTL_ETERNAL, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccSnapshot.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccSnapshot.java index 8dac3314dda..53bbff006c1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccSnapshot.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccSnapshot.java @@ -25,7 +25,7 @@ import org.apache.ignite.plugin.extensions.communication.Message; * - List of active transactions which should not be visible to current transaction * - Cleanup version which is used to help vacuum process. */ -public interface MvccSnapshot extends MvccVersion, Message { +public interface MvccSnapshot extends Message { /** * @return Cleanup version (all smaller versions are safe to remove). */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccSnapshotWithoutTxs.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccSnapshotWithoutTxs.java index 3e75cd7bdef..2e589798e08 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccSnapshotWithoutTxs.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccSnapshotWithoutTxs.java @@ -61,26 +61,11 @@ public class MvccSnapshotWithoutTxs implements MvccSnapshot { this.opCntr = opCntr; } - /** {@inheritDoc} */ - @Override public long coordinatorVersion() { - return crdVer; - } - /** {@inheritDoc} */ @Override public long cleanupVersion() { return cleanupVer; } - /** {@inheritDoc} */ - @Override public long counter() { - return cntr; - } - - /** {@inheritDoc} */ - @Override public int operationCounter() { - return opCntr; - } - /** {@inheritDoc} */ @Override public void incrementOperationCounter() { throw new UnsupportedOperationException(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUpdateVersionAware.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUpdateVersionAware.java deleted file mode 100644 index 17804c49887..00000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUpdateVersionAware.java +++ /dev/null @@ -1,76 +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.mvcc; - -/** - * Interface for objects aware theirs mvcc update version. - */ -public interface MvccUpdateVersionAware { - /** - * @return New mvcc coordinator version. - */ - public long newMvccCoordinatorVersion(); - - /** - * @return New mvcc counter. - */ - public long newMvccCounter(); - - /** - * @return New mvcc operation counter. - */ - public int newMvccOperationCounter(); - - /** - * @return New Tx state. - */ - public byte newMvccTxState(); - - /** - * Copies new MVCC version - * @param other Object to copy version from. - */ - public default void newMvccVersion(MvccUpdateVersionAware other) { - newMvccVersion(other.newMvccCoordinatorVersion(), other.newMvccCounter(), other.newMvccOperationCounter()); - } - - /** - * Sets new MVCC version - * @param ver MVCC version. - */ - public default void newMvccVersion(MvccVersion ver) { - newMvccVersion(ver.coordinatorVersion(), ver.counter(), ver.operationCounter()); - } - - /** - * Sets new mvcc version. - * @param crd New mvcc coordinator version. - * @param cntr New mvcc counter. - * @param opCntr New mvcc operation counter. - */ - public default void newMvccVersion(long crd, long cntr, int opCntr) { - throw new UnsupportedOperationException(); - } - - /** - * @return New mvcc version. - */ - public default MvccVersion newMvccVersion() { - return new MvccVersionImpl(newMvccCoordinatorVersion(), newMvccCounter(), newMvccOperationCounter()); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUtils.java index a14b26298a3..4c7f3954a65 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUtils.java @@ -17,558 +17,18 @@ package org.apache.ignite.internal.processors.cache.mvcc; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.processors.cache.CacheGroupContext; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal; -import org.apache.ignite.internal.processors.cache.mvcc.txlog.TxState; -import org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPageIO; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.internal.transactions.IgniteTxAlreadyCompletedCheckedException; -import org.apache.ignite.internal.transactions.IgniteTxUnexpectedStateCheckedException; -import org.apache.ignite.internal.util.typedef.internal.CU; -import org.apache.ignite.transactions.TransactionState; import org.apache.ignite.transactions.TransactionUnsupportedConcurrencyException; import org.jetbrains.annotations.Nullable; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; -import static org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPageIO.MVCC_INFO_SIZE; -import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; -import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; - /** * Utils for MVCC. */ public class MvccUtils { - /** */ - public static final int MVCC_KEY_ABSENT_BEFORE_OFF = 29; - - /** */ - public static final int MVCC_HINTS_BIT_OFF = MVCC_KEY_ABSENT_BEFORE_OFF + 1; - - /** Mask for KeyAbsent flag. */ - public static final int MVCC_KEY_ABSENT_BEFORE_MASK = 1 << MVCC_KEY_ABSENT_BEFORE_OFF; - - /** Mask for tx hints. (2 highest bits) */ - public static final int MVCC_HINTS_MASK = Integer.MIN_VALUE >> 1; - - /** Mask for operation counter bits. (Excludes hints and flags) */ - public static final int MVCC_OP_COUNTER_MASK = ~(Integer.MIN_VALUE >> 2); - - /** */ - public static final long MVCC_CRD_COUNTER_NA = 0L; - - /** */ - public static final long MVCC_CRD_START_CNTR = 1L; - - /** */ - public static final long MVCC_COUNTER_NA = 0L; - - /** */ - public static final long MVCC_INITIAL_CNTR = 1L; - - /** */ - public static final long MVCC_START_CNTR = 3L; - - /** */ - public static final int MVCC_OP_COUNTER_NA = 0; - - /** */ - public static final int MVCC_START_OP_CNTR = 1; - - /** Used as 'read' snapshot op counter. */ - public static final int MVCC_READ_OP_CNTR = MVCC_OP_COUNTER_MASK; - - /** */ - public static final int MVCC_INVISIBLE = 0; - - /** */ - public static final int MVCC_VISIBLE_REMOVED = 1; - - /** */ - public static final int MVCC_VISIBLE = 2; - - /** A special version visible by everyone */ - public static final MvccVersion INITIAL_VERSION = - mvccVersion(MVCC_CRD_START_CNTR, MVCC_INITIAL_CNTR, MVCC_START_OP_CNTR); - - /** A special snapshot for which all committed versions are visible */ - public static final MvccSnapshot MVCC_MAX_SNAPSHOT = - new MvccSnapshotWithoutTxs(Long.MAX_VALUE, Long.MAX_VALUE, MVCC_READ_OP_CNTR, MVCC_COUNTER_NA); - - /** */ - private static final MvccClosure<Integer> getVisibleState = new GetVisibleState(); - - /** */ - private static final MvccClosure<Boolean> isVisible = new IsVisible(); - - /** */ - private static final MvccClosure<MvccVersion> getNewVer = new GetNewVersion(); - - /** - * - */ - private MvccUtils() { - } - - /** - * @param cctx Cache context. - * @param mvccCrd Mvcc coordinator version. - * @param mvccCntr Mvcc counter. - * @param snapshot Snapshot. - * @return {@code True} if transaction is active. - * @see TxState - * @throws IgniteCheckedException If failed. - */ - public static boolean isActive(GridCacheContext cctx, long mvccCrd, long mvccCntr, MvccSnapshot snapshot) - throws IgniteCheckedException { - if (isVisible(cctx, snapshot, mvccCrd, mvccCntr, MVCC_OP_COUNTER_NA, false)) - return false; - - byte state; - - return (state = state(cctx, mvccCrd, mvccCntr, 0)) != TxState.COMMITTED && state != TxState.ABORTED; - } - - /** - * @param cctx Cache context. - * @param mvccCrd Mvcc coordinator version. - * @param mvccCntr Mvcc counter. - * @param mvccOpCntr Mvcc operation counter. - * @return TxState - * @see TxState - */ - public static byte state(GridCacheContext cctx, long mvccCrd, long mvccCntr, int mvccOpCntr) { - return TxState.NA; - } - - /** - * @param grp Cache group context. - * @param mvccCrd Mvcc coordinator version. - * @param mvccCntr Mvcc counter. - * @param mvccOpCntr Mvcc operation counter. - * @return TxState - * @see TxState - */ - public static byte state(CacheGroupContext grp, long mvccCrd, long mvccCntr, int mvccOpCntr) { - return TxState.NA; - } - - /** - * Checks if version is visible from the given snapshot. - * - * @param cctx Cache context. - * @param snapshot Snapshot. - * @param mvccCrd Mvcc coordinator. - * @param mvccCntr Mvcc counter. - * @param opCntr Operation counter. - * @return {@code True} if visible. - * @throws IgniteCheckedException If failed. - */ - public static boolean isVisible(GridCacheContext cctx, MvccSnapshot snapshot, long mvccCrd, long mvccCntr, - int opCntr) throws IgniteCheckedException { - return isVisible(cctx, snapshot, mvccCrd, mvccCntr, opCntr, true); - } - - /** - * Checks if version is visible from the given snapshot. - * - * @param cctx Cache context. - * @param snapshot Snapshot. - * @param mvccCrd Mvcc coordinator. - * @param mvccCntr Mvcc counter. - * @param opCntrWithHints Operation counter. - * @param useTxLog {@code True} if TxLog should be used. - * @return {@code True} if visible. - * @throws IgniteCheckedException If failed. - */ - public static boolean isVisible(GridCacheContext cctx, MvccSnapshot snapshot, long mvccCrd, long mvccCntr, - int opCntrWithHints, boolean useTxLog) throws IgniteCheckedException { - int opCntr = opCntrWithHints & MVCC_OP_COUNTER_MASK; - - if (mvccCrd == MVCC_CRD_COUNTER_NA) { - assert mvccCntr == MVCC_COUNTER_NA && opCntrWithHints == MVCC_OP_COUNTER_NA - : "rowVer=" + mvccVersion(mvccCrd, mvccCntr, opCntrWithHints) + ", snapshot=" + snapshot; - - return false; // Unassigned version is always invisible - } - - if (compare(INITIAL_VERSION, mvccCrd, mvccCntr, opCntr) == 0) - return true; // Initial version is always visible - - long snapshotCrd = snapshot.coordinatorVersion(); - - long snapshotCntr = snapshot.counter(); - int snapshotOpCntr = snapshot.operationCounter(); - - assert (snapshotOpCntr & ~MVCC_OP_COUNTER_MASK) == 0 : snapshot; - - if (mvccCrd > snapshotCrd) - return false; // Rows in the future are never visible. - - if (mvccCrd < snapshotCrd) { - if (!useTxLog) - return true; // The checking row is expected to be committed. - - byte state = state(cctx, mvccCrd, mvccCntr, opCntrWithHints); - - if (MVCC_MAX_SNAPSHOT.compareTo(snapshot) != 0 // Special version which sees all committed entries. - && state != TxState.COMMITTED && state != TxState.ABORTED) - throw unexpectedStateException(cctx, state, mvccCrd, mvccCntr, opCntrWithHints, snapshot); - - return state == TxState.COMMITTED; - } - - if (mvccCntr > snapshotCntr) // we don't see future updates - return false; - - // Basically we can make fast decision about visibility if found rows from the same transaction. - // But we can't make such decision for read-only queries, - // because read-only queries use last committed version in it's snapshot which could be actually aborted - // (during transaction recovery we do not know whether recovered transaction was committed or aborted). - if (mvccCntr == snapshotCntr && snapshotOpCntr != MVCC_READ_OP_CNTR) { - assert opCntr <= snapshotOpCntr : "rowVer=" + mvccVersion(mvccCrd, mvccCntr, opCntrWithHints) + ", snapshot=" + snapshot; - - return opCntr < snapshotOpCntr; // we don't see own pending updates - } - - if (!useTxLog) - return true; // The checking row is expected to be committed. - - byte state = state(cctx, mvccCrd, mvccCntr, opCntrWithHints); - - if (state != TxState.COMMITTED && state != TxState.ABORTED) - throw unexpectedStateException(cctx, state, mvccCrd, mvccCntr, opCntrWithHints, snapshot); - - return state == TxState.COMMITTED; - } - - /** - * - * @param grp Cache group context. - * @param state State. - * @param crd Mvcc coordinator counter. - * @param cntr Mvcc counter. - * @param opCntr Mvcc operation counter. - * @return State exception. - */ - public static IgniteTxUnexpectedStateCheckedException unexpectedStateException( - CacheGroupContext grp, byte state, long crd, long cntr, - int opCntr) { - return unexpectedStateException(grp.shared().kernalContext(), state, crd, cntr, opCntr, null); - } - - /** - * - * @param cctx Cache context. - * @param state State. - * @param crd Mvcc coordinator counter. - * @param cntr Mvcc counter. - * @param opCntr Mvcc operation counter. - * @param snapshot Mvcc snapshot - * @return State exception. - */ - public static IgniteTxUnexpectedStateCheckedException unexpectedStateException( - GridCacheContext cctx, byte state, long crd, long cntr, - int opCntr, MvccSnapshot snapshot) { - return unexpectedStateException(cctx.kernalContext(), state, crd, cntr, opCntr, snapshot); - } - - /** */ - private static IgniteTxUnexpectedStateCheckedException unexpectedStateException(GridKernalContext ctx, byte state, long crd, long cntr, - int opCntr, MvccSnapshot snapshot) { - String msg = "Unexpected state: [state=" + state + ", rowVer=" + crd + ":" + cntr + ":" + opCntr; - - if (snapshot != null) - msg += ", txVer=" + snapshot.coordinatorVersion() + ":" + snapshot.counter() + ":" + snapshot.operationCounter(); - - msg += ", localNodeId=" + ctx.localNodeId() + "]"; - - return new IgniteTxUnexpectedStateCheckedException(msg); - } - - /** - * Checks visibility of the given row versions from the given snapshot. - * - * @param cctx Context. - * @param snapshot Snapshot. - * @param crd Mvcc coordinator counter. - * @param cntr Mvcc counter. - * @param opCntr Mvcc operation counter. - * @param link Link to data row (new version is located there). - * @return Visibility status. - * @throws IgniteCheckedException If failed. - */ - public static boolean isVisible(GridCacheContext cctx, MvccSnapshot snapshot, long crd, long cntr, - int opCntr, long link) throws IgniteCheckedException { - return isVisible(cctx, snapshot, crd, cntr, opCntr, false) - && isVisible(cctx, link, snapshot); - } - - /** - * Checks if a row has not empty new version (xid_max). - * - * @param row Row. - * @return {@code True} if row has a new version. - */ - public static boolean hasNewVersion(MvccUpdateVersionAware row) { - assert row.newMvccCoordinatorVersion() == MVCC_CRD_COUNTER_NA - || mvccVersionIsValid(row.newMvccCoordinatorVersion(), row.newMvccCounter(), row.newMvccOperationCounter()); - - return row.newMvccCoordinatorVersion() > MVCC_CRD_COUNTER_NA; - } - - /** - * Checks if a row's new version is visible for the given snapshot. - * - * @param cctx Cache context. - * @param link Link to the row. - * @param snapshot Mvcc snapshot. - * @return {@code True} if row is visible for the given snapshot. - * @throws IgniteCheckedException If failed. - */ - public static int getVisibleState(GridCacheContext cctx, long link, MvccSnapshot snapshot) - throws IgniteCheckedException { - return invoke(cctx, link, getVisibleState, snapshot); - } - - /** - * Returns new version of row (xid_max) if any. - * - * @param cctx Cache context. - * @param link Link to the row. - * @return New {@code MvccVersion} if row has xid_max, or null if doesn't. - * @throws IgniteCheckedException If failed. - */ - public static MvccVersion getNewVersion(GridCacheContext cctx, long link) - throws IgniteCheckedException { - return invoke(cctx, link, getNewVer, null); - } - - /** - * Compares to pairs of MVCC versions. See {@link Comparable}. - * - * @param mvccVerLeft First MVCC version. - * @param mvccCrdRight Second coordinator version. - * @param mvccCntrRight Second counter. - * @return Comparison result, see {@link Comparable}. - */ - public static int compare(MvccVersion mvccVerLeft, long mvccCrdRight, long mvccCntrRight) { - return compare(mvccVerLeft.coordinatorVersion(), mvccVerLeft.counter(), mvccCrdRight, mvccCntrRight); - } - - /** - * Compares to pairs of MVCC versions. See {@link Comparable}. - * - * @param mvccVerLeft First MVCC version. - * @param mvccCrdRight Second coordinator version. - * @param mvccCntrRight Second counter. - * @param mvccOpCntrRight Second operation counter. - * @return Comparison result, see {@link Comparable}. - */ - public static int compare(MvccVersion mvccVerLeft, long mvccCrdRight, long mvccCntrRight, int mvccOpCntrRight) { - return compare(mvccVerLeft.coordinatorVersion(), mvccVerLeft.counter(), - mvccVerLeft.operationCounter(), mvccCrdRight, mvccCntrRight, mvccOpCntrRight); - } - - /** - * Compares to pairs of coordinator/counter versions. See {@link Comparable}. - * - * @param mvccCrdLeft First coordinator version. - * @param mvccCntrLeft First counter version. - * @param mvccCrdRight Second coordinator version. - * @param mvccCntrRight Second counter version. - * @return Comparison result, see {@link Comparable}. - */ - public static int compare(long mvccCrdLeft, long mvccCntrLeft, long mvccCrdRight, long mvccCntrRight) { - return compare(mvccCrdLeft, mvccCntrLeft, 0, mvccCrdRight, mvccCntrRight, 0); - } - - /** - * Compares to pairs of coordinator/counter versions. See {@link Comparable}. - * - * @param mvccCrdLeft First coordinator version. - * @param mvccCntrLeft First counter version. - * @param mvccOpCntrLeft First operation counter. - * @param mvccCrdRight Second coordinator version. - * @param mvccCntrRight Second counter version. - * @param mvccOpCntrRight Second operation counter. - * @return Comparison result, see {@link Comparable}. - */ - public static int compare(long mvccCrdLeft, long mvccCntrLeft, int mvccOpCntrLeft, long mvccCrdRight, - long mvccCntrRight, int mvccOpCntrRight) { - int cmp; - - if ((cmp = Long.compare(mvccCrdLeft, mvccCrdRight)) != 0 - || (cmp = Long.compare(mvccCntrLeft, mvccCntrRight)) != 0 - || (cmp = Integer.compare(mvccOpCntrLeft & MVCC_OP_COUNTER_MASK, mvccOpCntrRight & MVCC_OP_COUNTER_MASK)) != 0) - return cmp; - - return 0; - } - - /** - * Compares left version (xid_min) with the given version ignoring operation counter. - * - * @param left Version. - * @param right Version. - * @return Comparison result, see {@link Comparable}. - */ - public static int compareIgnoreOpCounter(MvccVersion left, MvccVersion right) { - return compare(left.coordinatorVersion(), left.counter(), 0, right.coordinatorVersion(), right.counter(), 0); - } - - /** - * Compares new row version (xid_max) with the given counter and coordinator versions. - * - * @param row Row. - * @param mvccCrd Mvcc coordinator. - * @param mvccCntr Mvcc counter. - * @return Comparison result, see {@link Comparable}. - */ - public static int compareNewVersion(MvccUpdateVersionAware row, long mvccCrd, long mvccCntr) { - return compare(row.newMvccCoordinatorVersion(), row.newMvccCounter(), mvccCrd, mvccCntr); - } - - /** - * Compares new row version (xid_max) with the given counter and coordinator versions. - * - * @param row Row. - * @param mvccCrd Mvcc coordinator. - * @param mvccCntr Mvcc counter. - * @param opCntr Mvcc operation counter. - * @return Comparison result, see {@link Comparable}. - */ - public static int compareNewVersion(MvccUpdateVersionAware row, long mvccCrd, long mvccCntr, int opCntr) { - return compare(row.newMvccCoordinatorVersion(), row.newMvccCounter(), row.newMvccOperationCounter(), mvccCrd, mvccCntr, opCntr); - } - - /** - * Compares new row version (xid_max) with the given version. - * - * @param row Row. - * @param ver Version. - * @return Comparison result, see {@link Comparable}. - */ - public static int compareNewVersion(MvccUpdateVersionAware row, MvccVersion ver) { - return compare(row.newMvccCoordinatorVersion(), row.newMvccCounter(), row.newMvccOperationCounter(), - ver.coordinatorVersion(), ver.counter(), ver.operationCounter()); - } - - /** - * @param crdVer Mvcc coordinator version. - * @param cntr Counter. - * @param opCntr Operation counter. - * @return Always {@code true}. - */ - public static boolean mvccVersionIsValid(long crdVer, long cntr, int opCntr) { - return mvccVersionIsValid(crdVer, cntr) && (opCntr & MVCC_OP_COUNTER_MASK) != MVCC_OP_COUNTER_NA; - } - - /** - * @param crdVer Mvcc coordinator version. - * @param cntr Counter. - * @return {@code True} if version is valid. - */ - public static boolean mvccVersionIsValid(long crdVer, long cntr) { - return crdVer > MVCC_CRD_COUNTER_NA && cntr > MVCC_COUNTER_NA; - } - - /** - * @param cctx Cache context. - * @param link Link to the row. - * @param snapshot Mvcc snapshot. - * @return {@code True} if row is updated for given snapshot. - * @throws IgniteCheckedException If failed. - */ - private static boolean isVisible(GridCacheContext cctx, long link, - MvccSnapshot snapshot) - throws IgniteCheckedException { - return invoke(cctx, link, isVisible, snapshot); - } - - /** - * Encapsulates common logic for working with row mvcc info: page locking/unlocking, checks and other. - * Strategy pattern. - * - * @param cctx Cache group. - * @param link Row link. - * @param clo Closure to apply. - * @param snapshot Mvcc snapshot. - * @param <R> Return type. - * @return Result. - * @throws IgniteCheckedException If failed. - */ - private static <R> R invoke(GridCacheContext cctx, long link, MvccClosure<R> clo, MvccSnapshot snapshot) - throws IgniteCheckedException { - assert false; // ex mvcc code, should never happen - - return null; - } - - /** - * @param cctx Cache context. - * @param dataIo Data page IO. - * @param pageAddr Page address. - * @param itemId Item Id. - * @param pageSize Page size. - * @param clo Closure. - * @param snapshot Mvcc snapshot. - * @return Result. - * @throws IgniteCheckedException If failed. - */ - private static <R> R invoke(GridCacheContext cctx, DataPageIO dataIo, long pageAddr, int itemId, int pageSize, - MvccClosure<R> clo, MvccSnapshot snapshot) throws IgniteCheckedException { - int offset = dataIo.getPayloadOffset(pageAddr, itemId, pageSize, MVCC_INFO_SIZE); - - long mvccCrd = dataIo.mvccCoordinator(pageAddr, offset); - long mvccCntr = dataIo.mvccCounter(pageAddr, offset); - int mvccOpCntr = dataIo.rawMvccOperationCounter(pageAddr, offset); - - assert mvccVersionIsValid(mvccCrd, mvccCntr, mvccOpCntr ) : mvccVersion(mvccCrd, mvccCntr, mvccOpCntr); - - long newMvccCrd = dataIo.newMvccCoordinator(pageAddr, offset); - long newMvccCntr = dataIo.newMvccCounter(pageAddr, offset); - int newMvccOpCntr = dataIo.rawNewMvccOperationCounter(pageAddr, offset); - - assert newMvccCrd == MVCC_CRD_COUNTER_NA || mvccVersionIsValid(newMvccCrd, newMvccCntr, newMvccOpCntr) - : mvccVersion(newMvccCrd, newMvccCntr, newMvccOpCntr); - - return clo.apply(cctx, snapshot, mvccCrd, mvccCntr, mvccOpCntr, newMvccCrd, newMvccCntr, newMvccOpCntr); - } - - /** - * @param cctx Cache context. - * @param snapshot Mvcc snapshot. - * @param dataIo Data page IO. - * @param pageAddr Page address. - * @param itemId Item Id. - * @param pageSize Page size. - * @return {@code true} If the row is visible. - * @throws IgniteCheckedException If failed. - */ - public static boolean isVisible(GridCacheContext cctx, MvccSnapshot snapshot, DataPageIO dataIo, - long pageAddr, int itemId, int pageSize) throws IgniteCheckedException { - return invoke(cctx, dataIo, pageAddr, itemId, pageSize, isVisible, snapshot); - } - - /** - * Checks transaction state. - * @param tx Transaction. - * @return Checked transaction. - */ - public static GridNearTxLocal checkActive(GridNearTxLocal tx) throws IgniteTxAlreadyCompletedCheckedException { - if (tx != null && tx.state() != TransactionState.ACTIVE) - throw new IgniteTxAlreadyCompletedCheckedException("Transaction is already completed."); - - return tx; - } - - /** * @param ctx Grid kernal context. * @return Currently started user transaction, or {@code null} if none started. @@ -601,145 +61,4 @@ public class MvccUtils { return tx; } - - /** - * @param ctx Grid kernal context. - * @param timeout Transaction timeout. - * @return Newly started SQL transaction. - */ - public static GridNearTxLocal txStart(GridKernalContext ctx, long timeout) { - return txStart(ctx, null, timeout); - } - - /** - * @param cctx Cache context. - * @param timeout Transaction timeout. - * @return Newly started SQL transaction. - */ - public static GridNearTxLocal txStart(GridCacheContext cctx, long timeout) { - return txStart(cctx.kernalContext(), cctx, timeout); - } - - /** - * @param ctx Grid kernal context. - * @param cctx Cache context. - * @param timeout Transaction timeout. - * @return Newly started SQL transaction. - */ - private static GridNearTxLocal txStart(GridKernalContext ctx, @Nullable GridCacheContext cctx, long timeout) { - if (timeout == 0) { - TransactionConfiguration tcfg = CU.transactionConfiguration(cctx, ctx.config()); - - if (tcfg != null) - timeout = tcfg.getDefaultTxTimeout(); - } - - GridNearTxLocal tx = ctx.cache().context().tm().newTx( - false, - false, - cctx != null && cctx.systemTx() ? cctx : null, - PESSIMISTIC, - REPEATABLE_READ, - timeout, - cctx == null || !cctx.skipStore(), - 0, - null - ); - - tx.syncMode(FULL_SYNC); - - return tx; - } - - /** */ - private static MvccVersion mvccVersion(long crd, long cntr, int opCntr) { - return new MvccVersionImpl(crd, cntr, opCntr); - } - - /** - * @param v1 First MVCC version. - * @param v2 Second MVCC version. - * @return {@code True} if compared versions belongs to the same transaction. - */ - public static boolean belongToSameTx(MvccVersion v1, MvccVersion v2) { - return v1.coordinatorVersion() == v2.coordinatorVersion() && v1.counter() == v2.counter(); - } - - /** - * Mvcc closure interface. - * @param <R> Return type. - */ - private interface MvccClosure<R> { - /** - * Runs closure over the Mvcc info. - * @param snapshot Mvcc snapshot. - * @param mvccCrd Coordinator version. - * @param mvccCntr Counter. - * @param mvccOpCntr Operation counter. - * @param newMvccCrd New mvcc coordinator - * @param newMvccCntr New mvcc counter. - * @param newMvccOpCntr New mvcc operation counter. - * @return Result. - */ - public R apply(GridCacheContext cctx, MvccSnapshot snapshot, long mvccCrd, long mvccCntr, int mvccOpCntr, - long newMvccCrd, long newMvccCntr, int newMvccOpCntr) throws IgniteCheckedException; - } - - /** - * Closure for checking row visibility for snapshot. - */ - private static class GetVisibleState implements MvccClosure<Integer> { - /** {@inheritDoc} */ - @Override public Integer apply(GridCacheContext cctx, MvccSnapshot snapshot, long mvccCrd, long mvccCntr, - int mvccOpCntr, long newMvccCrd, long newMvccCntr, int newMvccOpCntr) throws IgniteCheckedException { - - if (!isVisible(cctx, snapshot, mvccCrd, mvccCntr, mvccOpCntr)) - return MVCC_INVISIBLE; - - if (newMvccCrd == MVCC_CRD_COUNTER_NA) - return MVCC_VISIBLE; - - assert mvccVersionIsValid(newMvccCrd, newMvccCntr, newMvccOpCntr); - - if (mvccCrd == newMvccCrd && mvccCntr == newMvccCntr) // Double-changed in scope of one transaction. - return MVCC_VISIBLE_REMOVED; - - return isVisible(cctx, snapshot, newMvccCrd, newMvccCntr, newMvccOpCntr) ? MVCC_VISIBLE_REMOVED : - MVCC_VISIBLE; - } - } - - /** - * Closure for checking whether the row is visible for given snapshot. - */ - private static class IsVisible implements MvccClosure<Boolean> { - /** {@inheritDoc} */ - @Override public Boolean apply(GridCacheContext cctx, MvccSnapshot snapshot, long mvccCrd, long mvccCntr, - int mvccOpCntr, long newMvccCrd, long newMvccCntr, int newMvccOpCntr) throws IgniteCheckedException { - - if (!isVisible(cctx, snapshot, mvccCrd, mvccCntr, mvccOpCntr)) - return false; - - if (newMvccCrd == MVCC_CRD_COUNTER_NA) - return true; - - assert mvccVersionIsValid(newMvccCrd, newMvccCntr, newMvccOpCntr); - - if (mvccCrd == newMvccCrd && mvccCntr == newMvccCntr) // Double-changed in scope of one transaction. - return false; - - return !isVisible(cctx, snapshot, newMvccCrd, newMvccCntr, newMvccOpCntr); - } - } - - /** - * Closure for getting xid_max version of row. - */ - private static class GetNewVersion implements MvccClosure<MvccVersion> { - /** {@inheritDoc} */ - @Override public MvccVersion apply(GridCacheContext cctx, MvccSnapshot snapshot, long mvccCrd, long mvccCntr, - int mvccOpCntr, long newMvccCrd, long newMvccCntr, int newMvccOpCntr) { - return newMvccCrd == MVCC_CRD_COUNTER_NA ? null : mvccVersion(newMvccCrd, newMvccCntr, newMvccOpCntr); - } - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccVersion.java deleted file mode 100644 index f43d3b9b936..00000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccVersion.java +++ /dev/null @@ -1,48 +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.mvcc; - -import org.jetbrains.annotations.NotNull; - -/** - * MVCC version. This is unique version allowing to order all reads and writes within a cluster. Consists of two parts: - * - coordinator version - number which increases on every coordinator change; - * - counter - local coordinator counter which is increased on every update. - */ -public interface MvccVersion extends Comparable<MvccVersion> { - /** - * @return Coordinator version. - */ - public long coordinatorVersion(); - - /** - * @return Local counter. - */ - public long counter(); - - /** - * @return Operation id in scope of current transaction. - */ - public int operationCounter(); - - /** {@inheritDoc} */ - @Override default int compareTo(@NotNull MvccVersion another) { - return MvccUtils.compare(coordinatorVersion(), counter(), operationCounter(), - another.coordinatorVersion(), another.counter(), another.operationCounter()); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccVersionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccVersionImpl.java deleted file mode 100644 index c4f35ca6268..00000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccVersionImpl.java +++ /dev/null @@ -1,192 +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.mvcc; - -import java.nio.ByteBuffer; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.plugin.extensions.communication.MessageReader; -import org.apache.ignite.plugin.extensions.communication.MessageWriter; - -/** - * Base MVCC version implementation. - */ -public class MvccVersionImpl implements MvccVersion, Message { - /** */ - private static final long serialVersionUID = 0L; - - /** Coordinator version. */ - private long crdVer; - - /** Local counter. */ - private long cntr; - - /** Operation counter. */ - private int opCntr; - - /** - * Constructor. - */ - public MvccVersionImpl() { - // No-op. - } - - /** - * @param crdVer Coordinator version. - * @param cntr Counter. - * @param opCntr Operation counter. - */ - public MvccVersionImpl(long crdVer, long cntr, int opCntr) { - this.crdVer = crdVer; - this.cntr = cntr; - this.opCntr = opCntr; - } - - /** - * @return Coordinator version. - */ - @Override public long coordinatorVersion() { - return crdVer; - } - - /** - * @return Local counter. - */ - @Override public long counter() { - return cntr; - } - - /** {@inheritDoc} */ - @Override public int operationCounter() { - return opCntr; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (o == null || getClass() != o.getClass()) - return false; - - MvccVersionImpl that = (MvccVersionImpl)o; - - return crdVer == that.crdVer && cntr == that.cntr; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - int res = (int)(crdVer ^ (crdVer >>> 32)); - - res = 31 * res + (int)(cntr ^ (cntr >>> 32)); - - return res; - } - - /** {@inheritDoc} */ - @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) { - writer.setBuffer(buf); - - if (!writer.isHeaderWritten()) { - if (!writer.writeHeader(directType(), fieldsCount())) - return false; - - writer.onHeaderWritten(); - } - - switch (writer.state()) { - case 0: - if (!writer.writeLong("cntr", cntr)) - return false; - - writer.incrementState(); - - case 1: - if (!writer.writeLong("crdVer", crdVer)) - return false; - - writer.incrementState(); - - case 2: - if (!writer.writeInt("opCntr", opCntr)) - return false; - - writer.incrementState(); - - } - - return true; - } - - /** {@inheritDoc} */ - @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) { - reader.setBuffer(buf); - - if (!reader.beforeMessageRead()) - return false; - - switch (reader.state()) { - case 0: - cntr = reader.readLong("cntr"); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - - case 1: - crdVer = reader.readLong("crdVer"); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - - case 2: - opCntr = reader.readInt("opCntr"); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - - } - - return reader.afterMessageRead(MvccVersionImpl.class); - } - - /** {@inheritDoc} */ - @Override public short directType() { - return 148; - } - - /** {@inheritDoc} */ - @Override public byte fieldsCount() { - return 3; - } - - /** {@inheritDoc} */ - @Override public void onAckReceived() { - // No-op. - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(MvccVersionImpl.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/txlog/TxState.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/txlog/TxState.java index 0f761d39f08..f969a70f517 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/txlog/TxState.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/txlog/TxState.java @@ -27,9 +27,6 @@ public final class TxState { /** */ public static final byte PREPARED = 0x1; - /** */ - public static final byte ABORTED = 0x2; - /** */ public static final byte COMMITTED = 0x3; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/AbstractDataPageIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/AbstractDataPageIO.java index 1a60dc537c6..043036cd5e5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/AbstractDataPageIO.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/AbstractDataPageIO.java @@ -646,23 +646,6 @@ public abstract class AbstractDataPageIO<T extends Storable> extends PageIO impl nextLink); } - /** - * @param pageAddr Page address. - * @param itemId Item to position on. - * @param pageSize Page size. - * @param reqLen Required payload length. - * @return Offset to start of actual fragment data. - */ - public int getPayloadOffset(final long pageAddr, final int itemId, final int pageSize, int reqLen) { - int dataOff = getDataOffset(pageAddr, itemId, pageSize); - - int payloadSize = getPageEntrySize(pageAddr, dataOff, 0); - - assert payloadSize >= reqLen : payloadSize; - - return dataOff + PAYLOAD_LEN_SIZE + (isFragmented(pageAddr, dataOff) ? LINK_SIZE : 0); - } - /** * @param pageAddr Page address. * @param idx Item index. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java index 249f17d11f2..aaf744969e8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java @@ -35,9 +35,6 @@ import static org.apache.ignite.internal.processors.cache.persistence.tree.io.Da * Data pages IO. */ public class DataPageIO extends AbstractDataPageIO<CacheDataRow> { - /** */ - public static final int MVCC_INFO_SIZE = 40; - /** */ public static final IOVersions<DataPageIO> VERSIONS = new IOVersions<>( new DataPageIO(1) @@ -191,93 +188,6 @@ public class DataPageIO extends AbstractDataPageIO<CacheDataRow> { return len; } - /** - * Returns MVCC coordinator number. - * - * @param pageAddr Page address. - * @param dataOff Data offset. - * @return MVCC coordinator number. - */ - public long mvccCoordinator(long pageAddr, int dataOff) { - long addr = pageAddr + dataOff; - - return PageUtils.getLong(addr, 0); - } - - /** - * Returns MVCC counter value. - * - * @param pageAddr Page address. - * @param dataOff Data offset. - * @return MVCC counter value. - */ - public long mvccCounter(long pageAddr, int dataOff) { - long addr = pageAddr + dataOff; - - return PageUtils.getLong(addr, 8); - } - - /** - * Returns MVCC operation counter raw value (with hints and flags). - * - * @param pageAddr Page address. - * @param dataOff Data offset. - * @return MVCC counter value. - */ - public int rawMvccOperationCounter(long pageAddr, int dataOff) { - long addr = pageAddr + dataOff; - - return PageUtils.getInt(addr, 16); - } - - /** - * Returns new MVCC coordinator number. - * - * @param pageAddr Page address. - * @param dataOff Data offset. - * @return New MVCC coordinator number. - */ - public long newMvccCoordinator(long pageAddr, int dataOff) { - long addr = pageAddr + dataOff; - - // Skip xid_min. - addr += 20; - - return PageUtils.getLong(addr, 0); - } - - /** - * Returns new MVCC counter value. - * - * @param pageAddr Page address. - * @param dataOff Data offset. - * @return New MVCC counter value. - */ - public long newMvccCounter(long pageAddr, int dataOff) { - long addr = pageAddr + dataOff; - - // Skip xid_min. - addr += 20; - - return PageUtils.getLong(addr, 8); - } - - /** - * Returns MVCC operation counter raw value (with hints and flags). - * - * @param pageAddr Page address. - * @param dataOff Data offset. - * @return MVCC counter value. - */ - public int rawNewMvccOperationCounter(long pageAddr, int dataOff) { - long addr = pageAddr + dataOff; - - // Skip xid_min. - addr += 20; - - return PageUtils.getInt(addr, 16); - } - /** * @param buf Byte buffer. * @param ver Version. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/transactions/IgniteTxAlreadyCompletedCheckedException.java b/modules/core/src/main/java/org/apache/ignite/internal/transactions/IgniteTxAlreadyCompletedCheckedException.java deleted file mode 100644 index 47b47bcde5c..00000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/transactions/IgniteTxAlreadyCompletedCheckedException.java +++ /dev/null @@ -1,36 +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.transactions; - -/** - * Exception thrown whenever Mvcc transaction has been finished before operation finished. - * E.g. rollback due to some reason. - */ -public class IgniteTxAlreadyCompletedCheckedException extends TransactionCheckedException { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Creates new exception with given error message. - * - * @param msg Error message. - */ - public IgniteTxAlreadyCompletedCheckedException(String msg) { - super(msg); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/transactions/IgniteTxSerializationCheckedException.java b/modules/core/src/main/java/org/apache/ignite/internal/transactions/IgniteTxSerializationCheckedException.java deleted file mode 100644 index 9e61e81b89c..00000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/transactions/IgniteTxSerializationCheckedException.java +++ /dev/null @@ -1,35 +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.transactions; - -/** - * Exception thrown whenever transaction can't be serialized due to write conflict. - */ -public class IgniteTxSerializationCheckedException extends TransactionCheckedException { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Creates new transaction serialization exception with given error message. - * - * @param msg Error message. - */ - public IgniteTxSerializationCheckedException(String msg) { - super(msg); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/transactions/IgniteTxUnexpectedStateCheckedException.java b/modules/core/src/main/java/org/apache/ignite/internal/transactions/IgniteTxUnexpectedStateCheckedException.java deleted file mode 100644 index d8be1b16a19..00000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/transactions/IgniteTxUnexpectedStateCheckedException.java +++ /dev/null @@ -1,45 +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.transactions; - -/** - * Exception thrown whenever mvcc transaction enters an unknown state. - */ -public class IgniteTxUnexpectedStateCheckedException extends TransactionCheckedException { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Creates new exception with given error message. - * - * @param msg Error message. - */ - public IgniteTxUnexpectedStateCheckedException(String msg) { - super(msg); - } - - /** - * Creates new exception with given error message and optional nested exception. - * - * @param msg Error message. - * @param cause Optional nested exception (can be <tt>null</tt>). - */ - public IgniteTxUnexpectedStateCheckedException(String msg, Throwable cause) { - super(msg, cause); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java index 7ea6899e696..a344ee3d500 100755 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java @@ -227,11 +227,9 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.IgnitePeerToPeerClassLoadingException; import org.apache.ignite.internal.processors.cluster.BaselineTopology; -import org.apache.ignite.internal.transactions.IgniteTxAlreadyCompletedCheckedException; import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException; import org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException; import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException; -import org.apache.ignite.internal.transactions.IgniteTxSerializationCheckedException; import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException; import org.apache.ignite.internal.util.future.GridFutureAdapter; import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl; @@ -275,12 +273,10 @@ import org.apache.ignite.spi.discovery.DiscoverySpi; import org.apache.ignite.spi.discovery.DiscoverySpiOrderSupport; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.thread.IgniteThreadFactory; -import org.apache.ignite.transactions.TransactionAlreadyCompletedException; import org.apache.ignite.transactions.TransactionDeadlockException; import org.apache.ignite.transactions.TransactionHeuristicException; import org.apache.ignite.transactions.TransactionOptimisticException; import org.apache.ignite.transactions.TransactionRollbackException; -import org.apache.ignite.transactions.TransactionSerializationException; import org.apache.ignite.transactions.TransactionTimeoutException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -1052,18 +1048,6 @@ public abstract class IgniteUtils { } }); - m.put(IgniteTxSerializationCheckedException.class, new C1<IgniteCheckedException, IgniteException>() { - @Override public IgniteException apply(IgniteCheckedException e) { - return new TransactionSerializationException(e.getMessage(), e); - } - }); - - m.put(IgniteTxAlreadyCompletedCheckedException.class, new C1<IgniteCheckedException, IgniteException>() { - @Override public IgniteException apply(IgniteCheckedException e) { - return new TransactionAlreadyCompletedException(e.getMessage(), e); - } - }); - return m; } diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties index 266524b6897..4507cd17f1e 100644 --- a/modules/core/src/main/resources/META-INF/classnames.properties +++ b/modules/core/src/main/resources/META-INF/classnames.properties @@ -1124,7 +1124,6 @@ org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo org.apache.ignite.internal.processors.cache.mvcc.DeadlockProbe org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshotWithoutTxs -org.apache.ignite.internal.processors.cache.mvcc.MvccVersionImpl org.apache.ignite.internal.processors.cache.mvcc.ProbedTx org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter$RowData org.apache.ignite.internal.processors.cache.persistence.CheckpointState @@ -1808,13 +1807,10 @@ org.apache.ignite.internal.sql.optimizer.affinity.PartitionAffinityFunctionType org.apache.ignite.internal.sql.optimizer.affinity.PartitionCompositeNodeOperator org.apache.ignite.internal.sql.optimizer.affinity.PartitionParameterType org.apache.ignite.internal.tracing.TracingSpiType -org.apache.ignite.internal.transactions.IgniteTxAlreadyCompletedCheckedException org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException -org.apache.ignite.internal.transactions.IgniteTxSerializationCheckedException org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException -org.apache.ignite.internal.transactions.IgniteTxUnexpectedStateCheckedException org.apache.ignite.internal.transactions.TransactionCheckedException org.apache.ignite.internal.util.F0$1 org.apache.ignite.internal.util.F0$2 diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java index f0899e1edbb..c5a8dd09ecd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java @@ -25,7 +25,6 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.eviction.EvictableEntry; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicAbstractUpdateFuture; -import org.apache.ignite.internal.processors.cache.mvcc.MvccVersion; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey; @@ -616,8 +615,6 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr @Override public boolean initialValue( CacheObject val, GridCacheVersion ver, - MvccVersion mvccVer, - MvccVersion newMvccVer, byte mvccTxState, byte newMvccTxState, long ttl, diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotCheckTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotCheckTest.java index c3e811d8e71..2ad3d6ad2b6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotCheckTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotCheckTest.java @@ -436,8 +436,6 @@ public class IgniteClusterSnapshotCheckTest extends AbstractSnapshotSelfTest { new GridCacheVersion(row0.version().topologyVersion(), row0.version().nodeOrder(), row0.version().order() + 1), - null, - null, TxState.NA, TxState.NA, TTL_ETERNAL,