ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [20/22] ignite git commit: IGNITE-2882: .NET: Decreased amount of memory consumed by examples to allow the to run smoothly on 32-bit environment. Improved error messages when JVM fails to start. This closes #573.
Date Fri, 25 Mar 2016 11:32:15 GMT
IGNITE-2882: .NET: Decreased amount of memory consumed by examples to allow the to run smoothly
on 32-bit environment. Improved error messages when JVM fails to start. This closes #573.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/090144c4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/090144c4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/090144c4

Branch: refs/heads/ignite-1786
Commit: 090144c4578952335ea30ba9ce266ac0569af8c0
Parents: c63faf6
Author: Pavel Tupitsyn <ptupitsyn@gridgain.com>
Authored: Fri Mar 25 09:21:51 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Fri Mar 25 09:21:51 2016 +0300

----------------------------------------------------------------------
 modules/platforms/cpp/common/src/java.cpp       | 74 ++++++++++++++++----
 .../Examples/ExamplesTest.cs                    |  3 +-
 .../Compute/ClosureExample.cs                   |  2 +-
 .../Compute/TaskExample.cs                      |  2 +-
 .../Datagrid/ContinuousQueryExample.cs          |  2 +-
 .../Datagrid/DataStreamerExample.cs             |  2 +-
 .../Datagrid/PutGetExample.cs                   |  2 +-
 .../Datagrid/QueryExample.cs                    |  2 +-
 .../Datagrid/StoreExample.cs                    |  2 +-
 .../Datagrid/TransactionExample.cs              |  2 +-
 .../Events/EventsExample.cs                     |  2 +-
 .../Messaging/MessagingExample.cs               |  2 +-
 .../Misc/LifecycleExample.cs                    |  2 +-
 .../Services/ServicesExample.cs                 |  2 +-
 14 files changed, 72 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/cpp/common/src/java.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/java.cpp b/modules/platforms/cpp/common/src/java.cpp
index 89f4713..ae06c30 100644
--- a/modules/platforms/cpp/common/src/java.cpp
+++ b/modules/platforms/cpp/common/src/java.cpp
@@ -788,7 +788,7 @@ namespace ignite
             /**
              * Create JVM.
              */
