IGNITE-9301 Support method compute withNoResultCache in .Net - Fixes #4570.
Signed-off-by: Dmitriy Pavlov <dpav...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5994a58a Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5994a58a Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5994a58a Branch: refs/heads/ignite-9273 Commit: 5994a58a85d72029b6167710fd46b5d20f5eecc6 Parents: 9b00097 Author: Aleksei Zaitsev <m...@alexzaitzev.pro> Authored: Fri Aug 24 16:05:37 2018 +0300 Committer: Dmitriy Pavlov <dpav...@apache.org> Committed: Fri Aug 24 16:05:37 2018 +0300 ---------------------------------------------------------------------- .../platform/compute/PlatformCompute.java | 10 +++ .../Apache.Ignite.Core.Tests.csproj | 4 ++ .../ApiParity/ComputeParityTest.cs | 3 +- .../Client/ClientConnectionTest.cs | 5 +- .../Compute/ComputeApiTest.cs | 3 +- .../Apache.Ignite.Core.Tests/EventsTest.cs | 4 +- .../Examples/PathUtil.cs | 2 +- .../Impl/Compute/ComputeImplTest.cs | 65 ++++++++++++++++++++ .../Services/ServicesTest.cs | 3 +- .../Apache.Ignite.Core.Tests/packages.config | 1 + .../Apache.Ignite.Core/Compute/ICompute.cs | 6 ++ .../Apache.Ignite.Core/Impl/Compute/Compute.cs | 8 +++ .../Impl/Compute/ComputeImpl.cs | 11 ++++ .../Properties/AssemblyInfo.cs | 1 + 14 files changed, 118 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/5994a58a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java index 6012625..ed61021 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java @@ -74,6 +74,9 @@ public class PlatformCompute extends PlatformAbstractTarget { /** */ private static final int OP_EXEC_NATIVE = 8; + /** */ + private static final int OP_WITH_NO_RESULT_CACHE = 9; + /** Compute instance. */ private final IgniteComputeImpl compute; @@ -145,6 +148,13 @@ public class PlatformCompute extends PlatformAbstractTarget { return TRUE; } + + case OP_WITH_NO_RESULT_CACHE: { + compute.withNoResultCache(); + computeForPlatform.withNoResultCache(); + + return TRUE; + } } return super.processInLongOutLong(type, val); http://git-wip-us.apache.org/repos/asf/ignite/blob/5994a58a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj index 00eddeb..3a4ef03 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj @@ -47,6 +47,9 @@ <Private>True</Private> </Reference> <Reference Include="Microsoft.CSharp" /> + <Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL"> + <HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath> + </Reference> <Reference Include="NLog"> <HintPath>..\packages\NLog.4.3.7\lib\net40\NLog.dll</HintPath> </Reference> @@ -195,6 +198,7 @@ <Compile Include="Deployment\RuntimeDependencyFunc.cs" /> <Compile Include="EventsTestLocalListeners.cs" /> <Compile Include="FailureHandlerTest.cs" /> + <Compile Include="Impl\Compute\ComputeImplTest.cs" /> <Compile Include="Process\ListDataReader.cs" /> <Compile Include="Log\ConcurrentMemoryTarget.cs" /> <Compile Include="Log\DefaultLoggerTest.cs" /> http://git-wip-us.apache.org/repos/asf/ignite/blob/5994a58a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ComputeParityTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ComputeParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ComputeParityTest.cs index 012b585..e3f47ae 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ComputeParityTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ComputeParityTest.cs @@ -33,8 +33,7 @@ namespace Apache.Ignite.Core.Tests.ApiParity "localTasks", // Java-specific (classloaders) "undeployTask", // Java-specific (classloaders) "withName", // Java-specific (classloaders) - "activeTaskFutures", - "withNoResultCache" // https://issues.apache.org/jira/browse/IGNITE-9301 + "activeTaskFutures" }; /// <summary> http://git-wip-us.apache.org/repos/asf/ignite/blob/5994a58a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs index 67d1c52..14d1abf 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs @@ -31,6 +31,7 @@ namespace Apache.Ignite.Core.Tests.Client using Apache.Ignite.Core.Client; using Apache.Ignite.Core.Client.Cache; using Apache.Ignite.Core.Configuration; + using Apache.Ignite.Core.Impl.Client; using Apache.Ignite.Core.Impl.Common; using NUnit.Framework; @@ -251,8 +252,8 @@ namespace Apache.Ignite.Core.Tests.Client { // ReSharper disable once ObjectCreationAsStatement var ex = Assert.Throws<IgniteClientException>(() => - new Impl.Client.ClientSocket(GetClientConfiguration(), - new Impl.Client.ClientProtocolVersion(-1, -1, -1))); + new ClientSocket(GetClientConfiguration(), + new ClientProtocolVersion(-1, -1, -1))); Assert.AreEqual(ClientStatusCode.Fail, ex.StatusCode); http://git-wip-us.apache.org/repos/asf/ignite/blob/5994a58a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs index d0c576d..d41b4a6 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs @@ -27,6 +27,7 @@ namespace Apache.Ignite.Core.Tests.Compute using Apache.Ignite.Core.Cluster; using Apache.Ignite.Core.Compute; using Apache.Ignite.Core.Events; + using Apache.Ignite.Core.Impl; using Apache.Ignite.Core.Resource; using NUnit.Framework; @@ -800,7 +801,7 @@ namespace Apache.Ignite.Core.Tests.Compute [Test] public void TestFooterSetting() { - Assert.AreEqual(CompactFooter, ((Impl.Ignite) _grid1).Marshaller.CompactFooter); + Assert.AreEqual(CompactFooter, ((Ignite) _grid1).Marshaller.CompactFooter); foreach (var g in new[] {_grid1, _grid2, _grid3}) Assert.AreEqual(CompactFooter, g.GetConfiguration().BinaryConfiguration.CompactFooter); http://git-wip-us.apache.org/repos/asf/ignite/blob/5994a58a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs index e9bac02..7162d3e 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs @@ -40,6 +40,8 @@ namespace Apache.Ignite.Core.Tests using Apache.Ignite.Core.Tests.Compute; using NUnit.Framework; + using ImplCompute = Core.Impl.Compute.Compute; + /// <summary> /// <see cref="IEvents"/> tests. /// </summary> @@ -509,7 +511,7 @@ namespace Apache.Ignite.Core.Tests public void TestSerialization() { var grid = (Ignite) _grid1; - var comp = (Impl.Compute.Compute) grid.GetCluster().ForLocal().GetCompute(); + var comp = (ImplCompute) grid.GetCluster().ForLocal().GetCompute(); var locNode = grid.GetCluster().GetLocalNode(); var expectedGuid = Guid.Parse("00000000-0000-0001-0000-000000000002"); http://git-wip-us.apache.org/repos/asf/ignite/blob/5994a58a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs index 7c82d80..9295d29 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs @@ -28,7 +28,7 @@ namespace Apache.Ignite.Core.Tests.Examples public const string DevPrefix = "modules\\"; /** */ - public static readonly string IgniteHome = Impl.Common.IgniteHome.Resolve(null); + public static readonly string IgniteHome = Core.Impl.Common.IgniteHome.Resolve(null); /// <summary> /// Examples source code path. http://git-wip-us.apache.org/repos/asf/ignite/blob/5994a58a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Impl/Compute/ComputeImplTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Impl/Compute/ComputeImplTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Impl/Compute/ComputeImplTest.cs new file mode 100644 index 0000000..c888dda --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Impl/Compute/ComputeImplTest.cs @@ -0,0 +1,65 @@ +/* + * 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. + */ + +namespace Apache.Ignite.Core.Tests.Impl.Compute +{ + using Apache.Ignite.Core.Binary; + using Apache.Ignite.Core.Impl; + using Apache.Ignite.Core.Impl.Binary; + using Apache.Ignite.Core.Impl.Cluster; + using Apache.Ignite.Core.Impl.Compute; + using Moq; + using NUnit.Framework; + + /// <summary> + /// Tests for the compute implementations + /// </summary> + [TestFixture] + internal class ComputeImplTest + { + private const int OpWithNoResultCacheType = 9; + + /// <summary> + /// Test caching was disabled by passing right type + /// </summary> + [Test] + public void TestCachingWasDisabledByPassingRightType() + { + var target = GetTarget(); + var clusterGroupImpl = new ClusterGroupImpl(target.Object, null); + var sut = new ComputeImpl(target.Object, clusterGroupImpl, true); + + sut.WithNoResultCache(); + + target.Verify(x => x.InLongOutLong(OpWithNoResultCacheType, It.IsAny<long>()), Times.Once()); + } + + private static Mock<IPlatformTargetInternal> GetTarget() + { + var target = new Mock<IPlatformTargetInternal>(); + target + .Setup(x => x.InLongOutLong(It.IsAny<int>(), It.IsAny<long>())) + .Returns(1L); + + target + .SetupGet(x => x.Marshaller) + .Returns(new Marshaller(new BinaryConfiguration())); + + return target; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/5994a58a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs index 017a580..81c3652 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs @@ -28,6 +28,7 @@ namespace Apache.Ignite.Core.Tests.Services using Apache.Ignite.Core.Binary; using Apache.Ignite.Core.Cluster; using Apache.Ignite.Core.Common; + using Apache.Ignite.Core.Impl; using Apache.Ignite.Core.Resource; using Apache.Ignite.Core.Services; using NUnit.Framework; @@ -957,7 +958,7 @@ namespace Apache.Ignite.Core.Tests.Services { foreach (var grid in Grids) { - Assert.AreEqual(CompactFooter, ((Impl.Ignite) grid).Marshaller.CompactFooter); + Assert.AreEqual(CompactFooter, ((Ignite) grid).Marshaller.CompactFooter); Assert.AreEqual(CompactFooter, grid.GetConfiguration().BinaryConfiguration.CompactFooter); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/5994a58a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/packages.config ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/packages.config b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/packages.config index ccf079c..76c4c87 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/packages.config +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/packages.config @@ -20,5 +20,6 @@ <packages> <package id="NUnit.Runners" version="2.6.3" targetFramework="net40" /> <package id="log4net" version="2.0.5" targetFramework="net40" /> + <package id="Moq" version="4.0.10827" targetFramework="net40" /> <package id="NLog" version="4.3.7" targetFramework="net40" /> </packages> http://git-wip-us.apache.org/repos/asf/ignite/blob/5994a58a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs index f3bdb7d..7d70f97 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs @@ -63,6 +63,12 @@ namespace Apache.Ignite.Core.Compute ICompute WithNoFailover(); /// <summary> + /// Disables caching for the next executed task in the current thread. + /// </summary> + /// <returns>This compute instance for chaining calls.</returns> + ICompute WithNoResultCache(); + + /// <summary> /// Sets task timeout for the next executed task on this projection in the current thread. /// When task starts execution, the timeout is reset, so one timeout is used only once. /// </summary> http://git-wip-us.apache.org/repos/asf/ignite/blob/5994a58a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs index b54d6a9..efea1c7 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs @@ -60,6 +60,14 @@ namespace Apache.Ignite.Core.Impl.Compute } /** <inheritDoc /> */ + public ICompute WithNoResultCache() + { + _compute.WithNoResultCache(); + + return this; + } + + /** <inheritDoc /> */ public ICompute WithTimeout(long timeout) { _compute.WithTimeout(timeout); http://git-wip-us.apache.org/repos/asf/ignite/blob/5994a58a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs index 3c684ae..05efe3c 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs @@ -65,6 +65,9 @@ namespace Apache.Ignite.Core.Impl.Compute /** */ private const int OpExecNative = 8; + /** */ + private const int OpWithNoResultCache = 9; + /** Underlying projection. */ private readonly ClusterGroupImpl _prj; @@ -118,6 +121,14 @@ namespace Apache.Ignite.Core.Impl.Compute } /// <summary> + /// Disables caching for the next executed task in the current thread. + /// </summary> + public void WithNoResultCache() + { + DoOutInOp(OpWithNoResultCache); + } + + /// <summary> /// Sets keep-binary flag for the next executed Java task on this projection in the current /// thread so that task argument passed to Java and returned task results will not be /// deserialized. http://git-wip-us.apache.org/repos/asf/ignite/blob/5994a58a/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs index 94af7f8..c403c1f 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs @@ -41,6 +41,7 @@ using System.Runtime.InteropServices; #if !EXCLUDE_INTERNALS_VISIBLE_TO +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] [assembly: InternalsVisibleTo("Apache.Ignite.Core.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a5bf8e0062a26bde53ccf0f8c42ef5b122a22052f99aecacb7028adcc163050324ee3c75ff40eb0cbe2d0426fa20eca03726cad90d7eb882ff47f5361567a82b676a27565f88b2479d7b9354ae0a1e526ee781b6e11de943d8f4a49efb53765f8c954022bede0fca86c133fab038af8dc88b67d6b6e5b9796d6ca490e699efab")] [assembly: InternalsVisibleTo("Apache.Ignite.Benchmarks, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a3e0c1df4cbedbd4ed0e88808401c69b69ec12575ed1c056ac9f448e018fb29af19d236b7b03563aad66c48ab2045e72971ed098d4f65d4cdd38d65abcb39b4f84c626b22ccab2754375f0e8c97dc304fa146f0eddad5cc40a71803a8f15b0b0bb0bff0d4bf0ff6a64bb1044e0d71e6e2405b83fd4c1f7b3e2cfc2e9d50823d4")] [assembly: InternalsVisibleTo("Apache.Ignite.AspNet.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c9380ce05eb74bd7c531f72e9ea615c59d7eceb09bd9795cb3dff1fcf638fd799c2a58a9be42fff156efe1c8cdebb751e27763f6c9a7c80cdc1dc1bbf44283608ef18ccd5017fd57b2b026503637c89c2537f361807f3bdd49265f4d444716159d989342561d324b1a0961640338bb32eaf67f4ae0c95f1b210f65404b0909c6")]