ptupitsyn commented on code in PR #5889: URL: https://github.com/apache/ignite-3/pull/5889#discussion_r2104696380
########## modules/platforms/dotnet/README.md: ########## @@ -222,22 +222,73 @@ await tx.CommitAsync(); ## Compute -Compute API is used to execute distributed computations on the cluster. Compute jobs should be implemented in Java, deployed to server nodes, and called by the full class name. +Compute API is used to execute distributed computations on the cluster. -```cs -IList<IClusterNode> nodes = await client.GetClusterNodesAsync(); +Compute jobs can be implemented in Java or .NET. +Resulting binaries (jar or dll files) should be [deployed](https://ignite.apache.org/docs/ignite3/latest/developers-guide/code-deployment/code-deployment) to the server nodes and called by the full class name. + +Java job invocation example: +```csharp +IList<IClusterNode> nodes = await client.GetClusterNodesAsync(); IJobTarget<IEnumerable<IClusterNode>> jobTarget = JobTarget.AnyNode(nodes); var jobDesc = new JobDescriptor<string, string>( - "org.foo.bar.MyJob"); + JobClassName: "org.foo.bar.MyJob", + DeploymentUnits: [new DeploymentUnit("Unit1")]); IJobExecution<string> jobExecution = await client.Compute.SubmitAsync( jobTarget, jobDesc, "Job Arg"); string jobResult = await jobExecution.GetResultAsync(); ``` +### Implement a .NET Compute Job + +1. Prepare a "class library" project for the job implementations (`dotnet new classlib`). Prefer a separate project for compute jobs to reduce deployment size. +2. Add a reference to `Apache.Ignite` package to the class library project (`dotnet add package Apache.Ignite`). +3. Create a class that implements `IComputeJob<TArg, TRes>` interface + ```csharp + public class HelloJob : IComputeJob<string, string> + { + public ValueTask<string> ExecuteAsync(IJobExecutionContext context, string arg, CancellationToken cancellationToken) => + ValueTask.FromResult("Hello " + arg); + } + ``` +4. Publish the project (`dotnet publish -c Release`) +5. Copy the resulting dll file (and any extra dependencies, EXCLUDING Ignite dlls) to a separate directory. + * Note: The directory must not contain any subdirectories. +6. Use [Ignite CLI](https://ignite.apache.org/docs/ignite3/latest/ignite-cli-tool#cluster-commands) `cluster unit deploy` command to deploy the directory to the cluster as a deployment unit. + +### Run a .NET Compute Job + +.NET compute jobs can be executed from any client (.NET, Java, C++, etc), +by specifying the assembly-qualified class name and using the `JobExecutorType.DotNetSidecar` option. + Review Comment: This README is .NET-focused and already too long, I'd prefer to skip this. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org