-            void CreateJvm(char** opts, int optsLen, JavaVM** jvm, JNIEnv** env) {
+            jint CreateJvm(char** opts, int optsLen, JavaVM** jvm, JNIEnv** env) {
                 JavaVMOption* opts0 = new JavaVMOption[optsLen];
 
                 for (int i = 0; i < optsLen; i++)
@@ -805,8 +805,7 @@ namespace ignite
 
                 delete[] opts0;
 
-                if (res != JNI_OK)
-                    throw JvmException();
+                return res;
             }
 
             void RegisterNatives(JNIEnv* env) {
@@ -903,6 +902,40 @@ namespace ignite
                 return Create(opts, optsLen, hnds, NULL);
             }
 
+            void GetJniErrorMessage(std::string& errMsg, jint res)
+            {
+                switch (res)
+                {
+                    case JNI_ERR:
+                        errMsg = "Unknown error (JNI_ERR).";
+                        break;
+
+                    case JNI_EDETACHED:
+                        errMsg = "Thread detached from the JVM.";
+                        break;
+
+                    case JNI_EVERSION:
+                        errMsg = "JNI version error.";
+                        break;
+
+                    case JNI_ENOMEM:
+                        errMsg = "Could not reserve enough space for object heap. Check Xmx
option.";
+                        break;
+
+                    case JNI_EEXIST:
+                        errMsg = "JVM already created.";
+                        break;
+
+                    case JNI_EINVAL:
+                        errMsg = "Invalid JVM arguments.";
+                        break;
+
+                    default:
+                        errMsg = "Unexpected JNI_CreateJavaVM result.";
+                        break;
+                }
+            }
+
             JniContext* JniContext::Create(char** opts, int optsLen, JniHandlers hnds, JniErrorInfo*
errInfo)
             {
                 // Acquire global lock to instantiate the JVM.
@@ -926,25 +959,36 @@ namespace ignite
                 int errMsgLen = 0;
 
                 try {
-                    if (!JVM.GetJvm()) {
+                    if (!JVM.GetJvm()) 
+                    {
                         // 1. Create JVM itself.
-                        CreateJvm(opts, optsLen, &jvm, &env);
+                        jint res = CreateJvm(opts, optsLen, &jvm, &env);
 
-                        // 2. Populate members;
-                        javaMembers.Initialize(env);
-                        members.Initialize(env);
+                        if (res == JNI_OK)
+                        {
+                            // 2. Populate members;
+                            javaMembers.Initialize(env);
+                            members.Initialize(env);
 
-                        // 3. Register native functions.
-                        RegisterNatives(env);
+                            // 3. Register native functions.
+                            RegisterNatives(env);
 
-                        // 4. Create JNI JVM.
-                        JVM = JniJvm(jvm, javaMembers, members);
+                            // 4. Create JNI JVM.
+                            JVM = JniJvm(jvm, javaMembers, members);
 
-                        char* printStack = getenv("IGNITE_CPP_PRINT_STACK");
-                        PRINT_EXCEPTION = printStack && strcmp("true", printStack)
== 0;
+                            char* printStack = getenv("IGNITE_CPP_PRINT_STACK");
+                            PRINT_EXCEPTION = printStack && strcmp("true", printStack)
== 0;
+                        }
+                        else
+                        {
+                            GetJniErrorMessage(errMsg, res);
+
+                            errMsgLen = errMsg.length();
+                        }
                     }
 
-                    ctx = new JniContext(&JVM, hnds);
+                    if (JVM.GetJvm())
+                        ctx = new JniContext(&JVM, hnds);
                 }
                 catch (JvmException)
                 {

http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
index 4e8a036..7cf0d57 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
@@ -20,7 +20,6 @@ namespace Apache.Ignite.Core.Tests.Examples
     using System;
     using System.Collections.Generic;
     using System.IO;
-    using System.Linq;
     using Apache.Ignite.Core.Tests.Process;
     using Apache.Ignite.ExamplesDll.Compute;
     using NUnit.Framework;
@@ -104,7 +103,7 @@ namespace Apache.Ignite.Core.Tests.Examples
 
                     var proc = new IgniteProcess(args.ToArray());
 
-                    Assert.IsTrue(ignite.WaitTopology(i + 2, 30000));
+                    Assert.IsTrue(ignite.WaitTopology(i + 2));
                     Assert.IsTrue(proc.Alive);
                 }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
index aeb352f..e1194f8 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
@@ -48,7 +48,7 @@ namespace Apache.Ignite.Examples.Compute
             var cfg = new IgniteConfiguration
             {
                 SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
-                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx512m" }
             };
             
             using (var ignite = Ignition.Start(cfg))

http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs
b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs
index 38faf59..f0bcf13 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs
@@ -49,7 +49,7 @@ namespace Apache.Ignite.Examples.Compute
             var cfg = new IgniteConfiguration
             {
                 SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
-                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx512m" }
             };
 
             using (var ignite = Ignition.Start(cfg))

http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
index ca7f852..8dad1f4 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
@@ -50,7 +50,7 @@ namespace Apache.Ignite.Examples.Datagrid
             var cfg = new IgniteConfiguration
             {
                 SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
-                JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+                JvmOptions = new List<string> {"-Xms512m", "-Xmx512m" }
             };
 
             using (var ignite = Ignition.Start(cfg))

http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
index 1db89fe..08a670f 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
@@ -58,7 +58,7 @@ namespace Apache.Ignite.Examples.Datagrid
             var cfg = new IgniteConfiguration
             {
                 SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
-                JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+                JvmOptions = new List<string> {"-Xms512m", "-Xmx512m" }
             };
 
             using (var ignite = Ignition.Start(cfg))

http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
index 4d38ad9..e2502e8 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
@@ -55,7 +55,7 @@ namespace Apache.Ignite.Examples.Datagrid
             var cfg = new IgniteConfiguration
             {
                 SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
-                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx512m" }
             };
 
             using (var ignite = Ignition.Start(cfg))

http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
index d961f11..809eb65 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
@@ -49,7 +49,7 @@ namespace Apache.Ignite.Examples.Datagrid
             var cfg = new IgniteConfiguration
             {
                 SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache-query.xml",
-                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx512m" }
             };
 
             using (var ignite = Ignition.Start(cfg))

http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
index 421d3bc..1654b41 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
@@ -49,7 +49,7 @@ namespace Apache.Ignite.Examples.Datagrid
             var cfg = new IgniteConfiguration
             {
                 SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache-store.xml",
-                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx512m" }
             };
 
             using (var ignite = Ignition.Start(cfg))

http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
index c2b6e98..e814f8c 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
@@ -49,7 +49,7 @@ namespace Apache.Ignite.Examples.Datagrid
             var cfg = new IgniteConfiguration
             {
                 SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
-                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx512m" }
             };
 
             using (var ignite = Ignition.Start(cfg))

http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
index 42b1777..3b068e8 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
@@ -52,7 +52,7 @@ namespace Apache.Ignite.Examples.Events
             var cfg = new IgniteConfiguration
             {
                 SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
-                JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+                JvmOptions = new List<string> {"-Xms512m", "-Xmx512m" }
             };
 
             using (var ignite = Ignition.Start(cfg))

http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
index 3fafd8f..6438b95 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
@@ -45,7 +45,7 @@ namespace Apache.Ignite.Examples.Messaging
             var cfg = new IgniteConfiguration
             {
                 SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
-                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx512m" }
             };
 
             using (var ignite = Ignition.Start(cfg))

http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
index 4a1162b..bba6719 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
@@ -51,7 +51,7 @@ namespace Apache.Ignite.Examples.Misc
             var cfg = new IgniteConfiguration
             {
                 SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
-                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" },
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx512m" },
                 LifecycleBeans = new List<ILifecycleBean> { lifecycleExampleBean }
             };
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/090144c4/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Services/ServicesExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Services/ServicesExample.cs
b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Services/ServicesExample.cs
index d513305..e57774c 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Services/ServicesExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Services/ServicesExample.cs
@@ -47,7 +47,7 @@ namespace Apache.Ignite.Examples.Services
             var cfg = new IgniteConfiguration
             {
                 SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
-                JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+                JvmOptions = new List<string> {"-Xms512m", "-Xmx512m"}
             };
 
             using (var ignite = Ignition.Start(cfg))


Mime
View raw message