You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/10/13 09:00:20 UTC
[01/34] ignite git commit: 1.4.1-SNAPSHOT
Repository: ignite
Updated Branches:
refs/heads/ignite-1607 3b7c71d88 -> 775dba2f9
1.4.1-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e5e72ea0
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e5e72ea0
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e5e72ea0
Branch: refs/heads/ignite-1607
Commit: e5e72ea0e0951af9200dc81e3b69a02c961ee2c2
Parents: a2c972b
Author: Ignite Teamcity <ig...@apache.org>
Authored: Thu Sep 24 18:57:10 2015 +0300
Committer: Ignite Teamcity <ig...@apache.org>
Committed: Thu Sep 24 18:57:10 2015 +0300
----------------------------------------------------------------------
examples/pom.xml | 2 +-
examples/schema-import/pom.xml | 2 +-
modules/aop/pom.xml | 2 +-
modules/apache-license-gen/pom.xml | 2 +-
modules/aws/pom.xml | 2 +-
modules/clients/pom.xml | 2 +-
modules/cloud/pom.xml | 2 +-
modules/codegen/pom.xml | 2 +-
modules/core/pom.xml | 2 +-
modules/core/src/main/resources/ignite.properties | 2 +-
modules/extdata/p2p/pom.xml | 2 +-
modules/extdata/uri/modules/uri-dependency/pom.xml | 2 +-
modules/extdata/uri/pom.xml | 2 +-
modules/gce/pom.xml | 2 +-
modules/geospatial/pom.xml | 2 +-
modules/hadoop/pom.xml | 2 +-
modules/hibernate/pom.xml | 2 +-
modules/indexing/pom.xml | 2 +-
modules/jcl/pom.xml | 2 +-
modules/jms11/pom.xml | 2 +-
modules/jta/pom.xml | 2 +-
modules/kafka/pom.xml | 2 +-
modules/log4j/pom.xml | 2 +-
modules/log4j2/pom.xml | 2 +-
modules/mesos/pom.xml | 2 +-
modules/platform/pom.xml | 2 +-
modules/platform/src/main/cpp/common/configure.ac | 2 +-
modules/platform/src/main/cpp/core-test/configure.ac | 2 +-
modules/platform/src/main/cpp/core/configure.ac | 2 +-
.../main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs | 4 ++--
.../src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs | 4 ++--
.../Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs | 4 ++--
.../dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs | 4 ++--
modules/rest-http/pom.xml | 2 +-
modules/scalar-2.10/pom.xml | 2 +-
modules/scalar/pom.xml | 2 +-
modules/schedule/pom.xml | 2 +-
modules/schema-import/pom.xml | 2 +-
modules/slf4j/pom.xml | 2 +-
modules/spark-2.10/pom.xml | 2 +-
modules/spark/pom.xml | 2 +-
modules/spring/pom.xml | 2 +-
modules/ssh/pom.xml | 2 +-
modules/tools/pom.xml | 2 +-
modules/urideploy/pom.xml | 2 +-
modules/visor-console-2.10/pom.xml | 2 +-
modules/visor-console/pom.xml | 2 +-
modules/visor-plugins/pom.xml | 2 +-
modules/web/pom.xml | 2 +-
modules/yardstick/pom.xml | 2 +-
modules/yarn/pom.xml | 2 +-
modules/zookeeper/pom.xml | 2 +-
pom.xml | 2 +-
53 files changed, 57 insertions(+), 57 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index 64e8be9..a2ac452 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -28,7 +28,7 @@
</parent>
<artifactId>ignite-examples</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/examples/schema-import/pom.xml
----------------------------------------------------------------------
diff --git a/examples/schema-import/pom.xml b/examples/schema-import/pom.xml
index f51007a..05de048 100644
--- a/examples/schema-import/pom.xml
+++ b/examples/schema-import/pom.xml
@@ -35,7 +35,7 @@
</properties>
<artifactId>ignite-schema-import-demo</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/aop/pom.xml
----------------------------------------------------------------------
diff --git a/modules/aop/pom.xml b/modules/aop/pom.xml
index 391f5b8..a080b57 100644
--- a/modules/aop/pom.xml
+++ b/modules/aop/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-aop</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/apache-license-gen/pom.xml
----------------------------------------------------------------------
diff --git a/modules/apache-license-gen/pom.xml b/modules/apache-license-gen/pom.xml
index c17f98f..1af8c00 100644
--- a/modules/apache-license-gen/pom.xml
+++ b/modules/apache-license-gen/pom.xml
@@ -31,7 +31,7 @@
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-apache-license-gen</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<build>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/aws/pom.xml
----------------------------------------------------------------------
diff --git a/modules/aws/pom.xml b/modules/aws/pom.xml
index a0ca6b0..63d454d 100644
--- a/modules/aws/pom.xml
+++ b/modules/aws/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-aws</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/clients/pom.xml
----------------------------------------------------------------------
diff --git a/modules/clients/pom.xml b/modules/clients/pom.xml
index 6e690dc..74590ec 100644
--- a/modules/clients/pom.xml
+++ b/modules/clients/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-clients</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/cloud/pom.xml
----------------------------------------------------------------------
diff --git a/modules/cloud/pom.xml b/modules/cloud/pom.xml
index b7aa43b..e735804 100644
--- a/modules/cloud/pom.xml
+++ b/modules/cloud/pom.xml
@@ -29,7 +29,7 @@
</parent>
<artifactId>ignite-cloud</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<properties>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/codegen/pom.xml
----------------------------------------------------------------------
diff --git a/modules/codegen/pom.xml b/modules/codegen/pom.xml
index 89cadf5..a39da2f 100644
--- a/modules/codegen/pom.xml
+++ b/modules/codegen/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-codegen</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<properties>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index 9162afe..13d6fd4 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-core</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<properties>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/core/src/main/resources/ignite.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/ignite.properties b/modules/core/src/main/resources/ignite.properties
index 50725fa..c1c2d0f 100644
--- a/modules/core/src/main/resources/ignite.properties
+++ b/modules/core/src/main/resources/ignite.properties
@@ -15,7 +15,7 @@
# limitations under the License.
#
-ignite.version=1.4.0-SNAPSHOT
+ignite.version=1.4.1-SNAPSHOT
ignite.build=0
ignite.revision=DEV
ignite.rel.date=01011970
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/extdata/p2p/pom.xml
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/pom.xml b/modules/extdata/p2p/pom.xml
index aca3132..b48859b 100644
--- a/modules/extdata/p2p/pom.xml
+++ b/modules/extdata/p2p/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-extdata-p2p</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/extdata/uri/modules/uri-dependency/pom.xml
----------------------------------------------------------------------
diff --git a/modules/extdata/uri/modules/uri-dependency/pom.xml b/modules/extdata/uri/modules/uri-dependency/pom.xml
index 98d3fcf..f863bed 100644
--- a/modules/extdata/uri/modules/uri-dependency/pom.xml
+++ b/modules/extdata/uri/modules/uri-dependency/pom.xml
@@ -27,7 +27,7 @@
<artifactId>ignite-extdata-uri-dep</artifactId>
<packaging>jar</packaging>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/extdata/uri/pom.xml
----------------------------------------------------------------------
diff --git a/modules/extdata/uri/pom.xml b/modules/extdata/uri/pom.xml
index 7613f0c..0b4f92f 100644
--- a/modules/extdata/uri/pom.xml
+++ b/modules/extdata/uri/pom.xml
@@ -32,7 +32,7 @@
</parent>
<artifactId>ignite-extdata-uri</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/gce/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gce/pom.xml b/modules/gce/pom.xml
index 05f043f..b3fbb32 100644
--- a/modules/gce/pom.xml
+++ b/modules/gce/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-gce</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/geospatial/pom.xml
----------------------------------------------------------------------
diff --git a/modules/geospatial/pom.xml b/modules/geospatial/pom.xml
index 766114b..1330cf5 100644
--- a/modules/geospatial/pom.xml
+++ b/modules/geospatial/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-geospatial</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hadoop/pom.xml b/modules/hadoop/pom.xml
index 839ffb8..9fdfd99 100644
--- a/modules/hadoop/pom.xml
+++ b/modules/hadoop/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-hadoop</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/hibernate/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate/pom.xml b/modules/hibernate/pom.xml
index a3ae729..2d6d893 100644
--- a/modules/hibernate/pom.xml
+++ b/modules/hibernate/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-hibernate</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/indexing/pom.xml
----------------------------------------------------------------------
diff --git a/modules/indexing/pom.xml b/modules/indexing/pom.xml
index e4713b4..4bcadc8 100644
--- a/modules/indexing/pom.xml
+++ b/modules/indexing/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-indexing</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/jcl/pom.xml
----------------------------------------------------------------------
diff --git a/modules/jcl/pom.xml b/modules/jcl/pom.xml
index 335b6c8..0b2c48b 100644
--- a/modules/jcl/pom.xml
+++ b/modules/jcl/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-jcl</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/jms11/pom.xml
----------------------------------------------------------------------
diff --git a/modules/jms11/pom.xml b/modules/jms11/pom.xml
index dbb385d..1b8f67d 100644
--- a/modules/jms11/pom.xml
+++ b/modules/jms11/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-jms11</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<properties>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/jta/pom.xml
----------------------------------------------------------------------
diff --git a/modules/jta/pom.xml b/modules/jta/pom.xml
index c0ce618..7965dd9 100644
--- a/modules/jta/pom.xml
+++ b/modules/jta/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-jta</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/kafka/pom.xml
----------------------------------------------------------------------
diff --git a/modules/kafka/pom.xml b/modules/kafka/pom.xml
index 5103a32..ed192ab 100644
--- a/modules/kafka/pom.xml
+++ b/modules/kafka/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-kafka</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/log4j/pom.xml
----------------------------------------------------------------------
diff --git a/modules/log4j/pom.xml b/modules/log4j/pom.xml
index aaf1dca..c3c4a84 100644
--- a/modules/log4j/pom.xml
+++ b/modules/log4j/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-log4j</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/log4j2/pom.xml
----------------------------------------------------------------------
diff --git a/modules/log4j2/pom.xml b/modules/log4j2/pom.xml
index 2c0fd94..0628b47 100644
--- a/modules/log4j2/pom.xml
+++ b/modules/log4j2/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-log4j2</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/mesos/pom.xml
----------------------------------------------------------------------
diff --git a/modules/mesos/pom.xml b/modules/mesos/pom.xml
index a652b60..07bd13d 100644
--- a/modules/mesos/pom.xml
+++ b/modules/mesos/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-mesos</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<properties>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/platform/pom.xml
----------------------------------------------------------------------
diff --git a/modules/platform/pom.xml b/modules/platform/pom.xml
index ba5b9d0..f18b05b 100644
--- a/modules/platform/pom.xml
+++ b/modules/platform/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-platform</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/platform/src/main/cpp/common/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/configure.ac b/modules/platform/src/main/cpp/common/configure.ac
index b34d7d8..3f7c8a2 100644
--- a/modules/platform/src/main/cpp/common/configure.ac
+++ b/modules/platform/src/main/cpp/common/configure.ac
@@ -19,7 +19,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
-AC_INIT([Apache Ignite JNI bridge for C++], [1.4.0], [dev@ignite.apache.org], [ignite-common], [ignite.apache.org])
+AC_INIT([Apache Ignite JNI bridge for C++], [1.4.1], [dev@ignite.apache.org], [ignite-common], [ignite.apache.org])
AC_CONFIG_SRCDIR(src)
AC_CANONICAL_SYSTEM
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/platform/src/main/cpp/core-test/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/configure.ac b/modules/platform/src/main/cpp/core-test/configure.ac
index 3a1b660..c72e6bd 100644
--- a/modules/platform/src/main/cpp/core-test/configure.ac
+++ b/modules/platform/src/main/cpp/core-test/configure.ac
@@ -19,7 +19,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
-AC_INIT([Apache Ignite C++ Test], [1.4.0], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
+AC_INIT([Apache Ignite C++ Test], [1.4.1], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
AC_CONFIG_SRCDIR(src)
AC_CANONICAL_SYSTEM
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/platform/src/main/cpp/core/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/configure.ac b/modules/platform/src/main/cpp/core/configure.ac
index cdd238f..4a3a03a 100644
--- a/modules/platform/src/main/cpp/core/configure.ac
+++ b/modules/platform/src/main/cpp/core/configure.ac
@@ -19,7 +19,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
-AC_INIT([Apache Ignite C++], [1.4.0], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
+AC_INIT([Apache Ignite C++], [1.4.1], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
AC_CONFIG_SRCDIR(src)
AC_CANONICAL_SYSTEM
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
index 5f2c018..8e653e3 100644
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
@@ -33,8 +33,8 @@ using System.Runtime.InteropServices;
[assembly: Guid("97db45a8-f922-456a-a819-7b3c6e5e03ba")]
-[assembly: AssemblyVersion("1.4.0")]
-[assembly: AssemblyFileVersion("1.4.0")]
+[assembly: AssemblyVersion("1.4.1")]
+[assembly: AssemblyFileVersion("1.4.1")]
[assembly: CLSCompliant(true)]
[assembly: InternalsVisibleTo("Apache.Ignite")]
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs b/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
index ca38ea2..7cf47c3 100644
--- a/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
[assembly: Guid("0f9702ec-da7d-4ce5-b4b7-73310c885355")]
-[assembly: AssemblyVersion("1.4.0")]
-[assembly: AssemblyFileVersion("1.4.0")]
\ No newline at end of file
+[assembly: AssemblyVersion("1.4.1")]
+[assembly: AssemblyFileVersion("1.4.1")]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
index cb633ed..ba4b794 100644
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
@@ -45,5 +45,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.4.0")]
-[assembly: AssemblyFileVersion("1.4.0")]
+[assembly: AssemblyVersion("1.4.1")]
+[assembly: AssemblyFileVersion("1.4.1")]
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
index 947e18c..f474b03 100644
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
[assembly: Guid("de8dd5cc-7c7f-4a09-80d5-7086d9416a7b")]
-[assembly: AssemblyVersion("1.4.0")]
-[assembly: AssemblyFileVersion("1.4.0")]
\ No newline at end of file
+[assembly: AssemblyVersion("1.4.1")]
+[assembly: AssemblyFileVersion("1.4.1")]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/rest-http/pom.xml
----------------------------------------------------------------------
diff --git a/modules/rest-http/pom.xml b/modules/rest-http/pom.xml
index c506df6..8156887 100644
--- a/modules/rest-http/pom.xml
+++ b/modules/rest-http/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-rest-http</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/scalar-2.10/pom.xml
----------------------------------------------------------------------
diff --git a/modules/scalar-2.10/pom.xml b/modules/scalar-2.10/pom.xml
index 627f2b4..42fb9b9 100644
--- a/modules/scalar-2.10/pom.xml
+++ b/modules/scalar-2.10/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-scalar_2.10</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/scalar/pom.xml
----------------------------------------------------------------------
diff --git a/modules/scalar/pom.xml b/modules/scalar/pom.xml
index ab03a5d..982fcaf 100644
--- a/modules/scalar/pom.xml
+++ b/modules/scalar/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-scalar</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/schedule/pom.xml
----------------------------------------------------------------------
diff --git a/modules/schedule/pom.xml b/modules/schedule/pom.xml
index 207a97c..e64059a 100644
--- a/modules/schedule/pom.xml
+++ b/modules/schedule/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-schedule</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/schema-import/pom.xml
----------------------------------------------------------------------
diff --git a/modules/schema-import/pom.xml b/modules/schema-import/pom.xml
index ef36af9..0ba8597 100644
--- a/modules/schema-import/pom.xml
+++ b/modules/schema-import/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-schema-import</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/slf4j/pom.xml
----------------------------------------------------------------------
diff --git a/modules/slf4j/pom.xml b/modules/slf4j/pom.xml
index 807ed0d..5cdf791 100644
--- a/modules/slf4j/pom.xml
+++ b/modules/slf4j/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-slf4j</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/spark-2.10/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spark-2.10/pom.xml b/modules/spark-2.10/pom.xml
index 283855e..6c44006 100644
--- a/modules/spark-2.10/pom.xml
+++ b/modules/spark-2.10/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-spark_2.10</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/spark/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spark/pom.xml b/modules/spark/pom.xml
index f7b2110..1fb2753 100644
--- a/modules/spark/pom.xml
+++ b/modules/spark/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-spark</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/spring/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spring/pom.xml b/modules/spring/pom.xml
index bf093ef..4ed1fd7 100644
--- a/modules/spring/pom.xml
+++ b/modules/spring/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-spring</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/ssh/pom.xml
----------------------------------------------------------------------
diff --git a/modules/ssh/pom.xml b/modules/ssh/pom.xml
index 5b407ad..7922f53 100644
--- a/modules/ssh/pom.xml
+++ b/modules/ssh/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-ssh</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/tools/pom.xml
----------------------------------------------------------------------
diff --git a/modules/tools/pom.xml b/modules/tools/pom.xml
index ca0d0f4..5e3465e 100644
--- a/modules/tools/pom.xml
+++ b/modules/tools/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-tools</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<properties>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/urideploy/pom.xml
----------------------------------------------------------------------
diff --git a/modules/urideploy/pom.xml b/modules/urideploy/pom.xml
index df2b0fa..7dd0431 100644
--- a/modules/urideploy/pom.xml
+++ b/modules/urideploy/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-urideploy</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/visor-console-2.10/pom.xml
----------------------------------------------------------------------
diff --git a/modules/visor-console-2.10/pom.xml b/modules/visor-console-2.10/pom.xml
index fa541dc..a0edeaf 100644
--- a/modules/visor-console-2.10/pom.xml
+++ b/modules/visor-console-2.10/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-visor-console_2.10</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/visor-console/pom.xml
----------------------------------------------------------------------
diff --git a/modules/visor-console/pom.xml b/modules/visor-console/pom.xml
index dc841bf..d6f373a 100644
--- a/modules/visor-console/pom.xml
+++ b/modules/visor-console/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-visor-console</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/visor-plugins/pom.xml
----------------------------------------------------------------------
diff --git a/modules/visor-plugins/pom.xml b/modules/visor-plugins/pom.xml
index c0e5b5e..04142fa 100644
--- a/modules/visor-plugins/pom.xml
+++ b/modules/visor-plugins/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-visor-plugins</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/web/pom.xml
----------------------------------------------------------------------
diff --git a/modules/web/pom.xml b/modules/web/pom.xml
index d814f47..4432d81 100644
--- a/modules/web/pom.xml
+++ b/modules/web/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-web</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/yardstick/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/pom.xml b/modules/yardstick/pom.xml
index eda9429..3f3774a 100644
--- a/modules/yardstick/pom.xml
+++ b/modules/yardstick/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-yardstick</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<properties>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/yarn/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yarn/pom.xml b/modules/yarn/pom.xml
index c93efa4..079a173 100644
--- a/modules/yarn/pom.xml
+++ b/modules/yarn/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-yarn</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<properties>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/modules/zookeeper/pom.xml
----------------------------------------------------------------------
diff --git a/modules/zookeeper/pom.xml b/modules/zookeeper/pom.xml
index 3993bd5..ba10101 100644
--- a/modules/zookeeper/pom.xml
+++ b/modules/zookeeper/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-zookeeper</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<url>http://ignite.apache.org</url>
<properties>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e5e72ea0/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 6ddc443..191ed3b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,7 @@
<groupId>org.apache.ignite</groupId>
<artifactId>apache-ignite</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
[30/34] ignite git commit: ignite-1.4.2 - review and minor changes.
Posted by sb...@apache.org.
ignite-1.4.2 - review and minor changes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/94f549f2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/94f549f2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/94f549f2
Branch: refs/heads/ignite-1607
Commit: 94f549f2ff03c5f1f3eca29eb337eabf7d566cad
Parents: 155edd8
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Oct 12 13:32:36 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Oct 12 13:32:36 2015 +0300
----------------------------------------------------------------------
.../discovery/GridDiscoveryManager.java | 479 +------------------
.../processors/cache/GridCacheProcessor.java | 40 --
.../cache/query/GridCacheQueryManager.java | 41 --
.../processors/rest/GridRestProcessor.java | 47 --
.../top/GridTopologyCommandHandler.java | 129 -----
5 files changed, 1 insertion(+), 735 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/94f549f2/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 9e54f6f..6aba211 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -2842,484 +2842,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
}
}
- /** Cache for discovery collections. */
- private class DiscoCache {
- /** Remote nodes. */
- private final List<ClusterNode> rmtNodes;
-
- /** All nodes. */
- private final List<ClusterNode> allNodes;
-
- /** All nodes with at least one cache configured. */
- @GridToStringInclude
- private final Collection<ClusterNode> allNodesWithCaches;
-
- /** All nodes with at least one cache configured. */
- @GridToStringInclude
- private final Collection<ClusterNode> rmtNodesWithCaches;
-
- /** Cache nodes by cache name. */
- @GridToStringInclude
- private final Map<String, Collection<ClusterNode>> allCacheNodes;
-
- /** Remote cache nodes by cache name. */
- @GridToStringInclude
- private final Map<String, Collection<ClusterNode>> rmtCacheNodes;
-
- /** Cache nodes by cache name. */
- @GridToStringInclude
- private final Map<String, Collection<ClusterNode>> affCacheNodes;
-
- /** Caches where at least one node has near cache enabled. */
- @GridToStringInclude
- private final Set<String> nearEnabledCaches;
-
- /** Nodes grouped by version. */
- private final NavigableMap<IgniteProductVersion, Collection<ClusterNode>> nodesByVer;
-
- /** Daemon nodes. */
- private final List<ClusterNode> daemonNodes;
-
- /** Node map. */
- private final Map<UUID, ClusterNode> nodeMap;
-
- /** Local node. */
- private final ClusterNode loc;
-
- /** Highest node order. */
- private final long maxOrder;
-
- /**
- * Cached alive nodes list. As long as this collection doesn't accept {@code null}s use {@link
- * #maskNull(String)} before passing raw cache names to it.
- */
- private final ConcurrentMap<String, Collection<ClusterNode>> aliveCacheNodes;
-
- /**
- * Cached alive remote nodes list. As long as this collection doesn't accept {@code null}s use {@link
- * #maskNull(String)} before passing raw cache names to it.
- */
- private final ConcurrentMap<String, Collection<ClusterNode>> aliveRmtCacheNodes;
-
- /**
- * Cached alive remote nodes with caches.
- */
- private final Collection<ClusterNode> aliveNodesWithCaches;
-
- /**
- * Cached alive server remote nodes with caches.
- */
- private final Collection<ClusterNode> aliveSrvNodesWithCaches;
-
- /**
- * Cached alive remote server nodes with caches.
- */
- private final Collection<ClusterNode> aliveRmtSrvNodesWithCaches;
-
- /**
- * @param loc Local node.
- * @param rmts Remote nodes.
- */
- private DiscoCache(ClusterNode loc, Collection<ClusterNode> rmts) {
- this.loc = loc;
-
- rmtNodes = Collections.unmodifiableList(new ArrayList<>(F.view(rmts, daemonFilter)));
-
- assert !rmtNodes.contains(loc) : "Remote nodes collection shouldn't contain local node" +
- " [rmtNodes=" + rmtNodes + ", loc=" + loc + ']';
-
- List<ClusterNode> all = new ArrayList<>(rmtNodes.size() + 1);
-
- if (!loc.isDaemon())
- all.add(loc);
-
- all.addAll(rmtNodes);
-
- Collections.sort(all, GridNodeOrderComparator.INSTANCE);
-
- allNodes = Collections.unmodifiableList(all);
-
- Map<String, Collection<ClusterNode>> cacheMap = new HashMap<>(allNodes.size(), 1.0f);
- Map<String, Collection<ClusterNode>> rmtCacheMap = new HashMap<>(allNodes.size(), 1.0f);
- Map<String, Collection<ClusterNode>> dhtNodesMap = new HashMap<>(allNodes.size(), 1.0f);
- Collection<ClusterNode> nodesWithCaches = new HashSet<>(allNodes.size());
- Collection<ClusterNode> rmtNodesWithCaches = new HashSet<>(allNodes.size());
-
- aliveCacheNodes = new ConcurrentHashMap8<>(allNodes.size(), 1.0f);
- aliveRmtCacheNodes = new ConcurrentHashMap8<>(allNodes.size(), 1.0f);
- aliveNodesWithCaches = new ConcurrentSkipListSet<>();
- aliveSrvNodesWithCaches = new ConcurrentSkipListSet<>();
- aliveRmtSrvNodesWithCaches = new ConcurrentSkipListSet<>();
- nodesByVer = new TreeMap<>();
-
- long maxOrder0 = 0;
-
- Set<String> nearEnabledSet = new HashSet<>();
-
- for (ClusterNode node : allNodes) {
- assert node.order() != 0 : "Invalid node order [locNode=" + loc + ", node=" + node + ']';
-
- if (node.order() > maxOrder0)
- maxOrder0 = node.order();
-
- boolean hasCaches = false;
-
- for (Map.Entry<String, CachePredicate> entry : registeredCaches.entrySet()) {
- String cacheName = entry.getKey();
-
- CachePredicate filter = entry.getValue();
-
- if (filter.cacheNode(node)) {
- nodesWithCaches.add(node);
-
- if (!loc.id().equals(node.id()))
- rmtNodesWithCaches.add(node);
-
- addToMap(cacheMap, cacheName, node);
-
- if (alive(node.id()))
- addToMap(aliveCacheNodes, maskNull(cacheName), node);
-
- if (filter.dataNode(node))
- addToMap(dhtNodesMap, cacheName, node);
-
- if (filter.nearNode(node))
- nearEnabledSet.add(cacheName);
-
- if (!loc.id().equals(node.id())) {
- addToMap(rmtCacheMap, cacheName, node);
-
- if (alive(node.id()))
- addToMap(aliveRmtCacheNodes, maskNull(cacheName), node);
- }
-
- hasCaches = true;
- }
- }
-
- if (hasCaches) {
- if (alive(node.id())) {
- aliveNodesWithCaches.add(node);
-
- if (!CU.clientNode(node)) {
- aliveSrvNodesWithCaches.add(node);
-
- if (!loc.id().equals(node.id()))
- aliveRmtSrvNodesWithCaches.add(node);
- }
- }
- }
-
- IgniteProductVersion nodeVer = U.productVersion(node);
-
- // Create collection for this version if it does not exist.
- Collection<ClusterNode> nodes = nodesByVer.get(nodeVer);
-
- if (nodes == null) {
- nodes = new ArrayList<>(allNodes.size());
-
- nodesByVer.put(nodeVer, nodes);
- }
-
- nodes.add(node);
- }
-
- // Need second iteration to add this node to all previous node versions.
- for (ClusterNode node : allNodes) {
- IgniteProductVersion nodeVer = U.productVersion(node);
-
- // Get all versions lower or equal node's version.
- NavigableMap<IgniteProductVersion, Collection<ClusterNode>> updateView =
- nodesByVer.headMap(nodeVer, false);
-
- for (Collection<ClusterNode> prevVersions : updateView.values())
- prevVersions.add(node);
- }
-
- maxOrder = maxOrder0;
-
- allCacheNodes = Collections.unmodifiableMap(cacheMap);
- rmtCacheNodes = Collections.unmodifiableMap(rmtCacheMap);
- affCacheNodes = Collections.unmodifiableMap(dhtNodesMap);
- allNodesWithCaches = Collections.unmodifiableCollection(nodesWithCaches);
- this.rmtNodesWithCaches = Collections.unmodifiableCollection(rmtNodesWithCaches);
- nearEnabledCaches = Collections.unmodifiableSet(nearEnabledSet);
-
- daemonNodes = Collections.unmodifiableList(new ArrayList<>(
- F.view(F.concat(false, loc, rmts), F0.not(daemonFilter))));
-
- Map<UUID, ClusterNode> nodeMap = new HashMap<>(allNodes().size() + daemonNodes.size(), 1.0f);
-
- for (ClusterNode n : F.concat(false, allNodes(), daemonNodes()))
- nodeMap.put(n.id(), n);
-
- this.nodeMap = nodeMap;
- }
-
- /**
- * Adds node to map.
- *
- * @param cacheMap Map to add to.
- * @param cacheName Cache name.
- * @param rich Node to add
- */
- private void addToMap(Map<String, Collection<ClusterNode>> cacheMap, String cacheName, ClusterNode rich) {
- Collection<ClusterNode> cacheNodes = cacheMap.get(cacheName);
-
- if (cacheNodes == null) {
- cacheNodes = new ArrayList<>(allNodes.size());
-
- cacheMap.put(cacheName, cacheNodes);
- }
-
- cacheNodes.add(rich);
- }
-
- /** @return Local node. */
- ClusterNode localNode() {
- return loc;
- }
-
- /** @return Remote nodes. */
- Collection<ClusterNode> remoteNodes() {
- return rmtNodes;
- }
-
- /** @return All nodes. */
- Collection<ClusterNode> allNodes() {
- return allNodes;
- }
-
- /**
- * Gets collection of nodes which have version equal or greater than {@code ver}.
- *
- * @param ver Version to check.
- * @return Collection of nodes with version equal or greater than {@code ver}.
- */
- Collection<ClusterNode> elderNodes(IgniteProductVersion ver) {
- Map.Entry<IgniteProductVersion, Collection<ClusterNode>> entry = nodesByVer.ceilingEntry(ver);
-
- if (entry == null)
- return Collections.emptyList();
-
- return entry.getValue();
- }
-
- /**
- * @return Versions map.
- */
- NavigableMap<IgniteProductVersion, Collection<ClusterNode>> versionsMap() {
- return nodesByVer;
- }
-
- /**
- * Gets collection of nodes with at least one cache configured.
- *
- * @param topVer Topology version (maximum allowed node order).
- * @return Collection of nodes.
- */
- Collection<ClusterNode> allNodesWithCaches(final long topVer) {
- return filter(topVer, allNodesWithCaches);
- }
-
- /**
- * Gets all nodes that have cache with given name.
- *
- * @param cacheName Cache name.
- * @param topVer Topology version.
- * @return Collection of nodes.
- */
- Collection<ClusterNode> cacheNodes(@Nullable String cacheName, final long topVer) {
- return filter(topVer, allCacheNodes.get(cacheName));
- }
-
- /**
- * Gets all remote nodes that have cache with given name.
- *
- * @param cacheName Cache name.
- * @param topVer Topology version.
- * @return Collection of nodes.
- */
- Collection<ClusterNode> remoteCacheNodes(@Nullable String cacheName, final long topVer) {
- return filter(topVer, rmtCacheNodes.get(cacheName));
- }
-
- /**
- * Gets all remote nodes that have at least one cache configured.
- *
- * @param topVer Topology version.
- * @return Collection of nodes.
- */
- Collection<ClusterNode> remoteCacheNodes(final long topVer) {
- return filter(topVer, rmtNodesWithCaches);
- }
-
- /**
- * Gets all nodes that have cache with given name and should participate in affinity calculation. With
- * partitioned cache nodes with near-only cache do not participate in affinity node calculation.
- *
- * @param cacheName Cache name.
- * @param topVer Topology version.
- * @return Collection of nodes.
- */
- Collection<ClusterNode> cacheAffinityNodes(@Nullable String cacheName, final long topVer) {
- return filter(topVer, affCacheNodes.get(cacheName));
- }
-
- /**
- * Gets all alive nodes that have cache with given name.
- *
- * @param cacheName Cache name.
- * @param topVer Topology version.
- * @return Collection of nodes.
- */
- Collection<ClusterNode> aliveCacheNodes(@Nullable String cacheName, final long topVer) {
- return filter(topVer, aliveCacheNodes.get(maskNull(cacheName)));
- }
-
- /**
- * Gets all alive remote nodes that have cache with given name.
- *
- * @param cacheName Cache name.
- * @param topVer Topology version.
- * @return Collection of nodes.
- */
- Collection<ClusterNode> aliveRemoteCacheNodes(@Nullable String cacheName, final long topVer) {
- return filter(topVer, aliveRmtCacheNodes.get(maskNull(cacheName)));
- }
-
- /**
- * Gets all alive remote server nodes with at least one cache configured.
- *
- * @param topVer Topology version.
- * @return Collection of nodes.
- */
- Collection<ClusterNode> aliveRemoteServerNodesWithCaches(final long topVer) {
- return filter(topVer, aliveRmtSrvNodesWithCaches);
- }
-
- /**
- * Gets all alive server nodes with at least one cache configured.
- *
- * @param topVer Topology version.
- * @return Collection of nodes.
- */
- Collection<ClusterNode> aliveServerNodesWithCaches(final long topVer) {
- return filter(topVer, aliveSrvNodesWithCaches);
- }
-
- /**
- * Gets all alive remote nodes with at least one cache configured.
- *
- * @param topVer Topology version.
- * @return Collection of nodes.
- */
- Collection<ClusterNode> aliveNodesWithCaches(final long topVer) {
- return filter(topVer, aliveNodesWithCaches);
- }
-
- /**
- * Checks if cache with given name has at least one node with near cache enabled.
- *
- * @param cacheName Cache name.
- * @return {@code True} if cache with given name has at least one node with near cache enabled.
- */
- boolean hasNearCache(@Nullable String cacheName) {
- return nearEnabledCaches.contains(cacheName);
- }
-
- /**
- * Removes left node from cached alives lists.
- *
- * @param leftNode Left node.
- */
- void updateAlives(ClusterNode leftNode) {
- if (leftNode.order() > maxOrder)
- return;
-
- filterNodeMap(aliveCacheNodes, leftNode);
-
- filterNodeMap(aliveRmtCacheNodes, leftNode);
-
- aliveNodesWithCaches.remove(leftNode);
- aliveSrvNodesWithCaches.remove(leftNode);
- aliveRmtSrvNodesWithCaches.remove(leftNode);
- }
-
- /**
- * Creates a copy of nodes map without the given node.
- *
- * @param map Map to copy.
- * @param exclNode Node to exclude.
- */
- private void filterNodeMap(ConcurrentMap<String, Collection<ClusterNode>> map, final ClusterNode exclNode) {
- for (String cacheName : registeredCaches.keySet()) {
- String maskedName = maskNull(cacheName);
-
- while (true) {
- Collection<ClusterNode> oldNodes = map.get(maskedName);
-
- if (oldNodes == null || oldNodes.isEmpty())
- break;
-
- Collection<ClusterNode> newNodes = new ArrayList<>(oldNodes);
-
- if (!newNodes.remove(exclNode))
- break;
-
- if (map.replace(maskedName, oldNodes, newNodes))
- break;
- }
- }
- }
-
- /**
- * Replaces {@code null} with {@code NULL_CACHE_NAME}.
- *
- * @param cacheName Cache name.
- * @return Masked name.
- */
- private String maskNull(@Nullable String cacheName) {
- return cacheName == null ? NULL_CACHE_NAME : cacheName;
- }
-
- /**
- * @param topVer Topology version.
- * @param nodes Nodes.
- * @return Filtered collection (potentially empty, but never {@code null}).
- */
- private Collection<ClusterNode> filter(final long topVer, @Nullable Collection<ClusterNode> nodes) {
- if (nodes == null)
- return Collections.emptyList();
-
- // If no filtering needed, return original collection.
- return nodes.isEmpty() || topVer < 0 || topVer >= maxOrder ?
- nodes :
- F.view(nodes, new P1<ClusterNode>() {
- @Override public boolean apply(ClusterNode node) {
- return node.order() <= topVer;
- }
- });
- }
-
- /** @return Daemon nodes. */
- Collection<ClusterNode> daemonNodes() {
- return daemonNodes;
- }
-
- /**
- * @param id Node ID.
- * @return Node.
- */
- @Nullable ClusterNode node(UUID id) {
- return nodeMap.get(id);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(DiscoCache.class, this, "allNodesWithDaemons", U.toShortString(allNodes));
- }
- } /**
+ /**
* Cache predicate.
*/
private static class CachePredicate {
http://git-wip-us.apache.org/repos/asf/ignite/blob/94f549f2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 736e630..8c96c0c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -3482,46 +3482,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
/**
*
*/
- @SuppressWarnings("ExternalizableWithoutPublicNoArgConstructor")
- private class TemplateConfigurationFuture extends GridFutureAdapter<Object> {
- /** Start ID. */
- @GridToStringInclude
- private IgniteUuid deploymentId;
-
- /** Cache name. */
- private String cacheName;
-
- /**
- * @param cacheName Cache name.
- * @param deploymentId Deployment ID.
- */
- private TemplateConfigurationFuture(String cacheName, IgniteUuid deploymentId) {
- this.deploymentId = deploymentId;
- this.cacheName = cacheName;
- }
-
- /**
- * @return Start ID.
- */
- public IgniteUuid deploymentId() {
- return deploymentId;
- }
-
- /** {@inheritDoc} */
- @Override public boolean onDone(@Nullable Object res, @Nullable Throwable err) {
- // Make sure to remove future before completion.
- pendingTemplateFuts.remove(maskNull(cacheName), this);
-
- return super.onDone(res, err);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(TemplateConfigurationFuture.class, this);
- }
- } /**
- *
- */
private static class LocalAffinityFunction implements AffinityFunction {
/** */
private static final long serialVersionUID = 0L;
http://git-wip-us.apache.org/repos/asf/ignite/blob/94f549f2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 698b035..1c8107e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -3082,47 +3082,6 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
}
/**
- *
- */
- private class OffheapIteratorClosure
- extends CX2<T2<Long, Integer>, T2<Long, Integer>, IgniteBiTuple<K, V>> {
- /** */
- private static final long serialVersionUID = 7410163202728985912L;
-
- /** */
- private IgniteBiPredicate<K, V> filter;
-
- /** */
- private boolean keepPortable;
-
- /**
- * @param filter Filter.
- * @param keepPortable Keep portable flag.
- */
- private OffheapIteratorClosure(
- @Nullable IgniteBiPredicate<K, V> filter,
- boolean keepPortable) {
- assert filter != null;
-
- this.filter = filter;
- this.keepPortable = keepPortable;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public IgniteBiTuple<K, V> applyx(T2<Long, Integer> keyPtr,
- T2<Long, Integer> valPtr)
- throws IgniteCheckedException {
- LazyOffheapEntry e = new LazyOffheapEntry(keyPtr, valPtr);
-
- K key = (K)cctx.unwrapPortableIfNeeded(e.key(), keepPortable);
- V val = (V)cctx.unwrapPortableIfNeeded(e.value(), keepPortable);
-
- if (!filter.apply(key, val))
- return null;
-
- return new IgniteBiTuple<>(e.key(), (V)cctx.unwrapTemporary(e.value()));
- }
- } /**
* Creates user's SQL fields query for given clause. For more information refer to {@link CacheQuery}
* documentation.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/94f549f2/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
index df79232..4bb02c4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
@@ -565,53 +565,6 @@ public class GridRestProcessor extends GridProcessorAdapter {
}
/**
- * Applies {@link ConnectorMessageInterceptor}
- * from {@link ConnectorConfiguration#getMessageInterceptor()} ()}
- * to all user parameters in the request.
- *
- * @param req Client request.
- */
- private void interceptRequest(GridRestRequest req) {
- ConnectorMessageInterceptor interceptor = config().getMessageInterceptor();
-
- if (interceptor == null)
- return;
-
- if (req instanceof GridRestCacheRequest) {
- GridRestCacheRequest req0 = (GridRestCacheRequest) req;
-
- req0.key(interceptor.onReceive(req0.key()));
- req0.value(interceptor.onReceive(req0.value()));
- req0.value2(interceptor.onReceive(req0.value2()));
-
- Map<Object, Object> oldVals = req0.values();
-
- if (oldVals != null) {
- Map<Object, Object> newVals = U.newHashMap(oldVals.size());
-
- for (Map.Entry<Object, Object> e : oldVals.entrySet())
- newVals.put(interceptor.onReceive(e.getKey()), interceptor.onReceive(e.getValue()));
-
- req0.values(U.sealMap(newVals));
- }
- }
- else if (req instanceof GridRestTaskRequest) {
- GridRestTaskRequest req0 = (GridRestTaskRequest) req;
-
- List<Object> oldParams = req0.params();
-
- if (oldParams != null) {
- Collection<Object> newParams = new ArrayList<>(oldParams.size());
-
- for (Object o : oldParams)
- newParams.add(interceptor.onReceive(o));
-
- req0.params(U.sealList(newParams));
- }
- }
- }
-
- /**
* Applies {@link ConnectorMessageInterceptor} from
* {@link ConnectorConfiguration#getMessageInterceptor()}
* to all user objects in the response.
http://git-wip-us.apache.org/repos/asf/ignite/blob/94f549f2/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
index 3b36c6a..eea29d2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
@@ -307,135 +307,6 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter {
}
/**
- * Creates node bean out of grid node. Notice that cache attribute is handled separately.
- *
- * @param node Grid node.
- * @param mtr {@code true} to add metrics.
- * @param attr {@code true} to add attributes.
- * @return Grid Node bean.
- */
- private GridClientNodeBean createNodeBean(ClusterNode node, boolean mtr, boolean attr) {
- assert node != null;
-
- GridClientNodeBean nodeBean = new GridClientNodeBean();
-
- nodeBean.setNodeId(node.id());
- nodeBean.setConsistentId(node.consistentId());
- nodeBean.setTcpPort(attribute(node, ATTR_REST_TCP_PORT, 0));
-
- nodeBean.setTcpAddresses(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_ADDRS)));
- nodeBean.setTcpHostNames(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_HOST_NAMES)));
-
- Map<String, CacheMode> nodeCaches = ctx.discovery().nodeCaches(node);
-
- Map<String, String> cacheMap = U.newHashMap(nodeCaches.size());
-
- for (Map.Entry<String, CacheMode> cache : nodeCaches.entrySet()) {
- String cacheName = cache.getKey();
-
- if (CU.isSystemCache(cacheName) || CU.isIgfsCache(ctx.config(), cacheName))
- continue;
-
- String mode = cache.getValue().toString();
-
- if (cacheName != null)
- cacheMap.put(cacheName, mode);
- else
- nodeBean.setDefaultCacheMode(mode);
- }
-
- nodeBean.setCaches(cacheMap);
-
- if (mtr) {
- ClusterMetrics metrics = node.metrics();
-
- GridClientNodeMetricsBean metricsBean = new GridClientNodeMetricsBean();
-
- metricsBean.setStartTime(metrics.getStartTime());
- metricsBean.setAverageActiveJobs(metrics.getAverageActiveJobs());
- metricsBean.setAverageCancelledJobs(metrics.getAverageCancelledJobs());
- metricsBean.setAverageCpuLoad(metrics.getAverageCpuLoad());
- metricsBean.setAverageJobExecuteTime(metrics.getAverageJobExecuteTime());
- metricsBean.setAverageJobWaitTime(metrics.getAverageJobWaitTime());
- metricsBean.setAverageRejectedJobs(metrics.getAverageRejectedJobs());
- metricsBean.setAverageWaitingJobs(metrics.getAverageWaitingJobs());
- metricsBean.setCurrentActiveJobs(metrics.getCurrentActiveJobs());
- metricsBean.setCurrentCancelledJobs(metrics.getCurrentCancelledJobs());
- metricsBean.setCurrentCpuLoad(metrics.getCurrentCpuLoad());
- metricsBean.setCurrentGcCpuLoad(metrics.getCurrentGcCpuLoad());
- metricsBean.setCurrentDaemonThreadCount(metrics.getCurrentDaemonThreadCount());
- metricsBean.setCurrentIdleTime(metrics.getCurrentIdleTime());
- metricsBean.setCurrentJobExecuteTime(metrics.getCurrentJobExecuteTime());
- metricsBean.setCurrentJobWaitTime(metrics.getCurrentJobWaitTime());
- metricsBean.setCurrentRejectedJobs(metrics.getCurrentRejectedJobs());
- metricsBean.setCurrentThreadCount(metrics.getCurrentThreadCount());
- metricsBean.setCurrentWaitingJobs(metrics.getCurrentWaitingJobs());
- metricsBean.setHeapMemoryCommitted(metrics.getHeapMemoryCommitted());
- metricsBean.setHeapMemoryInitialized(metrics.getHeapMemoryInitialized());
- metricsBean.setHeapMemoryMaximum(metrics.getHeapMemoryMaximum());
- metricsBean.setHeapMemoryUsed(metrics.getHeapMemoryUsed());
- metricsBean.setLastDataVersion(metrics.getLastDataVersion());
- metricsBean.setLastUpdateTime(metrics.getLastUpdateTime());
- metricsBean.setMaximumActiveJobs(metrics.getMaximumActiveJobs());
- metricsBean.setMaximumCancelledJobs(metrics.getMaximumCancelledJobs());
- metricsBean.setMaximumJobExecuteTime(metrics.getMaximumJobExecuteTime());
- metricsBean.setMaximumJobWaitTime(metrics.getMaximumJobWaitTime());
- metricsBean.setMaximumRejectedJobs(metrics.getMaximumRejectedJobs());
- metricsBean.setMaximumThreadCount(metrics.getMaximumThreadCount());
- metricsBean.setMaximumWaitingJobs(metrics.getMaximumWaitingJobs());
- metricsBean.setNodeStartTime(metrics.getNodeStartTime());
- metricsBean.setNonHeapMemoryCommitted(metrics.getNonHeapMemoryCommitted());
- metricsBean.setNonHeapMemoryInitialized(metrics.getNonHeapMemoryInitialized());
- metricsBean.setNonHeapMemoryMaximum(metrics.getNonHeapMemoryMaximum());
- metricsBean.setNonHeapMemoryUsed(metrics.getNonHeapMemoryUsed());
- metricsBean.setStartTime(metrics.getStartTime());
- metricsBean.setTotalCancelledJobs(metrics.getTotalCancelledJobs());
- metricsBean.setTotalCpus(metrics.getTotalCpus());
- metricsBean.setTotalExecutedJobs(metrics.getTotalExecutedJobs());
- metricsBean.setTotalIdleTime(metrics.getTotalIdleTime());
- metricsBean.setTotalRejectedJobs(metrics.getTotalRejectedJobs());
- metricsBean.setTotalStartedThreadCount(metrics.getTotalStartedThreadCount());
- metricsBean.setTotalExecutedTasks(metrics.getTotalExecutedTasks());
- metricsBean.setSentMessagesCount(metrics.getSentMessagesCount());
- metricsBean.setSentBytesCount(metrics.getSentBytesCount());
- metricsBean.setReceivedMessagesCount(metrics.getReceivedMessagesCount());
- metricsBean.setReceivedBytesCount(metrics.getReceivedBytesCount());
- metricsBean.setUpTime(metrics.getUpTime());
-
- nodeBean.setMetrics(metricsBean);
- }
-
- if (attr) {
- Map<String, Object> attrs = new HashMap<>(node.attributes());
-
- attrs.remove(ATTR_CACHE);
- attrs.remove(ATTR_TX_CONFIG);
- attrs.remove(ATTR_SECURITY_SUBJECT);
- attrs.remove(ATTR_SECURITY_CREDENTIALS);
-
- for (Iterator<Map.Entry<String, Object>> i = attrs.entrySet().iterator(); i.hasNext();) {
- Map.Entry<String, Object> e = i.next();
-
- if (!e.getKey().startsWith("org.apache.ignite.") && !e.getKey().startsWith("plugins.") &&
- System.getProperty(e.getKey()) == null) {
- i.remove();
-
- continue;
- }
-
- if (e.getValue() != null) {
- if (e.getValue().getClass().isEnum() || e.getValue() instanceof InetAddress)
- e.setValue(e.getValue().toString());
- else if (e.getValue().getClass().isArray())
- i.remove();
- }
- }
-
- nodeBean.setAttributes(attrs);
- }
-
- return nodeBean;
- } /**
* @param col Collection;
* @return Non-empty list.
*/
[28/34] ignite git commit: IgniteTransactions javadoc updated
Posted by sb...@apache.org.
IgniteTransactions javadoc updated
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/075e7d06
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/075e7d06
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/075e7d06
Branch: refs/heads/ignite-1607
Commit: 075e7d06d55ba1c1249ce8b4d3b491aef7cbfd31
Parents: 1223525
Author: agura <ag...@gridgain.com>
Authored: Mon Oct 12 12:32:35 2015 +0300
Committer: agura <ag...@gridgain.com>
Committed: Mon Oct 12 12:33:12 2015 +0300
----------------------------------------------------------------------
.../core/src/main/java/org/apache/ignite/IgniteTransactions.java | 4 ----
1 file changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/075e7d06/modules/core/src/main/java/org/apache/ignite/IgniteTransactions.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteTransactions.java b/modules/core/src/main/java/org/apache/ignite/IgniteTransactions.java
index bb88d4a..875b647 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteTransactions.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteTransactions.java
@@ -17,7 +17,6 @@
package org.apache.ignite;
-import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.transactions.Transaction;
@@ -59,7 +58,6 @@ public interface IgniteTransactions {
*
* @return New transaction
* @throws IllegalStateException If transaction is already started by this thread.
- * @throws UnsupportedOperationException If cache is {@link CacheAtomicityMode#ATOMIC}.
*/
public Transaction txStart() throws IllegalStateException;
@@ -70,7 +68,6 @@ public interface IgniteTransactions {
* @param isolation Isolation.
* @return New transaction.
* @throws IllegalStateException If transaction is already started by this thread.
- * @throws UnsupportedOperationException If cache is {@link CacheAtomicityMode#ATOMIC}.
*/
public Transaction txStart(TransactionConcurrency concurrency, TransactionIsolation isolation);
@@ -84,7 +81,6 @@ public interface IgniteTransactions {
* @param txSize Number of entries participating in transaction (may be approximate).
* @return New transaction.
* @throws IllegalStateException If transaction is already started by this thread.
- * @throws UnsupportedOperationException If cache is {@link CacheAtomicityMode#ATOMIC}.
*/
public Transaction txStart(TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout,
int txSize);
[21/34] ignite git commit: ignite-1526: full support of IBM JDK by
Ignite
Posted by sb...@apache.org.
ignite-1526: full support of IBM JDK by Ignite
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a1e5cc57
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a1e5cc57
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a1e5cc57
Branch: refs/heads/ignite-1607
Commit: a1e5cc5783fc4b20f8c01f3b7af17a9ac772afd6
Parents: d917733
Author: Andrey Gura <ag...@gridgain.com>
Authored: Fri Oct 9 13:54:56 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Fri Oct 9 13:54:56 2015 +0300
----------------------------------------------------------------------
.../discovery/GridDiscoveryManager.java | 17 +-
.../internal/portable/PortableContext.java | 7 +
.../portable/api/PortableMarshaller.java | 14 +-
.../ignite/internal/util/GridJavaProcess.java | 12 +-
.../ignite/internal/util/lang/GridFunc.java | 12 +
.../apache/ignite/marshaller/Marshaller.java | 2 +-
.../optimized/OptimizedMarshallerUtils.java | 6 +-
.../cache/GridCacheAbstractFullApiSelfTest.java | 486 ++++---
.../CacheNoValueClassOnServerNodeTest.java | 1 +
...tomicClientOnlyMultiNodeFullApiSelfTest.java | 71 +-
...achePartitionedMultiNodeFullApiSelfTest.java | 129 +-
.../testframework/junits/GridAbstractTest.java | 116 +-
.../junits/IgniteTestResources.java | 8 +-
.../junits/common/GridCommonAbstractTest.java | 15 +-
.../junits/multijvm/AffinityProcessProxy.java | 440 ++++--
.../multijvm/IgniteCacheProcessProxy.java | 1346 ++++++++++++++----
.../multijvm/IgniteClusterProcessProxy.java | 115 +-
.../multijvm/IgniteEventsProcessProxy.java | 50 +-
.../junits/multijvm/IgniteNodeRunner.java | 39 +-
.../junits/multijvm/IgniteProcessProxy.java | 107 +-
.../cache/CacheConfigurationP2PTest.java | 3 +
21 files changed, 2185 insertions(+), 811 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index a6f5f08..2ed4520 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -987,19 +987,24 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
boolean locP2pEnabled = locNode.attribute(ATTR_PEER_CLASSLOADING);
- boolean warned = false;
+ boolean ipV4Warned = false;
+
+ boolean jvmMajVerWarned = false;
for (ClusterNode n : nodes) {
int rmtJvmMajVer = nodeJavaMajorVersion(n);
- if (locJvmMajVer != rmtJvmMajVer)
- throw new IgniteCheckedException("Local node's java major version is different from remote node's one" +
- " [locJvmMajVer=" + locJvmMajVer + ", rmtJvmMajVer=" + rmtJvmMajVer + "]");
+ if (locJvmMajVer != rmtJvmMajVer && !jvmMajVerWarned) {
+ U.warn(log, "Local java version is different from remote [loc=" +
+ locJvmMajVer + ", rmt=" + rmtJvmMajVer + "]");
+
+ jvmMajVerWarned = true;
+ }
String rmtPreferIpV4 = n.attribute("java.net.preferIPv4Stack");
if (!F.eq(rmtPreferIpV4, locPreferIpV4)) {
- if (!warned)
+ if (!ipV4Warned)
U.warn(log, "Local node's value of 'java.net.preferIPv4Stack' " +
"system property differs from remote node's " +
"(all nodes in topology should have identical value) " +
@@ -1008,7 +1013,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
", rmtAddrs=" + U.addressesAsString(n) + ']',
"Local and remote 'java.net.preferIPv4Stack' system properties do not match.");
- warned = true;
+ ipV4Warned = true;
}
// Daemon nodes are allowed to have any deployment they need.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index 2ee96b7..1ad42ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -967,6 +967,9 @@ public class PortableContext implements Externalizable {
}
}
+ /**
+ * Basic class ID mapper.
+ */
private static class BasicClassIdMapper implements PortableIdMapper {
/** {@inheritDoc} */
@Override public int typeId(String clsName) {
@@ -1121,6 +1124,10 @@ public class PortableContext implements Externalizable {
/** Whether the following type is registered in a cache or not */
private final boolean registered;
+ /**
+ * @param id Id.
+ * @param registered Registered.
+ */
public Type(int id, boolean registered) {
this.id = id;
this.registered = registered;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java
index de0df8d..3dfbdf0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java
@@ -29,12 +29,6 @@ import org.apache.ignite.internal.portable.GridPortableMarshaller;
import org.apache.ignite.internal.portable.PortableContext;
import org.apache.ignite.marshaller.AbstractMarshaller;
import org.apache.ignite.marshaller.MarshallerContext;
-import org.apache.ignite.internal.portable.api.PortableException;
-import org.apache.ignite.internal.portable.api.PortableIdMapper;
-import org.apache.ignite.internal.portable.api.PortableObject;
-import org.apache.ignite.internal.portable.api.PortableProtocolVersion;
-import org.apache.ignite.internal.portable.api.PortableSerializer;
-import org.apache.ignite.internal.portable.api.PortableTypeConfiguration;
import org.jetbrains.annotations.Nullable;
/**
@@ -336,7 +330,7 @@ public class PortableMarshaller extends AbstractMarshaller {
/** {@inheritDoc} */
@Override public <T> T unmarshal(InputStream in, @Nullable ClassLoader clsLdr) throws IgniteCheckedException {
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ ByteArrayOutputStream buf = new ByteArrayOutputStream();
byte[] arr = new byte[4096];
int cnt;
@@ -345,11 +339,11 @@ public class PortableMarshaller extends AbstractMarshaller {
// returns number of bytes remaining.
try {
while ((cnt = in.read(arr)) != -1)
- buffer.write(arr, 0, cnt);
+ buf.write(arr, 0, cnt);
- buffer.flush();
+ buf.flush();
- return impl.deserialize(buffer.toByteArray(), clsLdr);
+ return impl.deserialize(buf.toByteArray(), clsLdr);
}
catch (IOException e) {
throw new PortableException("Failed to unmarshal the object from InputStream", e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
index 92c20fe..3371eb8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
@@ -89,7 +89,7 @@ public final class GridJavaProcess {
*/
public static GridJavaProcess exec(Class cls, String params, @Nullable IgniteLogger log,
@Nullable IgniteInClosure<String> printC, @Nullable GridAbsClosure procKilledC) throws Exception {
- return exec(cls.getCanonicalName(), params, log, printC, procKilledC, null, null);
+ return exec(cls.getCanonicalName(), params, log, printC, procKilledC, null, null, null);
}
/**
@@ -108,7 +108,7 @@ public final class GridJavaProcess {
public static GridJavaProcess exec(Class cls, String params, @Nullable IgniteLogger log,
@Nullable IgniteInClosure<String> printC, @Nullable GridAbsClosure procKilledC,
@Nullable Collection<String> jvmArgs, @Nullable String cp) throws Exception {
- return exec(cls.getCanonicalName(), params, log, printC, procKilledC, jvmArgs, cp);
+ return exec(cls.getCanonicalName(), params, log, printC, procKilledC, null, jvmArgs, cp);
}
/**
@@ -116,9 +116,10 @@ public final class GridJavaProcess {
*
* @param clsName Class with main() method to be run.
* @param params main() method parameters.
+ * @param log Log to use.
* @param printC Optional closure to be called each time wrapped process prints line to system.out or system.err.
* @param procKilledC Optional closure to be called when process termination is detected.
- * @param log Log to use.
+ * @param javaHome Java home location. The process will be started under given JVM.
* @param jvmArgs JVM arguments to use.
* @param cp Additional classpath.
* @return Wrapper around {@link Process}
@@ -126,7 +127,7 @@ public final class GridJavaProcess {
*/
public static GridJavaProcess exec(String clsName, String params, @Nullable IgniteLogger log,
@Nullable IgniteInClosure<String> printC, @Nullable GridAbsClosure procKilledC,
- @Nullable Collection<String> jvmArgs, @Nullable String cp) throws Exception {
+ @Nullable String javaHome, @Nullable Collection<String> jvmArgs, @Nullable String cp) throws Exception {
if (!(U.isLinux() || U.isMacOs() || U.isWindows()))
throw new Exception("Your OS is not supported.");
@@ -140,7 +141,8 @@ public final class GridJavaProcess {
List<String> procCommands = new ArrayList<>();
- String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
+ String javaBin = (javaHome == null ? System.getProperty("java.home") : javaHome) +
+ File.separator + "bin" + File.separator + "java";
procCommands.add(javaBin);
procCommands.addAll(jvmArgs == null ? U.jvmArgs() : jvmArgs);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index ffeeca0..43bc5f3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -103,6 +103,9 @@ public class GridFunc {
/** */
private static final IgniteClosure IDENTITY = new C1() {
+ /** */
+ private static final long serialVersionUID = -6338573080046225172L;
+
@Override public Object apply(Object o) {
return o;
}
@@ -1196,6 +1199,9 @@ public class GridFunc {
A.notNull(nodeId, "nodeId");
return new P1<T>() {
+ /** */
+ private static final long serialVersionUID = -7082730222779476623L;
+
@Override public boolean apply(ClusterNode e) {
return e.id().equals(nodeId);
}
@@ -1705,6 +1711,9 @@ public class GridFunc {
assert c != null;
return new GridSerializableList<T2>() {
+ /** */
+ private static final long serialVersionUID = 3126625219739967068L;
+
@Override public T2 get(int idx) {
return trans.apply(c.get(idx));
}
@@ -1766,6 +1775,9 @@ public class GridFunc {
assert m != null;
return isEmpty(p) || isAlwaysTrue(p) ? m : new GridSerializableMap<K, V>() {
+ /** */
+ private static final long serialVersionUID = 5531745605372387948L;
+
/** Entry predicate. */
private IgnitePredicate<Entry<K, V>> ep = new P1<Map.Entry<K, V>>() {
@Override public boolean apply(Entry<K, V> e) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java
index 3e815fd..a76daa8 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java
@@ -92,7 +92,7 @@ public interface Marshaller {
public byte[] marshal(@Nullable Object obj) throws IgniteCheckedException;
/**
- * Unmarshals object from the output stream using given class loader.
+ * Unmarshals object from the input stream using given class loader.
* This method should not close given input stream.
*
* @param <T> Type of unmarshalled object.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
index 4abbd04..584083c 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
@@ -42,6 +42,10 @@ class OptimizedMarshallerUtils {
/** */
private static final Unsafe UNSAFE = GridUnsafe.unsafe();
+ /** Use default {@code serialVersionUid} for {@link Serializable} classes. */
+ private static final boolean USE_DFLT_SUID =
+ Boolean.valueOf(System.getProperty("ignite.marsh.optimized.useDefaultSUID", Boolean.TRUE.toString()));
+
/** */
static final long HASH_SET_MAP_OFF;
@@ -283,7 +287,7 @@ class OptimizedMarshallerUtils {
*/
@SuppressWarnings("ForLoopReplaceableByForEach")
static short computeSerialVersionUid(Class cls, List<Field> fields) throws IOException {
- if (Serializable.class.isAssignableFrom(cls) && !Enum.class.isAssignableFrom(cls))
+ if (USE_DFLT_SUID && Serializable.class.isAssignableFrom(cls) && !Enum.class.isAssignableFrom(cls))
return (short)ObjectStreamClass.lookup(cls).getSerialVersionUID();
MessageDigest md;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 2a64963..ec3ea0c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -49,6 +50,7 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteTransactions;
import org.apache.ignite.cache.CacheEntryProcessor;
import org.apache.ignite.cache.CacheMemoryMode;
@@ -75,6 +77,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.LoggerResource;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
import org.apache.ignite.testframework.GridTestUtils;
@@ -117,48 +120,37 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/** */
public static final CacheEntryProcessor<String, Integer, String> ERR_PROCESSOR =
new CacheEntryProcessor<String, Integer, String>() {
+ /** */
+ private static final long serialVersionUID = 0L;
+
@Override public String process(MutableEntry<String, Integer> e, Object... args) {
throw new RuntimeException("Failed!");
}
};
/** Increment processor for invoke operations. */
- public static final EntryProcessor<String, Integer, String> INCR_PROCESSOR = new EntryProcessor<String, Integer, String>() {
- @Override public String process(MutableEntry<String, Integer> e, Object... args) {
- assertNotNull(e.getKey());
-
- Integer old = e.getValue();
-
- e.setValue(old == null ? 1 : old + 1);
-
- return String.valueOf(old);
- }
- };
+ public static final EntryProcessor<String, Integer, String> INCR_PROCESSOR = new IncrementEntryProcessor();
/** Increment processor for invoke operations with IgniteEntryProcessor. */
public static final CacheEntryProcessor<String, Integer, String> INCR_IGNITE_PROCESSOR =
new CacheEntryProcessor<String, Integer, String>() {
+ /** */
+ private static final long serialVersionUID = 0L;
+
@Override public String process(MutableEntry<String, Integer> e, Object... args) {
return INCR_PROCESSOR.process(e, args);
}
};
/** Increment processor for invoke operations. */
- public static final EntryProcessor<String, Integer, String> RMV_PROCESSOR = new EntryProcessor<String, Integer, String>() {
- @Override public String process(MutableEntry<String, Integer> e, Object... args) {
- assertNotNull(e.getKey());
-
- Integer old = e.getValue();
-
- e.remove();
-
- return String.valueOf(old);
- }
- };
+ public static final EntryProcessor<String, Integer, String> RMV_PROCESSOR = new RemoveEntryProcessor();
/** Increment processor for invoke operations with IgniteEntryProcessor. */
public static final CacheEntryProcessor<String, Integer, String> RMV_IGNITE_PROCESSOR =
new CacheEntryProcessor<String, Integer, String>() {
+ /** */
+ private static final long serialVersionUID = 0L;
+
@Override public String process(MutableEntry<String, Integer> e, Object... args) {
return RMV_PROCESSOR.process(e, args);
}
@@ -346,21 +338,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assert jcache(i).localSize() != 0 || F.isEmpty(keysCol);
}
- for (int i = 0; i < gridCount(); i++) {
- executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
- @Override public void run(int idx) throws Exception {
- GridCacheContext<String, Integer> ctx = context(idx);
-
- int sum = 0;
-
- for (String key : map.keySet())
- if (ctx.affinity().localNode(key, new AffinityTopologyVersion(ctx.discovery().topologyVersion())))
- sum++;
-
- assertEquals("Incorrect key size on cache #" + idx, sum, jcache(idx).localSize(ALL));
- }
- });
- }
+ for (int i = 0; i < gridCount(); i++)
+ executeOnLocalOrRemoteJvm(i, new CheckCacheSizeTask(map));
for (int i = 0; i < gridCount(); i++) {
Collection<String> keysCol = mapped.get(grid(i).localNode());
@@ -1350,13 +1329,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertEquals((Integer)3, cache.get("k1"));
- EntryProcessor<String, Integer, Integer> c = new EntryProcessor<String, Integer, Integer>() {
- @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
- e.remove();
-
- return null;
- }
- };
+ EntryProcessor<String, Integer, Integer> c = new RemoveAndReturnNullEntryProcessor();
assertNull(cache.invoke("k1", c));
assertNull(cache.get("k1"));
@@ -1364,11 +1337,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (int i = 0; i < gridCount(); i++)
assertNull(jcache(i).localPeek("k1", ONHEAP));
- final EntryProcessor<String, Integer, Integer> errProcessor = new EntryProcessor<String, Integer, Integer>() {
- @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
- throw new EntryProcessorException("Test entry processor exception.");
- }
- };
+ final EntryProcessor<String, Integer, Integer> errProcessor = new FailedEntryProcessor();
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override public Void call() throws Exception {
@@ -2001,7 +1970,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertFalse(cacheAsync.<Boolean>future().get());
}
- cache.localEvict(Arrays.asList("key2"));
+ cache.localEvict(Collections.singletonList("key2"));
// Same checks inside tx.
Transaction tx = inTx ? transactions().txStart() : null;
@@ -2357,27 +2326,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (int i = 0; i < cnt; i++)
cache.remove(String.valueOf(i));
- for (int g = 0; g < gridCount(); g++) {
- executeOnLocalOrRemoteJvm(g, new TestIgniteIdxRunnable() {
- @Override public void run(int idx) throws Exception {
- for (int i = 0; i < cnt; i++) {
- String key = String.valueOf(i);
-
- GridCacheContext<String, Integer> cctx = context(idx);
-
- GridCacheEntryEx entry = cctx.isNear() ? cctx.near().dht().peekEx(key) :
- cctx.cache().peekEx(key);
-
- if (grid(idx).affinity(null).mapKeyToPrimaryAndBackups(key).contains(grid(idx).localNode())) {
- assertNotNull(entry);
- assertTrue(entry.deleted());
- }
- else
- assertNull(entry);
- }
- }
- });
- }
+ for (int g = 0; g < gridCount(); g++)
+ executeOnLocalOrRemoteJvm(g, new CheckEntriesDeletedTask(cnt));
}
}
@@ -2587,8 +2537,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
c.add(null);
GridTestUtils.assertThrows(log, new Callable<Void>() {
- @Override
- public Void call() throws Exception {
+ @Override public Void call() throws Exception {
cache.removeAll(c);
return null;
@@ -2725,7 +2674,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
public void testRemoveAfterClear() throws Exception {
IgniteEx ignite = grid(0);
- boolean affNode = ((IgniteKernal)ignite).context().cache().internalCache(null).context().affinityNode();
+ boolean affNode = ignite.context().cache().internalCache(null).context().affinityNode();
if (!affNode) {
if (gridCount() < 2)
@@ -2766,13 +2715,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
/**
- *
- */
- private void xxx() {
- System.out.printf("");
- }
-
- /**
* @throws Exception In case of error.
*/
public void testClear() throws Exception {
@@ -3597,26 +3539,9 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
info("Local keys (primary + backup): " + locKeys);
}
- for (int i = 0; i < gridCount(); i++) {
- grid(i).events().localListen(new IgnitePredicate<Event>() {
- @Override public boolean apply(Event evt) {
- info("Received event: " + evt);
-
- switch (evt.type()) {
- case EVT_CACHE_OBJECT_SWAPPED:
- swapEvts.incrementAndGet();
-
- break;
- case EVT_CACHE_OBJECT_UNSWAPPED:
- unswapEvts.incrementAndGet();
-
- break;
- }
-
- return true;
- }
- }, EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
- }
+ for (int i = 0; i < gridCount(); i++)
+ grid(i).events().localListen(
+ new SwapEvtsLocalListener(swapEvts, unswapEvts), EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
cache.localEvict(F.asList(k2, k3));
@@ -3934,7 +3859,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
map.put(entry.getKey(), entry.getValue());
}
- assert map != null;
assert map.size() == 2;
assert map.get("key1") == 1;
assert map.get("key2") == 2;
@@ -3951,32 +3875,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
if (nearEnabled())
assertEquals(keys.size(), jcache().localSize(CachePeekMode.ALL));
else {
- for (int i = 0; i < gridCount(); i++) {
- executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
- @Override public void run(int idx) throws Exception {
- GridCacheContext<String, Integer> ctx = context(idx);
-
- if (ctx.cache().configuration().getMemoryMode() == OFFHEAP_TIERED)
- return;
-
- int size = 0;
-
- for (String key : keys) {
- if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx())) {
- GridCacheEntryEx e =
- ctx.isNear() ? ctx.near().dht().peekEx(key) : ctx.cache().peekEx(key);
-
- assert e != null : "Entry is null [idx=" + idx + ", key=" + key + ", ctx=" + ctx + ']';
- assert !e.deleted() : "Entry is deleted: " + e;
-
- size++;
- }
- }
-
- assertEquals("Incorrect size on cache #" + idx, size, jcache(idx).localSize(ALL));
- }
- });
- }
+ for (int i = 0; i < gridCount(); i++)
+ executeOnLocalOrRemoteJvm(i, new CheckEntriesTask(keys));
}
}
@@ -3989,21 +3889,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertEquals("Invalid key size: " + jcache().localSize(ALL),
keys.size(), jcache().localSize(ALL));
else {
- for (int i = 0; i < gridCount(); i++) {
- executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
- @Override public void run(int idx) throws Exception {
- GridCacheContext<String, Integer> ctx = context(idx);
-
- int size = 0;
-
- for (String key : keys)
- if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx()))
- size++;
-
- assertEquals("Incorrect key size on cache #" + idx, size, jcache(idx).localSize(ALL));
- }
- });
- }
+ for (int i = 0; i < gridCount(); i++)
+ executeOnLocalOrRemoteJvm(i, new CheckKeySizeTask(keys));
}
}
@@ -4061,27 +3948,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* @param cnt Keys count.
* @return Collection of keys for which given cache is primary.
*/
- protected List<String> primaryKeysForCache(final IgniteCache<String, Integer> cache, final int cnt, final int startFrom) {
- return executeOnLocalOrRemoteJvm(cache, new TestCacheCallable<String, Integer, List<String>>() {
- @Override public List<String> call(Ignite ignite, IgniteCache<String, Integer> cache) throws Exception {
- List<String> found = new ArrayList<>();
-
- Affinity<Object> affinity = ignite.affinity(cache.getName());
-
- for (int i = startFrom; i < startFrom + 100_000; i++) {
- String key = "key" + i;
-
- if (affinity.isPrimary(ignite.cluster().localNode(), key)) {
- found.add(key);
-
- if (found.size() == cnt)
- return found;
- }
- }
-
- throw new IgniteException("Unable to find " + cnt + " keys as primary for cache.");
- }
- });
+ protected List<String> primaryKeysForCache(IgniteCache<String, Integer> cache, int cnt, int startFrom) {
+ return executeOnLocalOrRemoteJvm(cache, new CheckPrimaryKeysTask(startFrom, cnt));
}
/**
@@ -4272,18 +4140,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* Checks iterators are cleared.
*/
private void checkIteratorsCleared() {
- for (int j = 0; j < gridCount(); j++) {
- executeOnLocalOrRemoteJvm(j, new TestIgniteIdxRunnable() {
- @Override public void run(int idx) throws Exception {
- GridCacheQueryManager queries = context(idx).queries();
-
- Map map = GridTestUtils.getFieldValue(queries, GridCacheQueryManager.class, "qryIters");
-
- for (Object obj : map.values())
- assertEquals("Iterators not removed for grid " + idx, 0, ((Map)obj).size());
- }
- });
- }
+ for (int j = 0; j < gridCount(); j++)
+ executeOnLocalOrRemoteJvm(j, new CheckIteratorTask());
}
/**
@@ -5226,4 +5084,280 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/** */
ONE_BY_ONE
}
+
+ /**
+ *
+ */
+ private static class RemoveEntryProcessor implements EntryProcessor<String, Integer, String>, Serializable {
+ /** {@inheritDoc} */
+ @Override public String process(MutableEntry<String, Integer> e, Object... args) {
+ assertNotNull(e.getKey());
+
+ Integer old = e.getValue();
+
+ e.remove();
+
+ return String.valueOf(old);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IncrementEntryProcessor implements EntryProcessor<String, Integer, String>, Serializable {
+ /** {@inheritDoc} */
+ @Override public String process(MutableEntry<String, Integer> e, Object... args) {
+ assertNotNull(e.getKey());
+
+ Integer old = e.getValue();
+
+ e.setValue(old == null ? 1 : old + 1);
+
+ return String.valueOf(old);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CheckEntriesTask extends TestIgniteIdxRunnable {
+ /** Keys. */
+ private final Collection<String> keys;
+
+ /**
+ * @param keys Keys.
+ */
+ public CheckEntriesTask(Collection<String> keys) {
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run(int idx) throws Exception {
+ GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+
+ if (ctx.cache().configuration().getMemoryMode() == OFFHEAP_TIERED)
+ return;
+
+ int size = 0;
+
+ for (String key : keys) {
+ if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx())) {
+ GridCacheEntryEx e =
+ ctx.isNear() ? ctx.near().dht().peekEx(key) : ctx.cache().peekEx(key);
+
+ assert e != null : "Entry is null [idx=" + idx + ", key=" + key + ", ctx=" + ctx + ']';
+ assert !e.deleted() : "Entry is deleted: " + e;
+
+ size++;
+ }
+ }
+
+ assertEquals("Incorrect size on cache #" + idx, size, ignite.cache(ctx.name()).localSize(ALL));
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CheckCacheSizeTask extends TestIgniteIdxRunnable {
+ private final Map<String, Integer> map;
+
+ /**
+ * @param map Map.
+ */
+ public CheckCacheSizeTask(Map<String, Integer> map) {
+ this.map = map;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run(int idx) throws Exception {
+ GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+
+ int size = 0;
+
+ for (String key : map.keySet())
+ if (ctx.affinity().localNode(key, new AffinityTopologyVersion(ctx.discovery().topologyVersion())))
+ size++;
+
+ assertEquals("Incorrect key size on cache #" + idx, size, ignite.cache(ctx.name()).localSize(ALL));
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CheckPrimaryKeysTask implements TestCacheCallable<String, Integer, List<String>> {
+ /** Start from. */
+ private final int startFrom;
+
+ /** Count. */
+ private final int cnt;
+
+ /**
+ * @param startFrom Start from.
+ * @param cnt Count.
+ */
+ public CheckPrimaryKeysTask(int startFrom, int cnt) {
+ this.startFrom = startFrom;
+ this.cnt = cnt;
+ }
+
+ /** {@inheritDoc} */
+ @Override public List<String> call(Ignite ignite, IgniteCache<String, Integer> cache) throws Exception {
+ List<String> found = new ArrayList<>();
+
+ Affinity<Object> affinity = ignite.affinity(cache.getName());
+
+ for (int i = startFrom; i < startFrom + 100_000; i++) {
+ String key = "key" + i;
+
+ if (affinity.isPrimary(ignite.cluster().localNode(), key)) {
+ found.add(key);
+
+ if (found.size() == cnt)
+ return found;
+ }
+ }
+
+ throw new IgniteException("Unable to find " + cnt + " keys as primary for cache.");
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CheckIteratorTask extends TestIgniteIdxCallable<Void> {
+ /**
+ * @param idx Index.
+ */
+ @Override public Void call(int idx) throws Exception {
+ GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+ GridCacheQueryManager queries = ctx.queries();
+
+ Map map = GridTestUtils.getFieldValue(queries, GridCacheQueryManager.class, "qryIters");
+
+ for (Object obj : map.values())
+ assertEquals("Iterators not removed for grid " + idx, 0, ((Map)obj).size());
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveAndReturnNullEntryProcessor implements
+ EntryProcessor<String, Integer, Integer>, Serializable {
+
+ /** {@inheritDoc} */
+ @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
+ e.remove();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class SwapEvtsLocalListener implements IgnitePredicate<Event> {
+ @LoggerResource
+ private IgniteLogger log;
+
+ /** Swap events. */
+ private final AtomicInteger swapEvts;
+
+ /** Unswap events. */
+ private final AtomicInteger unswapEvts;
+
+ /**
+ * @param swapEvts Swap events.
+ * @param unswapEvts Unswap events.
+ */
+ public SwapEvtsLocalListener(AtomicInteger swapEvts, AtomicInteger unswapEvts) {
+ this.swapEvts = swapEvts;
+ this.unswapEvts = unswapEvts;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(Event evt) {
+ log.info("Received event: " + evt);
+
+ switch (evt.type()) {
+ case EVT_CACHE_OBJECT_SWAPPED:
+ swapEvts.incrementAndGet();
+
+ break;
+ case EVT_CACHE_OBJECT_UNSWAPPED:
+ unswapEvts.incrementAndGet();
+
+ break;
+ }
+
+ return true;
+ }
+ }
+
+ private static class CheckEntriesDeletedTask extends TestIgniteIdxRunnable {
+ private final int cnt;
+
+ public CheckEntriesDeletedTask(int cnt) {
+ this.cnt = cnt;
+ }
+
+ @Override public void run(int idx) throws Exception {
+ for (int i = 0; i < cnt; i++) {
+ String key = String.valueOf(i);
+
+ GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+
+ GridCacheEntryEx entry = ctx.isNear() ? ctx.near().dht().peekEx(key) : ctx.cache().peekEx(key);
+
+ if (ignite.affinity(null).mapKeyToPrimaryAndBackups(key).contains(((IgniteKernal)ignite).localNode())) {
+ assertNotNull(entry);
+ assertTrue(entry.deleted());
+ }
+ else
+ assertNull(entry);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CheckKeySizeTask extends TestIgniteIdxRunnable {
+ /** Keys. */
+ private final Collection<String> keys;
+
+ /**
+ * @param keys Keys.
+ */
+ public CheckKeySizeTask(Collection<String> keys) {
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run(int idx) throws Exception {
+ GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+
+ int size = 0;
+
+ for (String key : keys)
+ if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx()))
+ size++;
+
+ assertEquals("Incorrect key size on cache #" + idx, size, ignite.cache(null).localSize(ALL));
+ }
+ }
+
+ /**
+ *
+ */
+ private static class FailedEntryProcessor implements EntryProcessor<String, Integer, Integer>, Serializable {
+ /** {@inheritDoc} */
+ @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
+ throw new EntryProcessorException("Test entry processor exception.");
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
index da694b5..c6ce81e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
@@ -111,6 +111,7 @@ public class CacheNoValueClassOnServerNodeTest extends GridCommonAbstractTest {
}
},
null,
+ null,
jvmArgs,
cp
);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
index 1511c45..927ee62 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
@@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -29,6 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import javax.cache.expiry.Duration;
import javax.cache.expiry.TouchedExpiryPolicy;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -37,6 +39,7 @@ import org.apache.ignite.events.Event;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.LoggerResource;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
@@ -106,9 +109,11 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
affinityNodes(); // Just to ack cache configuration to log..
- checkKeySize(map.keySet());
+ Set<String> keys = new LinkedHashSet<>(map.keySet());
- checkSize(map.keySet());
+ checkKeySize(keys);
+
+ checkSize(keys);
int fullCacheSize = 0;
@@ -317,24 +322,8 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
Collection<String> locKeys = new HashSet<>();
for (int i = 0; i < gridCount(); i++) {
- grid(i).events().localListen(new IgnitePredicate<Event>() {
- @Override public boolean apply(Event evt) {
- info("Received event: " + evt);
-
- switch (evt.type()) {
- case EVT_CACHE_OBJECT_SWAPPED:
- swapEvts.incrementAndGet();
-
- break;
- case EVT_CACHE_OBJECT_UNSWAPPED:
- unswapEvts.incrementAndGet();
-
- break;
- }
-
- return true;
- }
- }, EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
+ grid(i).events().localListen(
+ new LocalListener(swapEvts, unswapEvts), EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
}
cache.localEvict(Collections.singleton(k2));
@@ -416,4 +405,46 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
assertEquals(cnt, swapEvts.get());
assertEquals(cnt, unswapEvts.get());
}
+
+ /**
+ *
+ */
+ private static class LocalListener implements IgnitePredicate<Event> {
+ /** Logger. */
+ @LoggerResource
+ private IgniteLogger log;
+
+ /** Swap events. */
+ private final AtomicInteger swapEvts;
+
+ /** Unswap events. */
+ private final AtomicInteger unswapEvts;
+
+ /**
+ * @param swapEvts Swap events.
+ * @param unswapEvts Unswap events.
+ */
+ public LocalListener(AtomicInteger swapEvts, AtomicInteger unswapEvts) {
+ this.swapEvts = swapEvts;
+ this.unswapEvts = unswapEvts;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(Event evt) {
+ log.info("Received event: " + evt);
+
+ switch (evt.type()) {
+ case EVT_CACHE_OBJECT_SWAPPED:
+ swapEvts.incrementAndGet();
+
+ break;
+ case EVT_CACHE_OBJECT_UNSWAPPED:
+ unswapEvts.incrementAndGet();
+
+ break;
+ }
+
+ return true;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
index c04bf2e..a2440e2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
@@ -20,11 +20,14 @@ package org.apache.ignite.internal.processors.cache.distributed.near;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteAtomicLong;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.CacheMemoryMode;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.cache.affinity.Affinity;
@@ -36,6 +39,8 @@ import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.resources.LoggerResource;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -93,7 +98,7 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
atomicClockModeDelay(c0);
- c1.removeAll(putMap.keySet());
+ c1.removeAll(new HashSet<>(putMap.keySet()));
for (int i = 0; i < size; i++) {
assertNull(c0.get(i));
@@ -159,22 +164,8 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
info("Finished putting value [i=" + i + ']');
}
- for (int i = 0; i < gridCount(); i++) {
- executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
- @Override public void run(int idx) throws Exception {
- assertEquals(0, context(idx).tm().idMapSize());
-
- IgniteCache<Object, Object> cache = grid(idx).cache(null);
- ClusterNode node = grid(idx).localNode();
-
- for (int k = 0; k < size; k++) {
- if (affinity(cache).isPrimaryOrBackup(node, k))
- assertEquals("Check failed for node: " + node.id(), k,
- cache.localPeek(k, CachePeekMode.ONHEAP, CachePeekMode.OFFHEAP));
- }
- }
- });
- }
+ for (int i = 0; i < gridCount(); i++)
+ executeOnLocalOrRemoteJvm(i, new CheckAffinityTask(size));
for (int i = 0; i < size; i++) {
info("Putting value 2 [i=" + i + ']');
@@ -199,28 +190,9 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
final IgniteAtomicLong unswapEvts = grid(0).atomicLong("unswapEvts", 0, true);
- for (int i = 0; i < gridCount(); i++) {
- final int iCopy = i;
-
- grid(i).events().localListen(new IgnitePredicate<Event>() {
- @Override public boolean apply(Event evt) {
- info("Received event: " + evt);
-
- switch (evt.type()) {
- case EVT_CACHE_OBJECT_SWAPPED:
- grid(iCopy).atomicLong("swapEvts", 0, false).incrementAndGet();
-
- break;
- case EVT_CACHE_OBJECT_UNSWAPPED:
- grid(iCopy).atomicLong("unswapEvts", 0, false).incrementAndGet();
-
- break;
- }
-
- return true;
- }
- }, EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
- }
+ for (int i = 0; i < gridCount(); i++)
+ grid(i).events().localListen(
+ new SwapUnswapLocalListener(), EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
jcache().put("key", 1);
@@ -254,13 +226,8 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
boolean nearEnabled = nearEnabled(c);
- if (nearEnabled) {
- executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
- @Override public void run(int idx) throws Exception {
- assertTrue(((IgniteKernal)ignite(idx)).internalCache().context().isNear());
- }
- });
- }
+ if (nearEnabled)
+ executeOnLocalOrRemoteJvm(i, new IsNearTask());
Integer nearPeekVal = nearEnabled ? 1 : null;
@@ -476,4 +443,74 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
assertFalse(affinity(cache).isPrimaryOrBackup(other, key));
}
}
+
+ /**
+ *
+ */
+ private static class SwapUnswapLocalListener implements IgnitePredicate<Event> {
+ /** Logger. */
+ @LoggerResource
+ private IgniteLogger log;
+
+ /** Ignite. */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(Event evt) {
+ log.info("Received event: " + evt);
+
+ switch (evt.type()) {
+ case EVT_CACHE_OBJECT_SWAPPED:
+ ignite.atomicLong("swapEvts", 0, false).incrementAndGet();
+
+ break;
+ case EVT_CACHE_OBJECT_UNSWAPPED:
+ ignite.atomicLong("unswapEvts", 0, false).incrementAndGet();
+
+ break;
+ }
+
+ return true;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CheckAffinityTask extends TestIgniteIdxRunnable {
+ /** Size. */
+ private final int size;
+
+ /**
+ * @param size Size.
+ */
+ public CheckAffinityTask(int size) {
+ this.size = size;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run(int idx) throws Exception {
+ assertEquals(0, ((IgniteKernal)ignite).<String, Integer>internalCache().context().tm().idMapSize());
+
+ IgniteCache<Object, Object> cache = ignite.cache(null);
+ ClusterNode node = ((IgniteKernal)ignite).localNode();
+
+ for (int k = 0; k < size; k++) {
+ if (affinity(cache).isPrimaryOrBackup(node, k))
+ assertEquals("Check failed for node: " + node.id(), k,
+ cache.localPeek(k, CachePeekMode.ONHEAP, CachePeekMode.OFFHEAP));
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IsNearTask extends TestIgniteIdxRunnable {
+ /** {@inheritDoc} */
+ @Override public void run(int idx) throws Exception {
+ assertTrue(((IgniteKernal)ignite).internalCache().context().isNear());
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index f54fe06..d133a84 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -73,6 +73,7 @@ import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.marshaller.MarshallerExclusions;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
+import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.spi.checkpoint.sharedfs.SharedFsCheckpointSpi;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -1471,6 +1472,8 @@ public abstract class GridAbstractTest extends TestCase {
if (!isMultiJvmObject(ignite))
try {
+ job.setIgnite(ignite);
+
return job.call(idx);
}
catch (Exception e) {
@@ -1532,11 +1535,7 @@ public abstract class GridAbstractTest extends TestCase {
IgniteProcessProxy proxy = (IgniteProcessProxy)ignite;
- return proxy.remoteCompute().call(new IgniteCallable<R>() {
- @Override public R call() throws Exception {
- return job.call(idx);
- }
- });
+ return proxy.remoteCompute().call(new ExecuteRemotelyTask<>(job, idx));
}
/**
@@ -1546,15 +1545,7 @@ public abstract class GridAbstractTest extends TestCase {
* @param job Job.
*/
public static <R> R executeRemotely(IgniteProcessProxy proxy, final TestIgniteCallable<R> job) {
- final UUID id = proxy.getId();
-
- return proxy.remoteCompute().call(new IgniteCallable<R>() {
- @Override public R call() throws Exception {
- Ignite ignite = Ignition.ignite(id);
-
- return job.call(ignite);
- }
- });
+ return proxy.remoteCompute().call(new TestRemoteTask<>(proxy.getId(), job));
}
/**
@@ -1571,6 +1562,8 @@ public abstract class GridAbstractTest extends TestCase {
final String cacheName = cache.getName();
return proxy.remoteCompute().call(new IgniteCallable<R>() {
+ private static final long serialVersionUID = -3868429485920845137L;
+
@Override public R call() throws Exception {
Ignite ignite = Ignition.ignite(id);
IgniteCache<K,V> cache = ignite.cache(cacheName);
@@ -1745,6 +1738,22 @@ public abstract class GridAbstractTest extends TestCase {
}
/**
+ * @param name Name.
+ * @param remote Remote.
+ * @param thisRemote This remote.
+ */
+ public static IgniteEx grid(String name, boolean remote, boolean thisRemote) {
+ if (!remote)
+ return (IgniteEx)G.ignite(name);
+ else {
+ if (thisRemote)
+ return IgniteNodeRunner.startedInstance();
+ else
+ return IgniteProcessProxy.ignite(name);
+ }
+ }
+
+ /**
*
*/
private static interface WriteReplaceOwner {
@@ -1781,6 +1790,67 @@ public abstract class GridAbstractTest extends TestCase {
}
/**
+ * Remote computation task.
+ */
+ private static class TestRemoteTask<R> implements IgniteCallable<R> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Node ID. */
+ private final UUID id;
+
+ /** Job. */
+ private final TestIgniteCallable<R> job;
+
+ /**
+ * @param id Id.
+ * @param job Job.
+ */
+ public TestRemoteTask(UUID id, TestIgniteCallable<R> job) {
+ this.id = id;
+ this.job = job;
+ }
+
+ /** {@inheritDoc} */
+ @Override public R call() throws Exception {
+ Ignite ignite = Ignition.ignite(id);
+
+ return job.call(ignite);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ExecuteRemotelyTask<R> implements IgniteCallable<R> {
+ /** Ignite. */
+ @IgniteInstanceResource
+ protected Ignite ignite;
+
+ /** Job. */
+ private final TestIgniteIdxCallable<R> job;
+
+ /** Index. */
+ private final int idx;
+
+ /**
+ * @param job Job.
+ * @param idx Index.
+ */
+ public ExecuteRemotelyTask(TestIgniteIdxCallable<R> job, int idx) {
+ this.job = job;
+ this.idx = idx;
+ }
+
+ /** {@inheritDoc} */
+ @Override public R call() throws Exception {
+ job.setIgnite(ignite);
+
+ return job.call(idx);
+ }
+ }
+
+ /**
* Test counters.
*/
protected class TestCounters {
@@ -1923,17 +1993,27 @@ public abstract class GridAbstractTest extends TestCase {
}
/** */
- public static interface TestIgniteIdxCallable<R> extends Serializable {
+ public static abstract class TestIgniteIdxCallable<R> implements Serializable {
+ @IgniteInstanceResource
+ protected Ignite ignite;
+
+ /**
+ * @param ignite Ignite.
+ */
+ public void setIgnite(Ignite ignite) {
+ this.ignite = ignite;
+ }
+
/**
* @param idx Grid index.
*/
- R call(int idx) throws Exception;
+ protected abstract R call(int idx) throws Exception;
}
/** */
- public abstract static class TestIgniteIdxRunnable implements TestIgniteIdxCallable<Object> {
+ public abstract static class TestIgniteIdxRunnable extends TestIgniteIdxCallable<Void> {
/** {@inheritDoc} */
- @Override public Object call(int idx) throws Exception {
+ @Override public Void call(int idx) throws Exception {
run(idx);
return null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
index eb72252..406318f 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
@@ -42,6 +42,9 @@ import org.jetbrains.annotations.Nullable;
* Test resources for injection.
*/
public class IgniteTestResources {
+ /** Marshaller class name. */
+ public static final String MARSH_CLASS_NAME = "test.marshaller.class";
+
/** */
private static final IgniteLogger rootLog = new GridTestLog4jLogger(false);
@@ -230,8 +233,9 @@ public class IgniteTestResources {
* @throws IgniteCheckedException If failed.
*/
@SuppressWarnings("unchecked")
- public synchronized Marshaller getMarshaller() throws IgniteCheckedException {
- String marshallerName = GridTestProperties.getProperty(GridTestProperties.MARSH_CLASS_NAME);
+ public static synchronized Marshaller getMarshaller() throws IgniteCheckedException {
+ String marshallerName =
+ System.getProperty(MARSH_CLASS_NAME, GridTestProperties.getProperty(GridTestProperties.MARSH_CLASS_NAME));
Marshaller marsh;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index 4bcf51e..e4c2129 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -246,10 +246,12 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
protected static <K, V> boolean nearEnabled(final IgniteCache<K,V> cache) {
CacheConfiguration cfg = GridAbstractTest.executeOnLocalOrRemoteJvm(cache,
new TestCacheCallable<K, V, CacheConfiguration>() {
- @Override public CacheConfiguration call(Ignite ignite, IgniteCache<K, V> cache) throws Exception {
- return ((IgniteKernal)ignite).<K, V>internalCache(cache.getName()).context().config();
- }
- });
+ private static final long serialVersionUID = 0L;
+
+ @Override public CacheConfiguration call(Ignite ignite, IgniteCache<K, V> cache) throws Exception {
+ return ((IgniteKernal)ignite).<K, V>internalCache(cache.getName()).context().config();
+ }
+ });
return isNearEnabled(cfg);
}
@@ -285,10 +287,13 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
* @throws Exception If failed.
*/
@SuppressWarnings("unchecked")
- protected static <K> void loadAll(Cache<K, ?> cache, final Set<K> keys, final boolean replaceExistingValues) throws Exception {
+ protected static <K> void loadAll(Cache<K, ?> cache, final Set<K> keys, final boolean replaceExistingValues)
+ throws Exception {
IgniteCache<K, Object> cacheCp = (IgniteCache<K, Object>)cache;
GridAbstractTest.executeOnLocalOrRemoteJvm(cacheCp, new TestCacheRunnable<K, Object>() {
+ private static final long serialVersionUID = -3030833765012500545L;
+
@Override public void run(Ignite ignite, IgniteCache<K, Object> cache) throws Exception {
final AtomicReference<Exception> ex = new AtomicReference<>();
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java
index e1959e5..57fbcfc 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java
@@ -19,12 +19,12 @@ package org.apache.ignite.testframework.junits.multijvm;
import java.util.Collection;
import java.util.Map;
-import java.util.UUID;
+import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.Ignition;
import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.resources.IgniteInstanceResource;
import org.jetbrains.annotations.Nullable;
/**
@@ -38,160 +38,388 @@ public class AffinityProcessProxy<K> implements Affinity<K> {
/** Cache name. */
private final String cacheName;
- /** Grid id. */
- private final UUID gridId;
-
/**
* @param cacheName Cache name.
- * @param proxy Ignite ptocess proxy.
+ * @param proxy Ignite process proxy.
*/
public AffinityProcessProxy(String cacheName, IgniteProcessProxy proxy) {
this.cacheName = cacheName;
- gridId = proxy.getId();
- compute = proxy.remoteCompute();
- }
-
- /**
- * Returns cache instance. Method to be called from closure at another JVM.
- *
- * @return Cache.
- */
- private Affinity<Object> affinity() {
- return Ignition.ignite(gridId).affinity(cacheName);
+ this.compute = proxy.remoteCompute();
}
/** {@inheritDoc} */
@Override public int partitions() {
- return (int)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().partitions();
- }
- });
+ return compute.call(new PartitionsTask(cacheName));
}
/** {@inheritDoc} */
- @Override public int partition(final K key) {
- return (int)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().partition(key);
- }
- });
+ @Override public int partition(K key) {
+ return compute.call(new PartitionTask<>(cacheName, key));
}
/** {@inheritDoc} */
- @Override public boolean isPrimary(final ClusterNode n, final K key) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().isPrimary(n, key);
- }
- });
+ @Override public boolean isPrimary(ClusterNode n, K key) {
+ return compute.call(new PrimaryOrBackupNodeTask<>(cacheName, key, n, true, false));
}
/** {@inheritDoc} */
- @Override public boolean isBackup(final ClusterNode n, final K key) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().isBackup(n, key);
- }
- });
+ @Override public boolean isBackup(ClusterNode n, K key) {
+ return compute.call(new PrimaryOrBackupNodeTask<>(cacheName, key, n, false, true));
}
/** {@inheritDoc} */
- @Override public boolean isPrimaryOrBackup(final ClusterNode n, final K key) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().isPrimaryOrBackup(n, key);
- }
- });
+ @Override public boolean isPrimaryOrBackup(ClusterNode n, K key) {
+ return compute.call(new PrimaryOrBackupNodeTask<>(cacheName, key, n, true, true));
}
/** {@inheritDoc} */
- @Override public int[] primaryPartitions(final ClusterNode n) {
- return (int[])compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().primaryPartitions(n);
- }
- });
+ @Override public int[] primaryPartitions(ClusterNode n) {
+ return compute.call(new GetPartitionsTask(cacheName, n, true, false));
}
/** {@inheritDoc} */
- @Override public int[] backupPartitions(final ClusterNode n) {
- return (int[])compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().backupPartitions(n);
- }
- });
+ @Override public int[] backupPartitions(ClusterNode n) {
+ return compute.call(new GetPartitionsTask(cacheName, n, false, true));
}
/** {@inheritDoc} */
- @Override public int[] allPartitions(final ClusterNode n) {
- return (int[])compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().allPartitions(n);
- }
- });
+ @Override public int[] allPartitions(ClusterNode n) {
+ return compute.call(new GetPartitionsTask(cacheName, n, true, true));
}
/** {@inheritDoc} */
- @Override public Object affinityKey(final K key) {
- return compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().affinityKey(key);
- }
- });
+ @Override public Object affinityKey(K key) {
+ return compute.call(new AffinityKeyTask<>(cacheName, key));
}
/** {@inheritDoc} */
- @Override public Map<ClusterNode, Collection<K>> mapKeysToNodes(final Collection<? extends K> keys) {
- return (Map<ClusterNode, Collection<K>>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().mapKeysToNodes(keys);
- }
- });
+ @Override public Map<ClusterNode, Collection<K>> mapKeysToNodes(Collection<? extends K> keys) {
+ return compute.call(new MapKeysToNodesTask<>(cacheName, keys));
}
/** {@inheritDoc} */
- @Nullable @Override public ClusterNode mapKeyToNode(final K key) {
- return (ClusterNode)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().mapKeyToNode(key);
- }
- });
+ @Nullable @Override public ClusterNode mapKeyToNode(K key) {
+ return compute.call(new MapKeyToNodeTask<>(cacheName, key));
}
/** {@inheritDoc} */
- @Override public Collection<ClusterNode> mapKeyToPrimaryAndBackups(final K key) {
- return (Collection<ClusterNode>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().mapKeyToPrimaryAndBackups(key);
- }
- });
+ @Override public Collection<ClusterNode> mapKeyToPrimaryAndBackups(K key) {
+ return compute.call(new MapKeyToPrimaryAndBackupsTask<>(cacheName, key));
}
/** {@inheritDoc} */
- @Override public ClusterNode mapPartitionToNode(final int part) {
- return (ClusterNode)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().mapPartitionToNode(part);
- }
- });
+ @Override public ClusterNode mapPartitionToNode(int part) {
+ return compute.call(new MapPartitionToNode<>(cacheName, part));
}
/** {@inheritDoc} */
- @Override public Map<Integer, ClusterNode> mapPartitionsToNodes(final Collection<Integer> parts) {
- return (Map<Integer, ClusterNode>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().mapPartitionsToNodes(parts);
- }
- });
+ @Override public Map<Integer, ClusterNode> mapPartitionsToNodes(Collection<Integer> parts) {
+ return compute.call(new MapPartitionsToNodes<>(cacheName, parts));
}
/** {@inheritDoc} */
- @Override public Collection<ClusterNode> mapPartitionToPrimaryAndBackups(final int part) {
- return (Collection<ClusterNode>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().mapPartitionToPrimaryAndBackups(part);
- }
- });
+ @Override public Collection<ClusterNode> mapPartitionToPrimaryAndBackups(int part) {
+ return compute.call(new MapPartitionsToPrimaryAndBackupsTask<>(cacheName, part));
+ }
+
+ /**
+ *
+ */
+ private static class PrimaryOrBackupNodeTask<K> extends AffinityTaskAdapter<K, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Node. */
+ private final ClusterNode n;
+
+ /** Primary. */
+ private final boolean primary;
+
+ /** Backup. */
+ private final boolean backup;
+
+ /**
+ * @param cacheName Cache name.
+ * @param key Key.
+ * @param n N.
+ */
+ public PrimaryOrBackupNodeTask(String cacheName, K key, ClusterNode n,
+ boolean primary, boolean backup) {
+ super(cacheName);
+ this.key = key;
+ this.n = n;
+ this.primary = primary;
+ this.backup = backup;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ if (primary && backup)
+ return affinity().isPrimaryOrBackup(n, key);
+ else if (primary)
+ return affinity().isPrimary(n, key);
+ else if (backup)
+ return affinity().isBackup(n, key);
+ else
+ throw new IllegalStateException("primary or backup or both flags should be switched on");
+ }
+ }
+
+ /**
+ *
+ */
+ private static class MapKeyToPrimaryAndBackupsTask<K> extends AffinityTaskAdapter<K, Collection<ClusterNode>> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param key Key.
+ */
+ public MapKeyToPrimaryAndBackupsTask(String cacheName, K key) {
+ super(cacheName);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<ClusterNode> call() throws Exception {
+ return affinity().mapKeyToPrimaryAndBackups(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class PartitionsTask extends AffinityTaskAdapter<Void, Integer> {
+ /**
+ * @param cacheName Cache name.
+ */
+ public PartitionsTask(String cacheName) {
+ super(cacheName);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Integer call() throws Exception {
+ return affinity().partitions();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class PartitionTask<K> extends AffinityTaskAdapter<K, Integer> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param key Key.
+ */
+ public PartitionTask(String cacheName, K key) {
+ super(cacheName);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Integer call() throws Exception {
+ return affinity().partition(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetPartitionsTask extends AffinityTaskAdapter<Void, int[]> {
+ /** Node. */
+ private final ClusterNode n;
+
+ /** Primary. */
+ private final boolean primary;
+
+ /** Backup. */
+ private final boolean backup;
+
+ /**
+ * @param cacheName Cache name.
+ * @param n N.
+ * @param primary Primary.
+ * @param backup Backup.
+ */
+ public GetPartitionsTask(String cacheName, ClusterNode n, boolean primary, boolean backup) {
+ super(cacheName);
+ this.n = n;
+ this.primary = primary;
+ this.backup = backup;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int[] call() throws Exception {
+ if (primary && backup)
+ return affinity().allPartitions(n);
+ else if (primary)
+ return affinity().primaryPartitions(n);
+ else if (backup)
+ return affinity().backupPartitions(n);
+ else
+ throw new IllegalStateException("primary or backup or both flags should be switched on");
+ }
+ }
+
+ /**
+ *
+ */
+ private static class AffinityKeyTask<K> extends AffinityTaskAdapter<K, Object> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param key Key.
+ */
+ public AffinityKeyTask(String cacheName, K key) {
+ super(cacheName);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object call() throws Exception {
+ return affinity().affinityKey(key);
+ }
+ }
+
+ /**
+ * @param <K>
+ */
+ private static class MapKeysToNodesTask<K> extends AffinityTaskAdapter<K, Map<ClusterNode, Collection<K>>> {
+ /** Keys. */
+ private final Collection<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param keys Keys.
+ */
+ public MapKeysToNodesTask(String cacheName, Collection<? extends K> keys) {
+ super(cacheName);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<ClusterNode, Collection<K>> call() throws Exception {
+ return affinity().mapKeysToNodes(keys);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class MapKeyToNodeTask<K> extends AffinityTaskAdapter<K, ClusterNode> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param key Key.
+ */
+ public MapKeyToNodeTask(String cacheName, K key) {
+ super(cacheName);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ClusterNode call() throws Exception {
+ return affinity().mapKeyToNode(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class MapPartitionToNode<K> extends AffinityTaskAdapter<K, ClusterNode> {
+ /** Partition. */
+ private final int part;
+
+ /**
+ * @param cacheName Cache name.
+ * @param part Partition.
+ */
+ public MapPartitionToNode(String cacheName, int part) {
+ super(cacheName);
+ this.part = part;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ClusterNode call() throws Exception {
+ return affinity().mapPartitionToNode(part);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class MapPartitionsToNodes<K> extends AffinityTaskAdapter<K, Map<Integer, ClusterNode>> {
+ /** Parts. */
+ private final Collection<Integer> parts;
+
+ /**
+ * @param cacheName Cache name.
+ * @param parts Parts.
+ */
+ public MapPartitionsToNodes(String cacheName, Collection<Integer> parts) {
+ super(cacheName);
+ this.parts = parts;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<Integer, ClusterNode> call() throws Exception {
+ return affinity().mapPartitionsToNodes(parts);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class MapPartitionsToPrimaryAndBackupsTask<K> extends AffinityTaskAdapter<K, Collection<ClusterNode>> {
+ /** Partition. */
+ private final int part;
+
+ /**
+ * @param cacheName Cache name.
+ * @param part Partition.
+ */
+ public MapPartitionsToPrimaryAndBackupsTask(String cacheName, int part) {
+ super(cacheName);
+ this.part = part;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<ClusterNode> call() throws Exception {
+ return affinity().mapPartitionToPrimaryAndBackups(part);
+ }
+ }
+
+ /**
+ *
+ */
+ private abstract static class AffinityTaskAdapter<K, R> implements IgniteCallable<R> {
+ /** Ignite. */
+ @IgniteInstanceResource
+ protected Ignite ignite;
+
+ /** Cache name. */
+ protected final String cacheName;
+
+ /**
+ * @param cacheName Cache name.
+ */
+ public AffinityTaskAdapter(String cacheName) {
+ this.cacheName = cacheName;
+ }
+
+ /**
+ * @return Affinity.
+ */
+ protected Affinity<K> affinity() {
+ return ignite.affinity(cacheName);
+ }
}
}
\ No newline at end of file
[12/34] ignite git commit: Merge remote-tracking branch
'origin/master'
Posted by sb...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6fce2c52
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6fce2c52
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6fce2c52
Branch: refs/heads/ignite-1607
Commit: 6fce2c52fd08da232659ff5b90bf15ad60c9dced
Parents: 8fc14ec 35fa5e6
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Tue Oct 6 13:36:41 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue Oct 6 13:36:41 2015 +0300
----------------------------------------------------------------------
.../cache/GridCacheDeploymentOffHeapSelfTest.java | 15 +++++++++++++++
1 file changed, 15 insertions(+)
----------------------------------------------------------------------
[06/34] ignite git commit: IGNITE-1554 Fix igniterouter scripts.
Posted by sb...@apache.org.
IGNITE-1554 Fix igniterouter scripts.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1597e6ca
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1597e6ca
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1597e6ca
Branch: refs/heads/ignite-1607
Commit: 1597e6ca1cf9a3b59b035b0c013aa6d26c8064a1
Parents: ff96888
Author: Raul Kripalani <ra...@apache.org>
Authored: Sat Sep 26 11:31:11 2015 +0100
Committer: Raul Kripalani <ra...@apache.org>
Committed: Sat Sep 26 11:33:13 2015 +0100
----------------------------------------------------------------------
bin/igniterouter.bat | 2 +-
bin/igniterouter.sh | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1597e6ca/bin/igniterouter.bat
----------------------------------------------------------------------
diff --git a/bin/igniterouter.bat b/bin/igniterouter.bat
index b1f9148..0a9775e 100644
--- a/bin/igniterouter.bat
+++ b/bin/igniterouter.bat
@@ -27,7 +27,7 @@ if "%OS%" == "Windows_NT" setlocal
:: Set router service environment.
::
set "DEFAULT_CONFIG=config\router\default-router.xml"
-set MAIN_CLASS=org.apache.ignite.client.router.impl.GridRouterCommandLineStartup
+set MAIN_CLASS=org.apache.ignite.internal.client.router.impl.GridRouterCommandLineStartup
::
:: Start router service.
http://git-wip-us.apache.org/repos/asf/ignite/blob/1597e6ca/bin/igniterouter.sh
----------------------------------------------------------------------
diff --git a/bin/igniterouter.sh b/bin/igniterouter.sh
index 9ab848e..af27f8b 100755
--- a/bin/igniterouter.sh
+++ b/bin/igniterouter.sh
@@ -45,7 +45,7 @@ setIgniteHome
# Set router service environment.
#
export DEFAULT_CONFIG=config/router/default-router.xml
-export MAIN_CLASS=org.apache.ignite.client.router.impl.GridRouterCommandLineStartup
+export MAIN_CLASS=org.apache.ignite.internal.client.router.impl.GridRouterCommandLineStartup
#
# Start router service.
[34/34] ignite git commit: Merge remote-tracking branch
'remotes/origin/master' into ignite-1607
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/master' into ignite-1607
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/775dba2f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/775dba2f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/775dba2f
Branch: refs/heads/ignite-1607
Commit: 775dba2f9425fd2f510e0b67e6b2a764844edd5d
Parents: 236344c 6844370
Author: sboikov <sb...@gridgain.com>
Authored: Tue Oct 13 09:58:48 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Oct 13 09:58:48 2015 +0300
----------------------------------------------------------------------
.../discovery/GridDiscoveryManager.java | 479 +------------------
.../processors/cache/GridCacheIoManager.java | 29 +-
.../processors/cache/GridCacheProcessor.java | 63 +--
.../dht/GridClientPartitionTopology.java | 13 +-
.../distributed/dht/GridDhtLocalPartition.java | 3 +-
.../dht/GridDhtPartitionTopologyImpl.java | 12 +-
.../GridDhtPartitionDemandMessage.java | 4 +-
.../GridDhtPartitionSupplyMessage.java | 3 +-
.../GridDhtPartitionsExchangeFuture.java | 12 +-
.../preloader/GridDhtPartitionsFullMessage.java | 12 +-
.../GridDhtPartitionsSingleMessage.java | 11 +-
.../dht/preloader/GridDhtPreloader.java | 18 +-
.../cache/query/GridCacheQueryManager.java | 41 --
.../processors/rest/GridRestProcessor.java | 47 --
.../top/GridTopologyCommandHandler.java | 129 -----
.../communication/tcp/TcpCommunicationSpi.java | 22 +-
.../IgniteCacheConfigurationTemplateTest.java | 31 ++
.../dht/GridCacheDhtPreloadPerformanceTest.java | 133 +++++
.../near/GridCacheNearTxForceKeyTest.java | 2 +-
19 files changed, 270 insertions(+), 794 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/775dba2f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
[16/34] ignite git commit: ignite-1624 Tests muted
Posted by sb...@apache.org.
ignite-1624 Tests muted
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f60cba79
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f60cba79
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f60cba79
Branch: refs/heads/ignite-1607
Commit: f60cba7986bcde8578e4e0dc4a065fb834514373
Parents: b3d347e
Author: agura <ag...@gridgain.com>
Authored: Wed Oct 7 13:34:33 2015 +0300
Committer: agura <ag...@gridgain.com>
Committed: Wed Oct 7 13:34:33 2015 +0300
----------------------------------------------------------------------
.../ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f60cba79/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
index 9fbf5b1..0bb9a42 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
@@ -1074,6 +1074,8 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testJoinError() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1624");
+
startServerNodes(1);
Ignite ignite = G.ignite("server-0");
[10/34] ignite git commit: ignite-1618 Tests muted
Posted by sb...@apache.org.
ignite-1618 Tests muted
Signed-off-by: Anton Vinogradov <av...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/35fa5e63
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/35fa5e63
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/35fa5e63
Branch: refs/heads/ignite-1607
Commit: 35fa5e630be2840eec2f9c9500e6f79bbc841597
Parents: 8616889
Author: agura <ag...@gridgain.com>
Authored: Mon Oct 5 22:03:46 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Tue Oct 6 11:11:13 2015 +0300
----------------------------------------------------------------------
.../cache/GridCacheDeploymentOffHeapSelfTest.java | 15 +++++++++++++++
1 file changed, 15 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/35fa5e63/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentOffHeapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentOffHeapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentOffHeapSelfTest.java
index fda054f..c51d72b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentOffHeapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentOffHeapSelfTest.java
@@ -38,4 +38,19 @@ public class GridCacheDeploymentOffHeapSelfTest extends GridCacheDeploymentSelfT
return cacheCfg;
}
+
+ /** {@inheritDoc} */
+ @Override public void testDeployment() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1618");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void testDeployment6() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1618");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void testDeployment7() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1618");
+ }
}
\ No newline at end of file
[08/34] ignite git commit: 1. fixed DhtInvalidPartitionException with
force keys request. 2. added proper message to DhtInvalidPartitionException
instantiations.
Posted by sb...@apache.org.
1. fixed DhtInvalidPartitionException with force keys request.
2. added proper message to DhtInvalidPartitionException instantiations.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6e3d1b11
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6e3d1b11
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6e3d1b11
Branch: refs/heads/ignite-1607
Commit: 6e3d1b11b409a966a351875661e43f48320da3fe
Parents: 93aabaa
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Mon Oct 5 10:59:41 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Mon Oct 5 10:59:41 2015 +0300
----------------------------------------------------------------------
.../dht/GridClientPartitionTopology.java | 13 +++++++++----
.../distributed/dht/GridDhtLocalPartition.java | 3 ++-
.../dht/GridDhtPartitionTopologyImpl.java | 12 +++++++-----
.../dht/preloader/GridDhtPreloader.java | 18 +++++++++++++++---
.../near/GridCacheNearTxForceKeyTest.java | 2 +-
5 files changed, 34 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/6e3d1b11/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
index 5e3cc0b..162c116 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
@@ -313,13 +313,18 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology {
}
/** {@inheritDoc} */
- @Nullable @Override public GridDhtLocalPartition localPartition(int p, AffinityTopologyVersion topVer, boolean create)
+ @Nullable @Override public GridDhtLocalPartition localPartition(
+ int p,
+ AffinityTopologyVersion topVer,
+ boolean create
+ )
throws GridDhtInvalidPartitionException {
if (!create)
return null;
- throw new GridDhtInvalidPartitionException(p, "Adding entry to evicted partition [part=" + p +
- ", topVer=" + topVer + ", this.topVer=" + this.topVer + ']');
+ throw new GridDhtInvalidPartitionException(p, "Adding entry to evicted partition (often may be caused by " +
+ "inconsistent 'key.hashCode()' implementation) " +
+ "[part=" + p + ", topVer=" + topVer + ", this.topVer=" + this.topVer + ']');
}
/** {@inheritDoc} */
@@ -912,4 +917,4 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology {
}
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6e3d1b11/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
index 2deabfe..4f124e6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
@@ -258,7 +258,8 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
GridDhtPartitionState state = state();
if (state == EVICTED)
- throw new GridDhtInvalidPartitionException(id, "Adding entry to invalid partition [part=" + id + ']');
+ throw new GridDhtInvalidPartitionException(id, "Adding entry to invalid partition " +
+ "(often may be caused by inconsistent 'key.hashCode()' implementation) [part=" + id + ']');
map.put(entry.key(), entry);
http://git-wip-us.apache.org/repos/asf/ignite/blob/6e3d1b11/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index a0c9c88..6bd283a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -563,16 +563,18 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
return null;
if (!belongs)
- throw new GridDhtInvalidPartitionException(p, "Adding entry to evicted partition [part=" + p +
- ", topVer=" + topVer + ", this.topVer=" + this.topVer + ']');
+ throw new GridDhtInvalidPartitionException(p, "Adding entry to evicted partition " +
+ "(often may be caused by inconsistent 'key.hashCode()' implementation) " +
+ "[part=" + p + ", topVer=" + topVer + ", this.topVer=" + this.topVer + ']');
continue;
}
if (loc == null && create) {
if (!belongs)
- throw new GridDhtInvalidPartitionException(p, "Creating partition which does not belong [part=" +
- p + ", topVer=" + topVer + ", this.topVer=" + this.topVer + ']');
+ throw new GridDhtInvalidPartitionException(p, "Creating partition which does not belong to " +
+ "local node (often may be caused by inconsistent 'key.hashCode()' implementation) " +
+ "[part=" + p + ", topVer=" + topVer + ", this.topVer=" + this.topVer + ']');
lock.writeLock().lock();
@@ -1324,4 +1326,4 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
}
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6e3d1b11/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
index 36c80a9..67985a3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
@@ -42,6 +42,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffini
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentResponse;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAssignmentFetchFuture;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtFuture;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
import org.apache.ignite.internal.util.GridAtomicLong;
@@ -373,10 +374,13 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
GridDhtLocalPartition locPart = top.localPartition(p, AffinityTopologyVersion.NONE, false);
// If this node is no longer an owner.
- if (locPart == null && !top.owners(p).contains(loc))
+ if (locPart == null && !top.owners(p).contains(loc)) {
res.addMissed(k);
- GridCacheEntryEx entry;
+ continue;
+ }
+
+ GridCacheEntryEx entry = null;
if (cctx.isSwapOrOffheapEnabled()) {
while (true) {
@@ -391,6 +395,14 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
if (log.isDebugEnabled())
log.debug("Got removed entry: " + k);
}
+ catch (GridDhtInvalidPartitionException ignore) {
+ if (log.isDebugEnabled())
+ log.debug("Local node is no longer an owner: " + p);
+
+ res.addMissed(k);
+
+ break;
+ }
}
}
else
@@ -619,4 +631,4 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
*/
protected abstract void onMessage(ClusterNode node, M msg);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6e3d1b11/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxForceKeyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxForceKeyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxForceKeyTest.java
index 6d8c190..348597e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxForceKeyTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxForceKeyTest.java
@@ -76,4 +76,4 @@ public class GridCacheNearTxForceKeyTest extends GridCommonAbstractTest {
assertTrue(ignite0.affinity(null).isPrimary(ignite1.cluster().localNode(), key));
}
-}
\ No newline at end of file
+}
[03/34] ignite git commit: skip deployment of schema-import demo
(cherry picked from commit 656b118)
Posted by sb...@apache.org.
skip deployment of schema-import demo
(cherry picked from commit 656b118)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b64a8282
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b64a8282
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b64a8282
Branch: refs/heads/ignite-1607
Commit: b64a828203f94df03f57b66d74bc998f6787ab7b
Parents: e5e72ea
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Sep 25 10:54:22 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Sep 25 11:01:43 2015 +0300
----------------------------------------------------------------------
examples/schema-import/pom.xml | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b64a8282/examples/schema-import/pom.xml
----------------------------------------------------------------------
diff --git a/examples/schema-import/pom.xml b/examples/schema-import/pom.xml
index 05de048..46bc83e 100644
--- a/examples/schema-import/pom.xml
+++ b/examples/schema-import/pom.xml
@@ -20,7 +20,8 @@
<!--
POM file.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -88,6 +89,14 @@
<target>1.7</target>
</configuration>
</plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
[13/34] ignite git commit: Minor fixes
Posted by sb...@apache.org.
Minor fixes
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/833405e3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/833405e3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/833405e3
Branch: refs/heads/ignite-1607
Commit: 833405e355a10e86db8054497d92f0b459c6e399
Parents: 6fce2c5
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Tue Oct 6 13:37:25 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue Oct 6 13:37:25 2015 +0300
----------------------------------------------------------------------
modules/yardstick/pom.xml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/833405e3/modules/yardstick/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/pom.xml b/modules/yardstick/pom.xml
index d18e1a9..c87ecbc 100644
--- a/modules/yardstick/pom.xml
+++ b/modules/yardstick/pom.xml
@@ -20,7 +20,9 @@
<!--
POM file.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
[07/34] ignite git commit: IGNITE-1557 (cherry picked from commit
00e61e5)
Posted by sb...@apache.org.
IGNITE-1557
(cherry picked from commit 00e61e5)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/93aabaa4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/93aabaa4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/93aabaa4
Branch: refs/heads/ignite-1607
Commit: 93aabaa4b02b1cb58d1ece49638a22d8a26bdb91
Parents: 1597e6c
Author: Anton Vinogradov <av...@apache.org>
Authored: Mon Sep 28 14:00:23 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Sep 28 14:02:57 2015 +0300
----------------------------------------------------------------------
pom.xml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/93aabaa4/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 6a17668..e218453 100644
--- a/pom.xml
+++ b/pom.xml
@@ -901,6 +901,22 @@
</execution>
</executions>
</plugin>
+
+ <plugin><!-- skipping generates dependencies licenses -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-remote-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>ignite-dependencies</id>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
[32/34] ignite git commit: ignite-1.4.2 - Fixed resource cleanup for
caches created from template.
Posted by sb...@apache.org.
ignite-1.4.2 - Fixed resource cleanup for caches created from template.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/30b731b3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/30b731b3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/30b731b3
Branch: refs/heads/ignite-1607
Commit: 30b731b3c54609b77293e08c401db2d96e48e8d9
Parents: 94f549f
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Oct 12 16:09:59 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Oct 12 16:09:59 2015 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheProcessor.java | 23 ++++++++++-----
.../IgniteCacheConfigurationTemplateTest.java | 31 ++++++++++++++++++++
2 files changed, 46 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/30b731b3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 8c96c0c..722e570 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -639,7 +639,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (ctx.config().isDaemon() && !CU.isMarshallerCache(cfgs[i].getName()))
continue;
- checkSerializable(cfgs[i]);
+ cloneCheckSerializable(cfgs[i]);
CacheConfiguration<?, ?> cfg = new CacheConfiguration(cfgs[i]);
@@ -2023,9 +2023,14 @@ public class GridCacheProcessor extends GridProcessorAdapter {
* @return Future that will be completed when cache is deployed.
*/
public IgniteInternalFuture<?> createFromTemplate(String cacheName) {
- CacheConfiguration cfg = createConfigFromTemplate(cacheName);
+ try {
+ CacheConfiguration cfg = createConfigFromTemplate(cacheName);
- return dynamicStartCache(cfg, cacheName, null, true, true);
+ return dynamicStartCache(cfg, cacheName, null, true, true);
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
}
/**
@@ -2052,7 +2057,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
* @param cacheName Cache name.
* @return Cache configuration.
*/
- private CacheConfiguration createConfigFromTemplate(String cacheName) {
+ private CacheConfiguration createConfigFromTemplate(String cacheName) throws IgniteCheckedException {
CacheConfiguration cfgTemplate = null;
CacheConfiguration dfltCacheCfg = null;
@@ -2112,6 +2117,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (cfgTemplate == null)
cfgTemplate = new CacheConfiguration();
+ else
+ cfgTemplate = cloneCheckSerializable(cfgTemplate);
CacheConfiguration cfg = new CacheConfiguration(cfgTemplate);
@@ -2168,7 +2175,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (ccfg != null) {
try {
- checkSerializable(ccfg);
+ cloneCheckSerializable(ccfg);
}
catch (IgniteCheckedException e) {
return new GridFinishedFuture<>(e);
@@ -3340,9 +3347,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
* @param val Object to check.
* @throws IgniteCheckedException If validation failed.
*/
- private void checkSerializable(CacheConfiguration val) throws IgniteCheckedException {
+ private CacheConfiguration cloneCheckSerializable(CacheConfiguration val) throws IgniteCheckedException {
if (val == null)
- return;
+ return null;
if (val.getCacheStoreFactory() != null) {
try {
@@ -3356,7 +3363,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
try {
- marshaller.unmarshal(marshaller.marshal(val), val.getClass().getClassLoader());
+ return marshaller.unmarshal(marshaller.marshal(val), val.getClass().getClassLoader());
}
catch (IgniteCheckedException e) {
throw new IgniteCheckedException("Failed to validate cache configuration " +
http://git-wip-us.apache.org/repos/asf/ignite/blob/30b731b3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java
index d3ba2d6..87a30a6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java
@@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheExistsException;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.events.Event;
@@ -365,6 +366,36 @@ public class IgniteCacheConfigurationTemplateTest extends GridCommonAbstractTest
}
/**
+ * @throws Exception If failed.
+ */
+ public void testTemplateCleanup() throws Exception {
+ startGridsMultiThreaded(3);
+
+ try {
+ CacheConfiguration ccfg = new CacheConfiguration("affTemplate-*");
+
+ ccfg.setAffinity(new RendezvousAffinityFunction());
+
+ ignite(0).addCacheConfiguration(ccfg);
+
+ ignite(0).getOrCreateCache("affTemplate-1");
+
+ IgniteCache<Object, Object> cache = ignite(0).getOrCreateCache("affTemplate-2");
+
+ ignite(0).destroyCache("affTemplate-1");
+
+ startGrid(3);
+
+ cache.put(1, 1);
+
+ assertEquals(1, cache.get(1));
+ }
+ finally {
+ stopAllGrids();
+ }
+ }
+
+ /**
* @param ignite Ignite.
* @param name Cache name.
* @param expBackups Expected number of backups.
[02/34] ignite git commit: ignite-1.4 Added schema-import-demo to
exclude. (cherry picked from commit 008c273)
Posted by sb...@apache.org.
ignite-1.4 Added schema-import-demo to exclude.
(cherry picked from commit 008c273)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d2cdf60a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d2cdf60a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d2cdf60a
Branch: refs/heads/ignite-1607
Commit: d2cdf60ad5b6500d98dfd7189dbfe7bedc3af354
Parents: e5e72ea
Author: Andrey <an...@gridgain.com>
Authored: Fri Sep 25 10:29:51 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Fri Sep 25 13:01:12 2015 +0700
----------------------------------------------------------------------
assembly/dependencies-fabric.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d2cdf60a/assembly/dependencies-fabric.xml
----------------------------------------------------------------------
diff --git a/assembly/dependencies-fabric.xml b/assembly/dependencies-fabric.xml
index f69ffde..f50847e 100644
--- a/assembly/dependencies-fabric.xml
+++ b/assembly/dependencies-fabric.xml
@@ -120,11 +120,11 @@
<exclude>org.apache.ignite:ignite-extdata-uri</exclude>
<exclude>org.apache.ignite:ignite-extdata-uri-dep</exclude>
<exclude>org.apache.ignite:ignite-examples</exclude>
+ <exclude>org.apache.ignite:ignite-schema-import-demo</exclude>
<exclude>org.apache.ignite:ignite-indexing</exclude>
<exclude>org.apache.ignite:ignite-visor-console</exclude>
<exclude>org.apache.ignite:ignite-visor-console_2.10</exclude>
<exclude>org.apache.ignite:ignite-visor-plugins</exclude>
- <exclude>org.apache.ignite:ignite-visor-trial</exclude>
<exclude>org.apache.ignite:ignite-hadoop</exclude>
<exclude>org.apache.ignite:ignite-schema-import</exclude>
<exclude>org.apache.ignite:ignite-codegen</exclude>
[15/34] ignite git commit: ignite-1112 Tests muted.
Posted by sb...@apache.org.
ignite-1112 Tests muted.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b3d347e3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b3d347e3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b3d347e3
Branch: refs/heads/ignite-1607
Commit: b3d347e35a254928fd1c4a0473f1b17d642c72f3
Parents: 2580994
Author: agura <ag...@gridgain.com>
Authored: Tue Oct 6 15:38:04 2015 +0300
Committer: agura <ag...@gridgain.com>
Committed: Tue Oct 6 15:38:04 2015 +0300
----------------------------------------------------------------------
...cheAtomicNearEnabledFairAffinityMultiJvmFullApiSelfTest.java | 5 +++++
.../GridCacheAtomicNearEnabledMultiJvmFullApiSelfTest.java | 5 +++++
2 files changed, 10 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b3d347e3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicNearEnabledFairAffinityMultiJvmFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicNearEnabledFairAffinityMultiJvmFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicNearEnabledFairAffinityMultiJvmFullApiSelfTest.java
index 8edf8b4..0948a1d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicNearEnabledFairAffinityMultiJvmFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicNearEnabledFairAffinityMultiJvmFullApiSelfTest.java
@@ -28,4 +28,9 @@ public class GridCacheAtomicNearEnabledFairAffinityMultiJvmFullApiSelfTest exten
protected boolean isMultiJvm() {
return true;
}
+
+ /** {@inheritDoc} */
+ @Override public void testPutAllPutAll() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1112");
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/b3d347e3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicNearEnabledMultiJvmFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicNearEnabledMultiJvmFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicNearEnabledMultiJvmFullApiSelfTest.java
index d11c679..8623de1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicNearEnabledMultiJvmFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicNearEnabledMultiJvmFullApiSelfTest.java
@@ -28,4 +28,9 @@ public class GridCacheAtomicNearEnabledMultiJvmFullApiSelfTest extends
protected boolean isMultiJvm() {
return true;
}
+
+ /** {@inheritDoc} */
+ @Override public void testPutAllPutAll() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1112");
+ }
}
\ No newline at end of file
[27/34] ignite git commit: Merge branch master into ignite-1.4.2
Posted by sb...@apache.org.
Merge branch master into ignite-1.4.2
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4ee154c8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4ee154c8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4ee154c8
Branch: refs/heads/ignite-1607
Commit: 4ee154c808ac0d7384cdfc0dfc5c1ef5733e7e1b
Parents: 6afc2fc 1223525
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Oct 12 12:28:00 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Oct 12 12:28:00 2015 +0300
----------------------------------------------------------------------
examples/pom.xml | 2 +-
examples/schema-import/pom.xml | 5 +-
.../computegrid/ComputeClosureExample.java | 2 +-
.../socket/WordsSocketStreamerServer.java | 5 +-
modules/aop/pom.xml | 2 +-
modules/apache-license-gen/README.txt | 33 +
modules/apache-license-gen/pom.xml | 2 +-
modules/aws/pom.xml | 2 +-
modules/clients/pom.xml | 2 +-
.../JettyRestProcessorAbstractSelfTest.java | 252 ++++-
modules/cloud/pom.xml | 2 +-
.../TcpDiscoveryCloudIpFinderSelfTest.java | 2 +
modules/codegen/pom.xml | 2 +-
modules/core/pom.xml | 2 +-
.../org/apache/ignite/IgniteAtomicLong.java | 15 +-
.../apache/ignite/IgniteAtomicReference.java | 9 +-
.../org/apache/ignite/IgniteAtomicSequence.java | 9 +-
.../org/apache/ignite/IgniteAtomicStamped.java | 13 +-
.../org/apache/ignite/IgniteFileSystem.java | 4 +-
.../apache/ignite/IgniteSystemProperties.java | 3 +
.../configuration/CacheConfiguration.java | 2 +-
.../ignite/configuration/TopologyValidator.java | 38 +-
.../java/org/apache/ignite/igfs/IgfsPath.java | 2 +-
.../apache/ignite/internal/IgniteKernal.java | 70 +-
.../managers/discovery/CustomEventListener.java | 4 +-
.../discovery/GridDiscoveryManager.java | 541 ++++++++++-
.../cache/DynamicCacheChangeRequest.java | 19 +
.../cache/DynamicCacheDescriptor.java | 36 +
.../processors/cache/GridCacheContext.java | 2 +-
.../processors/cache/GridCacheEventManager.java | 12 +-
.../cache/GridCacheExplicitLockSpan.java | 13 +-
.../processors/cache/GridCacheIoManager.java | 76 +-
.../processors/cache/GridCacheMessage.java | 7 -
.../cache/GridCacheMvccCandidate.java | 5 +-
.../processors/cache/GridCacheMvccManager.java | 67 +-
.../GridCachePartitionExchangeManager.java | 92 +-
.../processors/cache/GridCacheProcessor.java | 157 ++-
.../cache/GridCacheSharedContext.java | 32 -
.../processors/cache/GridCacheSwapManager.java | 4 +-
.../processors/cache/GridCacheUtils.java | 8 -
.../distributed/GridDistributedCacheEntry.java | 2 +-
.../dht/GridDhtAffinityAssignmentRequest.java | 5 -
.../dht/GridDhtAffinityAssignmentResponse.java | 5 -
.../cache/distributed/dht/GridDhtGetFuture.java | 4 +-
.../distributed/dht/GridDhtLockRequest.java | 10 +-
.../distributed/dht/GridDhtTxFinishRequest.java | 5 -
.../distributed/dht/GridDhtTxPrepareFuture.java | 6 +-
.../dht/GridDhtTxPrepareRequest.java | 7 +-
.../dht/GridPartitionedGetFuture.java | 5 +-
.../dht/atomic/GridDhtAtomicUpdateFuture.java | 5 +
.../dht/atomic/GridNearAtomicUpdateFuture.java | 17 +-
.../dht/colocated/GridDhtColocatedCache.java | 12 +-
.../colocated/GridDhtColocatedLockFuture.java | 27 +-
.../dht/preloader/GridDhtForceKeysRequest.java | 5 -
.../dht/preloader/GridDhtForceKeysResponse.java | 5 -
.../GridDhtPartitionDemandMessage.java | 5 -
.../GridDhtPartitionSupplyMessage.java | 5 -
.../GridDhtPartitionsAbstractMessage.java | 5 -
.../dht/preloader/GridDhtPreloader.java | 8 +-
.../distributed/near/GridNearGetFuture.java | 2 +
.../distributed/near/GridNearLockFuture.java | 11 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 24 +-
.../near/GridNearTxFinishFuture.java | 4 +-
.../cache/distributed/near/GridNearTxLocal.java | 21 +-
.../cache/local/GridLocalCacheEntry.java | 2 +-
.../cache/query/GridCacheQueryManager.java | 74 +-
.../cache/query/GridCacheSqlIndexMetadata.java | 7 +-
.../cache/query/GridCacheSqlMetadata.java | 22 +-
.../continuous/CacheContinuousQueryHandler.java | 10 +-
.../transactions/IgniteTxLocalAdapter.java | 35 +-
.../continuous/GridContinuousProcessor.java | 17 +-
.../datastructures/DataStructuresProcessor.java | 54 +-
.../internal/processors/igfs/IgfsFileInfo.java | 15 +-
.../internal/processors/igfs/IgfsImpl.java | 208 +---
.../processors/igfs/IgfsMetaManager.java | 594 ++++++++++--
.../processors/rest/GridRestCommand.java | 8 +-
.../processors/rest/GridRestProcessor.java | 411 +++++++-
.../handlers/cache/GridCacheCommandHandler.java | 364 +++----
.../handlers/query/QueryCommandHandler.java | 195 ++--
.../top/GridTopologyCommandHandler.java | 160 ++-
.../rest/request/RestQueryRequest.java | 175 ++++
.../rest/request/RestSqlQueryRequest.java | 125 ---
.../ignite/internal/util/GridArgumentCheck.java | 5 +-
.../ignite/internal/util/IgniteUtils.java | 2 +-
.../util/nio/GridNioRecoveryDescriptor.java | 4 +-
.../org/apache/ignite/stream/StreamAdapter.java | 104 +-
.../stream/StreamMultipleTupleExtractor.java | 38 +
.../stream/StreamSingleTupleExtractor.java | 40 +
.../ignite/stream/StreamTupleExtractor.java | 20 +-
.../ignite/stream/socket/SocketStreamer.java | 3 +-
.../core/src/main/resources/ignite.properties | 2 +-
.../ignite/igfs/IgfsFragmentizerSelfTest.java | 2 +-
.../internal/GridUpdateNotifierSelfTest.java | 1 +
.../IgniteClientReconnectAbstractTest.java | 35 +-
.../IgniteClientReconnectCacheTest.java | 154 +++
.../GridDiscoveryManagerAliveCacheSelfTest.java | 2 +
.../processors/cache/CrossCacheLockTest.java | 142 +++
.../GridCacheAbstractFailoverSelfTest.java | 3 +
.../GridCacheAbstractRemoveFailureTest.java | 3 +
.../GridCacheDeploymentOffHeapSelfTest.java | 15 +
.../GridCacheFinishPartitionsSelfTest.java | 5 +-
.../GridCacheVariableTopologySelfTest.java | 3 +-
...IgniteCacheAtomicPutAllFailoverSelfTest.java | 4 +
.../cache/IgniteCacheCreateRestartSelfTest.java | 3 +
.../cache/IgniteCacheEntryListenerTxTest.java | 4 +
.../IgniteCacheP2pUnmarshallingErrorTest.java | 7 +
...CacheP2pUnmarshallingRebalanceErrorTest.java | 12 +-
.../cache/IgniteCachePutAllRestartTest.java | 4 +-
.../cache/IgniteDynamicCacheFilterTest.java | 150 +++
.../IgniteTxExceptionAbstractSelfTest.java | 3 +
...omicOffheapQueueCreateMultiNodeSelfTest.java | 5 -
...ionedAtomicQueueCreateMultiNodeSelfTest.java | 9 +-
...artitionedOffHeapValuesQueueApiSelfTest.java | 4 +
...PartitionedQueueCreateMultiNodeSelfTest.java | 16 +-
...nedQueueFailoverDataConsistencySelfTest.java | 5 -
...GridCachePartitionedSetFailoverSelfTest.java | 4 +
...acheAsyncOperationsFailoverAbstractTest.java | 11 +
.../CacheGetFutureHangsSelfTest.java | 159 ++-
.../CachePutAllFailoverAbstractTest.java | 11 +
.../IgniteCacheAtomicNodeRestartTest.java | 8 +
...niteCacheClientNodeChangingTopologyTest.java | 6 +-
.../IgniteCacheCreatePutMultiNodeSelfTest.java | 151 +++
.../distributed/IgniteCacheCreatePutTest.java | 125 +++
.../IgniteCachePutGetRestartAbstractTest.java | 3 +
.../IgniteCacheSizeFailoverTest.java | 3 +
.../IgniteTxPreloadAbstractTest.java | 43 +-
.../GridCacheColocatedTxExceptionSelfTest.java | 5 -
.../dht/GridNearCacheTxNodeFailureSelfTest.java | 4 +
...gniteAtomicLongChangingTopologySelfTest.java | 186 +++-
.../IgniteCacheCrossCacheTxFailoverTest.java | 3 +
.../IgniteCrossCacheTxNearEnabledSelfTest.java | 28 +
.../dht/IgniteCrossCacheTxSelfTest.java | 213 ++++
...ledFairAffinityMultiNodeFullApiSelfTest.java | 4 +
.../near/GridCacheNearTxExceptionSelfTest.java | 9 +-
.../near/NearCacheMultithreadedUpdateTest.java | 217 +++++
.../GridCacheReplicatedInvalidateSelfTest.java | 249 -----
.../GridCacheReplicatedTxExceptionSelfTest.java | 5 -
.../replicated/GridReplicatedTxPreloadTest.java | 2 -
...eCacheExpiryPolicyWithStoreAbstractTest.java | 5 +-
.../GridCacheLocalTxExceptionSelfTest.java | 5 -
...bledFairAffinityMultiJvmFullApiSelfTest.java | 5 +
...tomicNearEnabledMultiJvmFullApiSelfTest.java | 5 +
.../DataStreamerMultiThreadedSelfTest.java | 4 +-
.../DataStreamerMultinodeCreateCacheTest.java | 2 +
.../processors/igfs/IgfsAbstractSelfTest.java | 378 ++++++--
.../igfs/IgfsClientCacheSelfTest.java | 15 +-
.../igfs/IgfsMetaManagerSelfTest.java | 100 +-
.../processors/igfs/IgfsMetricsSelfTest.java | 2 +-
.../processors/igfs/IgfsProcessorSelfTest.java | 29 +-
.../igfs/UniversalFileSystemAdapter.java | 1 -
.../tcp/TcpClientDiscoverySpiSelfTest.java | 2 +
.../stream/socket/SocketStreamerSelfTest.java | 112 ++-
.../multijvm/IgniteCacheProcessProxy.java | 965 +++++++++++++++++++
.../IgniteCacheFailoverTestSuite.java | 4 -
.../IgniteCacheFailoverTestSuite3.java | 28 +-
.../testsuites/IgniteCacheTestSuite3.java | 2 -
.../testsuites/IgniteCacheTestSuite4.java | 22 +
modules/extdata/p2p/pom.xml | 2 +-
.../extdata/uri/modules/uri-dependency/pom.xml | 2 +-
modules/extdata/uri/pom.xml | 2 +-
modules/gce/pom.xml | 2 +-
modules/geospatial/pom.xml | 2 +-
modules/hadoop/pom.xml | 2 +-
.../processors/hadoop/igfs/HadoopIgfsUtils.java | 36 +
.../ignite/igfs/Hadoop1DualAbstractTest.java | 5 +
...oopFileSystemUniversalFileSystemAdapter.java | 4 +-
.../HadoopIgfs20FileSystemAbstractSelfTest.java | 7 +-
.../IgniteHadoopFileSystemAbstractSelfTest.java | 5 +-
.../testsuites/IgniteHadoopTestSuite.java | 19 +-
modules/hibernate/pom.xml | 2 +-
modules/indexing/pom.xml | 2 +-
.../processors/query/h2/sql/GridSqlArray.java | 52 +
.../processors/query/h2/sql/GridSqlElement.java | 2 +-
.../query/h2/sql/GridSqlFunction.java | 60 +-
.../query/h2/sql/GridSqlFunctionType.java | 3 +
.../query/h2/sql/GridSqlPlaceholder.java | 7 +-
.../query/h2/sql/GridSqlQueryParser.java | 84 +-
.../processors/query/h2/sql/GridSqlType.java | 29 +-
.../query/h2/sql/GridQueryParsingTest.java | 27 +
modules/jcl/pom.xml | 2 +-
modules/jms11/pom.xml | 2 +-
modules/jta/pom.xml | 2 +-
modules/kafka/pom.xml | 2 +-
modules/log4j/pom.xml | 2 +-
modules/log4j2/pom.xml | 2 +-
modules/mesos/pom.xml | 2 +-
modules/mqtt/pom.xml | 114 +++
.../apache/ignite/stream/mqtt/MqttStreamer.java | 611 ++++++++++++
.../stream/mqtt/IgniteMqttStreamerTest.java | 553 +++++++++++
.../mqtt/IgniteMqttStreamerTestSuite.java | 34 +
modules/platform/pom.xml | 2 +-
.../platform/src/main/cpp/common/configure.ac | 2 +-
.../src/main/cpp/core-test/configure.ac | 2 +-
modules/platform/src/main/cpp/core/configure.ac | 2 +-
.../Properties/AssemblyInfo.cs | 6 +-
.../Apache.Ignite/Properties/AssemblyInfo.cs | 6 +-
.../Properties/AssemblyInfo.cs | 6 +-
.../Properties/AssemblyInfo.cs | 6 +-
modules/rest-http/pom.xml | 2 +-
.../http/jetty/GridJettyJsonConfig.java | 158 ++-
.../http/jetty/GridJettyRestHandler.java | 186 ++--
modules/scalar-2.10/pom.xml | 2 +-
modules/scalar/pom.xml | 2 +-
modules/schedule/pom.xml | 2 +-
modules/schema-import/pom.xml | 2 +-
modules/slf4j/pom.xml | 2 +-
modules/spark-2.10/pom.xml | 2 +-
modules/spark/pom.xml | 2 +-
modules/spring/pom.xml | 2 +-
modules/ssh/pom.xml | 2 +-
modules/tools/pom.xml | 2 +-
modules/urideploy/pom.xml | 2 +-
modules/visor-console-2.10/pom.xml | 2 +-
modules/visor-console/pom.xml | 2 +-
.../visor/commands/kill/VisorKillCommand.scala | 2 +-
.../scala/org/apache/ignite/visor/visor.scala | 1 -
modules/visor-plugins/pom.xml | 2 +-
modules/web/pom.xml | 2 +-
.../config/benchmark-put-indexed-val.properties | 2 +-
modules/yardstick/pom.xml | 12 +-
modules/yarn/pom.xml | 2 +-
modules/zookeeper/pom.xml | 2 +-
pom.xml | 3 +-
223 files changed, 8182 insertions(+), 2112 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4ee154c8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4ee154c8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4ee154c8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4ee154c8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4ee154c8/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index 02c6a26,d89e397..ddce314
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@@ -426,963 -427,963 +427,1927 @@@ public class IgniteCacheProcessProxy<K
*
*/
private static class GetConfigurationTask<K, V, C extends Configuration<K, V>> extends CacheTaskAdapter<K, V, C> {
+ /** Clazz. */
+ private final Class<C> clazz;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param clazz Clazz.
+ */
+ public GetConfigurationTask(String cacheName, boolean async, Class<C> clazz) {
+ super(cacheName, async);
+ this.clazz = clazz;
+ }
+
+ /** {@inheritDoc} */
+ @Override public C call() throws Exception {
+ return cache().getConfiguration(clazz);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class LocalLoadCacheTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+ /** Predicate. */
+ private final IgniteBiPredicate<K, V> p;
+
+ /** Args. */
+ private final Object[] args;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param p P.
+ * @param args Args.
+ */
+ public LocalLoadCacheTask(String cacheName, boolean async, IgniteBiPredicate<K, V> p, Object[] args) {
+ super(cacheName, async);
+ this.p = p;
+ this.args = args;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().localLoadCache(p, args);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAndPutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public GetAndPutIfAbsentTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().getAndPutIfAbsent(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IsLocalLockedTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** By current thread. */
+ private final boolean byCurrThread;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param byCurrThread By current thread.
+ */
+ public IsLocalLockedTask(String cacheName, boolean async, K key, boolean byCurrThread) {
+ super(cacheName, async);
+ this.key = key;
+ this.byCurrThread = byCurrThread;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().isLocalLocked(key, byCurrThread);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class LocalEntriesTask<K, V> extends CacheTaskAdapter<K, V, Iterable<Entry<K, V>>> {
+ /** Peek modes. */
+ private final CachePeekMode[] peekModes;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param peekModes Peek modes.
+ */
+ public LocalEntriesTask(String cacheName, boolean async, CachePeekMode[] peekModes) {
+ super(cacheName, async);
+ this.peekModes = peekModes;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Iterable<Entry<K, V>> call() throws Exception {
+ Collection<Entry<K, V>> res = new ArrayList<>();
+
+ for (Entry<K, V> e : cache().localEntries(peekModes))
+ res.add(new CacheEntryImpl<>(e.getKey(), e.getValue()));
+
+ return res;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class LocalEvictTask<K> extends CacheTaskAdapter<K, Void, Void> {
+ /** Keys. */
+ private final Collection<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public LocalEvictTask(String cacheName, boolean async, Collection<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().localEvict(keys);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class LocalPeekTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /** Peek modes. */
+ private final CachePeekMode[] peekModes;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param peekModes Peek modes.
+ */
+ public LocalPeekTask(String cacheName, boolean async, K key, CachePeekMode[] peekModes) {
+ super(cacheName, async);
+ this.key = key;
+ this.peekModes = peekModes;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().localPeek(key, peekModes);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class SizeTask extends CacheTaskAdapter<Void, Void, Integer> {
+ /** Peek modes. */
+ private final CachePeekMode[] peekModes;
+
+ /** Local. */
+ private final boolean loc;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param peekModes Peek modes.
+ * @param loc Local.
+ */
+ public SizeTask(String cacheName, boolean async, CachePeekMode[] peekModes, boolean loc) {
+ super(cacheName, async);
+ this.loc = loc;
+ this.peekModes = peekModes;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Integer call() throws Exception {
+ return loc ? cache().localSize(peekModes) : cache().size(peekModes);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public GetTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().get(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public RemoveAllTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ IgniteCache<K, V> cache = cache();
+
+ cache.removeAll();
+
+ if (async)
+ cache.future().get();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class PutTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public PutTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().put(key, val);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ContainsKeyTask<K> extends CacheTaskAdapter<K, Object, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public ContainsKeyTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().containsKey(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ClearTask extends CacheTaskAdapter<Object, Object, Void> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public ClearTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().clear();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IteratorTask<K, V> extends CacheTaskAdapter<K, V, Collection<Entry<K, V>>> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public IteratorTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<Entry<K, V>> call() throws Exception {
+ Collection<Entry<K, V>> res = new ArrayList<>();
+
+ for (Entry<K, V> o : cache())
+ res.add(o);
+
+ return res;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ReplaceTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public ReplaceTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().replace(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetNameTask extends CacheTaskAdapter<Void, Void, String> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public GetNameTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String call() throws Exception {
+ return cache().getName();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public RemoveTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().remove(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class PutAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+ /** Map. */
+ private final Map<? extends K, ? extends V> map;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param map Map.
+ */
+ public PutAllTask(String cacheName, boolean async, Map<? extends K, ? extends V> map) {
+ super(cacheName, async);
+ this.map = map;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().putAll(map);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveAllKeysTask<K> extends CacheTaskAdapter<K, Void, Void> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public RemoveAllKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().removeAll(keys);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAllTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public GetAllTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, V> call() throws Exception {
+ return cache().getAll(keys);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAllOutTxTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public GetAllOutTxTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, V> call() throws Exception {
+ return cache().getAllOutTx(keys);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ContainsKeysTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public ContainsKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().containsKeys(keys);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAndPutTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public GetAndPutTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().getAndPut(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class PutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public PutIfAbsentTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().putIfAbsent(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Old value. */
+ private final V oldVal;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param oldVal Old value.
+ */
+ public RemoveIfExistsTask(String cacheName, boolean async, K key, V oldVal) {
+ super(cacheName, async);
+ this.key = key;
+ this.oldVal = oldVal;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().remove(key, oldVal);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAndRemoveTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public GetAndRemoveTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().getAndRemove(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ReplaceIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Old value. */
+ private final V oldVal;
+
+ /** New value. */
+ private final V newVal;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param oldVal Old value.
+ * @param newVal New value.
+ */
+ public ReplaceIfExistsTask(String cacheName, boolean async, K key, V oldVal, V newVal) {
+ super(cacheName, async);
+ this.key = key;
+ this.oldVal = oldVal;
+ this.newVal = newVal;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().replace(key, oldVal, newVal);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAndReplaceTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public GetAndReplaceTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().getAndReplace(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ClearKeyTask<K> extends CacheTaskAdapter<K, Void, Void> {
+ /** Key. */
+ private final K key;
+
+ /** Local. */
+ private final boolean loc;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public ClearKeyTask(String cacheName, boolean async, boolean loc, K key) {
+ super(cacheName, async);
+ this.key = key;
+ this.loc = loc;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ if (loc)
+ cache().localClear(key);
+ else
+ cache().clear(key);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ClearAllKeys<K> extends CacheTaskAdapter<K, Void, Void> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /** Local. */
+ private final boolean loc;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public ClearAllKeys(String cacheName, boolean async, boolean loc, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ this.loc = loc;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ if (loc)
+ cache().localClearAll(keys);
+ else
+ cache().clearAll(keys);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class InvokeTask<K, V, R> extends CacheTaskAdapter<K, V, R> {
+ /** Key. */
+ private final K key;
+
+ /** Processor. */
+ private final EntryProcessor<K, V, R> processor;
+
+ /** Args. */
+ private final Object[] args;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param processor Processor.
+ * @param args Args.
+ */
+ public InvokeTask(String cacheName, boolean async, K key, EntryProcessor<K, V, R> processor,
+ Object[] args) {
+ super(cacheName, async);
+ this.args = args;
+ this.key = key;
+ this.processor = processor;
+ }
+
+ /** {@inheritDoc} */
+ @Override public R call() throws Exception {
+ return cache().invoke(key, processor, args);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class InvokeAllTask<K, V, T> extends CacheTaskAdapter<K, V, Map<K, EntryProcessorResult<T>>> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /** Processor. */
+ private final EntryProcessor<K, V, T> processor;
+
+ /** Args. */
+ private final Object[] args;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ * @param processor Processor.
+ * @param args Args.
+ */
+ public InvokeAllTask(String cacheName, boolean async, Set<? extends K> keys,
+ EntryProcessor<K, V, T> processor, Object[] args) {
+ super(cacheName, async);
+ this.args = args;
+ this.keys = keys;
+ this.processor = processor;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, EntryProcessorResult<T>> call() throws Exception {
+ return cache().invokeAll(keys, processor, args);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CloseTask extends CacheTaskAdapter<Void, Void, Void> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public CloseTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().close();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class DestroyTask extends CacheTaskAdapter<Void, Void, Void> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public DestroyTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().destroy();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IsClosedTask extends CacheTaskAdapter<Void, Void, Boolean> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public IsClosedTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().isClosed();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class UnwrapTask<R> extends CacheTaskAdapter<Void, Void, R> {
+ /** Clazz. */
+ private final Class<R> clazz;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param clazz Clazz.
+ */
+ public UnwrapTask(String cacheName, boolean async, Class<R> clazz) {
+ super(cacheName, async);
+ this.clazz = clazz;
+ }
+
+ /** {@inheritDoc} */
+ @Override public R call() throws Exception {
+ return cache().unwrap(clazz);
+ }
+ }
+
+ /**
+ *
+ */
+ private static abstract class CacheTaskAdapter<K, V, R> implements IgniteCallable<R> {
+ /** Ignite. */
+ @IgniteInstanceResource
+ protected Ignite ignite;
+
+ /** Cache name. */
+ protected final String cacheName;
+
+ /** Async. */
+ protected final boolean async;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public CacheTaskAdapter(String cacheName, boolean async) {
+ this.async = async;
+ this.cacheName = cacheName;
+ }
+
+ /**
+ * Returns cache instance.
+ */
+ protected IgniteCache<K, V> cache() {
+ IgniteCache<K, V> cache = ignite.cache(cacheName);
+
+ return async ? cache.withAsync() : cache;
+ }
+ }
-}
++
++ /**
++ *
++ */
++ private static class GetConfigurationTask<K, V, C extends Configuration<K, V>> extends CacheTaskAdapter<K, V, C> {
+ /** Clazz. */
+ private final Class<C> clazz;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param clazz Clazz.
+ */
+ public GetConfigurationTask(String cacheName, boolean async, Class<C> clazz) {
+ super(cacheName, async);
+ this.clazz = clazz;
+ }
+
+ /** {@inheritDoc} */
+ @Override public C call() throws Exception {
+ return cache().getConfiguration(clazz);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class LocalLoadCacheTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+ /** Predicate. */
+ private final IgniteBiPredicate<K, V> p;
+
+ /** Args. */
+ private final Object[] args;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param p P.
+ * @param args Args.
+ */
+ public LocalLoadCacheTask(String cacheName, boolean async, IgniteBiPredicate<K, V> p, Object[] args) {
+ super(cacheName, async);
+ this.p = p;
+ this.args = args;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().localLoadCache(p, args);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAndPutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public GetAndPutIfAbsentTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().getAndPutIfAbsent(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IsLocalLockedTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** By current thread. */
+ private final boolean byCurrThread;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param byCurrThread By current thread.
+ */
+ public IsLocalLockedTask(String cacheName, boolean async, K key, boolean byCurrThread) {
+ super(cacheName, async);
+ this.key = key;
+ this.byCurrThread = byCurrThread;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().isLocalLocked(key, byCurrThread);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class LocalEntriesTask<K, V> extends CacheTaskAdapter<K, V, Iterable<Entry<K, V>>> {
+ /** Peek modes. */
+ private final CachePeekMode[] peekModes;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param peekModes Peek modes.
+ */
+ public LocalEntriesTask(String cacheName, boolean async, CachePeekMode[] peekModes) {
+ super(cacheName, async);
+ this.peekModes = peekModes;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Iterable<Entry<K, V>> call() throws Exception {
+ Collection<Entry<K, V>> res = new ArrayList<>();
+
+ for (Entry<K, V> e : cache().localEntries(peekModes))
+ res.add(e);
+
+ return res;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class LocalEvictTask<K> extends CacheTaskAdapter<K, Void, Void> {
+ /** Keys. */
+ private final Collection<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public LocalEvictTask(String cacheName, boolean async, Collection<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().localEvict(keys);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class LocalPeekTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /** Peek modes. */
+ private final CachePeekMode[] peekModes;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param peekModes Peek modes.
+ */
+ public LocalPeekTask(String cacheName, boolean async, K key, CachePeekMode[] peekModes) {
+ super(cacheName, async);
+ this.key = key;
+ this.peekModes = peekModes;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().localPeek(key, peekModes);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class SizeTask extends CacheTaskAdapter<Void, Void, Integer> {
+ /** Peek modes. */
+ private final CachePeekMode[] peekModes;
+
+ /** Local. */
+ private final boolean loc;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param peekModes Peek modes.
+ * @param loc Local.
+ */
+ public SizeTask(String cacheName, boolean async, CachePeekMode[] peekModes, boolean loc) {
+ super(cacheName, async);
+ this.loc = loc;
+ this.peekModes = peekModes;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Integer call() throws Exception {
+ return loc ? cache().localSize(peekModes) : cache().size(peekModes);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public GetTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().get(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public RemoveAllTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ IgniteCache<K, V> cache = cache();
+
+ cache.removeAll();
+
+ if (async)
+ cache.future().get();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class PutTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public PutTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().put(key, val);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ContainsKeyTask<K> extends CacheTaskAdapter<K, Object, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public ContainsKeyTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().containsKey(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ClearTask extends CacheTaskAdapter<Object, Object, Void> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public ClearTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().clear();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IteratorTask<K, V> extends CacheTaskAdapter<K, V, Collection<Entry<K, V>>> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public IteratorTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<Entry<K, V>> call() throws Exception {
+ Collection<Entry<K, V>> res = new ArrayList<>();
+
+ for (Entry<K, V> o : cache())
+ res.add(o);
+
+ return res;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ReplaceTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public ReplaceTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().replace(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetNameTask extends CacheTaskAdapter<Void, Void, String> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public GetNameTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String call() throws Exception {
+ return cache().getName();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public RemoveTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().remove(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class PutAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+ /** Map. */
+ private final Map<? extends K, ? extends V> map;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param map Map.
+ */
+ public PutAllTask(String cacheName, boolean async, Map<? extends K, ? extends V> map) {
+ super(cacheName, async);
+ this.map = map;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().putAll(map);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveAllKeysTask<K> extends CacheTaskAdapter<K, Void, Void> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public RemoveAllKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().removeAll(keys);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAllTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public GetAllTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, V> call() throws Exception {
+ return cache().getAll(keys);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAllOutTxTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public GetAllOutTxTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, V> call() throws Exception {
+ return cache().getAllOutTx(keys);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ContainsKeysTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public ContainsKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().containsKeys(keys);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAndPutTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public GetAndPutTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().getAndPut(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class PutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public PutIfAbsentTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().putIfAbsent(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Old value. */
+ private final V oldVal;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param oldVal Old value.
+ */
+ public RemoveIfExistsTask(String cacheName, boolean async, K key, V oldVal) {
+ super(cacheName, async);
+ this.key = key;
+ this.oldVal = oldVal;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().remove(key, oldVal);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAndRemoveTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public GetAndRemoveTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().getAndRemove(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ReplaceIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Old value. */
+ private final V oldVal;
+
+ /** New value. */
+ private final V newVal;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param oldVal Old value.
+ * @param newVal New value.
+ */
+ public ReplaceIfExistsTask(String cacheName, boolean async, K key, V oldVal, V newVal) {
+ super(cacheName, async);
+ this.key = key;
+ this.oldVal = oldVal;
+ this.newVal = newVal;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().replace(key, oldVal, newVal);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAndReplaceTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public GetAndReplaceTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().getAndReplace(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ClearKeyTask<K> extends CacheTaskAdapter<K, Void, Void> {
+ /** Key. */
+ private final K key;
+
+ /** Local. */
+ private final boolean loc;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public ClearKeyTask(String cacheName, boolean async, boolean loc, K key) {
+ super(cacheName, async);
+ this.key = key;
+ this.loc = loc;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ if (loc)
+ cache().localClear(key);
+ else
+ cache().clear(key);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ClearAllKeys<K> extends CacheTaskAdapter<K, Void, Void> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /** Local. */
+ private final boolean loc;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public ClearAllKeys(String cacheName, boolean async, boolean loc, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ this.loc = loc;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ if (loc)
+ cache().localClearAll(keys);
+ else
+ cache().clearAll(keys);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class InvokeTask<K, V, R> extends CacheTaskAdapter<K, V, R> {
+ /** Key. */
+ private final K key;
+
+ /** Processor. */
+ private final EntryProcessor<K, V, R> processor;
+
+ /** Args. */
+ private final Object[] args;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param processor Processor.
+ * @param args Args.
+ */
+ public InvokeTask(String cacheName, boolean async, K key, EntryProcessor<K, V, R> processor,
+ Object[] args) {
+ super(cacheName, async);
+ this.args = args;
+ this.key = key;
+ this.processor = processor;
+ }
+
+ /** {@inheritDoc} */
+ @Override public R call() throws Exception {
+ return cache().invoke(key, processor, args);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class InvokeAllTask<K, V, T> extends CacheTaskAdapter<K, V, Map<K, EntryProcessorResult<T>>> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /** Processor. */
+ private final EntryProcessor<K, V, T> processor;
+
+ /** Args. */
+ private final Object[] args;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ * @param processor Processor.
+ * @param args Args.
+ */
+ public InvokeAllTask(String cacheName, boolean async, Set<? extends K> keys,
+ EntryProcessor<K, V, T> processor, Object[] args) {
+ super(cacheName, async);
+ this.args = args;
+ this.keys = keys;
+ this.processor = processor;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, EntryProcessorResult<T>> call() throws Exception {
+ return cache().invokeAll(keys, processor, args);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CloseTask extends CacheTaskAdapter<Void, Void, Void> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public CloseTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().close();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class DestroyTask extends CacheTaskAdapter<Void, Void, Void> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public DestroyTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().destroy();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IsClosedTask extends CacheTaskAdapter<Void, Void, Boolean> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public IsClosedTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().isClosed();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class UnwrapTask<R> extends CacheTaskAdapter<Void, Void, R> {
+ /** Clazz. */
+ private final Class<R> clazz;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param clazz Clazz.
+ */
+ public UnwrapTask(String cacheName, boolean async, Class<R> clazz) {
+ super(cacheName, async);
+ this.clazz = clazz;
+ }
+
+ /** {@inheritDoc} */
+ @Override public R call() throws Exception {
+ return cache().unwrap(clazz);
+ }
+ }
+
+ /**
+ *
+ */
+ private static abstract class CacheTaskAdapter<K, V, R> implements IgniteCallable<R> {
+ /** Ignite. */
+ @IgniteInstanceResource
+ protected Ignite ignite;
+
+ /** Cache name. */
+ protected final String cacheName;
+
+ /** Async. */
+ protected final boolean async;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public CacheTaskAdapter(String cacheName, boolean async) {
+ this.async = async;
+ this.cacheName = cacheName;
+ }
+
+ /**
+ * Returns cache instance.
+ */
+ protected IgniteCache<K, V> cache() {
+ IgniteCache<K, V> cache = ignite.cache(cacheName);
+
+ return async ? cache.withAsync() : cache;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4ee154c8/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --cc modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
index 8e653e3,1876e24..7425cb6
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
@@@ -1,4 -1,4 +1,4 @@@
--/*
++/*
* 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.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4ee154c8/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --cc modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
index 7cf47c3,03f7fb9..198cfa6
--- a/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
@@@ -1,4 -1,4 +1,4 @@@
--/*
++/*
* 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.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4ee154c8/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --cc modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
index ba4b794,22d74c9..a45f421
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
@@@ -1,4 -1,4 +1,4 @@@
--/*
++/*
* 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.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4ee154c8/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --cc modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
index f474b03,1ebcf24..db88e3b
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
@@@ -1,4 -1,4 +1,4 @@@
--/*
++/*
* 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.
[25/34] ignite git commit: ignite-1168 Added support for metadata,
scan commands in rest.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
index aee8a1f..3b36c6a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
@@ -27,11 +27,11 @@ import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cluster.ClusterMetrics;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.cache.GridCacheAttributes;
import org.apache.ignite.internal.processors.port.GridPortRecord;
import org.apache.ignite.internal.processors.rest.GridRestCommand;
import org.apache.ignite.internal.processors.rest.GridRestProtocol;
@@ -44,6 +44,7 @@ import org.apache.ignite.internal.processors.rest.request.GridRestTopologyReques
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.P1;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.spi.IgnitePortProtocol;
@@ -194,24 +195,26 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter {
nodeBean.setTcpAddresses(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_ADDRS)));
nodeBean.setTcpHostNames(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_HOST_NAMES)));
- GridCacheAttributes[] caches = node.attribute(ATTR_CACHE);
+ Map<String, CacheMode> nodeCaches = ctx.discovery().nodeCaches(node);
- if (!F.isEmpty(caches)) {
- Map<String, String> cacheMap = new HashMap<>();
+ Map<String, String> cacheMap = U.newHashMap(nodeCaches.size());
- for (GridCacheAttributes cacheAttr : caches) {
- if (ctx.cache().systemCache(cacheAttr.cacheName()))
- continue;
+ for (Map.Entry<String, CacheMode> cache : nodeCaches.entrySet()) {
+ String cacheName = cache.getKey();
- if (cacheAttr.cacheName() != null)
- cacheMap.put(cacheAttr.cacheName(), cacheAttr.cacheMode().toString());
- else
- nodeBean.setDefaultCacheMode(cacheAttr.cacheMode().toString());
- }
+ if (CU.isSystemCache(cacheName) || CU.isIgfsCache(ctx.config(), cacheName))
+ continue;
+
+ String mode = cache.getValue().toString();
- nodeBean.setCaches(cacheMap);
+ if (cacheName != null)
+ cacheMap.put(cacheName, mode);
+ else
+ nodeBean.setDefaultCacheMode(mode);
}
+ nodeBean.setCaches(cacheMap);
+
if (mtr) {
ClusterMetrics metrics = node.metrics();
@@ -304,6 +307,135 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter {
}
/**
+ * Creates node bean out of grid node. Notice that cache attribute is handled separately.
+ *
+ * @param node Grid node.
+ * @param mtr {@code true} to add metrics.
+ * @param attr {@code true} to add attributes.
+ * @return Grid Node bean.
+ */
+ private GridClientNodeBean createNodeBean(ClusterNode node, boolean mtr, boolean attr) {
+ assert node != null;
+
+ GridClientNodeBean nodeBean = new GridClientNodeBean();
+
+ nodeBean.setNodeId(node.id());
+ nodeBean.setConsistentId(node.consistentId());
+ nodeBean.setTcpPort(attribute(node, ATTR_REST_TCP_PORT, 0));
+
+ nodeBean.setTcpAddresses(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_ADDRS)));
+ nodeBean.setTcpHostNames(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_HOST_NAMES)));
+
+ Map<String, CacheMode> nodeCaches = ctx.discovery().nodeCaches(node);
+
+ Map<String, String> cacheMap = U.newHashMap(nodeCaches.size());
+
+ for (Map.Entry<String, CacheMode> cache : nodeCaches.entrySet()) {
+ String cacheName = cache.getKey();
+
+ if (CU.isSystemCache(cacheName) || CU.isIgfsCache(ctx.config(), cacheName))
+ continue;
+
+ String mode = cache.getValue().toString();
+
+ if (cacheName != null)
+ cacheMap.put(cacheName, mode);
+ else
+ nodeBean.setDefaultCacheMode(mode);
+ }
+
+ nodeBean.setCaches(cacheMap);
+
+ if (mtr) {
+ ClusterMetrics metrics = node.metrics();
+
+ GridClientNodeMetricsBean metricsBean = new GridClientNodeMetricsBean();
+
+ metricsBean.setStartTime(metrics.getStartTime());
+ metricsBean.setAverageActiveJobs(metrics.getAverageActiveJobs());
+ metricsBean.setAverageCancelledJobs(metrics.getAverageCancelledJobs());
+ metricsBean.setAverageCpuLoad(metrics.getAverageCpuLoad());
+ metricsBean.setAverageJobExecuteTime(metrics.getAverageJobExecuteTime());
+ metricsBean.setAverageJobWaitTime(metrics.getAverageJobWaitTime());
+ metricsBean.setAverageRejectedJobs(metrics.getAverageRejectedJobs());
+ metricsBean.setAverageWaitingJobs(metrics.getAverageWaitingJobs());
+ metricsBean.setCurrentActiveJobs(metrics.getCurrentActiveJobs());
+ metricsBean.setCurrentCancelledJobs(metrics.getCurrentCancelledJobs());
+ metricsBean.setCurrentCpuLoad(metrics.getCurrentCpuLoad());
+ metricsBean.setCurrentGcCpuLoad(metrics.getCurrentGcCpuLoad());
+ metricsBean.setCurrentDaemonThreadCount(metrics.getCurrentDaemonThreadCount());
+ metricsBean.setCurrentIdleTime(metrics.getCurrentIdleTime());
+ metricsBean.setCurrentJobExecuteTime(metrics.getCurrentJobExecuteTime());
+ metricsBean.setCurrentJobWaitTime(metrics.getCurrentJobWaitTime());
+ metricsBean.setCurrentRejectedJobs(metrics.getCurrentRejectedJobs());
+ metricsBean.setCurrentThreadCount(metrics.getCurrentThreadCount());
+ metricsBean.setCurrentWaitingJobs(metrics.getCurrentWaitingJobs());
+ metricsBean.setHeapMemoryCommitted(metrics.getHeapMemoryCommitted());
+ metricsBean.setHeapMemoryInitialized(metrics.getHeapMemoryInitialized());
+ metricsBean.setHeapMemoryMaximum(metrics.getHeapMemoryMaximum());
+ metricsBean.setHeapMemoryUsed(metrics.getHeapMemoryUsed());
+ metricsBean.setLastDataVersion(metrics.getLastDataVersion());
+ metricsBean.setLastUpdateTime(metrics.getLastUpdateTime());
+ metricsBean.setMaximumActiveJobs(metrics.getMaximumActiveJobs());
+ metricsBean.setMaximumCancelledJobs(metrics.getMaximumCancelledJobs());
+ metricsBean.setMaximumJobExecuteTime(metrics.getMaximumJobExecuteTime());
+ metricsBean.setMaximumJobWaitTime(metrics.getMaximumJobWaitTime());
+ metricsBean.setMaximumRejectedJobs(metrics.getMaximumRejectedJobs());
+ metricsBean.setMaximumThreadCount(metrics.getMaximumThreadCount());
+ metricsBean.setMaximumWaitingJobs(metrics.getMaximumWaitingJobs());
+ metricsBean.setNodeStartTime(metrics.getNodeStartTime());
+ metricsBean.setNonHeapMemoryCommitted(metrics.getNonHeapMemoryCommitted());
+ metricsBean.setNonHeapMemoryInitialized(metrics.getNonHeapMemoryInitialized());
+ metricsBean.setNonHeapMemoryMaximum(metrics.getNonHeapMemoryMaximum());
+ metricsBean.setNonHeapMemoryUsed(metrics.getNonHeapMemoryUsed());
+ metricsBean.setStartTime(metrics.getStartTime());
+ metricsBean.setTotalCancelledJobs(metrics.getTotalCancelledJobs());
+ metricsBean.setTotalCpus(metrics.getTotalCpus());
+ metricsBean.setTotalExecutedJobs(metrics.getTotalExecutedJobs());
+ metricsBean.setTotalIdleTime(metrics.getTotalIdleTime());
+ metricsBean.setTotalRejectedJobs(metrics.getTotalRejectedJobs());
+ metricsBean.setTotalStartedThreadCount(metrics.getTotalStartedThreadCount());
+ metricsBean.setTotalExecutedTasks(metrics.getTotalExecutedTasks());
+ metricsBean.setSentMessagesCount(metrics.getSentMessagesCount());
+ metricsBean.setSentBytesCount(metrics.getSentBytesCount());
+ metricsBean.setReceivedMessagesCount(metrics.getReceivedMessagesCount());
+ metricsBean.setReceivedBytesCount(metrics.getReceivedBytesCount());
+ metricsBean.setUpTime(metrics.getUpTime());
+
+ nodeBean.setMetrics(metricsBean);
+ }
+
+ if (attr) {
+ Map<String, Object> attrs = new HashMap<>(node.attributes());
+
+ attrs.remove(ATTR_CACHE);
+ attrs.remove(ATTR_TX_CONFIG);
+ attrs.remove(ATTR_SECURITY_SUBJECT);
+ attrs.remove(ATTR_SECURITY_CREDENTIALS);
+
+ for (Iterator<Map.Entry<String, Object>> i = attrs.entrySet().iterator(); i.hasNext();) {
+ Map.Entry<String, Object> e = i.next();
+
+ if (!e.getKey().startsWith("org.apache.ignite.") && !e.getKey().startsWith("plugins.") &&
+ System.getProperty(e.getKey()) == null) {
+ i.remove();
+
+ continue;
+ }
+
+ if (e.getValue() != null) {
+ if (e.getValue().getClass().isEnum() || e.getValue() instanceof InetAddress)
+ e.setValue(e.getValue().toString());
+ else if (e.getValue().getClass().isArray())
+ i.remove();
+ }
+ }
+
+ nodeBean.setAttributes(attrs);
+ }
+
+ return nodeBean;
+ } /**
* @param col Collection;
* @return Non-empty list.
*/
@@ -345,4 +477,4 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter {
@Override public String toString() {
return S.toString(GridTopologyCommandHandler.class, this);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestQueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestQueryRequest.java
new file mode 100644
index 0000000..a719776
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestQueryRequest.java
@@ -0,0 +1,175 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. See the NOTICE file distributed with
+ * * this work for additional information regarding copyright ownership.
+ * * The ASF licenses this file to You under the Apache License, Version 2.0
+ * * (the "License"); you may not use this file except in compliance with
+ * * the License. You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ *
+ */
+
+package org.apache.ignite.internal.processors.rest.request;
+
+/**
+ * Sql query request.
+ */
+public class RestQueryRequest extends GridRestRequest {
+ /** Sql query. */
+ private String sqlQry;
+
+ /** Sql query arguments. */
+ private Object[] args;
+
+ /** Page size. */
+ private Integer pageSize;
+
+ /** Cache name. */
+ private String cacheName;
+
+ /** Query id. */
+ private Long qryId;
+
+ /** Query type name. */
+ private String typeName;
+
+ /** Predicate class name for scan query. */
+ private String className;
+
+ /** Query type. */
+ private QueryType type;
+
+ /**
+ * @param sqlQry Sql query.
+ */
+ public void sqlQuery(String sqlQry) {
+ this.sqlQry = sqlQry;
+ }
+
+ /**
+ * @return Sql query.
+ */
+ public String sqlQuery() {
+ return sqlQry;
+ }
+
+ /**
+ * @param args Sql query arguments.
+ */
+ public void arguments(Object[] args) {
+ this.args = args;
+ }
+
+ /**
+ * @return Sql query arguments.
+ */
+ public Object[] arguments() {
+ return args;
+ }
+
+ /**
+ * @param pageSize Page size.
+ */
+ public void pageSize(Integer pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ /**
+ * @return Page size.
+ */
+ public int pageSize() {
+ return pageSize;
+ }
+
+ /**
+ * @param cacheName Cache name.
+ */
+ public void cacheName(String cacheName) {
+ this.cacheName = cacheName;
+ }
+
+ /**
+ * @return Cache name.
+ */
+ public String cacheName() {
+ return cacheName;
+ }
+
+ /**
+ * @param id Query id.
+ */
+ public void queryId(Long id) {
+ this.qryId = id;
+ }
+
+ /**
+ * @return Query id.
+ */
+ public Long queryId() {
+ return qryId;
+ }
+
+ /**
+ * @param typeName Query type name.
+ */
+ public void typeName(String typeName) {
+ this.typeName = typeName;
+ }
+
+ /**
+ * @return Query type name.
+ */
+ public String typeName() {
+ return typeName;
+ }
+
+ /**
+ * @return Predicate class name for scan query.
+ */
+ public String className() {
+ return className;
+ }
+
+ /**
+ * @param className Predicate class name for scan query.
+ */
+ public void className(String className) {
+ this.className = className;
+ }
+
+ /**
+ * @param type Query type.
+ */
+ public void queryType(QueryType type) {
+ this.type = type;
+ }
+
+ /**
+ * @return Query type.
+ */
+ public QueryType queryType() {
+ return type;
+ }
+
+ /**
+ * Supported query types.
+ */
+ public enum QueryType {
+ /** Sql query. */
+ SQL,
+
+ /** Sql fields query. */
+ SQL_FIELDS,
+
+ /** Scan query. */
+ SCAN
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestSqlQueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestSqlQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestSqlQueryRequest.java
deleted file mode 100644
index b6ab339..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestSqlQueryRequest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.rest.request;
-
-/**
- * Sql query request.
- */
-public class RestSqlQueryRequest extends GridRestRequest {
- /** Sql query. */
- private String sqlQry;
-
- /** Sql query arguments. */
- private Object[] args;
-
- /** Page size. */
- private Integer pageSize;
-
- /** Cache name. */
- private String cacheName;
-
- /** Query id. */
- private Long qryId;
-
- /** Query type name. */
- private String typeName;
-
- /**
- * @param sqlQry Sql query.
- */
- public void sqlQuery(String sqlQry) {
- this.sqlQry = sqlQry;
- }
-
- /**
- * @return Sql query.
- */
- public String sqlQuery() {
- return sqlQry;
- }
-
- /**
- * @param args Sql query arguments.
- */
- public void arguments(Object[] args) {
- this.args = args;
- }
-
- /**
- * @return Sql query arguments.
- */
- public Object[] arguments() {
- return args;
- }
-
- /**
- * @param pageSize Page size.
- */
- public void pageSize(Integer pageSize) {
- this.pageSize = pageSize;
- }
-
- /**
- * @return Page size.
- */
- public int pageSize() {
- return pageSize;
- }
-
- /**
- * @param cacheName Cache name.
- */
- public void cacheName(String cacheName) {
- this.cacheName = cacheName;
- }
-
- /**
- * @return Cache name.
- */
- public String cacheName() {
- return cacheName;
- }
-
- /**
- * @param id Query id.
- */
- public void queryId(Long id) {
- this.qryId = id;
- }
-
- /**
- * @return Query id.
- */
- public Long queryId() {
- return qryId;
- }
-
- /**
- * @param typeName Query type name.
- */
- public void typeName(String typeName) {
- this.typeName = typeName;
- }
-
- /**
- * @return Query type name.
- */
- public String typeName() {
- return typeName;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java
index 60b44ee..0adbc14 100644
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java
@@ -17,10 +17,19 @@
package org.apache.ignite.internal.processors.rest.protocols.http.jetty;
+import java.text.DateFormat;
import java.util.UUID;
+import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
+import net.sf.json.processors.JsonBeanProcessor;
+import net.sf.json.processors.JsonBeanProcessorMatcher;
import net.sf.json.processors.JsonValueProcessor;
+import java.util.*;
+import net.sf.json.processors.JsonValueProcessorMatcher;
+import org.apache.ignite.internal.processors.cache.query.GridCacheSqlIndexMetadata;
+import org.apache.ignite.internal.processors.cache.query.GridCacheSqlMetadata;
+
/**
* Jetty protocol json configuration.
*/
@@ -29,21 +38,158 @@ public class GridJettyJsonConfig extends JsonConfig {
* Constructs default jetty json config.
*/
public GridJettyJsonConfig() {
- registerJsonValueProcessor(UUID.class, new ToStringJsonProcessor());
+ registerJsonValueProcessor(UUID.class, new UUIDToStringJsonProcessor());
+ registerJsonValueProcessor(Date.class, new DateToStringJsonProcessor());
+ registerJsonValueProcessor(java.sql.Date.class, new DateToStringJsonProcessor());
+
+ registerJsonBeanProcessor(GridCacheSqlMetadata.class, new GridCacheSqlMetadataBeanProcessor());
+ registerJsonValueProcessor(GridCacheSqlIndexMetadata.class, new GridCacheSqlIndexMetadataToJson());
+
+ setJsonBeanProcessorMatcher(new GridJettyJsonBeanProcessorMatcher());
+ setJsonValueProcessorMatcher(new GridJettyJsonValueProcessorMatcher());
}
/**
- * Helper class for simple to-string conversion for the beans.
+ * Helper class for simple to-string conversion for {@link UUID}.
*/
- private static class ToStringJsonProcessor implements JsonValueProcessor {
+ private static class UUIDToStringJsonProcessor implements JsonValueProcessor {
/** {@inheritDoc} */
@Override public Object processArrayValue(Object val, JsonConfig jsonCfg) {
- throw new UnsupportedOperationException("Serialize array to string is not supported: " + val);
+ if (val == null)
+ return new JSONObject(true);
+
+ if (val instanceof UUID)
+ return val.toString();
+
+ throw new UnsupportedOperationException("Serialize value to json is not supported: " + val);
}
/** {@inheritDoc} */
@Override public Object processObjectValue(String key, Object val, JsonConfig jsonCfg) {
- return val == null ? null : val.toString();
+ return processArrayValue(val, jsonCfg);
+ }
+ }
+
+ /**
+ * Helper class for simple to-string conversion for {@link Date}.
+ */
+ private static class DateToStringJsonProcessor implements JsonValueProcessor {
+ private final DateFormat enUsFormat
+ = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.US);
+
+ /** {@inheritDoc} */
+ @Override public synchronized Object processArrayValue(Object val, JsonConfig jsonCfg) {
+ if (val == null)
+ return new JSONObject(true);
+
+ if (val instanceof Date)
+ return enUsFormat.format(val);
+
+ throw new UnsupportedOperationException("Serialize value to json is not supported: " + val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public synchronized Object processObjectValue(String key, Object val, JsonConfig jsonCfg) {
+ return processArrayValue(val, jsonCfg);
+ }
+ }
+
+ /**
+ * Helper class for simple to-json conversion for {@link GridCacheSqlMetadata}.
+ */
+ private static class GridCacheSqlMetadataBeanProcessor implements JsonBeanProcessor {
+ /** {@inheritDoc} */
+ @Override public JSONObject processBean(Object bean, JsonConfig jsonCfg) {
+ if (bean == null)
+ return new JSONObject(true);
+
+ if (bean instanceof GridCacheSqlMetadata) {
+ GridCacheSqlMetadata r = (GridCacheSqlMetadata) bean;
+
+ return new JSONObject()
+ .element("cacheName", r.cacheName(), jsonCfg)
+ .element("types", r.types(), jsonCfg)
+ .element("keyClasses", r.keyClasses(), jsonCfg)
+ .element("valClasses", r.valClasses(), jsonCfg)
+ .element("fields", r.fields(), jsonCfg)
+ .element("indexes", r.indexes(), jsonCfg);
+ }
+
+ throw new UnsupportedOperationException("Serialize bean to json is not supported: " + bean);
+ }
+ }
+
+ /**
+ * Helper class for simple to-json conversion for {@link GridCacheSqlIndexMetadata}.
+ */
+ private static class GridCacheSqlIndexMetadataToJson implements JsonValueProcessor {
+ /** {@inheritDoc} */
+ @Override public Object processArrayValue(Object val, JsonConfig jsonCfg) {
+ if (val == null)
+ return new JSONObject(true);
+
+ if (val instanceof GridCacheSqlIndexMetadata) {
+ GridCacheSqlIndexMetadata r = (GridCacheSqlIndexMetadata) val;
+
+ return new JSONObject()
+ .element("name", r.name())
+ .element("fields", r.fields())
+ .element("descendings", r.descendings())
+ .element("unique", r.unique());
+ }
+
+ throw new UnsupportedOperationException("Serialize array to string is not supported: " + val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object processObjectValue(String key, Object value, JsonConfig jsonCfg) {
+ return processArrayValue(value, jsonCfg);
+ }
+ }
+
+ /**
+ * Class for finding a matching JsonBeanProcessor. Matches the target class with instanceOf.
+ */
+ private static final class GridJettyJsonBeanProcessorMatcher extends JsonBeanProcessorMatcher {
+ /** {@inheritDoc} */
+ @Override public Object getMatch(Class target, Set keys) {
+ if (target == null || keys == null)
+ return null;
+
+ if (keys.contains(target))
+ return target;
+
+ for (Object key : keys) {
+ Class<?> clazz = (Class<?>) key;
+
+ if (clazz.isAssignableFrom(target))
+ return key;
+ }
+
+ return null;
+ }
+ }
+
+ /**
+ * Class for finding a matching JsonValueProcessor. Matches the target class with instanceOf.
+ */
+ private static final class GridJettyJsonValueProcessorMatcher extends JsonValueProcessorMatcher {
+ /** {@inheritDoc} */
+ @Override public Object getMatch(Class target, Set keys) {
+ if (target == null || keys == null)
+ return null;
+
+ if (keys.contains(target))
+ return target;
+
+ for (Object key : keys) {
+ Class<?> clazz = (Class<?>) key;
+
+ if (clazz.isAssignableFrom(target))
+ return key;
+ }
+
+ return null;
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
index 9b82098..48a60a9 100644
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
@@ -51,7 +51,7 @@ import org.apache.ignite.internal.processors.rest.request.GridRestLogRequest;
import org.apache.ignite.internal.processors.rest.request.GridRestRequest;
import org.apache.ignite.internal.processors.rest.request.GridRestTaskRequest;
import org.apache.ignite.internal.processors.rest.request.GridRestTopologyRequest;
-import org.apache.ignite.internal.processors.rest.request.RestSqlQueryRequest;
+import org.apache.ignite.internal.processors.rest.request.RestQueryRequest;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteClosure;
@@ -64,6 +64,7 @@ import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_C
import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_GET_ALL;
import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_PUT_ALL;
import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_REMOVE_ALL;
+import static org.apache.ignite.internal.processors.rest.GridRestCommand.EXECUTE_SQL_QUERY;
import static org.apache.ignite.internal.processors.rest.GridRestResponse.STATUS_FAILED;
/**
@@ -84,19 +85,15 @@ public class GridJettyRestHandler extends AbstractHandler {
/** Logger. */
private final IgniteLogger log;
-
+ /** Authentication checker. */
+ private final IgniteClosure<String, Boolean> authChecker;
/** Request handlers. */
private GridRestProtocolHandler hnd;
-
/** Default page. */
private volatile String dfltPage;
-
/** Favicon. */
private volatile byte[] favicon;
- /** Authentication checker. */
- private final IgniteClosure<String, Boolean> authChecker;
-
/**
* Creates new HTTP requests handler.
*
@@ -135,6 +132,74 @@ public class GridJettyRestHandler extends AbstractHandler {
}
/**
+ * Retrieves long value from parameters map.
+ *
+ * @param key Key.
+ * @param params Parameters map.
+ * @param dfltVal Default value.
+ * @return Long value from parameters map or {@code dfltVal} if null
+ * or not exists.
+ * @throws IgniteCheckedException If parsing failed.
+ */
+ @Nullable private static Long longValue(String key, Map<String, Object> params, Long dfltVal) throws IgniteCheckedException {
+ assert key != null;
+
+ String val = (String) params.get(key);
+
+ try {
+ return val == null ? dfltVal : Long.valueOf(val);
+ }
+ catch (NumberFormatException ignore) {
+ throw new IgniteCheckedException("Failed to parse parameter of Long type [" + key + "=" + val + "]");
+ }
+ }
+
+ /**
+ * Retrieves int value from parameters map.
+ *
+ * @param key Key.
+ * @param params Parameters map.
+ * @param dfltVal Default value.
+ * @return Integer value from parameters map or {@code dfltVal} if null
+ * or not exists.
+ * @throws IgniteCheckedException If parsing failed.
+ */
+ @Nullable private static Integer intValue(String key, Map<String, Object> params, Integer dfltVal) throws IgniteCheckedException {
+ assert key != null;
+
+ String val = (String) params.get(key);
+
+ try {
+ return val == null ? dfltVal : Integer.valueOf(val);
+ }
+ catch (NumberFormatException ignore) {
+ throw new IgniteCheckedException("Failed to parse parameter of Integer type [" + key + "=" + val + "]");
+ }
+ }
+
+ /**
+ * Retrieves UUID value from parameters map.
+ *
+ * @param key Key.
+ * @param params Parameters map.
+ * @return UUID value from parameters map or {@code null} if null
+ * or not exists.
+ * @throws IgniteCheckedException If parsing failed.
+ */
+ @Nullable private static UUID uuidValue(String key, Map<String, Object> params) throws IgniteCheckedException {
+ assert key != null;
+
+ String val = (String) params.get(key);
+
+ try {
+ return val == null ? null : UUID.fromString(val);
+ }
+ catch (NumberFormatException ignore) {
+ throw new IgniteCheckedException("Failed to parse parameter of UUID type [" + key + "=" + val + "]");
+ }
+ }
+
+ /**
* @throws IOException If failed.
*/
private void initDefaultPage() throws IOException {
@@ -396,6 +461,7 @@ public class GridJettyRestHandler extends AbstractHandler {
case CACHE_CAS:
case CACHE_METRICS:
case CACHE_SIZE:
+ case CACHE_METADATA:
case CACHE_REPLACE:
case CACHE_APPEND:
case CACHE_PREPEND: {
@@ -497,9 +563,9 @@ public class GridJettyRestHandler extends AbstractHandler {
case EXECUTE_SQL_QUERY:
case EXECUTE_SQL_FIELDS_QUERY: {
- RestSqlQueryRequest restReq0 = new RestSqlQueryRequest();
+ RestQueryRequest restReq0 = new RestQueryRequest();
- restReq0.sqlQuery((String) params.get("qry"));
+ restReq0.sqlQuery((String)params.get("qry"));
restReq0.arguments(values("arg", params).toArray());
@@ -512,20 +578,46 @@ public class GridJettyRestHandler extends AbstractHandler {
restReq0.cacheName((String)params.get("cacheName"));
+ if (cmd == EXECUTE_SQL_QUERY)
+ restReq0.queryType(RestQueryRequest.QueryType.SQL);
+ else
+ restReq0.queryType(RestQueryRequest.QueryType.SQL_FIELDS);
+
+ restReq = restReq0;
+
+ break;
+ }
+
+ case EXECUTE_SCAN_QUERY: {
+ RestQueryRequest restReq0 = new RestQueryRequest();
+
+ restReq0.sqlQuery((String)params.get("qry"));
+
+ String pageSize = (String)params.get("pageSize");
+
+ if (pageSize != null)
+ restReq0.pageSize(Integer.parseInt(pageSize));
+
+ restReq0.cacheName((String)params.get("cacheName"));
+
+ restReq0.className((String)params.get("classname"));
+
+ restReq0.queryType(RestQueryRequest.QueryType.SCAN);
+
restReq = restReq0;
break;
}
case FETCH_SQL_QUERY: {
- RestSqlQueryRequest restReq0 = new RestSqlQueryRequest();
+ RestQueryRequest restReq0 = new RestQueryRequest();
String qryId = (String) params.get("qryId");
if (qryId != null)
restReq0.queryId(Long.parseLong(qryId));
- String pageSize = (String) params.get("pageSize");
+ String pageSize = (String)params.get("pageSize");
if (pageSize != null)
restReq0.pageSize(Integer.parseInt(pageSize));
@@ -538,7 +630,7 @@ public class GridJettyRestHandler extends AbstractHandler {
}
case CLOSE_SQL_QUERY: {
- RestSqlQueryRequest restReq0 = new RestSqlQueryRequest();
+ RestQueryRequest restReq0 = new RestQueryRequest();
String qryId = (String) params.get("qryId");
@@ -601,74 +693,6 @@ public class GridJettyRestHandler extends AbstractHandler {
}
/**
- * Retrieves long value from parameters map.
- *
- * @param key Key.
- * @param params Parameters map.
- * @param dfltVal Default value.
- * @return Long value from parameters map or {@code dfltVal} if null
- * or not exists.
- * @throws IgniteCheckedException If parsing failed.
- */
- @Nullable private static Long longValue(String key, Map<String, Object> params, Long dfltVal) throws IgniteCheckedException {
- assert key != null;
-
- String val = (String) params.get(key);
-
- try {
- return val == null ? dfltVal : Long.valueOf(val);
- }
- catch (NumberFormatException ignore) {
- throw new IgniteCheckedException("Failed to parse parameter of Long type [" + key + "=" + val + "]");
- }
- }
-
- /**
- * Retrieves int value from parameters map.
- *
- * @param key Key.
- * @param params Parameters map.
- * @param dfltVal Default value.
- * @return Integer value from parameters map or {@code dfltVal} if null
- * or not exists.
- * @throws IgniteCheckedException If parsing failed.
- */
- @Nullable private static Integer intValue(String key, Map<String, Object> params, Integer dfltVal) throws IgniteCheckedException {
- assert key != null;
-
- String val = (String) params.get(key);
-
- try {
- return val == null ? dfltVal : Integer.valueOf(val);
- }
- catch (NumberFormatException ignore) {
- throw new IgniteCheckedException("Failed to parse parameter of Integer type [" + key + "=" + val + "]");
- }
- }
-
- /**
- * Retrieves UUID value from parameters map.
- *
- * @param key Key.
- * @param params Parameters map.
- * @return UUID value from parameters map or {@code null} if null
- * or not exists.
- * @throws IgniteCheckedException If parsing failed.
- */
- @Nullable private static UUID uuidValue(String key, Map<String, Object> params) throws IgniteCheckedException {
- assert key != null;
-
- String val = (String) params.get(key);
-
- try {
- return val == null ? null : UUID.fromString(val);
- }
- catch (NumberFormatException ignore) {
- throw new IgniteCheckedException("Failed to parse parameter of UUID type [" + key + "=" + val + "]");
- }
- }
-
- /**
* Gets values referenced by sequential keys, e.g. {@code key1...keyN}.
*
* @param keyPrefix Key prefix, e.g. {@code key} for {@code key1...keyN}.
@@ -736,4 +760,4 @@ public class GridJettyRestHandler extends AbstractHandler {
return null;
}
-}
\ No newline at end of file
+}
[24/34] ignite git commit: ignite-1526: fixed merging conflicts
Posted by sb...@apache.org.
ignite-1526: fixed merging conflicts
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6afc2fc3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6afc2fc3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6afc2fc3
Branch: refs/heads/ignite-1607
Commit: 6afc2fc3ca390dad7834105b53804b89f50aecf2
Parents: 5fc682f
Author: Andrey Gura <ag...@gridgain.com>
Authored: Fri Oct 9 14:23:34 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Fri Oct 9 14:23:34 2015 +0300
----------------------------------------------------------------------
.../testframework/junits/multijvm/IgniteCacheProcessProxy.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/6afc2fc3/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index 04d7893..02c6a26 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -553,7 +553,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
Collection<Entry<K, V>> res = new ArrayList<>();
for (Entry<K, V> e : cache().localEntries(peekModes))
- res.add(new CacheEntryImpl<>(e.getKey(), e.getValue()));
+ res.add(e);
return res;
}
[31/34] ignite git commit: ignite-1607 merge from master
Posted by sb...@apache.org.
ignite-1607 merge from master
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/236344c5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/236344c5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/236344c5
Branch: refs/heads/ignite-1607
Commit: 236344c5228dd418c86cf3842b6af193a67ecb7e
Parents: 3b7c71d 075e7d0
Author: sboikov <sb...@gridgain.com>
Authored: Mon Oct 12 14:50:34 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Oct 12 14:50:34 2015 +0300
----------------------------------------------------------------------
.../JettyRestProcessorAbstractSelfTest.java | 252 +++-
.../apache/ignite/IgniteSystemProperties.java | 3 +
.../org/apache/ignite/IgniteTransactions.java | 4 -
.../discovery/GridDiscoveryManager.java | 532 ++++++-
.../internal/portable/PortableContext.java | 7 +
.../portable/api/PortableMarshaller.java | 14 +-
.../processors/cache/GridCacheProcessor.java | 48 +-
.../distributed/dht/GridDhtLockRequest.java | 5 +-
.../dht/atomic/GridNearAtomicUpdateFuture.java | 8 +-
.../colocated/GridDhtColocatedLockFuture.java | 11 +-
.../distributed/near/GridNearLockFuture.java | 11 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 26 +-
.../cache/query/GridCacheQueryManager.java | 74 +-
.../cache/query/GridCacheSqlIndexMetadata.java | 7 +-
.../cache/query/GridCacheSqlMetadata.java | 22 +-
.../datastructures/DataStructuresProcessor.java | 48 +-
.../processors/rest/GridRestCommand.java | 8 +-
.../processors/rest/GridRestProcessor.java | 411 +++++-
.../handlers/cache/GridCacheCommandHandler.java | 364 ++---
.../handlers/query/QueryCommandHandler.java | 195 ++-
.../top/GridTopologyCommandHandler.java | 160 ++-
.../rest/request/RestQueryRequest.java | 175 +++
.../rest/request/RestSqlQueryRequest.java | 125 --
.../ignite/internal/util/GridJavaProcess.java | 12 +-
.../ignite/internal/util/IgniteUtils.java | 2 +-
.../ignite/internal/util/lang/GridFunc.java | 12 +
.../apache/ignite/marshaller/Marshaller.java | 2 +-
.../optimized/OptimizedMarshallerUtils.java | 6 +-
.../cache/GridCacheAbstractFullApiSelfTest.java | 486 ++++---
.../GridCacheDeploymentOffHeapSelfTest.java | 15 +
.../CacheGetFutureHangsSelfTest.java | 3 +
.../CacheNoValueClassOnServerNodeTest.java | 1 +
...niteCacheClientNodeChangingTopologyTest.java | 6 +-
...gniteAtomicLongChangingTopologySelfTest.java | 155 +-
...tomicClientOnlyMultiNodeFullApiSelfTest.java | 71 +-
...achePartitionedMultiNodeFullApiSelfTest.java | 129 +-
...bledFairAffinityMultiJvmFullApiSelfTest.java | 5 +
...tomicNearEnabledMultiJvmFullApiSelfTest.java | 5 +
.../tcp/TcpClientDiscoverySpiSelfTest.java | 2 +
.../testframework/junits/GridAbstractTest.java | 116 +-
.../junits/IgniteTestResources.java | 8 +-
.../junits/common/GridCommonAbstractTest.java | 15 +-
.../junits/multijvm/AffinityProcessProxy.java | 440 ++++--
.../multijvm/IgniteCacheProcessProxy.java | 1346 ++++++++++++++----
.../multijvm/IgniteClusterProcessProxy.java | 115 +-
.../multijvm/IgniteEventsProcessProxy.java | 50 +-
.../junits/multijvm/IgniteNodeRunner.java | 39 +-
.../junits/multijvm/IgniteProcessProxy.java | 107 +-
.../ignite/igfs/Hadoop1DualAbstractTest.java | 5 +
.../cache/CacheConfigurationP2PTest.java | 3 +
.../http/jetty/GridJettyJsonConfig.java | 158 +-
.../http/jetty/GridJettyRestHandler.java | 186 +--
.../visor/commands/kill/VisorKillCommand.scala | 2 +-
.../scala/org/apache/ignite/visor/visor.scala | 1 -
modules/yardstick/pom.xml | 10 +-
55 files changed, 4633 insertions(+), 1390 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/236344c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/236344c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
index 0646aac,1fb33a2..4dc8a84
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
@@@ -449,7 -450,10 +450,10 @@@ public class GridNearOptimisticTxPrepar
return;
}
- prepare(Collections.<IgniteTxEntry>emptyList(), tx.writeEntries());
+ prepare(
- tx.optimistic() && tx.serializable() ? tx.readEntries() : Collections.<IgniteTxEntry>emptyList(),
++ Collections.<IgniteTxEntry>emptyList(),
+ tx.writeEntries(),
+ topLocked);
markInitialized();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/236344c5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/236344c5/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
[19/34] ignite git commit: ignite-master Minor fix in visorcmd.
Posted by sb...@apache.org.
ignite-master Minor fix in visorcmd.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d9177333
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d9177333
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d9177333
Branch: refs/heads/ignite-1607
Commit: d9177333814450ad5a7b2ea88464bbbb2664b959
Parents: 3036c8d
Author: Andrey <an...@gridgain.com>
Authored: Fri Oct 9 10:13:19 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Fri Oct 9 10:13:19 2015 +0700
----------------------------------------------------------------------
.../org/apache/ignite/visor/commands/kill/VisorKillCommand.scala | 2 +-
.../src/main/scala/org/apache/ignite/visor/visor.scala | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d9177333/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/kill/VisorKillCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/kill/VisorKillCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/kill/VisorKillCommand.scala
index 6cd1ffa..dffd5f1 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/kill/VisorKillCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/kill/VisorKillCommand.scala
@@ -131,7 +131,7 @@ class VisorKillCommand extends VisorConsoleCommand {
if (kill && restart)
scold("Only one of '-k' or '-r' can be specified.")
else if (!kill && !restart)
- scold("Invalid command arguments: " + args)
+ scold("Missing '-k' or '-r' option in command: " + args)
else if (id8.isDefined && id.isDefined)
scold("Only one of -id8 or -id is allowed.")
else {
http://git-wip-us.apache.org/repos/asf/ignite/blob/d9177333/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
index 7bd6818..28ef0d7 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
@@ -461,7 +461,6 @@ object visor extends VisorTag {
shortInfo = "Starts or stops grid-wide events logging.",
longInfo = Seq(
"Logging of discovery and failure grid-wide events.",
- "Logging starts by default when Visor starts.",
" ",
"Events are logged to a file. If path is not provided,",
"it will log into '<Ignite home folder>/work/visor/visor-log'.",
[11/34] ignite git commit: Minor fixes
Posted by sb...@apache.org.
Minor fixes
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8fc14ec0
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8fc14ec0
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8fc14ec0
Branch: refs/heads/ignite-1607
Commit: 8fc14ec004cc87d731f4d089f5b5c44c91831e40
Parents: 8616889
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Tue Oct 6 13:36:25 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue Oct 6 13:36:25 2015 +0300
----------------------------------------------------------------------
.../processors/cache/distributed/dht/GridDhtLockRequest.java | 5 ++---
modules/yardstick/pom.xml | 6 ++++++
2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8fc14ec0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
index 87aa256..99c1b86 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
@@ -299,8 +299,7 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
return accessTtl;
}
- /** {@inheritDoc}
- * @param ctx*/
+ /** {@inheritDoc} */
@Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx);
@@ -529,4 +528,4 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
@Override public String toString() {
return S.toString(GridDhtLockRequest.class, this, "super", super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8fc14ec0/modules/yardstick/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/pom.xml b/modules/yardstick/pom.xml
index 2f0c5fe..d18e1a9 100644
--- a/modules/yardstick/pom.xml
+++ b/modules/yardstick/pom.xml
@@ -59,6 +59,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-log4j</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.yardstickframework</groupId>
<artifactId>yardstick</artifactId>
<version>${yardstick.version}</version>
[05/34] ignite git commit: fixed sha1 & md5,
again (cherry picked from commit 7752aa9)
Posted by sb...@apache.org.
fixed sha1 & md5, again
(cherry picked from commit 7752aa9)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ff96888e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ff96888e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ff96888e
Branch: refs/heads/ignite-1607
Commit: ff96888e0ae682ec2c2623c556f332235f25c9b8
Parents: f051e49
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Sep 25 16:01:40 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Sep 25 16:20:59 2015 +0300
----------------------------------------------------------------------
pom.xml | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ff96888e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 191ed3b..6a17668 100644
--- a/pom.xml
+++ b/pom.xml
@@ -626,7 +626,15 @@
</fileset>
</copy>
- <!-- appending filename to md5 and sha1 files. to be improved. -->
+ <!-- appending filename to md5 and sha1 files. to be improved!! -->
+ <!-- update versions task will replace " " to " ", so additional echo added. -->
+ <echo file="${basedir}/target/site/${project.artifactId}-fabric-${project.version}-bin.zip.md5" append="true" message=" " />
+ <echo file="${basedir}/target/site/${project.artifactId}-fabric-${project.version}-bin.zip.sha1" append="true" message=" " />
+ <echo file="${basedir}/target/site/${project.artifactId}-hadoop-${project.version}-bin.zip.md5" append="true" message=" " />
+ <echo file="${basedir}/target/site/${project.artifactId}-hadoop-${project.version}-bin.zip.sha1" append="true" message=" " />
+ <echo file="${basedir}/target/site/${project.artifactId}-${project.version}-src.zip.md5" append="true" message=" " />
+ <echo file="${basedir}/target/site/${project.artifactId}-${project.version}-src.zip.sha1" append="true" message=" " />
+
<echo file="${basedir}/target/site/${project.artifactId}-fabric-${project.version}-bin.zip.md5" append="true" message=" ${project.artifactId}-fabric-${project.version}-bin.zip" />
<echo file="${basedir}/target/site/${project.artifactId}-fabric-${project.version}-bin.zip.sha1" append="true" message=" ${project.artifactId}-fabric-${project.version}-bin.zip" />
<echo file="${basedir}/target/site/${project.artifactId}-hadoop-${project.version}-bin.zip.md5" append="true" message=" ${project.artifactId}-hadoop-${project.version}-bin.zip" />
[20/34] ignite git commit: ignite-1526: full support of IBM JDK by
Ignite
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index ac8c5af..d89e397 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -22,7 +22,6 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import java.util.UUID;
import java.util.concurrent.locks.Lock;
import javax.cache.CacheException;
import javax.cache.CacheManager;
@@ -35,7 +34,6 @@ import javax.cache.processor.EntryProcessorResult;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.Ignition;
import org.apache.ignite.cache.CacheEntryProcessor;
import org.apache.ignite.cache.CacheMetrics;
import org.apache.ignite.cache.CachePeekMode;
@@ -48,8 +46,8 @@ import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.lang.IgniteRunnable;
import org.apache.ignite.mxbean.CacheMetricsMXBean;
+import org.apache.ignite.resources.IgniteInstanceResource;
import org.jetbrains.annotations.Nullable;
/**
@@ -63,9 +61,6 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
/** Cache name. */
private final String cacheName;
- /** Grid id. */
- private final UUID gridId;
-
/** With async. */
private final boolean isAsync;
@@ -82,31 +77,16 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
/**
* @param name Name.
- * @param async
+ * @param async Async flag.
* @param proxy Ignite Process Proxy.
*/
public IgniteCacheProcessProxy(String name, boolean async, IgniteProcessProxy proxy) {
cacheName = name;
isAsync = async;
- gridId = proxy.getId();
igniteProxy = proxy;
compute = proxy.remoteCompute();
}
- /**
- * Returns cache instance. Method to be called from closure at another JVM.
- *
- * @return Cache.
- */
- private IgniteCache<Object, Object> cache() {
- IgniteCache cache = Ignition.ignite(gridId).cache(cacheName);
-
- if (isAsync)
- cache = cache.withAsync();
-
- return cache;
- }
-
/** {@inheritDoc} */
@Override public IgniteCache<K, V> withAsync() {
return new IgniteCacheProcessProxy<>(cacheName, true, igniteProxy);
@@ -124,14 +104,8 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
- @Override public <C extends Configuration<K, V>> C getConfiguration(final Class<C> clazz) {
- final Class cl = clazz;
-
- return (C)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().getConfiguration(cl);
- }
- });
+ @Override public <C extends Configuration<K, V>> C getConfiguration(Class<C> clazz) {
+ return compute.call(new GetConfigurationTask<>(cacheName, isAsync, clazz));
}
/** {@inheritDoc} */
@@ -149,33 +123,26 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
throw new UnsupportedOperationException("Method should be supported.");
}
+ /** {@inheritDoc} */
@Override public IgniteCache<K, V> withNoRetries() {
throw new UnsupportedOperationException("Method should be supported.");
}
/** {@inheritDoc} */
- @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException {
+ @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
+ throws CacheException {
throw new UnsupportedOperationException("Method should be supported.");
}
/** {@inheritDoc} */
- @Override public void localLoadCache(@Nullable final IgniteBiPredicate<K, V> p, @Nullable final Object... args) throws CacheException {
- final IgniteBiPredicate pCopy = p;
-
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().localLoadCache(pCopy, args);
- }
- });
+ @Override public void localLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
+ throws CacheException {
+ compute.call(new LocalLoadCacheTask<>(cacheName, isAsync, p, args));
}
/** {@inheritDoc} */
- @Override public V getAndPutIfAbsent(final K key, final V val) throws CacheException {
- return (V)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().getAndPutIfAbsent(key, val);
- }
- });
+ @Override public V getAndPutIfAbsent(K key, V val) throws CacheException {
+ return compute.call(new GetAndPutIfAbsentTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
@@ -189,12 +156,8 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
- @Override public boolean isLocalLocked(final K key, final boolean byCurrThread) {
- return compute.call(new IgniteCallable<Boolean>() {
- @Override public Boolean call() throws Exception {
- return cache().isLocalLocked(key, byCurrThread);
- }
- });
+ @Override public boolean isLocalLocked(K key, boolean byCurrThread) {
+ return compute.call(new IsLocalLockedTask<>(cacheName, isAsync, key, byCurrThread));
}
/** {@inheritDoc} */
@@ -203,18 +166,8 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public Iterable<Entry<K, V>> localEntries(final CachePeekMode... peekModes) throws CacheException {
- return (Iterable<Entry<K, V>>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- Collection<Entry> res = new ArrayList<>();
-
- for (Entry e : cache().localEntries(peekModes))
- res.add(new CacheEntryImpl(e.getKey(), e.getValue()));
-
- return res;
- }
- });
+ @Override public Iterable<Entry<K, V>> localEntries(CachePeekMode... peekModes) throws CacheException {
+ return compute.call(new LocalEntriesTask<K, V>(cacheName, isAsync, peekModes));
}
/** {@inheritDoc} */
@@ -223,21 +176,13 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
- @Override public void localEvict(final Collection<? extends K> keys) {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().localEvict(keys);
- }
- });
+ @Override public void localEvict(Collection<? extends K> keys) {
+ compute.call(new LocalEvictTask<>(cacheName, isAsync, keys));
}
/** {@inheritDoc} */
- @Override public V localPeek(final K key, final CachePeekMode... peekModes) {
- return (V)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().localPeek(key, peekModes);
- }
- });
+ @Override public V localPeek(K key, CachePeekMode... peekModes) {
+ return compute.call(new LocalPeekTask<K, V>(cacheName, isAsync, key, peekModes));
}
/** {@inheritDoc} */
@@ -246,274 +191,160 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
- @Override public int size(final CachePeekMode... peekModes) throws CacheException {
- return (int)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().size(peekModes);
- }
- });
+ @Override public int size(CachePeekMode... peekModes) throws CacheException {
+ return compute.call(new SizeTask(cacheName, isAsync, peekModes, false));
}
/** {@inheritDoc} */
- @Override public int localSize(final CachePeekMode... peekModes) {
- return (int)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().localSize(peekModes);
- }
- });
+ @Override public int localSize(CachePeekMode... peekModes) {
+ return compute.call(new SizeTask(cacheName, isAsync, peekModes, true));
}
/** {@inheritDoc} */
- @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Map<? extends K, ? extends EntryProcessor<K, V, T>> map,
- Object... args) {
+ @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(
+ Map<? extends K, ? extends EntryProcessor<K, V, T>> map,
+ Object... args)
+ {
throw new UnsupportedOperationException("Method should be supported.");
}
/** {@inheritDoc} */
- @Override public V get(final K key) {
- return (V)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().get(key);
- }
- });
+ @Override public V get(K key) {
+ return compute.call(new GetTask<K, V>(cacheName, isAsync, key));
}
/** {@inheritDoc} */
- @Override public Map<K, V> getAll(final Set<? extends K> keys) {
- return (Map<K, V>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().getAll(keys);
- }
- });
+ @Override public Map<K, V> getAll(Set<? extends K> keys) {
+ return compute.call(new GetAllTask<K, V>(cacheName, isAsync, keys));
}
- @Override public Map<K, V> getAllOutTx(final Set<? extends K> keys) {
- return (Map<K, V>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().getAllOutTx(keys);
- }
- });
+ /** {@inheritDoc} */
+ @Override public Map<K, V> getAllOutTx(Set<? extends K> keys) {
+ return compute.call(new GetAllOutTxTask<K, V>(cacheName, isAsync, keys));
}
/** {@inheritDoc} */
- @Override public boolean containsKey(final K key) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().containsKey(key);
- }
- });
+ @Override public boolean containsKey(K key) {
+ return compute.call(new ContainsKeyTask<>(cacheName, isAsync, key));
}
/** {@inheritDoc} */
- @Override public void loadAll(Set<? extends K> keys, boolean replaceExistingValues, CompletionListener completionLsnr) {
+ @Override public void loadAll(Set<? extends K> keys, boolean replaceExistVals, CompletionListener completionLsnr) {
throw new UnsupportedOperationException("Oparetion can't be supported automatically.");
}
/** {@inheritDoc} */
- @Override public boolean containsKeys(final Set<? extends K> keys) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().containsKeys(keys);
- }
- });
+ @Override public boolean containsKeys(Set<? extends K> keys) {
+ return compute.call(new ContainsKeysTask<>(cacheName, isAsync, keys));
}
/** {@inheritDoc} */
- @Override public void put(final K key, final V val) {;
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().put(key, val);
- }
- });
+ @Override public void put(K key, V val) {
+ compute.call(new PutTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
- @Override public V getAndPut(final K key, final V val) {
- return (V)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().getAndPut(key, val);
- }
- });
+ @Override public V getAndPut(K key, V val) {
+ return compute.call(new GetAndPutTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
- @Override public void putAll(final Map<? extends K, ? extends V> map) {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().putAll(map);
- }
- });
+ @Override public void putAll(Map<? extends K, ? extends V> map) {
+ compute.call(new PutAllTask<>(cacheName, isAsync, map));
}
/** {@inheritDoc} */
- @Override public boolean putIfAbsent(final K key, final V val) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().putIfAbsent(key, val);
- }
- });
+ @Override public boolean putIfAbsent(K key, V val) {
+ return compute.call(new PutIfAbsentTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
- @Override public boolean remove(final K key) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().remove(key);
- }
- });
+ @Override public boolean remove(K key) {
+ return compute.call(new RemoveTask<>(cacheName, isAsync, key));
}
/** {@inheritDoc} */
- @Override public boolean remove(final K key, final V oldVal) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().remove(key, oldVal);
- }
- });
+ @Override public boolean remove(K key, V oldVal) {
+ return compute.call(new RemoveIfExistsTask<>(cacheName, isAsync, key, oldVal));
}
/** {@inheritDoc} */
- @Override public V getAndRemove(final K key) {
- return (V)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().getAndRemove(key);
- }
- });
+ @Override public V getAndRemove(K key) {
+ return compute.call(new GetAndRemoveTask<K, V>(cacheName, isAsync, key));
}
/** {@inheritDoc} */
- @Override public boolean replace(final K key, final V oldVal, final V newVal) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().replace(key, oldVal, newVal);
- }
- });
+ @Override public boolean replace(K key, V oldVal, V newVal) {
+ return compute.call(new ReplaceIfExistsTask<>(cacheName, isAsync, key, oldVal, newVal));
}
/** {@inheritDoc} */
- @Override public boolean replace(final K key, final V val) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().replace(key, val);
- }
- });
+ @Override public boolean replace(K key, V val) {
+ return compute.call(new ReplaceTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
- @Override public V getAndReplace(final K key, final V val) {
- return (V)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().getAndReplace(key, val);
- }
- });
+ @Override public V getAndReplace(K key, V val) {
+ return compute.call(new GetAndReplaceTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
- @Override public void removeAll(final Set<? extends K> keys) {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().removeAll(keys);
- }
- });
+ @Override public void removeAll(Set<? extends K> keys) {
+ compute.call(new RemoveAllKeysTask<>(cacheName, isAsync, keys));
}
/** {@inheritDoc} */
@Override public void removeAll() {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- IgniteCache<Object, Object> cache = cache();
-
- cache.removeAll();
-
- if (isAsync)
- cache.future().get();
- }
- });
+ compute.call(new RemoveAllTask<K, V>(cacheName, isAsync));
}
/** {@inheritDoc} */
@Override public void clear() {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().clear();
- }
- });
+ compute.call(new ClearTask(cacheName, isAsync));
}
/** {@inheritDoc} */
- @Override public void clear(final K key) {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().clear(key);
- }
- });
+ @Override public void clear(K key) {
+ compute.call(new ClearKeyTask<>(cacheName, isAsync, false, key));
}
/** {@inheritDoc} */
- @Override public void clearAll(final Set<? extends K> keys) {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().clearAll(keys);
- }
- });
+ @Override public void clearAll(Set<? extends K> keys) {
+ compute.call(new ClearAllKeys<>(cacheName, isAsync, false, keys));
}
/** {@inheritDoc} */
- @Override public void localClear(final K key) {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().localClear(key);
- }
- });
+ @Override public void localClear(K key) {
+ compute.call(new ClearKeyTask<>(cacheName, isAsync, true, key));
}
/** {@inheritDoc} */
- @Override public void localClearAll(final Set<? extends K> keys) {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().localClearAll(keys);
- }
- });
+ @Override public void localClearAll(Set<? extends K> keys) {
+ compute.call(new ClearAllKeys<>(cacheName, isAsync, true, keys));
}
/** {@inheritDoc} */
- @Override public <T> T invoke(final K key, final EntryProcessor<K, V, T> entryProcessor, final Object... arguments) {
- return (T)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().invoke(key,
- (EntryProcessor<Object, Object, Object>)entryProcessor, arguments);
- }
- });
+ @Override public <T> T invoke(K key, EntryProcessor<K, V, T> processor, Object... args) {
+ return compute.call(new InvokeTask<>(cacheName, isAsync, key, processor, args));
}
/** {@inheritDoc} */
- @Override public <T> T invoke(final K key, final CacheEntryProcessor<K, V, T> entryProcessor, final Object... arguments) {
- return (T)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().invoke(key,
- (CacheEntryProcessor<Object, Object, Object>)entryProcessor, arguments);
- }
- });
+ @Override public <T> T invoke(K key, CacheEntryProcessor<K, V, T> processor, Object... args) {
+ return compute.call(new InvokeTask<>(cacheName, isAsync, key, processor, args));
}
/** {@inheritDoc} */
- @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(final Set<? extends K> keys, final EntryProcessor<K, V, T> entryProcessor,
- final Object... args) {
- return (Map<K, EntryProcessorResult<T>>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().invokeAll(keys,
- (EntryProcessor<Object, Object, Object>)entryProcessor, args);
- }
- });
+ @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(
+ Set<? extends K> keys,
+ EntryProcessor<K, V, T> processor,
+ Object... args)
+ {
+ return compute.call(new InvokeAllTask<>(cacheName, isAsync, keys, processor, args));
}
/** {@inheritDoc} */
@Override public String getName() {
- return (String)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().getName();
- }
- });
+ return compute.call(new GetNameTask(cacheName, isAsync));
}
/** {@inheritDoc} */
@@ -523,72 +354,47 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
/** {@inheritDoc} */
@Override public void close() {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().close();
- }
- });
+ compute.call(new CloseTask(cacheName, isAsync));
}
/** {@inheritDoc} */
@Override public void destroy() {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().destroy();
- }
- });
+ compute.call(new DestroyTask(cacheName, isAsync));
}
/** {@inheritDoc} */
@Override public boolean isClosed() {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().isClosed();
- }
- });
+ return compute.call(new IsClosedTask(cacheName, isAsync));
}
/** {@inheritDoc} */
- @Override public <T> T unwrap(final Class<T> clazz) {
+ @SuppressWarnings("unchecked")
+ @Override public <T> T unwrap(Class<T> clazz) {
if (Ignite.class.equals(clazz))
return (T)igniteProxy;
try {
- return (T)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().unwrap(clazz);
- }
- });
+ return compute.call(new UnwrapTask<>(cacheName, isAsync, clazz));
}
catch (Exception e) {
- throw new IllegalArgumentException("Looks like class " + clazz + " is unmarshallable. Exception type:" + e.getClass(), e);
+ throw new IllegalArgumentException("Looks like class " + clazz +
+ " is unmarshallable. Exception type:" + e.getClass(), e);
}
}
/** {@inheritDoc} */
- @Override public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
+ @Override public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> lsnrCfg) {
throw new UnsupportedOperationException("Method should be supported.");
}
/** {@inheritDoc} */
- @Override public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
+ @Override public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> lsnrCfg) {
throw new UnsupportedOperationException("Method should be supported.");
}
/** {@inheritDoc} */
@Override public Iterator<Entry<K, V>> iterator() {
- final Collection<Entry<K, V>> col = (Collection<Entry<K, V>>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- Collection res = new ArrayList();
-
- for (Object o : cache())
- res.add(o);
-
- return res;
- }
- });
-
- return col.iterator();
+ return compute.call(new IteratorTask<K, V>(cacheName, isAsync)).iterator();
}
/** {@inheritDoc} */
@@ -616,4 +422,968 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
@Override public CacheMetricsMXBean mxBean() {
throw new UnsupportedOperationException("Method should be supported.");
}
+
+ /**
+ *
+ */
+ private static class GetConfigurationTask<K, V, C extends Configuration<K, V>> extends CacheTaskAdapter<K, V, C> {
+ /** Clazz. */
+ private final Class<C> clazz;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param clazz Clazz.
+ */
+ public GetConfigurationTask(String cacheName, boolean async, Class<C> clazz) {
+ super(cacheName, async);
+ this.clazz = clazz;
+ }
+
+ /** {@inheritDoc} */
+ @Override public C call() throws Exception {
+ return cache().getConfiguration(clazz);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class LocalLoadCacheTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+ /** Predicate. */
+ private final IgniteBiPredicate<K, V> p;
+
+ /** Args. */
+ private final Object[] args;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param p P.
+ * @param args Args.
+ */
+ public LocalLoadCacheTask(String cacheName, boolean async, IgniteBiPredicate<K, V> p, Object[] args) {
+ super(cacheName, async);
+ this.p = p;
+ this.args = args;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().localLoadCache(p, args);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAndPutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public GetAndPutIfAbsentTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().getAndPutIfAbsent(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IsLocalLockedTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** By current thread. */
+ private final boolean byCurrThread;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param byCurrThread By current thread.
+ */
+ public IsLocalLockedTask(String cacheName, boolean async, K key, boolean byCurrThread) {
+ super(cacheName, async);
+ this.key = key;
+ this.byCurrThread = byCurrThread;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().isLocalLocked(key, byCurrThread);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class LocalEntriesTask<K, V> extends CacheTaskAdapter<K, V, Iterable<Entry<K, V>>> {
+ /** Peek modes. */
+ private final CachePeekMode[] peekModes;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param peekModes Peek modes.
+ */
+ public LocalEntriesTask(String cacheName, boolean async, CachePeekMode[] peekModes) {
+ super(cacheName, async);
+ this.peekModes = peekModes;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Iterable<Entry<K, V>> call() throws Exception {
+ Collection<Entry<K, V>> res = new ArrayList<>();
+
+ for (Entry<K, V> e : cache().localEntries(peekModes))
+ res.add(new CacheEntryImpl<>(e.getKey(), e.getValue()));
+
+ return res;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class LocalEvictTask<K> extends CacheTaskAdapter<K, Void, Void> {
+ /** Keys. */
+ private final Collection<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public LocalEvictTask(String cacheName, boolean async, Collection<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().localEvict(keys);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class LocalPeekTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /** Peek modes. */
+ private final CachePeekMode[] peekModes;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param peekModes Peek modes.
+ */
+ public LocalPeekTask(String cacheName, boolean async, K key, CachePeekMode[] peekModes) {
+ super(cacheName, async);
+ this.key = key;
+ this.peekModes = peekModes;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().localPeek(key, peekModes);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class SizeTask extends CacheTaskAdapter<Void, Void, Integer> {
+ /** Peek modes. */
+ private final CachePeekMode[] peekModes;
+
+ /** Local. */
+ private final boolean loc;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param peekModes Peek modes.
+ * @param loc Local.
+ */
+ public SizeTask(String cacheName, boolean async, CachePeekMode[] peekModes, boolean loc) {
+ super(cacheName, async);
+ this.loc = loc;
+ this.peekModes = peekModes;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Integer call() throws Exception {
+ return loc ? cache().localSize(peekModes) : cache().size(peekModes);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public GetTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().get(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public RemoveAllTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ IgniteCache<K, V> cache = cache();
+
+ cache.removeAll();
+
+ if (async)
+ cache.future().get();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class PutTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public PutTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().put(key, val);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ContainsKeyTask<K> extends CacheTaskAdapter<K, Object, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public ContainsKeyTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().containsKey(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ClearTask extends CacheTaskAdapter<Object, Object, Void> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public ClearTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().clear();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IteratorTask<K, V> extends CacheTaskAdapter<K, V, Collection<Entry<K, V>>> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public IteratorTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<Entry<K, V>> call() throws Exception {
+ Collection<Entry<K, V>> res = new ArrayList<>();
+
+ for (Entry<K, V> o : cache())
+ res.add(o);
+
+ return res;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ReplaceTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public ReplaceTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().replace(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetNameTask extends CacheTaskAdapter<Void, Void, String> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public GetNameTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String call() throws Exception {
+ return cache().getName();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public RemoveTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().remove(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class PutAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+ /** Map. */
+ private final Map<? extends K, ? extends V> map;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param map Map.
+ */
+ public PutAllTask(String cacheName, boolean async, Map<? extends K, ? extends V> map) {
+ super(cacheName, async);
+ this.map = map;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().putAll(map);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveAllKeysTask<K> extends CacheTaskAdapter<K, Void, Void> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public RemoveAllKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().removeAll(keys);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAllTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public GetAllTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, V> call() throws Exception {
+ return cache().getAll(keys);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAllOutTxTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public GetAllOutTxTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, V> call() throws Exception {
+ return cache().getAllOutTx(keys);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ContainsKeysTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public ContainsKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().containsKeys(keys);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAndPutTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public GetAndPutTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().getAndPut(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class PutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public PutIfAbsentTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().putIfAbsent(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Old value. */
+ private final V oldVal;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param oldVal Old value.
+ */
+ public RemoveIfExistsTask(String cacheName, boolean async, K key, V oldVal) {
+ super(cacheName, async);
+ this.key = key;
+ this.oldVal = oldVal;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().remove(key, oldVal);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAndRemoveTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public GetAndRemoveTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().getAndRemove(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ReplaceIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Old value. */
+ private final V oldVal;
+
+ /** New value. */
+ private final V newVal;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param oldVal Old value.
+ * @param newVal New value.
+ */
+ public ReplaceIfExistsTask(String cacheName, boolean async, K key, V oldVal, V newVal) {
+ super(cacheName, async);
+ this.key = key;
+ this.oldVal = oldVal;
+ this.newVal = newVal;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().replace(key, oldVal, newVal);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAndReplaceTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public GetAndReplaceTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().getAndReplace(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ClearKeyTask<K> extends CacheTaskAdapter<K, Void, Void> {
+ /** Key. */
+ private final K key;
+
+ /** Local. */
+ private final boolean loc;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public ClearKeyTask(String cacheName, boolean async, boolean loc, K key) {
+ super(cacheName, async);
+ this.key = key;
+ this.loc = loc;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ if (loc)
+ cache().localClear(key);
+ else
+ cache().clear(key);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ClearAllKeys<K> extends CacheTaskAdapter<K, Void, Void> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /** Local. */
+ private final boolean loc;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public ClearAllKeys(String cacheName, boolean async, boolean loc, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ this.loc = loc;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ if (loc)
+ cache().localClearAll(keys);
+ else
+ cache().clearAll(keys);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class InvokeTask<K, V, R> extends CacheTaskAdapter<K, V, R> {
+ /** Key. */
+ private final K key;
+
+ /** Processor. */
+ private final EntryProcessor<K, V, R> processor;
+
+ /** Args. */
+ private final Object[] args;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param processor Processor.
+ * @param args Args.
+ */
+ public InvokeTask(String cacheName, boolean async, K key, EntryProcessor<K, V, R> processor,
+ Object[] args) {
+ super(cacheName, async);
+ this.args = args;
+ this.key = key;
+ this.processor = processor;
+ }
+
+ /** {@inheritDoc} */
+ @Override public R call() throws Exception {
+ return cache().invoke(key, processor, args);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class InvokeAllTask<K, V, T> extends CacheTaskAdapter<K, V, Map<K, EntryProcessorResult<T>>> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /** Processor. */
+ private final EntryProcessor<K, V, T> processor;
+
+ /** Args. */
+ private final Object[] args;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ * @param processor Processor.
+ * @param args Args.
+ */
+ public InvokeAllTask(String cacheName, boolean async, Set<? extends K> keys,
+ EntryProcessor<K, V, T> processor, Object[] args) {
+ super(cacheName, async);
+ this.args = args;
+ this.keys = keys;
+ this.processor = processor;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, EntryProcessorResult<T>> call() throws Exception {
+ return cache().invokeAll(keys, processor, args);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CloseTask extends CacheTaskAdapter<Void, Void, Void> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public CloseTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().close();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class DestroyTask extends CacheTaskAdapter<Void, Void, Void> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public DestroyTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().destroy();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IsClosedTask extends CacheTaskAdapter<Void, Void, Boolean> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public IsClosedTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().isClosed();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class UnwrapTask<R> extends CacheTaskAdapter<Void, Void, R> {
+ /** Clazz. */
+ private final Class<R> clazz;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param clazz Clazz.
+ */
+ public UnwrapTask(String cacheName, boolean async, Class<R> clazz) {
+ super(cacheName, async);
+ this.clazz = clazz;
+ }
+
+ /** {@inheritDoc} */
+ @Override public R call() throws Exception {
+ return cache().unwrap(clazz);
+ }
+ }
+
+ /**
+ *
+ */
+ private static abstract class CacheTaskAdapter<K, V, R> implements IgniteCallable<R> {
+ /** Ignite. */
+ @IgniteInstanceResource
+ protected Ignite ignite;
+
+ /** Cache name. */
+ protected final String cacheName;
+
+ /** Async. */
+ protected final boolean async;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public CacheTaskAdapter(String cacheName, boolean async) {
+ this.async = async;
+ this.cacheName = cacheName;
+ }
+
+ /**
+ * Returns cache instance.
+ */
+ protected IgniteCache<K, V> cache() {
+ IgniteCache<K, V> cache = ignite.cache(cacheName);
+
+ return async ? cache.withAsync() : cache;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
index 05d6533..633e9d0 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
@@ -26,7 +26,6 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCluster;
import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.cluster.ClusterMetrics;
import org.apache.ignite.cluster.ClusterNode;
@@ -36,6 +35,7 @@ import org.apache.ignite.internal.cluster.IgniteClusterEx;
import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.IgniteInstanceResource;
import org.jetbrains.annotations.Nullable;
/**
@@ -43,9 +43,6 @@ import org.jetbrains.annotations.Nullable;
*/
@SuppressWarnings("TransientFieldInNonSerializableClass")
public class IgniteClusterProcessProxy implements IgniteClusterEx {
- /** Grid id. */
- private final UUID gridId;
-
/** Compute. */
private final transient IgniteCompute compute;
@@ -57,21 +54,11 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
*/
public IgniteClusterProcessProxy(IgniteProcessProxy proxy) {
this.proxy = proxy;
- gridId = proxy.getId();
compute = proxy.remoteCompute();
}
- /**
- * Returns cluster instance. Method to be called from closure at another JVM.
- *
- * @return Cache.
- */
- private IgniteClusterEx cluster() {
- return (IgniteClusterEx)Ignition.ignite(gridId).cluster();
- }
-
/** {@inheritDoc} */
- @Override public ClusterGroupEx forSubjectId(final UUID subjId) {
+ @Override public ClusterGroupEx forSubjectId(UUID subjId) {
throw new UnsupportedOperationException("Operation is not supported yet.");
}
@@ -83,11 +70,7 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
/** {@inheritDoc} */
@Override public ClusterNode localNode() {
- return compute.call(new IgniteCallable<ClusterNode>() {
- @Override public ClusterNode call() throws Exception {
- return cluster().localNode();
- }
- });
+ return compute.call(new LocalNodeTask());
}
/** {@inheritDoc} */
@@ -285,38 +268,22 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
/** {@inheritDoc} */
@Override public Collection<ClusterNode> nodes() {
- return compute.call(new IgniteCallable<Collection<ClusterNode>>() {
- @Override public Collection<ClusterNode> call() throws Exception {
- return cluster().nodes();
- }
- });
+ return compute.call(new NodesTask());
}
/** {@inheritDoc} */
- @Override public ClusterNode node(final UUID nid) {
- return compute.call(new IgniteCallable<ClusterNode>() {
- @Override public ClusterNode call() throws Exception {
- return cluster().node(nid);
- }
- });
+ @Override public ClusterNode node(UUID nid) {
+ return compute.call(new NodeTask(nid));
}
/** {@inheritDoc} */
@Override public ClusterNode node() {
- return compute.call(new IgniteCallable<ClusterNode>() {
- @Override public ClusterNode call() throws Exception {
- return cluster().node();
- }
- });
+ return compute.call(new NodeTask(null));
}
/** {@inheritDoc} */
@Override public Collection<String> hostNames() {
- return compute.call(new IgniteCallable<Collection<String>>() {
- @Override public Collection<String> call() throws Exception {
- return cluster().hostNames();
- }
- });
+ return compute.call(new HostNamesTask());
}
/** {@inheritDoc} */
@@ -333,4 +300,70 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
@Nullable @Override public IgniteFuture<?> clientReconnectFuture() {
throw new UnsupportedOperationException("Operation is not supported yet.");
}
+
+ /**
+ *
+ */
+ private static class LocalNodeTask extends ClusterTaskAdapter<ClusterNode> {
+ /** {@inheritDoc} */
+ @Override public ClusterNode call() throws Exception {
+ return cluster().localNode();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class NodesTask extends ClusterTaskAdapter<Collection<ClusterNode>> {
+ /** {@inheritDoc} */
+ @Override public Collection<ClusterNode> call() throws Exception {
+ return cluster().nodes();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class NodeTask extends ClusterTaskAdapter<ClusterNode> {
+ /** Node id. */
+ private final UUID nodeId;
+
+ /**
+ * @param nodeId Node id.
+ */
+ public NodeTask(UUID nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ClusterNode call() throws Exception {
+ return nodeId == null ? cluster().node() : cluster().node(nodeId);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class HostNamesTask extends ClusterTaskAdapter<Collection<String>> {
+ /** {@inheritDoc} */
+ @Override public Collection<String> call() throws Exception {
+ return cluster().hostNames();
+ }
+ }
+
+ /**
+ *
+ */
+ private abstract static class ClusterTaskAdapter<R> implements IgniteCallable<R> {
+ /** Ignite. */
+ @IgniteInstanceResource
+ protected Ignite ignite;
+
+ /**
+ *
+ */
+ protected IgniteCluster cluster() {
+ return ignite.cluster();
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
index 860f889..d5af81e 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
@@ -20,15 +20,16 @@ package org.apache.ignite.testframework.junits.multijvm;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
+import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteEvents;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.events.Event;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.IgniteInstanceResource;
import org.jetbrains.annotations.Nullable;
/**
@@ -39,23 +40,11 @@ public class IgniteEventsProcessProxy implements IgniteEvents {
/** Ignite proxy. */
private final transient IgniteProcessProxy igniteProxy;
- /** Grid id. */
- private final UUID gridId;
-
/**
* @param igniteProxy Ignite proxy.
*/
public IgniteEventsProcessProxy(IgniteProcessProxy igniteProxy) {
this.igniteProxy = igniteProxy;
-
- gridId = igniteProxy.getId();
- }
-
- /**
- * @return Events instance.
- */
- private IgniteEvents events() {
- return Ignition.ignite(gridId).events();
}
/** {@inheritDoc} */
@@ -105,11 +94,7 @@ public class IgniteEventsProcessProxy implements IgniteEvents {
/** {@inheritDoc} */
@Override public void localListen(final IgnitePredicate<? extends Event> lsnr, final int... types) {
- igniteProxy.remoteCompute().run(new IgniteRunnable() {
- @Override public void run() {
- events().localListen(lsnr, types);
- }
- });
+ igniteProxy.remoteCompute().run(new LocalListenTask(lsnr, types));
}
/** {@inheritDoc} */
@@ -151,4 +136,33 @@ public class IgniteEventsProcessProxy implements IgniteEvents {
@Override public <R> IgniteFuture<R> future() {
throw new UnsupportedOperationException("Operation isn't supported yet.");
}
+
+ /**
+ *
+ */
+ private static class LocalListenTask implements IgniteRunnable {
+ /** Ignite. */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** Listener. */
+ private final IgnitePredicate<? extends Event> lsnr;
+
+ /** Types. */
+ private final int[] types;
+
+ /**
+ * @param lsnr Listener.
+ * @param types Types.
+ */
+ public LocalListenTask(IgnitePredicate<? extends Event> lsnr, int[] types) {
+ this.lsnr = lsnr;
+ this.types = types;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ ignite.events().localListen(lsnr, types);
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
index f46e8e9..0597eda 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
@@ -25,13 +25,12 @@ import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
-import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.Ignition;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
@@ -39,8 +38,9 @@ import org.apache.ignite.internal.processors.cache.GridCacheAbstractFullApiSelfT
import org.apache.ignite.internal.util.GridJavaProcess;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.testframework.junits.IgniteTestResources;
import sun.jvmstat.monitor.HostIdentifier;
import sun.jvmstat.monitor.MonitoredHost;
import sun.jvmstat.monitor.MonitoredVm;
@@ -99,30 +99,6 @@ public class IgniteNodeRunner {
public static String storeToFile(IgniteConfiguration cfg) throws IOException {
String fileName = IGNITE_CONFIGURATION_FILE + cfg.getNodeId();
- // Check marshaller configuration, because read configuration method expect specific marshaller.
- if (cfg.getMarshaller() instanceof OptimizedMarshaller){
- OptimizedMarshaller marsh = (OptimizedMarshaller)cfg.getMarshaller();
-
- try {
- Field isRequireFiled = marsh.getClass().getDeclaredField("requireSer");
-
- isRequireFiled.setAccessible(true);
-
- boolean isRequireSer = isRequireFiled.getBoolean(marsh);
-
- if (isRequireSer)
- throw new UnsupportedOperationException("Unsupported marshaller configuration. " +
- "readCfgFromFileAndDeleteFile method expect " + OptimizedMarshaller.class.getSimpleName() +
- "with requireSerializeble flag in 'false'.");
- }
- catch (NoSuchFieldException|IllegalAccessException e) {
- throw new IgniteException("Failed to check filed of " + OptimizedMarshaller.class.getSimpleName(), e);
- }
- }
- else
- throw new UnsupportedOperationException("Unsupported marshaller. " +
- "readCfgFromFileAndDeleteFile method expect " + OptimizedMarshaller.class.getSimpleName());
-
try(OutputStream out = new BufferedOutputStream(new FileOutputStream(fileName))) {
cfg.setMBeanServer(null);
cfg.setMarshaller(null);
@@ -143,11 +119,16 @@ public class IgniteNodeRunner {
* @throws IOException If failed.
* @see #storeToFile(IgniteConfiguration)
*/
- private static IgniteConfiguration readCfgFromFileAndDeleteFile(String fileName) throws IOException {
+ private static IgniteConfiguration readCfgFromFileAndDeleteFile(String fileName)
+ throws IOException, IgniteCheckedException {
try(BufferedReader cfgReader = new BufferedReader(new FileReader(fileName))) {
IgniteConfiguration cfg = (IgniteConfiguration)new XStream().fromXML(cfgReader);
- cfg.setMarshaller(new OptimizedMarshaller(false));
+ Marshaller marsh = IgniteTestResources.getMarshaller();
+
+ cfg.setMarshaller(marsh);
+
+ X.println("Configured marshaller class: " + marsh.getClass().getName());
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(GridCacheAbstractFullApiSelfTest.LOCAL_IP_FINDER);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
index ec7dab7..aa1d470 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
@@ -41,13 +41,11 @@ import org.apache.ignite.IgniteFileSystem;
import org.apache.ignite.IgniteIllegalStateException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteMessaging;
-import org.apache.ignite.internal.portable.api.IgnitePortables;
import org.apache.ignite.IgniteQueue;
import org.apache.ignite.IgniteScheduler;
import org.apache.ignite.IgniteServices;
import org.apache.ignite.IgniteSet;
import org.apache.ignite.IgniteTransactions;
-import org.apache.ignite.Ignition;
import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.cluster.ClusterNode;
@@ -62,6 +60,7 @@ import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.cluster.IgniteClusterEx;
+import org.apache.ignite.internal.portable.api.IgnitePortables;
import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
import org.apache.ignite.internal.processors.hadoop.Hadoop;
@@ -78,6 +77,8 @@ import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.lang.IgniteRunnable;
import org.apache.ignite.plugin.IgnitePlugin;
import org.apache.ignite.plugin.PluginNotFoundException;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.testframework.junits.IgniteTestResources;
import org.jetbrains.annotations.Nullable;
/**
@@ -88,6 +89,9 @@ public class IgniteProcessProxy implements IgniteEx {
/** Grid proxies. */
private static final transient ConcurrentMap<String, IgniteProcessProxy> gridProxies = new ConcurrentHashMap<>();
+ /** Property that specify alternative {@code JAVA_HOME}. */
+ private static final String TEST_MULTIJVM_JAVA_HOME = "test.multijvm.java.home";
+
/** Jvm process with ignite instance. */
private final transient GridJavaProcess proc;
@@ -108,7 +112,7 @@ public class IgniteProcessProxy implements IgniteEx {
* @param log Logger.
* @param locJvmGrid Local JVM grid.
*/
- public IgniteProcessProxy(final IgniteConfiguration cfg, final IgniteLogger log, final Ignite locJvmGrid)
+ public IgniteProcessProxy(IgniteConfiguration cfg, IgniteLogger log, Ignite locJvmGrid)
throws Exception {
this.cfg = cfg;
this.locJvmGrid = locJvmGrid;
@@ -121,7 +125,9 @@ public class IgniteProcessProxy implements IgniteEx {
Collection<String> filteredJvmArgs = new ArrayList<>();
for (String arg : jvmArgs) {
- if(!arg.toLowerCase().startsWith("-agentlib"))
+ if(arg.startsWith("-Xmx") || arg.startsWith("-Xms") ||
+ arg.startsWith("-cp") || arg.startsWith("-classpath") ||
+ arg.startsWith("-D" + IgniteTestResources.MARSH_CLASS_NAME))
filteredJvmArgs.add(arg);
}
@@ -130,7 +136,7 @@ public class IgniteProcessProxy implements IgniteEx {
locJvmGrid.events().localListen(new NodeStartedListener(id, rmtNodeStartedLatch), EventType.EVT_NODE_JOINED);
proc = GridJavaProcess.exec(
- IgniteNodeRunner.class,
+ IgniteNodeRunner.class.getCanonicalName(),
cfgFileName, // Params.
this.log,
// Optional closure to be called each time wrapped process prints line to system.out or system.err.
@@ -140,6 +146,7 @@ public class IgniteProcessProxy implements IgniteEx {
}
},
null,
+ System.getProperty(TEST_MULTIJVM_JAVA_HOME),
filteredJvmArgs, // JVM Args.
System.getProperty("surefire.test.class.path")
);
@@ -149,11 +156,7 @@ public class IgniteProcessProxy implements IgniteEx {
IgniteProcessProxy prevVal = gridProxies.putIfAbsent(cfg.getGridName(), this);
if (prevVal != null) {
- remoteCompute().run(new IgniteRunnable() {
- @Override public void run() {
- G.stop(cfg.getGridName(), true);
- }
- });
+ remoteCompute().run(new StopGridTask(cfg.getGridName(), true));
throw new IllegalStateException("There was found instance assotiated with " + cfg.getGridName() +
", instance= " + prevVal + ". New started node was stopped.");
@@ -208,30 +211,17 @@ public class IgniteProcessProxy implements IgniteEx {
* @param gridName Grid name.
* @param cancel Cacnel flag.
*/
- public static void stop(final String gridName, final boolean cancel) {
+ public static void stop(String gridName, boolean cancel) {
IgniteProcessProxy proxy = gridProxies.get(gridName);
if (proxy != null) {
- proxy.remoteCompute().run(new IgniteRunnable() {
- @Override public void run() {
- G.stop(gridName, cancel);
- }
- });
+ proxy.remoteCompute().run(new StopGridTask(gridName, cancel));
gridProxies.remove(gridName, proxy);
}
}
/**
- * For usage in closures.
- *
- * @return Ignite instance.
- */
- private Ignite igniteById() {
- return Ignition.ignite(id);
- }
-
- /**
* @param locNodeId ID of local node the requested grid instance is managing.
* @return An instance of named grid. This method never returns {@code null}.
* @throws IgniteIllegalStateException Thrown if grid was not properly initialized or grid instance was stopped or
@@ -357,11 +347,7 @@ public class IgniteProcessProxy implements IgniteEx {
/** {@inheritDoc} */
@Override public ClusterNode localNode() {
- return remoteCompute().call(new IgniteCallable<ClusterNode>() {
- @Override public ClusterNode call() throws Exception {
- return ((IgniteEx)Ignition.ignite(id)).localNode();
- }
- });
+ return remoteCompute().call(new NodeTask());
}
/** {@inheritDoc} */
@@ -467,7 +453,10 @@ public class IgniteProcessProxy implements IgniteEx {
}
/** {@inheritDoc} */
- @Override public <K, V> IgniteCache<K, V> createNearCache(@Nullable String cacheName, NearCacheConfiguration<K, V> nearCfg) {
+ @Override public <K, V> IgniteCache<K, V> createNearCache(
+ @Nullable String cacheName,
+ NearCacheConfiguration<K, V> nearCfg)
+ {
throw new UnsupportedOperationException("Operation isn't supported yet.");
}
@@ -508,7 +497,8 @@ public class IgniteProcessProxy implements IgniteEx {
}
/** {@inheritDoc} */
- @Override public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create) throws IgniteException {
+ @Override public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create)
+ throws IgniteException {
throw new UnsupportedOperationException("Operation isn't supported yet.");
}
@@ -524,8 +514,12 @@ public class IgniteProcessProxy implements IgniteEx {
}
/** {@inheritDoc} */
- @Override public <T, S> IgniteAtomicStamped<T, S> atomicStamped(String name, @Nullable T initVal, @Nullable S initStamp,
- boolean create) throws IgniteException {
+ @Override public <T, S> IgniteAtomicStamped<T, S> atomicStamped(
+ String name,
+ @Nullable T initVal,
+ @Nullable S initStamp,
+ boolean create) throws IgniteException
+ {
throw new UnsupportedOperationException("Operation isn't supported yet.");
}
@@ -572,11 +566,7 @@ public class IgniteProcessProxy implements IgniteEx {
}
}, EventType.EVT_NODE_LEFT, EventType.EVT_NODE_FAILED);
- compute().run(new IgniteRunnable() {
- @Override public void run() {
- igniteById().close();
- }
- });
+ compute().run(new StopGridTask(localJvmGrid().name(), true));
try {
assert U.await(rmtNodeStoppedLatch, 15, TimeUnit.SECONDS) : "NodeId=" + id;
@@ -616,4 +606,43 @@ public class IgniteProcessProxy implements IgniteEx {
return locJvmGrid.compute(grp);
}
+
+ /**
+ *
+ */
+ private static class StopGridTask implements IgniteRunnable {
+ /** Grid name. */
+ private final String gridName;
+
+ /** Cancel. */
+ private final boolean cancel;
+
+ /**
+ * @param gridName Grid name.
+ * @param cancel Cancel.
+ */
+ public StopGridTask(String gridName, boolean cancel) {
+ this.gridName = gridName;
+ this.cancel = cancel;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ G.stop(gridName, cancel);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class NodeTask implements IgniteCallable<ClusterNode> {
+ /** Ignite. */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override public ClusterNode call() throws Exception {
+ return ((IgniteEx)ignite).localNode();
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java
index 5298dd4..3777154 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java
@@ -103,6 +103,7 @@ public class CacheConfigurationP2PTest extends GridCommonAbstractTest {
}
},
null,
+ null,
jvmArgs,
null
);
@@ -119,6 +120,7 @@ public class CacheConfigurationP2PTest extends GridCommonAbstractTest {
}
},
null,
+ null,
jvmArgs,
null
);
@@ -139,6 +141,7 @@ public class CacheConfigurationP2PTest extends GridCommonAbstractTest {
}
},
null,
+ null,
jvmArgs,
cp
);
[17/34] ignite git commit: Fix REST authentication.
Posted by sb...@apache.org.
Fix REST authentication.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f025714e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f025714e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f025714e
Branch: refs/heads/ignite-1607
Commit: f025714ef0d21ffff7ebf6088c254f26dd9aa3fc
Parents: f60cba7
Author: ashutak <as...@gridgain.com>
Authored: Wed Oct 7 16:11:18 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Oct 7 16:11:18 2015 +0300
----------------------------------------------------------------------
.../JettyRestProcessorAbstractSelfTest.java | 27 +-
.../apache/ignite/IgniteSystemProperties.java | 3 +
.../processors/rest/GridRestProcessor.java | 356 +++++++++++++++++--
.../handlers/cache/GridCacheCommandHandler.java | 2 +-
.../ignite/internal/util/IgniteUtils.java | 2 +-
5 files changed, 341 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f025714e/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
index 8db4cd7..ac0edff 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
@@ -84,6 +84,13 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
protected abstract int restPort();
/**
+ * @return Security enabled flag. Should be the same with {@code ctx.security().enabled()}.
+ */
+ protected boolean securityEnabled() {
+ return false;
+ }
+
+ /**
* @param params Command parameters.
* @return Returned content.
* @throws Exception If failed.
@@ -133,7 +140,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
return "\\{\\\"affinityNodeId\\\":\\\"\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}\\\"\\," +
"\\\"error\\\":\\\"\\\"\\," +
"\\\"response\\\":\\\"" + res + "\\\"\\," +
- "\\\"sessionToken\\\":\\\"\\\"," +
+ "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
"\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
}
@@ -157,7 +164,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
private String integerPattern(int res, boolean success) {
return "\\{\\\"error\\\":\\\"\\\"\\," +
"\\\"response\\\":" + res + "\\," +
- "\\\"sessionToken\\\":\\\"\\\"," +
+ "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
"\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
}
@@ -170,7 +177,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
return "\\{\\\"affinityNodeId\\\":\\\"\\\"\\," +
"\\\"error\\\":\\\"\\\"\\," +
"\\\"response\\\":" + res + "\\," +
- "\\\"sessionToken\\\":\\\"\\\"," +
+ "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
"\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
}
@@ -183,7 +190,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
return "\\{\\\"affinityNodeId\\\":\\\"\\\"\\," +
"\\\"error\\\":\\\"\\\"\\," +
"\\\"response\\\":" + res + "\\," +
- "\\\"sessionToken\\\":\\\"\\\"," +
+ "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
"\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
}
@@ -196,7 +203,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
return "\\{\\\"affinityNodeId\\\":\\\"\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}\\\"\\," +
"\\\"error\\\":\\\"\\\"\\," +
"\\\"response\\\":" + res + "\\," +
- "\\\"sessionToken\\\":\\\"\\\"," +
+ "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
"\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
}
@@ -209,7 +216,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
return "\\{\\\"affinityNodeId\\\":\\\"\\\"\\," +
"\\\"error\\\":\\\"\\\"\\," +
"\\\"response\\\":" + res + "\\," +
- "\\\"sessionToken\\\":\\\"\\\"," +
+ "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
"\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
}
@@ -222,7 +229,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
return "\\{\\\"affinityNodeId\\\":\\\"(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})?\\\"\\," +
"\\\"error\\\":\\\"\\\"\\," +
"\\\"response\\\":" + res + "\\," +
- "\\\"sessionToken\\\":\\\"\\\"," +
+ "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
"\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
}
@@ -234,7 +241,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
private String pattern(String res, boolean success) {
return "\\{\\\"error\\\":\\\"" + (!success ? ".+" : "") + "\\\"\\," +
"\\\"response\\\":" + res + "\\," +
- "\\\"sessionToken\\\":\\\"\\\"," +
+ "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
"\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
}
@@ -246,7 +253,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
private String stringPattern(String res, boolean success) {
return "\\{\\\"error\\\":\\\"" + (!success ? ".+" : "") + "\\\"\\," +
"\\\"response\\\":\\\"" + res + "\\\"\\," +
- "\\\"sessionToken\\\":\\\"\\\"," +
+ "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
"\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
}
@@ -1316,4 +1323,4 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
return id;
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f025714e/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index 1e4c8b7..5d3b08b 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -96,6 +96,9 @@ public final class IgniteSystemProperties {
*/
public static final String IGNITE_JETTY_LOG_NO_OVERRIDE = "IGNITE_JETTY_LOG_NO_OVERRIDE";
+ /** This property allow rewriting default ({@code 30}) rest session expire time (in seconds). */
+ public static final String IGNITE_REST_SESSION_TIMEOUT = "IGNITE_REST_SESSION_TIMEOUT";
+
/**
* This property allows to override maximum count of task results stored on one node
* in REST processor.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f025714e/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
index d606ba4..d54c8bb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.rest;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.EnumMap;
import java.util.HashMap;
@@ -30,7 +31,9 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.atomic.AtomicLong;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.configuration.ConnectorConfiguration;
import org.apache.ignite.configuration.ConnectorMessageInterceptor;
import org.apache.ignite.internal.GridKernalContext;
@@ -53,8 +56,10 @@ import org.apache.ignite.internal.processors.security.SecurityContext;
import org.apache.ignite.internal.util.GridSpinReadWriteLock;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.typedef.C1;
+import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.LT;
+import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.internal.util.worker.GridWorker;
import org.apache.ignite.internal.util.worker.GridWorkerFuture;
@@ -65,6 +70,7 @@ import org.apache.ignite.plugin.security.AuthenticationContext;
import org.apache.ignite.plugin.security.SecurityCredentials;
import org.apache.ignite.plugin.security.SecurityException;
import org.apache.ignite.plugin.security.SecurityPermission;
+import org.apache.ignite.thread.IgniteThread;
import org.jsr166.LongAdder8;
import static org.apache.ignite.internal.processors.rest.GridRestResponse.STATUS_AUTH_FAILED;
@@ -80,8 +86,11 @@ public class GridRestProcessor extends GridProcessorAdapter {
private static final String HTTP_PROTO_CLS =
"org.apache.ignite.internal.processors.rest.protocols.http.jetty.GridJettyRestProtocol";
- /** */
- public static final byte[] ZERO_BYTES = new byte[0];
+ /** Delay between sessions timeout checks. */
+ private static final int SES_TIMEOUT_CHECK_DELAY = 1_000;
+
+ /** Default session timout. */
+ private static final int DEFAULT_SES_TIMEOUT = 30_000;
/** Protocols. */
private final Collection<GridRestProtocol> protos = new ArrayList<>();
@@ -98,8 +107,14 @@ public class GridRestProcessor extends GridProcessorAdapter {
/** Workers count. */
private final LongAdder8 workersCnt = new LongAdder8();
- /** SecurityContext map. */
- private ConcurrentMap<UUID, SecurityContext> sesMap = new ConcurrentHashMap<>();
+ /** ClientId-SessionId map. */
+ private final ConcurrentMap<UUID, UUID> clientId2SesId = new ConcurrentHashMap<>();
+
+ /** SessionId-Session map. */
+ private final ConcurrentMap<UUID, Session> sesId2Ses = new ConcurrentHashMap<>();
+
+ /** */
+ private final Thread sesTimeoutCheckerThread;
/** Protocol handler. */
private final GridRestProtocolHandler protoHnd = new GridRestProtocolHandler() {
@@ -112,6 +127,9 @@ public class GridRestProcessor extends GridProcessorAdapter {
}
};
+ /** Session time to live. */
+ private final long sesTtl;
+
/**
* @param req Request.
* @return Future.
@@ -195,22 +213,40 @@ public class GridRestProcessor extends GridProcessorAdapter {
if (log.isDebugEnabled())
log.debug("Received request from client: " + req);
- SecurityContext subjCtx = null;
-
if (ctx.security().enabled()) {
+ Session ses;
+
try {
- subjCtx = authenticate(req);
+ ses = session(req);
+ }
+ catch (IgniteCheckedException e) {
+ GridRestResponse res = new GridRestResponse(STATUS_FAILED, e.getMessage());
- authorize(req, subjCtx);
+ return new GridFinishedFuture<>(res);
+ }
+
+ assert ses != null;
+
+ req.clientId(ses.clientId);
+ req.sessionToken(U.uuidToBytes(ses.sesId));
+
+ if (log.isDebugEnabled())
+ log.debug("Next clientId and sessionToken were extracted according to request: " +
+ "[clientId="+req.clientId()+", sesTok="+Arrays.toString(req.sessionToken())+"]");
+
+ SecurityContext secCtx0 = ses.secCtx;
+
+ try {
+ if (secCtx0 == null)
+ ses.secCtx = secCtx0 = authenticate(req);
+
+ authorize(req, secCtx0);
}
catch (SecurityException e) {
- assert subjCtx != null;
+ assert secCtx0 != null;
GridRestResponse res = new GridRestResponse(STATUS_SECURITY_CHECK_FAILED, e.getMessage());
- updateSession(req, subjCtx);
- res.sessionTokenBytes(ZERO_BYTES);
-
return new GridFinishedFuture<>(res);
}
catch (IgniteCheckedException e) {
@@ -228,16 +264,18 @@ public class GridRestProcessor extends GridProcessorAdapter {
return new GridFinishedFuture<>(
new IgniteCheckedException("Failed to find registered handler for command: " + req.command()));
- final SecurityContext subjCtx0 = subjCtx;
-
return res.chain(new C1<IgniteInternalFuture<GridRestResponse>, GridRestResponse>() {
@Override public GridRestResponse apply(IgniteInternalFuture<GridRestResponse> f) {
GridRestResponse res;
+ boolean failed = false;
+
try {
res = f.get();
}
catch (Exception e) {
+ failed = true;
+
if (!X.hasCause(e, VisorClusterGroupEmptyException.class))
LT.error(log, e, "Failed to handle request: " + req.command());
@@ -249,10 +287,8 @@ public class GridRestProcessor extends GridProcessorAdapter {
assert res != null;
- if (ctx.security().enabled()) {
- updateSession(req, subjCtx0);
- res.sessionTokenBytes(ZERO_BYTES);
- }
+ if (ctx.security().enabled() && !failed)
+ res.sessionTokenBytes(req.sessionToken());
interceptResponse(res, req);
@@ -262,10 +298,137 @@ public class GridRestProcessor extends GridProcessorAdapter {
}
/**
+ * @param req Request.
+ * @return Not null session.
+ * @throws IgniteCheckedException If failed.
+ */
+ private Session session(final GridRestRequest req) throws IgniteCheckedException {
+ final UUID clientId = req.clientId();
+ final byte[] sesTok = req.sessionToken();
+
+ while (true) {
+ if (F.isEmpty(sesTok) && clientId == null) {
+ Session ses = Session.random();
+
+ UUID oldSesId = clientId2SesId.put(ses.clientId, ses.sesId);
+
+ assert oldSesId == null : "Got an illegal state for request: " + req;
+
+ Session oldSes = sesId2Ses.put(ses.sesId, ses);
+
+ assert oldSes == null : "Got an illegal state for request: " + req;
+
+ return ses;
+ }
+
+ if (F.isEmpty(sesTok) && clientId != null) {
+ UUID sesId = clientId2SesId.get(clientId);
+
+ if (sesId == null) {
+ Session ses = Session.fromClientId(clientId);
+
+ if (clientId2SesId.putIfAbsent(ses.clientId, ses.sesId) != null)
+ continue; // Another thread already register session with the clientId.
+
+ Session prevSes = sesId2Ses.put(ses.sesId, ses);
+
+ assert prevSes == null : "Got an illegal state for request: " + req;
+
+ return ses;
+ }
+ else {
+ Session ses = sesId2Ses.get(sesId);
+
+ if (ses == null || !ses.touch())
+ continue; // Need to wait while timeout thread complete removing of timed out sessions.
+
+ return ses;
+ }
+ }
+
+ if (!F.isEmpty(sesTok) && clientId == null) {
+ UUID sesId = U.bytesToUuid(sesTok, 0);
+
+ Session ses = sesId2Ses.get(sesId);
+
+ if (ses == null)
+ throw new IgniteCheckedException("Failed to handle request - unknown session token " +
+ "(maybe expired session) [sesTok=" + U.byteArray2HexString(sesTok) + "]");
+
+ if (!ses.touch())
+ continue; // Need to wait while timeout thread complete removing of timed out sessions.
+
+ return ses;
+ }
+
+ if (!F.isEmpty(sesTok) && clientId != null) {
+ UUID sesId = clientId2SesId.get(clientId);
+
+ if (sesId == null || !sesId.equals(U.bytesToUuid(sesTok, 0)))
+ throw new IgniteCheckedException("Failed to handle request - unsupported case (misamatched " +
+ "clientId and session token) [clientId=" + clientId + ", sesTok=" +
+ U.byteArray2HexString(sesTok) + "]");
+
+ Session ses = sesId2Ses.get(sesId);
+
+ if (ses == null)
+ throw new IgniteCheckedException("Failed to handle request - unknown session token " +
+ "(maybe expired session) [sesTok=" + U.byteArray2HexString(sesTok) + "]");
+
+ if (!ses.touch())
+ continue; // Need to wait while timeout thread complete removing of timed out sessions.
+
+ return ses;
+ }
+
+ assert false : "Got an unreachable state.";
+ }
+ }
+
+ /**
* @param ctx Context.
*/
public GridRestProcessor(GridKernalContext ctx) {
super(ctx);
+
+ long sesExpTime0;
+ String sesExpTime = null;
+
+ try {
+ sesExpTime = System.getProperty(IgniteSystemProperties.IGNITE_REST_SESSION_TIMEOUT);
+
+ if (sesExpTime != null)
+ sesExpTime0 = Long.valueOf(sesExpTime) * 1000;
+ else
+ sesExpTime0 = DEFAULT_SES_TIMEOUT;
+ }
+ catch (NumberFormatException ignore) {
+ U.warn(log, "Failed parsing IGNITE_REST_SESSION_TIMEOUT system variable [IGNITE_REST_SESSION_TIMEOUT="
+ + sesExpTime + "]");
+
+ sesExpTime0 = DEFAULT_SES_TIMEOUT;
+ }
+
+ sesTtl = sesExpTime0;
+
+ sesTimeoutCheckerThread = new IgniteThread(ctx.gridName(), "session-timeout-worker",
+ new GridWorker(ctx.gridName(), "session-timeout-worker", log) {
+ @Override protected void body() throws InterruptedException {
+ while (!isCancelled()) {
+ Thread.sleep(SES_TIMEOUT_CHECK_DELAY);
+
+ for (Map.Entry<UUID, Session> e : sesId2Ses.entrySet()) {
+ Session ses = e.getValue();
+
+ if (ses.isTimedOut(sesTtl)) {
+ sesId2Ses.remove(ses.sesId, ses);
+
+ clientId2SesId.remove(ses.clientId, ses.sesId);
+ }
+ }
+ }
+ }
+ });
}
/** {@inheritDoc} */
@@ -310,6 +473,10 @@ public class GridRestProcessor extends GridProcessorAdapter {
for (GridRestProtocol proto : protos)
proto.onKernalStart();
+ sesTimeoutCheckerThread.setDaemon(true);
+
+ sesTimeoutCheckerThread.start();
+
startLatch.countDown();
if (log.isDebugEnabled())
@@ -334,6 +501,8 @@ public class GridRestProcessor extends GridProcessorAdapter {
}
}
+ U.interrupt(sesTimeoutCheckerThread);
+
if (interrupted)
Thread.currentThread().interrupt();
@@ -483,13 +652,8 @@ public class GridRestProcessor extends GridProcessorAdapter {
* @throws IgniteCheckedException If authentication failed.
*/
private SecurityContext authenticate(GridRestRequest req) throws IgniteCheckedException {
- UUID clientId = req.clientId();
- SecurityContext secCtx = clientId == null ? null : sesMap.get(clientId);
+ assert req.clientId() != null;
- if (secCtx != null)
- return secCtx;
-
- // Authenticate client if invalid session.
AuthenticationContext authCtx = new AuthenticationContext();
authCtx.subjectType(REMOTE_CLIENT);
@@ -531,18 +695,6 @@ public class GridRestProcessor extends GridProcessorAdapter {
}
/**
- * Update session.
- * @param req REST request.
- * @param sCtx Security context.
- */
- private void updateSession(GridRestRequest req, SecurityContext sCtx) {
- if (sCtx != null) {
- UUID id = req.clientId();
- sesMap.put(id, sCtx);
- }
- }
-
- /**
* @param req REST request.
* @param sCtx Security context.
* @throws SecurityException If authorization failed.
@@ -719,4 +871,134 @@ public class GridRestProcessor extends GridProcessorAdapter {
X.println(">>> protosSize: " + protos.size());
X.println(">>> handlersSize: " + handlers.size());
}
-}
\ No newline at end of file
+
+ /**
+ * Session.
+ */
+ private static class Session {
+ /** Expiration flag. It's a final state of lastToucnTime. */
+ private static final Long TIMEDOUT_FLAG = 0L;
+
+ /** Client id. */
+ private final UUID clientId;
+
+ /** Session token id. */
+ private final UUID sesId;
+
+ /** Security context. */
+ private volatile SecurityContext secCtx;
+
+ /**
+ * Time when session is used last time.
+ * If this time was set at TIMEDOUT_FLAG, then it should never be changed.
+ */
+ private final AtomicLong lastTouchTime = new AtomicLong(U.currentTimeMillis());
+
+ /**
+ * @param clientId Client ID.
+ * @param sesId session ID.
+ */
+ private Session(UUID clientId, UUID sesId) {
+ this.clientId = clientId;
+ this.sesId = sesId;
+ }
+
+ /**
+ * Static constructor.
+ *
+ * @return New session instance with random client ID and random session ID.
+ */
+ static Session random() {
+ return new Session(UUID.randomUUID(), UUID.randomUUID());
+ }
+
+ /**
+ * Static constructor.
+ *
+ * @param clientId Client ID.
+ * @return New session instance with given client ID and random session ID.
+ */
+ static Session fromClientId(UUID clientId) {
+ return new Session(clientId, UUID.randomUUID());
+ }
+
+ /**
+ * Static constructor.
+ *
+ * @param sesTokId Session token ID.
+ * @return New session instance with random client ID and given session ID.
+ */
+ static Session fromSessionToken(UUID sesTokId) {
+ return new Session(UUID.randomUUID(), sesTokId);
+ }
+
+ /**
+ * Checks expiration of session and if expired then sets TIMEDOUT_FLAG.
+ *
+ * @param sesTimeout Session timeout.
+ * @return <code>True</code> if expired.
+ * @see #touch()
+ */
+ boolean isTimedOut(long sesTimeout) {
+ long time0 = lastTouchTime.get();
+
+ if (time0 == TIMEDOUT_FLAG)
+ return true;
+
+ return U.currentTimeMillis() - time0 > sesTimeout && lastTouchTime.compareAndSet(time0, TIMEDOUT_FLAG);
+ }
+
+ /**
+ * Checks whether session at expired state (EPIRATION_FLAG) or not, if not then tries to update last touch time.
+ *
+ * @return {@code False} if session timed out (not successfully touched).
+ * @see #isTimedOut(long)
+ */
+ boolean touch() {
+ while (true) {
+ long time0 = lastTouchTime.get();
+
+ if (time0 == TIMEDOUT_FLAG)
+ return false;
+
+ boolean success = lastTouchTime.compareAndSet(time0, U.currentTimeMillis());
+
+ if (success)
+ return true;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (!(o instanceof Session))
+ return false;
+
+ Session ses = (Session)o;
+
+ if (clientId != null ? !clientId.equals(ses.clientId) : ses.clientId != null)
+ return false;
+
+ if (sesId != null ? !sesId.equals(ses.sesId) : ses.sesId != null)
+ return false;
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = clientId != null ? clientId.hashCode() : 0;
+
+ res = 31 * res + (sesId != null ? sesId.hashCode() : 0);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(Session.class, this);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f025714e/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
index b3af2f2..9d32c17 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
@@ -1391,4 +1391,4 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
return c.sizeAsync(new CachePeekMode[]{CachePeekMode.PRIMARY});
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f025714e/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index e5090cb..3c1913a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -9302,4 +9302,4 @@ public abstract class IgniteUtils {
throw new IgniteInterruptedCheckedException(e);
}
}
-}
\ No newline at end of file
+}
[23/34] ignite git commit: ignite-1526: full support of IBM JDK by
Ignite
Posted by sb...@apache.org.
ignite-1526: full support of IBM JDK by Ignite
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5fc682f1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5fc682f1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5fc682f1
Branch: refs/heads/ignite-1607
Commit: 5fc682f11f43f61d14d6b70be5ccf949a9ae05ac
Parents: 4f95be2
Author: Andrey Gura <ag...@gridgain.com>
Authored: Fri Oct 9 13:54:56 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Fri Oct 9 14:22:34 2015 +0300
----------------------------------------------------------------------
.../discovery/GridDiscoveryManager.java | 17 +-
.../internal/portable/PortableContext.java | 7 +
.../portable/api/PortableMarshaller.java | 14 +-
.../ignite/internal/util/GridJavaProcess.java | 12 +-
.../ignite/internal/util/lang/GridFunc.java | 12 +
.../apache/ignite/marshaller/Marshaller.java | 2 +-
.../optimized/OptimizedMarshallerUtils.java | 6 +-
.../cache/GridCacheAbstractFullApiSelfTest.java | 486 ++++---
.../CacheNoValueClassOnServerNodeTest.java | 1 +
...tomicClientOnlyMultiNodeFullApiSelfTest.java | 71 +-
...achePartitionedMultiNodeFullApiSelfTest.java | 129 +-
.../testframework/junits/GridAbstractTest.java | 116 +-
.../junits/IgniteTestResources.java | 8 +-
.../junits/common/GridCommonAbstractTest.java | 15 +-
.../junits/multijvm/AffinityProcessProxy.java | 440 ++++--
.../multijvm/IgniteCacheProcessProxy.java | 1348 ++++++++++++++----
.../multijvm/IgniteClusterProcessProxy.java | 115 +-
.../multijvm/IgniteEventsProcessProxy.java | 50 +-
.../junits/multijvm/IgniteNodeRunner.java | 39 +-
.../junits/multijvm/IgniteProcessProxy.java | 107 +-
.../cache/CacheConfigurationP2PTest.java | 3 +
21 files changed, 2186 insertions(+), 812 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 1801b9c..cba06de 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -987,19 +987,24 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
boolean locP2pEnabled = locNode.attribute(ATTR_PEER_CLASSLOADING);
- boolean warned = false;
+ boolean ipV4Warned = false;
+
+ boolean jvmMajVerWarned = false;
for (ClusterNode n : nodes) {
int rmtJvmMajVer = nodeJavaMajorVersion(n);
- if (locJvmMajVer != rmtJvmMajVer)
- throw new IgniteCheckedException("Local node's java major version is different from remote node's one" +
- " [locJvmMajVer=" + locJvmMajVer + ", rmtJvmMajVer=" + rmtJvmMajVer + "]");
+ if (locJvmMajVer != rmtJvmMajVer && !jvmMajVerWarned) {
+ U.warn(log, "Local java version is different from remote [loc=" +
+ locJvmMajVer + ", rmt=" + rmtJvmMajVer + "]");
+
+ jvmMajVerWarned = true;
+ }
String rmtPreferIpV4 = n.attribute("java.net.preferIPv4Stack");
if (!F.eq(rmtPreferIpV4, locPreferIpV4)) {
- if (!warned)
+ if (!ipV4Warned)
U.warn(log, "Local node's value of 'java.net.preferIPv4Stack' " +
"system property differs from remote node's " +
"(all nodes in topology should have identical value) " +
@@ -1008,7 +1013,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
", rmtAddrs=" + U.addressesAsString(n) + ']',
"Local and remote 'java.net.preferIPv4Stack' system properties do not match.");
- warned = true;
+ ipV4Warned = true;
}
// Daemon nodes are allowed to have any deployment they need.
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index 2ee96b7..1ad42ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -967,6 +967,9 @@ public class PortableContext implements Externalizable {
}
}
+ /**
+ * Basic class ID mapper.
+ */
private static class BasicClassIdMapper implements PortableIdMapper {
/** {@inheritDoc} */
@Override public int typeId(String clsName) {
@@ -1121,6 +1124,10 @@ public class PortableContext implements Externalizable {
/** Whether the following type is registered in a cache or not */
private final boolean registered;
+ /**
+ * @param id Id.
+ * @param registered Registered.
+ */
public Type(int id, boolean registered) {
this.id = id;
this.registered = registered;
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java
index de0df8d..3dfbdf0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java
@@ -29,12 +29,6 @@ import org.apache.ignite.internal.portable.GridPortableMarshaller;
import org.apache.ignite.internal.portable.PortableContext;
import org.apache.ignite.marshaller.AbstractMarshaller;
import org.apache.ignite.marshaller.MarshallerContext;
-import org.apache.ignite.internal.portable.api.PortableException;
-import org.apache.ignite.internal.portable.api.PortableIdMapper;
-import org.apache.ignite.internal.portable.api.PortableObject;
-import org.apache.ignite.internal.portable.api.PortableProtocolVersion;
-import org.apache.ignite.internal.portable.api.PortableSerializer;
-import org.apache.ignite.internal.portable.api.PortableTypeConfiguration;
import org.jetbrains.annotations.Nullable;
/**
@@ -336,7 +330,7 @@ public class PortableMarshaller extends AbstractMarshaller {
/** {@inheritDoc} */
@Override public <T> T unmarshal(InputStream in, @Nullable ClassLoader clsLdr) throws IgniteCheckedException {
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ ByteArrayOutputStream buf = new ByteArrayOutputStream();
byte[] arr = new byte[4096];
int cnt;
@@ -345,11 +339,11 @@ public class PortableMarshaller extends AbstractMarshaller {
// returns number of bytes remaining.
try {
while ((cnt = in.read(arr)) != -1)
- buffer.write(arr, 0, cnt);
+ buf.write(arr, 0, cnt);
- buffer.flush();
+ buf.flush();
- return impl.deserialize(buffer.toByteArray(), clsLdr);
+ return impl.deserialize(buf.toByteArray(), clsLdr);
}
catch (IOException e) {
throw new PortableException("Failed to unmarshal the object from InputStream", e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
index 92c20fe..3371eb8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
@@ -89,7 +89,7 @@ public final class GridJavaProcess {
*/
public static GridJavaProcess exec(Class cls, String params, @Nullable IgniteLogger log,
@Nullable IgniteInClosure<String> printC, @Nullable GridAbsClosure procKilledC) throws Exception {
- return exec(cls.getCanonicalName(), params, log, printC, procKilledC, null, null);
+ return exec(cls.getCanonicalName(), params, log, printC, procKilledC, null, null, null);
}
/**
@@ -108,7 +108,7 @@ public final class GridJavaProcess {
public static GridJavaProcess exec(Class cls, String params, @Nullable IgniteLogger log,
@Nullable IgniteInClosure<String> printC, @Nullable GridAbsClosure procKilledC,
@Nullable Collection<String> jvmArgs, @Nullable String cp) throws Exception {
- return exec(cls.getCanonicalName(), params, log, printC, procKilledC, jvmArgs, cp);
+ return exec(cls.getCanonicalName(), params, log, printC, procKilledC, null, jvmArgs, cp);
}
/**
@@ -116,9 +116,10 @@ public final class GridJavaProcess {
*
* @param clsName Class with main() method to be run.
* @param params main() method parameters.
+ * @param log Log to use.
* @param printC Optional closure to be called each time wrapped process prints line to system.out or system.err.
* @param procKilledC Optional closure to be called when process termination is detected.
- * @param log Log to use.
+ * @param javaHome Java home location. The process will be started under given JVM.
* @param jvmArgs JVM arguments to use.
* @param cp Additional classpath.
* @return Wrapper around {@link Process}
@@ -126,7 +127,7 @@ public final class GridJavaProcess {
*/
public static GridJavaProcess exec(String clsName, String params, @Nullable IgniteLogger log,
@Nullable IgniteInClosure<String> printC, @Nullable GridAbsClosure procKilledC,
- @Nullable Collection<String> jvmArgs, @Nullable String cp) throws Exception {
+ @Nullable String javaHome, @Nullable Collection<String> jvmArgs, @Nullable String cp) throws Exception {
if (!(U.isLinux() || U.isMacOs() || U.isWindows()))
throw new Exception("Your OS is not supported.");
@@ -140,7 +141,8 @@ public final class GridJavaProcess {
List<String> procCommands = new ArrayList<>();
- String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
+ String javaBin = (javaHome == null ? System.getProperty("java.home") : javaHome) +
+ File.separator + "bin" + File.separator + "java";
procCommands.add(javaBin);
procCommands.addAll(jvmArgs == null ? U.jvmArgs() : jvmArgs);
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index ffeeca0..43bc5f3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -103,6 +103,9 @@ public class GridFunc {
/** */
private static final IgniteClosure IDENTITY = new C1() {
+ /** */
+ private static final long serialVersionUID = -6338573080046225172L;
+
@Override public Object apply(Object o) {
return o;
}
@@ -1196,6 +1199,9 @@ public class GridFunc {
A.notNull(nodeId, "nodeId");
return new P1<T>() {
+ /** */
+ private static final long serialVersionUID = -7082730222779476623L;
+
@Override public boolean apply(ClusterNode e) {
return e.id().equals(nodeId);
}
@@ -1705,6 +1711,9 @@ public class GridFunc {
assert c != null;
return new GridSerializableList<T2>() {
+ /** */
+ private static final long serialVersionUID = 3126625219739967068L;
+
@Override public T2 get(int idx) {
return trans.apply(c.get(idx));
}
@@ -1766,6 +1775,9 @@ public class GridFunc {
assert m != null;
return isEmpty(p) || isAlwaysTrue(p) ? m : new GridSerializableMap<K, V>() {
+ /** */
+ private static final long serialVersionUID = 5531745605372387948L;
+
/** Entry predicate. */
private IgnitePredicate<Entry<K, V>> ep = new P1<Map.Entry<K, V>>() {
@Override public boolean apply(Entry<K, V> e) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java
index 3e815fd..a76daa8 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java
@@ -92,7 +92,7 @@ public interface Marshaller {
public byte[] marshal(@Nullable Object obj) throws IgniteCheckedException;
/**
- * Unmarshals object from the output stream using given class loader.
+ * Unmarshals object from the input stream using given class loader.
* This method should not close given input stream.
*
* @param <T> Type of unmarshalled object.
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
index 4abbd04..584083c 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
@@ -42,6 +42,10 @@ class OptimizedMarshallerUtils {
/** */
private static final Unsafe UNSAFE = GridUnsafe.unsafe();
+ /** Use default {@code serialVersionUid} for {@link Serializable} classes. */
+ private static final boolean USE_DFLT_SUID =
+ Boolean.valueOf(System.getProperty("ignite.marsh.optimized.useDefaultSUID", Boolean.TRUE.toString()));
+
/** */
static final long HASH_SET_MAP_OFF;
@@ -283,7 +287,7 @@ class OptimizedMarshallerUtils {
*/
@SuppressWarnings("ForLoopReplaceableByForEach")
static short computeSerialVersionUid(Class cls, List<Field> fields) throws IOException {
- if (Serializable.class.isAssignableFrom(cls) && !Enum.class.isAssignableFrom(cls))
+ if (USE_DFLT_SUID && Serializable.class.isAssignableFrom(cls) && !Enum.class.isAssignableFrom(cls))
return (short)ObjectStreamClass.lookup(cls).getSerialVersionUID();
MessageDigest md;
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 2a64963..ec3ea0c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -49,6 +50,7 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteTransactions;
import org.apache.ignite.cache.CacheEntryProcessor;
import org.apache.ignite.cache.CacheMemoryMode;
@@ -75,6 +77,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.LoggerResource;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
import org.apache.ignite.testframework.GridTestUtils;
@@ -117,48 +120,37 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/** */
public static final CacheEntryProcessor<String, Integer, String> ERR_PROCESSOR =
new CacheEntryProcessor<String, Integer, String>() {
+ /** */
+ private static final long serialVersionUID = 0L;
+
@Override public String process(MutableEntry<String, Integer> e, Object... args) {
throw new RuntimeException("Failed!");
}
};
/** Increment processor for invoke operations. */
- public static final EntryProcessor<String, Integer, String> INCR_PROCESSOR = new EntryProcessor<String, Integer, String>() {
- @Override public String process(MutableEntry<String, Integer> e, Object... args) {
- assertNotNull(e.getKey());
-
- Integer old = e.getValue();
-
- e.setValue(old == null ? 1 : old + 1);
-
- return String.valueOf(old);
- }
- };
+ public static final EntryProcessor<String, Integer, String> INCR_PROCESSOR = new IncrementEntryProcessor();
/** Increment processor for invoke operations with IgniteEntryProcessor. */
public static final CacheEntryProcessor<String, Integer, String> INCR_IGNITE_PROCESSOR =
new CacheEntryProcessor<String, Integer, String>() {
+ /** */
+ private static final long serialVersionUID = 0L;
+
@Override public String process(MutableEntry<String, Integer> e, Object... args) {
return INCR_PROCESSOR.process(e, args);
}
};
/** Increment processor for invoke operations. */
- public static final EntryProcessor<String, Integer, String> RMV_PROCESSOR = new EntryProcessor<String, Integer, String>() {
- @Override public String process(MutableEntry<String, Integer> e, Object... args) {
- assertNotNull(e.getKey());
-
- Integer old = e.getValue();
-
- e.remove();
-
- return String.valueOf(old);
- }
- };
+ public static final EntryProcessor<String, Integer, String> RMV_PROCESSOR = new RemoveEntryProcessor();
/** Increment processor for invoke operations with IgniteEntryProcessor. */
public static final CacheEntryProcessor<String, Integer, String> RMV_IGNITE_PROCESSOR =
new CacheEntryProcessor<String, Integer, String>() {
+ /** */
+ private static final long serialVersionUID = 0L;
+
@Override public String process(MutableEntry<String, Integer> e, Object... args) {
return RMV_PROCESSOR.process(e, args);
}
@@ -346,21 +338,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assert jcache(i).localSize() != 0 || F.isEmpty(keysCol);
}
- for (int i = 0; i < gridCount(); i++) {
- executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
- @Override public void run(int idx) throws Exception {
- GridCacheContext<String, Integer> ctx = context(idx);
-
- int sum = 0;
-
- for (String key : map.keySet())
- if (ctx.affinity().localNode(key, new AffinityTopologyVersion(ctx.discovery().topologyVersion())))
- sum++;
-
- assertEquals("Incorrect key size on cache #" + idx, sum, jcache(idx).localSize(ALL));
- }
- });
- }
+ for (int i = 0; i < gridCount(); i++)
+ executeOnLocalOrRemoteJvm(i, new CheckCacheSizeTask(map));
for (int i = 0; i < gridCount(); i++) {
Collection<String> keysCol = mapped.get(grid(i).localNode());
@@ -1350,13 +1329,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertEquals((Integer)3, cache.get("k1"));
- EntryProcessor<String, Integer, Integer> c = new EntryProcessor<String, Integer, Integer>() {
- @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
- e.remove();
-
- return null;
- }
- };
+ EntryProcessor<String, Integer, Integer> c = new RemoveAndReturnNullEntryProcessor();
assertNull(cache.invoke("k1", c));
assertNull(cache.get("k1"));
@@ -1364,11 +1337,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (int i = 0; i < gridCount(); i++)
assertNull(jcache(i).localPeek("k1", ONHEAP));
- final EntryProcessor<String, Integer, Integer> errProcessor = new EntryProcessor<String, Integer, Integer>() {
- @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
- throw new EntryProcessorException("Test entry processor exception.");
- }
- };
+ final EntryProcessor<String, Integer, Integer> errProcessor = new FailedEntryProcessor();
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override public Void call() throws Exception {
@@ -2001,7 +1970,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertFalse(cacheAsync.<Boolean>future().get());
}
- cache.localEvict(Arrays.asList("key2"));
+ cache.localEvict(Collections.singletonList("key2"));
// Same checks inside tx.
Transaction tx = inTx ? transactions().txStart() : null;
@@ -2357,27 +2326,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (int i = 0; i < cnt; i++)
cache.remove(String.valueOf(i));
- for (int g = 0; g < gridCount(); g++) {
- executeOnLocalOrRemoteJvm(g, new TestIgniteIdxRunnable() {
- @Override public void run(int idx) throws Exception {
- for (int i = 0; i < cnt; i++) {
- String key = String.valueOf(i);
-
- GridCacheContext<String, Integer> cctx = context(idx);
-
- GridCacheEntryEx entry = cctx.isNear() ? cctx.near().dht().peekEx(key) :
- cctx.cache().peekEx(key);
-
- if (grid(idx).affinity(null).mapKeyToPrimaryAndBackups(key).contains(grid(idx).localNode())) {
- assertNotNull(entry);
- assertTrue(entry.deleted());
- }
- else
- assertNull(entry);
- }
- }
- });
- }
+ for (int g = 0; g < gridCount(); g++)
+ executeOnLocalOrRemoteJvm(g, new CheckEntriesDeletedTask(cnt));
}
}
@@ -2587,8 +2537,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
c.add(null);
GridTestUtils.assertThrows(log, new Callable<Void>() {
- @Override
- public Void call() throws Exception {
+ @Override public Void call() throws Exception {
cache.removeAll(c);
return null;
@@ -2725,7 +2674,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
public void testRemoveAfterClear() throws Exception {
IgniteEx ignite = grid(0);
- boolean affNode = ((IgniteKernal)ignite).context().cache().internalCache(null).context().affinityNode();
+ boolean affNode = ignite.context().cache().internalCache(null).context().affinityNode();
if (!affNode) {
if (gridCount() < 2)
@@ -2766,13 +2715,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
/**
- *
- */
- private void xxx() {
- System.out.printf("");
- }
-
- /**
* @throws Exception In case of error.
*/
public void testClear() throws Exception {
@@ -3597,26 +3539,9 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
info("Local keys (primary + backup): " + locKeys);
}
- for (int i = 0; i < gridCount(); i++) {
- grid(i).events().localListen(new IgnitePredicate<Event>() {
- @Override public boolean apply(Event evt) {
- info("Received event: " + evt);
-
- switch (evt.type()) {
- case EVT_CACHE_OBJECT_SWAPPED:
- swapEvts.incrementAndGet();
-
- break;
- case EVT_CACHE_OBJECT_UNSWAPPED:
- unswapEvts.incrementAndGet();
-
- break;
- }
-
- return true;
- }
- }, EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
- }
+ for (int i = 0; i < gridCount(); i++)
+ grid(i).events().localListen(
+ new SwapEvtsLocalListener(swapEvts, unswapEvts), EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
cache.localEvict(F.asList(k2, k3));
@@ -3934,7 +3859,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
map.put(entry.getKey(), entry.getValue());
}
- assert map != null;
assert map.size() == 2;
assert map.get("key1") == 1;
assert map.get("key2") == 2;
@@ -3951,32 +3875,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
if (nearEnabled())
assertEquals(keys.size(), jcache().localSize(CachePeekMode.ALL));
else {
- for (int i = 0; i < gridCount(); i++) {
- executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
- @Override public void run(int idx) throws Exception {
- GridCacheContext<String, Integer> ctx = context(idx);
-
- if (ctx.cache().configuration().getMemoryMode() == OFFHEAP_TIERED)
- return;
-
- int size = 0;
-
- for (String key : keys) {
- if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx())) {
- GridCacheEntryEx e =
- ctx.isNear() ? ctx.near().dht().peekEx(key) : ctx.cache().peekEx(key);
-
- assert e != null : "Entry is null [idx=" + idx + ", key=" + key + ", ctx=" + ctx + ']';
- assert !e.deleted() : "Entry is deleted: " + e;
-
- size++;
- }
- }
-
- assertEquals("Incorrect size on cache #" + idx, size, jcache(idx).localSize(ALL));
- }
- });
- }
+ for (int i = 0; i < gridCount(); i++)
+ executeOnLocalOrRemoteJvm(i, new CheckEntriesTask(keys));
}
}
@@ -3989,21 +3889,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertEquals("Invalid key size: " + jcache().localSize(ALL),
keys.size(), jcache().localSize(ALL));
else {
- for (int i = 0; i < gridCount(); i++) {
- executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
- @Override public void run(int idx) throws Exception {
- GridCacheContext<String, Integer> ctx = context(idx);
-
- int size = 0;
-
- for (String key : keys)
- if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx()))
- size++;
-
- assertEquals("Incorrect key size on cache #" + idx, size, jcache(idx).localSize(ALL));
- }
- });
- }
+ for (int i = 0; i < gridCount(); i++)
+ executeOnLocalOrRemoteJvm(i, new CheckKeySizeTask(keys));
}
}
@@ -4061,27 +3948,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* @param cnt Keys count.
* @return Collection of keys for which given cache is primary.
*/
- protected List<String> primaryKeysForCache(final IgniteCache<String, Integer> cache, final int cnt, final int startFrom) {
- return executeOnLocalOrRemoteJvm(cache, new TestCacheCallable<String, Integer, List<String>>() {
- @Override public List<String> call(Ignite ignite, IgniteCache<String, Integer> cache) throws Exception {
- List<String> found = new ArrayList<>();
-
- Affinity<Object> affinity = ignite.affinity(cache.getName());
-
- for (int i = startFrom; i < startFrom + 100_000; i++) {
- String key = "key" + i;
-
- if (affinity.isPrimary(ignite.cluster().localNode(), key)) {
- found.add(key);
-
- if (found.size() == cnt)
- return found;
- }
- }
-
- throw new IgniteException("Unable to find " + cnt + " keys as primary for cache.");
- }
- });
+ protected List<String> primaryKeysForCache(IgniteCache<String, Integer> cache, int cnt, int startFrom) {
+ return executeOnLocalOrRemoteJvm(cache, new CheckPrimaryKeysTask(startFrom, cnt));
}
/**
@@ -4272,18 +4140,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* Checks iterators are cleared.
*/
private void checkIteratorsCleared() {
- for (int j = 0; j < gridCount(); j++) {
- executeOnLocalOrRemoteJvm(j, new TestIgniteIdxRunnable() {
- @Override public void run(int idx) throws Exception {
- GridCacheQueryManager queries = context(idx).queries();
-
- Map map = GridTestUtils.getFieldValue(queries, GridCacheQueryManager.class, "qryIters");
-
- for (Object obj : map.values())
- assertEquals("Iterators not removed for grid " + idx, 0, ((Map)obj).size());
- }
- });
- }
+ for (int j = 0; j < gridCount(); j++)
+ executeOnLocalOrRemoteJvm(j, new CheckIteratorTask());
}
/**
@@ -5226,4 +5084,280 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/** */
ONE_BY_ONE
}
+
+ /**
+ *
+ */
+ private static class RemoveEntryProcessor implements EntryProcessor<String, Integer, String>, Serializable {
+ /** {@inheritDoc} */
+ @Override public String process(MutableEntry<String, Integer> e, Object... args) {
+ assertNotNull(e.getKey());
+
+ Integer old = e.getValue();
+
+ e.remove();
+
+ return String.valueOf(old);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IncrementEntryProcessor implements EntryProcessor<String, Integer, String>, Serializable {
+ /** {@inheritDoc} */
+ @Override public String process(MutableEntry<String, Integer> e, Object... args) {
+ assertNotNull(e.getKey());
+
+ Integer old = e.getValue();
+
+ e.setValue(old == null ? 1 : old + 1);
+
+ return String.valueOf(old);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CheckEntriesTask extends TestIgniteIdxRunnable {
+ /** Keys. */
+ private final Collection<String> keys;
+
+ /**
+ * @param keys Keys.
+ */
+ public CheckEntriesTask(Collection<String> keys) {
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run(int idx) throws Exception {
+ GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+
+ if (ctx.cache().configuration().getMemoryMode() == OFFHEAP_TIERED)
+ return;
+
+ int size = 0;
+
+ for (String key : keys) {
+ if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx())) {
+ GridCacheEntryEx e =
+ ctx.isNear() ? ctx.near().dht().peekEx(key) : ctx.cache().peekEx(key);
+
+ assert e != null : "Entry is null [idx=" + idx + ", key=" + key + ", ctx=" + ctx + ']';
+ assert !e.deleted() : "Entry is deleted: " + e;
+
+ size++;
+ }
+ }
+
+ assertEquals("Incorrect size on cache #" + idx, size, ignite.cache(ctx.name()).localSize(ALL));
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CheckCacheSizeTask extends TestIgniteIdxRunnable {
+ private final Map<String, Integer> map;
+
+ /**
+ * @param map Map.
+ */
+ public CheckCacheSizeTask(Map<String, Integer> map) {
+ this.map = map;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run(int idx) throws Exception {
+ GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+
+ int size = 0;
+
+ for (String key : map.keySet())
+ if (ctx.affinity().localNode(key, new AffinityTopologyVersion(ctx.discovery().topologyVersion())))
+ size++;
+
+ assertEquals("Incorrect key size on cache #" + idx, size, ignite.cache(ctx.name()).localSize(ALL));
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CheckPrimaryKeysTask implements TestCacheCallable<String, Integer, List<String>> {
+ /** Start from. */
+ private final int startFrom;
+
+ /** Count. */
+ private final int cnt;
+
+ /**
+ * @param startFrom Start from.
+ * @param cnt Count.
+ */
+ public CheckPrimaryKeysTask(int startFrom, int cnt) {
+ this.startFrom = startFrom;
+ this.cnt = cnt;
+ }
+
+ /** {@inheritDoc} */
+ @Override public List<String> call(Ignite ignite, IgniteCache<String, Integer> cache) throws Exception {
+ List<String> found = new ArrayList<>();
+
+ Affinity<Object> affinity = ignite.affinity(cache.getName());
+
+ for (int i = startFrom; i < startFrom + 100_000; i++) {
+ String key = "key" + i;
+
+ if (affinity.isPrimary(ignite.cluster().localNode(), key)) {
+ found.add(key);
+
+ if (found.size() == cnt)
+ return found;
+ }
+ }
+
+ throw new IgniteException("Unable to find " + cnt + " keys as primary for cache.");
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CheckIteratorTask extends TestIgniteIdxCallable<Void> {
+ /**
+ * @param idx Index.
+ */
+ @Override public Void call(int idx) throws Exception {
+ GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+ GridCacheQueryManager queries = ctx.queries();
+
+ Map map = GridTestUtils.getFieldValue(queries, GridCacheQueryManager.class, "qryIters");
+
+ for (Object obj : map.values())
+ assertEquals("Iterators not removed for grid " + idx, 0, ((Map)obj).size());
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveAndReturnNullEntryProcessor implements
+ EntryProcessor<String, Integer, Integer>, Serializable {
+
+ /** {@inheritDoc} */
+ @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
+ e.remove();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class SwapEvtsLocalListener implements IgnitePredicate<Event> {
+ @LoggerResource
+ private IgniteLogger log;
+
+ /** Swap events. */
+ private final AtomicInteger swapEvts;
+
+ /** Unswap events. */
+ private final AtomicInteger unswapEvts;
+
+ /**
+ * @param swapEvts Swap events.
+ * @param unswapEvts Unswap events.
+ */
+ public SwapEvtsLocalListener(AtomicInteger swapEvts, AtomicInteger unswapEvts) {
+ this.swapEvts = swapEvts;
+ this.unswapEvts = unswapEvts;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(Event evt) {
+ log.info("Received event: " + evt);
+
+ switch (evt.type()) {
+ case EVT_CACHE_OBJECT_SWAPPED:
+ swapEvts.incrementAndGet();
+
+ break;
+ case EVT_CACHE_OBJECT_UNSWAPPED:
+ unswapEvts.incrementAndGet();
+
+ break;
+ }
+
+ return true;
+ }
+ }
+
+ private static class CheckEntriesDeletedTask extends TestIgniteIdxRunnable {
+ private final int cnt;
+
+ public CheckEntriesDeletedTask(int cnt) {
+ this.cnt = cnt;
+ }
+
+ @Override public void run(int idx) throws Exception {
+ for (int i = 0; i < cnt; i++) {
+ String key = String.valueOf(i);
+
+ GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+
+ GridCacheEntryEx entry = ctx.isNear() ? ctx.near().dht().peekEx(key) : ctx.cache().peekEx(key);
+
+ if (ignite.affinity(null).mapKeyToPrimaryAndBackups(key).contains(((IgniteKernal)ignite).localNode())) {
+ assertNotNull(entry);
+ assertTrue(entry.deleted());
+ }
+ else
+ assertNull(entry);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CheckKeySizeTask extends TestIgniteIdxRunnable {
+ /** Keys. */
+ private final Collection<String> keys;
+
+ /**
+ * @param keys Keys.
+ */
+ public CheckKeySizeTask(Collection<String> keys) {
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run(int idx) throws Exception {
+ GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+
+ int size = 0;
+
+ for (String key : keys)
+ if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx()))
+ size++;
+
+ assertEquals("Incorrect key size on cache #" + idx, size, ignite.cache(null).localSize(ALL));
+ }
+ }
+
+ /**
+ *
+ */
+ private static class FailedEntryProcessor implements EntryProcessor<String, Integer, Integer>, Serializable {
+ /** {@inheritDoc} */
+ @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
+ throw new EntryProcessorException("Test entry processor exception.");
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
index da694b5..c6ce81e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
@@ -111,6 +111,7 @@ public class CacheNoValueClassOnServerNodeTest extends GridCommonAbstractTest {
}
},
null,
+ null,
jvmArgs,
cp
);
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
index 1511c45..927ee62 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
@@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -29,6 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import javax.cache.expiry.Duration;
import javax.cache.expiry.TouchedExpiryPolicy;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -37,6 +39,7 @@ import org.apache.ignite.events.Event;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.LoggerResource;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
@@ -106,9 +109,11 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
affinityNodes(); // Just to ack cache configuration to log..
- checkKeySize(map.keySet());
+ Set<String> keys = new LinkedHashSet<>(map.keySet());
- checkSize(map.keySet());
+ checkKeySize(keys);
+
+ checkSize(keys);
int fullCacheSize = 0;
@@ -317,24 +322,8 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
Collection<String> locKeys = new HashSet<>();
for (int i = 0; i < gridCount(); i++) {
- grid(i).events().localListen(new IgnitePredicate<Event>() {
- @Override public boolean apply(Event evt) {
- info("Received event: " + evt);
-
- switch (evt.type()) {
- case EVT_CACHE_OBJECT_SWAPPED:
- swapEvts.incrementAndGet();
-
- break;
- case EVT_CACHE_OBJECT_UNSWAPPED:
- unswapEvts.incrementAndGet();
-
- break;
- }
-
- return true;
- }
- }, EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
+ grid(i).events().localListen(
+ new LocalListener(swapEvts, unswapEvts), EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
}
cache.localEvict(Collections.singleton(k2));
@@ -416,4 +405,46 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
assertEquals(cnt, swapEvts.get());
assertEquals(cnt, unswapEvts.get());
}
+
+ /**
+ *
+ */
+ private static class LocalListener implements IgnitePredicate<Event> {
+ /** Logger. */
+ @LoggerResource
+ private IgniteLogger log;
+
+ /** Swap events. */
+ private final AtomicInteger swapEvts;
+
+ /** Unswap events. */
+ private final AtomicInteger unswapEvts;
+
+ /**
+ * @param swapEvts Swap events.
+ * @param unswapEvts Unswap events.
+ */
+ public LocalListener(AtomicInteger swapEvts, AtomicInteger unswapEvts) {
+ this.swapEvts = swapEvts;
+ this.unswapEvts = unswapEvts;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(Event evt) {
+ log.info("Received event: " + evt);
+
+ switch (evt.type()) {
+ case EVT_CACHE_OBJECT_SWAPPED:
+ swapEvts.incrementAndGet();
+
+ break;
+ case EVT_CACHE_OBJECT_UNSWAPPED:
+ unswapEvts.incrementAndGet();
+
+ break;
+ }
+
+ return true;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
index c04bf2e..a2440e2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
@@ -20,11 +20,14 @@ package org.apache.ignite.internal.processors.cache.distributed.near;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteAtomicLong;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.CacheMemoryMode;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.cache.affinity.Affinity;
@@ -36,6 +39,8 @@ import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.resources.LoggerResource;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -93,7 +98,7 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
atomicClockModeDelay(c0);
- c1.removeAll(putMap.keySet());
+ c1.removeAll(new HashSet<>(putMap.keySet()));
for (int i = 0; i < size; i++) {
assertNull(c0.get(i));
@@ -159,22 +164,8 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
info("Finished putting value [i=" + i + ']');
}
- for (int i = 0; i < gridCount(); i++) {
- executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
- @Override public void run(int idx) throws Exception {
- assertEquals(0, context(idx).tm().idMapSize());
-
- IgniteCache<Object, Object> cache = grid(idx).cache(null);
- ClusterNode node = grid(idx).localNode();
-
- for (int k = 0; k < size; k++) {
- if (affinity(cache).isPrimaryOrBackup(node, k))
- assertEquals("Check failed for node: " + node.id(), k,
- cache.localPeek(k, CachePeekMode.ONHEAP, CachePeekMode.OFFHEAP));
- }
- }
- });
- }
+ for (int i = 0; i < gridCount(); i++)
+ executeOnLocalOrRemoteJvm(i, new CheckAffinityTask(size));
for (int i = 0; i < size; i++) {
info("Putting value 2 [i=" + i + ']');
@@ -199,28 +190,9 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
final IgniteAtomicLong unswapEvts = grid(0).atomicLong("unswapEvts", 0, true);
- for (int i = 0; i < gridCount(); i++) {
- final int iCopy = i;
-
- grid(i).events().localListen(new IgnitePredicate<Event>() {
- @Override public boolean apply(Event evt) {
- info("Received event: " + evt);
-
- switch (evt.type()) {
- case EVT_CACHE_OBJECT_SWAPPED:
- grid(iCopy).atomicLong("swapEvts", 0, false).incrementAndGet();
-
- break;
- case EVT_CACHE_OBJECT_UNSWAPPED:
- grid(iCopy).atomicLong("unswapEvts", 0, false).incrementAndGet();
-
- break;
- }
-
- return true;
- }
- }, EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
- }
+ for (int i = 0; i < gridCount(); i++)
+ grid(i).events().localListen(
+ new SwapUnswapLocalListener(), EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
jcache().put("key", 1);
@@ -254,13 +226,8 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
boolean nearEnabled = nearEnabled(c);
- if (nearEnabled) {
- executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
- @Override public void run(int idx) throws Exception {
- assertTrue(((IgniteKernal)ignite(idx)).internalCache().context().isNear());
- }
- });
- }
+ if (nearEnabled)
+ executeOnLocalOrRemoteJvm(i, new IsNearTask());
Integer nearPeekVal = nearEnabled ? 1 : null;
@@ -476,4 +443,74 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
assertFalse(affinity(cache).isPrimaryOrBackup(other, key));
}
}
+
+ /**
+ *
+ */
+ private static class SwapUnswapLocalListener implements IgnitePredicate<Event> {
+ /** Logger. */
+ @LoggerResource
+ private IgniteLogger log;
+
+ /** Ignite. */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(Event evt) {
+ log.info("Received event: " + evt);
+
+ switch (evt.type()) {
+ case EVT_CACHE_OBJECT_SWAPPED:
+ ignite.atomicLong("swapEvts", 0, false).incrementAndGet();
+
+ break;
+ case EVT_CACHE_OBJECT_UNSWAPPED:
+ ignite.atomicLong("unswapEvts", 0, false).incrementAndGet();
+
+ break;
+ }
+
+ return true;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CheckAffinityTask extends TestIgniteIdxRunnable {
+ /** Size. */
+ private final int size;
+
+ /**
+ * @param size Size.
+ */
+ public CheckAffinityTask(int size) {
+ this.size = size;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run(int idx) throws Exception {
+ assertEquals(0, ((IgniteKernal)ignite).<String, Integer>internalCache().context().tm().idMapSize());
+
+ IgniteCache<Object, Object> cache = ignite.cache(null);
+ ClusterNode node = ((IgniteKernal)ignite).localNode();
+
+ for (int k = 0; k < size; k++) {
+ if (affinity(cache).isPrimaryOrBackup(node, k))
+ assertEquals("Check failed for node: " + node.id(), k,
+ cache.localPeek(k, CachePeekMode.ONHEAP, CachePeekMode.OFFHEAP));
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IsNearTask extends TestIgniteIdxRunnable {
+ /** {@inheritDoc} */
+ @Override public void run(int idx) throws Exception {
+ assertTrue(((IgniteKernal)ignite).internalCache().context().isNear());
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index f54fe06..d133a84 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -73,6 +73,7 @@ import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.marshaller.MarshallerExclusions;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
+import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.spi.checkpoint.sharedfs.SharedFsCheckpointSpi;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -1471,6 +1472,8 @@ public abstract class GridAbstractTest extends TestCase {
if (!isMultiJvmObject(ignite))
try {
+ job.setIgnite(ignite);
+
return job.call(idx);
}
catch (Exception e) {
@@ -1532,11 +1535,7 @@ public abstract class GridAbstractTest extends TestCase {
IgniteProcessProxy proxy = (IgniteProcessProxy)ignite;
- return proxy.remoteCompute().call(new IgniteCallable<R>() {
- @Override public R call() throws Exception {
- return job.call(idx);
- }
- });
+ return proxy.remoteCompute().call(new ExecuteRemotelyTask<>(job, idx));
}
/**
@@ -1546,15 +1545,7 @@ public abstract class GridAbstractTest extends TestCase {
* @param job Job.
*/
public static <R> R executeRemotely(IgniteProcessProxy proxy, final TestIgniteCallable<R> job) {
- final UUID id = proxy.getId();
-
- return proxy.remoteCompute().call(new IgniteCallable<R>() {
- @Override public R call() throws Exception {
- Ignite ignite = Ignition.ignite(id);
-
- return job.call(ignite);
- }
- });
+ return proxy.remoteCompute().call(new TestRemoteTask<>(proxy.getId(), job));
}
/**
@@ -1571,6 +1562,8 @@ public abstract class GridAbstractTest extends TestCase {
final String cacheName = cache.getName();
return proxy.remoteCompute().call(new IgniteCallable<R>() {
+ private static final long serialVersionUID = -3868429485920845137L;
+
@Override public R call() throws Exception {
Ignite ignite = Ignition.ignite(id);
IgniteCache<K,V> cache = ignite.cache(cacheName);
@@ -1745,6 +1738,22 @@ public abstract class GridAbstractTest extends TestCase {
}
/**
+ * @param name Name.
+ * @param remote Remote.
+ * @param thisRemote This remote.
+ */
+ public static IgniteEx grid(String name, boolean remote, boolean thisRemote) {
+ if (!remote)
+ return (IgniteEx)G.ignite(name);
+ else {
+ if (thisRemote)
+ return IgniteNodeRunner.startedInstance();
+ else
+ return IgniteProcessProxy.ignite(name);
+ }
+ }
+
+ /**
*
*/
private static interface WriteReplaceOwner {
@@ -1781,6 +1790,67 @@ public abstract class GridAbstractTest extends TestCase {
}
/**
+ * Remote computation task.
+ */
+ private static class TestRemoteTask<R> implements IgniteCallable<R> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Node ID. */
+ private final UUID id;
+
+ /** Job. */
+ private final TestIgniteCallable<R> job;
+
+ /**
+ * @param id Id.
+ * @param job Job.
+ */
+ public TestRemoteTask(UUID id, TestIgniteCallable<R> job) {
+ this.id = id;
+ this.job = job;
+ }
+
+ /** {@inheritDoc} */
+ @Override public R call() throws Exception {
+ Ignite ignite = Ignition.ignite(id);
+
+ return job.call(ignite);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ExecuteRemotelyTask<R> implements IgniteCallable<R> {
+ /** Ignite. */
+ @IgniteInstanceResource
+ protected Ignite ignite;
+
+ /** Job. */
+ private final TestIgniteIdxCallable<R> job;
+
+ /** Index. */
+ private final int idx;
+
+ /**
+ * @param job Job.
+ * @param idx Index.
+ */
+ public ExecuteRemotelyTask(TestIgniteIdxCallable<R> job, int idx) {
+ this.job = job;
+ this.idx = idx;
+ }
+
+ /** {@inheritDoc} */
+ @Override public R call() throws Exception {
+ job.setIgnite(ignite);
+
+ return job.call(idx);
+ }
+ }
+
+ /**
* Test counters.
*/
protected class TestCounters {
@@ -1923,17 +1993,27 @@ public abstract class GridAbstractTest extends TestCase {
}
/** */
- public static interface TestIgniteIdxCallable<R> extends Serializable {
+ public static abstract class TestIgniteIdxCallable<R> implements Serializable {
+ @IgniteInstanceResource
+ protected Ignite ignite;
+
+ /**
+ * @param ignite Ignite.
+ */
+ public void setIgnite(Ignite ignite) {
+ this.ignite = ignite;
+ }
+
/**
* @param idx Grid index.
*/
- R call(int idx) throws Exception;
+ protected abstract R call(int idx) throws Exception;
}
/** */
- public abstract static class TestIgniteIdxRunnable implements TestIgniteIdxCallable<Object> {
+ public abstract static class TestIgniteIdxRunnable extends TestIgniteIdxCallable<Void> {
/** {@inheritDoc} */
- @Override public Object call(int idx) throws Exception {
+ @Override public Void call(int idx) throws Exception {
run(idx);
return null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
index eb72252..406318f 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
@@ -42,6 +42,9 @@ import org.jetbrains.annotations.Nullable;
* Test resources for injection.
*/
public class IgniteTestResources {
+ /** Marshaller class name. */
+ public static final String MARSH_CLASS_NAME = "test.marshaller.class";
+
/** */
private static final IgniteLogger rootLog = new GridTestLog4jLogger(false);
@@ -230,8 +233,9 @@ public class IgniteTestResources {
* @throws IgniteCheckedException If failed.
*/
@SuppressWarnings("unchecked")
- public synchronized Marshaller getMarshaller() throws IgniteCheckedException {
- String marshallerName = GridTestProperties.getProperty(GridTestProperties.MARSH_CLASS_NAME);
+ public static synchronized Marshaller getMarshaller() throws IgniteCheckedException {
+ String marshallerName =
+ System.getProperty(MARSH_CLASS_NAME, GridTestProperties.getProperty(GridTestProperties.MARSH_CLASS_NAME));
Marshaller marsh;
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index 4bcf51e..e4c2129 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -246,10 +246,12 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
protected static <K, V> boolean nearEnabled(final IgniteCache<K,V> cache) {
CacheConfiguration cfg = GridAbstractTest.executeOnLocalOrRemoteJvm(cache,
new TestCacheCallable<K, V, CacheConfiguration>() {
- @Override public CacheConfiguration call(Ignite ignite, IgniteCache<K, V> cache) throws Exception {
- return ((IgniteKernal)ignite).<K, V>internalCache(cache.getName()).context().config();
- }
- });
+ private static final long serialVersionUID = 0L;
+
+ @Override public CacheConfiguration call(Ignite ignite, IgniteCache<K, V> cache) throws Exception {
+ return ((IgniteKernal)ignite).<K, V>internalCache(cache.getName()).context().config();
+ }
+ });
return isNearEnabled(cfg);
}
@@ -285,10 +287,13 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
* @throws Exception If failed.
*/
@SuppressWarnings("unchecked")
- protected static <K> void loadAll(Cache<K, ?> cache, final Set<K> keys, final boolean replaceExistingValues) throws Exception {
+ protected static <K> void loadAll(Cache<K, ?> cache, final Set<K> keys, final boolean replaceExistingValues)
+ throws Exception {
IgniteCache<K, Object> cacheCp = (IgniteCache<K, Object>)cache;
GridAbstractTest.executeOnLocalOrRemoteJvm(cacheCp, new TestCacheRunnable<K, Object>() {
+ private static final long serialVersionUID = -3030833765012500545L;
+
@Override public void run(Ignite ignite, IgniteCache<K, Object> cache) throws Exception {
final AtomicReference<Exception> ex = new AtomicReference<>();
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java
index e1959e5..57fbcfc 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java
@@ -19,12 +19,12 @@ package org.apache.ignite.testframework.junits.multijvm;
import java.util.Collection;
import java.util.Map;
-import java.util.UUID;
+import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.Ignition;
import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.resources.IgniteInstanceResource;
import org.jetbrains.annotations.Nullable;
/**
@@ -38,160 +38,388 @@ public class AffinityProcessProxy<K> implements Affinity<K> {
/** Cache name. */
private final String cacheName;
- /** Grid id. */
- private final UUID gridId;
-
/**
* @param cacheName Cache name.
- * @param proxy Ignite ptocess proxy.
+ * @param proxy Ignite process proxy.
*/
public AffinityProcessProxy(String cacheName, IgniteProcessProxy proxy) {
this.cacheName = cacheName;
- gridId = proxy.getId();
- compute = proxy.remoteCompute();
- }
-
- /**
- * Returns cache instance. Method to be called from closure at another JVM.
- *
- * @return Cache.
- */
- private Affinity<Object> affinity() {
- return Ignition.ignite(gridId).affinity(cacheName);
+ this.compute = proxy.remoteCompute();
}
/** {@inheritDoc} */
@Override public int partitions() {
- return (int)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().partitions();
- }
- });
+ return compute.call(new PartitionsTask(cacheName));
}
/** {@inheritDoc} */
- @Override public int partition(final K key) {
- return (int)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().partition(key);
- }
- });
+ @Override public int partition(K key) {
+ return compute.call(new PartitionTask<>(cacheName, key));
}
/** {@inheritDoc} */
- @Override public boolean isPrimary(final ClusterNode n, final K key) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().isPrimary(n, key);
- }
- });
+ @Override public boolean isPrimary(ClusterNode n, K key) {
+ return compute.call(new PrimaryOrBackupNodeTask<>(cacheName, key, n, true, false));
}
/** {@inheritDoc} */
- @Override public boolean isBackup(final ClusterNode n, final K key) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().isBackup(n, key);
- }
- });
+ @Override public boolean isBackup(ClusterNode n, K key) {
+ return compute.call(new PrimaryOrBackupNodeTask<>(cacheName, key, n, false, true));
}
/** {@inheritDoc} */
- @Override public boolean isPrimaryOrBackup(final ClusterNode n, final K key) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().isPrimaryOrBackup(n, key);
- }
- });
+ @Override public boolean isPrimaryOrBackup(ClusterNode n, K key) {
+ return compute.call(new PrimaryOrBackupNodeTask<>(cacheName, key, n, true, true));
}
/** {@inheritDoc} */
- @Override public int[] primaryPartitions(final ClusterNode n) {
- return (int[])compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().primaryPartitions(n);
- }
- });
+ @Override public int[] primaryPartitions(ClusterNode n) {
+ return compute.call(new GetPartitionsTask(cacheName, n, true, false));
}
/** {@inheritDoc} */
- @Override public int[] backupPartitions(final ClusterNode n) {
- return (int[])compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().backupPartitions(n);
- }
- });
+ @Override public int[] backupPartitions(ClusterNode n) {
+ return compute.call(new GetPartitionsTask(cacheName, n, false, true));
}
/** {@inheritDoc} */
- @Override public int[] allPartitions(final ClusterNode n) {
- return (int[])compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().allPartitions(n);
- }
- });
+ @Override public int[] allPartitions(ClusterNode n) {
+ return compute.call(new GetPartitionsTask(cacheName, n, true, true));
}
/** {@inheritDoc} */
- @Override public Object affinityKey(final K key) {
- return compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().affinityKey(key);
- }
- });
+ @Override public Object affinityKey(K key) {
+ return compute.call(new AffinityKeyTask<>(cacheName, key));
}
/** {@inheritDoc} */
- @Override public Map<ClusterNode, Collection<K>> mapKeysToNodes(final Collection<? extends K> keys) {
- return (Map<ClusterNode, Collection<K>>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().mapKeysToNodes(keys);
- }
- });
+ @Override public Map<ClusterNode, Collection<K>> mapKeysToNodes(Collection<? extends K> keys) {
+ return compute.call(new MapKeysToNodesTask<>(cacheName, keys));
}
/** {@inheritDoc} */
- @Nullable @Override public ClusterNode mapKeyToNode(final K key) {
- return (ClusterNode)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().mapKeyToNode(key);
- }
- });
+ @Nullable @Override public ClusterNode mapKeyToNode(K key) {
+ return compute.call(new MapKeyToNodeTask<>(cacheName, key));
}
/** {@inheritDoc} */
- @Override public Collection<ClusterNode> mapKeyToPrimaryAndBackups(final K key) {
- return (Collection<ClusterNode>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().mapKeyToPrimaryAndBackups(key);
- }
- });
+ @Override public Collection<ClusterNode> mapKeyToPrimaryAndBackups(K key) {
+ return compute.call(new MapKeyToPrimaryAndBackupsTask<>(cacheName, key));
}
/** {@inheritDoc} */
- @Override public ClusterNode mapPartitionToNode(final int part) {
- return (ClusterNode)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().mapPartitionToNode(part);
- }
- });
+ @Override public ClusterNode mapPartitionToNode(int part) {
+ return compute.call(new MapPartitionToNode<>(cacheName, part));
}
/** {@inheritDoc} */
- @Override public Map<Integer, ClusterNode> mapPartitionsToNodes(final Collection<Integer> parts) {
- return (Map<Integer, ClusterNode>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().mapPartitionsToNodes(parts);
- }
- });
+ @Override public Map<Integer, ClusterNode> mapPartitionsToNodes(Collection<Integer> parts) {
+ return compute.call(new MapPartitionsToNodes<>(cacheName, parts));
}
/** {@inheritDoc} */
- @Override public Collection<ClusterNode> mapPartitionToPrimaryAndBackups(final int part) {
- return (Collection<ClusterNode>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return affinity().mapPartitionToPrimaryAndBackups(part);
- }
- });
+ @Override public Collection<ClusterNode> mapPartitionToPrimaryAndBackups(int part) {
+ return compute.call(new MapPartitionsToPrimaryAndBackupsTask<>(cacheName, part));
+ }
+
+ /**
+ *
+ */
+ private static class PrimaryOrBackupNodeTask<K> extends AffinityTaskAdapter<K, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Node. */
+ private final ClusterNode n;
+
+ /** Primary. */
+ private final boolean primary;
+
+ /** Backup. */
+ private final boolean backup;
+
+ /**
+ * @param cacheName Cache name.
+ * @param key Key.
+ * @param n N.
+ */
+ public PrimaryOrBackupNodeTask(String cacheName, K key, ClusterNode n,
+ boolean primary, boolean backup) {
+ super(cacheName);
+ this.key = key;
+ this.n = n;
+ this.primary = primary;
+ this.backup = backup;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ if (primary && backup)
+ return affinity().isPrimaryOrBackup(n, key);
+ else if (primary)
+ return affinity().isPrimary(n, key);
+ else if (backup)
+ return affinity().isBackup(n, key);
+ else
+ throw new IllegalStateException("primary or backup or both flags should be switched on");
+ }
+ }
+
+ /**
+ *
+ */
+ private static class MapKeyToPrimaryAndBackupsTask<K> extends AffinityTaskAdapter<K, Collection<ClusterNode>> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param key Key.
+ */
+ public MapKeyToPrimaryAndBackupsTask(String cacheName, K key) {
+ super(cacheName);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<ClusterNode> call() throws Exception {
+ return affinity().mapKeyToPrimaryAndBackups(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class PartitionsTask extends AffinityTaskAdapter<Void, Integer> {
+ /**
+ * @param cacheName Cache name.
+ */
+ public PartitionsTask(String cacheName) {
+ super(cacheName);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Integer call() throws Exception {
+ return affinity().partitions();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class PartitionTask<K> extends AffinityTaskAdapter<K, Integer> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param key Key.
+ */
+ public PartitionTask(String cacheName, K key) {
+ super(cacheName);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Integer call() throws Exception {
+ return affinity().partition(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetPartitionsTask extends AffinityTaskAdapter<Void, int[]> {
+ /** Node. */
+ private final ClusterNode n;
+
+ /** Primary. */
+ private final boolean primary;
+
+ /** Backup. */
+ private final boolean backup;
+
+ /**
+ * @param cacheName Cache name.
+ * @param n N.
+ * @param primary Primary.
+ * @param backup Backup.
+ */
+ public GetPartitionsTask(String cacheName, ClusterNode n, boolean primary, boolean backup) {
+ super(cacheName);
+ this.n = n;
+ this.primary = primary;
+ this.backup = backup;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int[] call() throws Exception {
+ if (primary && backup)
+ return affinity().allPartitions(n);
+ else if (primary)
+ return affinity().primaryPartitions(n);
+ else if (backup)
+ return affinity().backupPartitions(n);
+ else
+ throw new IllegalStateException("primary or backup or both flags should be switched on");
+ }
+ }
+
+ /**
+ *
+ */
+ private static class AffinityKeyTask<K> extends AffinityTaskAdapter<K, Object> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param key Key.
+ */
+ public AffinityKeyTask(String cacheName, K key) {
+ super(cacheName);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object call() throws Exception {
+ return affinity().affinityKey(key);
+ }
+ }
+
+ /**
+ * @param <K>
+ */
+ private static class MapKeysToNodesTask<K> extends AffinityTaskAdapter<K, Map<ClusterNode, Collection<K>>> {
+ /** Keys. */
+ private final Collection<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param keys Keys.
+ */
+ public MapKeysToNodesTask(String cacheName, Collection<? extends K> keys) {
+ super(cacheName);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<ClusterNode, Collection<K>> call() throws Exception {
+ return affinity().mapKeysToNodes(keys);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class MapKeyToNodeTask<K> extends AffinityTaskAdapter<K, ClusterNode> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param key Key.
+ */
+ public MapKeyToNodeTask(String cacheName, K key) {
+ super(cacheName);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ClusterNode call() throws Exception {
+ return affinity().mapKeyToNode(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class MapPartitionToNode<K> extends AffinityTaskAdapter<K, ClusterNode> {
+ /** Partition. */
+ private final int part;
+
+ /**
+ * @param cacheName Cache name.
+ * @param part Partition.
+ */
+ public MapPartitionToNode(String cacheName, int part) {
+ super(cacheName);
+ this.part = part;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ClusterNode call() throws Exception {
+ return affinity().mapPartitionToNode(part);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class MapPartitionsToNodes<K> extends AffinityTaskAdapter<K, Map<Integer, ClusterNode>> {
+ /** Parts. */
+ private final Collection<Integer> parts;
+
+ /**
+ * @param cacheName Cache name.
+ * @param parts Parts.
+ */
+ public MapPartitionsToNodes(String cacheName, Collection<Integer> parts) {
+ super(cacheName);
+ this.parts = parts;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<Integer, ClusterNode> call() throws Exception {
+ return affinity().mapPartitionsToNodes(parts);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class MapPartitionsToPrimaryAndBackupsTask<K> extends AffinityTaskAdapter<K, Collection<ClusterNode>> {
+ /** Partition. */
+ private final int part;
+
+ /**
+ * @param cacheName Cache name.
+ * @param part Partition.
+ */
+ public MapPartitionsToPrimaryAndBackupsTask(String cacheName, int part) {
+ super(cacheName);
+ this.part = part;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<ClusterNode> call() throws Exception {
+ return affinity().mapPartitionToPrimaryAndBackups(part);
+ }
+ }
+
+ /**
+ *
+ */
+ private abstract static class AffinityTaskAdapter<K, R> implements IgniteCallable<R> {
+ /** Ignite. */
+ @IgniteInstanceResource
+ protected Ignite ignite;
+
+ /** Cache name. */
+ protected final String cacheName;
+
+ /**
+ * @param cacheName Cache name.
+ */
+ public AffinityTaskAdapter(String cacheName) {
+ this.cacheName = cacheName;
+ }
+
+ /**
+ * @return Affinity.
+ */
+ protected Affinity<K> affinity() {
+ return ignite.affinity(cacheName);
+ }
}
}
\ No newline at end of file
[14/34] ignite git commit: ignite-1620 Tests muted
Posted by sb...@apache.org.
ignite-1620 Tests muted
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/25809947
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/25809947
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/25809947
Branch: refs/heads/ignite-1607
Commit: 25809947a7715d57092d8bb009ef6e48afa79b62
Parents: 833405e
Author: agura <ag...@gridgain.com>
Authored: Tue Oct 6 15:19:21 2015 +0300
Committer: agura <ag...@gridgain.com>
Committed: Tue Oct 6 15:19:21 2015 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/25809947/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java
index ea65464..efe95be 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java
@@ -64,6 +64,11 @@ public abstract class Hadoop1DualAbstractTest extends IgfsDualAbstractSelfTest {
super(mode);
}
+ /** {@inheritDoc} */
+ @Override public void testMkdirs() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1620");
+ }
+
/**
* Creates secondary filesystems.
* @return IgfsSecondaryFileSystem
[18/34] ignite git commit: ignite-1183 Fixed data structures
create/destroy from client node
Posted by sb...@apache.org.
ignite-1183 Fixed data structures create/destroy from client node
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3036c8d8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3036c8d8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3036c8d8
Branch: refs/heads/ignite-1607
Commit: 3036c8d85db223a26f48f273ad08b6ea87e2e2ba
Parents: f025714
Author: sboikov <sb...@gridgain.com>
Authored: Thu Oct 8 16:33:53 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Oct 8 16:33:53 2015 +0300
----------------------------------------------------------------------
.../dht/atomic/GridNearAtomicUpdateFuture.java | 8 +-
.../colocated/GridDhtColocatedLockFuture.java | 11 +-
.../distributed/near/GridNearLockFuture.java | 11 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 24 +--
.../datastructures/DataStructuresProcessor.java | 48 ++++--
.../CacheGetFutureHangsSelfTest.java | 3 +
...niteCacheClientNodeChangingTopologyTest.java | 6 +-
...gniteAtomicLongChangingTopologySelfTest.java | 155 +++++++++++++++++--
8 files changed, 216 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3036c8d8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
index 41df53a..97aa646 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
@@ -585,8 +585,12 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object>
if (req != null) {
res = new GridNearAtomicUpdateResponse(cctx.cacheId(), nodeId, req.futureVersion());
- res.addFailedKeys(req.keys(), new ClusterTopologyCheckedException("Primary node left grid before " +
- "response is received: " + nodeId));
+ ClusterTopologyCheckedException e = new ClusterTopologyCheckedException("Primary node left grid " +
+ "before response is received: " + nodeId);
+
+ e.retryReadyFuture(cctx.shared().nextAffinityReadyFuture(req.topologyVersion()));
+
+ res.addFailedKeys(req.keys(), e);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/3036c8d8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
index 33a5cbd..be09f54 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
@@ -598,7 +598,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
// Continue mapping on the same topology version as it was before.
this.topVer.compareAndSet(null, topVer);
- map(keys, false);
+ map(keys, false, true);
markInitialized();
@@ -654,7 +654,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
this.topVer.compareAndSet(null, topVer);
}
- map(keys, remap);
+ map(keys, remap, false);
if (c != null)
c.run();
@@ -691,8 +691,9 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
*
* @param keys Keys.
* @param remap Remap flag.
+ * @param topLocked {@code True} if thread already acquired lock preventing topology change.
*/
- private void map(Collection<KeyCacheObject> keys, boolean remap) {
+ private void map(Collection<KeyCacheObject> keys, boolean remap, boolean topLocked) {
try {
AffinityTopologyVersion topVer = this.topVer.get();
@@ -819,7 +820,9 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
boolean clientFirst = false;
if (first) {
- clientFirst = clientNode && (tx == null || !tx.hasRemoteLocks());
+ clientFirst = clientNode &&
+ !topLocked &&
+ (tx == null || !tx.hasRemoteLocks());
first = false;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/3036c8d8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
index dcc8da6..e6b1e02 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
@@ -718,7 +718,7 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
// Continue mapping on the same topology version as it was before.
this.topVer.compareAndSet(null, topVer);
- map(keys, false);
+ map(keys, false, true);
markInitialized();
@@ -773,7 +773,7 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
this.topVer.compareAndSet(null, topVer);
}
- map(keys, remap);
+ map(keys, remap, false);
markInitialized();
}
@@ -807,8 +807,9 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
*
* @param keys Keys.
* @param remap Remap flag.
+ * @param topLocked {@code True} if thread already acquired lock preventing topology change.
*/
- private void map(Iterable<KeyCacheObject> keys, boolean remap) {
+ private void map(Iterable<KeyCacheObject> keys, boolean remap, boolean topLocked) {
try {
AffinityTopologyVersion topVer = this.topVer.get();
@@ -938,7 +939,9 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
boolean clientFirst = false;
if (first) {
- clientFirst = clientNode && (tx == null || !tx.hasRemoteLocks());
+ clientFirst = clientNode &&
+ !topLocked &&
+ (tx == null || !tx.hasRemoteLocks());
first = false;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/3036c8d8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
index 25028c4..1fb33a2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
@@ -271,7 +271,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
cctx.mvcc().addFuture(this);
- prepare0(false);
+ prepare0(false, true);
return;
}
@@ -338,7 +338,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
return;
}
- prepare0(remap);
+ prepare0(remap, false);
if (c != null)
c.run();
@@ -428,8 +428,9 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
* Initializes future.
*
* @param remap Remap flag.
+ * @param topLocked {@code True} if thread already acquired lock preventing topology change.
*/
- private void prepare0(boolean remap) {
+ private void prepare0(boolean remap, boolean topLocked) {
try {
boolean txStateCheck = remap ? tx.state() == PREPARING : tx.state(PREPARING);
@@ -451,7 +452,8 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
prepare(
tx.optimistic() && tx.serializable() ? tx.readEntries() : Collections.<IgniteTxEntry>emptyList(),
- tx.writeEntries());
+ tx.writeEntries(),
+ topLocked);
markInitialized();
}
@@ -466,11 +468,13 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
/**
* @param reads Read entries.
* @param writes Write entries.
+ * @param topLocked {@code True} if thread already acquired lock preventing topology change.
* @throws IgniteCheckedException If failed.
*/
private void prepare(
Iterable<IgniteTxEntry> reads,
- Iterable<IgniteTxEntry> writes
+ Iterable<IgniteTxEntry> writes,
+ boolean topLocked
) throws IgniteCheckedException {
AffinityTopologyVersion topVer = tx.topologyVersion();
@@ -497,7 +501,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
GridDistributedTxMapping cur = null;
for (IgniteTxEntry read : reads) {
- GridDistributedTxMapping updated = map(read, topVer, cur, false);
+ GridDistributedTxMapping updated = map(read, topVer, cur, false, topLocked);
if (cur != updated) {
mappings.offer(updated);
@@ -514,7 +518,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
}
for (IgniteTxEntry write : writes) {
- GridDistributedTxMapping updated = map(write, topVer, cur, true);
+ GridDistributedTxMapping updated = map(write, topVer, cur, true, topLocked);
if (cur != updated) {
mappings.offer(updated);
@@ -647,13 +651,15 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
* @param topVer Topology version.
* @param cur Current mapping.
* @param waitLock Wait lock flag.
+ * @param topLocked {@code True} if thread already acquired lock preventing topology change.
* @return Mapping.
*/
private GridDistributedTxMapping map(
IgniteTxEntry entry,
AffinityTopologyVersion topVer,
@Nullable GridDistributedTxMapping cur,
- boolean waitLock
+ boolean waitLock,
+ boolean topLocked
) {
GridCacheContext cacheCtx = entry.context();
@@ -685,7 +691,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
}
if (cur == null || !cur.node().id().equals(primary.id()) || cur.near() != cacheCtx.isNear()) {
- boolean clientFirst = cur == null && cctx.kernalContext().clientNode();
+ boolean clientFirst = cur == null && !topLocked && cctx.kernalContext().clientNode();
cur = new GridDistributedTxMapping(primary);
http://git-wip-us.apache.org/repos/asf/ignite/blob/3036c8d8/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
index ef2c543..7c5e97c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
@@ -505,14 +505,20 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
return dataStructure;
}
- catch (ClusterTopologyCheckedException e) {
- IgniteInternalFuture<?> fut = e.retryReadyFuture();
-
- fut.get();
- }
catch (IgniteTxRollbackCheckedException ignore) {
// Safe to retry right away.
}
+ catch (IgniteCheckedException e) {
+ ClusterTopologyCheckedException topErr = e.getCause(ClusterTopologyCheckedException.class);
+
+ if (topErr == null)
+ throw e;
+
+ IgniteInternalFuture<?> fut = topErr.retryReadyFuture();
+
+ if (fut != null)
+ fut.get();
+ }
}
}
@@ -593,14 +599,20 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
if (afterRmv != null && rmvInfo != null)
afterRmv.applyx(rmvInfo);
}
- catch (ClusterTopologyCheckedException e) {
- IgniteInternalFuture<?> fut = e.retryReadyFuture();
-
- fut.get();
- }
catch (IgniteTxRollbackCheckedException ignore) {
// Safe to retry right away.
}
+ catch (IgniteCheckedException e) {
+ ClusterTopologyCheckedException topErr = e.getCause(ClusterTopologyCheckedException.class);
+
+ if (topErr == null)
+ throw e;
+
+ IgniteInternalFuture<?> fut = topErr.retryReadyFuture();
+
+ if (fut != null)
+ fut.get();
+ }
}
}
@@ -995,14 +1007,20 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
return col;
}
- catch (ClusterTopologyCheckedException e) {
- IgniteInternalFuture<?> fut = e.retryReadyFuture();
-
- fut.get();
- }
catch (IgniteTxRollbackCheckedException ignore) {
// Safe to retry right away.
}
+ catch (IgniteCheckedException e) {
+ ClusterTopologyCheckedException topErr = e.getCause(ClusterTopologyCheckedException.class);
+
+ if (topErr == null)
+ throw e;
+
+ IgniteInternalFuture<?> fut = topErr.retryReadyFuture();
+
+ if (fut != null)
+ fut.get();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/3036c8d8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
index e8622aa..51e76f6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
@@ -31,6 +31,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.jetbrains.annotations.Nullable;
@@ -54,6 +55,8 @@ public class CacheGetFutureHangsSelfTest extends GridCommonAbstractTest {
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
+ ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
OptimizedMarshaller marsh = new OptimizedMarshaller();
marsh.setRequireSerializable(false);
http://git-wip-us.apache.org/repos/asf/ignite/blob/3036c8d8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
index 2d29c49..1b3dc7a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
@@ -118,7 +118,11 @@ public class IgniteCacheClientNodeChangingTopologyTest extends GridCommonAbstrac
cfg.setClientMode(client);
- cfg.setCommunicationSpi(new TestCommunicationSpi());
+ TestCommunicationSpi commSpi = new TestCommunicationSpi();
+
+ commSpi.setSharedMemoryPort(-1);
+
+ cfg.setCommunicationSpi(commSpi);
cfg.setCacheConfiguration(ccfg);
http://git-wip-us.apache.org/repos/asf/ignite/blob/3036c8d8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
index 337334e..32a86e4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
@@ -17,21 +17,37 @@
package org.apache.ignite.internal.processors.cache.distributed.dht;
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Queue;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReferenceArray;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteAtomicLong;
+import org.apache.ignite.IgniteQueue;
+import org.apache.ignite.configuration.AtomicConfiguration;
+import org.apache.ignite.configuration.CollectionConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
-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.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
/**
*
@@ -52,6 +68,9 @@ public class IgniteAtomicLongChangingTopologySelfTest extends GridCommonAbstract
/** */
private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+ /** */
+ private boolean client;
+
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
@@ -60,16 +79,18 @@ public class IgniteAtomicLongChangingTopologySelfTest extends GridCommonAbstract
discoSpi.setIpFinder(IP_FINDER);
- cfg.setDiscoverySpi(discoSpi);
+ cfg.setDiscoverySpi(discoSpi).setNetworkTimeout(30_000);
AtomicConfiguration atomicCfg = new AtomicConfiguration();
- atomicCfg.setCacheMode(CacheMode.PARTITIONED);
+ atomicCfg.setCacheMode(PARTITIONED);
atomicCfg.setBackups(1);
cfg.setAtomicConfiguration(atomicCfg);
((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+ cfg.setClientMode(client);
+
return cfg;
}
@@ -111,6 +132,110 @@ public class IgniteAtomicLongChangingTopologySelfTest extends GridCommonAbstract
/**
* @throws Exception If failed.
*/
+ public void testClientAtomicLongCreateCloseFailover() throws Exception {
+ testFailoverWithClient(new IgniteInClosure<Ignite>() {
+ @Override public void apply(Ignite ignite) {
+ for (int i = 0; i < 100; i++) {
+ IgniteAtomicLong l = ignite.atomicLong("long-" + 1, 0, true);
+
+ l.close();
+ }
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClientQueueCreateCloseFailover() throws Exception {
+ testFailoverWithClient(new IgniteInClosure<Ignite>() {
+ @Override public void apply(Ignite ignite) {
+ for (int i = 0; i < 100; i++) {
+ CollectionConfiguration colCfg = new CollectionConfiguration();
+
+ colCfg.setBackups(1);
+ colCfg.setCacheMode(PARTITIONED);
+ colCfg.setAtomicityMode(i % 2 == 0 ? TRANSACTIONAL : ATOMIC);
+
+ IgniteQueue q = ignite.queue("q-" + i, 0, colCfg);
+
+ q.close();
+ }
+ }
+ });
+ }
+
+ /**
+ * @param c Test iteration closure.
+ * @throws Exception If failed.
+ */
+ private void testFailoverWithClient(IgniteInClosure<Ignite> c) throws Exception {
+ startGridsMultiThreaded(GRID_CNT, false);
+
+ client = true;
+
+ Ignite ignite = startGrid(GRID_CNT);
+
+ assertTrue(ignite.configuration().isClientMode());
+
+ client = false;
+
+ final AtomicBoolean finished = new AtomicBoolean();
+
+ IgniteInternalFuture<?> fut = restartThread(finished);
+
+ long stop = System.currentTimeMillis() + 30_000;
+
+ try {
+ int iter = 0;
+
+ while (System.currentTimeMillis() < stop) {
+ log.info("Iteration: " + iter++);
+
+ c.apply(ignite);
+ }
+
+ finished.set(true);
+
+ fut.get();
+ }
+ finally {
+ finished.set(true);
+ }
+ }
+
+ /**
+ * @param finished Finished flag.
+ * @return Future.
+ */
+ private IgniteInternalFuture<?> restartThread(final AtomicBoolean finished) {
+ return GridTestUtils.runAsync(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ while (!finished.get()) {
+ for (int i = 0; i < GRID_CNT; i++) {
+ log.info("Stop node: " + i);
+
+ stopGrid(i);
+
+ U.sleep(500);
+
+ log.info("Start node: " + i);
+
+ startGrid(i);
+
+ if (finished.get())
+ break;
+ }
+ }
+
+ return null;
+ }
+ }, "restart-thread");
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testIncrementConsistency() throws Exception {
startGrids(GRID_CNT);
[29/34] ignite git commit: ignite-1.4.2 - review and minor changes.
Posted by sb...@apache.org.
ignite-1.4.2 - review and minor changes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/155edd8d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/155edd8d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/155edd8d
Branch: refs/heads/ignite-1607
Commit: 155edd8d254fa56c4fcc1666fe014c116e649a39
Parents: 4ee154c
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Oct 12 12:41:59 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Oct 12 12:41:59 2015 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheIoManager.java | 9 +-
.../GridDhtPartitionDemandMessage.java | 1 -
.../GridDhtPartitionsExchangeFuture.java | 16 +-
.../preloader/GridDhtPartitionsFullMessage.java | 1 -
.../multijvm/IgniteCacheProcessProxy.java | 966 +------------------
.../Properties/AssemblyInfo.cs | 2 +-
.../Apache.Ignite/Properties/AssemblyInfo.cs | 2 +-
.../Properties/AssemblyInfo.cs | 2 +-
.../Properties/AssemblyInfo.cs | 2 +-
9 files changed, 12 insertions(+), 989 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
index ae3eb22..476a96c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
@@ -24,7 +24,6 @@ import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
@@ -57,8 +56,6 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPr
import org.apache.ignite.internal.util.F0;
import org.apache.ignite.internal.util.GridLeanSet;
import org.apache.ignite.internal.util.GridSpinReadWriteLock;
-import org.apache.ignite.internal.util.future.GridFinishedFuture;
-import org.apache.ignite.internal.util.lang.GridPlainRunnable;
import org.apache.ignite.internal.util.typedef.CI1;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.P1;
@@ -99,9 +96,6 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
/** Stopping flag. */
private boolean stopping;
- /** Error flag. */
- private final AtomicBoolean startErr = new AtomicBoolean();
-
/** Mutex. */
private final GridSpinReadWriteLock rw = new GridSpinReadWriteLock();
@@ -944,10 +938,9 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
/**
* @param nodeId Sender node ID.
* @param cacheMsg Message.
- * @throws IgniteCheckedException If failed.
*/
@SuppressWarnings({"ErrorNotRethrown", "unchecked"})
- private void unmarshall(UUID nodeId, GridCacheMessage cacheMsg) throws IgniteCheckedException {
+ private void unmarshall(UUID nodeId, GridCacheMessage cacheMsg) {
if (cctx.localNodeId().equals(nodeId))
return;
http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
index 156c37f..848ad87 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
@@ -27,7 +27,6 @@ import org.apache.ignite.internal.GridDirectTransient;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.GridCacheMessage;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index eaa5584..77e47a7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -193,6 +193,9 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
/** */
private boolean clientOnlyExchange;
+ /** Init timestamp. Used to track the amount of time spent to complete the future. */
+ private long initTs;
+
/**
* Dummy future created to trigger reassignments if partition
* topology changed while preloading.
@@ -475,9 +478,6 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
busyLock.readLock().unlock();
}
- // TODO remove
- long inited;
-
/**
* Starts activity.
*
@@ -491,7 +491,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
if (isDone())
return;
- inited = U.currentTimeMillis();
+ initTs = U.currentTimeMillis();
try {
// Wait for event to occur to make sure that discovery
@@ -1065,7 +1065,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
if (super.onDone(res, err) && !dummy && !forcePreload) {
if (log.isDebugEnabled())
log.debug("Completed partition exchange [localNode=" + cctx.localNodeId() + ", exchange= " + this +
- "duration=" + duration() + ", durationFromInit=" + (U.currentTimeMillis() - inited) + ']');
+ "duration=" + duration() + ", durationFromInit=" + (U.currentTimeMillis() - initTs) + ']');
initFut.onDone(err == null);
@@ -1196,8 +1196,6 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
if (match) {
boolean allReceived;
- long start = U.currentTimeMillis();
-
synchronized (rcvdIds) {
if (rcvdIds.add(nodeId))
updatePartitionSingleMap(msg);
@@ -1205,8 +1203,6 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
allReceived = allReceived();
}
- long end = U.currentTimeMillis();
-
// If got all replies, and initialization finished, and reply has not been sent yet.
if (allReceived && ready.get() && replied.compareAndSet(false, true)) {
spreadPartitions();
@@ -1216,7 +1212,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
else if (log.isDebugEnabled())
log.debug("Exchange future full map is not sent [allReceived=" + allReceived() +
", ready=" + ready + ", replied=" + replied.get() + ", init=" + init.get() +
- ", fut=" + GridDhtPartitionsExchangeFuture.this + ", updateDur=" + (end - start) + ']');
+ ", fut=" + GridDhtPartitionsExchangeFuture.this + ']');
}
}
});
http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
index 5429538..c06d773 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
@@ -203,4 +203,3 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
"super", super.toString());
}
}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index ddce314..d89e397 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -1386,968 +1386,4 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
return async ? cache.withAsync() : cache;
}
}
-
- /**
- *
- */
- private static class GetConfigurationTask<K, V, C extends Configuration<K, V>> extends CacheTaskAdapter<K, V, C> {
- /** Clazz. */
- private final Class<C> clazz;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param clazz Clazz.
- */
- public GetConfigurationTask(String cacheName, boolean async, Class<C> clazz) {
- super(cacheName, async);
- this.clazz = clazz;
- }
-
- /** {@inheritDoc} */
- @Override public C call() throws Exception {
- return cache().getConfiguration(clazz);
- }
- }
-
- /**
- *
- */
- private static class LocalLoadCacheTask<K, V> extends CacheTaskAdapter<K, V, Void> {
- /** Predicate. */
- private final IgniteBiPredicate<K, V> p;
-
- /** Args. */
- private final Object[] args;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param p P.
- * @param args Args.
- */
- public LocalLoadCacheTask(String cacheName, boolean async, IgniteBiPredicate<K, V> p, Object[] args) {
- super(cacheName, async);
- this.p = p;
- this.args = args;
- }
-
- /** {@inheritDoc} */
- @Override public Void call() {
- cache().localLoadCache(p, args);
-
- return null;
- }
- }
-
- /**
- *
- */
- private static class GetAndPutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, V> {
- /** Key. */
- private final K key;
-
- /** Value. */
- private final V val;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param key Key.
- * @param val Value.
- */
- public GetAndPutIfAbsentTask(String cacheName, boolean async, K key, V val) {
- super(cacheName, async);
- this.key = key;
- this.val = val;
- }
-
- /** {@inheritDoc} */
- @Override public V call() throws Exception {
- return cache().getAndPutIfAbsent(key, val);
- }
- }
-
- /**
- *
- */
- private static class IsLocalLockedTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
- /** Key. */
- private final K key;
-
- /** By current thread. */
- private final boolean byCurrThread;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param key Key.
- * @param byCurrThread By current thread.
- */
- public IsLocalLockedTask(String cacheName, boolean async, K key, boolean byCurrThread) {
- super(cacheName, async);
- this.key = key;
- this.byCurrThread = byCurrThread;
- }
-
- /** {@inheritDoc} */
- @Override public Boolean call() throws Exception {
- return cache().isLocalLocked(key, byCurrThread);
- }
- }
-
- /**
- *
- */
- private static class LocalEntriesTask<K, V> extends CacheTaskAdapter<K, V, Iterable<Entry<K, V>>> {
- /** Peek modes. */
- private final CachePeekMode[] peekModes;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param peekModes Peek modes.
- */
- public LocalEntriesTask(String cacheName, boolean async, CachePeekMode[] peekModes) {
- super(cacheName, async);
- this.peekModes = peekModes;
- }
-
- /** {@inheritDoc} */
- @Override public Iterable<Entry<K, V>> call() throws Exception {
- Collection<Entry<K, V>> res = new ArrayList<>();
-
- for (Entry<K, V> e : cache().localEntries(peekModes))
- res.add(e);
-
- return res;
- }
- }
-
- /**
- *
- */
- private static class LocalEvictTask<K> extends CacheTaskAdapter<K, Void, Void> {
- /** Keys. */
- private final Collection<? extends K> keys;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param keys Keys.
- */
- public LocalEvictTask(String cacheName, boolean async, Collection<? extends K> keys) {
- super(cacheName, async);
- this.keys = keys;
- }
-
- /** {@inheritDoc} */
- @Override public Void call() {
- cache().localEvict(keys);
-
- return null;
- }
- }
-
- /**
- *
- */
- private static class LocalPeekTask<K, V> extends CacheTaskAdapter<K, V, V> {
- /** Key. */
- private final K key;
-
- /** Peek modes. */
- private final CachePeekMode[] peekModes;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param key Key.
- * @param peekModes Peek modes.
- */
- public LocalPeekTask(String cacheName, boolean async, K key, CachePeekMode[] peekModes) {
- super(cacheName, async);
- this.key = key;
- this.peekModes = peekModes;
- }
-
- /** {@inheritDoc} */
- @Override public V call() throws Exception {
- return cache().localPeek(key, peekModes);
- }
- }
-
- /**
- *
- */
- private static class SizeTask extends CacheTaskAdapter<Void, Void, Integer> {
- /** Peek modes. */
- private final CachePeekMode[] peekModes;
-
- /** Local. */
- private final boolean loc;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param peekModes Peek modes.
- * @param loc Local.
- */
- public SizeTask(String cacheName, boolean async, CachePeekMode[] peekModes, boolean loc) {
- super(cacheName, async);
- this.loc = loc;
- this.peekModes = peekModes;
- }
-
- /** {@inheritDoc} */
- @Override public Integer call() throws Exception {
- return loc ? cache().localSize(peekModes) : cache().size(peekModes);
- }
- }
-
- /**
- *
- */
- private static class GetTask<K, V> extends CacheTaskAdapter<K, V, V> {
- /** Key. */
- private final K key;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param key Key.
- */
- public GetTask(String cacheName, boolean async, K key) {
- super(cacheName, async);
- this.key = key;
- }
-
- /** {@inheritDoc} */
- @Override public V call() throws Exception {
- return cache().get(key);
- }
- }
-
- /**
- *
- */
- private static class RemoveAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
- /**
- * @param cacheName Cache name.
- * @param async Async.
- */
- public RemoveAllTask(String cacheName, boolean async) {
- super(cacheName, async);
- }
-
- /** {@inheritDoc} */
- @Override public Void call() {
- IgniteCache<K, V> cache = cache();
-
- cache.removeAll();
-
- if (async)
- cache.future().get();
-
- return null;
- }
- }
-
- /**
- *
- */
- private static class PutTask<K, V> extends CacheTaskAdapter<K, V, Void> {
- /** Key. */
- private final K key;
-
- /** Value. */
- private final V val;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param key Key.
- * @param val Value.
- */
- public PutTask(String cacheName, boolean async, K key, V val) {
- super(cacheName, async);
- this.key = key;
- this.val = val;
- }
-
- /** {@inheritDoc} */
- @Override public Void call() {
- cache().put(key, val);
-
- return null;
- }
- }
-
- /**
- *
- */
- private static class ContainsKeyTask<K> extends CacheTaskAdapter<K, Object, Boolean> {
- /** Key. */
- private final K key;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param key Key.
- */
- public ContainsKeyTask(String cacheName, boolean async, K key) {
- super(cacheName, async);
- this.key = key;
- }
-
- /** {@inheritDoc} */
- @Override public Boolean call() throws Exception {
- return cache().containsKey(key);
- }
- }
-
- /**
- *
- */
- private static class ClearTask extends CacheTaskAdapter<Object, Object, Void> {
- /**
- * @param cacheName Cache name.
- * @param async Async.
- */
- public ClearTask(String cacheName, boolean async) {
- super(cacheName, async);
- }
-
- /** {@inheritDoc} */
- @Override public Void call() {
- cache().clear();
-
- return null;
- }
- }
-
- /**
- *
- */
- private static class IteratorTask<K, V> extends CacheTaskAdapter<K, V, Collection<Entry<K, V>>> {
- /**
- * @param cacheName Cache name.
- * @param async Async.
- */
- public IteratorTask(String cacheName, boolean async) {
- super(cacheName, async);
- }
-
- /** {@inheritDoc} */
- @Override public Collection<Entry<K, V>> call() throws Exception {
- Collection<Entry<K, V>> res = new ArrayList<>();
-
- for (Entry<K, V> o : cache())
- res.add(o);
-
- return res;
- }
- }
-
- /**
- *
- */
- private static class ReplaceTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
- /** Key. */
- private final K key;
-
- /** Value. */
- private final V val;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param key Key.
- * @param val Value.
- */
- public ReplaceTask(String cacheName, boolean async, K key, V val) {
- super(cacheName, async);
- this.key = key;
- this.val = val;
- }
-
- /** {@inheritDoc} */
- @Override public Boolean call() throws Exception {
- return cache().replace(key, val);
- }
- }
-
- /**
- *
- */
- private static class GetNameTask extends CacheTaskAdapter<Void, Void, String> {
- /**
- * @param cacheName Cache name.
- * @param async Async.
- */
- public GetNameTask(String cacheName, boolean async) {
- super(cacheName, async);
- }
-
- /** {@inheritDoc} */
- @Override public String call() throws Exception {
- return cache().getName();
- }
- }
-
- /**
- *
- */
- private static class RemoveTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
- /** Key. */
- private final K key;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param key Key.
- */
- public RemoveTask(String cacheName, boolean async, K key) {
- super(cacheName, async);
- this.key = key;
- }
-
- /** {@inheritDoc} */
- @Override public Boolean call() throws Exception {
- return cache().remove(key);
- }
- }
-
- /**
- *
- */
- private static class PutAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
- /** Map. */
- private final Map<? extends K, ? extends V> map;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param map Map.
- */
- public PutAllTask(String cacheName, boolean async, Map<? extends K, ? extends V> map) {
- super(cacheName, async);
- this.map = map;
- }
-
- /** {@inheritDoc} */
- @Override public Void call() {
- cache().putAll(map);
-
- return null;
- }
- }
-
- /**
- *
- */
- private static class RemoveAllKeysTask<K> extends CacheTaskAdapter<K, Void, Void> {
- /** Keys. */
- private final Set<? extends K> keys;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param keys Keys.
- */
- public RemoveAllKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
- super(cacheName, async);
- this.keys = keys;
- }
-
- /** {@inheritDoc} */
- @Override public Void call() {
- cache().removeAll(keys);
-
- return null;
- }
- }
-
- /**
- *
- */
- private static class GetAllTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
- /** Keys. */
- private final Set<? extends K> keys;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param keys Keys.
- */
- public GetAllTask(String cacheName, boolean async, Set<? extends K> keys) {
- super(cacheName, async);
- this.keys = keys;
- }
-
- /** {@inheritDoc} */
- @Override public Map<K, V> call() throws Exception {
- return cache().getAll(keys);
- }
- }
-
- /**
- *
- */
- private static class GetAllOutTxTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
- /** Keys. */
- private final Set<? extends K> keys;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param keys Keys.
- */
- public GetAllOutTxTask(String cacheName, boolean async, Set<? extends K> keys) {
- super(cacheName, async);
- this.keys = keys;
- }
-
- /** {@inheritDoc} */
- @Override public Map<K, V> call() throws Exception {
- return cache().getAllOutTx(keys);
- }
- }
-
- /**
- *
- */
- private static class ContainsKeysTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
- /** Keys. */
- private final Set<? extends K> keys;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param keys Keys.
- */
- public ContainsKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
- super(cacheName, async);
- this.keys = keys;
- }
-
- /** {@inheritDoc} */
- @Override public Boolean call() throws Exception {
- return cache().containsKeys(keys);
- }
- }
-
- /**
- *
- */
- private static class GetAndPutTask<K, V> extends CacheTaskAdapter<K, V, V> {
- /** Key. */
- private final K key;
-
- /** Value. */
- private final V val;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param key Key.
- * @param val Value.
- */
- public GetAndPutTask(String cacheName, boolean async, K key, V val) {
- super(cacheName, async);
- this.key = key;
- this.val = val;
- }
-
- /** {@inheritDoc} */
- @Override public V call() throws Exception {
- return cache().getAndPut(key, val);
- }
- }
-
- /**
- *
- */
- private static class PutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
- /** Key. */
- private final K key;
-
- /** Value. */
- private final V val;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param key Key.
- * @param val Value.
- */
- public PutIfAbsentTask(String cacheName, boolean async, K key, V val) {
- super(cacheName, async);
- this.key = key;
- this.val = val;
- }
-
- /** {@inheritDoc} */
- @Override public Boolean call() throws Exception {
- return cache().putIfAbsent(key, val);
- }
- }
-
- /**
- *
- */
- private static class RemoveIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
- /** Key. */
- private final K key;
-
- /** Old value. */
- private final V oldVal;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param key Key.
- * @param oldVal Old value.
- */
- public RemoveIfExistsTask(String cacheName, boolean async, K key, V oldVal) {
- super(cacheName, async);
- this.key = key;
- this.oldVal = oldVal;
- }
-
- /** {@inheritDoc} */
- @Override public Boolean call() throws Exception {
- return cache().remove(key, oldVal);
- }
- }
-
- /**
- *
- */
- private static class GetAndRemoveTask<K, V> extends CacheTaskAdapter<K, V, V> {
- /** Key. */
- private final K key;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param key Key.
- */
- public GetAndRemoveTask(String cacheName, boolean async, K key) {
- super(cacheName, async);
- this.key = key;
- }
-
- /** {@inheritDoc} */
- @Override public V call() throws Exception {
- return cache().getAndRemove(key);
- }
- }
-
- /**
- *
- */
- private static class ReplaceIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
- /** Key. */
- private final K key;
-
- /** Old value. */
- private final V oldVal;
-
- /** New value. */
- private final V newVal;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param key Key.
- * @param oldVal Old value.
- * @param newVal New value.
- */
- public ReplaceIfExistsTask(String cacheName, boolean async, K key, V oldVal, V newVal) {
- super(cacheName, async);
- this.key = key;
- this.oldVal = oldVal;
- this.newVal = newVal;
- }
-
- /** {@inheritDoc} */
- @Override public Boolean call() throws Exception {
- return cache().replace(key, oldVal, newVal);
- }
- }
-
- /**
- *
- */
- private static class GetAndReplaceTask<K, V> extends CacheTaskAdapter<K, V, V> {
- /** Key. */
- private final K key;
-
- /** Value. */
- private final V val;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param key Key.
- * @param val Value.
- */
- public GetAndReplaceTask(String cacheName, boolean async, K key, V val) {
- super(cacheName, async);
- this.key = key;
- this.val = val;
- }
-
- /** {@inheritDoc} */
- @Override public V call() throws Exception {
- return cache().getAndReplace(key, val);
- }
- }
-
- /**
- *
- */
- private static class ClearKeyTask<K> extends CacheTaskAdapter<K, Void, Void> {
- /** Key. */
- private final K key;
-
- /** Local. */
- private final boolean loc;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param key Key.
- */
- public ClearKeyTask(String cacheName, boolean async, boolean loc, K key) {
- super(cacheName, async);
- this.key = key;
- this.loc = loc;
- }
-
- /** {@inheritDoc} */
- @Override public Void call() {
- if (loc)
- cache().localClear(key);
- else
- cache().clear(key);
-
- return null;
- }
- }
-
- /**
- *
- */
- private static class ClearAllKeys<K> extends CacheTaskAdapter<K, Void, Void> {
- /** Keys. */
- private final Set<? extends K> keys;
-
- /** Local. */
- private final boolean loc;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param keys Keys.
- */
- public ClearAllKeys(String cacheName, boolean async, boolean loc, Set<? extends K> keys) {
- super(cacheName, async);
- this.keys = keys;
- this.loc = loc;
- }
-
- /** {@inheritDoc} */
- @Override public Void call() {
- if (loc)
- cache().localClearAll(keys);
- else
- cache().clearAll(keys);
-
- return null;
- }
- }
-
- /**
- *
- */
- private static class InvokeTask<K, V, R> extends CacheTaskAdapter<K, V, R> {
- /** Key. */
- private final K key;
-
- /** Processor. */
- private final EntryProcessor<K, V, R> processor;
-
- /** Args. */
- private final Object[] args;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param key Key.
- * @param processor Processor.
- * @param args Args.
- */
- public InvokeTask(String cacheName, boolean async, K key, EntryProcessor<K, V, R> processor,
- Object[] args) {
- super(cacheName, async);
- this.args = args;
- this.key = key;
- this.processor = processor;
- }
-
- /** {@inheritDoc} */
- @Override public R call() throws Exception {
- return cache().invoke(key, processor, args);
- }
- }
-
- /**
- *
- */
- private static class InvokeAllTask<K, V, T> extends CacheTaskAdapter<K, V, Map<K, EntryProcessorResult<T>>> {
- /** Keys. */
- private final Set<? extends K> keys;
-
- /** Processor. */
- private final EntryProcessor<K, V, T> processor;
-
- /** Args. */
- private final Object[] args;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param keys Keys.
- * @param processor Processor.
- * @param args Args.
- */
- public InvokeAllTask(String cacheName, boolean async, Set<? extends K> keys,
- EntryProcessor<K, V, T> processor, Object[] args) {
- super(cacheName, async);
- this.args = args;
- this.keys = keys;
- this.processor = processor;
- }
-
- /** {@inheritDoc} */
- @Override public Map<K, EntryProcessorResult<T>> call() throws Exception {
- return cache().invokeAll(keys, processor, args);
- }
- }
-
- /**
- *
- */
- private static class CloseTask extends CacheTaskAdapter<Void, Void, Void> {
- /**
- * @param cacheName Cache name.
- * @param async Async.
- */
- public CloseTask(String cacheName, boolean async) {
- super(cacheName, async);
- }
-
- /** {@inheritDoc} */
- @Override public Void call() {
- cache().close();
-
- return null;
- }
- }
-
- /**
- *
- */
- private static class DestroyTask extends CacheTaskAdapter<Void, Void, Void> {
- /**
- * @param cacheName Cache name.
- * @param async Async.
- */
- public DestroyTask(String cacheName, boolean async) {
- super(cacheName, async);
- }
-
- /** {@inheritDoc} */
- @Override public Void call() {
- cache().destroy();
-
- return null;
- }
- }
-
- /**
- *
- */
- private static class IsClosedTask extends CacheTaskAdapter<Void, Void, Boolean> {
- /**
- * @param cacheName Cache name.
- * @param async Async.
- */
- public IsClosedTask(String cacheName, boolean async) {
- super(cacheName, async);
- }
-
- /** {@inheritDoc} */
- @Override public Boolean call() throws Exception {
- return cache().isClosed();
- }
- }
-
- /**
- *
- */
- private static class UnwrapTask<R> extends CacheTaskAdapter<Void, Void, R> {
- /** Clazz. */
- private final Class<R> clazz;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- * @param clazz Clazz.
- */
- public UnwrapTask(String cacheName, boolean async, Class<R> clazz) {
- super(cacheName, async);
- this.clazz = clazz;
- }
-
- /** {@inheritDoc} */
- @Override public R call() throws Exception {
- return cache().unwrap(clazz);
- }
- }
-
- /**
- *
- */
- private static abstract class CacheTaskAdapter<K, V, R> implements IgniteCallable<R> {
- /** Ignite. */
- @IgniteInstanceResource
- protected Ignite ignite;
-
- /** Cache name. */
- protected final String cacheName;
-
- /** Async. */
- protected final boolean async;
-
- /**
- * @param cacheName Cache name.
- * @param async Async.
- */
- public CacheTaskAdapter(String cacheName, boolean async) {
- this.async = async;
- this.cacheName = cacheName;
- }
-
- /**
- * Returns cache instance.
- */
- protected IgniteCache<K, V> cache() {
- IgniteCache<K, V> cache = ignite.cache(cacheName);
-
- return async ? cache.withAsync() : cache;
- }
- }
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
index 7425cb6..1876e24 100644
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-/*
+/*
* 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.
http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs b/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
index 198cfa6..03f7fb9 100644
--- a/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-/*
+/*
* 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.
http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
index a45f421..22d74c9 100644
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-/*
+/*
* 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.
http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
index db88e3b..1ebcf24 100644
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-/*
+/*
* 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.
[09/34] ignite git commit: Minor fixes + some debug statements in
scope of slow rebalancing investigation.
Posted by sb...@apache.org.
Minor fixes + some debug statements in scope of slow rebalancing investigation.
Squashed commit of the following:
commit ee4e65088114fd1e2dfa229f0853551c1ecb5e1d
Author: Alexey Goncharuk <al...@gmail.com>
Date: Thu Oct 1 14:45:36 2015 +0300
debug
commit 4d61a0f0c95b16f701993e5a3131ebdcf1beb67c
Author: Alexey Goncharuk <al...@gmail.com>
Date: Thu Oct 1 13:07:40 2015 +0300
debug
commit 663a2d993b9750b34eb8eef89cebf5cea4db8c6d
Author: Yakov Zhdanov <yz...@gridgain.com>
Date: Wed Sep 30 19:21:58 2015 +0300
debugging rebalance
commit 79bc2eb077cb3a8175c25864f2cebdc074372057
Author: Denis Magda <dm...@gridgain.com>
Date: Wed Sep 30 12:33:54 2015 +0300
slow rebalancing
commit a950de96624dcef64b6e8935c4f82ef7629035b3
Author: Denis Magda <dm...@gridgain.com>
Date: Wed Sep 30 12:30:47 2015 +0300
slow rebalancing
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4f95be25
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4f95be25
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4f95be25
Branch: refs/heads/ignite-1607
Commit: 4f95be256fc49d3d2d58076adb3e2d213822e24c
Parents: 6e3d1b1
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Mon Oct 5 11:26:10 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Mon Oct 5 11:26:10 2015 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheIoManager.java | 20 ++-
.../GridDhtPartitionDemandMessage.java | 3 +-
.../GridDhtPartitionSupplyMessage.java | 3 +-
.../GridDhtPartitionsExchangeFuture.java | 16 ++-
.../preloader/GridDhtPartitionsFullMessage.java | 13 +-
.../GridDhtPartitionsSingleMessage.java | 11 +-
.../communication/tcp/TcpCommunicationSpi.java | 22 ++-
.../dht/GridCacheDhtPreloadPerformanceTest.java | 133 +++++++++++++++++++
8 files changed, 193 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f95be25/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
index 421ec82..4000bbf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
@@ -28,6 +28,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
@@ -923,9 +924,12 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
", old=" + clsHandlers.get(key) + ", new=" + c + ']';
}
- if (log != null && log.isDebugEnabled())
- log.debug("Registered cache communication handler [cacheId=" + cacheId + ", type=" + type +
- ", msgIdx=" + msgIdx + ", handler=" + c + ']');
+ IgniteLogger log0 = log;
+
+ if (log0 != null && log0.isTraceEnabled())
+ log0.trace(
+ "Registered cache communication handler [cacheId=" + cacheId + ", type=" + type +
+ ", msgIdx=" + msgIdx + ", handler=" + c + ']');
}
/**
@@ -978,15 +982,17 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
*/
@SuppressWarnings({"unchecked"})
public void addOrderedHandler(Object topic, IgniteBiInClosure<UUID, ? extends GridCacheMessage> c) {
+ IgniteLogger log0 = log;
+
if (orderedHandlers.putIfAbsent(topic, c) == null) {
cctx.gridIO().addMessageListener(topic, new OrderedMessageListener(
(IgniteBiInClosure<UUID, GridCacheMessage>)c));
- if (log != null && log.isDebugEnabled())
- log.debug("Registered ordered cache communication handler [topic=" + topic + ", handler=" + c + ']');
+ if (log0 != null && log0.isTraceEnabled())
+ log0.trace("Registered ordered cache communication handler [topic=" + topic + ", handler=" + c + ']');
}
- else if (log != null)
- U.warn(log, "Failed to register ordered cache communication handler because it is already " +
+ else if (log0 != null)
+ U.warn(log0, "Failed to register ordered cache communication handler because it is already " +
"registered for this topic [topic=" + topic + ", handler=" + c + ']');
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f95be25/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
index b588372..863ec8f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
@@ -45,7 +45,6 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage {
private long updateSeq;
/** Partition. */
- @GridToStringInclude
@GridDirectCollection(int.class)
private Collection<Integer> parts;
@@ -330,4 +329,4 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage {
return S.toString(GridDhtPartitionDemandMessage.class, this, "partCnt", parts.size(), "super",
super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f95be25/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
index 3ccc5ae..cf10a13 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
@@ -404,7 +404,6 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
@Override public String toString() {
return S.toString(GridDhtPartitionSupplyMessage.class, this,
"size", size(),
- "parts", infos.keySet(),
"super", super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f95be25/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index a1b03c1..eaa5584 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -475,6 +475,9 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
busyLock.readLock().unlock();
}
+ // TODO remove
+ long inited;
+
/**
* Starts activity.
*
@@ -488,6 +491,8 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
if (isDone())
return;
+ inited = U.currentTimeMillis();
+
try {
// Wait for event to occur to make sure that discovery
// will return corresponding nodes.
@@ -800,7 +805,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
for (Map.Entry<IgniteTxKey, Collection<GridCacheMvccCandidate>> e : locks.entrySet())
U.warn(log, "Awaited locked entry [key=" + e.getKey() + ", mvcc=" + e.getValue() + ']');
-
+
dumpedObjects++;
}
}
@@ -1059,7 +1064,8 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
if (super.onDone(res, err) && !dummy && !forcePreload) {
if (log.isDebugEnabled())
- log.debug("Completed partition exchange [localNode=" + cctx.localNodeId() + ", exchange= " + this + ']');
+ log.debug("Completed partition exchange [localNode=" + cctx.localNodeId() + ", exchange= " + this +
+ "duration=" + duration() + ", durationFromInit=" + (U.currentTimeMillis() - inited) + ']');
initFut.onDone(err == null);
@@ -1190,6 +1196,8 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
if (match) {
boolean allReceived;
+ long start = U.currentTimeMillis();
+
synchronized (rcvdIds) {
if (rcvdIds.add(nodeId))
updatePartitionSingleMap(msg);
@@ -1197,6 +1205,8 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
allReceived = allReceived();
}
+ long end = U.currentTimeMillis();
+
// If got all replies, and initialization finished, and reply has not been sent yet.
if (allReceived && ready.get() && replied.compareAndSet(false, true)) {
spreadPartitions();
@@ -1206,7 +1216,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
else if (log.isDebugEnabled())
log.debug("Exchange future full map is not sent [allReceived=" + allReceived() +
", ready=" + ready + ", replied=" + replied.get() + ", init=" + init.get() +
- ", fut=" + this + ']');
+ ", fut=" + GridDhtPartitionsExchangeFuture.this + ", updateDur=" + (end - start) + ']');
}
}
});
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f95be25/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
index b91a2de..5429538 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
@@ -43,7 +43,7 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
/** */
@GridToStringInclude
@GridDirectTransient
- private Map<Integer, GridDhtPartitionFullMap> parts = new HashMap<>();
+ private Map<Integer, GridDhtPartitionFullMap> parts;
/** */
private byte[] partsBytes;
@@ -68,7 +68,6 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
@NotNull AffinityTopologyVersion topVer) {
super(id, lastVer);
- assert parts != null;
assert id == null || topVer.equals(id.topologyVersion());
this.topVer = topVer;
@@ -86,6 +85,9 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
* @param fullMap Full partitions map.
*/
public void addFullPartitionsMap(int cacheId, GridDhtPartitionFullMap fullMap) {
+ if (parts == null)
+ parts = new HashMap<>();
+
if (!parts.containsKey(cacheId))
parts.put(cacheId, fullMap);
}
@@ -95,7 +97,7 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
@Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx);
- if (parts != null)
+ if (parts != null && partsBytes == null)
partsBytes = ctx.marshaller().marshal(parts);
}
@@ -117,7 +119,7 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);
- if (partsBytes != null)
+ if (partsBytes != null && parts == null)
parts = ctx.marshaller().unmarshal(partsBytes, ldr);
}
@@ -200,4 +202,5 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
return S.toString(GridDhtPartitionsFullMessage.class, this, "partCnt", parts != null ? parts.size() : 0,
"super", super.toString());
}
-}
\ No newline at end of file
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f95be25/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
index 9b6dcf7..83fbb1a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
@@ -41,7 +41,7 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
/** Local partitions. */
@GridToStringInclude
@GridDirectTransient
- private Map<Integer, GridDhtPartitionMap> parts = new HashMap<>();
+ private Map<Integer, GridDhtPartitionMap> parts;
/** Serialized partitions. */
private byte[] partsBytes;
@@ -83,6 +83,9 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
* @param locMap Local partition map.
*/
public void addLocalPartitionMap(int cacheId, GridDhtPartitionMap locMap) {
+ if (parts == null)
+ parts = new HashMap<>();
+
parts.put(cacheId, locMap);
}
@@ -98,7 +101,7 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
@Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx);
- if (parts != null)
+ if (partsBytes == null && parts != null)
partsBytes = ctx.marshaller().marshal(parts);
}
@@ -106,7 +109,7 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);
- if (partsBytes != null)
+ if (partsBytes != null && parts == null)
parts = ctx.marshaller().unmarshal(partsBytes, ldr);
}
@@ -188,4 +191,4 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
@Override public String toString() {
return S.toString(GridDhtPartitionsSingleMessage.class, this, super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f95be25/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index c93d5af..5ea2c02 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -2050,11 +2050,21 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
if (locNode == null)
throw new IgniteCheckedException("Failed to create NIO client (local node is stopping)");
+ if (log.isDebugEnabled())
+ log.debug("Creating NIO client to node: " + node);
+
// If remote node has shared memory server enabled and has the same set of MACs
// then we are likely to run on the same host and shared memory communication could be tried.
if (shmemPort != null && U.sameMacs(locNode, node)) {
try {
- return createShmemClient(node, shmemPort);
+ GridCommunicationClient client = createShmemClient(
+ node,
+ shmemPort);
+
+ if (log.isDebugEnabled())
+ log.debug("Shmem client created: " + client);
+
+ return client;
}
catch (IgniteCheckedException e) {
if (e.hasCause(IpcOutOfSystemResourcesException.class))
@@ -2071,7 +2081,12 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
connectGate.enter();
try {
- return createTcpClient(node);
+ GridCommunicationClient client = createTcpClient(node);
+
+ if (log.isDebugEnabled())
+ log.debug("TCP client created: " + client);
+
+ return client;
}
finally {
connectGate.leave();
@@ -2453,9 +2468,6 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
throw errs;
}
- if (log.isDebugEnabled())
- log.debug("Created client: " + client);
-
return client;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f95be25/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadPerformanceTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadPerformanceTest.java
new file mode 100644
index 0000000..8b68829
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadPerformanceTest.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed.dht;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import java.util.concurrent.Callable;
+
+/**
+ * Test cases for partitioned cache {@link GridDhtPreloader preloader}.
+ */
+public class GridCacheDhtPreloadPerformanceTest extends GridCommonAbstractTest {
+ /** */
+ private static final int THREAD_CNT = 30;
+
+ /** IP finder. */
+ private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration c = super.getConfiguration(gridName);
+
+ CacheConfiguration cc = defaultCacheConfiguration();
+
+ cc.setCacheMode(
+ CacheMode.PARTITIONED);
+ cc.setWriteSynchronizationMode(
+ CacheWriteSynchronizationMode.FULL_SYNC);
+ cc.setRebalanceMode(
+ CacheRebalanceMode.SYNC);
+ cc.setAffinity(new RendezvousAffinityFunction(false, 1300));
+ cc.setBackups(2);
+
+ CacheConfiguration cc1 = defaultCacheConfiguration();
+
+ cc1.setName("cc1");
+ cc1.setCacheMode(
+ CacheMode.PARTITIONED);
+ cc1.setWriteSynchronizationMode(
+ CacheWriteSynchronizationMode.FULL_SYNC);
+ cc1.setRebalanceMode(
+ CacheRebalanceMode.SYNC);
+ cc1.setAffinity(
+ new RendezvousAffinityFunction(
+ false,
+ 1300));
+ cc1.setBackups(2);
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(ipFinder);
+
+ c.setDiscoverySpi(disco);
+
+ c.setIgfsThreadPoolSize(1);
+ c.setSystemThreadPoolSize(2);
+ c.setPublicThreadPoolSize(2);
+ c.setManagementThreadPoolSize(1);
+ c.setUtilityCachePoolSize(2);
+ c.setPeerClassLoadingThreadPoolSize(1);
+
+ c.setCacheConfiguration(cc, cc1);
+
+ TcpCommunicationSpi comm = new TcpCommunicationSpi();
+
+ comm.setSharedMemoryPort(-1);
+
+ c.setCommunicationSpi(comm);
+
+ return c;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testConcurrentStartPerformance() throws Exception {
+//
+// for (int i = 0; i < 10; i++) {
+// try {
+// startGrid(1);
+// startGrid(2);
+// startGrid(3);
+// }
+// finally {
+// G.stopAll(true);
+// }
+// }
+
+ multithreaded(
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ long start = U.currentTimeMillis();
+
+ Ignite grid = startGrid(Thread.currentThread().getName());
+
+ System.out.println(
+ ">>> Time to start: " + (U.currentTimeMillis() - start) +
+ ", topSize=" + grid.cluster().nodes().size());
+
+ return null;
+ }
+ },
+ THREAD_CNT);
+ }
+}
[26/34] ignite git commit: ignite-1168 Added support for metadata,
scan commands in rest.
Posted by sb...@apache.org.
ignite-1168 Added support for metadata, scan commands in rest.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/12235254
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/12235254
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/12235254
Branch: refs/heads/ignite-1607
Commit: 1223525478a80f527abcce7327a4d8b92c8b085a
Parents: a1e5cc5
Author: Andrey <an...@gridgain.com>
Authored: Mon Oct 12 15:51:48 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Oct 12 15:51:48 2015 +0700
----------------------------------------------------------------------
.../JettyRestProcessorAbstractSelfTest.java | 225 ++++++++
.../discovery/GridDiscoveryManager.java | 515 ++++++++++++++++++-
.../processors/cache/GridCacheProcessor.java | 48 +-
.../cache/query/GridCacheQueryManager.java | 74 ++-
.../cache/query/GridCacheSqlIndexMetadata.java | 7 +-
.../cache/query/GridCacheSqlMetadata.java | 22 +-
.../processors/rest/GridRestCommand.java | 8 +-
.../processors/rest/GridRestProcessor.java | 63 ++-
.../handlers/cache/GridCacheCommandHandler.java | 362 +++++++------
.../handlers/query/QueryCommandHandler.java | 195 +++++--
.../top/GridTopologyCommandHandler.java | 160 +++++-
.../rest/request/RestQueryRequest.java | 175 +++++++
.../rest/request/RestSqlQueryRequest.java | 125 -----
.../http/jetty/GridJettyJsonConfig.java | 158 +++++-
.../http/jetty/GridJettyRestHandler.java | 186 ++++---
15 files changed, 1849 insertions(+), 474 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
index ac0edff..bb6e67e 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
@@ -24,6 +24,7 @@ import java.io.Serializable;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -31,14 +32,24 @@ import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
+import net.sf.json.JSONNull;
import net.sf.json.JSONObject;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.cache.query.SqlQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
+import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.query.GridCacheSqlIndexMetadata;
+import org.apache.ignite.internal.processors.cache.query.GridCacheSqlMetadata;
import org.apache.ignite.internal.processors.rest.handlers.GridRestCommandHandler;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.testframework.GridTestUtils;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_JETTY_PORT;
@@ -907,6 +918,106 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
}
/**
+ * @param meta Metadata for Ignite cache.
+ * @throws Exception If failed.
+ */
+ private void testMetadata(GridCacheSqlMetadata meta) throws Exception {
+ Map<String, String> params = F.asMap("cmd", GridRestCommand.CACHE_METADATA.key());
+
+ if (meta.cacheName() != null)
+ params.put("cacheName", meta.cacheName());
+
+ String ret = content(params);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ info("Cache metadata result: " + ret);
+
+ jsonEquals(ret, pattern("\\{.+\\}", true));
+
+ Map res = (Map)JSONObject.fromObject(ret).get("response");
+
+ Collection types = (Collection)res.get("types");
+
+ assertNotNull(types);
+ assertEqualsCollections(meta.types(), types);
+
+ Map keyClasses = (Map)res.get("keyClasses");
+
+ assertNotNull(keyClasses);
+ assertTrue(meta.keyClasses().equals(keyClasses));
+
+ Map valClasses = (Map)res.get("valClasses");
+
+ assertNotNull(valClasses);
+ assertTrue(meta.valClasses().equals(valClasses));
+
+ Map fields = (Map)res.get("fields");
+
+ assertNotNull(fields);
+ assertTrue(meta.fields().equals(fields));
+
+ Map indexesByType = (Map)res.get("indexes");
+
+ assertNotNull(indexesByType);
+ assertEquals(meta.indexes().size(), indexesByType.size());
+
+ for (Map.Entry<String, Collection<GridCacheSqlIndexMetadata>> metaIndexes : meta.indexes().entrySet()) {
+ Collection<Map> indexes = (Collection<Map>)indexesByType.get(metaIndexes.getKey());
+
+ assertNotNull(indexes);
+ assertEquals(metaIndexes.getValue().size(), indexes.size());
+
+ for (final GridCacheSqlIndexMetadata metaIdx : metaIndexes.getValue()) {
+ Map idx = F.find(indexes, null, new IgnitePredicate<Map>() {
+ @Override public boolean apply(Map map) {
+ return metaIdx.name().equals(map.get("name"));
+ }
+ });
+
+ assertNotNull(idx);
+
+ assertEqualsCollections(metaIdx.fields(), (Collection)idx.get("fields"));
+ assertEqualsCollections(metaIdx.descendings(), (Collection)idx.get("descendings"));
+ assertEquals(metaIdx.unique(), idx.get("unique"));
+ }
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMetadataLocal() throws Exception {
+ GridCacheProcessor cacheProc = grid(0).context().cache();
+
+ for (IgniteInternalCache<?, ?> cache : cacheProc.caches()) {
+ if (CU.isSystemCache(cache.name()))
+ continue;
+
+ GridCacheSqlMetadata meta = F.first(cache.context().queries().sqlMetadata());
+
+ testMetadata(meta);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMetadataRemote() throws Exception {
+ CacheConfiguration<Integer, String> partialCacheCfg = new CacheConfiguration<>("partial");
+
+ partialCacheCfg.setIndexedTypes(Integer.class, String.class);
+ partialCacheCfg.setNodeFilter(new NodeIdFilter(grid(1).localNode().id()));
+
+ IgniteCacheProxy<Integer, String> c = (IgniteCacheProxy<Integer, String>)grid(1).createCache(partialCacheCfg);
+
+ GridCacheSqlMetadata meta = F.first(c.context().queries().sqlMetadata());
+
+ testMetadata(meta);
+ }
+
+ /**
* @throws Exception If failed.
*/
public void testTopology() throws Exception {
@@ -918,6 +1029,23 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
info("Topology command result: " + ret);
jsonEquals(ret, pattern("\\[\\{.+\\}\\]", true));
+
+ JSONObject json = JSONObject.fromObject(ret);
+
+ Collection<Map> nodes = (Collection)json.get("response");
+
+ assertEquals(GRID_CNT, nodes.size());
+
+ for (Map node : nodes) {
+ assertEquals(JSONNull.getInstance(), node.get("attributes"));
+ assertEquals(JSONNull.getInstance(), node.get("metrics"));
+
+ assertEquals("PARTITIONED", node.get("defaultCacheMode"));
+
+ Map caches = (Map)node.get("caches");
+
+ assertEquals(F.asMap("person", "PARTITIONED"), caches);
+ }
}
/**
@@ -1056,6 +1184,75 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
/**
* @throws Exception If failed.
*/
+ public void testQueryScan() throws Exception {
+ Map<String, String> params = new HashMap<>();
+ params.put("cmd", GridRestCommand.EXECUTE_SCAN_QUERY.key());
+ params.put("pageSize", "10");
+ params.put("cacheName", "person");
+
+ String ret = content(params);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ JSONObject json = JSONObject.fromObject(ret);
+
+ List items = (List)((Map)json.get("response")).get("items");
+
+ assertEquals(4, items.size());
+
+ assertFalse(queryCursorFound());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFilterQueryScan() throws Exception {
+ Map<String, String> params = new HashMap<>();
+ params.put("cmd", GridRestCommand.EXECUTE_SCAN_QUERY.key());
+ params.put("pageSize", "10");
+ params.put("cacheName", "person");
+ params.put("classname", ScanFilter.class.getName());
+
+ String ret = content(params);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ JSONObject json = JSONObject.fromObject(ret);
+
+ List items = (List)((Map)json.get("response")).get("items");
+
+ assertEquals(2, items.size());
+
+ assertFalse(queryCursorFound());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIncorrectFilterQueryScan() throws Exception {
+ Map<String, String> params = new HashMap<>();
+ params.put("cmd", GridRestCommand.EXECUTE_SCAN_QUERY.key());
+ params.put("pageSize", "10");
+ params.put("cacheName", "person");
+ params.put("classname", ScanFilter.class.getName() + 1);
+
+ String ret = content(params);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ JSONObject json = JSONObject.fromObject(ret);
+
+ String err = (String)json.get("error");
+
+ assertTrue(err.contains("Failed to find target class"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testQuery() throws Exception {
grid(0).cache(null).put("1", "1");
grid(0).cache(null).put("2", "2");
@@ -1323,4 +1520,32 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
return id;
}
}
+
+ /**
+ * Test filter for scan query.
+ */
+ public static class ScanFilter implements IgniteBiPredicate<Integer, Person> {
+ /** {@inheritDoc} */
+ @Override public boolean apply(Integer integer, Person person) {
+ return person.salary > 1000;
+ }
+ }
+
+ /** Filter by node ID. */
+ private static class NodeIdFilter implements IgnitePredicate<ClusterNode> {
+ /** */
+ private final UUID nid;
+
+ /**
+ * @param nid Node ID where cache should be started.
+ */
+ NodeIdFilter(UUID nid) {
+ this.nid = nid;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(ClusterNode n) {
+ return n.id().equals(nid);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 2ed4520..9e54f6f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -56,6 +56,7 @@ import org.apache.ignite.IgniteClientDisconnectedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteInterruptedException;
import org.apache.ignite.cache.CacheMetrics;
+import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cluster.ClusterMetrics;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.events.DiscoveryEvent;
@@ -299,16 +300,16 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
* @param cacheName Cache name.
* @param filter Cache filter.
* @param nearEnabled Near enabled flag.
- * @param loc {@code True} if cache is local.
+ * @param cacheMode Cache mode.
*/
public void setCacheFilter(
String cacheName,
IgnitePredicate<ClusterNode> filter,
boolean nearEnabled,
- boolean loc
+ CacheMode cacheMode
) {
if (!registeredCaches.containsKey(cacheName))
- registeredCaches.put(cacheName, new CachePredicate(filter, nearEnabled, loc));
+ registeredCaches.put(cacheName, new CachePredicate(filter, nearEnabled, cacheMode));
}
/**
@@ -1592,6 +1593,25 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
}
/**
+ * @param node Node to check.
+ * @return Cache names accessible on the given node.
+ */
+ public Map<String, CacheMode> nodeCaches(ClusterNode node) {
+ Map<String, CacheMode> caches = U.newHashMap(registeredCaches.size());
+
+ for (Map.Entry<String, CachePredicate> entry : registeredCaches.entrySet()) {
+ String cacheName = entry.getKey();
+
+ CachePredicate pred = entry.getValue();
+
+ if (pred != null && pred.cacheNode(node))
+ caches.put(cacheName, pred.cacheMode);
+ }
+
+ return caches;
+ }
+
+ /**
* Checks if cache with given name has at least one node with near cache enabled.
*
* @param cacheName Cache name.
@@ -2822,7 +2842,484 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
}
}
- /**
+ /** Cache for discovery collections. */
+ private class DiscoCache {
+ /** Remote nodes. */
+ private final List<ClusterNode> rmtNodes;
+
+ /** All nodes. */
+ private final List<ClusterNode> allNodes;
+
+ /** All nodes with at least one cache configured. */
+ @GridToStringInclude
+ private final Collection<ClusterNode> allNodesWithCaches;
+
+ /** All nodes with at least one cache configured. */
+ @GridToStringInclude
+ private final Collection<ClusterNode> rmtNodesWithCaches;
+
+ /** Cache nodes by cache name. */
+ @GridToStringInclude
+ private final Map<String, Collection<ClusterNode>> allCacheNodes;
+
+ /** Remote cache nodes by cache name. */
+ @GridToStringInclude
+ private final Map<String, Collection<ClusterNode>> rmtCacheNodes;
+
+ /** Cache nodes by cache name. */
+ @GridToStringInclude
+ private final Map<String, Collection<ClusterNode>> affCacheNodes;
+
+ /** Caches where at least one node has near cache enabled. */
+ @GridToStringInclude
+ private final Set<String> nearEnabledCaches;
+
+ /** Nodes grouped by version. */
+ private final NavigableMap<IgniteProductVersion, Collection<ClusterNode>> nodesByVer;
+
+ /** Daemon nodes. */
+ private final List<ClusterNode> daemonNodes;
+
+ /** Node map. */
+ private final Map<UUID, ClusterNode> nodeMap;
+
+ /** Local node. */
+ private final ClusterNode loc;
+
+ /** Highest node order. */
+ private final long maxOrder;
+
+ /**
+ * Cached alive nodes list. As long as this collection doesn't accept {@code null}s use {@link
+ * #maskNull(String)} before passing raw cache names to it.
+ */
+ private final ConcurrentMap<String, Collection<ClusterNode>> aliveCacheNodes;
+
+ /**
+ * Cached alive remote nodes list. As long as this collection doesn't accept {@code null}s use {@link
+ * #maskNull(String)} before passing raw cache names to it.
+ */
+ private final ConcurrentMap<String, Collection<ClusterNode>> aliveRmtCacheNodes;
+
+ /**
+ * Cached alive remote nodes with caches.
+ */
+ private final Collection<ClusterNode> aliveNodesWithCaches;
+
+ /**
+ * Cached alive server remote nodes with caches.
+ */
+ private final Collection<ClusterNode> aliveSrvNodesWithCaches;
+
+ /**
+ * Cached alive remote server nodes with caches.
+ */
+ private final Collection<ClusterNode> aliveRmtSrvNodesWithCaches;
+
+ /**
+ * @param loc Local node.
+ * @param rmts Remote nodes.
+ */
+ private DiscoCache(ClusterNode loc, Collection<ClusterNode> rmts) {
+ this.loc = loc;
+
+ rmtNodes = Collections.unmodifiableList(new ArrayList<>(F.view(rmts, daemonFilter)));
+
+ assert !rmtNodes.contains(loc) : "Remote nodes collection shouldn't contain local node" +
+ " [rmtNodes=" + rmtNodes + ", loc=" + loc + ']';
+
+ List<ClusterNode> all = new ArrayList<>(rmtNodes.size() + 1);
+
+ if (!loc.isDaemon())
+ all.add(loc);
+
+ all.addAll(rmtNodes);
+
+ Collections.sort(all, GridNodeOrderComparator.INSTANCE);
+
+ allNodes = Collections.unmodifiableList(all);
+
+ Map<String, Collection<ClusterNode>> cacheMap = new HashMap<>(allNodes.size(), 1.0f);
+ Map<String, Collection<ClusterNode>> rmtCacheMap = new HashMap<>(allNodes.size(), 1.0f);
+ Map<String, Collection<ClusterNode>> dhtNodesMap = new HashMap<>(allNodes.size(), 1.0f);
+ Collection<ClusterNode> nodesWithCaches = new HashSet<>(allNodes.size());
+ Collection<ClusterNode> rmtNodesWithCaches = new HashSet<>(allNodes.size());
+
+ aliveCacheNodes = new ConcurrentHashMap8<>(allNodes.size(), 1.0f);
+ aliveRmtCacheNodes = new ConcurrentHashMap8<>(allNodes.size(), 1.0f);
+ aliveNodesWithCaches = new ConcurrentSkipListSet<>();
+ aliveSrvNodesWithCaches = new ConcurrentSkipListSet<>();
+ aliveRmtSrvNodesWithCaches = new ConcurrentSkipListSet<>();
+ nodesByVer = new TreeMap<>();
+
+ long maxOrder0 = 0;
+
+ Set<String> nearEnabledSet = new HashSet<>();
+
+ for (ClusterNode node : allNodes) {
+ assert node.order() != 0 : "Invalid node order [locNode=" + loc + ", node=" + node + ']';
+
+ if (node.order() > maxOrder0)
+ maxOrder0 = node.order();
+
+ boolean hasCaches = false;
+
+ for (Map.Entry<String, CachePredicate> entry : registeredCaches.entrySet()) {
+ String cacheName = entry.getKey();
+
+ CachePredicate filter = entry.getValue();
+
+ if (filter.cacheNode(node)) {
+ nodesWithCaches.add(node);
+
+ if (!loc.id().equals(node.id()))
+ rmtNodesWithCaches.add(node);
+
+ addToMap(cacheMap, cacheName, node);
+
+ if (alive(node.id()))
+ addToMap(aliveCacheNodes, maskNull(cacheName), node);
+
+ if (filter.dataNode(node))
+ addToMap(dhtNodesMap, cacheName, node);
+
+ if (filter.nearNode(node))
+ nearEnabledSet.add(cacheName);
+
+ if (!loc.id().equals(node.id())) {
+ addToMap(rmtCacheMap, cacheName, node);
+
+ if (alive(node.id()))
+ addToMap(aliveRmtCacheNodes, maskNull(cacheName), node);
+ }
+
+ hasCaches = true;
+ }
+ }
+
+ if (hasCaches) {
+ if (alive(node.id())) {
+ aliveNodesWithCaches.add(node);
+
+ if (!CU.clientNode(node)) {
+ aliveSrvNodesWithCaches.add(node);
+
+ if (!loc.id().equals(node.id()))
+ aliveRmtSrvNodesWithCaches.add(node);
+ }
+ }
+ }
+
+ IgniteProductVersion nodeVer = U.productVersion(node);
+
+ // Create collection for this version if it does not exist.
+ Collection<ClusterNode> nodes = nodesByVer.get(nodeVer);
+
+ if (nodes == null) {
+ nodes = new ArrayList<>(allNodes.size());
+
+ nodesByVer.put(nodeVer, nodes);
+ }
+
+ nodes.add(node);
+ }
+
+ // Need second iteration to add this node to all previous node versions.
+ for (ClusterNode node : allNodes) {
+ IgniteProductVersion nodeVer = U.productVersion(node);
+
+ // Get all versions lower or equal node's version.
+ NavigableMap<IgniteProductVersion, Collection<ClusterNode>> updateView =
+ nodesByVer.headMap(nodeVer, false);
+
+ for (Collection<ClusterNode> prevVersions : updateView.values())
+ prevVersions.add(node);
+ }
+
+ maxOrder = maxOrder0;
+
+ allCacheNodes = Collections.unmodifiableMap(cacheMap);
+ rmtCacheNodes = Collections.unmodifiableMap(rmtCacheMap);
+ affCacheNodes = Collections.unmodifiableMap(dhtNodesMap);
+ allNodesWithCaches = Collections.unmodifiableCollection(nodesWithCaches);
+ this.rmtNodesWithCaches = Collections.unmodifiableCollection(rmtNodesWithCaches);
+ nearEnabledCaches = Collections.unmodifiableSet(nearEnabledSet);
+
+ daemonNodes = Collections.unmodifiableList(new ArrayList<>(
+ F.view(F.concat(false, loc, rmts), F0.not(daemonFilter))));
+
+ Map<UUID, ClusterNode> nodeMap = new HashMap<>(allNodes().size() + daemonNodes.size(), 1.0f);
+
+ for (ClusterNode n : F.concat(false, allNodes(), daemonNodes()))
+ nodeMap.put(n.id(), n);
+
+ this.nodeMap = nodeMap;
+ }
+
+ /**
+ * Adds node to map.
+ *
+ * @param cacheMap Map to add to.
+ * @param cacheName Cache name.
+ * @param rich Node to add
+ */
+ private void addToMap(Map<String, Collection<ClusterNode>> cacheMap, String cacheName, ClusterNode rich) {
+ Collection<ClusterNode> cacheNodes = cacheMap.get(cacheName);
+
+ if (cacheNodes == null) {
+ cacheNodes = new ArrayList<>(allNodes.size());
+
+ cacheMap.put(cacheName, cacheNodes);
+ }
+
+ cacheNodes.add(rich);
+ }
+
+ /** @return Local node. */
+ ClusterNode localNode() {
+ return loc;
+ }
+
+ /** @return Remote nodes. */
+ Collection<ClusterNode> remoteNodes() {
+ return rmtNodes;
+ }
+
+ /** @return All nodes. */
+ Collection<ClusterNode> allNodes() {
+ return allNodes;
+ }
+
+ /**
+ * Gets collection of nodes which have version equal or greater than {@code ver}.
+ *
+ * @param ver Version to check.
+ * @return Collection of nodes with version equal or greater than {@code ver}.
+ */
+ Collection<ClusterNode> elderNodes(IgniteProductVersion ver) {
+ Map.Entry<IgniteProductVersion, Collection<ClusterNode>> entry = nodesByVer.ceilingEntry(ver);
+
+ if (entry == null)
+ return Collections.emptyList();
+
+ return entry.getValue();
+ }
+
+ /**
+ * @return Versions map.
+ */
+ NavigableMap<IgniteProductVersion, Collection<ClusterNode>> versionsMap() {
+ return nodesByVer;
+ }
+
+ /**
+ * Gets collection of nodes with at least one cache configured.
+ *
+ * @param topVer Topology version (maximum allowed node order).
+ * @return Collection of nodes.
+ */
+ Collection<ClusterNode> allNodesWithCaches(final long topVer) {
+ return filter(topVer, allNodesWithCaches);
+ }
+
+ /**
+ * Gets all nodes that have cache with given name.
+ *
+ * @param cacheName Cache name.
+ * @param topVer Topology version.
+ * @return Collection of nodes.
+ */
+ Collection<ClusterNode> cacheNodes(@Nullable String cacheName, final long topVer) {
+ return filter(topVer, allCacheNodes.get(cacheName));
+ }
+
+ /**
+ * Gets all remote nodes that have cache with given name.
+ *
+ * @param cacheName Cache name.
+ * @param topVer Topology version.
+ * @return Collection of nodes.
+ */
+ Collection<ClusterNode> remoteCacheNodes(@Nullable String cacheName, final long topVer) {
+ return filter(topVer, rmtCacheNodes.get(cacheName));
+ }
+
+ /**
+ * Gets all remote nodes that have at least one cache configured.
+ *
+ * @param topVer Topology version.
+ * @return Collection of nodes.
+ */
+ Collection<ClusterNode> remoteCacheNodes(final long topVer) {
+ return filter(topVer, rmtNodesWithCaches);
+ }
+
+ /**
+ * Gets all nodes that have cache with given name and should participate in affinity calculation. With
+ * partitioned cache nodes with near-only cache do not participate in affinity node calculation.
+ *
+ * @param cacheName Cache name.
+ * @param topVer Topology version.
+ * @return Collection of nodes.
+ */
+ Collection<ClusterNode> cacheAffinityNodes(@Nullable String cacheName, final long topVer) {
+ return filter(topVer, affCacheNodes.get(cacheName));
+ }
+
+ /**
+ * Gets all alive nodes that have cache with given name.
+ *
+ * @param cacheName Cache name.
+ * @param topVer Topology version.
+ * @return Collection of nodes.
+ */
+ Collection<ClusterNode> aliveCacheNodes(@Nullable String cacheName, final long topVer) {
+ return filter(topVer, aliveCacheNodes.get(maskNull(cacheName)));
+ }
+
+ /**
+ * Gets all alive remote nodes that have cache with given name.
+ *
+ * @param cacheName Cache name.
+ * @param topVer Topology version.
+ * @return Collection of nodes.
+ */
+ Collection<ClusterNode> aliveRemoteCacheNodes(@Nullable String cacheName, final long topVer) {
+ return filter(topVer, aliveRmtCacheNodes.get(maskNull(cacheName)));
+ }
+
+ /**
+ * Gets all alive remote server nodes with at least one cache configured.
+ *
+ * @param topVer Topology version.
+ * @return Collection of nodes.
+ */
+ Collection<ClusterNode> aliveRemoteServerNodesWithCaches(final long topVer) {
+ return filter(topVer, aliveRmtSrvNodesWithCaches);
+ }
+
+ /**
+ * Gets all alive server nodes with at least one cache configured.
+ *
+ * @param topVer Topology version.
+ * @return Collection of nodes.
+ */
+ Collection<ClusterNode> aliveServerNodesWithCaches(final long topVer) {
+ return filter(topVer, aliveSrvNodesWithCaches);
+ }
+
+ /**
+ * Gets all alive remote nodes with at least one cache configured.
+ *
+ * @param topVer Topology version.
+ * @return Collection of nodes.
+ */
+ Collection<ClusterNode> aliveNodesWithCaches(final long topVer) {
+ return filter(topVer, aliveNodesWithCaches);
+ }
+
+ /**
+ * Checks if cache with given name has at least one node with near cache enabled.
+ *
+ * @param cacheName Cache name.
+ * @return {@code True} if cache with given name has at least one node with near cache enabled.
+ */
+ boolean hasNearCache(@Nullable String cacheName) {
+ return nearEnabledCaches.contains(cacheName);
+ }
+
+ /**
+ * Removes left node from cached alives lists.
+ *
+ * @param leftNode Left node.
+ */
+ void updateAlives(ClusterNode leftNode) {
+ if (leftNode.order() > maxOrder)
+ return;
+
+ filterNodeMap(aliveCacheNodes, leftNode);
+
+ filterNodeMap(aliveRmtCacheNodes, leftNode);
+
+ aliveNodesWithCaches.remove(leftNode);
+ aliveSrvNodesWithCaches.remove(leftNode);
+ aliveRmtSrvNodesWithCaches.remove(leftNode);
+ }
+
+ /**
+ * Creates a copy of nodes map without the given node.
+ *
+ * @param map Map to copy.
+ * @param exclNode Node to exclude.
+ */
+ private void filterNodeMap(ConcurrentMap<String, Collection<ClusterNode>> map, final ClusterNode exclNode) {
+ for (String cacheName : registeredCaches.keySet()) {
+ String maskedName = maskNull(cacheName);
+
+ while (true) {
+ Collection<ClusterNode> oldNodes = map.get(maskedName);
+
+ if (oldNodes == null || oldNodes.isEmpty())
+ break;
+
+ Collection<ClusterNode> newNodes = new ArrayList<>(oldNodes);
+
+ if (!newNodes.remove(exclNode))
+ break;
+
+ if (map.replace(maskedName, oldNodes, newNodes))
+ break;
+ }
+ }
+ }
+
+ /**
+ * Replaces {@code null} with {@code NULL_CACHE_NAME}.
+ *
+ * @param cacheName Cache name.
+ * @return Masked name.
+ */
+ private String maskNull(@Nullable String cacheName) {
+ return cacheName == null ? NULL_CACHE_NAME : cacheName;
+ }
+
+ /**
+ * @param topVer Topology version.
+ * @param nodes Nodes.
+ * @return Filtered collection (potentially empty, but never {@code null}).
+ */
+ private Collection<ClusterNode> filter(final long topVer, @Nullable Collection<ClusterNode> nodes) {
+ if (nodes == null)
+ return Collections.emptyList();
+
+ // If no filtering needed, return original collection.
+ return nodes.isEmpty() || topVer < 0 || topVer >= maxOrder ?
+ nodes :
+ F.view(nodes, new P1<ClusterNode>() {
+ @Override public boolean apply(ClusterNode node) {
+ return node.order() <= topVer;
+ }
+ });
+ }
+
+ /** @return Daemon nodes. */
+ Collection<ClusterNode> daemonNodes() {
+ return daemonNodes;
+ }
+
+ /**
+ * @param id Node ID.
+ * @return Node.
+ */
+ @Nullable ClusterNode node(UUID id) {
+ return nodeMap.get(id);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(DiscoCache.class, this, "allNodesWithDaemons", U.toShortString(allNodes));
+ }
+ } /**
* Cache predicate.
*/
private static class CachePredicate {
@@ -2832,8 +3329,8 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
/** If near cache is enabled on data nodes. */
private final boolean nearEnabled;
- /** Flag indicating if cache is local. */
- private final boolean loc;
+ /** Cache mode. */
+ private final CacheMode cacheMode;
/** Collection of client near nodes. */
private final ConcurrentHashMap<UUID, Boolean> clientNodes;
@@ -2841,14 +3338,14 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
/**
* @param cacheFilter Cache filter.
* @param nearEnabled Near enabled flag.
- * @param loc {@code True} if cache is local.
+ * @param cacheMode Cache mode.
*/
- private CachePredicate(IgnitePredicate<ClusterNode> cacheFilter, boolean nearEnabled, boolean loc) {
+ private CachePredicate(IgnitePredicate<ClusterNode> cacheFilter, boolean nearEnabled, CacheMode cacheMode) {
assert cacheFilter != null;
this.cacheFilter = cacheFilter;
this.nearEnabled = nearEnabled;
- this.loc = loc;
+ this.cacheMode = cacheMode;
clientNodes = new ConcurrentHashMap<>();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index daa4475..736e630 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -689,7 +689,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
cfg.getName(),
cfg.getNodeFilter(),
cfg.getNearConfiguration() != null && cfg.getCacheMode() == PARTITIONED,
- cfg.getCacheMode() == LOCAL);
+ cfg.getCacheMode());
ctx.discovery().addClientNode(cfg.getName(),
ctx.localNodeId(),
@@ -1941,7 +1941,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
req.cacheName(),
ccfg.getNodeFilter(),
ccfg.getNearConfiguration() != null,
- ccfg.getCacheMode() == LOCAL);
+ ccfg.getCacheMode());
}
}
else {
@@ -1968,7 +1968,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
req.cacheName(),
ccfg.getNodeFilter(),
ccfg.getNearConfiguration() != null,
- ccfg.getCacheMode() == LOCAL);
+ ccfg.getCacheMode());
}
}
}
@@ -2468,7 +2468,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
ccfg.getName(),
ccfg.getNodeFilter(),
ccfg.getNearConfiguration() != null,
- ccfg.getCacheMode() == LOCAL);
+ ccfg.getCacheMode());
ctx.discovery().addClientNode(req.cacheName(),
req.initiatingNodeId(),
@@ -3482,6 +3482,46 @@ public class GridCacheProcessor extends GridProcessorAdapter {
/**
*
*/
+ @SuppressWarnings("ExternalizableWithoutPublicNoArgConstructor")
+ private class TemplateConfigurationFuture extends GridFutureAdapter<Object> {
+ /** Start ID. */
+ @GridToStringInclude
+ private IgniteUuid deploymentId;
+
+ /** Cache name. */
+ private String cacheName;
+
+ /**
+ * @param cacheName Cache name.
+ * @param deploymentId Deployment ID.
+ */
+ private TemplateConfigurationFuture(String cacheName, IgniteUuid deploymentId) {
+ this.deploymentId = deploymentId;
+ this.cacheName = cacheName;
+ }
+
+ /**
+ * @return Start ID.
+ */
+ public IgniteUuid deploymentId() {
+ return deploymentId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean onDone(@Nullable Object res, @Nullable Throwable err) {
+ // Make sure to remove future before completion.
+ pendingTemplateFuts.remove(maskNull(cacheName), this);
+
+ return super.onDone(res, err);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(TemplateConfigurationFuture.class, this);
+ }
+ } /**
+ *
+ */
private static class LocalAffinityFunction implements AffinityFunction {
/** */
private static final long serialVersionUID = 0L;
http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 25ace1b..698b035 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -2229,6 +2229,26 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
}
/** {@inheritDoc} */
+ @Override public Map<String, String> keyClasses() {
+ return keyClasses;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<String, String> valClasses() {
+ return valClasses;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<String, Map<String, String>> fields() {
+ return fields;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<String, Collection<GridCacheSqlIndexMetadata>> indexes() {
+ return indexes;
+ }
+
+ /** {@inheritDoc} */
@Override public Collection<GridCacheSqlIndexMetadata> indexes(String type) {
return indexes.get(type);
}
@@ -2319,6 +2339,11 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
}
/** {@inheritDoc} */
+ @Override public Collection<String> descendings() {
+ return descendings;
+ }
+
+ /** {@inheritDoc} */
@Override public boolean unique() {
return unique;
}
@@ -2687,15 +2712,13 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
* Cached result.
*/
private abstract static class CachedResult<R> extends GridFutureAdapter<IgniteSpiCloseableIterator<R>> {
+ /** Absolute position of each recipient. */
+ private final Map<Object, QueueIterator> recipients = new GridLeanMap<>(1);
/** */
private CircularQueue<R> queue;
-
/** */
private int pruned;
- /** Absolute position of each recipient. */
- private final Map<Object, QueueIterator> recipients = new GridLeanMap<>(1);
-
/**
* @param rcpt ID of the recipient.
*/
@@ -3059,6 +3082,47 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
}
/**
+ *
+ */
+ private class OffheapIteratorClosure
+ extends CX2<T2<Long, Integer>, T2<Long, Integer>, IgniteBiTuple<K, V>> {
+ /** */
+ private static final long serialVersionUID = 7410163202728985912L;
+
+ /** */
+ private IgniteBiPredicate<K, V> filter;
+
+ /** */
+ private boolean keepPortable;
+
+ /**
+ * @param filter Filter.
+ * @param keepPortable Keep portable flag.
+ */
+ private OffheapIteratorClosure(
+ @Nullable IgniteBiPredicate<K, V> filter,
+ boolean keepPortable) {
+ assert filter != null;
+
+ this.filter = filter;
+ this.keepPortable = keepPortable;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public IgniteBiTuple<K, V> applyx(T2<Long, Integer> keyPtr,
+ T2<Long, Integer> valPtr)
+ throws IgniteCheckedException {
+ LazyOffheapEntry e = new LazyOffheapEntry(keyPtr, valPtr);
+
+ K key = (K)cctx.unwrapPortableIfNeeded(e.key(), keepPortable);
+ V val = (V)cctx.unwrapPortableIfNeeded(e.value(), keepPortable);
+
+ if (!filter.apply(key, val))
+ return null;
+
+ return new IgniteBiTuple<>(e.key(), (V)cctx.unwrapTemporary(e.value()));
+ }
+ } /**
* Creates user's SQL fields query for given clause. For more information refer to {@link CacheQuery}
* documentation.
*
@@ -3078,4 +3142,4 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
false,
keepPortable);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlIndexMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlIndexMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlIndexMetadata.java
index 6b3ed68..539a156 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlIndexMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlIndexMetadata.java
@@ -51,9 +51,14 @@ public interface GridCacheSqlIndexMetadata extends Externalizable {
public boolean descending(String field);
/**
+ * @return Descendings.
+ */
+ public Collection<String> descendings();
+
+ /**
* Gets whether this is a unique index.
*
* @return {@code True} if index is unique, {@code false} otherwise.
*/
public boolean unique();
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlMetadata.java
index dae034c..724962e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlMetadata.java
@@ -78,6 +78,26 @@ public interface GridCacheSqlMetadata extends Externalizable {
@Nullable public Map<String, String> fields(String type);
/**
+ * @return Key classes.
+ */
+ public Map<String, String> keyClasses();
+
+ /**
+ * @return Value classes.
+ */
+ public Map<String, String> valClasses();
+
+ /**
+ * @return Fields.
+ */
+ public Map<String, Map<String, String>> fields();
+
+ /**
+ * @return Indexes.
+ */
+ public Map<String, Collection<GridCacheSqlIndexMetadata>> indexes();
+
+ /**
* Gets descriptors of indexes created for provided type.
* See {@link GridCacheSqlIndexMetadata} javadoc for more information.
*
@@ -86,4 +106,4 @@ public interface GridCacheSqlMetadata extends Externalizable {
* @see GridCacheSqlIndexMetadata
*/
public Collection<GridCacheSqlIndexMetadata> indexes(String type);
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
index 4f9b3ae..8282d3a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
@@ -96,6 +96,9 @@ public enum GridRestCommand {
/** Cache size. */
CACHE_SIZE("size"),
+ /** Cache metadata. */
+ CACHE_METADATA("metadata"),
+
/** Increment. */
ATOMIC_INCREMENT("incr"),
@@ -141,6 +144,9 @@ public enum GridRestCommand {
/** Execute sql fields query. */
EXECUTE_SQL_FIELDS_QUERY("qryfldexe"),
+ /** Execute scan query. */
+ EXECUTE_SCAN_QUERY("qryscanexe"),
+
/** Fetch query results. */
FETCH_SQL_QUERY("qryfetch"),
@@ -193,4 +199,4 @@ public enum GridRestCommand {
public String key() {
return key;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
index d54c8bb..df79232 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
@@ -51,7 +51,7 @@ import org.apache.ignite.internal.processors.rest.protocols.tcp.GridTcpRestProto
import org.apache.ignite.internal.processors.rest.request.GridRestCacheRequest;
import org.apache.ignite.internal.processors.rest.request.GridRestRequest;
import org.apache.ignite.internal.processors.rest.request.GridRestTaskRequest;
-import org.apache.ignite.internal.processors.rest.request.RestSqlQueryRequest;
+import org.apache.ignite.internal.processors.rest.request.RestQueryRequest;
import org.apache.ignite.internal.processors.security.SecurityContext;
import org.apache.ignite.internal.util.GridSpinReadWriteLock;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
@@ -565,6 +565,53 @@ public class GridRestProcessor extends GridProcessorAdapter {
}
/**
+ * Applies {@link ConnectorMessageInterceptor}
+ * from {@link ConnectorConfiguration#getMessageInterceptor()} ()}
+ * to all user parameters in the request.
+ *
+ * @param req Client request.
+ */
+ private void interceptRequest(GridRestRequest req) {
+ ConnectorMessageInterceptor interceptor = config().getMessageInterceptor();
+
+ if (interceptor == null)
+ return;
+
+ if (req instanceof GridRestCacheRequest) {
+ GridRestCacheRequest req0 = (GridRestCacheRequest) req;
+
+ req0.key(interceptor.onReceive(req0.key()));
+ req0.value(interceptor.onReceive(req0.value()));
+ req0.value2(interceptor.onReceive(req0.value2()));
+
+ Map<Object, Object> oldVals = req0.values();
+
+ if (oldVals != null) {
+ Map<Object, Object> newVals = U.newHashMap(oldVals.size());
+
+ for (Map.Entry<Object, Object> e : oldVals.entrySet())
+ newVals.put(interceptor.onReceive(e.getKey()), interceptor.onReceive(e.getValue()));
+
+ req0.values(U.sealMap(newVals));
+ }
+ }
+ else if (req instanceof GridRestTaskRequest) {
+ GridRestTaskRequest req0 = (GridRestTaskRequest) req;
+
+ List<Object> oldParams = req0.params();
+
+ if (oldParams != null) {
+ Collection<Object> newParams = new ArrayList<>(oldParams.size());
+
+ for (Object o : oldParams)
+ newParams.add(interceptor.onReceive(o));
+
+ req0.params(U.sealList(newParams));
+ }
+ }
+ }
+
+ /**
* Applies {@link ConnectorMessageInterceptor} from
* {@link ConnectorConfiguration#getMessageInterceptor()}
* to all user objects in the response.
@@ -609,9 +656,7 @@ public class GridRestProcessor extends GridProcessorAdapter {
break;
}
}
- }
-
- /**
+ } /**
* Applies interceptor to a response object.
* Specially handler {@link Map} and {@link Collection} responses.
*
@@ -715,10 +760,11 @@ public class GridRestProcessor extends GridProcessorAdapter {
case EXECUTE_SQL_QUERY:
case EXECUTE_SQL_FIELDS_QUERY:
+ case EXECUTE_SCAN_QUERY:
case CLOSE_SQL_QUERY:
case FETCH_SQL_QUERY:
perm = SecurityPermission.CACHE_READ;
- name = ((RestSqlQueryRequest)req).cacheName();
+ name = ((RestQueryRequest)req).cacheName();
break;
@@ -764,6 +810,7 @@ public class GridRestProcessor extends GridProcessorAdapter {
case CACHE_METRICS:
case CACHE_SIZE:
+ case CACHE_METADATA:
case TOPOLOGY:
case NODE:
case VERSION:
@@ -884,15 +931,13 @@ public class GridRestProcessor extends GridProcessorAdapter {
/** Session token id. */
private final UUID sesId;
-
- /** Security context. */
- private volatile SecurityContext secCtx;
-
/**
* Time when session is used last time.
* If this time was set at TIMEDOUT_FLAG, then it should never be changed.
*/
private final AtomicLong lastTouchTime = new AtomicLong(U.currentTimeMillis());
+ /** Security context. */
+ private volatile SecurityContext secCtx;
/**
* @param clientId Client ID.
http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
index 9d32c17..1bbc754 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
@@ -40,6 +40,7 @@ import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.query.GridCacheSqlMetadata;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.rest.GridRestCommand;
import org.apache.ignite.internal.processors.rest.GridRestResponse;
@@ -73,6 +74,7 @@ import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_G
import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_GET_AND_PUT_IF_ABSENT;
import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_GET_AND_REMOVE;
import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_GET_AND_REPLACE;
+import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_METADATA;
import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_METRICS;
import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_PREPEND;
import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_PUT;
@@ -119,7 +121,8 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
CACHE_APPEND,
CACHE_PREPEND,
CACHE_METRICS,
- CACHE_SIZE
+ CACHE_SIZE,
+ CACHE_METADATA
);
/** Requests with required parameter {@code key}. */
@@ -151,11 +154,6 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
super(ctx);
}
- /** {@inheritDoc} */
- @Override public Collection<GridRestCommand> supportedCommands() {
- return SUPPORTED_COMMANDS;
- }
-
/**
* Retrieves cache flags from corresponding bits.
*
@@ -172,6 +170,153 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
return false;
}
+ /**
+ * Handles append and prepend commands.
+ *
+ * @param ctx Kernal context.
+ * @param cache Cache.
+ * @param key Key.
+ * @param req Request.
+ * @param prepend Whether to prepend.
+ * @return Future of operation result.
+ * @throws IgniteCheckedException In case of any exception.
+ */
+ private static IgniteInternalFuture<?> appendOrPrepend(
+ final GridKernalContext ctx,
+ final IgniteInternalCache<Object, Object> cache,
+ final Object key, GridRestCacheRequest req, final boolean prepend) throws IgniteCheckedException {
+ assert cache != null;
+ assert key != null;
+ assert req != null;
+
+ final Object val = req.value();
+
+ if (val == null)
+ throw new IgniteCheckedException(GridRestCommandHandlerAdapter.missingParameter("val"));
+
+ return ctx.closure().callLocalSafe(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ try (IgniteInternalTx tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+ Object curVal = cache.get(key);
+
+ if (curVal == null)
+ return false;
+
+ // Modify current value with appendix one.
+ Object newVal = appendOrPrepend(curVal, val, !prepend);
+
+ // Put new value asynchronously.
+ cache.put(key, newVal);
+
+ tx.commit();
+ }
+
+ return true;
+ }
+ }, false);
+ }
+
+ /**
+ * Append or prepend new value to the current one.
+ *
+ * @param origVal Original value.
+ * @param appendVal Appendix value to add to the original one.
+ * @param appendPlc Append or prepend policy flag.
+ * @return Resulting value.
+ * @throws IgniteCheckedException In case of grid exceptions.
+ */
+ private static Object appendOrPrepend(Object origVal, Object appendVal, boolean appendPlc) throws IgniteCheckedException {
+ // Strings.
+ if (appendVal instanceof String && origVal instanceof String)
+ return appendPlc ? origVal + (String)appendVal : (String)appendVal + origVal;
+
+ // Maps.
+ if (appendVal instanceof Map && origVal instanceof Map) {
+ Map<Object, Object> origMap = (Map<Object, Object>)origVal;
+ Map<Object, Object> appendMap = (Map<Object, Object>)appendVal;
+
+ Map<Object, Object> map = X.cloneObject(origMap, false, true);
+
+ if (appendPlc)
+ map.putAll(appendMap); // Append.
+ else {
+ map.clear();
+ map.putAll(appendMap); // Prepend.
+ map.putAll(origMap);
+ }
+
+ for (Map.Entry<Object, Object> e : appendMap.entrySet()) // Remove zero-valued entries.
+ if (e.getValue() == null && map.get(e.getKey()) == null)
+ map.remove(e.getKey());
+
+ return map;
+ }
+
+ // Generic collection.
+ if (appendVal instanceof Collection<?> && origVal instanceof Collection<?>) {
+ Collection<Object> origCol = (Collection<Object>)origVal;
+ Collection<Object> appendCol = (Collection<Object>)appendVal;
+
+ Collection<Object> col = X.cloneObject(origCol, false, true);
+
+ if (appendPlc)
+ col.addAll(appendCol); // Append.
+ else {
+ col.clear();
+ col.addAll(appendCol); // Prepend.
+ col.addAll(origCol);
+ }
+
+ return col;
+ }
+
+ throw new IgniteCheckedException("Incompatible types [appendVal=" + appendVal + ", old=" + origVal + ']');
+ }
+
+ /**
+ * Creates a transformation function from {@link CacheCommand}'s results into {@link GridRestResponse}.
+ *
+ * @param c Cache instance to obtain affinity data.
+ * @param key Affinity key for previous operation.
+ * @return Rest response.
+ */
+ private static IgniteClosure<IgniteInternalFuture<?>, GridRestResponse> resultWrapper(
+ final IgniteInternalCache<Object, Object> c, @Nullable final Object key) {
+ return new CX1<IgniteInternalFuture<?>, GridRestResponse>() {
+ @Override public GridRestResponse applyx(IgniteInternalFuture<?> f) throws IgniteCheckedException {
+ GridCacheRestResponse resp = new GridCacheRestResponse();
+
+ resp.setResponse(f.get());
+
+ if (key != null)
+ resp.setAffinityNodeId(c.cache().affinity().mapKeyToNode(key).id().toString());
+
+ return resp;
+ }
+ };
+ }
+
+ /**
+ * @param ignite Grid instance.
+ * @param cacheName Name of the cache.
+ * @return Instance on the named cache.
+ * @throws IgniteCheckedException If cache not found.
+ */
+ private static IgniteInternalCache<Object, Object> cache(Ignite ignite, String cacheName) throws IgniteCheckedException {
+ IgniteInternalCache<Object, Object> cache = ((IgniteKernal)ignite).getCache(cacheName);
+
+ if (cache == null)
+ throw new IgniteCheckedException(
+ "Failed to find cache for given cache name (null for default cache): " + cacheName);
+
+ return cache;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<GridRestCommand> supportedCommands() {
+ return SUPPORTED_COMMANDS;
+ }
+
/** {@inheritDoc} */
@Override public IgniteInternalFuture<GridRestResponse> handleAsync(final GridRestRequest req) {
assert req instanceof GridRestCacheRequest : "Invalid command for topology handler: " + req;
@@ -224,6 +369,25 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
break;
}
+ case CACHE_METADATA: {
+ IgniteInternalCache<?, ?> cache = ctx.cache().cache(cacheName);
+
+ if (cache != null) {
+ GridCacheSqlMetadata res = F.first(cache.context().queries().sqlMetadata());
+
+ fut = new GridFinishedFuture<>(new GridRestResponse(res));
+ }
+ else {
+ ClusterGroup prj = ctx.grid().cluster().forDataNodes(cacheName);
+
+ ctx.task().setThreadContext(TC_NO_FAILOVER, true);
+
+ fut = ctx.closure().callAsync(BALANCE, new MetadataCommand(cacheName), prj.nodes());
+ }
+
+ break;
+ }
+
case CACHE_CONTAINS_KEYS: {
fut = executeCommand(req.destinationId(), req.clientId(), cacheName, skipStore, key,
new ContainsKeysCommand(getKeys(req0)));
@@ -545,138 +709,12 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
}
}
- /**
- * Handles append and prepend commands.
- *
- * @param ctx Kernal context.
- * @param cache Cache.
- * @param key Key.
- * @param req Request.
- * @param prepend Whether to prepend.
- * @return Future of operation result.
- * @throws IgniteCheckedException In case of any exception.
- */
- private static IgniteInternalFuture<?> appendOrPrepend(
- final GridKernalContext ctx,
- final IgniteInternalCache<Object, Object> cache,
- final Object key, GridRestCacheRequest req, final boolean prepend) throws IgniteCheckedException {
- assert cache != null;
- assert key != null;
- assert req != null;
-
- final Object val = req.value();
-
- if (val == null)
- throw new IgniteCheckedException(GridRestCommandHandlerAdapter.missingParameter("val"));
-
- return ctx.closure().callLocalSafe(new Callable<Object>() {
- @Override public Object call() throws Exception {
- try (IgniteInternalTx tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
- Object curVal = cache.get(key);
-
- if (curVal == null)
- return false;
-
- // Modify current value with appendix one.
- Object newVal = appendOrPrepend(curVal, val, !prepend);
-
- // Put new value asynchronously.
- cache.put(key, newVal);
-
- tx.commit();
- }
-
- return true;
- }
- }, false);
- }
-
- /**
- * Append or prepend new value to the current one.
- *
- * @param origVal Original value.
- * @param appendVal Appendix value to add to the original one.
- * @param appendPlc Append or prepend policy flag.
- * @return Resulting value.
- * @throws IgniteCheckedException In case of grid exceptions.
- */
- private static Object appendOrPrepend(Object origVal, Object appendVal, boolean appendPlc) throws IgniteCheckedException {
- // Strings.
- if (appendVal instanceof String && origVal instanceof String)
- return appendPlc ? origVal + (String)appendVal : (String)appendVal + origVal;
-
- // Maps.
- if (appendVal instanceof Map && origVal instanceof Map) {
- Map<Object, Object> origMap = (Map<Object, Object>)origVal;
- Map<Object, Object> appendMap = (Map<Object, Object>)appendVal;
-
- Map<Object, Object> map = X.cloneObject(origMap, false, true);
-
- if (appendPlc)
- map.putAll(appendMap); // Append.
- else {
- map.clear();
- map.putAll(appendMap); // Prepend.
- map.putAll(origMap);
- }
-
- for (Map.Entry<Object, Object> e : appendMap.entrySet()) // Remove zero-valued entries.
- if (e.getValue() == null && map.get(e.getKey()) == null)
- map.remove(e.getKey());
-
- return map;
- }
-
- // Generic collection.
- if (appendVal instanceof Collection<?> && origVal instanceof Collection<?>) {
- Collection<Object> origCol = (Collection<Object>)origVal;
- Collection<Object> appendCol = (Collection<Object>)appendVal;
-
- Collection<Object> col = X.cloneObject(origCol, false, true);
-
- if (appendPlc)
- col.addAll(appendCol); // Append.
- else {
- col.clear();
- col.addAll(appendCol); // Prepend.
- col.addAll(origCol);
- }
-
- return col;
- }
-
- throw new IgniteCheckedException("Incompatible types [appendVal=" + appendVal + ", old=" + origVal + ']');
- }
-
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(GridCacheCommandHandler.class, this);
}
/**
- * Creates a transformation function from {@link CacheCommand}'s results into {@link GridRestResponse}.
- *
- * @param c Cache instance to obtain affinity data.
- * @param key Affinity key for previous operation.
- * @return Rest response.
- */
- private static IgniteClosure<IgniteInternalFuture<?>, GridRestResponse> resultWrapper(
- final IgniteInternalCache<Object, Object> c, @Nullable final Object key) {
- return new CX1<IgniteInternalFuture<?>, GridRestResponse>() {
- @Override public GridRestResponse applyx(IgniteInternalFuture<?> f) throws IgniteCheckedException {
- GridCacheRestResponse resp = new GridCacheRestResponse();
-
- resp.setResponse(f.get());
-
- if (key != null)
- resp.setAffinityNodeId(c.cache().affinity().mapKeyToNode(key).id().toString());
-
- return resp;
- }
- };
- }
-
- /**
* @param cacheName Cache name.
* @return If replicated cache with given name is locally available.
*/
@@ -702,22 +740,6 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
}
/**
- * @param ignite Grid instance.
- * @param cacheName Name of the cache.
- * @return Instance on the named cache.
- * @throws IgniteCheckedException If cache not found.
- */
- private static IgniteInternalCache<Object, Object> cache(Ignite ignite, String cacheName) throws IgniteCheckedException {
- IgniteInternalCache<Object, Object> cache = ((IgniteKernal)ignite).getCache(cacheName);
-
- if (cache == null)
- throw new IgniteCheckedException(
- "Failed to find cache for given cache name (null for default cache): " + cacheName);
-
- return cache;
- }
-
- /**
* Fixed result closure.
*/
private static final class FixedResult extends CX1<IgniteInternalFuture<?>, Object> {
@@ -771,22 +793,16 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
private static class FlaggedCacheOperationCallable implements Callable<GridRestResponse>, Serializable {
/** */
private static final long serialVersionUID = 0L;
-
- /** Client ID. */
- private UUID clientId;
-
/** */
private final String cacheName;
-
/** */
private final boolean skipStore;
-
/** */
private final CacheProjectionCommand op;
-
/** */
private final Object key;
-
+ /** Client ID. */
+ private UUID clientId;
/** */
@IgniteInstanceResource
private Ignite g;
@@ -829,19 +845,14 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
private static class CacheOperationCallable implements Callable<GridRestResponse>, Serializable {
/** */
private static final long serialVersionUID = 0L;
-
- /** Client ID. */
- private UUID clientId;
-
/** */
private final String cacheName;
-
/** */
private final CacheCommand op;
-
/** */
private final Object key;
-
+ /** Client ID. */
+ private UUID clientId;
/** */
@IgniteInstanceResource
private Ignite g;
@@ -892,6 +903,31 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
}
/** */
+ private static class MetadataCommand implements Callable<GridRestResponse>, Serializable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final String cacheName;
+
+ /** */
+ @IgniteInstanceResource
+ private Ignite g;
+
+ /**
+ * @param cacheName Cache name.
+ */
+ private MetadataCommand(String cacheName) {
+ this.cacheName = cacheName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridRestResponse call() throws Exception {
+ return new GridRestResponse(F.first(cache(g, cacheName).context().queries().sqlMetadata()));
+ }
+ }
+
+ /** */
private static class ContainsKeysCommand extends CacheProjectionCommand {
/** */
private static final long serialVersionUID = 0L;
http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java
index 64c7673..f4ddd59 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java
@@ -17,6 +17,8 @@
package org.apache.ignite.internal.processors.rest.handlers.query;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -25,8 +27,10 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.query.Query;
import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.ScanQuery;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.SqlQuery;
import org.apache.ignite.internal.GridKernalContext;
@@ -37,12 +41,14 @@ import org.apache.ignite.internal.processors.rest.GridRestCommand;
import org.apache.ignite.internal.processors.rest.GridRestResponse;
import org.apache.ignite.internal.processors.rest.handlers.GridRestCommandHandlerAdapter;
import org.apache.ignite.internal.processors.rest.request.GridRestRequest;
-import org.apache.ignite.internal.processors.rest.request.RestSqlQueryRequest;
+import org.apache.ignite.internal.processors.rest.request.RestQueryRequest;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgniteBiTuple;
import static org.apache.ignite.internal.processors.rest.GridRestCommand.CLOSE_SQL_QUERY;
+import static org.apache.ignite.internal.processors.rest.GridRestCommand.EXECUTE_SCAN_QUERY;
import static org.apache.ignite.internal.processors.rest.GridRestCommand.EXECUTE_SQL_FIELDS_QUERY;
import static org.apache.ignite.internal.processors.rest.GridRestCommand.EXECUTE_SQL_QUERY;
import static org.apache.ignite.internal.processors.rest.GridRestCommand.FETCH_SQL_QUERY;
@@ -54,6 +60,7 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
/** Supported commands. */
private static final Collection<GridRestCommand> SUPPORTED_COMMANDS = U.sealList(EXECUTE_SQL_QUERY,
EXECUTE_SQL_FIELDS_QUERY,
+ EXECUTE_SCAN_QUERY,
FETCH_SQL_QUERY,
CLOSE_SQL_QUERY);
@@ -70,6 +77,76 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
super(ctx);
}
+ /**
+ * @param qryCurs Query cursors.
+ * @param cur Current cursor.
+ * @param req Sql request.
+ * @param qryId Query id.
+ * @return Query result with items.
+ */
+ private static CacheQueryResult createQueryResult(
+ ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs,
+ Iterator cur, RestQueryRequest req, Long qryId) {
+ CacheQueryResult res = new CacheQueryResult();
+
+ List<Object> items = new ArrayList<>();
+
+ for (int i = 0; i < req.pageSize() && cur.hasNext(); ++i)
+ items.add(cur.next());
+
+ res.setItems(items);
+
+ res.setLast(!cur.hasNext());
+
+ res.setQueryId(qryId);
+
+ if (!cur.hasNext())
+ qryCurs.remove(qryId);
+
+ return res;
+ }
+
+ /**
+ * Creates class instance.
+ *
+ * @param cls Target class.
+ * @param clsName Implementing class name.
+ * @return Class instance.
+ * @throws IgniteException If failed.
+ */
+ private static <T> T instance(Class<? extends T> cls, String clsName) throws IgniteException {
+ try {
+ Class<?> implCls = Class.forName(clsName);
+
+ if (!cls.isAssignableFrom(implCls))
+ throw new IgniteException("Failed to create instance (target class does not extend or implement " +
+ "required class or interface) [cls=" + cls.getName() + ", clsName=" + clsName + ']');
+
+ Constructor<?> ctor = implCls.getConstructor();
+
+ return (T)ctor.newInstance();
+ }
+ catch (ClassNotFoundException e) {
+ throw new IgniteException("Failed to find target class: " + clsName, e);
+ }
+ catch (NoSuchMethodException e) {
+ throw new IgniteException("Failed to find constructor for provided arguments " +
+ "[clsName=" + clsName + ']', e);
+ }
+ catch (InstantiationException e) {
+ throw new IgniteException("Failed to instantiate target class " +
+ "[clsName=" + clsName + ']', e);
+ }
+ catch (IllegalAccessException e) {
+ throw new IgniteException("Failed to instantiate class (constructor is not available) " +
+ "[clsName=" + clsName + ']', e);
+ }
+ catch (InvocationTargetException e) {
+ throw new IgniteException("Failed to instantiate class (constructor threw an exception) " +
+ "[clsName=" + clsName + ']', e.getCause());
+ }
+ }
+
/** {@inheritDoc} */
@Override public Collection<GridRestCommand> supportedCommands() {
return SUPPORTED_COMMANDS;
@@ -80,23 +157,24 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
assert req != null;
assert SUPPORTED_COMMANDS.contains(req.command());
- assert req instanceof RestSqlQueryRequest : "Invalid type of query request.";
+ assert req instanceof RestQueryRequest : "Invalid type of query request.";
switch (req.command()) {
case EXECUTE_SQL_QUERY:
- case EXECUTE_SQL_FIELDS_QUERY: {
+ case EXECUTE_SQL_FIELDS_QUERY:
+ case EXECUTE_SCAN_QUERY: {
return ctx.closure().callLocalSafe(
- new ExecuteQueryCallable(ctx, (RestSqlQueryRequest)req, qryCurs), false);
+ new ExecuteQueryCallable(ctx, (RestQueryRequest)req, qryCurs), false);
}
case FETCH_SQL_QUERY: {
return ctx.closure().callLocalSafe(
- new FetchQueryCallable((RestSqlQueryRequest)req, qryCurs), false);
+ new FetchQueryCallable(ctx, (RestQueryRequest)req, qryCurs), false);
}
case CLOSE_SQL_QUERY: {
return ctx.closure().callLocalSafe(
- new CloseQueryCallable((RestSqlQueryRequest)req, qryCurs), false);
+ new CloseQueryCallable((RestQueryRequest)req, qryCurs), false);
}
}
@@ -111,7 +189,7 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
private GridKernalContext ctx;
/** Execute query request. */
- private RestSqlQueryRequest req;
+ private RestQueryRequest req;
/** Queries cursors. */
private ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs;
@@ -121,7 +199,7 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
* @param req Execute query request.
* @param qryCurs Queries cursors.
*/
- public ExecuteQueryCallable(GridKernalContext ctx, RestSqlQueryRequest req,
+ public ExecuteQueryCallable(GridKernalContext ctx, RestQueryRequest req,
ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
this.ctx = ctx;
this.req = req;
@@ -135,15 +213,33 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
try {
Query qry;
- if (req.typeName() != null) {
- qry = new SqlQuery(req.typeName(), req.sqlQuery());
+ switch (req.queryType()) {
+ case SQL:
+ qry = new SqlQuery(req.typeName(), req.sqlQuery());
- ((SqlQuery)qry).setArgs(req.arguments());
- }
- else {
- qry = new SqlFieldsQuery(req.sqlQuery());
+ ((SqlQuery)qry).setArgs(req.arguments());
+
+ break;
+
+ case SQL_FIELDS:
+ qry = new SqlFieldsQuery(req.sqlQuery());
+
+ ((SqlFieldsQuery)qry).setArgs(req.arguments());
- ((SqlFieldsQuery)qry).setArgs(req.arguments());
+ break;
+
+ case SCAN:
+ IgniteBiPredicate pred = null;
+
+ if (req.className() != null)
+ pred = instance(IgniteBiPredicate.class, req.className());
+
+ qry = new ScanQuery(pred);
+
+ break;
+
+ default:
+ throw new IgniteException("Incorrect query type [type=" + req.queryType() + "]");
}
IgniteCache<Object, Object> cache = ctx.grid().cache(req.cacheName());
@@ -160,9 +256,25 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
CacheQueryResult res = createQueryResult(qryCurs, cur, req, qryId);
- List<GridQueryFieldMetadata> fieldsMeta = ((QueryCursorImpl<?>) qryCur).fieldsMeta();
+ switch (req.queryType()) {
+ case SQL:
+ case SQL_FIELDS:
+ List<GridQueryFieldMetadata> fieldsMeta = ((QueryCursorImpl) qryCur).fieldsMeta();
+
+ res.setFieldsMetadata(convertMetadata(fieldsMeta));
- res.setFieldsMetadata(convertMetadata(fieldsMeta));
+ break;
+ case SCAN:
+ CacheQueryFieldsMetaResult keyField = new CacheQueryFieldsMetaResult();
+ keyField.setFieldName("key");
+
+ CacheQueryFieldsMetaResult valField = new CacheQueryFieldsMetaResult();
+ valField.setFieldName("value");
+
+ res.setFieldsMetadata(U.sealList(keyField, valField));
+
+ break;
+ }
return new GridRestResponse(res);
}
@@ -193,17 +305,16 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
* Close query callable.
*/
private static class CloseQueryCallable implements Callable<GridRestResponse> {
- /** Execute query request. */
- private RestSqlQueryRequest req;
-
/** Queries cursors. */
private final ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs;
+ /** Execute query request. */
+ private RestQueryRequest req;
/**
* @param req Execute query request.
* @param qryCurs Queries cursors.
*/
- public CloseQueryCallable(RestSqlQueryRequest req,
+ public CloseQueryCallable(RestQueryRequest req,
ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
this.req = req;
this.qryCurs = qryCurs;
@@ -236,18 +347,21 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
* Fetch query callable.
*/
private static class FetchQueryCallable implements Callable<GridRestResponse> {
- /** Execute query request. */
- private RestSqlQueryRequest req;
-
/** Queries cursors. */
private final ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs;
+ /** Grid kernal context. */
+ private final GridKernalContext ctx;
+ /** Execute query request. */
+ private RestQueryRequest req;
/**
+ * @param ctx Grid kernal context.
* @param req Execute query request.
* @param qryCurs Queries cursors.
*/
- public FetchQueryCallable(RestSqlQueryRequest req,
+ public FetchQueryCallable(GridKernalContext ctx, RestQueryRequest req,
ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
+ this.ctx = ctx;
this.req = req;
this.qryCurs = qryCurs;
}
@@ -272,33 +386,4 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
}
}
}
-
- /**
- * @param qryCurs Query cursors.
- * @param cur Current cursor.
- * @param req Sql request.
- * @param qryId Query id.
- * @return Query result with items.
- */
- private static CacheQueryResult createQueryResult(
- ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs,
- Iterator cur, RestSqlQueryRequest req, Long qryId) {
- CacheQueryResult res = new CacheQueryResult();
-
- List<Object> items = new ArrayList<>();
-
- for (int i = 0; i < req.pageSize() && cur.hasNext(); ++i)
- items.add(cur.next());
-
- res.setItems(items);
-
- res.setLast(!cur.hasNext());
-
- res.setQueryId(qryId);
-
- if (!cur.hasNext())
- qryCurs.remove(qryId);
-
- return res;
- }
-}
\ No newline at end of file
+}
[33/34] ignite git commit: Merging fixes to master.
Posted by sb...@apache.org.
Merging fixes to master.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6844370d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6844370d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6844370d
Branch: refs/heads/ignite-1607
Commit: 6844370dc16790423a59fb9e9f6ec39ca0699b9b
Parents: 075e7d0 30b731b
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Oct 12 20:14:14 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Oct 12 20:14:14 2015 +0300
----------------------------------------------------------------------
.../discovery/GridDiscoveryManager.java | 479 +------------------
.../processors/cache/GridCacheIoManager.java | 29 +-
.../processors/cache/GridCacheProcessor.java | 63 +--
.../dht/GridClientPartitionTopology.java | 13 +-
.../distributed/dht/GridDhtLocalPartition.java | 3 +-
.../dht/GridDhtPartitionTopologyImpl.java | 12 +-
.../GridDhtPartitionDemandMessage.java | 4 +-
.../GridDhtPartitionSupplyMessage.java | 3 +-
.../GridDhtPartitionsExchangeFuture.java | 12 +-
.../preloader/GridDhtPartitionsFullMessage.java | 12 +-
.../GridDhtPartitionsSingleMessage.java | 11 +-
.../dht/preloader/GridDhtPreloader.java | 18 +-
.../cache/query/GridCacheQueryManager.java | 41 --
.../processors/rest/GridRestProcessor.java | 47 --
.../top/GridTopologyCommandHandler.java | 129 -----
.../communication/tcp/TcpCommunicationSpi.java | 22 +-
.../IgniteCacheConfigurationTemplateTest.java | 31 ++
.../dht/GridCacheDhtPreloadPerformanceTest.java | 133 +++++
.../near/GridCacheNearTxForceKeyTest.java | 2 +-
19 files changed, 270 insertions(+), 794 deletions(-)
----------------------------------------------------------------------
[04/34] ignite git commit: Merge remote-tracking branch
'origin/ignite-1.4.1' into ignite-1.4.1
Posted by sb...@apache.org.
Merge remote-tracking branch 'origin/ignite-1.4.1' into ignite-1.4.1
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f051e49f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f051e49f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f051e49f
Branch: refs/heads/ignite-1607
Commit: f051e49fa2a3f664ee680a638e3c8864c4a01859
Parents: b64a828 d2cdf60
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Sep 25 11:02:04 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Sep 25 11:02:04 2015 +0300
----------------------------------------------------------------------
assembly/dependencies-fabric.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
[22/34] ignite git commit: ignite-1526: full support of IBM JDK by
Ignite
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index dfbb0ae..04d7893 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -22,7 +22,6 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import java.util.UUID;
import java.util.concurrent.locks.Lock;
import javax.cache.CacheException;
import javax.cache.CacheManager;
@@ -35,7 +34,6 @@ import javax.cache.processor.EntryProcessorResult;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.Ignition;
import org.apache.ignite.cache.CacheEntryProcessor;
import org.apache.ignite.cache.CacheMetrics;
import org.apache.ignite.cache.CachePeekMode;
@@ -47,8 +45,8 @@ import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.lang.IgniteRunnable;
import org.apache.ignite.mxbean.CacheMetricsMXBean;
+import org.apache.ignite.resources.IgniteInstanceResource;
import org.jetbrains.annotations.Nullable;
/**
@@ -62,9 +60,6 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
/** Cache name. */
private final String cacheName;
- /** Grid id. */
- private final UUID gridId;
-
/** With async. */
private final boolean isAsync;
@@ -81,31 +76,16 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
/**
* @param name Name.
- * @param async
+ * @param async Async flag.
* @param proxy Ignite Process Proxy.
*/
public IgniteCacheProcessProxy(String name, boolean async, IgniteProcessProxy proxy) {
cacheName = name;
isAsync = async;
- gridId = proxy.getId();
igniteProxy = proxy;
compute = proxy.remoteCompute();
}
- /**
- * Returns cache instance. Method to be called from closure at another JVM.
- *
- * @return Cache.
- */
- private IgniteCache<Object, Object> cache() {
- IgniteCache cache = Ignition.ignite(gridId).cache(cacheName);
-
- if (isAsync)
- cache = cache.withAsync();
-
- return cache;
- }
-
/** {@inheritDoc} */
@Override public IgniteCache<K, V> withAsync() {
return new IgniteCacheProcessProxy<>(cacheName, true, igniteProxy);
@@ -123,14 +103,8 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
- @Override public <C extends Configuration<K, V>> C getConfiguration(final Class<C> clazz) {
- final Class cl = clazz;
-
- return (C)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().getConfiguration(cl);
- }
- });
+ @Override public <C extends Configuration<K, V>> C getConfiguration(Class<C> clazz) {
+ return compute.call(new GetConfigurationTask<>(cacheName, isAsync, clazz));
}
/** {@inheritDoc} */
@@ -148,33 +122,26 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
throw new UnsupportedOperationException("Method should be supported.");
}
+ /** {@inheritDoc} */
@Override public IgniteCache<K, V> withNoRetries() {
throw new UnsupportedOperationException("Method should be supported.");
}
/** {@inheritDoc} */
- @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException {
+ @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
+ throws CacheException {
throw new UnsupportedOperationException("Method should be supported.");
}
/** {@inheritDoc} */
- @Override public void localLoadCache(@Nullable final IgniteBiPredicate<K, V> p, @Nullable final Object... args) throws CacheException {
- final IgniteBiPredicate pCopy = p;
-
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().localLoadCache(pCopy, args);
- }
- });
+ @Override public void localLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
+ throws CacheException {
+ compute.call(new LocalLoadCacheTask<>(cacheName, isAsync, p, args));
}
/** {@inheritDoc} */
- @Override public V getAndPutIfAbsent(final K key, final V val) throws CacheException {
- return (V)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().getAndPutIfAbsent(key, val);
- }
- });
+ @Override public V getAndPutIfAbsent(K key, V val) throws CacheException {
+ return compute.call(new GetAndPutIfAbsentTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
@@ -188,12 +155,8 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
- @Override public boolean isLocalLocked(final K key, final boolean byCurrThread) {
- return compute.call(new IgniteCallable<Boolean>() {
- @Override public Boolean call() throws Exception {
- return cache().isLocalLocked(key, byCurrThread);
- }
- });
+ @Override public boolean isLocalLocked(K key, boolean byCurrThread) {
+ return compute.call(new IsLocalLockedTask<>(cacheName, isAsync, key, byCurrThread));
}
/** {@inheritDoc} */
@@ -202,18 +165,8 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public Iterable<Entry<K, V>> localEntries(final CachePeekMode... peekModes) throws CacheException {
- return (Iterable<Entry<K, V>>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- Collection<Entry> res = new ArrayList<>();
-
- for (Entry e : cache().localEntries(peekModes))
- res.add(e);
-
- return res;
- }
- });
+ @Override public Iterable<Entry<K, V>> localEntries(CachePeekMode... peekModes) throws CacheException {
+ return compute.call(new LocalEntriesTask<K, V>(cacheName, isAsync, peekModes));
}
/** {@inheritDoc} */
@@ -222,21 +175,13 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
- @Override public void localEvict(final Collection<? extends K> keys) {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().localEvict(keys);
- }
- });
+ @Override public void localEvict(Collection<? extends K> keys) {
+ compute.call(new LocalEvictTask<>(cacheName, isAsync, keys));
}
/** {@inheritDoc} */
- @Override public V localPeek(final K key, final CachePeekMode... peekModes) {
- return (V)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().localPeek(key, peekModes);
- }
- });
+ @Override public V localPeek(K key, CachePeekMode... peekModes) {
+ return compute.call(new LocalPeekTask<K, V>(cacheName, isAsync, key, peekModes));
}
/** {@inheritDoc} */
@@ -245,274 +190,160 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
- @Override public int size(final CachePeekMode... peekModes) throws CacheException {
- return (int)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().size(peekModes);
- }
- });
+ @Override public int size(CachePeekMode... peekModes) throws CacheException {
+ return compute.call(new SizeTask(cacheName, isAsync, peekModes, false));
}
/** {@inheritDoc} */
- @Override public int localSize(final CachePeekMode... peekModes) {
- return (int)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().localSize(peekModes);
- }
- });
+ @Override public int localSize(CachePeekMode... peekModes) {
+ return compute.call(new SizeTask(cacheName, isAsync, peekModes, true));
}
/** {@inheritDoc} */
- @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Map<? extends K, ? extends EntryProcessor<K, V, T>> map,
- Object... args) {
+ @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(
+ Map<? extends K, ? extends EntryProcessor<K, V, T>> map,
+ Object... args)
+ {
throw new UnsupportedOperationException("Method should be supported.");
}
/** {@inheritDoc} */
- @Override public V get(final K key) {
- return (V)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().get(key);
- }
- });
+ @Override public V get(K key) {
+ return compute.call(new GetTask<K, V>(cacheName, isAsync, key));
}
/** {@inheritDoc} */
- @Override public Map<K, V> getAll(final Set<? extends K> keys) {
- return (Map<K, V>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().getAll(keys);
- }
- });
+ @Override public Map<K, V> getAll(Set<? extends K> keys) {
+ return compute.call(new GetAllTask<K, V>(cacheName, isAsync, keys));
}
- @Override public Map<K, V> getAllOutTx(final Set<? extends K> keys) {
- return (Map<K, V>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().getAllOutTx(keys);
- }
- });
+ /** {@inheritDoc} */
+ @Override public Map<K, V> getAllOutTx(Set<? extends K> keys) {
+ return compute.call(new GetAllOutTxTask<K, V>(cacheName, isAsync, keys));
}
/** {@inheritDoc} */
- @Override public boolean containsKey(final K key) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().containsKey(key);
- }
- });
+ @Override public boolean containsKey(K key) {
+ return compute.call(new ContainsKeyTask<>(cacheName, isAsync, key));
}
/** {@inheritDoc} */
- @Override public void loadAll(Set<? extends K> keys, boolean replaceExistingValues, CompletionListener completionLsnr) {
+ @Override public void loadAll(Set<? extends K> keys, boolean replaceExistVals, CompletionListener completionLsnr) {
throw new UnsupportedOperationException("Oparetion can't be supported automatically.");
}
/** {@inheritDoc} */
- @Override public boolean containsKeys(final Set<? extends K> keys) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().containsKeys(keys);
- }
- });
+ @Override public boolean containsKeys(Set<? extends K> keys) {
+ return compute.call(new ContainsKeysTask<>(cacheName, isAsync, keys));
}
/** {@inheritDoc} */
- @Override public void put(final K key, final V val) {;
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().put(key, val);
- }
- });
+ @Override public void put(K key, V val) {
+ compute.call(new PutTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
- @Override public V getAndPut(final K key, final V val) {
- return (V)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().getAndPut(key, val);
- }
- });
+ @Override public V getAndPut(K key, V val) {
+ return compute.call(new GetAndPutTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
- @Override public void putAll(final Map<? extends K, ? extends V> map) {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().putAll(map);
- }
- });
+ @Override public void putAll(Map<? extends K, ? extends V> map) {
+ compute.call(new PutAllTask<>(cacheName, isAsync, map));
}
/** {@inheritDoc} */
- @Override public boolean putIfAbsent(final K key, final V val) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().putIfAbsent(key, val);
- }
- });
+ @Override public boolean putIfAbsent(K key, V val) {
+ return compute.call(new PutIfAbsentTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
- @Override public boolean remove(final K key) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().remove(key);
- }
- });
+ @Override public boolean remove(K key) {
+ return compute.call(new RemoveTask<>(cacheName, isAsync, key));
}
/** {@inheritDoc} */
- @Override public boolean remove(final K key, final V oldVal) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().remove(key, oldVal);
- }
- });
+ @Override public boolean remove(K key, V oldVal) {
+ return compute.call(new RemoveIfExistsTask<>(cacheName, isAsync, key, oldVal));
}
/** {@inheritDoc} */
- @Override public V getAndRemove(final K key) {
- return (V)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().getAndRemove(key);
- }
- });
+ @Override public V getAndRemove(K key) {
+ return compute.call(new GetAndRemoveTask<K, V>(cacheName, isAsync, key));
}
/** {@inheritDoc} */
- @Override public boolean replace(final K key, final V oldVal, final V newVal) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().replace(key, oldVal, newVal);
- }
- });
+ @Override public boolean replace(K key, V oldVal, V newVal) {
+ return compute.call(new ReplaceIfExistsTask<>(cacheName, isAsync, key, oldVal, newVal));
}
/** {@inheritDoc} */
- @Override public boolean replace(final K key, final V val) {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().replace(key, val);
- }
- });
+ @Override public boolean replace(K key, V val) {
+ return compute.call(new ReplaceTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
- @Override public V getAndReplace(final K key, final V val) {
- return (V)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().getAndReplace(key, val);
- }
- });
+ @Override public V getAndReplace(K key, V val) {
+ return compute.call(new GetAndReplaceTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
- @Override public void removeAll(final Set<? extends K> keys) {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().removeAll(keys);
- }
- });
+ @Override public void removeAll(Set<? extends K> keys) {
+ compute.call(new RemoveAllKeysTask<>(cacheName, isAsync, keys));
}
/** {@inheritDoc} */
@Override public void removeAll() {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- IgniteCache<Object, Object> cache = cache();
-
- cache.removeAll();
-
- if (isAsync)
- cache.future().get();
- }
- });
+ compute.call(new RemoveAllTask<K, V>(cacheName, isAsync));
}
/** {@inheritDoc} */
@Override public void clear() {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().clear();
- }
- });
+ compute.call(new ClearTask(cacheName, isAsync));
}
/** {@inheritDoc} */
- @Override public void clear(final K key) {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().clear(key);
- }
- });
+ @Override public void clear(K key) {
+ compute.call(new ClearKeyTask<>(cacheName, isAsync, false, key));
}
/** {@inheritDoc} */
- @Override public void clearAll(final Set<? extends K> keys) {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().clearAll(keys);
- }
- });
+ @Override public void clearAll(Set<? extends K> keys) {
+ compute.call(new ClearAllKeys<>(cacheName, isAsync, false, keys));
}
/** {@inheritDoc} */
- @Override public void localClear(final K key) {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().localClear(key);
- }
- });
+ @Override public void localClear(K key) {
+ compute.call(new ClearKeyTask<>(cacheName, isAsync, true, key));
}
/** {@inheritDoc} */
- @Override public void localClearAll(final Set<? extends K> keys) {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().localClearAll(keys);
- }
- });
+ @Override public void localClearAll(Set<? extends K> keys) {
+ compute.call(new ClearAllKeys<>(cacheName, isAsync, true, keys));
}
/** {@inheritDoc} */
- @Override public <T> T invoke(final K key, final EntryProcessor<K, V, T> entryProcessor, final Object... arguments) {
- return (T)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().invoke(key,
- (EntryProcessor<Object, Object, Object>)entryProcessor, arguments);
- }
- });
+ @Override public <T> T invoke(K key, EntryProcessor<K, V, T> processor, Object... args) {
+ return compute.call(new InvokeTask<>(cacheName, isAsync, key, processor, args));
}
/** {@inheritDoc} */
- @Override public <T> T invoke(final K key, final CacheEntryProcessor<K, V, T> entryProcessor, final Object... arguments) {
- return (T)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().invoke(key,
- (CacheEntryProcessor<Object, Object, Object>)entryProcessor, arguments);
- }
- });
+ @Override public <T> T invoke(K key, CacheEntryProcessor<K, V, T> processor, Object... args) {
+ return compute.call(new InvokeTask<>(cacheName, isAsync, key, processor, args));
}
/** {@inheritDoc} */
- @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(final Set<? extends K> keys, final EntryProcessor<K, V, T> entryProcessor,
- final Object... args) {
- return (Map<K, EntryProcessorResult<T>>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().invokeAll(keys,
- (EntryProcessor<Object, Object, Object>)entryProcessor, args);
- }
- });
+ @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(
+ Set<? extends K> keys,
+ EntryProcessor<K, V, T> processor,
+ Object... args)
+ {
+ return compute.call(new InvokeAllTask<>(cacheName, isAsync, keys, processor, args));
}
/** {@inheritDoc} */
@Override public String getName() {
- return (String)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().getName();
- }
- });
+ return compute.call(new GetNameTask(cacheName, isAsync));
}
/** {@inheritDoc} */
@@ -522,72 +353,47 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
/** {@inheritDoc} */
@Override public void close() {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().close();
- }
- });
+ compute.call(new CloseTask(cacheName, isAsync));
}
/** {@inheritDoc} */
@Override public void destroy() {
- compute.run(new IgniteRunnable() {
- @Override public void run() {
- cache().destroy();
- }
- });
+ compute.call(new DestroyTask(cacheName, isAsync));
}
/** {@inheritDoc} */
@Override public boolean isClosed() {
- return (boolean)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().isClosed();
- }
- });
+ return compute.call(new IsClosedTask(cacheName, isAsync));
}
/** {@inheritDoc} */
- @Override public <T> T unwrap(final Class<T> clazz) {
+ @SuppressWarnings("unchecked")
+ @Override public <T> T unwrap(Class<T> clazz) {
if (Ignite.class.equals(clazz))
return (T)igniteProxy;
try {
- return (T)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- return cache().unwrap(clazz);
- }
- });
+ return compute.call(new UnwrapTask<>(cacheName, isAsync, clazz));
}
catch (Exception e) {
- throw new IllegalArgumentException("Looks like class " + clazz + " is unmarshallable. Exception type:" + e.getClass(), e);
+ throw new IllegalArgumentException("Looks like class " + clazz +
+ " is unmarshallable. Exception type:" + e.getClass(), e);
}
}
/** {@inheritDoc} */
- @Override public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
+ @Override public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> lsnrCfg) {
throw new UnsupportedOperationException("Method should be supported.");
}
/** {@inheritDoc} */
- @Override public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
+ @Override public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> lsnrCfg) {
throw new UnsupportedOperationException("Method should be supported.");
}
/** {@inheritDoc} */
@Override public Iterator<Entry<K, V>> iterator() {
- final Collection<Entry<K, V>> col = (Collection<Entry<K, V>>)compute.call(new IgniteCallable<Object>() {
- @Override public Object call() throws Exception {
- Collection res = new ArrayList();
-
- for (Object o : cache())
- res.add(o);
-
- return res;
- }
- });
-
- return col.iterator();
+ return compute.call(new IteratorTask<K, V>(cacheName, isAsync)).iterator();
}
/** {@inheritDoc} */
@@ -615,4 +421,968 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
@Override public CacheMetricsMXBean mxBean() {
throw new UnsupportedOperationException("Method should be supported.");
}
-}
\ No newline at end of file
+
+ /**
+ *
+ */
+ private static class GetConfigurationTask<K, V, C extends Configuration<K, V>> extends CacheTaskAdapter<K, V, C> {
+ /** Clazz. */
+ private final Class<C> clazz;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param clazz Clazz.
+ */
+ public GetConfigurationTask(String cacheName, boolean async, Class<C> clazz) {
+ super(cacheName, async);
+ this.clazz = clazz;
+ }
+
+ /** {@inheritDoc} */
+ @Override public C call() throws Exception {
+ return cache().getConfiguration(clazz);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class LocalLoadCacheTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+ /** Predicate. */
+ private final IgniteBiPredicate<K, V> p;
+
+ /** Args. */
+ private final Object[] args;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param p P.
+ * @param args Args.
+ */
+ public LocalLoadCacheTask(String cacheName, boolean async, IgniteBiPredicate<K, V> p, Object[] args) {
+ super(cacheName, async);
+ this.p = p;
+ this.args = args;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().localLoadCache(p, args);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAndPutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public GetAndPutIfAbsentTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().getAndPutIfAbsent(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IsLocalLockedTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** By current thread. */
+ private final boolean byCurrThread;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param byCurrThread By current thread.
+ */
+ public IsLocalLockedTask(String cacheName, boolean async, K key, boolean byCurrThread) {
+ super(cacheName, async);
+ this.key = key;
+ this.byCurrThread = byCurrThread;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().isLocalLocked(key, byCurrThread);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class LocalEntriesTask<K, V> extends CacheTaskAdapter<K, V, Iterable<Entry<K, V>>> {
+ /** Peek modes. */
+ private final CachePeekMode[] peekModes;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param peekModes Peek modes.
+ */
+ public LocalEntriesTask(String cacheName, boolean async, CachePeekMode[] peekModes) {
+ super(cacheName, async);
+ this.peekModes = peekModes;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Iterable<Entry<K, V>> call() throws Exception {
+ Collection<Entry<K, V>> res = new ArrayList<>();
+
+ for (Entry<K, V> e : cache().localEntries(peekModes))
+ res.add(new CacheEntryImpl<>(e.getKey(), e.getValue()));
+
+ return res;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class LocalEvictTask<K> extends CacheTaskAdapter<K, Void, Void> {
+ /** Keys. */
+ private final Collection<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public LocalEvictTask(String cacheName, boolean async, Collection<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().localEvict(keys);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class LocalPeekTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /** Peek modes. */
+ private final CachePeekMode[] peekModes;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param peekModes Peek modes.
+ */
+ public LocalPeekTask(String cacheName, boolean async, K key, CachePeekMode[] peekModes) {
+ super(cacheName, async);
+ this.key = key;
+ this.peekModes = peekModes;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().localPeek(key, peekModes);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class SizeTask extends CacheTaskAdapter<Void, Void, Integer> {
+ /** Peek modes. */
+ private final CachePeekMode[] peekModes;
+
+ /** Local. */
+ private final boolean loc;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param peekModes Peek modes.
+ * @param loc Local.
+ */
+ public SizeTask(String cacheName, boolean async, CachePeekMode[] peekModes, boolean loc) {
+ super(cacheName, async);
+ this.loc = loc;
+ this.peekModes = peekModes;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Integer call() throws Exception {
+ return loc ? cache().localSize(peekModes) : cache().size(peekModes);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public GetTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().get(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public RemoveAllTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ IgniteCache<K, V> cache = cache();
+
+ cache.removeAll();
+
+ if (async)
+ cache.future().get();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class PutTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public PutTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().put(key, val);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ContainsKeyTask<K> extends CacheTaskAdapter<K, Object, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public ContainsKeyTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().containsKey(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ClearTask extends CacheTaskAdapter<Object, Object, Void> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public ClearTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().clear();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IteratorTask<K, V> extends CacheTaskAdapter<K, V, Collection<Entry<K, V>>> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public IteratorTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<Entry<K, V>> call() throws Exception {
+ Collection<Entry<K, V>> res = new ArrayList<>();
+
+ for (Entry<K, V> o : cache())
+ res.add(o);
+
+ return res;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ReplaceTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public ReplaceTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().replace(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetNameTask extends CacheTaskAdapter<Void, Void, String> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public GetNameTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String call() throws Exception {
+ return cache().getName();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public RemoveTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().remove(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class PutAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+ /** Map. */
+ private final Map<? extends K, ? extends V> map;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param map Map.
+ */
+ public PutAllTask(String cacheName, boolean async, Map<? extends K, ? extends V> map) {
+ super(cacheName, async);
+ this.map = map;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().putAll(map);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveAllKeysTask<K> extends CacheTaskAdapter<K, Void, Void> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public RemoveAllKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().removeAll(keys);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAllTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public GetAllTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, V> call() throws Exception {
+ return cache().getAll(keys);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAllOutTxTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public GetAllOutTxTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, V> call() throws Exception {
+ return cache().getAllOutTx(keys);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ContainsKeysTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public ContainsKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().containsKeys(keys);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAndPutTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public GetAndPutTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().getAndPut(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class PutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public PutIfAbsentTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().putIfAbsent(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class RemoveIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Old value. */
+ private final V oldVal;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param oldVal Old value.
+ */
+ public RemoveIfExistsTask(String cacheName, boolean async, K key, V oldVal) {
+ super(cacheName, async);
+ this.key = key;
+ this.oldVal = oldVal;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().remove(key, oldVal);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAndRemoveTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public GetAndRemoveTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().getAndRemove(key);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ReplaceIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+ /** Key. */
+ private final K key;
+
+ /** Old value. */
+ private final V oldVal;
+
+ /** New value. */
+ private final V newVal;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param oldVal Old value.
+ * @param newVal New value.
+ */
+ public ReplaceIfExistsTask(String cacheName, boolean async, K key, V oldVal, V newVal) {
+ super(cacheName, async);
+ this.key = key;
+ this.oldVal = oldVal;
+ this.newVal = newVal;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().replace(key, oldVal, newVal);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class GetAndReplaceTask<K, V> extends CacheTaskAdapter<K, V, V> {
+ /** Key. */
+ private final K key;
+
+ /** Value. */
+ private final V val;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param val Value.
+ */
+ public GetAndReplaceTask(String cacheName, boolean async, K key, V val) {
+ super(cacheName, async);
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V call() throws Exception {
+ return cache().getAndReplace(key, val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ClearKeyTask<K> extends CacheTaskAdapter<K, Void, Void> {
+ /** Key. */
+ private final K key;
+
+ /** Local. */
+ private final boolean loc;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public ClearKeyTask(String cacheName, boolean async, boolean loc, K key) {
+ super(cacheName, async);
+ this.key = key;
+ this.loc = loc;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ if (loc)
+ cache().localClear(key);
+ else
+ cache().clear(key);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ClearAllKeys<K> extends CacheTaskAdapter<K, Void, Void> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /** Local. */
+ private final boolean loc;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public ClearAllKeys(String cacheName, boolean async, boolean loc, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ this.loc = loc;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ if (loc)
+ cache().localClearAll(keys);
+ else
+ cache().clearAll(keys);
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class InvokeTask<K, V, R> extends CacheTaskAdapter<K, V, R> {
+ /** Key. */
+ private final K key;
+
+ /** Processor. */
+ private final EntryProcessor<K, V, R> processor;
+
+ /** Args. */
+ private final Object[] args;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ * @param processor Processor.
+ * @param args Args.
+ */
+ public InvokeTask(String cacheName, boolean async, K key, EntryProcessor<K, V, R> processor,
+ Object[] args) {
+ super(cacheName, async);
+ this.args = args;
+ this.key = key;
+ this.processor = processor;
+ }
+
+ /** {@inheritDoc} */
+ @Override public R call() throws Exception {
+ return cache().invoke(key, processor, args);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class InvokeAllTask<K, V, T> extends CacheTaskAdapter<K, V, Map<K, EntryProcessorResult<T>>> {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /** Processor. */
+ private final EntryProcessor<K, V, T> processor;
+
+ /** Args. */
+ private final Object[] args;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ * @param processor Processor.
+ * @param args Args.
+ */
+ public InvokeAllTask(String cacheName, boolean async, Set<? extends K> keys,
+ EntryProcessor<K, V, T> processor, Object[] args) {
+ super(cacheName, async);
+ this.args = args;
+ this.keys = keys;
+ this.processor = processor;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, EntryProcessorResult<T>> call() throws Exception {
+ return cache().invokeAll(keys, processor, args);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CloseTask extends CacheTaskAdapter<Void, Void, Void> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public CloseTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().close();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class DestroyTask extends CacheTaskAdapter<Void, Void, Void> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public DestroyTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() {
+ cache().destroy();
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class IsClosedTask extends CacheTaskAdapter<Void, Void, Boolean> {
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public IsClosedTask(String cacheName, boolean async) {
+ super(cacheName, async);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Boolean call() throws Exception {
+ return cache().isClosed();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class UnwrapTask<R> extends CacheTaskAdapter<Void, Void, R> {
+ /** Clazz. */
+ private final Class<R> clazz;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param clazz Clazz.
+ */
+ public UnwrapTask(String cacheName, boolean async, Class<R> clazz) {
+ super(cacheName, async);
+ this.clazz = clazz;
+ }
+
+ /** {@inheritDoc} */
+ @Override public R call() throws Exception {
+ return cache().unwrap(clazz);
+ }
+ }
+
+ /**
+ *
+ */
+ private static abstract class CacheTaskAdapter<K, V, R> implements IgniteCallable<R> {
+ /** Ignite. */
+ @IgniteInstanceResource
+ protected Ignite ignite;
+
+ /** Cache name. */
+ protected final String cacheName;
+
+ /** Async. */
+ protected final boolean async;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ */
+ public CacheTaskAdapter(String cacheName, boolean async) {
+ this.async = async;
+ this.cacheName = cacheName;
+ }
+
+ /**
+ * Returns cache instance.
+ */
+ protected IgniteCache<K, V> cache() {
+ IgniteCache<K, V> cache = ignite.cache(cacheName);
+
+ return async ? cache.withAsync() : cache;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
index 05d6533..633e9d0 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
@@ -26,7 +26,6 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCluster;
import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.cluster.ClusterMetrics;
import org.apache.ignite.cluster.ClusterNode;
@@ -36,6 +35,7 @@ import org.apache.ignite.internal.cluster.IgniteClusterEx;
import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.IgniteInstanceResource;
import org.jetbrains.annotations.Nullable;
/**
@@ -43,9 +43,6 @@ import org.jetbrains.annotations.Nullable;
*/
@SuppressWarnings("TransientFieldInNonSerializableClass")
public class IgniteClusterProcessProxy implements IgniteClusterEx {
- /** Grid id. */
- private final UUID gridId;
-
/** Compute. */
private final transient IgniteCompute compute;
@@ -57,21 +54,11 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
*/
public IgniteClusterProcessProxy(IgniteProcessProxy proxy) {
this.proxy = proxy;
- gridId = proxy.getId();
compute = proxy.remoteCompute();
}
- /**
- * Returns cluster instance. Method to be called from closure at another JVM.
- *
- * @return Cache.
- */
- private IgniteClusterEx cluster() {
- return (IgniteClusterEx)Ignition.ignite(gridId).cluster();
- }
-
/** {@inheritDoc} */
- @Override public ClusterGroupEx forSubjectId(final UUID subjId) {
+ @Override public ClusterGroupEx forSubjectId(UUID subjId) {
throw new UnsupportedOperationException("Operation is not supported yet.");
}
@@ -83,11 +70,7 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
/** {@inheritDoc} */
@Override public ClusterNode localNode() {
- return compute.call(new IgniteCallable<ClusterNode>() {
- @Override public ClusterNode call() throws Exception {
- return cluster().localNode();
- }
- });
+ return compute.call(new LocalNodeTask());
}
/** {@inheritDoc} */
@@ -285,38 +268,22 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
/** {@inheritDoc} */
@Override public Collection<ClusterNode> nodes() {
- return compute.call(new IgniteCallable<Collection<ClusterNode>>() {
- @Override public Collection<ClusterNode> call() throws Exception {
- return cluster().nodes();
- }
- });
+ return compute.call(new NodesTask());
}
/** {@inheritDoc} */
- @Override public ClusterNode node(final UUID nid) {
- return compute.call(new IgniteCallable<ClusterNode>() {
- @Override public ClusterNode call() throws Exception {
- return cluster().node(nid);
- }
- });
+ @Override public ClusterNode node(UUID nid) {
+ return compute.call(new NodeTask(nid));
}
/** {@inheritDoc} */
@Override public ClusterNode node() {
- return compute.call(new IgniteCallable<ClusterNode>() {
- @Override public ClusterNode call() throws Exception {
- return cluster().node();
- }
- });
+ return compute.call(new NodeTask(null));
}
/** {@inheritDoc} */
@Override public Collection<String> hostNames() {
- return compute.call(new IgniteCallable<Collection<String>>() {
- @Override public Collection<String> call() throws Exception {
- return cluster().hostNames();
- }
- });
+ return compute.call(new HostNamesTask());
}
/** {@inheritDoc} */
@@ -333,4 +300,70 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
@Nullable @Override public IgniteFuture<?> clientReconnectFuture() {
throw new UnsupportedOperationException("Operation is not supported yet.");
}
+
+ /**
+ *
+ */
+ private static class LocalNodeTask extends ClusterTaskAdapter<ClusterNode> {
+ /** {@inheritDoc} */
+ @Override public ClusterNode call() throws Exception {
+ return cluster().localNode();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class NodesTask extends ClusterTaskAdapter<Collection<ClusterNode>> {
+ /** {@inheritDoc} */
+ @Override public Collection<ClusterNode> call() throws Exception {
+ return cluster().nodes();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class NodeTask extends ClusterTaskAdapter<ClusterNode> {
+ /** Node id. */
+ private final UUID nodeId;
+
+ /**
+ * @param nodeId Node id.
+ */
+ public NodeTask(UUID nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ClusterNode call() throws Exception {
+ return nodeId == null ? cluster().node() : cluster().node(nodeId);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class HostNamesTask extends ClusterTaskAdapter<Collection<String>> {
+ /** {@inheritDoc} */
+ @Override public Collection<String> call() throws Exception {
+ return cluster().hostNames();
+ }
+ }
+
+ /**
+ *
+ */
+ private abstract static class ClusterTaskAdapter<R> implements IgniteCallable<R> {
+ /** Ignite. */
+ @IgniteInstanceResource
+ protected Ignite ignite;
+
+ /**
+ *
+ */
+ protected IgniteCluster cluster() {
+ return ignite.cluster();
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
index 860f889..d5af81e 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
@@ -20,15 +20,16 @@ package org.apache.ignite.testframework.junits.multijvm;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
+import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteEvents;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.events.Event;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.IgniteInstanceResource;
import org.jetbrains.annotations.Nullable;
/**
@@ -39,23 +40,11 @@ public class IgniteEventsProcessProxy implements IgniteEvents {
/** Ignite proxy. */
private final transient IgniteProcessProxy igniteProxy;
- /** Grid id. */
- private final UUID gridId;
-
/**
* @param igniteProxy Ignite proxy.
*/
public IgniteEventsProcessProxy(IgniteProcessProxy igniteProxy) {
this.igniteProxy = igniteProxy;
-
- gridId = igniteProxy.getId();
- }
-
- /**
- * @return Events instance.
- */
- private IgniteEvents events() {
- return Ignition.ignite(gridId).events();
}
/** {@inheritDoc} */
@@ -105,11 +94,7 @@ public class IgniteEventsProcessProxy implements IgniteEvents {
/** {@inheritDoc} */
@Override public void localListen(final IgnitePredicate<? extends Event> lsnr, final int... types) {
- igniteProxy.remoteCompute().run(new IgniteRunnable() {
- @Override public void run() {
- events().localListen(lsnr, types);
- }
- });
+ igniteProxy.remoteCompute().run(new LocalListenTask(lsnr, types));
}
/** {@inheritDoc} */
@@ -151,4 +136,33 @@ public class IgniteEventsProcessProxy implements IgniteEvents {
@Override public <R> IgniteFuture<R> future() {
throw new UnsupportedOperationException("Operation isn't supported yet.");
}
+
+ /**
+ *
+ */
+ private static class LocalListenTask implements IgniteRunnable {
+ /** Ignite. */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** Listener. */
+ private final IgnitePredicate<? extends Event> lsnr;
+
+ /** Types. */
+ private final int[] types;
+
+ /**
+ * @param lsnr Listener.
+ * @param types Types.
+ */
+ public LocalListenTask(IgnitePredicate<? extends Event> lsnr, int[] types) {
+ this.lsnr = lsnr;
+ this.types = types;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ ignite.events().localListen(lsnr, types);
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
index f46e8e9..0597eda 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
@@ -25,13 +25,12 @@ import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
-import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.Ignition;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
@@ -39,8 +38,9 @@ import org.apache.ignite.internal.processors.cache.GridCacheAbstractFullApiSelfT
import org.apache.ignite.internal.util.GridJavaProcess;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.testframework.junits.IgniteTestResources;
import sun.jvmstat.monitor.HostIdentifier;
import sun.jvmstat.monitor.MonitoredHost;
import sun.jvmstat.monitor.MonitoredVm;
@@ -99,30 +99,6 @@ public class IgniteNodeRunner {
public static String storeToFile(IgniteConfiguration cfg) throws IOException {
String fileName = IGNITE_CONFIGURATION_FILE + cfg.getNodeId();
- // Check marshaller configuration, because read configuration method expect specific marshaller.
- if (cfg.getMarshaller() instanceof OptimizedMarshaller){
- OptimizedMarshaller marsh = (OptimizedMarshaller)cfg.getMarshaller();
-
- try {
- Field isRequireFiled = marsh.getClass().getDeclaredField("requireSer");
-
- isRequireFiled.setAccessible(true);
-
- boolean isRequireSer = isRequireFiled.getBoolean(marsh);
-
- if (isRequireSer)
- throw new UnsupportedOperationException("Unsupported marshaller configuration. " +
- "readCfgFromFileAndDeleteFile method expect " + OptimizedMarshaller.class.getSimpleName() +
- "with requireSerializeble flag in 'false'.");
- }
- catch (NoSuchFieldException|IllegalAccessException e) {
- throw new IgniteException("Failed to check filed of " + OptimizedMarshaller.class.getSimpleName(), e);
- }
- }
- else
- throw new UnsupportedOperationException("Unsupported marshaller. " +
- "readCfgFromFileAndDeleteFile method expect " + OptimizedMarshaller.class.getSimpleName());
-
try(OutputStream out = new BufferedOutputStream(new FileOutputStream(fileName))) {
cfg.setMBeanServer(null);
cfg.setMarshaller(null);
@@ -143,11 +119,16 @@ public class IgniteNodeRunner {
* @throws IOException If failed.
* @see #storeToFile(IgniteConfiguration)
*/
- private static IgniteConfiguration readCfgFromFileAndDeleteFile(String fileName) throws IOException {
+ private static IgniteConfiguration readCfgFromFileAndDeleteFile(String fileName)
+ throws IOException, IgniteCheckedException {
try(BufferedReader cfgReader = new BufferedReader(new FileReader(fileName))) {
IgniteConfiguration cfg = (IgniteConfiguration)new XStream().fromXML(cfgReader);
- cfg.setMarshaller(new OptimizedMarshaller(false));
+ Marshaller marsh = IgniteTestResources.getMarshaller();
+
+ cfg.setMarshaller(marsh);
+
+ X.println("Configured marshaller class: " + marsh.getClass().getName());
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(GridCacheAbstractFullApiSelfTest.LOCAL_IP_FINDER);
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
index ec7dab7..aa1d470 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
@@ -41,13 +41,11 @@ import org.apache.ignite.IgniteFileSystem;
import org.apache.ignite.IgniteIllegalStateException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteMessaging;
-import org.apache.ignite.internal.portable.api.IgnitePortables;
import org.apache.ignite.IgniteQueue;
import org.apache.ignite.IgniteScheduler;
import org.apache.ignite.IgniteServices;
import org.apache.ignite.IgniteSet;
import org.apache.ignite.IgniteTransactions;
-import org.apache.ignite.Ignition;
import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.cluster.ClusterNode;
@@ -62,6 +60,7 @@ import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.cluster.IgniteClusterEx;
+import org.apache.ignite.internal.portable.api.IgnitePortables;
import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
import org.apache.ignite.internal.processors.hadoop.Hadoop;
@@ -78,6 +77,8 @@ import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.lang.IgniteRunnable;
import org.apache.ignite.plugin.IgnitePlugin;
import org.apache.ignite.plugin.PluginNotFoundException;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.testframework.junits.IgniteTestResources;
import org.jetbrains.annotations.Nullable;
/**
@@ -88,6 +89,9 @@ public class IgniteProcessProxy implements IgniteEx {
/** Grid proxies. */
private static final transient ConcurrentMap<String, IgniteProcessProxy> gridProxies = new ConcurrentHashMap<>();
+ /** Property that specify alternative {@code JAVA_HOME}. */
+ private static final String TEST_MULTIJVM_JAVA_HOME = "test.multijvm.java.home";
+
/** Jvm process with ignite instance. */
private final transient GridJavaProcess proc;
@@ -108,7 +112,7 @@ public class IgniteProcessProxy implements IgniteEx {
* @param log Logger.
* @param locJvmGrid Local JVM grid.
*/
- public IgniteProcessProxy(final IgniteConfiguration cfg, final IgniteLogger log, final Ignite locJvmGrid)
+ public IgniteProcessProxy(IgniteConfiguration cfg, IgniteLogger log, Ignite locJvmGrid)
throws Exception {
this.cfg = cfg;
this.locJvmGrid = locJvmGrid;
@@ -121,7 +125,9 @@ public class IgniteProcessProxy implements IgniteEx {
Collection<String> filteredJvmArgs = new ArrayList<>();
for (String arg : jvmArgs) {
- if(!arg.toLowerCase().startsWith("-agentlib"))
+ if(arg.startsWith("-Xmx") || arg.startsWith("-Xms") ||
+ arg.startsWith("-cp") || arg.startsWith("-classpath") ||
+ arg.startsWith("-D" + IgniteTestResources.MARSH_CLASS_NAME))
filteredJvmArgs.add(arg);
}
@@ -130,7 +136,7 @@ public class IgniteProcessProxy implements IgniteEx {
locJvmGrid.events().localListen(new NodeStartedListener(id, rmtNodeStartedLatch), EventType.EVT_NODE_JOINED);
proc = GridJavaProcess.exec(
- IgniteNodeRunner.class,
+ IgniteNodeRunner.class.getCanonicalName(),
cfgFileName, // Params.
this.log,
// Optional closure to be called each time wrapped process prints line to system.out or system.err.
@@ -140,6 +146,7 @@ public class IgniteProcessProxy implements IgniteEx {
}
},
null,
+ System.getProperty(TEST_MULTIJVM_JAVA_HOME),
filteredJvmArgs, // JVM Args.
System.getProperty("surefire.test.class.path")
);
@@ -149,11 +156,7 @@ public class IgniteProcessProxy implements IgniteEx {
IgniteProcessProxy prevVal = gridProxies.putIfAbsent(cfg.getGridName(), this);
if (prevVal != null) {
- remoteCompute().run(new IgniteRunnable() {
- @Override public void run() {
- G.stop(cfg.getGridName(), true);
- }
- });
+ remoteCompute().run(new StopGridTask(cfg.getGridName(), true));
throw new IllegalStateException("There was found instance assotiated with " + cfg.getGridName() +
", instance= " + prevVal + ". New started node was stopped.");
@@ -208,30 +211,17 @@ public class IgniteProcessProxy implements IgniteEx {
* @param gridName Grid name.
* @param cancel Cacnel flag.
*/
- public static void stop(final String gridName, final boolean cancel) {
+ public static void stop(String gridName, boolean cancel) {
IgniteProcessProxy proxy = gridProxies.get(gridName);
if (proxy != null) {
- proxy.remoteCompute().run(new IgniteRunnable() {
- @Override public void run() {
- G.stop(gridName, cancel);
- }
- });
+ proxy.remoteCompute().run(new StopGridTask(gridName, cancel));
gridProxies.remove(gridName, proxy);
}
}
/**
- * For usage in closures.
- *
- * @return Ignite instance.
- */
- private Ignite igniteById() {
- return Ignition.ignite(id);
- }
-
- /**
* @param locNodeId ID of local node the requested grid instance is managing.
* @return An instance of named grid. This method never returns {@code null}.
* @throws IgniteIllegalStateException Thrown if grid was not properly initialized or grid instance was stopped or
@@ -357,11 +347,7 @@ public class IgniteProcessProxy implements IgniteEx {
/** {@inheritDoc} */
@Override public ClusterNode localNode() {
- return remoteCompute().call(new IgniteCallable<ClusterNode>() {
- @Override public ClusterNode call() throws Exception {
- return ((IgniteEx)Ignition.ignite(id)).localNode();
- }
- });
+ return remoteCompute().call(new NodeTask());
}
/** {@inheritDoc} */
@@ -467,7 +453,10 @@ public class IgniteProcessProxy implements IgniteEx {
}
/** {@inheritDoc} */
- @Override public <K, V> IgniteCache<K, V> createNearCache(@Nullable String cacheName, NearCacheConfiguration<K, V> nearCfg) {
+ @Override public <K, V> IgniteCache<K, V> createNearCache(
+ @Nullable String cacheName,
+ NearCacheConfiguration<K, V> nearCfg)
+ {
throw new UnsupportedOperationException("Operation isn't supported yet.");
}
@@ -508,7 +497,8 @@ public class IgniteProcessProxy implements IgniteEx {
}
/** {@inheritDoc} */
- @Override public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create) throws IgniteException {
+ @Override public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create)
+ throws IgniteException {
throw new UnsupportedOperationException("Operation isn't supported yet.");
}
@@ -524,8 +514,12 @@ public class IgniteProcessProxy implements IgniteEx {
}
/** {@inheritDoc} */
- @Override public <T, S> IgniteAtomicStamped<T, S> atomicStamped(String name, @Nullable T initVal, @Nullable S initStamp,
- boolean create) throws IgniteException {
+ @Override public <T, S> IgniteAtomicStamped<T, S> atomicStamped(
+ String name,
+ @Nullable T initVal,
+ @Nullable S initStamp,
+ boolean create) throws IgniteException
+ {
throw new UnsupportedOperationException("Operation isn't supported yet.");
}
@@ -572,11 +566,7 @@ public class IgniteProcessProxy implements IgniteEx {
}
}, EventType.EVT_NODE_LEFT, EventType.EVT_NODE_FAILED);
- compute().run(new IgniteRunnable() {
- @Override public void run() {
- igniteById().close();
- }
- });
+ compute().run(new StopGridTask(localJvmGrid().name(), true));
try {
assert U.await(rmtNodeStoppedLatch, 15, TimeUnit.SECONDS) : "NodeId=" + id;
@@ -616,4 +606,43 @@ public class IgniteProcessProxy implements IgniteEx {
return locJvmGrid.compute(grp);
}
+
+ /**
+ *
+ */
+ private static class StopGridTask implements IgniteRunnable {
+ /** Grid name. */
+ private final String gridName;
+
+ /** Cancel. */
+ private final boolean cancel;
+
+ /**
+ * @param gridName Grid name.
+ * @param cancel Cancel.
+ */
+ public StopGridTask(String gridName, boolean cancel) {
+ this.gridName = gridName;
+ this.cancel = cancel;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ G.stop(gridName, cancel);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class NodeTask implements IgniteCallable<ClusterNode> {
+ /** Ignite. */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override public ClusterNode call() throws Exception {
+ return ((IgniteEx)ignite).localNode();
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java
index 5298dd4..3777154 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java
@@ -103,6 +103,7 @@ public class CacheConfigurationP2PTest extends GridCommonAbstractTest {
}
},
null,
+ null,
jvmArgs,
null
);
@@ -119,6 +120,7 @@ public class CacheConfigurationP2PTest extends GridCommonAbstractTest {
}
},
null,
+ null,
jvmArgs,
null
);
@@ -139,6 +141,7 @@ public class CacheConfigurationP2PTest extends GridCommonAbstractTest {
}
},
null,
+ null,
jvmArgs,
cp
);