IGNITE-96 - Merge branch sprint-1 into ignite-96
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/af231de3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/af231de3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/af231de3 Branch: refs/heads/sprint-1 Commit: af231de335ecca259a7695fe02c1727a4431fd41 Parents: 2dd61e0 1e65f16 Author: Alexey Goncharuk <agoncha...@gridgain.com> Authored: Tue Feb 10 17:13:36 2015 -0800 Committer: Alexey Goncharuk <agoncha...@gridgain.com> Committed: Tue Feb 10 17:13:36 2015 -0800 ---------------------------------------------------------------------- config/router/default-router.xml | 2 +- .../HibernateL2CacheExampleNodeStartup.java | 1 + .../MemcacheRestExampleNodeStartup.java | 2 +- .../examples/ScalarCacheAffinityExample1.scala | 2 - .../config/grid-client-spring-config.xml | 6 +- .../ClientAbstractMultiThreadedSelfTest.java | 598 ------- .../client/ClientDefaultCacheSelfTest.java | 220 --- .../ignite/client/ClientGetAffinityTask.java | 64 - .../apache/ignite/client/ClientHttpTask.java | 58 - .../apache/ignite/client/ClientNodeStartup.java | 57 - .../client/ClientReconnectionSelfTest.java | 235 --- .../ignite/client/ClientSslNodeStartup.java | 59 - .../ignite/client/ClientStartNodeTask.java | 179 -- .../ignite/client/ClientStopNodeTask.java | 127 -- .../ignite/client/ClientStringLengthTask.java | 71 - .../client/ClientTcpMultiThreadedSelfTest.java | 45 - .../ClientTcpSslAuthenticationSelfTest.java | 265 --- .../ClientTcpSslMultiThreadedSelfTest.java | 46 - .../org/apache/ignite/client/ClientTcpTask.java | 71 - ...skExecutionAfterTopologyRestartSelfTest.java | 75 - .../ignite/client/ClientTestRestServer.java | 281 --- .../client/ClientTopologyCacheSelfTest.java | 288 ---- .../org/apache/ignite/client/HashMapStore.java | 53 - .../org/apache/ignite/client/SleepTestTask.java | 66 - .../client/TaskSingleJobSplitAdapter.java | 70 - .../client/impl/ClientCacheFlagsCodecTest.java | 83 - .../client/impl/ClientComputeImplSelfTest.java | 167 -- .../client/impl/ClientDataImplSelfTest.java | 268 --- .../impl/ClientFutureAdapterSelfTest.java | 115 -- .../impl/ClientPartitionAffinitySelfTest.java | 406 ----- .../ClientPropertiesConfigurationSelfTest.java | 232 --- .../ClientAbstractConnectivitySelfTest.java | 303 ---- .../ClientAbstractMultiNodeSelfTest.java | 834 --------- .../integration/ClientAbstractSelfTest.java | 1604 ------------------ .../integration/ClientPreferDirectSelfTest.java | 192 --- .../ClientTcpConnectivitySelfTest.java | 75 - .../ClientTcpDirectMultiNodeSelfTest.java | 55 - .../integration/ClientTcpDirectSelfTest.java | 58 - .../integration/ClientTcpMultiNodeSelfTest.java | 35 - .../client/integration/ClientTcpSelfTest.java | 46 - .../ClientTcpSslDirectMultiNodeSelfTest.java | 62 - .../integration/ClientTcpSslDirectSelfTest.java | 59 - .../ClientTcpSslMultiNodeSelfTest.java | 42 - .../integration/ClientTcpSslSelfTest.java | 47 - .../ClientTcpUnreachableMultiNodeSelfTest.java | 134 -- .../ignite/client/integration/package.html | 24 - .../client/router/ClientFailedInitSelfTest.java | 275 --- .../client/router/RouterFactorySelfTest.java | 107 -- .../router/TcpRouterAbstractSelfTest.java | 125 -- .../router/TcpRouterMultiNodeSelfTest.java | 110 -- .../ignite/client/router/TcpRouterSelfTest.java | 35 - .../client/router/TcpSslRouterSelfTest.java | 48 - .../apache/ignite/client/router/package.html | 24 - .../testsuites/IgniteRouterTestSuite.java | 41 - .../client/suite/IgniteClientTestSuite.java | 118 -- .../ignite/client/util/ClientByteUtilsTest.java | 172 -- .../util/ClientConsistentHashSelfTest.java | 281 --- .../client/util/ClientJavaHasherSelfTest.java | 84 - .../internal/TaskEventSubjectIdSelfTest.java | 4 +- .../ClientAbstractMultiThreadedSelfTest.java | 598 +++++++ .../client/ClientDefaultCacheSelfTest.java | 220 +++ .../internal/client/ClientGetAffinityTask.java | 64 + .../ignite/internal/client/ClientHttpTask.java | 58 + .../internal/client/ClientNodeStartup.java | 57 + .../client/ClientReconnectionSelfTest.java | 233 +++ .../internal/client/ClientSslNodeStartup.java | 59 + .../internal/client/ClientStartNodeTask.java | 179 ++ .../internal/client/ClientStopNodeTask.java | 127 ++ .../internal/client/ClientStringLengthTask.java | 71 + .../client/ClientTcpMultiThreadedSelfTest.java | 45 + .../ClientTcpSslAuthenticationSelfTest.java | 265 +++ .../ClientTcpSslMultiThreadedSelfTest.java | 46 + .../ignite/internal/client/ClientTcpTask.java | 71 + ...skExecutionAfterTopologyRestartSelfTest.java | 75 + .../internal/client/ClientTestRestServer.java | 281 +++ .../client/ClientTopologyCacheSelfTest.java | 288 ++++ .../ignite/internal/client/HashMapStore.java | 53 + .../ignite/internal/client/SleepTestTask.java | 66 + .../client/TaskSingleJobSplitAdapter.java | 70 + .../client/impl/ClientCacheFlagsCodecTest.java | 83 + .../client/impl/ClientComputeImplSelfTest.java | 167 ++ .../client/impl/ClientDataImplSelfTest.java | 268 +++ .../impl/ClientFutureAdapterSelfTest.java | 115 ++ .../impl/ClientPartitionAffinitySelfTest.java | 406 +++++ .../ClientPropertiesConfigurationSelfTest.java | 232 +++ .../ClientAbstractConnectivitySelfTest.java | 303 ++++ .../ClientAbstractMultiNodeSelfTest.java | 828 +++++++++ .../integration/ClientAbstractSelfTest.java | 1483 ++++++++++++++++ .../integration/ClientPreferDirectSelfTest.java | 192 +++ .../ClientTcpConnectivitySelfTest.java | 75 + .../ClientTcpDirectMultiNodeSelfTest.java | 55 + .../integration/ClientTcpDirectSelfTest.java | 58 + .../integration/ClientTcpMultiNodeSelfTest.java | 35 + .../client/integration/ClientTcpSelfTest.java | 46 + .../ClientTcpSslDirectMultiNodeSelfTest.java | 62 + .../integration/ClientTcpSslDirectSelfTest.java | 59 + .../ClientTcpSslMultiNodeSelfTest.java | 42 + .../integration/ClientTcpSslSelfTest.java | 47 + .../ClientTcpUnreachableMultiNodeSelfTest.java | 134 ++ .../client/router/ClientFailedInitSelfTest.java | 275 +++ .../client/router/RouterFactorySelfTest.java | 107 ++ .../router/TcpRouterAbstractSelfTest.java | 125 ++ .../router/TcpRouterMultiNodeSelfTest.java | 110 ++ .../client/router/TcpRouterSelfTest.java | 35 + .../client/router/TcpSslRouterSelfTest.java | 48 + .../client/suite/IgniteClientTestSuite.java | 118 ++ .../client/util/ClientByteUtilsTest.java | 172 ++ .../util/ClientConsistentHashSelfTest.java | 281 +++ .../client/util/ClientJavaHasherSelfTest.java | 84 + .../rest/AbstractRestProcessorSelfTest.java | 6 +- .../rest/ClientMemcachedProtocolSelfTest.java | 4 +- .../rest/JettyRestProcessorSignedSelfTest.java | 4 +- .../rest/RestBinaryProtocolSelfTest.java | 54 +- .../rest/RestMemcacheProtocolSelfTest.java | 8 +- .../rest/RestProcessorMultiStartSelfTest.java | 2 +- .../rest/RestProcessorStartSelfTest.java | 10 +- .../processors/rest/RestProcessorTest.java | 8 +- .../rest/TaskCommandHandlerSelfTest.java | 12 +- .../processors/rest/TestBinaryClient.java | 23 +- .../protocols/tcp/TcpRestParserSelfTest.java | 4 +- .../ignite/jdbc/JdbcComplexQuerySelfTest.java | 2 +- .../ignite/jdbc/JdbcConnectionSelfTest.java | 8 +- .../ignite/jdbc/JdbcEmptyCacheSelfTest.java | 2 +- .../ignite/jdbc/JdbcLocalCachesSelfTest.java | 2 +- .../ignite/jdbc/JdbcMetadataSelfTest.java | 2 +- .../jdbc/JdbcPreparedStatementSelfTest.java | 2 +- .../ignite/jdbc/JdbcResultSetSelfTest.java | 2 +- .../ignite/jdbc/JdbcStatementSelfTest.java | 2 +- .../loadtests/client/ClientCacheBenchmark.java | 2 +- .../client/ClientMarshallerBenchmarkTest.java | 6 +- .../loadtests/client/ClientTcpSslLoadTest.java | 2 +- .../clients/src/test/resources/spring-cache.xml | 5 - .../src/test/resources/spring-router-ssl.xml | 4 +- .../src/test/resources/spring-router.xml | 2 +- .../src/test/resources/spring-server-node.xml | 12 +- .../test/resources/spring-server-ssl-node.xml | 18 +- .../main/java/org/apache/ignite/Ignition.java | 6 - .../java/org/apache/ignite/cache/CacheName.java | 41 - .../org/apache/ignite/client/GridClient.java | 148 -- .../GridClientAuthenticationException.java | 35 - .../ignite/client/GridClientCacheFlag.java | 65 - .../ignite/client/GridClientCacheMode.java | 32 - .../client/GridClientClosedException.java | 35 - .../apache/ignite/client/GridClientCompute.java | 476 ------ .../ignite/client/GridClientConfiguration.java | 845 --------- .../apache/ignite/client/GridClientData.java | 443 ----- .../ignite/client/GridClientDataAffinity.java | 39 - .../client/GridClientDataConfiguration.java | 118 -- .../ignite/client/GridClientDataMetrics.java | 77 - .../client/GridClientDisconnectedException.java | 36 - .../ignite/client/GridClientException.java | 111 -- .../apache/ignite/client/GridClientFactory.java | 138 -- .../apache/ignite/client/GridClientFuture.java | 68 - .../ignite/client/GridClientFutureListener.java | 30 - .../GridClientFutureTimeoutException.java | 45 - .../client/GridClientHandshakeException.java | 48 - .../apache/ignite/client/GridClientNode.java | 128 -- .../ignite/client/GridClientNodeMetrics.java | 524 ------ .../client/GridClientPartitionAffinity.java | 369 ---- .../ignite/client/GridClientPredicate.java | 38 - .../ignite/client/GridClientProtocol.java | 26 - .../client/GridClientTopologyListener.java | 41 - .../client/GridServerUnreachableException.java | 45 - .../balancer/GridClientBalancerAdapter.java | 76 - .../client/balancer/GridClientLoadBalancer.java | 44 - .../balancer/GridClientRandomBalancer.java | 75 - .../balancer/GridClientRoundRobinBalancer.java | 111 -- .../apache/ignite/client/balancer/package.html | 24 - .../impl/GridClientAbstractProjection.java | 458 ----- .../client/impl/GridClientAndPredicate.java | 52 - .../client/impl/GridClientComputeImpl.java | 293 ---- .../ignite/client/impl/GridClientDataImpl.java | 389 ----- .../impl/GridClientDataMetricsAdapter.java | 160 -- .../client/impl/GridClientFutureAdapter.java | 349 ---- .../client/impl/GridClientFutureCallback.java | 35 - .../ignite/client/impl/GridClientImpl.java | 527 ------ .../ignite/client/impl/GridClientNodeImpl.java | 396 ----- .../impl/GridClientNodeMetricsAdapter.java | 990 ----------- .../client/impl/GridClientThreadFactory.java | 62 - .../impl/connection/GridClientConnection.java | 531 ------ .../GridClientConnectionCloseReason.java | 32 - .../connection/GridClientConnectionManager.java | 71 - .../GridClientConnectionManagerAdapter.java | 644 ------- .../GridClientConnectionManagerOsImpl.java | 48 - .../GridClientConnectionResetException.java | 48 - .../connection/GridClientNioTcpConnection.java | 1075 ------------ .../impl/connection/GridClientTopology.java | 450 ----- .../GridConnectionIdleClosedException.java | 36 - .../org/apache/ignite/client/impl/package.html | 24 - .../client/marshaller/GridClientMarshaller.java | 45 - .../marshaller/jdk/GridClientJdkMarshaller.java | 68 - .../ignite/client/marshaller/jdk/package.html | 24 - .../GridClientOptimizedMarshaller.java | 103 -- .../client/marshaller/optimized/package.html | 24 - .../ignite/client/marshaller/package.html | 24 - .../java/org/apache/ignite/client/package.html | 24 - .../ignite/client/router/GridRouterFactory.java | 126 -- .../ignite/client/router/GridTcpRouter.java | 76 - .../router/GridTcpRouterConfiguration.java | 306 ---- .../client/router/GridTcpRouterMBean.java | 88 - .../router/impl/GridRouterClientImpl.java | 200 --- .../impl/GridRouterCommandLineStartup.java | 169 -- .../client/router/impl/GridTcpRouterImpl.java | 348 ---- .../impl/GridTcpRouterNioListenerAdapter.java | 203 --- .../impl/GridTcpRouterNioListenerOsImpl.java | 38 - .../router/impl/GridTcpRouterNioParser.java | 115 -- .../ignite/client/router/impl/package.html | 24 - .../apache/ignite/client/router/package.html | 24 - .../client/ssl/GridSslBasicContextFactory.java | 438 ----- .../client/ssl/GridSslContextFactory.java | 36 - .../org/apache/ignite/client/ssl/package.html | 24 - .../client/util/GridClientConsistentHash.java | 440 ----- .../client/util/GridClientStripedLock.java | 135 -- .../ignite/client/util/GridClientUtils.java | 171 -- .../client/util/GridConcurrentHashSet.java | 113 -- .../org/apache/ignite/client/util/package.html | 24 - .../ignite/compute/ComputeJobContext.java | 20 - .../ClientConnectionConfiguration.java | 541 ------ .../configuration/ClientMessageInterceptor.java | 45 - .../configuration/ConnectorConfiguration.java | 518 ++++++ .../ConnectorMessageInterceptor.java | 45 + .../configuration/IgniteConfiguration.java | 579 +------ .../ignite/internal/GridJobContextImpl.java | 20 - .../ignite/internal/GridPluginComponent.java | 2 + .../apache/ignite/internal/GridProductImpl.java | 6 +- .../apache/ignite/internal/IgniteKernal.java | 25 +- .../org/apache/ignite/internal/IgnitionEx.java | 16 +- .../ignite/internal/client/GridClient.java | 146 ++ .../GridClientAuthenticationException.java | 35 + .../internal/client/GridClientCacheFlag.java | 65 + .../internal/client/GridClientCacheMode.java | 32 + .../client/GridClientClosedException.java | 35 + .../internal/client/GridClientCompute.java | 419 +++++ .../client/GridClientConfiguration.java | 844 +++++++++ .../ignite/internal/client/GridClientData.java | 443 +++++ .../internal/client/GridClientDataAffinity.java | 39 + .../client/GridClientDataConfiguration.java | 118 ++ .../internal/client/GridClientDataMetrics.java | 77 + .../client/GridClientDisconnectedException.java | 36 + .../internal/client/GridClientException.java | 111 ++ .../internal/client/GridClientFactory.java | 138 ++ .../internal/client/GridClientFuture.java | 68 + .../client/GridClientFutureListener.java | 30 + .../GridClientFutureTimeoutException.java | 45 + .../client/GridClientHandshakeException.java | 48 + .../ignite/internal/client/GridClientNode.java | 128 ++ .../internal/client/GridClientNodeMetrics.java | 524 ++++++ .../client/GridClientPartitionAffinity.java | 369 ++++ .../internal/client/GridClientPredicate.java | 38 + .../internal/client/GridClientProtocol.java | 26 + .../client/GridClientTopologyListener.java | 41 + .../client/GridServerUnreachableException.java | 45 + .../balancer/GridClientBalancerAdapter.java | 76 + .../client/balancer/GridClientLoadBalancer.java | 44 + .../balancer/GridClientRandomBalancer.java | 75 + .../balancer/GridClientRoundRobinBalancer.java | 111 ++ .../impl/GridClientAbstractProjection.java | 458 +++++ .../client/impl/GridClientAndPredicate.java | 52 + .../client/impl/GridClientComputeImpl.java | 263 +++ .../client/impl/GridClientDataImpl.java | 389 +++++ .../impl/GridClientDataMetricsAdapter.java | 160 ++ .../client/impl/GridClientFutureAdapter.java | 349 ++++ .../client/impl/GridClientFutureCallback.java | 35 + .../internal/client/impl/GridClientImpl.java | 527 ++++++ .../client/impl/GridClientNodeImpl.java | 396 +++++ .../impl/GridClientNodeMetricsAdapter.java | 990 +++++++++++ .../client/impl/GridClientThreadFactory.java | 62 + .../impl/connection/GridClientConnection.java | 515 ++++++ .../GridClientConnectionCloseReason.java | 32 + .../connection/GridClientConnectionManager.java | 71 + .../GridClientConnectionManagerAdapter.java | 644 +++++++ .../GridClientConnectionManagerOsImpl.java | 48 + .../GridClientConnectionResetException.java | 48 + .../connection/GridClientNioTcpConnection.java | 1063 ++++++++++++ .../impl/connection/GridClientTopology.java | 450 +++++ .../GridConnectionIdleClosedException.java | 36 + .../client/marshaller/GridClientMarshaller.java | 45 + .../marshaller/jdk/GridClientJdkMarshaller.java | 68 + .../GridClientOptimizedMarshaller.java | 103 ++ .../client/router/GridRouterFactory.java | 126 ++ .../internal/client/router/GridTcpRouter.java | 74 + .../router/GridTcpRouterConfiguration.java | 306 ++++ .../client/router/GridTcpRouterMBean.java | 88 + .../router/impl/GridRouterClientImpl.java | 200 +++ .../impl/GridRouterCommandLineStartup.java | 169 ++ .../client/router/impl/GridTcpRouterImpl.java | 348 ++++ .../impl/GridTcpRouterNioListenerAdapter.java | 203 +++ .../impl/GridTcpRouterNioListenerOsImpl.java | 38 + .../router/impl/GridTcpRouterNioParser.java | 115 ++ .../client/ssl/GridSslBasicContextFactory.java | 438 +++++ .../client/ssl/GridSslContextFactory.java | 36 + .../client/util/GridClientConsistentHash.java | 440 +++++ .../client/util/GridClientStripedLock.java | 135 ++ .../internal/client/util/GridClientUtils.java | 171 ++ .../client/util/GridConcurrentHashSet.java | 113 ++ .../ignite/internal/jdbc/JdbcConnection.java | 2 +- .../internal/jdbc/JdbcDatabaseMetadata.java | 2 +- .../ignite/internal/jdbc/JdbcResultSet.java | 2 +- .../ignite/internal/jdbc/JdbcStatement.java | 2 +- .../loadbalancer/GridLoadBalancerManager.java | 57 - .../closure/GridClosureProcessor.java | 286 +--- .../portable/GridPortableProcessor.java | 2 +- .../portable/os/GridOsPortableProcessor.java | 2 +- .../processors/rest/GridRestProcessor.java | 23 +- .../client/message/GridClientLogRequest.java | 118 -- .../handlers/log/GridLogCommandHandler.java | 306 ---- .../processors/rest/handlers/log/package.html | 24 - .../rest/protocols/GridRestProtocolAdapter.java | 8 +- .../protocols/tcp/GridTcpRestNioListener.java | 15 +- .../rest/protocols/tcp/GridTcpRestParser.java | 8 +- .../rest/protocols/tcp/GridTcpRestProtocol.java | 40 +- .../ignite/internal/util/IgniteUtils.java | 2 +- .../ignite/internal/util/nio/GridNioServer.java | 4 +- .../visor/node/VisorBasicConfiguration.java | 18 - .../node/VisorExecutorServiceConfiguration.java | 4 +- .../visor/node/VisorRestConfiguration.java | 13 +- .../ignite/lang/IgniteProductVersion.java | 12 +- .../org/apache/ignite/mxbean/IgniteMXBean.java | 8 - .../ignite/startup/BasicWarmupClosure.java | 2 +- .../test/config/default-spring-url-testing.xml | 2 + modules/core/src/test/config/example-cache.xml | 2 + .../src/test/config/io-manager-benchmark.xml | 1 + .../src/test/config/job-loadtest/client.xml | 2 + .../src/test/config/job-loadtest/server.xml | 2 + modules/core/src/test/config/jobs-load-base.xml | 2 + .../src/test/config/load/cache-benchmark.xml | 2 + .../test/config/load/cache-client-benchmark.xml | 2 + .../core/src/test/config/load/dsi-load-base.xml | 2 + .../src/test/config/load/merge-sort-base.xml | 2 + .../test/config/loaders/grid-cfg-2-grids.xml | 4 + .../core/src/test/config/loaders/grid-cfg.xml | 5 + .../config/spring-cache-put-remove-load.xml | 2 + .../src/test/config/spring-start-nodes-attr.xml | 2 + .../core/src/test/config/spring-start-nodes.xml | 2 + .../config/streamer/spring-streamer-base.xml | 2 + .../test/config/websession/spring-cache-1.xml | 2 + .../test/config/websession/spring-cache-2.xml | 2 + .../test/config/websession/spring-cache-3.xml | 2 + .../org/apache/ignite/GridTestJobContext.java | 10 - .../internal/GridDiscoveryEventSelfTest.java | 2 + .../internal/GridLifecycleAwareSelfTest.java | 18 +- .../ignite/internal/GridStartStopSelfTest.java | 6 + .../cache/GridCacheAffinityRoutingSelfTest.java | 420 ----- .../GridCacheDaemonNodeAbstractSelfTest.java | 2 + .../cache/GridCacheDeploymentSelfTest.java | 2 + .../cache/GridCacheLuceneQueryIndexTest.java | 1 + ...GridCacheQueueMultiNodeAbstractSelfTest.java | 1 + ...dCacheMultithreadedFailoverAbstractTest.java | 1 + .../GridCachePreloadLifecycleAbstractTest.java | 1 + .../GridCacheNearReaderPreloadSelfTest.java | 1 + .../dataload/GridDataLoaderPerformanceTest.java | 2 + ...heGgfsPerBlockLruEvictionPolicySelfTest.java | 2 + .../processors/fs/GridGgfsAbstractSelfTest.java | 1 + .../processors/fs/GridGgfsModesSelfTest.java | 2 + .../cache/GridCacheCommandHandlerSelfTest.java | 6 +- .../product/GridProductVersionSelfTest.java | 16 +- ...dStartupWithUndefinedIgniteHomeSelfTest.java | 105 -- .../GridTcpCommunicationBenchmark.java | 2 +- .../ignite/loadtests/dsi/GridDsiPerfJob.java | 1 - .../marshaller/GridMarshallerAbstractTest.java | 2 +- .../marshaller/GridMarshallerResourceBean.java | 2 +- .../marshaller/GridMarshallerTestBean.java | 2 +- .../spi/GridTcpSpiForwardingSelfTest.java | 1 + .../spi/discovery/tcp/TcpDiscoverySelfTest.java | 2 + .../tcp/TcpDiscoverySnapshotHistoryTest.java | 1 + .../ignite/testframework/GridTestUtils.java | 2 +- .../testframework/junits/GridAbstractTest.java | 2 + .../testsuites/IgniteKernalSelfTestSuite.java | 1 - .../client/hadoop/GridHadoopClientProtocol.java | 2 +- .../GridHadoopClientProtocolProvider.java | 6 +- .../GridGgfsHadoopDualAbstractSelfTest.java | 1 + ...idGgfsHadoopFileSystemHandshakeSelfTest.java | 1 + ...GgfsHadoopFileSystemLoggerStateSelfTest.java | 1 + .../hadoop/GridHadoopAbstractSelfTest.java | 6 +- .../log4j/GridLog4jCorrectFileNameTest.java | 1 + .../http/jetty/GridJettyRestProtocol.java | 6 +- .../ignite/internal/GridFactorySelfTest.java | 9 + .../GridSpringBeanSerializationSelfTest.java | 2 + .../config/VisorConfigurationCommand.scala | 13 +- .../scala/org/apache/ignite/visor/visor.scala | 2 +- modules/yardstick/config/ignite-base-config.xml | 2 + .../yardstick/config/ignite-store-config.xml | 2 + .../org/apache/ignite/yardstick/IgniteNode.java | 8 +- pom.xml | 91 - 384 files changed, 23872 insertions(+), 26529 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/af231de3/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientAbstractMultiThreadedSelfTest.java ---------------------------------------------------------------------- diff --cc modules/clients/src/test/java/org/apache/ignite/internal/client/ClientAbstractMultiThreadedSelfTest.java index 0000000,da9d033..2ab2c28 mode 000000,100644..100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientAbstractMultiThreadedSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientAbstractMultiThreadedSelfTest.java @@@ -1,0 -1,615 +1,598 @@@ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package org.apache.ignite.internal.client; + + import org.apache.ignite.*; -import org.apache.ignite.cache.affinity.*; ++import org.apache.ignite.cache.*; + import org.apache.ignite.cluster.*; + import org.apache.ignite.compute.*; + import org.apache.ignite.configuration.*; + import org.apache.ignite.internal.*; + import org.apache.ignite.internal.client.balancer.*; + import org.apache.ignite.internal.client.impl.*; + import org.apache.ignite.internal.client.ssl.*; -import org.apache.ignite.internal.processors.affinity.*; + import org.apache.ignite.internal.util.typedef.*; + import org.apache.ignite.internal.util.typedef.internal.*; + import org.apache.ignite.lang.*; + import org.apache.ignite.resources.*; + import org.apache.ignite.spi.discovery.tcp.*; + import org.apache.ignite.spi.discovery.tcp.ipfinder.*; + import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; + import org.apache.ignite.testframework.junits.common.*; + import org.jetbrains.annotations.*; + import org.junit.*; + + import java.util.*; + import java.util.concurrent.*; + import java.util.concurrent.atomic.*; + + import static org.apache.ignite.cache.CacheAtomicityMode.*; + import static org.apache.ignite.cache.CacheDistributionMode.*; + import static org.apache.ignite.cache.CacheMode.*; + import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; -import static org.apache.ignite.testframework.GridTestUtils.*; + + /** + * + */ + public abstract class ClientAbstractMultiThreadedSelfTest extends GridCommonAbstractTest { + /** IP finder. */ + private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + + /** Partitioned cache name. */ + protected static final String PARTITIONED_CACHE_NAME = "partitioned"; + + /** Partitioned cache with async commit and backup name. */ + protected static final String PARTITIONED_ASYNC_BACKUP_CACHE_NAME = "partitioned-async-backup"; + + /** Replicated cache name. */ + private static final String REPLICATED_CACHE_NAME = "replicated"; + + /** Replicated cache with async commit name. */ + private static final String REPLICATED_ASYNC_CACHE_NAME = "replicated-async"; + + /** Nodes count. */ + protected static final int NODES_CNT = 5; + + /** Thread count to run tests. */ + private static final int THREAD_CNT = 20; + + /** Count of tasks to run. */ + private static final int TASK_EXECUTION_CNT = 50000; + + /** Count of cache puts in tests. */ + private static final int CACHE_PUT_CNT = 10000; + + /** Topology update frequency. */ + private static final int TOP_REFRESH_FREQ = 1000; + + /** Info messages will be printed each 5000 iterations. */ + private static final int STATISTICS_PRINT_STEP = 5000; + + /** Host. */ + public static final String HOST = "127.0.0.1"; + + /** Base for tcp rest ports. */ + public static final int REST_TCP_PORT_BASE = 12345; + + static { + System.setProperty("CLIENTS_MODULE_PATH", U.resolveIgnitePath("modules/clients").getAbsolutePath()); + } + + /** Client instance for each test. */ + private GridClient client; + + /** + * @return Client protocol that should be used. + */ + protected abstract GridClientProtocol protocol(); + + /** + * @return Server address to create first connection. + */ + protected abstract String serverAddress(); + + /** + * @return Whether SSL should be used. + */ + protected abstract boolean useSsl(); + + /** + * @return SSL context factory to use if SSL is enabled. + */ + protected abstract GridSslContextFactory sslContextFactory(); + + /** + * @return Count of iterations for sync commit test. + */ + protected int syncCommitIterCount() { + return 1000; + } + + /** + * @return Topology refresh frequency interval. + */ + protected int topologyRefreshFrequency() { + return TOP_REFRESH_FREQ; + } + + /** + * @return Max connection idle time. + */ + protected int maxConnectionIdleTime() { + return 5000; + } + + /** + * @return Number of tasks that should be executed during test. + */ + protected int taskExecutionCount() { + return TASK_EXECUTION_CNT; + } + + /** + * @return Number of puts to the cache. + */ + protected int cachePutCount() { + return CACHE_PUT_CNT; + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration c = super.getConfiguration(gridName); + + c.setLocalHost(HOST); + + assert c.getConnectorConfiguration() == null; + + ConnectorConfiguration clientCfg = new ConnectorConfiguration(); + + clientCfg.setPort(REST_TCP_PORT_BASE); + + if (useSsl()) { + clientCfg.setSslEnabled(true); + + clientCfg.setSslContextFactory(sslContextFactory()); + } + + c.setConnectorConfiguration(clientCfg); + + TcpDiscoverySpi disco = new TcpDiscoverySpi(); + + disco.setIpFinder(IP_FINDER); + + c.setDiscoverySpi(disco); + + c.setCacheConfiguration(cacheConfiguration(null), cacheConfiguration(PARTITIONED_CACHE_NAME), + cacheConfiguration(REPLICATED_CACHE_NAME), cacheConfiguration(PARTITIONED_ASYNC_BACKUP_CACHE_NAME), + cacheConfiguration(REPLICATED_ASYNC_CACHE_NAME)); + + return c; + } + + /** + * @param cacheName Cache name. + * @return Cache configuration. + * @throws Exception In case of error. + */ + private CacheConfiguration cacheConfiguration(@Nullable String cacheName) throws Exception { + CacheConfiguration cfg = defaultCacheConfiguration(); + + cfg.setDistributionMode(NEAR_PARTITIONED); + cfg.setAtomicityMode(TRANSACTIONAL); + + if (cacheName == null) + cfg.setCacheMode(LOCAL); + else if (PARTITIONED_CACHE_NAME.equals(cacheName)) { + cfg.setCacheMode(PARTITIONED); + + cfg.setBackups(0); + } + else if (PARTITIONED_ASYNC_BACKUP_CACHE_NAME.equals(cacheName)) { + cfg.setCacheMode(PARTITIONED); + + cfg.setBackups(1); + } + else + cfg.setCacheMode(REPLICATED); + + cfg.setName(cacheName); + + if (cacheName != null && !cacheName.contains("async")) + cfg.setWriteSynchronizationMode(FULL_SYNC); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + startGridsMultiThreaded(NODES_CNT); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + client = GridClientFactory.start(clientConfiguration()); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + GridClientFactory.stop(client.id(), false); + + client = null; + } + + /** + * @throws Exception If failed. + */ + public void testSyncCommitFlagReplicated() throws Exception { + doTestSyncCommitFlag(client.data(REPLICATED_ASYNC_CACHE_NAME)); + } + + /** + * @throws Exception If failed. + */ + public void testSyncCommitFlagPartitioned() throws Exception { + doTestSyncCommitFlag(client.data(PARTITIONED_ASYNC_BACKUP_CACHE_NAME)); + } + + /** + * Extracts array from given iterator. + * + * @param nodes Iterator of nodes. + * @return Nodes array. + */ + private GridClientNode[] toArray(Iterator<? extends GridClientNode> nodes) { + ArrayList<GridClientNode> res = new ArrayList<>(); + + while (nodes.hasNext()) + res.add(nodes.next()); + + return res.toArray(new GridClientNode[res.size()]); + } + + /** + * Runs test on SYNC_COMMIT flag. + * + * @param data Client data to run test on. + * @throws Exception If failed. + */ + private void doTestSyncCommitFlag(final GridClientData data) throws Exception { + final String key = "k0"; + + Collection<UUID> affNodesIds = F.viewReadOnly( - grid(0).cache(data.cacheName()).affinity().mapKeyToPrimaryAndBackups(key), ++ affinity(grid(0).jcache(data.cacheName())).mapKeyToPrimaryAndBackups(key), + F.node2id()); + + final GridClientData dataFirst = data.pinNodes(F.first(client.compute().nodes())); + + List<GridClientNode> affNodes = new ArrayList<>(); + + for (GridClientNode node : client.compute().nodes()) { + if (affNodesIds.contains(node.nodeId())) + affNodes.add(node); + } + + Assert.assertFalse(affNodes.isEmpty()); + + Iterator<? extends GridClientNode> it = affNodes.iterator(); + + final GridClientData dataOthers = data.pinNodes(it.next(), toArray(it)); + + for (int i = 0; i < syncCommitIterCount(); i++) { + final CountDownLatch l = new CountDownLatch(1); + + final String val = "v" + i; + + IgniteInternalFuture<?> f = multithreadedAsync(new Callable<Object>() { + @Override public Object call() throws Exception { + l.await(); + + assertEquals(val, dataOthers.get(key)); + + return null; + } + }, THREAD_CNT); + + dataFirst.flagsOn(GridClientCacheFlag.SYNC_COMMIT).put(key, val); + + l.countDown(); + + f.get(); + } + } + + /** + * @throws Exception If failed. + */ + public void testMultithreadedTaskRun() throws Exception { + final AtomicLong cnt = new AtomicLong(); + + final AtomicReference<GridClientException> err = new AtomicReference<>(); + + final ConcurrentLinkedQueue<String> execQueue = new ConcurrentLinkedQueue<>(); + + IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() { + @Override + public void run() { + long processed; + + while ((processed = cnt.getAndIncrement()) < taskExecutionCount()) { + try { + if (processed > 0 && processed % STATISTICS_PRINT_STEP == 0) + info(">>>>>>> " + processed + " tasks finished."); + + String res = client.compute().execute(TestTask.class.getName(), null); + + execQueue.add(res); + } + catch (GridClientException e) { + err.compareAndSet(null, e); + } + } + } + }, THREAD_CNT, "client-task-request"); + + fut.get(); + + if (err.get() != null) + throw new Exception(err.get()); + + assertEquals(taskExecutionCount(), execQueue.size()); + + // With round-robin balancer each node must receive equal count of task requests. + Collection<String> executionIds = new HashSet<>(execQueue); + + assertTrue(executionIds.size() == NODES_CNT); + + Map<String, AtomicInteger> statisticsMap = new HashMap<>(); + + for (String id : executionIds) + statisticsMap.put(id, new AtomicInteger()); + + for (String id : execQueue) + statisticsMap.get(id).incrementAndGet(); + + info(">>>>>>> Execution statistics per node:"); + + for (Map.Entry<String, AtomicInteger> e : statisticsMap.entrySet()) + info(">>>>>>> " + e.getKey() + " run " + e.getValue().get() + " tasks"); + } + + /** + * @throws Exception If failed. + */ + public void test6Affinity() throws Exception { + GridClientData cache = client.data(PARTITIONED_CACHE_NAME); + UUID nodeId = cache.affinity("6"); + + info("Affinity node: " + nodeId); + } + + /** + * @throws Exception If failed. + */ + public void testMultithreadedCachePut() throws Exception { + final AtomicLong keyCnt = new AtomicLong(); + + final AtomicReference<Exception> err = new AtomicReference<>(); + + final ConcurrentMap<String, T2<UUID, String>> puts = new ConcurrentHashMap<>(); + + final Map<UUID, Ignite> gridMap = new HashMap<>(); + + for (int i = 0; i < NODES_CNT; i++) { + Ignite g = grid(i); + + gridMap.put(g.cluster().localNode().id(), g); + } + + final Ignite ignite = F.first(gridMap.values()); + + assertEquals(NODES_CNT, client.compute().refreshTopology(false, false).size()); + + IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() { + @SuppressWarnings("OverlyStrongTypeCast") + @Override public void run() { + try { + GridClientData cache = client.data(PARTITIONED_CACHE_NAME); + + assertEquals(NODES_CNT, ((GridClientDataImpl)cache).projectionNodes().size()); + + long rawKey; + + while ((rawKey = keyCnt.getAndIncrement()) < cachePutCount()) { + String key = String.valueOf(rawKey); + + UUID nodeId = cache.affinity(key); + UUID srvNodeId = ignite.cluster().mapKeyToNode(PARTITIONED_CACHE_NAME, key).id(); + + if (!nodeId.equals(srvNodeId)) { + //GridClientDataAffinity clAff = + // ((GridClientConfiguration)getFieldValue(client, "cfg")). + // getDataConfiguration(PARTITIONED_CACHE_NAME).getAffinity(); + + //printAffinityState(gridMap.values()); + //info("Client affinity: " + clAff); + + info("Got wrong client mapping [key=" + key + ", exp=" + srvNodeId + + ", actual=" + nodeId + "]"); + } + + String val = "val" + rawKey; + + if (cache.put(key, val)) { + T2<UUID, String> old = puts.putIfAbsent(key, new T2<>(nodeId, val)); + + assert old == null : "Map contained entry [key=" + rawKey + ", entry=" + old + ']'; + } + } + } + catch (Exception e) { + err.compareAndSet(null, e); + } + } + }, THREAD_CNT, "client-cache-put"); + + fut.get(); + + if (err.get() != null) + throw new Exception(err.get()); + + assertEquals(cachePutCount(), puts.size()); + + // Now check that all puts went to primary nodes. + for (long i = 0; i < cachePutCount(); i++) { + String key = String.valueOf(i); + + ClusterNode node = ignite.cluster().mapKeyToNode(PARTITIONED_CACHE_NAME, key); + - if (!puts.get(key).get2().equals(gridMap.get(node.id()).cache(PARTITIONED_CACHE_NAME).peek(key))) { ++ if (!puts.get(key).get2().equals(gridMap.get(node.id()).jcache(PARTITIONED_CACHE_NAME).localPeek(key, CachePeekMode.ONHEAP))) { + // printAffinityState(gridMap.values()); + + failNotEquals("Node don't have value for key [nodeId=" + node.id() + ", key=" + key + "]", - puts.get(key).get2(), gridMap.get(node.id()).cache(PARTITIONED_CACHE_NAME).peek(key)); ++ puts.get(key).get2(), gridMap.get(node.id()).jcache(PARTITIONED_CACHE_NAME).localPeek(key, CachePeekMode.ONHEAP)); + } + + // Assert that client has properly determined affinity node. + if (!node.id().equals(puts.get(key).get1())) { + //GridClientDataAffinity clAff = + // ((GridClientConfiguration)getFieldValue(client, "cfg")). + // getDataConfiguration(PARTITIONED_CACHE_NAME).getAffinity(); + + //printAffinityState(gridMap.values()); + //info("Client affinity: " + clAff); + + UUID curAffNode = client.data(PARTITIONED_CACHE_NAME).affinity(key); + + failNotEquals( + "Got different mappings [key=" + key + ", currId=" + curAffNode + "]", + node.id(), puts.get(key).get1()); + } + + // Check that no other nodes see this key. + for (UUID id : F.view(gridMap.keySet(), F.notEqualTo(node.id()))) - assertNull("Got value in near cache.", gridMap.get(id).cache(PARTITIONED_CACHE_NAME).peek(key)); ++ assertNull("Got value in near cache.", gridMap.get(id).jcache(PARTITIONED_CACHE_NAME).localPeek(key, CachePeekMode.ONHEAP)); + } + + for (Ignite g : gridMap.values()) - g.cache(PARTITIONED_CACHE_NAME).clear(); - } - - /** - * @param grids Collection for Grids to print affinity info. - */ - private void printAffinityState(Iterable<Ignite> grids) { - for (Ignite g : grids) { - GridAffinityAssignmentCache affCache = getFieldValue( - ((IgniteKernal)g).internalCache(PARTITIONED_CACHE_NAME).context().affinity(), - "aff"); - - CacheAffinityFunction aff = getFieldValue(affCache, "aff"); - - info("Affinity [nodeId=" + g.cluster().localNode().id() + ", affinity=" + aff + "]"); - } ++ g.jcache(PARTITIONED_CACHE_NAME).clear(); + } + + /** {@inheritDoc} */ + @Override protected long getTestTimeout() { + return 5 * 60 * 1000; + } + + /** + * Creates client that will try to connect to only first node in grid. + * + * @return Client. + */ + private GridClientConfiguration clientConfiguration() { + GridClientConfiguration cfg = new GridClientConfiguration(); + + cfg.setTopologyRefreshFrequency(topologyRefreshFrequency()); + cfg.setMaxConnectionIdleTime(maxConnectionIdleTime()); + + cfg.setProtocol(protocol()); + cfg.setServers(Arrays.asList(serverAddress())); + cfg.setBalancer(new GridClientRoundRobinBalancer()); + + if (useSsl()) + cfg.setSslContextFactory(sslContextFactory()); + + GridClientDataConfiguration loc = new GridClientDataConfiguration(); + + GridClientDataConfiguration partitioned = new GridClientDataConfiguration(); + partitioned.setName(PARTITIONED_CACHE_NAME); + partitioned.setAffinity(new GridClientPartitionAffinity()); + + GridClientDataConfiguration partitionedAsyncBackup = new GridClientDataConfiguration(); + partitionedAsyncBackup.setName(PARTITIONED_ASYNC_BACKUP_CACHE_NAME); + partitionedAsyncBackup.setAffinity(new GridClientPartitionAffinity()); + + GridClientDataConfiguration replicated = new GridClientDataConfiguration(); + replicated.setName(REPLICATED_CACHE_NAME); + + GridClientDataConfiguration replicatedAsync = new GridClientDataConfiguration(); + replicatedAsync.setName(REPLICATED_ASYNC_CACHE_NAME); + + cfg.setDataConfigurations(Arrays.asList(loc, partitioned, replicated, replicatedAsync, partitionedAsyncBackup)); + + return cfg; + } + + /** + * Test task. Returns a tuple in which first component is id of node that has split the task, + * and second component is count of nodes that executed jobs. + */ + private static class TestTask extends ComputeTaskSplitAdapter<Object, String> { + /** Injected grid. */ + @IgniteInstanceResource + private Ignite ignite; + + /** Count of tasks this job was split to. */ + private int gridSize; + + /** {@inheritDoc} */ + @Override protected Collection<? extends ComputeJob> split(int gridSize, Object arg) { + Collection<ComputeJobAdapter> jobs = new ArrayList<>(gridSize); + + this.gridSize = gridSize; + + final String locNodeId = ignite.cluster().localNode().id().toString(); + + for (int i = 0; i < gridSize; i++) { + jobs.add(new ComputeJobAdapter() { + @Override public Object execute() { + return new IgniteBiTuple<>(locNodeId, 1); + } + }); + } + + return jobs; + } + + /** {@inheritDoc} */ + @Override public String reduce(List<ComputeJobResult> results) { + int sum = 0; + + String locNodeId = null; + + for (ComputeJobResult res : results) { + IgniteBiTuple<String, Integer> part = res.getData(); + + if (locNodeId == null) + locNodeId = part.get1(); + + Integer i = part.get2(); + + if (i != null) + sum += i; + } + + assert gridSize == sum; + + return locNodeId; + } + } + } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/af231de3/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java ---------------------------------------------------------------------- diff --cc modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java index 0000000,0eefb0f..c0fc287 mode 000000,100644..100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java @@@ -1,0 -1,828 +1,828 @@@ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package org.apache.ignite.internal.client.integration; + + import org.apache.ignite.*; + import org.apache.ignite.cache.*; + import org.apache.ignite.cluster.*; + import org.apache.ignite.compute.*; + import org.apache.ignite.configuration.*; + import org.apache.ignite.internal.*; + import org.apache.ignite.internal.client.*; + import org.apache.ignite.internal.client.balancer.*; + import org.apache.ignite.internal.client.ssl.*; + import org.apache.ignite.internal.managers.communication.*; + import org.apache.ignite.internal.processors.cache.*; + import org.apache.ignite.internal.processors.cache.distributed.*; + import org.apache.ignite.internal.processors.cache.transactions.*; + import org.apache.ignite.internal.processors.cache.version.*; + import org.apache.ignite.internal.util.typedef.*; + import org.apache.ignite.lang.*; + import org.apache.ignite.plugin.extensions.communication.*; + import org.apache.ignite.resources.*; + import org.apache.ignite.spi.*; + import org.apache.ignite.spi.communication.tcp.*; + import org.apache.ignite.spi.discovery.tcp.*; + import org.apache.ignite.spi.discovery.tcp.ipfinder.*; + import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; + import org.apache.ignite.testframework.*; + import org.apache.ignite.testframework.junits.common.*; + import org.jetbrains.annotations.*; + + import java.util.*; + import java.util.concurrent.*; + import java.util.concurrent.atomic.*; + + import static java.util.concurrent.TimeUnit.*; + import static org.apache.ignite.cache.CacheAtomicityMode.*; + import static org.apache.ignite.cache.CacheDistributionMode.*; + import static org.apache.ignite.cache.CacheMode.*; + import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; + + /** + * Tests basic client behavior with multiple nodes. + */ + @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + public abstract class ClientAbstractMultiNodeSelfTest extends GridCommonAbstractTest { + /** */ + private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + + /** Partitioned cache name. */ + private static final String PARTITIONED_CACHE_NAME = "partitioned"; + + /** Replicated cache name. */ + private static final String REPLICATED_CACHE_NAME = "replicated"; + + /** Replicated async cache name. */ + private static final String REPLICATED_ASYNC_CACHE_NAME = "replicated_async"; + + /** Nodes count. */ + public static final int NODES_CNT = 5; + + /** + * Topology update frequency. + * Set it longer than router's, so we wouldn't receive failures + * caused only by obsolete topology on router. + */ + static final int TOP_REFRESH_FREQ = 2500; + + /** Path to jetty config. */ + public static final String REST_JETTY_CFG = "modules/clients/src/test/resources/jetty/rest-jetty.xml"; + + /** Path to jetty config with SSl enabled. */ + public static final String REST_JETTY_SSL_CFG = "modules/clients/src/test/resources/jetty/rest-jetty-ssl.xml"; + + /** Host. */ + public static final String HOST = "127.0.0.1"; + + /** Base for tcp rest ports. */ + public static final int REST_TCP_PORT_BASE = 12345; + + /** Base for http rest ports, defined in {@link #REST_JETTY_CFG}. */ + public static final int REST_HTTP_PORT_BASE = 11080; + + /** Base for https rest ports, defined in {@link #REST_JETTY_SSL_CFG}. */ + public static final int REST_HTTPS_PORT_BASE = 11443; + + /** */ + private static volatile boolean commSpiEnabled; + + /** Flag to enable REST in node configuration. */ + private boolean restEnabled = true; + + /** Client instance for each test. */ + private GridClient client; + + /** + * @return Client protocol that should be used. + */ + protected abstract GridClientProtocol protocol(); + + /** + * @return Server address to create first connection. + */ + protected abstract String serverAddress(); + + /** + * @return SSL context factory to use if SSL or {@code null} to disable SSL usage. + */ + @Nullable protected GridSslContextFactory sslContextFactory() { + return null; + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration c = super.getConfiguration(gridName); + + c.setLocalHost(HOST); + + assert c.getConnectorConfiguration() == null; + + if (restEnabled) { + ConnectorConfiguration clientCfg = new ConnectorConfiguration(); + + clientCfg.setPort(REST_TCP_PORT_BASE); + + GridSslContextFactory sslCtxFactory = sslContextFactory(); + + if (sslCtxFactory != null) { + clientCfg.setSslEnabled(true); + clientCfg.setSslContextFactory(sslCtxFactory); + } + + c.setConnectorConfiguration(clientCfg); + } + + TcpDiscoverySpi disco = new TcpDiscoverySpi(); + + disco.setIpFinder(IP_FINDER); + + c.setDiscoverySpi(disco); + + TestCommunicationSpi spi = new TestCommunicationSpi(); + + spi.setLocalPort(GridTestUtils.getNextCommPort(getClass())); + + c.setCommunicationSpi(spi); + + c.setCacheConfiguration(cacheConfiguration(null), cacheConfiguration(PARTITIONED_CACHE_NAME), + cacheConfiguration(REPLICATED_CACHE_NAME), cacheConfiguration(REPLICATED_ASYNC_CACHE_NAME)); + + c.setPublicThreadPoolSize(40); + + c.setSystemThreadPoolSize(40); + + return c; + } + + /** + * @param cacheName Cache name. + * @return Cache configuration. + * @throws Exception In case of error. + */ + private CacheConfiguration cacheConfiguration(@Nullable String cacheName) throws Exception { + CacheConfiguration cfg = defaultCacheConfiguration(); + + cfg.setAtomicityMode(TRANSACTIONAL); + cfg.setDistributionMode(NEAR_PARTITIONED); + + if (cacheName == null) + cfg.setCacheMode(LOCAL); + else if (PARTITIONED_CACHE_NAME.equals(cacheName)) { + cfg.setCacheMode(PARTITIONED); + + cfg.setBackups(0); + } + else + cfg.setCacheMode(REPLICATED); + + cfg.setName(cacheName); + + cfg.setWriteSynchronizationMode(REPLICATED_ASYNC_CACHE_NAME.equals(cacheName) ? FULL_ASYNC : FULL_SYNC); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + startGridsMultiThreaded(NODES_CNT); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + info("Stopping grids."); + + stopAllGrids(); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + client = GridClientFactory.start(clientConfiguration()); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + if (client != null) { + GridClientFactory.stop(client.id(), false); + + client = null; + } + } + + /** + * @throws Exception If failed. + */ + public void testSyncCommitRollbackFlags() throws Exception { + commSpiEnabled = true; + + try { + GridClientData data = client.data(REPLICATED_ASYNC_CACHE_NAME); + + info("Before put x1"); + + data.put("x1", "y1"); + + info("Before put x2"); + + data.flagsOn(GridClientCacheFlag.SYNC_COMMIT).put("x2", "y2"); + + info("Before put x3"); + + data.put("x3", "y3"); + + info("Before put x4"); + + data.flagsOn(GridClientCacheFlag.SYNC_COMMIT).put("x4", "y4"); + } + finally { + commSpiEnabled = false; + } + } + + /** + * @throws Exception If failed. + */ + public void testEmptyProjections() throws Exception { + final GridClientCompute dflt = client.compute(); + + Collection<? extends GridClientNode> nodes = dflt.nodes(); + + assertEquals(NODES_CNT, nodes.size()); + + Iterator<? extends GridClientNode> iter = nodes.iterator(); + + final GridClientCompute singleNodePrj = dflt.projection(Collections.singletonList(iter.next())); + + final GridClientNode second = iter.next(); + + final GridClientPredicate<GridClientNode> noneFilter = new GridClientPredicate<GridClientNode>() { + @Override public boolean apply(GridClientNode node) { + return false; + } + }; + + final GridClientPredicate<GridClientNode> targetFilter = new GridClientPredicate<GridClientNode>() { + @Override public boolean apply(GridClientNode node) { + return node.nodeId().equals(second.nodeId()); + } + }; + + GridTestUtils.assertThrows(log(), new Callable<Object>() { + @Override public Object call() throws Exception { + return singleNodePrj.projection(second); + } + }, GridClientException.class, null); + + GridTestUtils.assertThrows(log(), new Callable<Object>() { + @Override + public Object call() throws Exception { + return singleNodePrj.projection(targetFilter); + } + }, GridClientException.class, null); + } + + /** + * @throws Exception If failed. + */ + public void testProjectionRun() throws Exception { + GridClientCompute dflt = client.compute(); + + Collection<? extends GridClientNode> nodes = dflt.nodes(); + + assertEquals(NODES_CNT, nodes.size()); + + for (int i = 0; i < NODES_CNT; i++) { + Ignite g = grid(i); + + assert g != null; + + GridClientNode clientNode = dflt.node(g.cluster().localNode().id()); + + assertNotNull("Client node for " + g.cluster().localNode().id() + " was not found", clientNode); + + GridClientCompute prj = dflt.projection(clientNode); + + String res = prj.execute(TestTask.class.getName(), null); + + assertNotNull(res); + + assertEquals(g.cluster().localNode().id().toString(), res); + } + } + + /** + * @throws Exception If failed. + */ + public void testAffinityExecute() throws Exception { + GridClientCompute dflt = client.compute(); + + GridClientData data = client.data(PARTITIONED_CACHE_NAME); + + Collection<? extends GridClientNode> nodes = dflt.nodes(); + + assertEquals(NODES_CNT, nodes.size()); + + for (int i = 0; i < NODES_CNT; i++) { + Ignite g = grid(i); + + assert g != null; + + int affinityKey = -1; + + for (int key = 0; key < 10000; key++) { + if (g.cluster().localNode().id().equals(data.affinity(key))) { + affinityKey = key; + + break; + } + } + + if (affinityKey == -1) + throw new Exception("Unable to found key for which node is primary: " + g.cluster().localNode().id()); + + GridClientNode clientNode = dflt.node(g.cluster().localNode().id()); + + assertNotNull("Client node for " + g.cluster().localNode().id() + " was not found", clientNode); + + String res = dflt.affinityExecute(TestTask.class.getName(), PARTITIONED_CACHE_NAME, affinityKey, null); + + assertNotNull(res); + + assertEquals(g.cluster().localNode().id().toString(), res); + } + } + + /** + * @throws Exception If failed. + */ + public void testInvalidateFlag() throws Exception { + IgniteEx g0 = grid(0); + - GridCache<String, String> cache = g0.cache(PARTITIONED_CACHE_NAME); ++ IgniteCache<String, String> cache = g0.jcache(PARTITIONED_CACHE_NAME); + + String key = null; + + for (int i = 0; i < 10_000; i++) { - if (!cache.affinity().isPrimaryOrBackup(g0.localNode(), String.valueOf(i))) { ++ if (!affinity(cache).isPrimaryOrBackup(g0.localNode(), String.valueOf(i))) { + key = String.valueOf(i); + + break; + } + } + + assertNotNull(key); + + cache.put(key, key); // Create entry in near cache, it is invalidated if INVALIDATE flag is set. + - assertNotNull(cache.peek(key)); ++ assertNotNull(cache.localPeek(key, CachePeekMode.ONHEAP)); + + GridClientData d = client.data(PARTITIONED_CACHE_NAME); + + d.flagsOn(GridClientCacheFlag.INVALIDATE).put(key, "zzz"); + + for (Ignite g : G.allGrids()) { - cache = g.cache(PARTITIONED_CACHE_NAME); ++ cache = g.jcache(PARTITIONED_CACHE_NAME); + - if (cache.affinity().isPrimaryOrBackup(g.cluster().localNode(), key)) - assertEquals("zzz", cache.peek(key)); ++ if (affinity(cache).isPrimaryOrBackup(g.cluster().localNode(), key)) ++ assertEquals("zzz", cache.localPeek(key, CachePeekMode.ONHEAP)); + else - assertNull(cache.peek(key)); ++ assertNull(cache.localPeek(key, CachePeekMode.ONHEAP)); + } + } + + /** + * @throws Exception If failed. + */ + public void testClientAffinity() throws Exception { + GridClientData partitioned = client.data(PARTITIONED_CACHE_NAME); + + Collection<Object> keys = new ArrayList<>(); + + keys.addAll(Arrays.asList( + Boolean.TRUE, + Boolean.FALSE, + 1, + Integer.MAX_VALUE + )); + + Random rnd = new Random(); + StringBuilder sb = new StringBuilder(); + + // Generate some random strings. + for (int i = 0; i < 100; i++) { + sb.setLength(0); + + for (int j = 0; j < 255; j++) + // Only printable ASCII symbols for test. + sb.append((char)(rnd.nextInt(0x7f - 0x20) + 0x20)); + + keys.add(sb.toString()); + } + + // Generate some more keys to achieve better coverage. + for (int i = 0; i < 100; i++) + keys.add(UUID.randomUUID()); + + for (Object key : keys) { + UUID nodeId = grid(0).mapKeyToNode(PARTITIONED_CACHE_NAME, key).id(); + + UUID clientNodeId = partitioned.affinity(key); + + assertEquals("Invalid affinity mapping for REST response for key: " + key, nodeId, clientNodeId); + } + } + + /** + * @throws Exception If failed. + */ + public void testTopologyListener() throws Exception { + final Collection<UUID> added = new ArrayList<>(1); + final Collection<UUID> rmvd = new ArrayList<>(1); + + final CountDownLatch addedLatch = new CountDownLatch(1); + final CountDownLatch rmvLatch = new CountDownLatch(1); + + assertEquals(NODES_CNT, client.compute().refreshTopology(false, false).size()); + + GridClientTopologyListener lsnr = new GridClientTopologyListener() { + @Override public void onNodeAdded(GridClientNode node) { + added.add(node.nodeId()); + + addedLatch.countDown(); + } + + @Override public void onNodeRemoved(GridClientNode node) { + rmvd.add(node.nodeId()); + + rmvLatch.countDown(); + } + }; + + client.addTopologyListener(lsnr); + + try { + Ignite g = startGrid(NODES_CNT + 1); + + UUID id = g.cluster().localNode().id(); + + assertTrue(addedLatch.await(2 * TOP_REFRESH_FREQ, MILLISECONDS)); + + assertEquals(1, added.size()); + assertEquals(id, F.first(added)); + + stopGrid(NODES_CNT + 1); + + assertTrue(rmvLatch.await(2 * TOP_REFRESH_FREQ, MILLISECONDS)); + + assertEquals(1, rmvd.size()); + assertEquals(id, F.first(rmvd)); + } + finally { + client.removeTopologyListener(lsnr); + + stopGrid(NODES_CNT + 1); + } + } + + /** + * @throws Exception If failed. + */ + public void testDisabledRest() throws Exception { + restEnabled = false; + + final Ignite g = startGrid("disabled-rest"); + + try { + Thread.sleep(2 * TOP_REFRESH_FREQ); + + // As long as we have round robin load balancer this will cause every node to be queried. + for (int i = 0; i < NODES_CNT + 1; i++) + assertEquals(NODES_CNT + 1, client.compute().refreshTopology(false, false).size()); + + final GridClientData data = client.data(PARTITIONED_CACHE_NAME); + + // Check rest-disabled node is unavailable. + try { + String affKey; + + do { + affKey = UUID.randomUUID().toString(); + } while (!data.affinity(affKey).equals(g.cluster().localNode().id())); + + data.put(affKey, "asdf"); + + assertEquals("asdf", cache(0, PARTITIONED_CACHE_NAME).get(affKey)); + } + catch (GridServerUnreachableException e) { + // Thrown for direct client-node connections. + assertTrue("Unexpected exception message: " + e.getMessage(), + e.getMessage().startsWith("No available endpoints to connect (is rest enabled for this node?)")); + } + catch (GridClientException e) { + // Thrown for routed client-router-node connections. + String msg = e.getMessage(); + + assertTrue("Unexpected exception message: " + msg, protocol() == GridClientProtocol.TCP ? + msg.contains("No available endpoints to connect (is rest enabled for this node?)") : // TCP router. + msg.startsWith("No available nodes on the router for destination node ID")); // HTTP router. + } + + // Check rest-enabled nodes are available. + String affKey; + + do { + affKey = UUID.randomUUID().toString(); + } while (data.affinity(affKey).equals(g.cluster().localNode().id())); + + data.put(affKey, "fdsa"); + + assertEquals("fdsa", cache(0, PARTITIONED_CACHE_NAME).get(affKey)); + } + finally { + restEnabled = true; + + G.stop(g.name(), true); + } + } + + /** + * @throws Exception If failed. + */ + public void testAffinityPut() throws Exception { + Thread.sleep(2 * TOP_REFRESH_FREQ); + + assertEquals(NODES_CNT, client.compute().refreshTopology(false, false).size()); + + Map<UUID, Ignite> gridsByLocNode = new HashMap<>(NODES_CNT); + + GridClientData partitioned = client.data(PARTITIONED_CACHE_NAME); + + GridClientCompute compute = client.compute(); + + for (int i = 0; i < NODES_CNT; i++) + gridsByLocNode.put(grid(i).localNode().id(), grid(i)); + + for (int i = 0; i < 100; i++) { + String key = "key" + i; + + UUID primaryNodeId = grid(0).mapKeyToNode(PARTITIONED_CACHE_NAME, key).id(); + + assertEquals("Affinity mismatch for key: " + key, primaryNodeId, partitioned.affinity(key)); + + assertEquals(primaryNodeId, partitioned.affinity(key)); + + // Must go to primary node only. Since backup count is 0, value must present on + // primary node only. + partitioned.put(key, "val" + key); + + for (Map.Entry<UUID, Ignite> entry : gridsByLocNode.entrySet()) { - Object val = entry.getValue().cache(PARTITIONED_CACHE_NAME).peek(key); ++ Object val = entry.getValue().jcache(PARTITIONED_CACHE_NAME).localPeek(key, CachePeekMode.ONHEAP); + + if (primaryNodeId.equals(entry.getKey())) + assertEquals("val" + key, val); + else + assertNull(val); + } + } + + // Now check that we will see value in near cache in pinned mode. + for (int i = 100; i < 200; i++) { + String pinnedKey = "key" + i; + + UUID primaryNodeId = grid(0).mapKeyToNode(PARTITIONED_CACHE_NAME, pinnedKey).id(); + + UUID pinnedNodeId = F.first(F.view(gridsByLocNode.keySet(), F.notEqualTo(primaryNodeId))); + + GridClientNode node = compute.node(pinnedNodeId); + + partitioned.pinNodes(node).put(pinnedKey, "val" + pinnedKey); + + for (Map.Entry<UUID, Ignite> entry : gridsByLocNode.entrySet()) { - Object val = entry.getValue().cache(PARTITIONED_CACHE_NAME).peek(pinnedKey); ++ Object val = entry.getValue().jcache(PARTITIONED_CACHE_NAME).localPeek(pinnedKey, CachePeekMode.ONHEAP); + + if (primaryNodeId.equals(entry.getKey()) || pinnedNodeId.equals(entry.getKey())) + assertEquals("val" + pinnedKey, val); + else + assertNull(val); + } + } + } + + /** + * @return Client configuration for the test. + */ + protected GridClientConfiguration clientConfiguration() throws GridClientException { + GridClientConfiguration cfg = new GridClientConfiguration(); + + cfg.setBalancer(getBalancer()); + + cfg.setTopologyRefreshFrequency(TOP_REFRESH_FREQ); + + cfg.setProtocol(protocol()); + cfg.setServers(Arrays.asList(serverAddress())); + cfg.setSslContextFactory(sslContextFactory()); + + GridClientDataConfiguration loc = new GridClientDataConfiguration(); + + GridClientDataConfiguration partitioned = new GridClientDataConfiguration(); + + partitioned.setName(PARTITIONED_CACHE_NAME); + partitioned.setAffinity(new GridClientPartitionAffinity()); + + GridClientDataConfiguration replicated = new GridClientDataConfiguration(); + replicated.setName(REPLICATED_CACHE_NAME); + + GridClientDataConfiguration replicatedAsync = new GridClientDataConfiguration(); + replicatedAsync.setName(REPLICATED_ASYNC_CACHE_NAME); + + cfg.setDataConfigurations(Arrays.asList(loc, partitioned, replicated, replicatedAsync)); + + return cfg; + } + + /** + * Gets client load balancer. + * + * @return Load balancer. + */ + protected GridClientLoadBalancer getBalancer() { + return new GridClientRoundRobinBalancer(); + } + + /** + * Test task. Returns a tuple in which first component is id of node that has split the task, + * and second component is count of nodes that executed jobs. + */ + private static class TestTask extends ComputeTaskSplitAdapter<Object, String> { + /** */ + @IgniteInstanceResource + private Ignite ignite; + + /** Count of tasks this job was split to. */ + private int gridSize; + + /** {@inheritDoc} */ + @Override protected Collection<? extends ComputeJob> split(int gridSize, Object arg) { + Collection<ComputeJobAdapter> jobs = new ArrayList<>(gridSize); + + this.gridSize = gridSize; + + final String locNodeId = ignite.cluster().localNode().id().toString(); + + for (int i = 0; i < gridSize; i++) { + jobs.add(new ComputeJobAdapter() { + @SuppressWarnings("OverlyStrongTypeCast") + @Override public Object execute() { + try { + Thread.sleep(1000); + } + catch (InterruptedException ignored) { + Thread.currentThread().interrupt(); + } + + return new IgniteBiTuple<>(locNodeId, 1); + } + }); + } + + return jobs; + } + + /** {@inheritDoc} */ + @Override public String reduce(List<ComputeJobResult> results) { + int sum = 0; + + String locNodeId = null; + + for (ComputeJobResult res : results) { + IgniteBiTuple<String, Integer> part = res.getData(); + + if (locNodeId == null) + locNodeId = part.get1(); + + Integer i = part.get2(); + + if (i != null) + sum += i; + } + + assert gridSize == sum; + + return locNodeId; + } + } + + /** + * Communication SPI which checks cache flags. + */ + @SuppressWarnings("unchecked") + private static class TestCommunicationSpi extends TcpCommunicationSpi { + /** {@inheritDoc} */ + @Override public void sendMessage(ClusterNode node, MessageAdapter msg) + throws IgniteSpiException { + checkSyncFlags((GridIoMessage)msg); + + super.sendMessage(node, msg); + } + + /** + * Check if flags in correct state. + * + * @param msg Message. + */ + private void checkSyncFlags(GridIoMessage msg) { + if (!commSpiEnabled) + return; + + Object o = msg.message(); + + if (!(o instanceof GridDistributedLockRequest)) + return; + + IgniteKernal g = (IgniteKernal)G.ignite(ignite.configuration().getNodeId()); + + GridCacheContext<Object, Object> cacheCtx = g.internalCache(REPLICATED_ASYNC_CACHE_NAME).context(); + + IgniteTxManager<Object, Object> tm = cacheCtx.tm(); + + GridCacheVersion v = ((GridCacheVersionable)o).version(); + + IgniteInternalTx t = tm.tx(v); + + if (t.hasWriteKey(cacheCtx.txKey("x1"))) + assertFalse("Invalid tx flags: " + t, t.syncCommit()); + else if (t.hasWriteKey(cacheCtx.txKey("x2"))) + assertTrue("Invalid tx flags: " + t, t.syncCommit()); + else if (t.hasWriteKey(cacheCtx.txKey("x3"))) + assertFalse("Invalid tx flags: " + t, t.syncCommit()); + else if (t.hasWriteKey(cacheCtx.txKey("x4"))) + assertTrue("Invalid tx flags: " + t, t.syncCommit()); + } + } + + /** + * @throws Exception If failed. + */ + public void testMultithreadedCommand() throws Exception { + final GridClientData data = client.data(PARTITIONED_CACHE_NAME); + final GridClientCompute compute = client.compute(); + final AtomicInteger cnt = new AtomicInteger(0); + + multithreaded(new Callable<Object>() { + @Override public Object call() throws Exception { + for (int i = 0; i < 20; i++) { + String key = UUID.randomUUID().toString(); + String val = UUID.randomUUID().toString(); + + switch (cnt.incrementAndGet() % 4) { + case 0: { + assertTrue(data.put(key, val)); + assertEquals(val, data.get(key)); + assertTrue(data.remove(key)); + + break; + } + + case 1: { + assertNotNull(data.metrics()); + + break; + } + + case 2: { + String nodeId = compute.execute(TestTask.class.getName(), null); + + assertNotNull(nodeId); + assertNotNull(compute.refreshNode(UUID.fromString(nodeId), true, true)); + + break; + } + + case 3: { + assertEquals(NODES_CNT, compute.refreshTopology(true, true).size()); + + break; + } + } + } + + return null; + } + }, 50, "multithreaded-client-access"); + } + }