Apache Ignite.NET Documentation

The Apache Ignite .NET Developer Hub

Welcome to the Apache Ignite .NET developer hub. You'll find comprehensive guides and documentation to help you start working with Apache Ignite.NET as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Getting Started

This page will help you get started with Apache Ignite.NET. You'll be up and running in a jiffy!

Prerequisites

Name
Value

JDK

8+

OS

Windows (7 and up),
Windows Server (2008 R2 and up),
Linux (any distro with .NET Core support),
macOS

Network

No restrictions (10G recommended)

Hardware

No restrictions

.NET Framework

.NET 4.0+, .NET Core 2.0+

IDE

Visual Studio 2010+, Rider, Visual Studio Code, MonoDevelop

The guide below is for Windows and Visual Studio. See Cross-Platform guide for Linux and macOS usage instructions.

Installation

NuGet

NuGet is the most convenient way to include Ignite.NET into your project. Type the following in Package Manager Console: Install-Package Apache.Ignite

Or search for the package in the NuGet gallery: https://www.nuget.org/packages/Apache.Ignite/

Installing NuGet package will update your project's post-build event to copy Libs folder to the output directory. See Deployment page for more details.

Upgrading NuGet packages

When upgrading to a new version of Ignite.NET, make sure to clean "bin" folder and rebuild the solution so that Libs folder is updated.

Binary Distribution

Binary distribution package includes Ignite, Ignite.NET, Ignite.C++, optional Java packages, examples, and more:

Run examples:

  • Open platforms\dotnet\examples\Apache.Ignite.Examples.sln
  • Open Apache.Ignite.Examples project properties and select an example via Startup object combobox
  • Optionally: start a standalone node with Apache.Ignite.exe -configFileName=platforms\dotnet\examples\Apache.Ignite.Examples\App.config -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
  • Run the example with F5 or Ctrl-F5

Source Distribution

Apache Ignite.NET is based on Apache Ignite, and requires building Java sources first. Please refer to Apache Ignite Getting Started page: https://apacheignite.readme.io/docs/getting-started

You can build Java sources, .NET sources, and NuGet packages via a single build.bat or build.ps1 script (in modules\platforms\dotnet\ folder).

rem Switch to Ignite.NET directory
cd modules\platforms\dotnet

build

Start From Command Line

An Ignite node can be started from a command line either with default configuration or by passing a configuration file. You can start as many nodes as you like and they will automatically discover each other. Assuming that you are in Ignite installation folder, type this in command line:

platforms\dotnet\bin\Apache.Ignite.exe

You will see the output similar to this:

[02:49:12] Ignite node started OK (id=ab5d18a6)
[02:49:12] Topology snapshot [ver=1, nodes=1, CPUs=8, heap=1.0GB]

Refer to this page to learn more on how to spawn standalone Ignite.NET nodes and use various configuration parameters.

First Ignite Compute Application

Let's write our first grid application which will count a number of non-white-space characters in a sentence. As an example, we will take a sentence, split it into multiple words, and have every compute job count number of characters in each individual word. At the end we simply add up results received from individual jobs to get our total count.

  • Create a new console application project
  • When using NuGet: Install Apache Ignite.NET NuGet package
  • When using full distro: add reference to platforms\dotnet\bin\Apache.Ignite.Core.dll
static void Compute()
{
    using (var ignite = Ignition.Start())
    {
        var funcs = "Count characters using callable".Split(' ')
          .Select(word => new ComputeFunc { Word = word });

        ICollection<int> res = ignite.GetCompute().Call(funcs);

        var sum = res.Sum();

        Console.WriteLine(">>> Total number of characters in the phrase is '{0}'.", sum);
    }
}

class ComputeFunc : IComputeFunc<int>
{
    public string Word { get; set; }

    public int Invoke()
    {
        return Word.Length;
    }
}

First Ignite Data Grid Application

Now let's write a simple set of mini-examples which will put and get values to/from distributed cache, and perform basic transactions.

using (var ignite = Ignition.Start())
{
    var cache = ignite.GetOrCreateCache<int, string>("myCache");

    // Store keys in cache (values will end up on different cache nodes).
    for (int i = 0; i < 10; i++)
        cache.Put(i, i.ToString());

    for (int i = 0; i < 10; i++)
        Console.WriteLine("Got [key={0}, val={1}]", i, cache.Get(i));
}
// Put-if-absent which returns previous value.
CacheResult<string> oldVal = cache.GetAndPutIfAbsent(11, "Hello");

// Put-if-absent which returns boolean success flag.
bool success = cache.PutIfAbsent(22, "World");

// Replace-if-exists operation (opposite of getAndPutIfAbsent), returns previous value.
oldVal = cache.GetAndReplace(11, "Hello");

// Replace-if-exists operation (opposite of putIfAbsent), returns boolean success flag.
success = cache.Replace(22, "World");

// Replace-if-matches operation.
success = cache.Replace(22, "World", "World!");

// Remove-if-matches operation.
success = cache.Remove(1, "Hello");
using (var tx = ignite.GetTransactions().TxStart())
{
    var hello = cache.Get(1);

    if (hello == "1")
        cache.Put(1, "Hello");

    cache.Put(22, "World");

    tx.Commit();
}
// Lock cache key "11".
using (var cacheLock = cache.Lock(11))
{
    cacheLock.Enter();

    try
    {
        cache.Put(11, "Hello");
        cache.Put(22, "World");
    }
    finally 
    {
        cacheLock.Exit();
    }
}

Ignite Visor Admin Console

The easiest way to examine the content of the data grid as well as perform a long list of other management and monitoring operations is to use Ignite Visor Command Line Utility.

To start Visor run:

bin\ignitevisorcmd.bat

Getting started in LINQPad

LINQPad is excellent for quickly trying things out.
Apache Ignite.NET NuGet package includes LINQPad samples.

  • Reference NuGet package: F4 -> Add NuGet...
  • Go to Samples tab -> nuget -> Apache.Ignite

More details: Using Apache Ignite.NET in LINQPad

See also

Getting Started with Apache Ignite.NET blog series covers the basics of creating an Ignite.NET application.