ignite-545: merge from sprint-6
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/1652fd18 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/1652fd18 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/1652fd18 Branch: refs/heads/ignite-545 Commit: 1652fd181f0f94388d4bf10bf87223c9ebef2269 Parents: cd96383 Author: Denis Magda <dma...@gridgain.com> Authored: Wed Jun 10 17:08:54 2015 +0300 Committer: Denis Magda <dma...@gridgain.com> Committed: Wed Jun 10 17:08:54 2015 +0300 ---------------------------------------------------------------------- DEVNOTES.txt | 42 +- assembly/dependencies-visor-console.xml | 3 + .../hibernate/CacheHibernatePersonStore.java | 202 +- .../hibernate/CacheHibernateStoreExample.java | 17 + .../store/jdbc/CacheJdbcPersonStore.java | 180 +- .../store/jdbc/CacheJdbcStoreExample.java | 13 + .../store/spring/CacheSpringPersonStore.java | 128 + .../store/spring/CacheSpringStoreExample.java | 143 + .../datagrid/store/spring/package-info.java | 22 + .../java/org/apache/ignite/IgniteCache.java | 16 + .../main/java/org/apache/ignite/Ignition.java | 18 +- .../org/apache/ignite/cache/CacheMetrics.java | 187 +- .../ignite/cache/eviction/EvictableEntry.java | 7 + .../ignite/cache/eviction/EvictionPolicy.java | 2 + .../cache/eviction/fifo/FifoEvictionPolicy.java | 117 +- .../eviction/fifo/FifoEvictionPolicyMBean.java | 22 + .../cache/eviction/lru/LruEvictionPolicy.java | 135 +- .../eviction/lru/LruEvictionPolicyMBean.java | 38 + .../eviction/random/RandomEvictionPolicy.java | 10 +- .../eviction/sorted/SortedEvictionPolicy.java | 141 +- .../sorted/SortedEvictionPolicyMBean.java | 22 + .../apache/ignite/cache/query/QueryMetrics.java | 6 +- .../apache/ignite/cache/store/CacheStore.java | 2 + .../ignite/cache/store/CacheStoreSession.java | 22 + .../cache/store/CacheStoreSessionListener.java | 133 + .../jdbc/CacheJdbcStoreSessionListener.java | 141 + .../org/apache/ignite/cluster/ClusterNode.java | 24 +- .../configuration/CacheConfiguration.java | 66 +- .../configuration/IgniteConfiguration.java | 48 +- .../org/apache/ignite/igfs/IgfsUserContext.java | 119 + .../igfs/secondary/IgfsSecondaryFileSystem.java | 7 + .../ignite/internal/ClusterMetricsSnapshot.java | 14 + .../internal/GridEventConsumeHandler.java | 100 +- .../ignite/internal/GridKernalContext.java | 5 + .../ignite/internal/GridKernalContextImpl.java | 5 + .../apache/ignite/internal/IgniteKernal.java | 56 +- .../ignite/internal/IgniteNodeAttributes.java | 5 +- .../org/apache/ignite/internal/IgnitionEx.java | 30 +- .../internal/MarshallerContextAdapter.java | 36 +- .../ignite/internal/MarshallerContextImpl.java | 2 +- .../internal/events/DiscoveryCustomEvent.java | 18 +- .../internal/igfs/common/IgfsMarshaller.java | 35 +- .../igfs/common/IgfsPathControlRequest.java | 22 + .../internal/managers/GridManagerAdapter.java | 68 +- .../checkpoint/GridCheckpointManager.java | 52 +- .../managers/communication/GridIoManager.java | 129 +- .../managers/discovery/CustomEventListener.java | 31 + .../discovery/CustomMessageWrapper.java | 63 + .../discovery/DiscoveryCustomMessage.java | 54 + .../discovery/GridDiscoveryManager.java | 278 +- .../managers/indexing/GridIndexingManager.java | 4 - .../affinity/GridAffinityAssignment.java | 12 + .../affinity/GridAffinityAssignmentCache.java | 32 + .../affinity/GridAffinityProcessor.java | 23 +- .../cache/CacheEvictableEntryImpl.java | 31 + .../processors/cache/CacheMetricsImpl.java | 367 +- .../cache/CacheMetricsMXBeanImpl.java | 100 + .../processors/cache/CacheMetricsSnapshot.java | 380 +- .../cache/DynamicCacheChangeBatch.java | 29 +- .../cache/DynamicCacheDescriptor.java | 19 + .../processors/cache/GridCacheAdapter.java | 50 +- .../cache/GridCacheAffinityManager.java | 14 + .../cache/GridCacheConcurrentMap.java | 21 +- .../processors/cache/GridCacheContext.java | 22 +- .../processors/cache/GridCacheEntryEx.java | 6 + .../processors/cache/GridCacheGateway.java | 2 +- .../processors/cache/GridCacheIoManager.java | 8 +- .../processors/cache/GridCacheMapEntry.java | 69 +- .../processors/cache/GridCacheMvccManager.java | 32 +- .../GridCachePartitionExchangeManager.java | 97 +- .../processors/cache/GridCachePreloader.java | 6 +- .../cache/GridCachePreloaderAdapter.java | 11 +- .../processors/cache/GridCacheProcessor.java | 121 +- .../processors/cache/GridCacheProxyImpl.java | 26 +- .../cache/GridCacheSharedContext.java | 48 +- .../processors/cache/GridCacheSwapManager.java | 118 +- .../processors/cache/GridCacheTtlManager.java | 9 +- .../processors/cache/GridCacheUtils.java | 288 +- .../processors/cache/IgniteCacheProxy.java | 23 + .../processors/cache/IgniteInternalCache.java | 16 +- .../cache/affinity/GridCacheAffinityImpl.java | 10 +- .../CacheDataStructuresManager.java | 2 +- .../distributed/GridDistributedCacheEntry.java | 7 - .../distributed/GridDistributedTxMapping.java | 17 + .../dht/GridClientPartitionTopology.java | 10 +- .../dht/GridDhtAssignmentFetchFuture.java | 4 +- .../distributed/dht/GridDhtCacheAdapter.java | 27 +- .../distributed/dht/GridDhtCacheEntry.java | 6 +- .../cache/distributed/dht/GridDhtGetFuture.java | 11 +- .../distributed/dht/GridDhtLockFuture.java | 10 +- .../dht/GridDhtPartitionTopologyImpl.java | 38 +- .../dht/GridDhtTransactionalCacheAdapter.java | 224 +- .../distributed/dht/GridDhtTxLocalAdapter.java | 8 +- .../distributed/dht/GridDhtTxPrepareFuture.java | 3 +- .../dht/atomic/GridDhtAtomicCache.java | 53 +- .../dht/atomic/GridDhtAtomicUpdateFuture.java | 10 +- .../dht/atomic/GridNearAtomicUpdateFuture.java | 84 +- .../dht/atomic/GridNearAtomicUpdateRequest.java | 112 +- .../dht/colocated/GridDhtColocatedCache.java | 12 +- .../colocated/GridDhtColocatedLockFuture.java | 213 +- .../dht/preloader/GridDhtForceKeysFuture.java | 44 +- .../preloader/GridDhtPartitionDemandPool.java | 26 +- .../dht/preloader/GridDhtPartitionMap.java | 2 +- .../preloader/GridDhtPartitionSupplyPool.java | 29 +- .../GridDhtPartitionsExchangeFuture.java | 442 +- .../preloader/GridDhtPartitionsFullMessage.java | 4 +- .../GridDhtPartitionsSingleMessage.java | 33 +- .../dht/preloader/GridDhtPreloader.java | 39 +- .../preloader/GridDhtPreloaderAssignments.java | 3 +- .../distributed/near/GridNearAtomicCache.java | 5 + .../distributed/near/GridNearCacheAdapter.java | 2 +- .../distributed/near/GridNearGetFuture.java | 2 +- .../distributed/near/GridNearLockFuture.java | 271 +- .../distributed/near/GridNearLockRequest.java | 68 +- .../distributed/near/GridNearLockResponse.java | 48 +- .../near/GridNearOptimisticTxPrepareFuture.java | 83 +- .../GridNearPessimisticTxPrepareFuture.java | 5 +- .../near/GridNearTransactionalCache.java | 4 +- .../cache/distributed/near/GridNearTxLocal.java | 43 +- .../near/GridNearTxPrepareRequest.java | 72 +- .../near/GridNearTxPrepareResponse.java | 70 +- .../processors/cache/local/GridLocalCache.java | 6 +- .../local/atomic/GridLocalAtomicCache.java | 31 +- .../cache/query/GridCacheQueryAdapter.java | 24 +- .../cache/query/GridCacheQueryErrorFuture.java | 2 + .../cache/query/GridCacheQueryManager.java | 2 +- .../continuous/CacheContinuousQueryManager.java | 28 +- .../cache/store/CacheOsStoreManager.java | 1 - .../cache/store/CacheStoreManager.java | 7 +- .../store/GridCacheStoreManagerAdapter.java | 202 +- .../cache/transactions/IgniteInternalTx.java | 5 + .../cache/transactions/IgniteTxAdapter.java | 48 +- .../cache/transactions/IgniteTxHandler.java | 148 +- .../transactions/IgniteTxLocalAdapter.java | 170 +- .../cache/transactions/IgniteTxManager.java | 3 - .../cacheobject/IgniteCacheObjectProcessor.java | 5 +- .../IgniteCacheObjectProcessorImpl.java | 2 +- .../continuous/AbstractContinuousMessage.java | 63 + .../continuous/GridContinuousMessageType.java | 12 - .../continuous/GridContinuousProcessor.java | 838 +-- .../processors/continuous/StartRequestData.java | 267 + .../StartRoutineAckDiscoveryMessage.java | 63 + .../StartRoutineDiscoveryMessage.java | 85 + .../StopRoutineAckDiscoveryMessage.java | 49 + .../continuous/StopRoutineDiscoveryMessage.java | 49 + .../datastreamer/DataStreamerImpl.java | 94 +- .../datastructures/DataStructuresProcessor.java | 107 +- .../internal/processors/hadoop/HadoopJob.java | 2 +- .../processors/hadoop/HadoopTaskContext.java | 14 +- .../ignite/internal/processors/igfs/IgfsEx.java | 8 +- .../internal/processors/igfs/IgfsImpl.java | 8 +- .../processors/igfs/IgfsIpcHandler.java | 184 +- .../processors/igfs/IgfsMetaManager.java | 2 +- .../igfs/IgfsSecondaryFileSystemImpl.java | 9 +- .../internal/processors/igfs/IgfsServer.java | 4 +- .../internal/processors/igfs/IgfsUtils.java | 16 + .../processors/query/GridQueryProcessor.java | 305 +- .../service/GridServiceProcessor.java | 125 +- .../timeout/GridSpiTimeoutObject.java | 73 + .../timeout/GridTimeoutProcessor.java | 105 +- .../IgniteTxRollbackCheckedException.java | 9 + .../ignite/internal/util/GridJavaProcess.java | 30 +- .../internal/util/future/GridFutureAdapter.java | 4 +- .../util/nio/GridCommunicationClient.java | 30 +- .../util/nio/GridNioDelimitedBuffer.java | 2 +- .../util/nio/GridNioRecoveryDescriptor.java | 13 +- .../util/nio/GridTcpCommunicationClient.java | 554 -- .../util/nio/GridTcpNioCommunicationClient.java | 8 - .../ignite/internal/visor/cache/VisorCache.java | 2 +- .../VisorCacheConfigurationCollectorJob.java | 6 +- .../internal/visor/cache/VisorCacheMetrics.java | 19 +- .../cache/VisorCacheMetricsCollectorTask.java | 10 +- .../cache/VisorCacheStoreConfiguration.java | 5 +- .../visor/node/VisorNodeDataCollectorTask.java | 9 +- .../node/VisorNodeDataCollectorTaskResult.java | 17 +- .../node/VisorNodeSuppressedErrorsTask.java | 12 +- .../internal/visor/query/VisorQueryJob.java | 13 +- .../internal/visor/query/VisorQueryTask.java | 3 +- .../visor/util/VisorExceptionWrapper.java | 81 + .../internal/visor/util/VisorTaskUtils.java | 10 + .../ignite/mxbean/CacheMetricsMXBean.java | 80 + .../apache/ignite/plugin/PluginProvider.java | 26 +- .../org/apache/ignite/spi/IgniteSpiAdapter.java | 70 +- .../org/apache/ignite/spi/IgniteSpiContext.java | 57 +- .../ignite/spi/IgniteSpiTimeoutObject.java | 44 + .../spi/checkpoint/noop/NoopCheckpointSpi.java | 3 +- .../communication/tcp/TcpCommunicationSpi.java | 438 +- .../tcp/TcpCommunicationSpiMBean.java | 2 - .../ignite/spi/discovery/DiscoverySpi.java | 20 +- .../discovery/DiscoverySpiCustomMessage.java | 40 + .../spi/discovery/DiscoverySpiListener.java | 5 +- .../ignite/spi/discovery/tcp/ClientImpl.java | 1478 +++++ .../ignite/spi/discovery/tcp/ServerImpl.java | 4733 ++++++++++++++ .../discovery/tcp/TcpClientDiscoverySpi.java | 1264 ---- .../tcp/TcpClientDiscoverySpiMBean.java | 164 - .../spi/discovery/tcp/TcpDiscoveryImpl.java | 212 + .../spi/discovery/tcp/TcpDiscoverySpi.java | 5771 ++++-------------- .../discovery/tcp/TcpDiscoverySpiAdapter.java | 1160 ---- .../spi/discovery/tcp/TcpDiscoverySpiMBean.java | 9 + .../tcp/internal/TcpDiscoveryNode.java | 7 +- .../tcp/internal/TcpDiscoveryNodesRing.java | 2 +- .../tcp/ipfinder/TcpDiscoveryIpFinder.java | 10 +- .../TcpDiscoveryMulticastIpFinder.java | 57 +- .../messages/TcpDiscoveryAbstractMessage.java | 24 +- .../TcpDiscoveryClientHeartbeatMessage.java | 67 + .../messages/TcpDiscoveryClientPingRequest.java | 56 + .../TcpDiscoveryClientPingResponse.java | 67 + .../TcpDiscoveryCustomEventMessage.java | 41 +- .../messages/TcpDiscoveryHeartbeatMessage.java | 28 +- .../TcpDiscoveryNodeAddFinishedMessage.java | 43 + .../messages/TcpDiscoveryNodeAddedMessage.java | 2 +- .../tcp/messages/TcpDiscoveryPingRequest.java | 6 + .../tcp/messages/TcpDiscoveryPingResponse.java | 15 +- .../spi/swapspace/file/FileSwapSpaceSpi.java | 8 +- .../affinity/IgniteClientNodeAffinityTest.java | 182 + ...cheStoreSessionListenerAbstractSelfTest.java | 315 + ...heStoreSessionListenerLifecycleSelfTest.java | 395 ++ .../CacheJdbcStoreSessionListenerSelfTest.java | 175 + .../ignite/internal/GridAffinitySelfTest.java | 1 + .../internal/GridDiscoveryEventSelfTest.java | 7 +- ...ridFailFastNodeFailureDetectionSelfTest.java | 7 +- .../internal/GridProjectionAbstractTest.java | 16 + .../GridProjectionForCachesSelfTest.java | 11 +- .../internal/GridReleaseTypeSelfTest.java | 77 +- .../apache/ignite/internal/GridSelfTest.java | 4 +- .../GridDiscoveryManagerAliveCacheSelfTest.java | 62 +- .../GridDiscoveryManagerAttributesSelfTest.java | 122 +- .../discovery/GridDiscoveryManagerSelfTest.java | 46 +- .../GridAffinityProcessorAbstractSelfTest.java | 1 + ...acheReadOnlyTransactionalClientSelfTest.java | 327 + .../cache/CacheRemoveAllSelfTest.java | 2 +- .../GridCacheAbstractFailoverSelfTest.java | 2 +- .../cache/GridCacheAbstractFullApiSelfTest.java | 113 + .../cache/GridCacheAbstractMetricsSelfTest.java | 48 +- .../GridCacheAbstractRemoveFailureTest.java | 23 + .../cache/GridCacheAbstractSelfTest.java | 2 +- .../GridCacheAtomicMessageCountSelfTest.java | 1 + .../GridCacheConcurrentTxMultiNodeTest.java | 8 +- ...idCacheConfigurationConsistencySelfTest.java | 14 +- .../GridCacheExAbstractFullApiSelfTest.java | 103 - .../cache/GridCacheMemoryModeSelfTest.java | 23 +- ...GridCacheMixedPartitionExchangeSelfTest.java | 2 +- .../processors/cache/GridCacheOffHeapTest.java | 5 +- .../cache/GridCachePutAllFailoverSelfTest.java | 1 + .../cache/GridCacheReloadSelfTest.java | 6 +- .../GridCacheReturnValueTransferSelfTest.java | 3 + ...acheTcpClientDiscoveryMultiThreadedTest.java | 190 + .../processors/cache/GridCacheTestEntryEx.java | 4 + .../GridCacheVariableTopologySelfTest.java | 12 +- .../IgniteCacheAbstractStopBusySelfTest.java | 6 +- .../cache/IgniteCacheAbstractTest.java | 2 +- .../IgniteCacheConfigurationTemplateTest.java | 2 +- .../cache/IgniteCacheNearLockValueSelfTest.java | 3 + .../IgniteCacheP2pUnmarshallingErrorTest.java | 29 +- ...gniteCacheP2pUnmarshallingNearErrorTest.java | 13 +- .../IgniteCachePartitionMapUpdateTest.java | 226 + .../cache/IgniteCachePeekModesAbstractTest.java | 5 +- .../cache/IgniteDynamicCacheStartSelfTest.java | 62 + ...niteDynamicCacheWithConfigStartSelfTest.java | 97 + .../IgniteDynamicClientCacheStartSelfTest.java | 283 + .../cache/IgniteSystemCacheOnClientTest.java | 97 + .../GridCacheQueueApiSelfAbstractTest.java | 4 +- .../IgniteClientDataStructuresAbstractTest.java | 283 + .../IgniteClientDataStructuresTest.java | 28 + ...IgniteClientDiscoveryDataStructuresTest.java | 28 + .../IgniteCountDownLatchAbstractSelfTest.java | 102 + .../GridCacheClientModesAbstractSelfTest.java | 94 +- ...ientModesTcpClientDiscoveryAbstractTest.java | 168 + .../distributed/GridCacheMixedModeSelfTest.java | 3 + ...niteCacheClientNodeChangingTopologyTest.java | 1803 ++++++ .../IgniteCacheClientNodeConcurrentStart.java | 105 + ...teCacheClientNodePartitionsExchangeTest.java | 632 ++ .../IgniteCrossCacheTxStoreSelfTest.java | 147 +- .../dht/GridCacheClientOnlySelfTest.java | 60 +- .../GridCacheDhtClientRemoveFailureTest.java | 28 + ...GridCacheDhtEvictionNearReadersSelfTest.java | 11 +- .../dht/GridCacheDhtEvictionSelfTest.java | 11 +- .../GridCacheExColocatedFullApiSelfTest.java | 33 - .../dht/IgniteCacheMultiTxLockSelfTest.java | 53 +- ...cClientInvalidPartitionHandlingSelfTest.java | 29 + .../GridCacheAtomicClientRemoveFailureTest.java | 28 + ...eAtomicInvalidPartitionHandlingSelfTest.java | 23 +- ...unctionExcludeNeighborsAbstractSelfTest.java | 3 +- .../near/GridCacheAtomicNearOnlySelfTest.java | 32 - .../near/GridCacheExNearFullApiSelfTest.java | 39 - ...idCacheNearOnlyMultiNodeFullApiSelfTest.java | 2 + .../near/GridCacheNearOnlySelfTest.java | 63 +- .../near/GridCacheNearOnlyTopologySelfTest.java | 1 + ...ionedClientOnlyNoPrimaryFullApiSelfTest.java | 5 +- .../GridCachePartitionedEvictionSelfTest.java | 11 +- .../GridCachePartitionedFullApiSelfTest.java | 32 + ...ePartitionedMultiThreadedPutGetSelfTest.java | 6 +- ...edOffHeapTieredMultiNodeFullApiSelfTest.java | 2 +- ...idCacheRendezvousAffinityClientSelfTest.java | 4 + .../GridCacheExReplicatedFullApiSelfTest.java | 33 - .../GridCacheReplicatedClientOnlySelfTest.java | 43 - .../GridCacheReplicatedNearOnlySelfTest.java | 43 - .../GridCacheSyncReplicatedPreloadSelfTest.java | 1 - .../cache/eviction/EvictionAbstractTest.java | 1056 ++++ .../GridCacheBatchEvictUnswapSelfTest.java | 5 +- ...heConcurrentEvictionConsistencySelfTest.java | 82 +- .../GridCacheConcurrentEvictionsSelfTest.java | 29 +- .../GridCacheDistributedEvictionsSelfTest.java | 5 +- .../GridCacheEmptyEntriesAbstractSelfTest.java | 11 +- .../eviction/GridCacheEvictionAbstractTest.java | 484 -- .../GridCacheEvictionTouchSelfTest.java | 22 +- .../cache/eviction/GridCacheMockEntry.java | 5 + .../fifo/FifoEvictionPolicySelfTest.java | 262 + ...ridCacheFifoBatchEvictionPolicySelfTest.java | 384 -- .../GridCacheFifoEvictionPolicySelfTest.java | 372 -- .../lru/GridCacheLruEvictionPolicySelfTest.java | 417 -- .../GridCacheLruNearEvictionPolicySelfTest.java | 136 - ...heNearOnlyLruNearEvictionPolicySelfTest.java | 171 - .../eviction/lru/LruEvictionPolicySelfTest.java | 353 ++ .../lru/LruNearEvictionPolicySelfTest.java | 140 + .../LruNearOnlyNearEvictionPolicySelfTest.java | 172 + .../GridCacheRandomEvictionPolicySelfTest.java | 258 - .../RandomEvictionPolicyCacheSizeSelfTest.java | 6 + .../random/RandomEvictionPolicySelfTest.java | 357 ++ ...dCacheSortedBatchEvictionPolicySelfTest.java | 385 -- ...acheSortedEvictionPolicyPerformanceTest.java | 135 - .../GridCacheSortedEvictionPolicySelfTest.java | 373 -- .../SortedEvictionPolicyPerformanceTest.java | 134 + .../sorted/SortedEvictionPolicySelfTest.java | 266 + .../IgniteCacheClientNearCacheExpiryTest.java | 103 + .../IgniteCacheExpiryPolicyTestSuite.java | 2 + ...CacheLocalOffHeapAndSwapMetricsSelfTest.java | 412 ++ .../local/GridCacheExLocalFullApiSelfTest.java | 30 - ...ridCacheContinuousQueryAbstractSelfTest.java | 6 +- .../continuous/GridEventConsumeSelfTest.java | 96 +- .../DataStreamProcessorSelfTest.java | 1 + .../DataStreamerMultiThreadedSelfTest.java | 59 +- .../DataStreamerMultinodeCreateCacheTest.java | 97 + .../igfs/IgfsClientCacheSelfTest.java | 12 +- .../processors/igfs/IgfsCommonAbstractTest.java | 10 - .../processors/igfs/IgfsOneClientNodeTest.java | 8 +- .../service/ClosureServiceClientsNodesTest.java | 16 +- .../service/GridServiceClientNodeTest.java | 81 + .../nio/GridNioDelimitedBufferSelfTest.java | 112 + .../internal/util/nio/GridNioSelfTest.java | 2 +- .../loadtests/GridCacheMultiNodeLoadTest.java | 5 +- .../GridCachePartitionedAtomicLongLoadTest.java | 6 +- .../loadtests/hashmap/GridCacheTestContext.java | 4 +- .../swap/GridSwapEvictAllBenchmark.java | 6 +- .../OptimizedMarshallerNodeFailoverTest.java | 4 +- ...GridMessagingNoPeerClassLoadingSelfTest.java | 7 +- .../ignite/messaging/GridMessagingSelfTest.java | 13 +- .../IgniteMessagingWithClientTest.java | 166 + .../GridTcpCommunicationSpiAbstractTest.java | 4 +- ...mmunicationSpiConcurrentConnectSelfTest.java | 2 +- .../GridTcpCommunicationSpiConfigSelfTest.java | 2 - ...cpCommunicationSpiMultithreadedSelfTest.java | 2 +- .../discovery/AbstractDiscoverySelfTest.java | 21 +- ...pClientDiscoveryMarshallerCheckSelfTest.java | 76 + .../tcp/TcpClientDiscoverySelfTest.java | 700 --- .../tcp/TcpClientDiscoverySpiMulticastTest.java | 129 + .../tcp/TcpClientDiscoverySpiSelfTest.java | 1196 ++++ .../tcp/TcpDiscoveryConcurrentStartTest.java | 61 +- .../tcp/TcpDiscoveryMultiThreadedTest.java | 18 +- .../spi/discovery/tcp/TcpDiscoverySelfTest.java | 2 +- .../stream/socket/SocketStreamerSelfTest.java | 29 +- .../testframework/GridSpiTestContext.java | 35 +- .../ignite/testframework/GridTestUtils.java | 15 + .../testframework/junits/GridAbstractTest.java | 52 +- .../junits/cache/TestCacheSession.java | 18 + .../cache/TestThreadLocalCacheSession.java | 15 + .../junits/common/GridCommonAbstractTest.java | 83 +- .../ignite/testsuites/IgniteBasicTestSuite.java | 4 +- .../IgniteCacheDataStructuresSelfTestSuite.java | 3 + .../IgniteCacheEvictionSelfTestSuite.java | 14 +- .../IgniteCacheFailoverTestSuite.java | 4 +- .../IgniteCacheFullApiSelfTestSuite.java | 6 - .../IgniteCacheMetricsSelfTestSuite.java | 1 + .../IgniteCacheNearOnlySelfTestSuite.java | 16 +- ...niteCacheP2pUnmarshallingErrorTestSuite.java | 41 + .../IgniteCacheTcpClientDiscoveryTestSuite.java | 47 + .../ignite/testsuites/IgniteCacheTestSuite.java | 5 + .../testsuites/IgniteCacheTestSuite2.java | 11 +- .../testsuites/IgniteCacheTestSuite4.java | 8 + .../testsuites/IgniteKernalSelfTestSuite.java | 7 +- .../IgniteSpiDiscoverySelfTestSuite.java | 4 +- .../testsuites/IgniteStreamSelfTestSuite.java | 39 + .../testsuites/IgniteUtilSelfTestSuite.java | 2 +- .../gce/TcpDiscoveryGoogleStorageIpFinder.java | 43 +- .../fs/IgniteHadoopFileSystemCounterWriter.java | 14 +- .../fs/IgniteHadoopIgfsSecondaryFileSystem.java | 165 +- .../hadoop/fs/v1/IgniteHadoopFileSystem.java | 137 +- .../hadoop/fs/v2/IgniteHadoopFileSystem.java | 32 +- .../processors/hadoop/HadoopDefaultJobInfo.java | 2 +- .../internal/processors/hadoop/HadoopUtils.java | 288 +- .../hadoop/SecondaryFileSystemProvider.java | 57 +- .../hadoop/fs/HadoopDistributedFileSystem.java | 91 - .../hadoop/fs/HadoopFileSystemsUtils.java | 17 - .../hadoop/fs/HadoopLazyConcurrentMap.java | 204 + .../processors/hadoop/igfs/HadoopIgfsEx.java | 6 + .../hadoop/igfs/HadoopIgfsInProc.java | 170 +- .../processors/hadoop/igfs/HadoopIgfsIpcIo.java | 2 +- .../hadoop/igfs/HadoopIgfsOutProc.java | 33 +- .../hadoop/igfs/HadoopIgfsWrapper.java | 19 +- .../hadoop/taskexecutor/HadoopRunnableTask.java | 20 +- .../processors/hadoop/v2/HadoopV2Job.java | 31 +- .../hadoop/v2/HadoopV2JobResourceManager.java | 26 +- .../hadoop/v2/HadoopV2TaskContext.java | 52 +- .../hadoop/HadoopClientProtocolSelfTest.java | 6 +- .../HadoopIgfs20FileSystemAbstractSelfTest.java | 56 +- ...oopSecondaryFileSystemConfigurationTest.java | 4 +- .../igfs/IgfsNearOnlyMultiNodeSelfTest.java | 5 +- .../IgniteHadoopFileSystemAbstractSelfTest.java | 63 +- .../IgniteHadoopFileSystemClientSelfTest.java | 2 +- .../IgniteHadoopFileSystemIpcCacheSelfTest.java | 2 + .../hadoop/HadoopAbstractSelfTest.java | 14 +- .../hadoop/HadoopCommandLineTest.java | 14 +- .../hadoop/HadoopFileSystemsTest.java | 23 +- .../processors/hadoop/HadoopMapReduceTest.java | 183 +- .../hadoop/HadoopTaskExecutionSelfTest.java | 2 +- .../hadoop/HadoopTasksAllVersionsTest.java | 15 +- .../processors/hadoop/HadoopTasksV1Test.java | 5 +- .../processors/hadoop/HadoopTasksV2Test.java | 5 +- .../processors/hadoop/HadoopV2JobSelfTest.java | 6 +- .../collections/HadoopAbstractMapTest.java | 12 + .../collections/HadoopSkipListSelfTest.java | 4 +- .../CacheHibernateStoreSessionListener.java | 216 + ...heHibernateStoreSessionListenerSelfTest.java | 228 + .../testsuites/IgniteHibernateTestSuite.java | 2 + .../GridCacheOffheapIndexEntryEvictTest.java | 200 + .../cache/GridCacheOffheapIndexGetSelfTest.java | 80 +- .../cache/GridCacheQueryMetricsSelfTest.java | 84 +- .../cache/GridIndexingWithNoopSwapSelfTest.java | 6 +- .../cache/IgniteCacheAbstractQuerySelfTest.java | 6 +- ...acheConfigurationPrimitiveTypesSelfTest.java | 104 + ...niteCacheP2pUnmarshallingQueryErrorTest.java | 3 +- ...QueryMultiThreadedOffHeapTieredSelfTest.java | 37 + .../IgniteCacheQueryMultiThreadedSelfTest.java | 11 +- .../cache/ttl/CacheTtlAbstractSelfTest.java | 6 +- .../IgniteCacheQuerySelfTestSuite.java | 4 +- .../IgniteCacheWithIndexingTestSuite.java | 3 + modules/mesos/pom.xml | 8 +- modules/spring/pom.xml | 14 + .../spring/CacheSpringStoreSessionListener.java | 207 + ...CacheSpringStoreSessionListenerSelfTest.java | 197 + .../testsuites/IgniteSpringTestSuite.java | 3 + .../commands/cache/VisorCacheScanCommand.scala | 2 +- scripts/git-apply-patch.sh | 8 +- scripts/git-format-patch.sh | 16 +- scripts/git-patch-functions.sh | 36 +- 445 files changed, 30917 insertions(+), 16660 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1652fd18/DEVNOTES.txt ---------------------------------------------------------------------- diff --git a/DEVNOTES.txt b/DEVNOTES.txt index 8f1730c..cd72418 100644 --- a/DEVNOTES.txt +++ b/DEVNOTES.txt @@ -24,12 +24,14 @@ NOTE: JDK version should be 1.7.0-* or >= 1.8.0-u40. Ignite Release Instructions =========================== -Use people.apache.org/keys/committer/<username>.asc key to generate KEYS file. -Execute these commands at source root: +Use your people.apache.org/keys/committer/<username>.asc key to generate KEYS file. +Download https://dist.apache.org/repos/dist/release/incubator/ignite/KEYS and append you key using commands: gpg --list-sigs <keyname> >> KEYS gpg --armor --export <keyname> >> KEYS +Upload modified KEYS file. + Specify gpg profile at settings.xml. It will be used to sign sources and artifacts. <profile> @@ -43,24 +45,38 @@ Specify gpg profile at settings.xml. It will be used to sign sources and artifac Ensure you have RELEASE (not SNAPSHOT) version at Ignite poms. Maven release plugin release:prepare goal can be used to make release tag. -Deploy Ignite release candidate to maven repository and dev-svn: +Deploy Ignite release candidate to maven repository and dev-svn, make tag: + + Following command deploys Ignite to maven repository, prepares sources and fabric edition binaries. + mvn deploy -P apache-release,gpg,release,scala,lgpl,deploy-ignite-site -Dignite.edition=fabric -DskipTests -B + + In case you want to release both fabric and hadoop editions you have to build hadoop edition first using command + mvn package -P apache-release,gpg,release,scala,lgpl -Dignite.edition=hadoop -DskipTests -B + save /target/bin/*.zip, make "mvn clean" and restore saved files before deploying fabric. - mvn deploy -P apache-release,gpg,release,scala,lgpl,deploy-ignite-site -Dignite.edition=fabric -DskipTests -B + Binary artifact name can be changed by setting additional property -Dignite.zip.pattern. Binary artifact will be + created inside /target/bin folder when release profile is used. - Binary artifact name can be changed by setting additional property -Dignite.zip.pattern. - Sources package name is fixed. Sources package zip will be created automatically when apache-release profile used. + Sources artifact name is fixed. Sources artifact will be created inside /target dir when apache-release profile is used. - In case you want to release both fabric and hadoop editions you have to build hadoop first, save /target/bin/*.zip, - make "mvn clean" and restore them before deploy step. + Nexus staging (repository.apache.org) should be closed with appropriate comment contains release version and + release candidate number, for example "Apache Ignite 1.0.0-rc7", when mvn deploy finished. - Nexus staging (repository.apache.org) should be closed when mvn deploy finished. - Checkout https://dist.apache.org/repos/dist/dev/incubator/ignite svn. Create new folder with name equals to released - version at svn root. Copy target/site folder content to svn/ignite/<version> folder and commit. + Checkout https://dist.apache.org/repos/dist/dev/incubator/ignite svn. Create release candidate folder with name + equals to release version with "-rc*" ending, for example "1.0.0-rc7", at svn root. + Copy /target/site folder content to svn/ignite/<rc-version> folder and commit with appropriate comment. -Start vote based on https://dist.apache.org/repos/dist/dev/incubator/ignite/<version>. + Make appropriate git tag for release candidate, for example "ignite-1.0.0-incubating-rc7". -Release nexus staging and copy binaries and sources from https://dist.apache.org/repos/dist/dev/incubator/ignite/<version> +Start vote based on https://dist.apache.org/repos/dist/dev/incubator/ignite/<rc-version>. + +Release nexus staging, move binaries and sources from https://dist.apache.org/repos/dist/dev/incubator/ignite/<rc-version> to https://dist.apache.org/repos/dist/release/incubator/ignite/<version> when version accepted. +Use svn mv ^/dev/incubator/ignite/<rc-version> ^/release/incubator/ignite/<version> command for proper moving. + +Make appropriate git tag for released version, for example "ignite-1.0.0-incubating". + +Send an email to d...@ignite.incubator.apache.org contains release svn url. JCache TCK compliance http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1652fd18/assembly/dependencies-visor-console.xml ---------------------------------------------------------------------- diff --git a/assembly/dependencies-visor-console.xml b/assembly/dependencies-visor-console.xml index 28151da..d773769 100644 --- a/assembly/dependencies-visor-console.xml +++ b/assembly/dependencies-visor-console.xml @@ -90,6 +90,9 @@ <fileSet> <directory>target/libs</directory> <outputDirectory>/visor-common</outputDirectory> + <excludes> + <exclude>spring-jdbc-*.jar</exclude> + </excludes> </fileSet> <fileSet> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1652fd18/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java index 577301c..80a9f22 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java @@ -21,10 +21,7 @@ import org.apache.ignite.cache.store.*; import org.apache.ignite.examples.datagrid.store.*; import org.apache.ignite.lang.*; import org.apache.ignite.resources.*; -import org.apache.ignite.transactions.Transaction; import org.hibernate.*; -import org.hibernate.cfg.*; -import org.jetbrains.annotations.*; import javax.cache.integration.*; import java.util.*; @@ -34,99 +31,55 @@ import java.util.*; * and deals with maps {@link UUID} to {@link Person}. */ public class CacheHibernatePersonStore extends CacheStoreAdapter<Long, Person> { - /** Default hibernate configuration resource path. */ - private static final String DFLT_HIBERNATE_CFG = "/org/apache/ignite/examples/datagrid/store/hibernate" + - "/hibernate.cfg.xml"; - - /** Session attribute name. */ - private static final String ATTR_SES = "HIBERNATE_STORE_SESSION"; - - /** Session factory. */ - private SessionFactory sesFactory; - /** Auto-injected store session. */ @CacheStoreSessionResource private CacheStoreSession ses; - /** - * Default constructor. - */ - public CacheHibernatePersonStore() { - sesFactory = new Configuration().configure(DFLT_HIBERNATE_CFG).buildSessionFactory(); - } - /** {@inheritDoc} */ @Override public Person load(Long key) { - Transaction tx = transaction(); - - System.out.println(">>> Store load [key=" + key + ", xid=" + (tx == null ? null : tx.xid()) + ']'); + System.out.println(">>> Store load [key=" + key + ']'); - Session ses = session(tx); + Session hibSes = ses.attachment(); try { - return (Person) ses.get(Person.class, key); + return (Person)hibSes.get(Person.class, key); } catch (HibernateException e) { - rollback(ses, tx); - - throw new CacheLoaderException("Failed to load value from cache store with key: " + key, e); - } - finally { - end(ses, tx); + throw new CacheLoaderException("Failed to load value from cache store [key=" + key + ']', e); } } /** {@inheritDoc} */ @Override public void write(javax.cache.Cache.Entry<? extends Long, ? extends Person> entry) { - Transaction tx = transaction(); - Long key = entry.getKey(); - Person val = entry.getValue(); - System.out.println(">>> Store put [key=" + key + ", val=" + val + ", xid=" + (tx == null ? null : tx.xid()) + ']'); + System.out.println(">>> Store write [key=" + key + ", val=" + val + ']'); - if (val == null) { - delete(key); - - return; - } - - Session ses = session(tx); + Session hibSes = ses.attachment(); try { - ses.saveOrUpdate(val); + hibSes.saveOrUpdate(val); } catch (HibernateException e) { - rollback(ses, tx); - throw new CacheWriterException("Failed to put value to cache store [key=" + key + ", val" + val + "]", e); } - finally { - end(ses, tx); - } } /** {@inheritDoc} */ @SuppressWarnings({"JpaQueryApiInspection"}) @Override public void delete(Object key) { - Transaction tx = transaction(); + System.out.println(">>> Store delete [key=" + key + ']'); - System.out.println(">>> Store remove [key=" + key + ", xid=" + (tx == null ? null : tx.xid()) + ']'); - - Session ses = session(tx); + Session hibSes = ses.attachment(); try { - ses.createQuery("delete " + Person.class.getSimpleName() + " where key = :key") - .setParameter("key", key).setFlushMode(FlushMode.ALWAYS).executeUpdate(); + hibSes.createQuery("delete " + Person.class.getSimpleName() + " where key = :key"). + setParameter("key", key). + executeUpdate(); } catch (HibernateException e) { - rollback(ses, tx); - - throw new CacheWriterException("Failed to remove value from cache store with key: " + key, e); - } - finally { - end(ses, tx); + throw new CacheWriterException("Failed to remove value from cache store [key=" + key + ']', e); } } @@ -137,18 +90,18 @@ public class CacheHibernatePersonStore extends CacheStoreAdapter<Long, Person> { final int entryCnt = (Integer)args[0]; - Session ses = session(null); + Session hibSes = ses.attachment(); try { int cnt = 0; - List res = ses.createCriteria(Person.class).list(); - - if (res != null) { - Iterator iter = res.iterator(); + List list = hibSes.createCriteria(Person.class). + setMaxResults(entryCnt). + list(); - while (cnt < entryCnt && iter.hasNext()) { - Person person = (Person)iter.next(); + if (list != null) { + for (Object obj : list) { + Person person = (Person)obj; clo.apply(person.getId(), person); @@ -161,120 +114,5 @@ public class CacheHibernatePersonStore extends CacheStoreAdapter<Long, Person> { catch (HibernateException e) { throw new CacheLoaderException("Failed to load values from cache store.", e); } - finally { - end(ses, null); - } - } - - /** - * Rolls back hibernate session. - * - * @param ses Hibernate session. - * @param tx Cache ongoing transaction. - */ - private void rollback(Session ses, Transaction tx) { - // Rollback only if there is no cache transaction, - // otherwise sessionEnd() will do all required work. - if (tx == null) { - org.hibernate.Transaction hTx = ses.getTransaction(); - - if (hTx != null && hTx.isActive()) - hTx.rollback(); - } - } - - /** - * Ends hibernate session. - * - * @param ses Hibernate session. - * @param tx Cache ongoing transaction. - */ - private void end(Session ses, @Nullable Transaction tx) { - // Commit only if there is no cache transaction, - // otherwise sessionEnd() will do all required work. - if (tx == null) { - org.hibernate.Transaction hTx = ses.getTransaction(); - - if (hTx != null && hTx.isActive()) - hTx.commit(); - - ses.close(); - } - } - - /** {@inheritDoc} */ - @Override public void sessionEnd(boolean commit) { - Transaction tx = ses.transaction(); - - Map<String, Session> props = ses.properties(); - - Session ses = props.remove(ATTR_SES); - - if (ses != null) { - org.hibernate.Transaction hTx = ses.getTransaction(); - - if (hTx != null) { - try { - if (commit) { - ses.flush(); - - hTx.commit(); - } - else - hTx.rollback(); - - System.out.println("Transaction ended [xid=" + tx.xid() + ", commit=" + commit + ']'); - } - catch (HibernateException e) { - throw new CacheWriterException("Failed to end transaction [xid=" + tx.xid() + - ", commit=" + commit + ']', e); - } - finally { - ses.close(); - } - } - } - } - - /** - * Gets Hibernate session. - * - * @param tx Cache transaction. - * @return Session. - */ - private Session session(@Nullable Transaction tx) { - Session hbSes; - - if (tx != null) { - Map<String, Session> props = ses.properties(); - - hbSes = props.get(ATTR_SES); - - if (hbSes == null) { - hbSes = sesFactory.openSession(); - - hbSes.beginTransaction(); - - // Store session in session properties, so it can be accessed - // for other operations on the same transaction. - props.put(ATTR_SES, hbSes); - - System.out.println("Hibernate session open [ses=" + hbSes + ", tx=" + tx.xid() + "]"); - } - } - else { - hbSes = sesFactory.openSession(); - - hbSes.beginTransaction(); - } - - return hbSes; - } - - /** - * @return Current transaction. - */ - @Nullable private Transaction transaction() { - return ses != null ? ses.transaction() : null; } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1652fd18/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java index 5a0cd0a..25760f0 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java @@ -18,6 +18,8 @@ package org.apache.ignite.examples.datagrid.store.hibernate; import org.apache.ignite.*; +import org.apache.ignite.cache.store.*; +import org.apache.ignite.cache.store.hibernate.*; import org.apache.ignite.configuration.*; import org.apache.ignite.examples.*; import org.apache.ignite.examples.datagrid.store.*; @@ -37,6 +39,10 @@ import static org.apache.ignite.cache.CacheAtomicityMode.*; * start node with {@code examples/config/example-ignite.xml} configuration. */ public class CacheHibernateStoreExample { + /** Hibernate configuration resource path. */ + private static final String HIBERNATE_CFG = + "/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml"; + /** Cache name. */ private static final String CACHE_NAME = CacheHibernateStoreExample.class.getSimpleName(); @@ -71,6 +77,17 @@ public class CacheHibernateStoreExample { // Configure Hibernate store. cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(CacheHibernatePersonStore.class)); + // Configure Hibernate session listener. + cacheCfg.setCacheStoreSessionListenerFactories(new Factory<CacheStoreSessionListener>() { + @Override public CacheStoreSessionListener create() { + CacheHibernateStoreSessionListener lsnr = new CacheHibernateStoreSessionListener(); + + lsnr.setHibernateConfigurationPath(HIBERNATE_CFG); + + return lsnr; + } + }); + cacheCfg.setReadThrough(true); cacheCfg.setWriteThrough(true); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1652fd18/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java index 791f861..ed14a99 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java @@ -22,23 +22,23 @@ import org.apache.ignite.cache.store.*; import org.apache.ignite.examples.datagrid.store.*; import org.apache.ignite.lang.*; import org.apache.ignite.resources.*; -import org.jetbrains.annotations.*; +import org.h2.jdbcx.*; import javax.cache.*; import javax.cache.integration.*; +import javax.sql.*; import java.sql.*; -import java.util.*; /** * Example of {@link CacheStore} implementation that uses JDBC * transaction with cache transactions and maps {@link Long} to {@link Person}. - * */ public class CacheJdbcPersonStore extends CacheStoreAdapter<Long, Person> { - /** Transaction metadata attribute name. */ - private static final String ATTR_NAME = "SIMPLE_STORE_CONNECTION"; + /** Data source. */ + public static final DataSource DATA_SRC = + JdbcConnectionPool.create("jdbc:h2:mem:example;DB_CLOSE_DELAY=-1", "", ""); - /** Auto-injected store session. */ + /** Store session. */ @CacheStoreSessionResource private CacheStoreSession ses; @@ -58,11 +58,10 @@ public class CacheJdbcPersonStore extends CacheStoreAdapter<Long, Person> { * @throws IgniteException If failed. */ private void prepareDb() throws IgniteException { - try (Connection conn = openConnection(false); Statement st = conn.createStatement()) { - st.execute("create table if not exists PERSONS (id number unique, firstName varchar(255), " + - "lastName varchar(255))"); - - conn.commit(); + try (Connection conn = DATA_SRC.getConnection()) { + conn.createStatement().execute( + "create table if not exists PERSONS (" + + "id number unique, firstName varchar(255), lastName varchar(255))"); } catch (SQLException e) { throw new IgniteException("Failed to create database table.", e); @@ -70,71 +69,39 @@ public class CacheJdbcPersonStore extends CacheStoreAdapter<Long, Person> { } /** {@inheritDoc} */ - @Override public void sessionEnd(boolean commit) { - Map<String, Connection> props = ses.properties(); - - try (Connection conn = props.remove(ATTR_NAME)) { - if (conn != null) { - if (commit) - conn.commit(); - else - conn.rollback(); - } - - System.out.println(">>> Transaction ended [commit=" + commit + ']'); - } - catch (SQLException e) { - throw new CacheWriterException("Failed to end transaction: " + ses.transaction(), e); - } - } - - /** {@inheritDoc} */ @Override public Person load(Long key) { - System.out.println(">>> Loading key: " + key); + System.out.println(">>> Store load [key=" + key + ']'); - Connection conn = null; + Connection conn = ses.attachment(); - try { - conn = connection(); - - try (PreparedStatement st = conn.prepareStatement("select * from PERSONS where id=?")) { - st.setString(1, key.toString()); + try (PreparedStatement st = conn.prepareStatement("select * from PERSONS where id = ?")) { + st.setString(1, key.toString()); - ResultSet rs = st.executeQuery(); + ResultSet rs = st.executeQuery(); - if (rs.next()) - return new Person(rs.getLong(1), rs.getString(2), rs.getString(3)); - } + return rs.next() ? new Person(rs.getLong(1), rs.getString(2), rs.getString(3)) : null; } catch (SQLException e) { - throw new CacheLoaderException("Failed to load object: " + key, e); + throw new CacheLoaderException("Failed to load object [key=" + key + ']', e); } - finally { - end(conn); - } - - return null; } /** {@inheritDoc} */ @Override public void write(Cache.Entry<? extends Long, ? extends Person> entry) { Long key = entry.getKey(); - Person val = entry.getValue(); - System.out.println(">>> Putting [key=" + key + ", val=" + val + ']'); - - Connection conn = null; + System.out.println(">>> Store write [key=" + key + ", val=" + val + ']'); try { - conn = connection(); + Connection conn = ses.attachment(); int updated; // Try update first. If it does not work, then try insert. // Some databases would allow these to be done in one 'upsert' operation. try (PreparedStatement st = conn.prepareStatement( - "update PERSONS set firstName=?, lastName=? where id=?")) { + "update PERSONS set firstName = ?, lastName = ? where id = ?")) { st.setString(1, val.getFirstName()); st.setString(2, val.getLastName()); st.setLong(3, val.getId()); @@ -145,7 +112,7 @@ public class CacheJdbcPersonStore extends CacheStoreAdapter<Long, Person> { // If update failed, try to insert. if (updated == 0) { try (PreparedStatement st = conn.prepareStatement( - "insert into PERSONS (id, firstName, lastName) values(?, ?, ?)")) { + "insert into PERSONS (id, firstName, lastName) values (?, ?, ?)")) { st.setLong(1, val.getId()); st.setString(2, val.getFirstName()); st.setString(3, val.getLastName()); @@ -155,33 +122,23 @@ public class CacheJdbcPersonStore extends CacheStoreAdapter<Long, Person> { } } catch (SQLException e) { - throw new CacheLoaderException("Failed to put object [key=" + key + ", val=" + val + ']', e); - } - finally { - end(conn); + throw new CacheWriterException("Failed to write object [key=" + key + ", val=" + val + ']', e); } } /** {@inheritDoc} */ @Override public void delete(Object key) { - System.out.println(">>> Removing key: " + key); - - Connection conn = null; + System.out.println(">>> Store delete [key=" + key + ']'); - try { - conn = connection(); + Connection conn = ses.attachment(); - try (PreparedStatement st = conn.prepareStatement("delete from PERSONS where id=?")) { - st.setLong(1, (Long)key); + try (PreparedStatement st = conn.prepareStatement("delete from PERSONS where id=?")) { + st.setLong(1, (Long)key); - st.executeUpdate(); - } + st.executeUpdate(); } catch (SQLException e) { - throw new CacheWriterException("Failed to remove object: " + key, e); - } - finally { - end(conn); + throw new CacheWriterException("Failed to delete object [key=" + key + ']', e); } } @@ -192,84 +149,27 @@ public class CacheJdbcPersonStore extends CacheStoreAdapter<Long, Person> { final int entryCnt = (Integer)args[0]; - try (Connection conn = connection()) { - try (PreparedStatement st = conn.prepareStatement("select * from PERSONS")) { - try (ResultSet rs = st.executeQuery()) { - int cnt = 0; + Connection conn = ses.attachment(); - while (cnt < entryCnt && rs.next()) { - Person person = new Person(rs.getLong(1), rs.getString(2), rs.getString(3)); + try (PreparedStatement stmt = conn.prepareStatement("select * from PERSONS limit ?")) { + stmt.setInt(1, entryCnt); - clo.apply(person.getId(), person); + ResultSet rs = stmt.executeQuery(); - cnt++; - } + int cnt = 0; - System.out.println(">>> Loaded " + cnt + " values into cache."); - } - } - } - catch (SQLException e) { - throw new CacheLoaderException("Failed to load values from cache store.", e); - } - } - - /** - * @return Connection. - * @throws SQLException In case of error. - */ - private Connection connection() throws SQLException { - // If there is an ongoing transaction, - // we must reuse the same connection. - if (ses.isWithinTransaction()) { - Map<Object, Object> props = ses.properties(); - - Connection conn = (Connection)props.get(ATTR_NAME); + while (rs.next()) { + Person person = new Person(rs.getLong(1), rs.getString(2), rs.getString(3)); - if (conn == null) { - conn = openConnection(false); + clo.apply(person.getId(), person); - // Store connection in session properties, so it can be accessed - // for other operations on the same transaction. - props.put(ATTR_NAME, conn); + cnt++; } - return conn; + System.out.println(">>> Loaded " + cnt + " values into cache."); } - // Transaction can be null in case of simple load or put operation. - else - return openConnection(true); - } - - /** - * Closes allocated resources depending on transaction status. - * - * @param conn Allocated connection. - */ - private void end(@Nullable Connection conn) { - if (!ses.isWithinTransaction() && conn != null) { - // Close connection right away if there is no transaction. - try { - conn.close(); - } - catch (SQLException ignored) { - // No-op. - } + catch (SQLException e) { + throw new CacheLoaderException("Failed to load values from cache store.", e); } } - - /** - * Gets connection from a pool. - * - * @param autocommit {@code true} If connection should use autocommit mode. - * @return Pooled connection. - * @throws SQLException In case of error. - */ - private Connection openConnection(boolean autocommit) throws SQLException { - Connection conn = DriverManager.getConnection("jdbc:h2:mem:example;DB_CLOSE_DELAY=-1"); - - conn.setAutoCommit(autocommit); - - return conn; - } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1652fd18/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java index 1cb73c9..637d6dc 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java @@ -18,6 +18,8 @@ package org.apache.ignite.examples.datagrid.store.jdbc; import org.apache.ignite.*; +import org.apache.ignite.cache.store.*; +import org.apache.ignite.cache.store.jdbc.*; import org.apache.ignite.configuration.*; import org.apache.ignite.examples.*; import org.apache.ignite.examples.datagrid.store.*; @@ -71,6 +73,17 @@ public class CacheJdbcStoreExample { // Configure JDBC store. cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(CacheJdbcPersonStore.class)); + // Configure JDBC session listener. + cacheCfg.setCacheStoreSessionListenerFactories(new Factory<CacheStoreSessionListener>() { + @Override public CacheStoreSessionListener create() { + CacheJdbcStoreSessionListener lsnr = new CacheJdbcStoreSessionListener(); + + lsnr.setDataSource(CacheJdbcPersonStore.DATA_SRC); + + return lsnr; + } + }); + cacheCfg.setReadThrough(true); cacheCfg.setWriteThrough(true); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1652fd18/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/CacheSpringPersonStore.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/CacheSpringPersonStore.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/CacheSpringPersonStore.java new file mode 100644 index 0000000..50149ba --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/CacheSpringPersonStore.java @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.datagrid.store.spring; + +import org.apache.ignite.*; +import org.apache.ignite.cache.store.*; +import org.apache.ignite.examples.datagrid.store.*; +import org.apache.ignite.lang.*; +import org.springframework.dao.*; +import org.springframework.jdbc.core.*; +import org.springframework.jdbc.datasource.*; + +import javax.cache.*; +import javax.cache.integration.*; +import javax.sql.*; +import java.sql.*; +import java.util.concurrent.atomic.*; + +/** + * Example of {@link CacheStore} implementation that uses JDBC + * transaction with cache transactions and maps {@link Long} to {@link Person}. + */ +public class CacheSpringPersonStore extends CacheStoreAdapter<Long, Person> { + /** Data source. */ + public static final DataSource DATA_SRC = new DriverManagerDataSource("jdbc:h2:mem:example;DB_CLOSE_DELAY=-1"); + + /** Spring JDBC template. */ + private JdbcTemplate jdbcTemplate; + + /** + * Constructor. + * + * @throws IgniteException If failed. + */ + public CacheSpringPersonStore() throws IgniteException { + jdbcTemplate = new JdbcTemplate(DATA_SRC); + + prepareDb(); + } + + /** + * Prepares database for example execution. This method will create a + * table called "PERSONS" so it can be used by store implementation. + * + * @throws IgniteException If failed. + */ + private void prepareDb() throws IgniteException { + jdbcTemplate.update( + "create table if not exists PERSONS (" + + "id number unique, firstName varchar(255), lastName varchar(255))"); + } + + /** {@inheritDoc} */ + @Override public Person load(Long key) { + System.out.println(">>> Store load [key=" + key + ']'); + + try { + return jdbcTemplate.queryForObject("select * from PERSONS where id = ?", new RowMapper<Person>() { + @Override public Person mapRow(ResultSet rs, int rowNum) throws SQLException { + return new Person(rs.getLong(1), rs.getString(2), rs.getString(3)); + } + }, key); + } + catch (EmptyResultDataAccessException ignored) { + return null; + } + } + + /** {@inheritDoc} */ + @Override public void write(Cache.Entry<? extends Long, ? extends Person> entry) { + Long key = entry.getKey(); + Person val = entry.getValue(); + + System.out.println(">>> Store write [key=" + key + ", val=" + val + ']'); + + int updated = jdbcTemplate.update("update PERSONS set firstName = ?, lastName = ? where id = ?", + val.getFirstName(), val.getLastName(), val.getId()); + + if (updated == 0) { + jdbcTemplate.update("insert into PERSONS (id, firstName, lastName) values (?, ?, ?)", + val.getId(), val.getFirstName(), val.getLastName()); + } + } + + /** {@inheritDoc} */ + @Override public void delete(Object key) { + System.out.println(">>> Store delete [key=" + key + ']'); + + jdbcTemplate.update("delete from PERSONS where id = ?", key); + } + + /** {@inheritDoc} */ + @Override public void loadCache(final IgniteBiInClosure<Long, Person> clo, Object... args) { + if (args == null || args.length == 0 || args[0] == null) + throw new CacheLoaderException("Expected entry count parameter is not provided."); + + int entryCnt = (Integer)args[0]; + + final AtomicInteger cnt = new AtomicInteger(); + + jdbcTemplate.query("select * from PERSONS limit ?", new RowCallbackHandler() { + @Override public void processRow(ResultSet rs) throws SQLException { + Person person = new Person(rs.getLong(1), rs.getString(2), rs.getString(3)); + + clo.apply(person.getId(), person); + + cnt.incrementAndGet(); + } + }, entryCnt); + + System.out.println(">>> Loaded " + cnt + " values into cache."); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1652fd18/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/CacheSpringStoreExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/CacheSpringStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/CacheSpringStoreExample.java new file mode 100644 index 0000000..aa624bc --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/CacheSpringStoreExample.java @@ -0,0 +1,143 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.datagrid.store.spring; + +import org.apache.ignite.*; +import org.apache.ignite.cache.store.*; +import org.apache.ignite.cache.store.jdbc.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.examples.*; +import org.apache.ignite.examples.datagrid.store.*; +import org.apache.ignite.transactions.*; + +import javax.cache.configuration.*; +import java.util.*; + +import static org.apache.ignite.cache.CacheAtomicityMode.*; + +/** + * Demonstrates usage of cache with underlying persistent store configured. + * <p> + * This example uses {@link CacheSpringPersonStore} as a persistent store. + * <p> + * Remote nodes can be started with {@link ExampleNodeStartup} in another JVM which will + * start node with {@code examples/config/example-ignite.xml} configuration. + */ +public class CacheSpringStoreExample { + /** Cache name. */ + private static final String CACHE_NAME = CacheSpringStoreExample.class.getSimpleName(); + + /** Heap size required to run this example. */ + public static final int MIN_MEMORY = 1024 * 1024 * 1024; + + /** Number of entries to load. */ + private static final int ENTRY_COUNT = 100_000; + + /** Global person ID to use across entire example. */ + private static final Long id = Math.abs(UUID.randomUUID().getLeastSignificantBits()); + + /** + * Executes example. + * + * @param args Command line arguments, none required. + * @throws IgniteException If example execution failed. + */ + public static void main(String[] args) throws IgniteException { + ExamplesUtils.checkMinMemory(MIN_MEMORY); + + // To start ignite with desired configuration uncomment the appropriate line. + try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) { + System.out.println(); + System.out.println(">>> Cache store example started."); + + CacheConfiguration<Long, Person> cacheCfg = new CacheConfiguration<>(CACHE_NAME); + + // Set atomicity as transaction, since we are showing transactions in example. + cacheCfg.setAtomicityMode(TRANSACTIONAL); + + // Configure Spring store. + cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(CacheSpringPersonStore.class)); + + // Configure Spring session listener. + cacheCfg.setCacheStoreSessionListenerFactories(new Factory<CacheStoreSessionListener>() { + @Override public CacheStoreSessionListener create() { + CacheJdbcStoreSessionListener lsnr = new CacheJdbcStoreSessionListener(); + + lsnr.setDataSource(CacheSpringPersonStore.DATA_SRC); + + return lsnr; + } + }); + + cacheCfg.setReadThrough(true); + cacheCfg.setWriteThrough(true); + + try (IgniteCache<Long, Person> cache = ignite.getOrCreateCache(cacheCfg)) { + // Make initial cache loading from persistent store. This is a + // distributed operation and will call CacheStore.loadCache(...) + // method on all nodes in topology. + loadCache(cache); + + // Start transaction and execute several cache operations with + // read/write-through to persistent store. + executeTransaction(cache); + } + } + } + + /** + * Makes initial cache loading. + * + * @param cache Cache to load. + */ + private static void loadCache(IgniteCache<Long, Person> cache) { + long start = System.currentTimeMillis(); + + // Start loading cache from persistent store on all caching nodes. + cache.loadCache(null, ENTRY_COUNT); + + long end = System.currentTimeMillis(); + + System.out.println(">>> Loaded " + cache.size() + " keys with backups in " + (end - start) + "ms."); + } + + /** + * Executes transaction with read/write-through to persistent store. + * + * @param cache Cache to execute transaction on. + */ + private static void executeTransaction(IgniteCache<Long, Person> cache) { + try (Transaction tx = Ignition.ignite().transactions().txStart()) { + Person val = cache.get(id); + + System.out.println("Read value: " + val); + + val = cache.getAndPut(id, new Person(id, "Isaac", "Newton")); + + System.out.println("Overwrote old value: " + val); + + val = cache.get(id); + + System.out.println("Read value: " + val); + + tx.commit(); + } + + System.out.println("Read value after commit: " + cache.get(id)); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1652fd18/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/package-info.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/package-info.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/package-info.java new file mode 100644 index 0000000..211239f --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/spring/package-info.java @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * <!-- Package description. --> + * Contains Spring-based cache store implementation. + */ +package org.apache.ignite.examples.datagrid.store.spring; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1652fd18/modules/core/src/main/java/org/apache/ignite/IgniteCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java index f9007a2..a54adc9 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java @@ -311,10 +311,26 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS @IgniteAsyncSupported @Override public Map<K, V> getAll(Set<? extends K> keys); + /** + * Gets values from cache. Will bypass started transaction, if any, i.e. will not enlist entries + * and will not lock any keys if pessimistic transaction is started by thread. + * + * @param keys The keys whose associated values are to be returned. + * @return A map of entries that were found for the given keys. + */ + @IgniteAsyncSupported + public Map<K, V> getAllOutTx(Set<? extends K> keys); + /** {@inheritDoc} */ @IgniteAsyncSupported @Override public boolean containsKey(K key); + /** + * Determines if the {@link Cache} contains entries for the specified keys. + * + * @param keys Key whose presence in this cache is to be tested. + * @return {@code True} if this cache contains a mapping for the specified keys. + */ @IgniteAsyncSupported public boolean containsKeys(Set<? extends K> keys); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1652fd18/modules/core/src/main/java/org/apache/ignite/Ignition.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/Ignition.java b/modules/core/src/main/java/org/apache/ignite/Ignition.java index 6ed99bd..d5d59a5 100644 --- a/modules/core/src/main/java/org/apache/ignite/Ignition.java +++ b/modules/core/src/main/java/org/apache/ignite/Ignition.java @@ -20,6 +20,8 @@ package org.apache.ignite; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.spi.discovery.*; +import org.apache.ignite.spi.discovery.tcp.*; import org.jetbrains.annotations.*; import java.io.*; @@ -133,18 +135,30 @@ public class Ignition { } /** - * Sets client mode flag. + * Sets client mode static flag. + * <p> + * This flag used when node is started if {@link IgniteConfiguration#isClientMode()} + * is {@code null}. When {@link IgniteConfiguration#isClientMode()} is set this flag is ignored. + * It is recommended to use {@link DiscoverySpi} in client mode too. * * @param clientMode Client mode flag. + * @see IgniteConfiguration#isClientMode() + * @see TcpDiscoverySpi#setForceServerMode(boolean) */ public static void setClientMode(boolean clientMode) { IgnitionEx.setClientMode(clientMode); } /** - * Gets client mode flag. + * Gets client mode static flag. + * <p> + * This flag used when node is started if {@link IgniteConfiguration#isClientMode()} + * is {@code null}. When {@link IgniteConfiguration#isClientMode()} is set this flag is ignored. + * It is recommended to use {@link DiscoverySpi} in client mode too. * * @return Client mode flag. + * @see IgniteConfiguration#isClientMode() + * @see TcpDiscoverySpi#setForceServerMode(boolean) */ public static boolean isClientMode() { return IgnitionEx.isClientMode(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1652fd18/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java index 0d87326..799aace 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java @@ -30,21 +30,21 @@ public interface CacheMetrics { /** * The number of get requests that were satisfied by the cache. * - * @return the number of hits + * @return The number of hits. */ public long getCacheHits(); /** * This is a measure of cache efficiency. * - * @return the percentage of successful hits, as a decimal e.g 75. + * @return The percentage of successful hits, as a decimal e.g 75. */ public float getCacheHitPercentage(); /** * A miss is a get request that is not satisfied. * - * @return the number of misses + * @return The number of misses. */ public long getCacheMisses(); @@ -52,7 +52,7 @@ public interface CacheMetrics { * Returns the percentage of cache accesses that did not find a requested entry * in the cache. * - * @return the percentage of accesses that failed to find anything + * @return The percentage of accesses that failed to find anything. */ public float getCacheMissPercentage(); @@ -60,14 +60,14 @@ public interface CacheMetrics { * The total number of requests to the cache. This will be equal to the sum of * the hits and misses. * - * @return the number of gets + * @return The number of gets. */ public long getCacheGets(); /** * The total number of puts to the cache. * - * @return the number of puts + * @return The number of puts. */ public long getCachePuts(); @@ -75,7 +75,7 @@ public interface CacheMetrics { * The total number of removals from the cache. This does not include evictions, * where the cache itself initiates the removal to make space. * - * @return the number of removals + * @return The number of removals. */ public long getCacheRemovals(); @@ -84,28 +84,28 @@ public interface CacheMetrics { * initiated by the cache itself to free up space. An eviction is not treated as * a removal and does not appear in the removal counts. * - * @return the number of evictions + * @return The number of evictions. */ public long getCacheEvictions(); /** * The mean time to execute gets. * - * @return the time in µs + * @return The time in µs. */ public float getAverageGetTime(); /** * The mean time to execute puts. * - * @return the time in µs + * @return The time in µs. */ public float getAveragePutTime(); /** * The mean time to execute removes. * - * @return the time in µs + * @return The time in µs. */ public float getAverageRemoveTime(); @@ -113,7 +113,7 @@ public interface CacheMetrics { /** * The mean time to execute tx commit. * - * @return the time in µs + * @return The time in µs. */ public float getAverageTxCommitTime(); @@ -124,7 +124,6 @@ public interface CacheMetrics { */ public float getAverageTxRollbackTime(); - /** * Gets total number of transaction commits. * @@ -154,6 +153,62 @@ public interface CacheMetrics { public long getOverflowSize(); /** + * The total number of get requests to the off-heap memory. + * + * @return The number of gets. + */ + public long getOffHeapGets(); + + /** + * The total number of put requests to the off-heap memory. + * + * @return The number of puts. + */ + public long getOffHeapPuts(); + + /** + * The total number of removals from the off-heap memory. This does not include evictions. + * + * @return The number of removals. + */ + public long getOffHeapRemovals(); + + /** + * The total number of evictions from the off-heap memory. + * + * @return The number of evictions. + */ + public long getOffHeapEvictions(); + + /** + * The number of get requests that were satisfied by the off-heap memory. + * + * @return The off-heap hits number. + */ + public long getOffHeapHits(); + + /** + * Gets the percentage of hits on off-heap memory. + * + * @return The percentage of hits on off-heap memory. + */ + public float getOffHeapHitPercentage(); + + /** + * A miss is a get request that is not satisfied by off-heap memory. + * + * @return The off-heap misses number. + */ + public long getOffHeapMisses(); + + /** + * Gets the percentage of misses on off-heap memory. + * + * @return The percentage of misses on off-heap memory. + */ + public float getOffHeapMissPercentage(); + + /** * Gets number of entries stored in off-heap memory. * * @return Number of entries stored in off-heap memory. @@ -161,6 +216,20 @@ public interface CacheMetrics { public long getOffHeapEntriesCount(); /** + * Gets number of primary entries stored in off-heap memory. + * + * @return Number of primary entries stored in off-heap memory. + */ + public long getOffHeapPrimaryEntriesCount(); + + /** + * Gets number of backup entries stored in off-heap memory. + * + * @return Number of backup entries stored in off-heap memory. + */ + public long getOffHeapBackupEntriesCount(); + + /** * Gets memory size allocated in off-heap. * * @return Memory size allocated in off-heap. @@ -168,6 +237,76 @@ public interface CacheMetrics { public long getOffHeapAllocatedSize(); /** + * Gets off-heap memory maximum size. + * + * @return Off-heap memory maximum size. + */ + public long getOffHeapMaxSize(); + + /** + * The total number of get requests to the swap. + * + * @return The number of gets. + */ + public long getSwapGets(); + + /** + * The total number of put requests to the swap. + * + * @return The number of puts. + */ + public long getSwapPuts(); + + /** + * The total number of removals from the swap. + * + * @return The number of removals. + */ + public long getSwapRemovals(); + + /** + * The number of get requests that were satisfied by the swap. + * + * @return The swap hits number. + */ + public long getSwapHits(); + + /** + * A miss is a get request that is not satisfied by swap. + * + * @return The swap misses number. + */ + public long getSwapMisses(); + + /** + * Gets number of entries stored in swap. + * + * @return Number of entries stored in swap. + */ + public long getSwapEntriesCount(); + + /** + * Gets size of swap. + * + * @return Size of swap. + */ + public long getSwapSize(); + + /** + * Gets the percentage of hits on swap. + * + * @return The percentage of hits on swap. + */ + public float getSwapHitPercentage(); + + /** + * Gets the percentage of misses on swap. + * + * @return The percentage of misses on swap. + */ + public float getSwapMissPercentage(); + + /** * Gets number of non-{@code null} values in the cache. * * @return Number of non-{@code null} values in the cache. @@ -184,7 +323,7 @@ public interface CacheMetrics { /** * Returns {@code true} if this cache is empty. * - * @return {@code true} if this cache is empty. + * @return {@code True} if this cache is empty. */ public boolean isEmpty(); @@ -294,7 +433,7 @@ public interface CacheMetrics { public int getTxDhtRolledbackVersionsSize(); /** - * Returns {@code True} if write-behind is enabled. + * Returns {@code true} if write-behind is enabled. * * @return {@code True} if write-behind is enabled. */ @@ -372,16 +511,16 @@ public interface CacheMetrics { /** * Determines the required type of keys for this {@link Cache}, if any. * - * @return the fully qualified class name of the key type, - * or "java.lang.Object" if the type is undefined. + * @return The fully qualified class name of the key type, + * or {@code "java.lang.Object"} if the type is undefined. */ public String getKeyType(); /** * Determines the required type of values for this {@link Cache}, if any. * - * @return the fully qualified class name of the value type, - * or "java.lang.Object" if the type is undefined. + * @return The fully qualified class name of the value type, + * or {@code "java.lang.Object"} if the type is undefined. */ public String getValueType(); @@ -407,7 +546,7 @@ public interface CacheMetrics { * <p> * The default value is {@code true}. * - * @return true if the cache is store by value + * @return {@code True} if the cache is store by value. */ public boolean isStoreByValue(); @@ -416,7 +555,7 @@ public interface CacheMetrics { * <p> * The default value is {@code false}. * - * @return true if statistics collection is enabled + * @return {@code True} if statistics collection is enabled. */ public boolean isStatisticsEnabled(); @@ -425,7 +564,7 @@ public interface CacheMetrics { * <p> * The default value is {@code false}. * - * @return true if management is enabled + * @return {@code true} if management is enabled. */ public boolean isManagementEnabled(); @@ -434,7 +573,7 @@ public interface CacheMetrics { * <p> * The default value is {@code false} * - * @return {@code true} when a {@link Cache} is in + * @return {@code True} when a {@link Cache} is in * "read-through" mode. * @see CacheLoader */ @@ -448,7 +587,7 @@ public interface CacheMetrics { * <p> * The default value is {@code false} * - * @return {@code true} when a {@link Cache} is in "write-through" mode. + * @return {@code True} when a {@link Cache} is in "write-through" mode. * @see CacheWriter */ public boolean isWriteThrough(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1652fd18/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictableEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictableEntry.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictableEntry.java index d87109f..9f1889a 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictableEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictableEntry.java @@ -46,6 +46,13 @@ public interface EvictableEntry<K, V> extends Cache.Entry<K, V> { public boolean isCached(); /** + * Returns entry size in bytes. + * + * @return entry size in bytes. + */ + public int size(); + + /** * Gets metadata added by eviction policy. * * @return Metadata value or {@code null}. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1652fd18/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictionPolicy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictionPolicy.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictionPolicy.java index f409e9b..07c269d 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictionPolicy.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictionPolicy.java @@ -20,6 +20,7 @@ package org.apache.ignite.cache.eviction; import org.apache.ignite.cache.eviction.fifo.*; import org.apache.ignite.cache.eviction.lru.*; import org.apache.ignite.cache.eviction.random.*; +import org.apache.ignite.cache.eviction.sorted.*; /** * Pluggable cache eviction policy. Usually, implementations will internally order @@ -32,6 +33,7 @@ import org.apache.ignite.cache.eviction.random.*; * <li>{@link LruEvictionPolicy}</li> * <li>{@link RandomEvictionPolicy}</li> * <li>{@link FifoEvictionPolicy}</li> + * <li>{@link SortedEvictionPolicy}</li> * </ul> * <p> * The eviction policy thread-safety is ensured by Ignition. Implementations of this interface should