ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [26/50] [abbrv] ignite git commit: IGNITE-4216 .NET: Fix PlatformAffinityFunction to inject resource into baseFunc
Date Tue, 22 Nov 2016 11:40:15 GMT
IGNITE-4216 .NET: Fix PlatformAffinityFunction to inject resource into baseFunc


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

Branch: refs/heads/master
Commit: 85a4b966fdfb7018d1c91b73df1659082128f786
Parents: d69e26d
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Mon Nov 14 13:38:33 2016 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Mon Nov 14 13:39:56 2016 +0300

----------------------------------------------------------------------
 .../affinity/PlatformAffinityFunction.java      |  7 ++++-
 .../dotnet/PlatformDotNetAffinityFunction.java  |  9 ++----
 .../Cache/Affinity/AffinityFunctionTest.cs      | 33 ++++++++++++++++++--
 .../Apache.Ignite.Core.Tests/TestUtils.cs       |  3 +-
 4 files changed, 41 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/85a4b966/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityFunction.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityFunction.java
index 1e844e7..8076a19 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityFunction.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinityFunction.java
@@ -18,10 +18,12 @@
 package org.apache.ignite.internal.processors.platform.cache.affinity;
 
 import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.cache.affinity.AffinityFunction;
 import org.apache.ignite.cache.affinity.AffinityFunctionContext;
 import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.binary.BinaryRawWriterEx;
 import org.apache.ignite.internal.processors.platform.PlatformContext;
 import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
@@ -298,7 +300,10 @@ public class PlatformAffinityFunction implements AffinityFunction, Externalizabl
      */
     @SuppressWarnings("unused")
     @IgniteInstanceResource
-    public void setIgnite(Ignite ignite) {
+    public void setIgnite(Ignite ignite) throws IgniteCheckedException {
         this.ignite = ignite;
+
+        if (baseFunc != null && ignite != null)
+            ((IgniteEx)ignite).context().resource().injectGeneric(baseFunc);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/85a4b966/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetAffinityFunction.java
b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetAffinityFunction.java
index 483fd22..f9f457d 100644
--- a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetAffinityFunction.java
+++ b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetAffinityFunction.java
@@ -18,17 +18,12 @@
 package org.apache.ignite.platform.dotnet;
 
 import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.binary.BinaryRawWriter;
 import org.apache.ignite.cache.affinity.AffinityFunction;
 import org.apache.ignite.cache.affinity.AffinityFunctionContext;
 import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.internal.binary.BinaryRawWriterEx;
-import org.apache.ignite.internal.processors.platform.PlatformContext;
 import org.apache.ignite.internal.processors.platform.cache.affinity.PlatformAffinityFunction;
-import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
-import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
-import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
 import org.apache.ignite.lifecycle.LifecycleAware;
 import org.apache.ignite.resources.IgniteInstanceResource;
 
@@ -178,7 +173,7 @@ public class PlatformDotNetAffinityFunction implements AffinityFunction,
Externa
      */
     @SuppressWarnings("unused")
     @IgniteInstanceResource
-    private void setIgnite(Ignite ignite) {
+    private void setIgnite(Ignite ignite) throws IgniteCheckedException {
         assert func != null;
 
         func.setIgnite(ignite);

http://git-wip-us.apache.org/repos/asf/ignite/blob/85a4b966/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityFunctionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityFunctionTest.cs
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityFunctionTest.cs
index f38cb3e..d4b6680 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityFunctionTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityFunctionTest.cs
@@ -100,8 +100,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Affinity
         public void FixtureTearDown()
         {
             // Check that affinity handles are present
-            TestUtils.AssertHandleRegistryHasItems(_ignite, _ignite.GetCacheNames().Count
- 1, 0);
-            TestUtils.AssertHandleRegistryHasItems(_ignite2, _ignite.GetCacheNames().Count
- 1, 0);
+            TestUtils.AssertHandleRegistryHasItems(_ignite, _ignite.GetCacheNames().Count
- 3, 0);
+            TestUtils.AssertHandleRegistryHasItems(_ignite2, _ignite.GetCacheNames().Count
- 3, 0);
 
             // Destroy all caches
             _ignite.GetCacheNames().ToList().ForEach(_ignite.DestroyCache);
@@ -165,6 +165,34 @@ namespace Apache.Ignite.Core.Tests.Cache.Affinity
         }
 
         /// <summary>
+        /// Tests the dynamic cache with predefined functions.
+        /// </summary>
+        [Test]
+        public void TestDynamicCachePredefined()
+        {
+            var caches = new[]
+            {
+                new CacheConfiguration("rendezvousPredefined")
+                {
+                    AffinityFunction = new RendezvousAffinityFunction {Partitions = 1234}
+                },
+                new CacheConfiguration("fairPredefined")
+                {
+                    AffinityFunction = new FairAffinityFunction {Partitions = 1234}
+                },
+            }.Select(_ignite.CreateCache<int, int>);
+
+            foreach (var cache in caches)
+            {
+                Assert.AreEqual(1234, cache.GetConfiguration().AffinityFunction.Partitions);
+
+                cache[1] = 2;
+
+                Assert.AreEqual(2, cache[1]);
+            }
+        }
+
+        /// <summary>
         /// Verifies the cache affinity.
         /// </summary>
         private static void VerifyCacheAffinity(ICache<int, int> cache)
@@ -231,6 +259,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Affinity
             });
 
             var ex = Assert.Throws<CacheException>(() => cache.Put(1, 2));
+            Assert.IsNotNull(ex.InnerException);
             Assert.AreEqual("User error", ex.InnerException.Message);
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/85a4b966/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
index 88a2b52..5073b1a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
@@ -284,7 +284,8 @@ namespace Apache.Ignite.Core.Tests
             var items = handleRegistry.GetItems().Where(x => !(x.Value is LifecycleBeanHolder)).ToList();
 
             if (items.Any())
-                Assert.Fail("HandleRegistry is not empty in grid '{0}':\n '{1}'", grid.Name,
+                Assert.Fail("HandleRegistry is not empty in grid '{0}' (expected {1}, actual
{2}):\n '{3}'", 
+                    grid.Name, expectedCount, handleRegistry.Count,
                     items.Select(x => x.ToString()).Aggregate((x, y) => x + "\n" +
y));
         }
 


Mime
View raw message