You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2014/12/22 11:42:49 UTC
[47/50] [abbrv] incubator-ignite git commit: # ignite-41
# ignite-41
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/f537940c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f537940c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f537940c
Branch: refs/heads/ignite-41
Commit: f537940cde1c4f1dcb171a21bdb10da7137c6d19
Parents: afe0d03 f7118ce
Author: sboikov <sb...@gridgain.com>
Authored: Mon Dec 22 09:50:53 2014 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Dec 22 09:50:53 2014 +0300
----------------------------------------------------------------------
.../datagrid/CacheTransactionExample.java | 8 +-
.../datagrid/store/CacheStoreExample.java | 4 +-
.../store/dummy/CacheDummyPersonStore.java | 8 +-
.../hibernate/CacheHibernatePersonStore.java | 16 +-
.../store/jdbc/CacheJdbcPersonStore.java | 14 +-
.../org/gridgain/client/GridHashMapStore.java | 8 +-
.../GridClientAbstractMultiNodeSelfTest.java | 5 +-
.../integration/GridClientAbstractSelfTest.java | 7 +-
.../java/org/apache/ignite/IgniteCache.java | 8 +-
.../java/org/apache/ignite/IgniteCompute.java | 16 +
.../java/org/apache/ignite/IgniteManaged.java | 47 +-
.../org/apache/ignite/IgniteTransactions.java | 17 +-
.../java/org/apache/ignite/cache/CacheFlag.java | 3 +-
.../configuration/IgniteConfiguration.java | 6 +-
.../TransactionsConfiguration.java | 194 ++
.../ignite/lang/IgniteAsyncSupported.java | 29 +
.../org/apache/ignite/lang/IgniteFuture.java | 10 +-
.../communication/tcp/TcpCommunicationSpi.java | 3 +-
.../tcp/ipfinder/vm/TcpDiscoveryVmIpFinder.java | 7 +-
.../apache/ignite/transactions/IgniteTx.java | 246 ++
.../transactions/IgniteTxConcurrency.java | 37 +
.../IgniteTxHeuristicException.java | 43 +
.../ignite/transactions/IgniteTxIsolation.java | 41 +
.../ignite/transactions/IgniteTxMetrics.java | 45 +
.../IgniteTxOptimisticException.java | 39 +
.../transactions/IgniteTxRollbackException.java | 39 +
.../ignite/transactions/IgniteTxState.java | 57 +
.../transactions/IgniteTxSynchronization.java | 38 +
.../transactions/IgniteTxTimeoutException.java | 39 +
.../java/org/gridgain/grid/cache/GridCache.java | 11 +-
.../grid/cache/GridCacheAtomicityMode.java | 3 +-
.../grid/cache/GridCacheConfiguration.java | 5 +-
.../org/gridgain/grid/cache/GridCacheEntry.java | 9 +-
.../org/gridgain/grid/cache/GridCacheFlag.java | 3 +-
.../grid/cache/GridCacheProjection.java | 129 +-
.../org/gridgain/grid/cache/GridCacheTx.java | 243 --
.../grid/cache/GridCacheTxConcurrency.java | 37 -
.../cache/GridCacheTxHeuristicException.java | 43 -
.../grid/cache/GridCacheTxIsolation.java | 41 -
.../cache/GridCacheTxOptimisticException.java | 39 -
.../cache/GridCacheTxRollbackException.java | 39 -
.../gridgain/grid/cache/GridCacheTxState.java | 57 -
.../grid/cache/GridCacheTxSynchronization.java | 37 -
.../grid/cache/GridCacheTxTimeoutException.java | 39 -
.../GridCacheWriteSynchronizationMode.java | 5 +-
.../cache/GridTransactionsConfiguration.java | 190 -
.../gridgain/grid/cache/IgniteTxMetrics.java | 45 -
.../grid/cache/IgniteTxMetricsAdapter.java | 107 -
.../store/GridCacheLoadOnlyStoreAdapter.java | 16 +-
.../grid/cache/store/GridCacheStore.java | 27 +-
.../grid/cache/store/GridCacheStoreAdapter.java | 17 +-
.../store/GridCacheStoreBalancingWrapper.java | 16 +-
.../store/jdbc/GridCacheJdbcBlobStore.java | 15 +-
.../org/gridgain/grid/kernal/GridGainEx.java | 2 +-
.../grid/kernal/GridNodeAttributes.java | 3 +
.../grid/kernal/IgniteTransactionsEx.java | 3 +-
.../affinity/GridAffinityAssignmentCache.java | 1 -
.../processors/cache/GridCacheAdapter.java | 182 +-
.../processors/cache/GridCacheContext.java | 7 +-
.../processors/cache/GridCacheEntryEx.java | 15 +-
.../processors/cache/GridCacheEntryImpl.java | 7 +-
.../processors/cache/GridCacheEventManager.java | 8 +-
.../cache/GridCacheEvictionEntry.java | 5 +-
.../cache/GridCacheEvictionManager.java | 73 +-
.../processors/cache/GridCacheMapEntry.java | 33 +-
.../processors/cache/GridCacheMessage.java | 9 +-
.../cache/GridCacheMultiTxFuture.java | 19 +-
.../kernal/processors/cache/GridCacheMvcc.java | 3 +-
.../processors/cache/GridCacheMvccManager.java | 15 +-
.../processors/cache/GridCacheProcessor.java | 62 +-
.../processors/cache/GridCacheProjectionEx.java | 9 +-
.../cache/GridCacheProjectionImpl.java | 17 +-
.../processors/cache/GridCacheProxyImpl.java | 23 +-
.../cache/GridCacheSharedContext.java | 20 +-
.../processors/cache/GridCacheStoreManager.java | 16 +-
.../processors/cache/GridCacheTxAdapter.java | 1524 --------
.../processors/cache/GridCacheTxEntry.java | 1105 ------
.../kernal/processors/cache/GridCacheTxEx.java | 518 ---
.../processors/cache/GridCacheTxHandler.java | 1498 --------
.../kernal/processors/cache/GridCacheTxKey.java | 97 -
.../cache/GridCacheTxLocalAdapter.java | 3293 ------------------
.../processors/cache/GridCacheTxLocalEx.java | 166 -
.../processors/cache/GridCacheTxManager.java | 2212 ------------
.../kernal/processors/cache/GridCacheTxMap.java | 179 -
.../processors/cache/GridCacheTxProxy.java | 19 -
.../processors/cache/GridCacheTxProxyImpl.java | 303 --
.../processors/cache/GridCacheTxRemoteEx.java | 37 -
.../kernal/processors/cache/GridCacheUtils.java | 76 +-
.../cache/GridCacheWriteBehindStore.java | 15 +-
.../datastructures/GridCacheAtomicLongImpl.java | 21 +-
.../GridCacheAtomicReferenceImpl.java | 10 +-
.../GridCacheAtomicSequenceImpl.java | 8 +-
.../GridCacheAtomicStampedImpl.java | 10 +-
.../GridCacheCountDownLatchImpl.java | 10 +-
.../GridCacheDataStructuresManager.java | 29 +-
.../GridTransactionalCacheQueueImpl.java | 14 +-
.../distributed/GridCacheCommittedTxInfo.java | 9 +-
...ridCacheOptimisticCheckPreparedTxFuture.java | 6 +-
...idCacheOptimisticCheckPreparedTxRequest.java | 3 +-
.../GridCachePerThreadTxCommitBuffer.java | 3 +-
...dCachePessimisticCheckCommittedTxFuture.java | 9 +-
...CachePessimisticCheckCommittedTxRequest.java | 3 +-
.../distributed/GridCacheTxCommitBuffer.java | 3 +-
.../GridDistributedCacheAdapter.java | 12 +-
.../distributed/GridDistributedCacheEntry.java | 47 +-
.../distributed/GridDistributedLockRequest.java | 23 +-
.../GridDistributedTxFinishRequest.java | 31 +-
.../distributed/GridDistributedTxMapping.java | 31 +-
.../GridDistributedTxPrepareRequest.java | 67 +-
.../GridDistributedTxRemoteAdapter.java | 76 +-
.../distributed/dht/GridDhtCacheEntry.java | 5 +-
.../cache/distributed/dht/GridDhtGetFuture.java | 5 +-
.../distributed/dht/GridDhtLockFuture.java | 6 +-
.../distributed/dht/GridDhtLockRequest.java | 9 +-
.../distributed/dht/GridDhtLockResponse.java | 7 +-
.../dht/GridDhtTransactionalCacheAdapter.java | 40 +-
.../distributed/dht/GridDhtTxFinishFuture.java | 20 +-
.../distributed/dht/GridDhtTxFinishRequest.java | 29 +-
.../cache/distributed/dht/GridDhtTxLocal.java | 77 +-
.../distributed/dht/GridDhtTxLocalAdapter.java | 46 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 75 +-
.../dht/GridDhtTxPrepareRequest.java | 25 +-
.../dht/GridDhtTxPrepareResponse.java | 7 +-
.../cache/distributed/dht/GridDhtTxRemote.java | 25 +-
.../dht/atomic/GridDhtAtomicCache.java | 6 +-
.../dht/colocated/GridDhtColocatedCache.java | 10 +-
.../colocated/GridDhtColocatedLockFuture.java | 12 +-
.../distributed/near/GridNearAtomicCache.java | 6 +-
.../distributed/near/GridNearCacheAdapter.java | 7 +-
.../distributed/near/GridNearCacheEntry.java | 16 +-
.../distributed/near/GridNearGetFuture.java | 7 +-
.../distributed/near/GridNearLockFuture.java | 10 +-
.../distributed/near/GridNearLockRequest.java | 8 +-
.../near/GridNearTransactionalCache.java | 20 +-
.../near/GridNearTxFinishFuture.java | 28 +-
.../near/GridNearTxFinishRequest.java | 31 +-
.../cache/distributed/near/GridNearTxLocal.java | 135 +-
.../near/GridNearTxPrepareFuture.java | 69 +-
.../near/GridNearTxPrepareRequest.java | 15 +-
.../near/GridNearTxPrepareResponse.java | 15 +-
.../distributed/near/GridNearTxRemote.java | 41 +-
.../processors/cache/dr/GridCacheDrManager.java | 3 +-
.../cache/dr/os/GridOsCacheDrManager.java | 3 +-
.../processors/cache/local/GridLocalCache.java | 10 +-
.../cache/local/GridLocalCacheEntry.java | 5 +-
.../cache/local/GridLocalLockFuture.java | 6 +-
.../processors/cache/local/GridLocalTx.java | 25 +-
.../cache/local/GridLocalTxFuture.java | 28 +-
.../local/atomic/GridLocalAtomicCache.java | 6 +-
.../transactions/IgniteTransactionsImpl.java | 45 +-
.../cache/transactions/IgniteTxAdapter.java | 1524 ++++++++
.../cache/transactions/IgniteTxEntry.java | 1106 ++++++
.../cache/transactions/IgniteTxEx.java | 520 +++
.../cache/transactions/IgniteTxHandler.java | 1504 ++++++++
.../cache/transactions/IgniteTxKey.java | 97 +
.../transactions/IgniteTxLocalAdapter.java | 3285 +++++++++++++++++
.../cache/transactions/IgniteTxLocalEx.java | 167 +
.../cache/transactions/IgniteTxManager.java | 2213 ++++++++++++
.../cache/transactions/IgniteTxMap.java | 179 +
.../transactions/IgniteTxMetricsAdapter.java | 108 +
.../cache/transactions/IgniteTxProxy.java | 19 +
.../cache/transactions/IgniteTxProxyImpl.java | 304 ++
.../cache/transactions/IgniteTxRemoteEx.java | 39 +
.../dataload/GridDataLoadCacheUpdaters.java | 7 +-
.../processors/ggfs/GridGgfsDataManager.java | 9 +-
.../processors/ggfs/GridGgfsMetaManager.java | 31 +-
.../handlers/cache/GridCacheCommandHandler.java | 7 +-
.../service/GridServiceProcessor.java | 7 +-
.../cache/VisorCacheDefaultConfiguration.java | 13 +-
.../grid/util/future/GridCompoundFuture.java | 4 +-
.../store/GridCacheBalancingStoreSelfTest.java | 16 +-
.../cache/store/GridGeneratingTestStore.java | 16 +-
...CacheJdbcBlobStoreMultithreadedSelfTest.java | 3 +-
.../grid/kernal/GridStartStopSelfTest.java | 7 +-
.../GridCacheAbstractFailoverSelfTest.java | 17 +-
.../cache/GridCacheAbstractFullApiSelfTest.java | 118 +-
.../GridCacheAbstractProjectionSelfTest.java | 8 +-
.../cache/GridCacheAbstractSelfTest.java | 9 +-
.../cache/GridCacheAbstractTxReadTest.java | 17 +-
.../cache/GridCacheBasicStoreAbstractTest.java | 11 +-
...acheBasicStoreMultithreadedAbstractTest.java | 7 +-
.../cache/GridCacheClearAllSelfTest.java | 3 +-
...dCacheColocatedTxStoreExceptionSelfTest.java | 2 +-
.../GridCacheConcurrentTxMultiNodeTest.java | 8 +-
...idCacheConfigurationConsistencySelfTest.java | 16 +-
.../GridCacheDaemonNodeAbstractSelfTest.java | 9 +-
.../cache/GridCacheDeploymentSelfTest.java | 7 +-
.../GridCacheExAbstractFullApiSelfTest.java | 7 +-
.../GridCacheFinishPartitionsSelfTest.java | 9 +-
.../cache/GridCacheGenericTestStore.java | 32 +-
.../GridCacheGroupLockAbstractSelfTest.java | 75 +-
.../cache/GridCacheGroupLockPutTask.java | 8 +-
.../GridCacheInterceptorAbstractSelfTest.java | 13 +-
.../cache/GridCacheLifecycleAwareSelfTest.java | 15 +-
.../GridCacheLocalTxStoreExceptionSelfTest.java | 2 +-
.../GridCacheMarshallerTxAbstractTest.java | 8 +-
...GridCacheMixedPartitionExchangeSelfTest.java | 7 +-
.../cache/GridCacheMultiUpdateLockSelfTest.java | 9 +-
.../cache/GridCacheMvccManagerSelfTest.java | 3 +-
.../GridCacheNearTxStoreExceptionSelfTest.java | 2 +-
.../cache/GridCacheNestedTxAbstractTest.java | 11 +-
.../cache/GridCacheObjectToStringSelfTest.java | 7 +-
...CacheOffHeapMultiThreadedUpdateSelfTest.java | 21 +-
.../GridCacheOffHeapTieredAbstractSelfTest.java | 23 +-
.../cache/GridCacheOffheapUpdateSelfTest.java | 15 +-
.../cache/GridCachePartitionedWritesTest.java | 9 +-
.../GridCacheReferenceCleanupSelfTest.java | 5 +-
.../GridCacheRefreshAheadAbstractSelfTest.java | 7 +-
.../cache/GridCacheReloadSelfTest.java | 7 +-
...CacheReplicatedTxStoreExceptionSelfTest.java | 2 +-
.../cache/GridCacheSlowTxWarnTest.java | 3 +-
.../processors/cache/GridCacheStopSelfTest.java | 3 +-
.../cache/GridCacheStorePutxSelfTest.java | 17 +-
.../cache/GridCacheSwapReloadSelfTest.java | 7 +-
.../processors/cache/GridCacheTestEntryEx.java | 17 +-
.../processors/cache/GridCacheTestStore.java | 37 +-
...cheTransactionalAbstractMetricsSelfTest.java | 13 +-
.../cache/GridCacheTxAbstractTest.java | 484 ---
.../GridCacheTxConcurrentGetAbstractTest.java | 134 -
.../GridCacheTxExceptionAbstractSelfTest.java | 630 ----
.../cache/GridCacheTxMultiNodeAbstractTest.java | 918 -----
.../GridCacheTxMultiThreadedAbstractTest.java | 275 --
.../GridCacheTxReentryAbstractSelfTest.java | 168 -
.../GridCacheTxSingleThreadedAbstractTest.java | 129 -
...idCacheTxStoreExceptionAbstractSelfTest.java | 630 ----
.../GridCacheVariableTopologySelfTest.java | 5 +-
.../GridCacheWriteBehindStoreAbstractTest.java | 9 +-
...BehindStorePartitionedMultiNodeSelfTest.java | 9 +-
.../GridCacheWriteBehindStoreSelfTest.java | 4 +-
.../processors/cache/IgniteTxAbstractTest.java | 484 +++
.../IgniteTxConcurrentGetAbstractTest.java | 134 +
.../IgniteTxExceptionAbstractSelfTest.java | 631 ++++
.../cache/IgniteTxMultiNodeAbstractTest.java | 918 +++++
.../IgniteTxMultiThreadedAbstractTest.java | 275 ++
.../cache/IgniteTxReentryAbstractSelfTest.java | 169 +
.../IgniteTxSingleThreadedAbstractTest.java | 129 +
.../IgniteTxStoreExceptionAbstractSelfTest.java | 631 ++++
.../GridCacheAtomicLongApiSelfTest.java | 3 +-
.../GridCacheSequenceApiSelfAbstractTest.java | 8 +-
...idCachePartitionedNodeRestartTxSelfTest.java | 13 +-
...PartitionedQueueCreateMultiNodeSelfTest.java | 7 +-
...tractDistributedByteArrayValuesSelfTest.java | 11 +-
.../GridCacheAbstractJobExecutionTest.java | 12 +-
.../GridCacheAbstractNodeRestartSelfTest.java | 13 +-
...tractPartitionedByteArrayValuesSelfTest.java | 2 +-
.../GridCacheAbstractPrimarySyncSelfTest.java | 7 +-
.../GridCacheBasicOpAbstractTest.java | 9 +-
.../GridCacheEntrySetAbstractSelfTest.java | 7 +-
.../distributed/GridCacheEventAbstractTest.java | 25 +-
...dCacheMultithreadedFailoverAbstractTest.java | 3 +-
.../GridCacheNodeFailureAbstractTest.java | 12 +-
...chePartitionedReloadAllAbstractSelfTest.java | 7 +-
.../GridCacheTransformEventSelfTest.java | 20 +-
...cheTxConsistencyRestartAbstractSelfTest.java | 193 -
...xOriginatingNodeFailureAbstractSelfTest.java | 294 --
...cOriginatingNodeFailureAbstractSelfTest.java | 487 ---
.../GridCacheTxPreloadAbstractTest.java | 191 -
.../GridCacheTxTimeoutAbstractTest.java | 147 -
...iteTxConsistencyRestartAbstractSelfTest.java | 194 ++
...xOriginatingNodeFailureAbstractSelfTest.java | 295 ++
...cOriginatingNodeFailureAbstractSelfTest.java | 489 +++
.../IgniteTxPreloadAbstractTest.java | 192 +
.../IgniteTxTimeoutAbstractTest.java | 147 +
...heAbstractTransformWriteThroughSelfTest.java | 9 +-
.../dht/GridCacheColocatedDebugTest.java | 34 +-
...eColocatedOptimisticTransactionSelfTest.java | 7 +-
.../GridCacheColocatedTxExceptionSelfTest.java | 2 +-
...ssimisticOriginatingNodeFailureSelfTest.java | 2 +-
...dCacheColocatedTxSingleThreadedSelfTest.java | 2 +-
.../dht/GridCacheDhtEntrySelfTest.java | 3 +-
.../dht/GridCacheDhtTxPreloadSelfTest.java | 3 +-
...cheGroupLockPartitionedAbstractSelfTest.java | 11 +-
...ockPartitionedMultiNodeAbstractSelfTest.java | 13 +-
...dCachePartitionedTopologyChangeSelfTest.java | 14 +-
...itionedTxOriginatingNodeFailureSelfTest.java | 2 +-
...heTxConsistencyColocatedRestartSelfTest.java | 28 -
.../GridCacheTxReentryColocatedSelfTest.java | 71 -
...teTxConsistencyColocatedRestartSelfTest.java | 28 +
.../dht/IgniteTxReentryColocatedSelfTest.java | 71 +
.../atomic/GridCacheAtomicPreloadSelfTest.java | 13 +-
.../near/GridCacheGetStoreErrorSelfTest.java | 7 +-
.../near/GridCacheNearMultiGetSelfTest.java | 14 +-
.../near/GridCacheNearMultiNodeSelfTest.java | 21 +-
.../near/GridCacheNearOneNodeSelfTest.java | 17 +-
.../near/GridCacheNearOnlyTopologySelfTest.java | 9 +-
.../near/GridCacheNearTxExceptionSelfTest.java | 2 +-
.../near/GridCacheNearTxMultiNodeSelfTest.java | 21 +-
...ssimisticOriginatingNodeFailureSelfTest.java | 2 +-
.../near/GridCacheNearTxPreloadSelfTest.java | 3 +-
...ePartitionedBasicStoreMultiNodeSelfTest.java | 23 +-
.../GridCachePartitionedEvictionSelfTest.java | 9 +-
...GridCachePartitionedFilteredPutSelfTest.java | 5 +-
.../GridCachePartitionedLoadCacheSelfTest.java | 7 +-
...achePartitionedMultiNodeCounterSelfTest.java | 14 +-
...ePartitionedMultiThreadedPutGetSelfTest.java | 9 +-
.../GridCachePartitionedNodeRestartTest.java | 2 +-
...ePartitionedOptimisticTxNodeRestartTest.java | 5 +-
...achePartitionedPreloadLifecycleSelfTest.java | 6 +-
.../GridCachePartitionedStorePutSelfTest.java | 7 +-
...GridCachePartitionedTxConcurrentGetTest.java | 2 +-
...GridCachePartitionedTxMultiNodeSelfTest.java | 2 +-
...CachePartitionedTxMultiThreadedSelfTest.java | 2 +-
.../GridCachePartitionedTxSalvageSelfTest.java | 22 +-
...achePartitionedTxSingleThreadedSelfTest.java | 2 +-
.../GridCachePartitionedTxTimeoutSelfTest.java | 4 +-
.../near/GridCacheTxReentryNearSelfTest.java | 71 -
.../near/GridPartitionedBackupLoadSelfTest.java | 7 +-
.../near/IgniteTxReentryNearSelfTest.java | 71 +
.../GridCacheReplicatedInvalidateSelfTest.java | 14 +-
.../GridCacheReplicatedTxConcurrentGetTest.java | 2 +-
.../GridCacheReplicatedTxExceptionSelfTest.java | 2 +-
...GridCacheReplicatedTxMultiNodeBasicTest.java | 2 +-
...dCacheReplicatedTxMultiThreadedSelfTest.java | 4 +-
...licatedTxOriginatingNodeFailureSelfTest.java | 2 +-
...ssimisticOriginatingNodeFailureSelfTest.java | 2 +-
...CacheReplicatedTxSingleThreadedSelfTest.java | 2 +-
.../GridCacheReplicatedTxTimeoutSelfTest.java | 2 +-
.../replicated/GridReplicatedTxPreloadTest.java | 2 +-
...CacheReplicatedPreloadLifecycleSelfTest.java | 5 +-
.../GridCacheBatchEvictUnswapSelfTest.java | 8 +-
...heConcurrentEvictionConsistencySelfTest.java | 7 +-
.../GridCacheConcurrentEvictionsSelfTest.java | 4 +-
.../GridCacheDistributedEvictionsSelfTest.java | 6 +-
.../GridCacheEmptyEntriesAbstractSelfTest.java | 21 +-
.../eviction/GridCacheEvictionAbstractTest.java | 7 +-
.../GridCacheEvictionTouchSelfTest.java | 17 +-
.../GridCacheLocalByteArrayValuesSelfTest.java | 11 +-
.../local/GridCacheLocalLoadAllSelfTest.java | 10 +-
.../GridCacheLocalTxExceptionSelfTest.java | 2 +-
.../GridCacheLocalTxMultiThreadedSelfTest.java | 4 +-
.../GridCacheLocalTxSingleThreadedSelfTest.java | 2 +-
.../local/GridCacheLocalTxTimeoutSelfTest.java | 16 +-
...ridCacheContinuousQueryAbstractSelfTest.java | 7 +-
.../ggfs/GridGgfsDataManagerSelfTest.java | 7 +-
.../processors/ggfs/GridGgfsSizeSelfTest.java | 9 +-
.../cache/GridCacheAbstractLoadTest.java | 14 +-
...ridCacheAffinityTransactionsOffHeapTest.java | 8 +-
.../cache/GridCacheGroupLockComparisonTest.java | 7 +-
.../GridCacheWriteBehindStoreLoadTest.java | 7 +-
.../colocation/GridTestCacheStore.java | 8 +-
.../GridCachePartitionedAtomicLongLoadTest.java | 7 +-
.../gridgain/loadtests/dsi/GridDsiPerfJob.java | 4 +-
.../loadtests/hashmap/GridCacheTestContext.java | 4 +-
.../loadtests/hashmap/GridHashMapLoadTest.java | 5 +-
.../swap/GridSwapEvictAllBenchmark.java | 8 +-
.../cache/GridAbstractCacheStoreSelfTest.java | 20 +-
.../GridCacheDataStructuresSelfTestSuite.java | 9 +-
.../GridCacheEvictionSelfTestSuite.java | 4 +-
.../GridCacheFullApiSelfTestSuite.java | 6 +-
.../GridCacheWriteBehindTestSuite.java | 4 +-
.../bamboo/GridDataGridRestartTestSuite.java | 4 -
.../bamboo/GridDataGridTestSuite.java | 38 +-
.../GridHibernateReadWriteAccessStrategy.java | 10 +-
.../hibernate/GridHibernateRegionFactory.java | 15 +-
.../hibernate/GridCacheHibernateBlobStore.java | 17 +-
.../cache/GridCacheAbstractQuerySelfTest.java | 8 +-
.../cache/GridCacheQueryLoadSelfTest.java | 7 +-
...idCachePartitionedHitsAndMissesSelfTest.java | 8 +-
.../GridCacheReplicatedQuerySelfTest.java | 6 +-
.../cache/jta/GridCacheJtaManager.java | 10 +-
.../cache/jta/GridCacheXAResource.java | 12 +-
.../processors/cache/GridCacheJtaSelfTest.java | 5 +-
.../cache/websession/GridWebSessionFilter.java | 7 +-
363 files changed, 18934 insertions(+), 18698 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index 87086a9,c80617e..9ba7c45
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@@ -163,8 -163,7 +163,7 @@@ public class TcpCommunicationSpi extend
public static final int DFLT_PORT = 47100;
/** Default port which node sets listener for shared memory connections (value is <tt>48100</tt>). */
- // FIXME IGNITE-41.
-- public static final int DFLT_SHMEM_PORT = -1;
++ public static final int DFLT_SHMEM_PORT = 48100;
/** Default idle connection timeout (value is <tt>30000</tt>ms). */
public static final long DFLT_IDLE_CONN_TIMEOUT = 30000;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEntryEx.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMessage.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMessage.java
index 882fc5a,12e7329..95cccdb
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMessage.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMessage.java
@@@ -330,12 -331,7 +331,12 @@@ public abstract class GridCacheMessage<
assert ctx != null;
if (txEntries != null) {
+ boolean transferExpiry = transferExpiryPolicy();
+
- for (GridCacheTxEntry<K, V> e : txEntries) {
+ for (IgniteTxEntry<K, V> e : txEntries) {
+ if (transferExpiry)
+ e.transferExpiryPolicyIfNeeded();
+
e.marshal(ctx);
if (ctx.deploymentEnabled()) {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProjectionEx.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProjectionImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProxyImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtGetFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
index 612b7f6,ec091d3..8196fec
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
@@@ -15,7 -15,7 +15,8 @@@ import org.apache.ignite.transactions.*
import org.gridgain.grid.kernal.*;
import org.gridgain.grid.kernal.processors.cache.*;
import org.gridgain.grid.kernal.processors.cache.distributed.*;
+ import org.gridgain.grid.kernal.processors.cache.transactions.*;
+import org.gridgain.grid.util.*;
import org.gridgain.grid.util.direct.*;
import org.gridgain.grid.util.tostring.*;
import org.gridgain.grid.util.typedef.internal.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
index 4fcedca,47e4b98..8913c28
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
@@@ -510,11 -514,13 +514,13 @@@ public abstract class GridDhtTxLocalAda
if (txEntry == null) {
GridDhtCacheEntry<K, V> cached = dhtCache.entryExx(key, topVer);
+ addActiveCache(dhtCache.context());
+
cached.unswap(!read, read);
- GridCacheTxEntry<K, V> w = writeEntries == null ? null : writeEntries.get(idx++);
+ IgniteTxEntry<K, V> w = writeEntries == null ? null : writeEntries.get(idx++);
- txEntry = addEntry(NOOP, null, null, cached, -1, CU.<K, V>empty(), false, -1L, -1L,
+ txEntry = addEntry(read ? READ : NOOP, null, null, cached, null, CU.<K, V>empty(), false, -1L, -1L,
drVers != null ? drVers[drVerIdx++] : null);
if (w != null) {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxRemote.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxRemote.java
index cfdea9c,8c3f0e6..5a179eb
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxRemote.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxRemote.java
@@@ -280,13 -281,8 +281,13 @@@ public class GridDhtTxRemote<K, V> exte
* @param drVer Data center replication version.
* @param clos Transform closures.
*/
- public void addWrite(GridCacheContext<K, V> cacheCtx, GridCacheOperation op, IgniteTxKey<K> key, byte[] keyBytes,
- @Nullable V val, @Nullable byte[] valBytes, @Nullable Collection<IgniteClosure<V, V>> clos,
+ public void addWrite(GridCacheContext<K, V> cacheCtx,
+ GridCacheOperation op,
- GridCacheTxKey<K> key,
++ IgniteTxKey<K> key,
+ byte[] keyBytes,
+ @Nullable V val,
+ @Nullable byte[] valBytes,
+ @Nullable Collection<IgniteClosure<V, V>> clos,
@Nullable GridCacheVersion drVer) {
checkInternal(key);
@@@ -295,14 -291,7 +296,14 @@@
GridDhtCacheEntry<K, V> cached = cacheCtx.dht().entryExx(key.key(), topologyVersion());
- GridCacheTxEntry<K, V> txEntry = new GridCacheTxEntry<>(cacheCtx,
- IgniteTxEntry<K, V> txEntry = new IgniteTxEntry<>(cacheCtx, this, op, val, 0L, -1L, cached, drVer);
++ IgniteTxEntry<K, V> txEntry = new IgniteTxEntry<>(cacheCtx,
+ this,
+ op,
+ val,
+ -1L,
+ -1L,
+ cached,
+ drVer);
txEntry.keyBytes(keyBytes);
txEntry.valueBytes(valBytes);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index 6e9f921,6776cc6..d1e93c9
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@@ -354,14 -316,9 +356,14 @@@ public class GridDhtColocatedCache<K, V
*
* {@inheritDoc}
*/
- @Override public IgniteFuture<Boolean> lockAllAsync(Collection<? extends K> keys, long timeout,
- @Nullable IgniteTxLocalEx<K, V> tx, boolean isInvalidate, boolean isRead, boolean retval,
- @Nullable IgniteTxIsolation isolation, IgnitePredicate<GridCacheEntry<K, V>>[] filter) {
+ @Override public IgniteFuture<Boolean> lockAllAsync(Collection<? extends K> keys,
+ long timeout,
- @Nullable GridCacheTxLocalEx<K, V> tx,
++ @Nullable IgniteTxLocalEx<K, V> tx,
+ boolean isInvalidate,
+ boolean isRead,
+ boolean retval,
- @Nullable GridCacheTxIsolation isolation,
++ @Nullable IgniteTxIsolation isolation,
+ IgnitePredicate<GridCacheEntry<K, V>>[] filter) {
assert tx == null || tx instanceof GridNearTxLocal;
GridNearTxLocal<K, V> txx = (GridNearTxLocal<K, V>)tx;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearAtomicCache.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheAdapter.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheAdapter.java
index 6f71d3c,44bb2e8..2df7506
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheAdapter.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheAdapter.java
@@@ -163,17 -163,9 +164,17 @@@ public abstract class GridNearCacheAdap
/** {@inheritDoc} */
@SuppressWarnings({"unchecked", "RedundantCast"})
@Override public IgniteFuture<Object> readThroughAllAsync(Collection<? extends K> keys, boolean reload,
- GridCacheTxEx<K, V> tx, IgnitePredicate<GridCacheEntry<K, V>>[] filter, @Nullable UUID subjId, String taskName,
+ IgniteTxEx<K, V> tx, IgnitePredicate<GridCacheEntry<K, V>>[] filter, @Nullable UUID subjId, String taskName,
IgniteBiInClosure<K, V> vis) {
- return (IgniteFuture)loadAsync(tx, keys, reload, false, filter, subjId, taskName, true);
+ return (IgniteFuture)loadAsync(tx,
+ keys,
+ reload,
+ false,
+ filter,
+ subjId,
+ taskName,
+ true,
+ null);
}
/** {@inheritDoc} */
@@@ -255,42 -247,21 +256,42 @@@
* @param reload Reload flag.
* @param forcePrimary Force primary flag.
* @param filter Filter.
+ * @param subjId Subject ID.
+ * @param taskName Task name.
+ * @param deserializePortable Deserialize portable flag.
+ * @param expiryPlc Expiry policy.
* @return Loaded values.
*/
- public IgniteFuture<Map<K, V>> loadAsync(@Nullable GridCacheTxEx tx,
- public IgniteFuture<Map<K, V>> loadAsync(@Nullable IgniteTxEx tx, @Nullable Collection<? extends K> keys,
- boolean reload, boolean forcePrimary, @Nullable IgnitePredicate<GridCacheEntry<K, V>>[] filter,
- @Nullable UUID subjId, String taskName, boolean deserializePortable) {
++ public IgniteFuture<Map<K, V>> loadAsync(@Nullable IgniteTxEx tx,
+ @Nullable Collection<? extends K> keys,
+ boolean reload,
+ boolean forcePrimary,
+ @Nullable IgnitePredicate<GridCacheEntry<K, V>>[] filter,
+ @Nullable UUID subjId,
+ String taskName,
+ boolean deserializePortable,
+ @Nullable ExpiryPolicy expiryPlc) {
if (F.isEmpty(keys))
return new GridFinishedFuture<>(ctx.kernalContext(), Collections.<K, V>emptyMap());
if (keyCheck)
validateCacheKeys(keys);
- GridCacheTxLocalEx<K, V> txx = (tx != null && tx.local()) ? (GridCacheTxLocalEx<K, V>)tx : null;
+ IgniteTxLocalEx<K, V> txx = (tx != null && tx.local()) ? (IgniteTxLocalEx<K, V>)tx : null;
- GridNearGetFuture<K, V> fut = new GridNearGetFuture<>(ctx, keys, reload, forcePrimary, txx, filter,
- subjId, taskName, deserializePortable);
+ final GridCacheAccessExpiryPolicy expiry =
+ GridCacheAccessExpiryPolicy.forPolicy(expiryPlc != null ? expiryPlc : ctx.expiry());
+
+ GridNearGetFuture<K, V> fut = new GridNearGetFuture<>(ctx,
+ keys,
+ reload,
+ forcePrimary,
+ txx,
+ filter,
+ subjId,
+ taskName,
+ deserializePortable,
+ expiry);
// init() will register future for responses if future has remote mappings.
fut.init();
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheEntry.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheEntry.java
index 967496b,8699ed9..b5cc463
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheEntry.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheEntry.java
@@@ -310,17 -311,10 +311,17 @@@ public class GridNearCacheEntry<K, V> e
}
/** {@inheritDoc} */
- @Override protected V readThrough(GridCacheTxEx<K, V> tx, K key, boolean reload,
+ @Override protected V readThrough(IgniteTxEx<K, V> tx, K key, boolean reload,
IgnitePredicate<GridCacheEntry<K, V>>[] filter, UUID subjId, String taskName) throws IgniteCheckedException {
- return cctx.near().loadAsync(tx, F.asList(key), reload, /*force primary*/false, filter, subjId, taskName, true).
- get().get(key);
+ return cctx.near().loadAsync(tx,
+ F.asList(key),
+ reload,
+ /*force primary*/false,
+ filter,
+ subjId,
+ taskName,
+ true,
+ null).get().get(key);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTransactionalCache.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxRemote.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxRemote.java
index 9323a9c,fbec6dd..c419a48
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxRemote.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxRemote.java
@@@ -348,13 -349,7 +349,13 @@@ public class GridNearTxRemote<K, V> ext
return false;
}
else {
- GridCacheTxEntry<K, V> txEntry = new GridCacheTxEntry<>(cacheCtx,
- IgniteTxEntry<K, V> txEntry = new IgniteTxEntry<>(cacheCtx, this, op, val, 0L, -1L, cached,
++ IgniteTxEntry<K, V> txEntry = new IgniteTxEntry<>(cacheCtx,
+ this,
+ op,
+ val,
+ -1L,
+ -1L,
+ cached,
drVer);
txEntry.keyBytes(keyBytes);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f537940c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java
index 0000000,a9d28f4..dda7d44
mode 000000,100644..100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java
@@@ -1,0 -1,1523 +1,1524 @@@
+ /* @java.file.header */
+
+ /* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+ package org.gridgain.grid.kernal.processors.cache.transactions;
+
+ import org.apache.ignite.*;
+ import org.apache.ignite.cluster.*;
+ import org.apache.ignite.lang.*;
+ import org.apache.ignite.transactions.*;
+ import org.gridgain.grid.kernal.processors.cache.*;
+ import org.gridgain.grid.kernal.processors.cache.distributed.near.*;
+ import org.gridgain.grid.util.*;
+ import org.gridgain.grid.util.typedef.*;
+ import org.gridgain.grid.util.typedef.internal.*;
+ import org.gridgain.grid.util.future.*;
+ import org.gridgain.grid.util.lang.*;
+ import org.gridgain.grid.util.tostring.*;
+ import org.jetbrains.annotations.*;
+
+ import java.io.*;
+ import java.util.*;
+ import java.util.concurrent.atomic.*;
+ import java.util.concurrent.locks.*;
+
+ import static org.apache.ignite.events.IgniteEventType.*;
+ import static org.gridgain.grid.kernal.processors.cache.GridCacheUtils.*;
+ import static org.apache.ignite.transactions.IgniteTxConcurrency.*;
+ import static org.apache.ignite.transactions.IgniteTxIsolation.*;
+ import static org.apache.ignite.transactions.IgniteTxState.*;
+ import static org.gridgain.grid.kernal.processors.cache.GridCacheOperation.*;
+
+ /**
+ * Managed transaction adapter.
+ */
+ public abstract class IgniteTxAdapter<K, V> extends GridMetadataAwareAdapter
+ implements IgniteTxEx<K, V>, Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Static logger to avoid re-creation. */
+ private static final AtomicReference<IgniteLogger> logRef = new AtomicReference<>();
+
+ /** Logger. */
+ protected static IgniteLogger log;
+
+ /** Transaction ID. */
+ @GridToStringInclude
+ protected GridCacheVersion xidVer;
+
+ /** Entries write version. */
+ @GridToStringInclude
+ protected GridCacheVersion writeVer;
+
+ /** Implicit flag. */
+ @GridToStringInclude
+ protected boolean implicit;
+
+ /** Implicit with one key flag. */
+ @GridToStringInclude
+ protected boolean implicitSingle;
+
+ /** Local flag. */
+ @GridToStringInclude
+ protected boolean loc;
+
+ /** Thread ID. */
+ @GridToStringInclude
+ protected long threadId;
+
+ /** Transaction start time. */
+ @GridToStringInclude
+ protected long startTime = U.currentTimeMillis();
+
+ /** Node ID. */
+ @GridToStringInclude
+ protected UUID nodeId;
+
+ /** Transaction counter value at the start of transaction. */
+ @GridToStringInclude
+ protected GridCacheVersion startVer;
+
+ /** Cache registry. */
+ @GridToStringExclude
+ protected GridCacheSharedContext<K, V> cctx;
+
+ /**
+ * End version (a.k.a. <tt>'tnc'</tt> or <tt>'transaction number counter'</tt>)
+ * assigned to this transaction at the end of write phase.
+ */
+ @GridToStringInclude
+ protected GridCacheVersion endVer;
+
+ /** Isolation. */
+ @GridToStringInclude
+ protected IgniteTxIsolation isolation = READ_COMMITTED;
+
+ /** Concurrency. */
+ @GridToStringInclude
+ protected IgniteTxConcurrency concurrency = PESSIMISTIC;
+
+ /** Transaction timeout. */
+ @GridToStringInclude
+ protected long timeout;
+
+ /** Invalidate flag. */
+ protected volatile boolean invalidate;
+
+ /** Invalidation flag for system invalidations (not user-based ones). */
+ private boolean sysInvalidate;
+
+ /** Internal flag. */
+ protected boolean internal;
+
+ /** System transaction flag. */
+ private boolean sys;
+
+ /** */
+ protected boolean onePhaseCommit;
+
+ /** */
+ protected boolean syncCommit;
+
+ /** */
+ protected boolean syncRollback;
+
+ /** If this transaction contains transform entries. */
+ protected boolean transform;
+
+ /** Commit version. */
+ private AtomicReference<GridCacheVersion> commitVer = new AtomicReference<>(null);
+
+ /** Done marker. */
+ protected final AtomicBoolean isDone = new AtomicBoolean(false);
+
+ /** */
+ private AtomicReference<FinalizationStatus> finalizing = new AtomicReference<>(FinalizationStatus.NONE);
+
+ /** Preparing flag. */
+ private AtomicBoolean preparing = new AtomicBoolean();
+
+ /** */
+ private Set<Integer> invalidParts = new GridLeanSet<>();
+
+ /** Recover writes. */
+ private Collection<IgniteTxEntry<K, V>> recoveryWrites;
+
+ /**
+ * Transaction state. Note that state is not protected, as we want to
+ * always use {@link #state()} and {@link #state(IgniteTxState)}
+ * methods.
+ */
+ @GridToStringInclude
+ private volatile IgniteTxState state = ACTIVE;
+
+ /** Timed out flag. */
+ private volatile boolean timedOut;
+
+ /** */
+ protected int txSize;
+
+ /** Group lock key, if any. */
+ protected IgniteTxKey grpLockKey;
+
+ /** */
+ @GridToStringExclude
+ private AtomicReference<GridFutureAdapter<IgniteTx>> finFut = new AtomicReference<>();
+
+ /** Topology version. */
+ private AtomicLong topVer = new AtomicLong(-1);
+
+ /** Mutex. */
+ private final Lock lock = new ReentrantLock();
+
+ /** Lock condition. */
+ private final Condition cond = lock.newCondition();
+
+ /** Subject ID initiated this transaction. */
+ protected UUID subjId;
+
+ /** Task name hash code. */
+ protected int taskNameHash;
+
+ /** Task name. */
+ protected String taskName;
+
+ /** Store used flag. */
+ protected boolean storeEnabled = true;
+
+ /**
+ * Empty constructor required for {@link Externalizable}.
+ */
+ protected IgniteTxAdapter() {
+ // No-op.
+ }
+
+ /**
+ * @param cctx Cache registry.
+ * @param xidVer Transaction ID.
+ * @param implicit Implicit flag.
+ * @param implicitSingle Implicit with one key flag.
+ * @param loc Local flag.
+ * @param sys System transaction flag.
+ * @param concurrency Concurrency.
+ * @param isolation Isolation.
+ * @param timeout Timeout.
+ * @param txSize Transaction size.
+ * @param grpLockKey Group lock key if this is group-lock transaction.
+ */
+ protected IgniteTxAdapter(
+ GridCacheSharedContext<K, V> cctx,
+ GridCacheVersion xidVer,
+ boolean implicit,
+ boolean implicitSingle,
+ boolean loc,
+ boolean sys,
+ IgniteTxConcurrency concurrency,
+ IgniteTxIsolation isolation,
+ long timeout,
+ boolean invalidate,
+ boolean storeEnabled,
+ int txSize,
+ @Nullable IgniteTxKey grpLockKey,
+ @Nullable UUID subjId,
+ int taskNameHash
+ ) {
+ assert xidVer != null;
+ assert cctx != null;
+
+ this.cctx = cctx;
+ this.xidVer = xidVer;
+ this.implicit = implicit;
+ this.implicitSingle = implicitSingle;
+ this.loc = loc;
+ this.sys = sys;
+ this.concurrency = concurrency;
+ this.isolation = isolation;
+ this.timeout = timeout;
+ this.invalidate = invalidate;
+ this.storeEnabled = storeEnabled;
+ this.txSize = txSize;
+ this.grpLockKey = grpLockKey;
+ this.subjId = subjId;
+ this.taskNameHash = taskNameHash;
+
+ startVer = cctx.versions().last();
+
+ nodeId = cctx.discovery().localNode().id();
+
+ threadId = Thread.currentThread().getId();
+
+ log = U.logger(cctx.kernalContext(), logRef, this);
+ }
+
+ /**
+ * @param cctx Cache registry.
+ * @param nodeId Node ID.
+ * @param xidVer Transaction ID.
+ * @param startVer Start version mark.
+ * @param threadId Thread ID.
+ * @param sys System transaction flag.
+ * @param concurrency Concurrency.
+ * @param isolation Isolation.
+ * @param timeout Timeout.
+ * @param txSize Transaction size.
+ * @param grpLockKey Group lock key if this is group-lock transaction.
+ */
+ protected IgniteTxAdapter(
+ GridCacheSharedContext<K, V> cctx,
+ UUID nodeId,
+ GridCacheVersion xidVer,
+ GridCacheVersion startVer,
+ long threadId,
+ boolean sys,
+ IgniteTxConcurrency concurrency,
+ IgniteTxIsolation isolation,
+ long timeout,
+ int txSize,
+ @Nullable IgniteTxKey grpLockKey,
+ @Nullable UUID subjId,
+ int taskNameHash
+ ) {
+ this.cctx = cctx;
+ this.nodeId = nodeId;
+ this.threadId = threadId;
+ this.xidVer = xidVer;
+ this.startVer = startVer;
+ this.sys = sys;
+ this.concurrency = concurrency;
+ this.isolation = isolation;
+ this.timeout = timeout;
+ this.txSize = txSize;
+ this.grpLockKey = grpLockKey;
+ this.subjId = subjId;
+ this.taskNameHash = taskNameHash;
+
+ implicit = false;
+ implicitSingle = false;
+ loc = false;
+
+ log = U.logger(cctx.kernalContext(), logRef, this);
+ }
+
+ /**
+ * Acquires lock.
+ */
+ @SuppressWarnings({"LockAcquiredButNotSafelyReleased"})
+ protected final void lock() {
+ lock.lock();
+ }
+
+ /**
+ * Releases lock.
+ */
+ protected final void unlock() {
+ lock.unlock();
+ }
+
+ /**
+ * Signals all waiters.
+ */
+ protected final void signalAll() {
+ cond.signalAll();
+ }
+
+ /**
+ * Waits for signal.
+ *
+ * @throws InterruptedException If interrupted.
+ */
+ protected final void awaitSignal() throws InterruptedException {
+ cond.await();
+ }
+
+ /**
+ * Checks whether near cache should be updated.
+ *
+ * @return Flag indicating whether near cache should be updated.
+ */
+ protected boolean updateNearCache(GridCacheContext<K, V> cacheCtx, K key, long topVer) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<IgniteTxEntry<K, V>> optimisticLockEntries() {
+ assert optimistic();
+
+ if (!groupLock())
+ return writeEntries();
+ else {
+ if (!F.isEmpty(invalidParts)) {
+ assert invalidParts.size() == 1 : "Only one partition expected for group lock transaction " +
+ "[tx=" + this + ", invalidParts=" + invalidParts + ']';
+ assert groupLockEntry() == null : "Group lock key should be rejected " +
+ "[tx=" + this + ", groupLockEntry=" + groupLockEntry() + ']';
+ assert F.isEmpty(writeMap()) : "All entries should be rejected for group lock transaction " +
+ "[tx=" + this + ", writes=" + writeMap() + ']';
+
+ return Collections.emptyList();
+ }
+
+ IgniteTxEntry<K, V> grpLockEntry = groupLockEntry();
+
+ assert grpLockEntry != null || (near() && !local()):
+ "Group lock entry was not enlisted into transaction [tx=" + this +
+ ", grpLockKey=" + groupLockKey() + ']';
+
+ return grpLockEntry == null ?
+ Collections.<IgniteTxEntry<K,V>>emptyList() :
+ Collections.singletonList(grpLockEntry);
+ }
+ }
+
+ /**
+ * @param recoveryWrites Recover write entries.
+ */
+ public void recoveryWrites(Collection<IgniteTxEntry<K, V>> recoveryWrites) {
+ this.recoveryWrites = recoveryWrites;
+ }
+
+ /**
+ * @return Recover write entries.
+ */
+ @Override public Collection<IgniteTxEntry<K, V>> recoveryWrites() {
+ return recoveryWrites;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean storeEnabled() {
+ return storeEnabled;
+ }
+
+ /**
+ * @param storeEnabled Store enabled flag.
+ */
+ public void storeEnabled(boolean storeEnabled) {
+ this.storeEnabled = storeEnabled;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean system() {
+ return sys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean storeUsed() {
+ return storeEnabled() && store() != null;
+ }
+
+ /**
+ * Store manager for current transaction.
+ *
+ * @return Store manager.
+ */
+ protected GridCacheStoreManager<K, V> store() {
+ if (!activeCacheIds().isEmpty()) {
+ int cacheId = F.first(activeCacheIds());
+
+ GridCacheStoreManager<K, V> store = cctx.cacheContext(cacheId).store();
+
+ return store.configured() ? store : null;
+ }
+
+ return null;
+ }
+
+ /**
+ * This method uses unchecked assignment to cast group lock key entry to transaction generic signature.
+ *
+ * @return Group lock tx entry.
+ */
+ @SuppressWarnings("unchecked")
+ public IgniteTxEntry<K, V> groupLockEntry() {
+ return ((IgniteTxAdapter)this).entry(groupLockKey());
+ }
+
+ /** {@inheritDoc} */
+ @Override public UUID otherNodeId() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public UUID subjectId() {
+ if (subjId != null)
+ return subjId;
+
+ return originatingNodeId();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int taskNameHash() {
+ return taskNameHash;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long topologyVersion() {
+ long res = topVer.get();
+
+ if (res == -1)
+ return cctx.exchange().topologyVersion();
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long topologyVersion(long topVer) {
+ this.topVer.compareAndSet(-1, topVer);
+
+ return this.topVer.get();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean hasTransforms() {
+ return transform;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean markPreparing() {
+ return preparing.compareAndSet(false, true);
+ }
+
+ /**
+ * @return {@code True} if marked.
+ */
+ @Override public boolean markFinalizing(FinalizationStatus status) {
+ boolean res;
+
+ switch (status) {
+ case USER_FINISH:
+ res = finalizing.compareAndSet(FinalizationStatus.NONE, FinalizationStatus.USER_FINISH);
+
+ break;
+
+ case RECOVERY_WAIT:
+ finalizing.compareAndSet(FinalizationStatus.NONE, FinalizationStatus.RECOVERY_WAIT);
+
+ FinalizationStatus cur = finalizing.get();
+
+ res = cur == FinalizationStatus.RECOVERY_WAIT || cur == FinalizationStatus.RECOVERY_FINISH;
+
+ break;
+
+ case RECOVERY_FINISH:
+ FinalizationStatus old = finalizing.get();
+
+ res = old != FinalizationStatus.USER_FINISH && finalizing.compareAndSet(old, status);
+
+ break;
+
+ default:
+ throw new IllegalArgumentException("Cannot set finalization status: " + status);
+
+ }
+
+ if (res) {
+ if (log.isDebugEnabled())
+ log.debug("Marked transaction as finalized: " + this);
+ }
+ else {
+ if (log.isDebugEnabled())
+ log.debug("Transaction was not marked finalized: " + this);
+ }
+
+ return res;
+ }
+
+ /**
+ * @return Finalization status.
+ */
+ protected FinalizationStatus finalizationStatus() {
+ return finalizing.get();
+ }
+
+ /**
+ * @return {@code True} if transaction has at least one key enlisted.
+ */
+ public abstract boolean isStarted();
+
+ /** {@inheritDoc} */
+ @Override public boolean groupLock() {
+ return grpLockKey != null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteTxKey groupLockKey() {
+ return grpLockKey;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int size() {
+ return txSize;
+ }
+
+ /**
+ * @return Logger.
+ */
+ protected IgniteLogger log() {
+ return log;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean near() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean implicit() {
+ return implicit;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean implicitSingle() {
+ return implicitSingle;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean local() {
+ return loc;
+ }
+
+ /** {@inheritDoc} */
+ @Override public final boolean user() {
+ return !implicit() && local() && !dht() && !internal();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean dht() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean colocated() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean replicated() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean enforceSerializable() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean syncCommit() {
+ return syncCommit;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean syncRollback() {
+ return syncRollback;
+ }
+
+ /**
+ * @param syncCommit Synchronous commit flag.
+ */
+ public void syncCommit(boolean syncCommit) {
+ this.syncCommit = syncCommit;
+ }
+
+ /**
+ * @param syncRollback Synchronous rollback flag.
+ */
+ public void syncRollback(boolean syncRollback) {
+ this.syncRollback = syncRollback;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteUuid xid() {
+ return xidVer.asGridUuid();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Set<Integer> invalidPartitions() {
+ return invalidParts;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void addInvalidPartition(GridCacheContext<K, V> cacheCtx, int part) {
+ invalidParts.add(part);
+
+ if (log.isDebugEnabled())
+ log.debug("Added invalid partition for transaction [part=" + part + ", tx=" + this + ']');
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCacheVersion ownedVersion(IgniteTxKey<K> key) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long startTime() {
+ return startTime;
+ }
+
+ /**
+ * Gets remaining allowed transaction time.
+ *
+ * @return Remaining transaction time.
+ */
+ @Override public long remainingTime() {
+ if (timeout() <= 0)
+ return -1;
+
+ long timeLeft = timeout() - (U.currentTimeMillis() - startTime());
+
+ if (timeLeft < 0)
+ return 0;
+
+ return timeLeft;
+ }
+
+ /**
+ * @return Lock timeout.
+ */
+ protected long lockTimeout() {
+ long timeout = remainingTime();
+
+ return timeout < 0 ? 0 : timeout == 0 ? -1 : timeout;
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCacheVersion xidVersion() {
+ return xidVer;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long threadId() {
+ return threadId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public UUID nodeId() {
+ return nodeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteTxIsolation isolation() {
+ return isolation;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteTxConcurrency concurrency() {
+ return concurrency;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long timeout() {
+ return timeout;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long timeout(long timeout) {
+ if (isStarted())
+ throw new IllegalStateException("Cannot change timeout after transaction has started: " + this);
+
+ long old = this.timeout;
+
+ this.timeout = timeout;
+
+ return old;
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("SimplifiableIfStatement")
+ @Override public boolean ownsLock(GridCacheEntryEx<K, V> entry) throws GridCacheEntryRemovedException {
+ GridCacheContext<K, V> cacheCtx = entry.context();
+
+ IgniteTxEntry<K, V> txEntry = entry(entry.txKey());
+
+ GridCacheVersion explicit = txEntry == null ? null : txEntry.explicitVersion();
+
+ assert !txEntry.groupLockEntry() || groupLock() : "Can not have group-locked tx entries in " +
+ "non-group-lock transactions [txEntry=" + txEntry + ", tx=" + this + ']';
+
+ return local() && !cacheCtx.isDht() ?
+ entry.lockedByThread(threadId()) || (explicit != null && entry.lockedBy(explicit)) :
+ // If candidate is not there, then lock was explicit.
+ // Otherwise, check if entry is owned by version.
+ !entry.hasLockCandidate(xidVersion()) || entry.lockedBy(xidVersion());
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("SimplifiableIfStatement")
+ @Override public boolean ownsLockUnsafe(GridCacheEntryEx<K, V> entry) {
+ GridCacheContext<K, V> cacheCtx = entry.context();
+
+ IgniteTxEntry<K, V> txEntry = entry(entry.txKey());
+
+ GridCacheVersion explicit = txEntry == null ? null : txEntry.explicitVersion();
+
+ assert !txEntry.groupLockEntry() || groupLock() : "Can not have group-locked tx entries in " +
+ "non-group-lock transactions [txEntry=" + txEntry + ", tx=" + this + ']';
+
+ return local() && !cacheCtx.isDht() ?
+ entry.lockedByThreadUnsafe(threadId()) || (explicit != null && entry.lockedByUnsafe(explicit)) :
+ // If candidate is not there, then lock was explicit.
+ // Otherwise, check if entry is owned by version.
+ !entry.hasLockCandidateUnsafe(xidVersion()) || entry.lockedByUnsafe(xidVersion());
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteTxState state() {
+ return state;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean setRollbackOnly() {
+ return state(MARKED_ROLLBACK);
+ }
+
+ /**
+ * @return {@code True} if rollback only flag is set.
+ */
+ @Override public boolean isRollbackOnly() {
+ return state == MARKED_ROLLBACK || state == ROLLING_BACK || state == ROLLED_BACK;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean done() {
+ return isDone.get();
+ }
+
+ /**
+ * @return Commit version.
+ */
+ @Override public GridCacheVersion commitVersion() {
+ initCommitVersion();
+
+ return commitVer.get();
+ }
+
+ /**
+ * @param commitVer Commit version.
+ * @return {@code True} if set to not null value.
+ */
+ @Override public boolean commitVersion(GridCacheVersion commitVer) {
+ return commitVer != null && this.commitVer.compareAndSet(null, commitVer);
+ }
+
+ /**
+ *
+ */
+ public void initCommitVersion() {
+ if (commitVer.get() == null)
+ commitVer.compareAndSet(null, xidVer);
+ }
+
+ /**
+ *
+ */
+ @Override public void close() throws IgniteCheckedException {
+ IgniteTxState state = state();
+
+ if (state != ROLLING_BACK && state != ROLLED_BACK && state != COMMITTING && state != COMMITTED)
+ rollback();
+
+ awaitCompletion();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean needsCompletedVersions() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void completedVersions(GridCacheVersion base, Collection<GridCacheVersion> committed,
+ Collection<GridCacheVersion> txs) {
+ /* No-op. */
+ }
+
+ /**
+ * Awaits transaction completion.
+ *
+ * @throws IgniteCheckedException If waiting failed.
+ */
+ protected void awaitCompletion() throws IgniteCheckedException {
+ lock();
+
+ try {
+ while (!done())
+ awaitSignal();
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+
+ if (!done())
+ throw new IgniteCheckedException("Got interrupted while waiting for transaction to complete: " + this, e);
+ }
+ finally {
+ unlock();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean internal() {
+ return internal;
+ }
+
+ /**
+ * @param key Key.
+ * @return {@code True} if key is internal.
+ */
+ protected boolean checkInternal(IgniteTxKey<K> key) {
+ if (key.key() instanceof GridCacheInternal) {
+ internal = true;
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * @param onePhaseCommit {@code True} if transaction commit should be performed in short-path way.
+ */
+ public void onePhaseCommit(boolean onePhaseCommit) {
+ this.onePhaseCommit = onePhaseCommit;
+ }
+
+ /**
+ * @return Fast commit flag.
+ */
+ @Override public boolean onePhaseCommit() {
+ return onePhaseCommit;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean optimistic() {
+ return concurrency == OPTIMISTIC;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean pessimistic() {
+ return concurrency == PESSIMISTIC;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean serializable() {
+ return isolation == SERIALIZABLE;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean repeatableRead() {
+ return isolation == REPEATABLE_READ;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean readCommitted() {
+ return isolation == READ_COMMITTED;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean state(IgniteTxState state) {
+ return state(state, false);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("ExternalizableWithoutPublicNoArgConstructor")
+ @Override public IgniteFuture<IgniteTx> finishFuture() {
+ GridFutureAdapter<IgniteTx> fut = finFut.get();
+
+ if (fut == null) {
+ fut = new GridFutureAdapter<IgniteTx>(cctx.kernalContext()) {
+ @Override public String toString() {
+ return S.toString(GridFutureAdapter.class, this, "tx", IgniteTxAdapter.this);
+ }
+ };
+
+ if (!finFut.compareAndSet(null, fut))
+ fut = finFut.get();
+ }
+
+ assert fut != null;
+
+ if (isDone.get())
+ fut.onDone(this);
+
+ return fut;
+ }
+
+ /**
+ *
+ * @param state State to set.
+ * @param timedOut Timeout flag.
+ * @return {@code True} if state changed.
+ */
+ @SuppressWarnings({"TooBroadScope"})
+ private boolean state(IgniteTxState state, boolean timedOut) {
+ boolean valid = false;
+
+ IgniteTxState prev;
+
+ boolean notify = false;
+
+ lock();
+
+ try {
+ prev = this.state;
+
+ switch (state) {
+ case ACTIVE: {
+ valid = false;
+
+ break;
+ } // Active is initial state and cannot be transitioned to.
+ case PREPARING: {
+ valid = prev == ACTIVE;
+
+ break;
+ }
+ case PREPARED: {
+ valid = prev == PREPARING;
+
+ break;
+ }
+ case COMMITTING: {
+ valid = prev == PREPARED;
+
+ break;
+ }
+
+ case UNKNOWN: {
+ if (isDone.compareAndSet(false, true))
+ notify = true;
+
+ valid = prev == ROLLING_BACK || prev == COMMITTING;
+
+ break;
+ }
+
+ case COMMITTED: {
+ if (isDone.compareAndSet(false, true))
+ notify = true;
+
+ valid = prev == COMMITTING;
+
+ break;
+ }
+
+ case ROLLED_BACK: {
+ if (isDone.compareAndSet(false, true))
+ notify = true;
+
+ valid = prev == ROLLING_BACK;
+
+ break;
+ }
+
+ case MARKED_ROLLBACK: {
+ valid = prev == ACTIVE || prev == PREPARING || prev == PREPARED || prev == COMMITTING;
+
+ break;
+ }
+
+ case ROLLING_BACK: {
+ valid =
+ prev == ACTIVE || prev == MARKED_ROLLBACK || prev == PREPARING ||
+ prev == PREPARED || (prev == COMMITTING && local() && !dht());
+
+ break;
+ }
+ }
+
+ if (valid) {
+ this.state = state;
+ this.timedOut = timedOut;
+
+ if (log.isDebugEnabled())
+ log.debug("Changed transaction state [prev=" + prev + ", new=" + this.state + ", tx=" + this + ']');
+
+ // Notify of state change.
+ signalAll();
+ }
+ else {
+ if (log.isDebugEnabled())
+ log.debug("Invalid transaction state transition [invalid=" + state + ", cur=" + this.state +
+ ", tx=" + this + ']');
+ }
+ }
+ finally {
+ unlock();
+ }
+
+ if (notify) {
+ GridFutureAdapter<IgniteTx> fut = finFut.get();
+
+ if (fut != null)
+ fut.onDone(this);
+ }
+
+ if (valid) {
+ // Seal transactions maps.
+ if (state != ACTIVE)
+ seal();
+
+ cctx.tm().onTxStateChange(prev, state, this);
+ }
+
+ return valid;
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCacheVersion startVersion() {
+ return startVer;
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCacheVersion endVersion() {
+ return endVer;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void endVersion(GridCacheVersion endVer) {
+ this.endVer = endVer;
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCacheVersion writeVersion() {
+ return writeVer == null ? commitVersion() : writeVer;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeVersion(GridCacheVersion writeVer) {
+ this.writeVer = writeVer;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteUuid timeoutId() {
+ return xidVer.asGridUuid();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long endTime() {
+ long endTime = timeout == 0 ? Long.MAX_VALUE : startTime + timeout;
+
+ return endTime > 0 ? endTime : endTime < 0 ? Long.MAX_VALUE : endTime;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onTimeout() {
+ state(MARKED_ROLLBACK, true);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean timedOut() {
+ return timedOut;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void invalidate(boolean invalidate) {
+ if (isStarted() && !dht())
+ throw new IllegalStateException("Cannot change invalidation flag after transaction has started: " + this);
+
+ this.invalidate = invalidate;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isInvalidate() {
+ return invalidate;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isSystemInvalidate() {
+ return sysInvalidate;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void systemInvalidate(boolean sysInvalidate) {
+ this.sysInvalidate = sysInvalidate;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Map<UUID, Collection<UUID>> transactionNodes() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public GridCacheVersion nearXidVersion() {
+ return null;
+ }
+
+ /**
+ * @param txEntry Entry to process.
+ * @param metrics {@code True} if metrics should be updated.
+ * @return Tuple containing transformation results.
+ * @throws IgniteCheckedException If failed to get previous value for transform.
+ * @throws GridCacheEntryRemovedException If entry was concurrently deleted.
+ */
+ protected GridTuple3<GridCacheOperation, V, byte[]> applyTransformClosures(IgniteTxEntry<K, V> txEntry,
+ boolean metrics) throws GridCacheEntryRemovedException, IgniteCheckedException {
+ GridCacheContext cacheCtx = txEntry.context();
+
+ assert cacheCtx != null;
+
+ if (isSystemInvalidate())
+ return F.t(cacheCtx.isStoreEnabled() ? RELOAD : DELETE, null, null);
+ if (F.isEmpty(txEntry.transformClosures()))
+ return F.t(txEntry.op(), txEntry.value(), txEntry.valueBytes());
+ else {
+ try {
+ boolean recordEvt = cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_READ);
+
+ V val = txEntry.hasValue() ? txEntry.value() :
+ txEntry.cached().innerGet(this,
+ /*swap*/false,
+ /*read through*/false,
+ /*fail fast*/true,
+ /*unmarshal*/true,
+ /*metrics*/metrics,
+ /*event*/recordEvt,
+ /*temporary*/true,
+ /*subjId*/subjId,
+ /**closure name */recordEvt ? F.first(txEntry.transformClosures()) : null,
+ resolveTaskName(),
- CU.<K, V>empty());
++ CU.<K, V>empty(),
++ null);
+
+ try {
+ for (IgniteClosure<V, V> clos : txEntry.transformClosures())
+ val = clos.apply(val);
+ }
+ catch (Throwable e) {
+ throw new IgniteException("Transform closure must not throw any exceptions " +
+ "(transaction will be invalidated)", e);
+ }
+
+ GridCacheOperation op = val == null ? DELETE : UPDATE;
+
+ return F.t(op, (V)cacheCtx.<V>unwrapTemporary(val), null);
+ }
+ catch (GridCacheFilterFailedException e) {
+ assert false : "Empty filter failed for innerGet: " + e;
+
+ return null;
+ }
+ }
+ }
+
+ /**
+ * @return Resolves task name.
+ */
+ public String resolveTaskName() {
+ if (taskName != null)
+ return taskName;
+
+ return (taskName = cctx.kernalContext().task().resolveTaskName(taskNameHash));
+ }
+
+ /**
+ * @param e Transaction entry.
+ * @param primaryOnly Flag to include backups into check or not.
+ * @return {@code True} if entry is locally mapped as a primary or back up node.
+ */
+ protected boolean isNearLocallyMapped(IgniteTxEntry<K, V> e, boolean primaryOnly) {
+ GridCacheContext<K, V> cacheCtx = e.context();
+
+ if (!cacheCtx.isNear())
+ return false;
+
+ // Try to take either entry-recorded primary node ID,
+ // or transaction node ID from near-local transactions.
+ UUID nodeId = e.nodeId() == null ? local() ? this.nodeId : null : e.nodeId();
+
+ if (nodeId != null && nodeId.equals(cctx.localNodeId()))
+ return true;
+
+ GridCacheEntryEx<K, V> cached = e.cached();
+
+ int part = cached != null ? cached.partition() : cacheCtx.affinity().partition(e.key());
+
+ List<ClusterNode> affNodes = cacheCtx.affinity().nodes(part, topologyVersion());
+
+ e.locallyMapped(F.contains(affNodes, cctx.localNode()));
+
+ if (primaryOnly) {
+ ClusterNode primary = F.first(affNodes);
+
+ if (primary == null && !isAffinityNode(cacheCtx.config()))
+ return false;
+
+ assert primary != null : "Primary node is null for affinity nodes: " + affNodes;
+
+ return primary.isLocal();
+ }
+ else
+ return e.locallyMapped();
+ }
+
+ /**
+ * @param e Entry to evict if it qualifies for eviction.
+ * @param primaryOnly Flag to try to evict only on primary node.
+ * @return {@code True} if attempt was made to evict the entry.
+ * @throws IgniteCheckedException If failed.
+ */
+ protected boolean evictNearEntry(IgniteTxEntry<K, V> e, boolean primaryOnly) throws IgniteCheckedException {
+ assert e != null;
+
+ if (isNearLocallyMapped(e, primaryOnly)) {
+ GridCacheEntryEx<K, V> cached = e.cached();
+
+ assert cached instanceof GridNearCacheEntry : "Invalid cache entry: " + e;
+
+ if (log.isDebugEnabled())
+ log.debug("Evicting dht-local entry from near cache [entry=" + cached + ", tx=" + this + ']');
+
+ if (cached != null && cached.markObsolete(xidVer))
+ return true;
+ }
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ writeExternalMeta(out);
+
+ out.writeObject(xidVer);
+ out.writeBoolean(invalidate);
+ out.writeLong(timeout);
+ out.writeLong(threadId);
+ out.writeLong(startTime);
+
+ U.writeUuid(out, nodeId);
+
+ out.write(isolation.ordinal());
+ out.write(concurrency.ordinal());
+ out.write(state().ordinal());
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ readExternalMeta(in);
+
+ xidVer = (GridCacheVersion)in.readObject();
+ invalidate = in.readBoolean();
+ timeout = in.readLong();
+ threadId = in.readLong();
+ startTime = in.readLong();
+
+ nodeId = U.readUuid(in);
+
+ isolation = IgniteTxIsolation.fromOrdinal(in.read());
+ concurrency = IgniteTxConcurrency.fromOrdinal(in.read());
+
+ state = IgniteTxState.fromOrdinal(in.read());
+ }
+
+ /**
+ * Reconstructs object on unmarshalling.
+ *
+ * @return Reconstructed object.
+ * @throws ObjectStreamException Thrown in case of unmarshalling error.
+ */
+ protected Object readResolve() throws ObjectStreamException {
+ return new TxShadow(
+ xidVer.asGridUuid(),
+ nodeId,
+ threadId,
+ startTime,
+ isolation,
+ concurrency,
+ invalidate,
+ implicit,
+ timeout,
+ state(),
+ isRollbackOnly()
+ );
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ return o == this || (o instanceof IgniteTxAdapter && xidVer.equals(((IgniteTxAdapter)o).xidVer));
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return xidVer.hashCode();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return GridToStringBuilder.toString(IgniteTxAdapter.class, this,
+ "duration", (U.currentTimeMillis() - startTime) + "ms", "grpLock", groupLock(),
+ "onePhaseCommit", onePhaseCommit);
+ }
+
+ /**
+ * Transaction shadow class to be used for deserialization.
+ */
+ private static class TxShadow extends GridMetadataAwareAdapter implements IgniteTx {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Xid. */
+ private final IgniteUuid xid;
+
+ /** Node ID. */
+ private final UUID nodeId;
+
+ /** Thread ID. */
+ private final long threadId;
+
+ /** Start time. */
+ private final long startTime;
+
+ /** Transaction isolation. */
+ private final IgniteTxIsolation isolation;
+
+ /** Concurrency. */
+ private final IgniteTxConcurrency concurrency;
+
+ /** Invalidate flag. */
+ private final boolean invalidate;
+
+ /** Timeout. */
+ private final long timeout;
+
+ /** State. */
+ private final IgniteTxState state;
+
+ /** Rollback only flag. */
+ private final boolean rollbackOnly;
+
+ /** Implicit flag. */
+ private final boolean implicit;
+
+ /**
+ * @param xid Xid.
+ * @param nodeId Node ID.
+ * @param threadId Thread ID.
+ * @param startTime Start time.
+ * @param isolation Isolation.
+ * @param concurrency Concurrency.
+ * @param invalidate Invalidate flag.
+ * @param implicit Implicit flag.
+ * @param timeout Transaction timeout.
+ * @param state Transaction state.
+ * @param rollbackOnly Rollback-only flag.
+ */
+ TxShadow(IgniteUuid xid, UUID nodeId, long threadId, long startTime, IgniteTxIsolation isolation,
+ IgniteTxConcurrency concurrency, boolean invalidate, boolean implicit, long timeout,
+ IgniteTxState state, boolean rollbackOnly) {
+ this.xid = xid;
+ this.nodeId = nodeId;
+ this.threadId = threadId;
+ this.startTime = startTime;
+ this.isolation = isolation;
+ this.concurrency = concurrency;
+ this.invalidate = invalidate;
+ this.implicit = implicit;
+ this.timeout = timeout;
+ this.state = state;
+ this.rollbackOnly = rollbackOnly;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteUuid xid() {
+ return xid;
+ }
+
+ /** {@inheritDoc} */
+ @Override public UUID nodeId() {
+ return nodeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long threadId() {
+ return threadId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long startTime() {
+ return startTime;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteTxIsolation isolation() {
+ return isolation;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteTxConcurrency concurrency() {
+ return concurrency;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isInvalidate() {
+ return invalidate;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean implicit() {
+ return implicit;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long timeout() {
+ return timeout;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteTxState state() {
+ return state;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isRollbackOnly() {
+ return rollbackOnly;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long timeout(long timeout) {
+ throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean setRollbackOnly() {
+ throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void commit() {
+ throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() {
+ throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteFuture<IgniteTx> commitAsync() {
+ throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void rollback() {
+ throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ return this == o || o instanceof IgniteTx && xid.equals(((IgniteTx)o).xid());
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return xid.hashCode();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(TxShadow.class, this);
+ }
+ }
+ }