This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new 72d4e747134 IGNITE-25466 .NET: Update NuGet README with platform 
compute info (#5889)
72d4e747134 is described below

commit 72d4e7471349687b2761466bed34563380b8980d
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Mon May 26 12:15:49 2025 +0300

    IGNITE-25466 .NET: Update NuGet README with platform compute info (#5889)
    
    Co-authored-by: IgGusev <[email protected]>
---
 modules/platforms/dotnet/README.md | 61 +++++++++++++++++++++++++++++++++++---
 1 file changed, 57 insertions(+), 4 deletions(-)

diff --git a/modules/platforms/dotnet/README.md 
b/modules/platforms/dotnet/README.md
index 35f6b6772c1..65c58ea7ae0 100644
--- a/modules/platforms/dotnet/README.md
+++ b/modules/platforms/dotnet/README.md
@@ -222,15 +222,22 @@ 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.
+
+### Call a Java Compute Job
 
+You can call [Java computing 
jobs](https://ignite.apache.org/docs/ignite3/latest/developers-guide/compute/compute)
 from your .NET code, for 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");
@@ -238,6 +245,52 @@ IJobExecution<string> jobExecution = await 
client.Compute.SubmitAsync(
 string jobResult = await jobExecution.GetResultAsync();
 ```
 
+### Implement a .NET Compute Job
+
+1. Prepare a "class library" project for the job implementation (`dotnet new 
classlib`). In most cases, it is better to use 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, for 
example:
+    ```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 with the dll 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.
+
+```csharp
+var jobTarget = JobTarget.AnyNode(await client.GetClusterNodesAsync());
+var jobDesc = new JobDescriptor<string, string>(
+    JobClassName: typeof(HelloJob).AssemblyQualifiedName!,
+    DeploymentUnits: [new DeploymentUnit("unit1")],
+    Options: new JobExecutionOptions(ExecutorType: 
JobExecutorType.DotNetSidecar));
+
+IJobExecution<string> jobExec = await client.Compute.SubmitAsync(jobTarget, 
jobDesc, "world");
+```
+
+Alternatively, use the `JobDescriptor.Of` shortcut method to create a job 
descriptor from a job instance:
+
+```csharp
+JobDescriptor<string, string> jobDesc = JobDescriptor.Of(new HelloJob())
+    with { DeploymentUnits = [new DeploymentUnit("unit1")] };
+```
+
+#### Notes
+
+* .NET 8 (or later) runtime (not SDK) is required on the server nodes.
+* .NET compute jobs are executed in a separate process (sidecar) on the server 
node. 
+* The process is started on the first .NET job call and then reused for 
subsequent jobs.
+* Every deployment unit combination is loaded into a separate 
[AssemblyLoadContext](https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/understanding-assemblyloadcontext).
+
 
 ## Failover, Retry, Reconnect, Load Balancing
 

Reply via email to