Class IgniteTxAdapter

    • Constructor Detail

      • IgniteTxAdapter

        protected IgniteTxAdapter​(GridCacheSharedContext<?,​?> cctx,
                                  GridCacheVersion xidVer,
                                  boolean implicit,
                                  boolean loc,
                                  boolean sys,
                                  byte plc,
                                  TransactionConcurrency concurrency,
                                  TransactionIsolation isolation,
                                  long timeout,
                                  boolean invalidate,
                                  boolean storeEnabled,
                                  boolean onePhaseCommit,
                                  int txSize,
                                  @Nullable
                                  @Nullable UUID subjId,
                                  int taskNameHash)
        Parameters:
        cctx - Cache registry.
        xidVer - Transaction ID.
        implicit - Implicit flag.
        loc - Local flag.
        sys - System transaction flag.
        plc - IO policy.
        concurrency - Concurrency.
        isolation - Isolation.
        timeout - Timeout.
        txSize - Transaction size.
      • IgniteTxAdapter

        protected IgniteTxAdapter​(GridCacheSharedContext<?,​?> cctx,
                                  UUID nodeId,
                                  GridCacheVersion xidVer,
                                  long threadId,
                                  boolean sys,
                                  byte plc,
                                  TransactionConcurrency concurrency,
                                  TransactionIsolation isolation,
                                  long timeout,
                                  int txSize,
                                  @Nullable
                                  @Nullable UUID subjId,
                                  int taskNameHash)
        Parameters:
        cctx - Cache registry.
        nodeId - Node ID.
        xidVer - Transaction ID.
        threadId - Thread ID.
        sys - System transaction flag.
        plc - IO policy.
        concurrency - Concurrency.
        isolation - Isolation.
        timeout - Timeout.
        txSize - Transaction size.
    • Method Detail

      • incrementalSnapshotId

        public UUID incrementalSnapshotId()
        Specified by:
        incrementalSnapshotId in interface IgniteInternalTx
        Returns:
        ID of incremental snapshot after which this transaction commits, null if snapshot isn't running.
      • incrementalSnapshotId

        public void incrementalSnapshotId​(UUID id)
        Specified by:
        incrementalSnapshotId in interface IgniteInternalTx
        Parameters:
        id - ID of incremental snapshot after which this transaction commits, null if snapshot isn't running.
      • setParentTx

        public void setParentTx​(GridNearTxLocal parentTx)
        Parameters:
        parentTx - Transaction from which this transaction was copied by.
      • skipCompletedVersions

        public boolean skipCompletedVersions()
        Returns:
        True if tx should skip adding itself to completed version map on finish.
      • skipCompletedVersions

        public void skipCompletedVersions​(boolean skipCompletedVers)
        Parameters:
        skipCompletedVers - True if tx should skip adding itself to completed version map on finish.
      • localResult

        public boolean localResult()
        Specified by:
        localResult in interface IgniteInternalTx
        Returns:
        True if transaction started on the node initiated cache operation.
      • optimisticLockEntries

        public Collection<IgniteTxEntry> optimisticLockEntries()
        Gets a list of entries that needs to be locked on the next step of prepare stage of optimistic transaction.
        Specified by:
        optimisticLockEntries in interface IgniteInternalTx
        Returns:
        List of tx entries for optimistic locking.
      • storeEnabled

        public boolean storeEnabled()
        Specified by:
        storeEnabled in interface IgniteInternalTx
        Returns:
        True if transaction is allowed to use store.
      • storeEnabled

        public void storeEnabled​(boolean storeEnabled)
        Parameters:
        storeEnabled - Store enabled flag.
      • system

        public boolean system()
        Checks if this is system cache transaction. System transactions are isolated from user transactions because some of the public API methods may be invoked inside user transactions and internally start system cache transactions.
        Specified by:
        system in interface IgniteInternalTx
        Returns:
        True if transaction is started for system cache.
      • ioPolicy

        public byte ioPolicy()
        Specified by:
        ioPolicy in interface IgniteInternalTx
        Returns:
        Pool where message for the given transaction must be processed.
      • storeWriteThrough

        public boolean storeWriteThrough()
        Specified by:
        storeWriteThrough in interface IgniteInternalTx
        Returns:
        True if transaction is allowed to use store and transactions spans one or more caches with store enabled.
      • uncommit

        protected void uncommit()
        Uncommits transaction by invalidating all of its entries. Courtesy to minimize inconsistency.
      • otherNodeId

        public UUID otherNodeId()
        Gets ID of additional node involved. For example, in DHT case, other node is near node ID.
        Specified by:
        otherNodeId in interface IgniteInternalTx
        Returns:
        Parent node IDs.
      • taskNameHash

        public int taskNameHash()
        Task name hash in case if transaction was initiated within task execution.
        Specified by:
        taskNameHash in interface IgniteInternalTx
        Returns:
        Task name hash.
      • topologyVersion

        public final AffinityTopologyVersion topologyVersion​(AffinityTopologyVersion topVer)
        Attempts to set topology version and returns the current value. If topology version was previously set, then it's value will be returned (but not updated).
        Specified by:
        topologyVersion in interface IgniteInternalTx
        Parameters:
        topVer - Topology version.
        Returns:
        Recorded topology version.
      • isStarted

        public abstract boolean isStarted()
        Returns:
        True if transaction has at least one key enlisted.
      • size

        public int size()
        Specified by:
        size in interface IgniteInternalTx
        Returns:
        Size of the transaction.
      • remote

        public boolean remote()
        Returns:
        True if transaction reflects changes in primary -> backup direction.
      • near

        public boolean near()
        Specified by:
        near in interface IgniteInternalTx
        Returns:
        True if near transaction.
      • implicit

        public boolean implicit()
        Flag indicating whether transaction was started automatically by the system or not. System will start transactions implicitly whenever any cache put(..) or remove(..) operation is invoked outside of transaction.
        Specified by:
        implicit in interface IgniteInternalTx
        Returns:
        True if transaction was started implicitly.
      • implicitSingle

        public boolean implicitSingle()
        Specified by:
        implicitSingle in interface IgniteInternalTx
        Returns:
        Flag indicating whether transaction is implicit with only one key.
      • local

        public boolean local()
        Specified by:
        local in interface IgniteInternalTx
        Returns:
        True if transaction is local, false if it's remote.
      • user

        public final boolean user()
        Specified by:
        user in interface IgniteInternalTx
        Returns:
        True if transaction is user transaction, which means:
        • Explicit
        • Local
        • Not DHT
      • dht

        public boolean dht()
        Specified by:
        dht in interface IgniteInternalTx
        Returns:
        True if DHT transaction.
      • colocated

        public boolean colocated()
        Specified by:
        colocated in interface IgniteInternalTx
        Returns:
        True if dht colocated transaction.
      • xid

        public IgniteUuid xid()
        Gets unique identifier for this transaction.
        Specified by:
        xid in interface IgniteInternalTx
        Returns:
        Transaction UID.
      • addInvalidPartition

        public void addInvalidPartition​(int cacheId,
                                        int part)
        Specified by:
        addInvalidPartition in interface IgniteInternalTx
        Parameters:
        cacheId - Cache id.
        part - Invalid partition.
      • startTime

        public long startTime()
        Start time of this transaction.
        Specified by:
        startTime in interface IgniteInternalTx
        Returns:
        Start time of this transaction on this node.
      • startTimeNanos

        public long startTimeNanos()
        Start time of this transaction in nanoseconds to measure duration.
        Specified by:
        startTimeNanos in interface IgniteInternalTx
        Returns:
        Start time of this transaction in nanoseconds.
      • needReturnValue

        public boolean needReturnValue()
        Returns:
        Flag indicating whether transaction needs return value.
      • needReturnValue

        public void needReturnValue​(boolean needRetVal)
        Parameters:
        needRetVal - Need return value flag.
      • remainingTime

        public long remainingTime()
        Gets remaining allowed transaction time.
        Specified by:
        remainingTime in interface IgniteInternalTx
        Returns:
        Remaining transaction time. 0 if timeout isn't specified. -1 if time is out.
      • timeoutException

        public final IgniteCheckedException timeoutException()
        Returns:
        Transaction timeout exception with the message of lock acquire failure.
      • timeoutException

        public final IgniteCheckedException timeoutException​(String msg)
        Parameters:
        msg - Message text to put to the timeout exception.
        Returns:
        Transaction timeout exception with the provided message.
      • logTxFinishErrorSafe

        public void logTxFinishErrorSafe​(@Nullable
                                         @Nullable IgniteLogger log,
                                         boolean commit,
                                         Throwable e)
        Parameters:
        log - Log.
        commit - Commit.
        e - Exception.
      • threadId

        public long threadId()
        ID of the thread in which this transaction started.
        Specified by:
        threadId in interface IgniteInternalTx
        Returns:
        Thread ID.
      • nodeId

        public UUID nodeId()
        ID of the node on which this transaction started.
        Specified by:
        nodeId in interface IgniteInternalTx
        Returns:
        Originating node ID.
      • timeout

        public long timeout()
        Gets timeout value in milliseconds for this transaction. If transaction times out prior to it's completion, IgniteTxTimeoutCheckedException will be thrown.
        Specified by:
        timeout in interface IgniteInternalTx
        Returns:
        Transaction timeout value.
      • timeout

        public long timeout​(long timeout)
        Sets transaction timeout value. This value can be set only before a first operation on transaction has been performed.
        Specified by:
        timeout in interface IgniteInternalTx
        Parameters:
        timeout - Transaction timeout value.
        Returns:
        Previous timeout.
      • errorWhenCommitting

        public final void errorWhenCommitting()
        Changes transaction state from COMMITTING to MARKED_ROLLBACK. Must be called only from thread committing transaction.
        Specified by:
        errorWhenCommitting in interface IgniteInternalTx
      • setRollbackOnly

        public boolean setRollbackOnly()
        Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.
        Specified by:
        setRollbackOnly in interface IgniteInternalTx
        Returns:
        True if rollback-only flag was set as a result of this operation, false if it was already set prior to this call or could not be set because transaction is already finishing up committing or rolling back.
      • isRollbackOnly

        public boolean isRollbackOnly()
        Description copied from interface: IgniteInternalTx
        If transaction was marked as rollback-only.
        Specified by:
        isRollbackOnly in interface IgniteInternalTx
        Returns:
        True if rollback only flag is set.
      • done

        public boolean done()
        Specified by:
        done in interface IgniteInternalTx
        Returns:
        True if transaction had completed successfully or unsuccessfully.
      • needsCompletedVersions

        public boolean needsCompletedVersions()
        Specified by:
        needsCompletedVersions in interface IgniteInternalTx
        Returns:
        True if transaction needs completed versions for processing.
      • internal

        public boolean internal()
        Specified by:
        internal in interface IgniteInternalTx
        Returns:
        True if transaction has at least one internal entry.
      • checkInternal

        protected boolean checkInternal​(IgniteTxKey key)
        Parameters:
        key - Key.
        Returns:
        True if key is internal.
      • onePhaseCommit

        public void onePhaseCommit​(boolean onePhaseCommit)
        Parameters:
        onePhaseCommit - True if transaction commit should be performed in short-path way.
      • optimistic

        public boolean optimistic()
        Specified by:
        optimistic in interface IgniteInternalTx
        Returns:
        True for OPTIMISTIC transactions.
      • pessimistic

        public boolean pessimistic()
        Specified by:
        pessimistic in interface IgniteInternalTx
        Returns:
        True for PESSIMISTIC transactions.
      • state

        public boolean state​(TransactionState state)
        Specified by:
        state in interface IgniteInternalTx
        Parameters:
        state - Transaction state.
        Returns:
        True if transition was valid, false otherwise.
      • chainState

        public boolean chainState​(TransactionState state)
        Changing state for this transaction as well as chained(parent) transactions.
        Parameters:
        state - Transaction state.
        Returns:
        True if transition was valid, false otherwise.
      • state

        protected final boolean state​(TransactionState state,
                                      boolean timedOut)
        Parameters:
        state - State to set.
        timedOut - Timeout flag.
        Returns:
        True if state changed.
      • recordStateChangedEvent

        protected void recordStateChangedEvent​(int type)
        Parameters:
        type - Event type.
      • timedOut

        public boolean timedOut()
        Specified by:
        timedOut in interface IgniteInternalTx
        Returns:
        True if transaction timed out.
      • invalidate

        public void invalidate​(boolean invalidate)
        Specified by:
        invalidate in interface IgniteInternalTx
        Parameters:
        invalidate - Invalidate flag.
      • isInvalidate

        public boolean isInvalidate()
        Get invalidation flag for this transaction. If set to true, then remote values will be invalidated (set to null) instead of updated.

        Invalidation messages don't carry new values, so they are a lot lighter than update messages. However, when a value is accessed on a node after it's been invalidated, it must be loaded from persistent store.

        Specified by:
        isInvalidate in interface IgniteInternalTx
        Returns:
        Invalidation flag.
      • systemInvalidate

        public final void systemInvalidate​(boolean sysInvalidate)
        Specified by:
        systemInvalidate in interface IgniteInternalTx
        Parameters:
        sysInvalidate - System invalidate flag.
      • transactionNodes

        public void transactionNodes​(Map<UUID,​Collection<UUID>> txNodes)
        Parameters:
        txNodes - Transaction nodes.
      • isWriteToStoreFromDhtValid

        protected boolean isWriteToStoreFromDhtValid​(Collection<CacheStoreManager> stores)
        Parameters:
        stores - Store managers.
        Returns:
        If isWriteToStoreFromDht value same for all stores.
      • batchStoreCommit

        protected final void batchStoreCommit​(Iterable<IgniteTxEntry> writeEntries)
                                       throws IgniteCheckedException
        Performs batch database operations. This commit must be called before cache update. This way if there is a DB failure, cache transaction can still be rolled back.
        Parameters:
        writeEntries - Transaction write set.
        Throws:
        IgniteCheckedException - If batch update failed.
      • resolveTaskName

        public String resolveTaskName()
        Returns:
        Resolves task name.
      • isNearLocallyMapped

        protected boolean isNearLocallyMapped​(IgniteTxEntry e,
                                              boolean primaryOnly)
        Parameters:
        e - Transaction entry.
        primaryOnly - Flag to include backups into check or not.
        Returns:
        True if entry is locally mapped as a primary or back up node.
      • evictNearEntry

        protected boolean evictNearEntry​(IgniteTxEntry e,
                                         boolean primaryOnly)
        Parameters:
        e - Entry to evict if it qualifies for eviction.
        primaryOnly - Flag to try to evict only on primary node.
        Returns:
        True if attempt was made to evict the entry.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • txCounters

        public TxCounters txCounters​(boolean createIfAbsent)
        Specified by:
        txCounters in interface IgniteInternalTx
        Parameters:
        createIfAbsent - True if non-null instance is needed.
        Returns:
        Transaction counters.
      • applyTxSizes

        protected void applyTxSizes()
        Makes cache sizes changes accumulated during transaction visible outside of transaction.