-
Notifications
You must be signed in to change notification settings - Fork 1.9k
IGNITE-27341 .ΝΕΤ: Propagate compute task names to Java #12609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c026098
IGNITE-27341 Introduced task name for .Net compute tasks.
ravxz 76d74cf
IGNITE-27341 Rolled back changes in .Net compute task API.
ravxz aefc7df
IGNITE-27341 Fixed checkstyle
ravxz 6516262
IGNITE-27341 Introduced auto test for .Net compute task name propagat…
ravxz f165e53
Fix after code review
ravxz 2b7160f
IGNITE-27341 Fixed auto test
ravxz dc02af1
IGNITE-27341 Introduced taskName field to PlatformAbstractTask. Propa…
ravxz 88cfe6d
IGNITE-27341 Introduced tests for other compute methods.
ravxz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 173 additions & 0 deletions
173
modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeTaskName.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| /* | ||
| * 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.Compute | ||
| { | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Net; | ||
| using System.Threading; | ||
| using Apache.Ignite.Core.Binary; | ||
| using Apache.Ignite.Core.Cache.Affinity; | ||
| using Apache.Ignite.Core.Cache.Query; | ||
| using Apache.Ignite.Core.Client; | ||
| using Apache.Ignite.Core.Compute; | ||
| using NUnit.Framework; | ||
| using static TestUtils; | ||
|
|
||
| /// <summary> | ||
| /// Tests for <see cref="IComputeTaskSession"/> | ||
| /// </summary> | ||
| public class ComputeTaskNameTest | ||
| { | ||
| /** First node. */ | ||
| private IIgnite _grid1; | ||
|
|
||
| /** Second node. */ | ||
| private IIgnite _grid2; | ||
|
|
||
| /** Third node. */ | ||
| private IIgnite _grid3; | ||
|
|
||
| /** Thin client. */ | ||
| private IIgniteClient _igniteClient; | ||
|
|
||
| /// <summary> | ||
| /// Initialization routine. | ||
| /// </summary> | ||
| [TestFixtureSetUp] | ||
| public void InitClient() | ||
| { | ||
| var configs = GetConfigs(); | ||
|
|
||
| _grid1 = Ignition.Start(Configuration(configs.Item1)); | ||
| _grid2 = Ignition.Start(Configuration(configs.Item2)); | ||
|
|
||
| AffinityTopologyVersion waitingTop = new AffinityTopologyVersion(2, 1); | ||
|
|
||
| Assert.True(_grid1.WaitTopology(waitingTop), "Failed to wait topology " + waitingTop); | ||
|
|
||
| _grid3 = Ignition.Start(Configuration(configs.Item3)); | ||
|
|
||
| // Start thin client. | ||
| _igniteClient = Ignition.StartClient(GetThinClientConfiguration()); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the configs. | ||
| /// </summary> | ||
| protected virtual Tuple<string, string, string> GetConfigs() | ||
| { | ||
| var path = Path.Combine("Config", "Compute", "compute-grid"); | ||
|
|
||
| return Tuple.Create(path + "1.xml", path + "2.xml", path + "3.xml"); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the thin client configuration. | ||
| /// </summary> | ||
| private static IgniteClientConfiguration GetThinClientConfiguration() | ||
| { | ||
| return new IgniteClientConfiguration | ||
| { | ||
| Endpoints = new List<string> { IPAddress.Loopback.ToString() }, | ||
| SocketTimeout = TimeSpan.FromSeconds(15) | ||
| }; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// .Net compute task name is written into java task. Checked in System Views (via SQL). | ||
| /// </summary> | ||
| [Test] | ||
| public void TaskNameTakenFromPlatformTask() | ||
| { | ||
| // Call task asynchronously with delay | ||
| var task = new LongTask(3000); | ||
| _grid1.GetCompute().ExecuteAsync(task, 123); | ||
|
|
||
| // Check task in system views via SQL | ||
| var results = _grid1 | ||
| .GetOrCreateCache<string, string>("test") | ||
| .Query(new SqlFieldsQuery("SELECT * FROM SYS.TASKS", null)).GetAll(); | ||
|
|
||
| Assert.AreEqual(1, results.Count()); | ||
| Assert.AreEqual("Apache.Ignite.Core.Tests.Compute.ComputeTaskNameTest+LongTask", results[0][3]); | ||
| Assert.AreEqual("org.apache.ignite.internal.processors.platform.compute.PlatformFullTask", results[0][4]); | ||
ravxz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /// <summary> | ||
| /// Create configuration. | ||
| /// </summary> | ||
| /// <param name="path">XML config path.</param> | ||
| private static IgniteConfiguration Configuration(string path) | ||
| { | ||
| return new IgniteConfiguration(TestUtils.GetTestConfiguration()) | ||
| { | ||
| BinaryConfiguration = new BinaryConfiguration | ||
| { | ||
| NameMapper = new BinaryBasicNameMapper { IsSimpleName = true } | ||
| }, | ||
| SpringConfigUrl = path | ||
| }; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Creates a task that executes <see cref="LongJob"/>. | ||
| /// </summary> | ||
| [ComputeTaskSessionFullSupport] | ||
| private class LongTask : ComputeTaskSplitAdapter<int, string, string> | ||
| { | ||
| private readonly int _delay; | ||
|
|
||
| public LongTask(int delay) | ||
| { | ||
| _delay = delay; | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public override string Reduce(IList<IComputeJobResult<string>> results) => results[0].Data; | ||
|
|
||
| /// <inheritdoc /> | ||
| protected override ICollection<IComputeJob<string>> Split(int gridSize, int attrValue) | ||
| { | ||
| return new List<IComputeJob<string>> {new LongJob(_delay)}; | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Implements delayed jow execution. | ||
| /// </summary> | ||
| private class LongJob : ComputeJobAdapter<string> | ||
| { | ||
| private readonly int _delay; | ||
|
|
||
| public LongJob(int delay) | ||
| { | ||
| _delay = delay; | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public override string Execute() | ||
| { | ||
| Thread.Sleep(_delay); | ||
| return "OK"; | ||
| } | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.