Apache.Ignite
3.0.0-nightly20241216-g4530aa288f
Prefix Reserved
dotnet add package Apache.Ignite --version 3.0.0-nightly20241216-g4530aa288f
NuGet\Install-Package Apache.Ignite -Version 3.0.0-nightly20241216-g4530aa288f
<PackageReference Include="Apache.Ignite" Version="3.0.0-nightly20241216-g4530aa288f" />
paket add Apache.Ignite --version 3.0.0-nightly20241216-g4530aa288f
#r "nuget: Apache.Ignite, 3.0.0-nightly20241216-g4530aa288f"
// Install Apache.Ignite as a Cake Addin #addin nuget:?package=Apache.Ignite&version=3.0.0-nightly20241216-g4530aa288f&prerelease // Install Apache.Ignite as a Cake Tool #tool nuget:?package=Apache.Ignite&version=3.0.0-nightly20241216-g4530aa288f&prerelease
Apache Ignite 3 .NET Client
.NET client for Apache Ignite - a distributed database for high‑performance applications with in‑memory speed.
Key Features
- Full support of all Ignite APIs: SQL, Transactions, Key/Value, Compute.
- Connects to any number of Ignite nodes at the same time.
- Partition awareness: sends key-based requests to the right node.
- Load-balancing, failover, automatic reconnection and request retries.
- Built-in LINQ provider for strongly-typed SQL queries.
- Integrates with NodaTime to provide precise mapping to Ignite date/time types.
- Logging and metrics.
- High performance and fully asynchronous.
Getting Started
Below are a few examples of basic usage to get you started:
// Connect to the cluster.
var cfg = new IgniteClientConfiguration("127.0.0.1:10800");
IIgniteClient client = await IgniteClient.StartAsync(cfg);
// Start a read-only transaction.
await using var tx = await client.Transactions.BeginAsync(
new TransactionOptions { ReadOnly = true });
// Get table by name.
ITable? table = await client.Tables.GetTableAsync("Person");
// Get a strongly-typed view of table data using Person record.
IRecordView<Person> view = table!.GetRecordView<Person>();
// Upsert a record with KV (NoSQL) API.
await view.UpsertAsync(tx, new Person(1, "John"));
// Query data with SQL.
await using var resultSet = await client.Sql.ExecuteAsync<Person>(
tx, "SELECT * FROM Person");
List<Person> sqlResults = await resultSet.ToListAsync();
// Query data with LINQ.
List<string> names = view.AsQueryable(tx)
.OrderBy(person => person.Name)
.Select(person => person.Name)
.ToList();
// Execute a distributed computation.
IList<IClusterNode> nodes = await client.GetClusterNodesAsync();
int wordCount = await client.Compute.ExecuteAsync<int>(
nodes, "org.foo.bar.WordCountTask", "Hello, world!");
API Walkthrough
Configuration
IgniteClientConfiguration
is used to configure connections properties (endpoints, SSL), retry policy, logging, and timeouts.
var cfg = new IgniteClientConfiguration
{
// Connect to multiple servers.
Endpoints = { "server1:10800", "server2:10801" },
// Enable TLS.
SslStreamFactory = new SslStreamFactory
{
SslClientAuthenticationOptions = new SslClientAuthenticationOptions
{
// Allow self-signed certificates.
RemoteCertificateValidationCallback =
(sender, certificate, chain, errors) => true
}
},
// Retry all read operations in case of network issues.
RetryPolicy = new RetryReadPolicy { RetryLimit = 32 }
};
SQL
SQL is the primary API for data access. It is used to create, drop, and query tables, as well as to insert, update, and delete data.
using var client = await IgniteClient.StartAsync(new("localhost"));
await client.Sql.ExecuteAsync(
null, "CREATE TABLE Person (Id INT PRIMARY KEY, Name VARCHAR)");
await client.Sql.ExecuteAsync(
null, "INSERT INTO Person (Id, Name) VALUES (1, 'John Doe')");
await using var resultSet = await client.Sql.ExecuteAsync(
null, "SELECT Name FROM Person");
await foreach (IIgniteTuple row in resultSet)
Console.WriteLine(row[0]);
Mapping SQL Results to User Types
SQL results can be mapped to user types using ExecuteAsync<T>
method. This is cleaner and more efficient than IIgniteTuple
approach above.
await using var resultSet = await client.Sql.ExecuteAsync<Person>(
null, "SELECT Name FROM Person");
await foreach (Person p in resultSet)
Console.WriteLine(p.Name);
public record Person(int Id, string Name);
Column names are matched to record properties by name. To map columns to properties with different names, use ColumnAttribute
.
DbDataReader (ADO.NET API)
Another way to work with query results is System.Data.Common.DbDataReader
, which can be obtained with ExecuteReaderAsync
method.
For example, you can bind query results to a DataGridView
control:
await using var reader = await Client.Sql.ExecuteReaderAsync(
null, "select * from Person");
var dt = new DataTable();
dt.Load(reader);
dataGridView1.DataSource = dt;
NoSQL
NoSQL API is used to store and retrieve data in a key/value fashion. It can be more efficient than SQL in certain scenarios. Existing tables can be accessed, but new tables can only be created with SQL.
First, get a table by name:
ITable? table = await client.Tables.GetTableAsync("Person");
Then, there are two ways to look at the data.
Record View
Record view represents the entire row as a single object. It can be an IIgniteTuple
or a user-defined type.
IRecordView<IIgniteTuple> binaryView = table.RecordBinaryView;
IRecordView<Person> view = table.GetRecordView<Person>();
await view.UpsertAsync(null, new Person(1, "John"));
KeyValue View
Key/Value view splits the row into key and value parts.
IKeyValueView<IIgniteTuple, IIgniteTuple> kvBinaryView = table.KeyValueBinaryView;
IKeyValueView<PersonKey, Person> kvView = table.GetKeyValueView<PersonKey, Person>();
await kvView.PutAsync(null, new PersonKey(1), new Person("John"));
LINQ
Data can be queried and modified with LINQ using AsQueryable
method.
LINQ expressions are translated to SQL queries and executed on the server.
ITable? table = await client.Tables.GetTableAsync("Person");
IRecordView<Person> view = table!.GetRecordView<Person>();
IQueryable<string> query = view.AsQueryable()
.Where(p => p.Id > 100)
.Select(p => p.Name);
List<string> names = await query.ToListAsync();
Generated SQL can be retrieved with ToQueryString
extension method, or by enabling debug logging.
Bulk update and delete with optional conditions are supported via ExecuteUpdateAsync
and ExecuteDeleteAsync
extensions methods on IQueryable<T>
Transactions
All operations on data in Ignite are transactional. If a transaction is not specified, an explicit transaction is started and committed automatically.
To start a transaction, use ITransactions.BeginAsync
method. Then, pass the transaction object to all operations that should be part of the same transaction.
ITransaction tx = await client.Transactions.BeginAsync();
await view.UpsertAsync(tx, new Person(1, "John"));
await client.Sql.ExecuteAsync(
tx, "INSERT INTO Person (Id, Name) VALUES (2, 'Jane')");
await view.AsQueryable(tx)
.Where(p => p.Id > 0)
.ExecuteUpdateAsync(p => new Person(p.Id, p.Name + " Doe"));
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.
IList<IClusterNode> nodes = await client.GetClusterNodesAsync();
string result = await client.Compute.ExecuteAsync<string>(
nodes, "org.acme.tasks.MyTask", "Task argument 1", "Task argument 2");
Failover, Retry, Reconnect, Load Balancing
Ignite client implements a number of features to improve reliability and performance:
- When multiple endpoints are configured, the client will maintain connections to all of them, and load balance requests between them.
- If a connection is lost, the client will try to reconnect, assuming it may be a temporary network issue or a node restart.
- Periodic heartbeat messages are used to detect connection issues early.
- If a user request fails due to a connection issue, the client will retry it automatically according to the configured
IgniteClientConfiguration.RetryPolicy
.
Logging
To enable logging, set IgniteClientConfiguration.LoggerFactory
property. It uses the standard Microsoft.Extensions.Logging API.
For example, to log to console (requires Microsoft.Extensions.Logging.Console
package):
var cfg = new IgniteClientConfiguration
{
LoggerFactory = LoggerFactory.Create(builder => builder.AddConsole().SetMinimumLevel(LogLevel.Debug))
};
Or with Serilog (requires Serilog.Extensions.Logging
and Serilog.Sinks.Console
packages):
var cfg = new IgniteClientConfiguration
{
LoggerFactory = LoggerFactory.Create(builder =>
builder.AddSerilog(new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.Console()
.CreateLogger()))
};
Metrics
Ignite client exposes a number of metrics with Apache.Ignite
meter name through the System.Diagnostics.Metrics API
that can be used to monitor system health and performance.
For example, dotnet-counters tool can be used like this:
dotnet-counters monitor --counters Apache.Ignite,System.Runtime --process-id PID
Documentation
Full documentation is available at https://ignite.apache.org/docs.
Feedback
Use any of the following channels to provide feedback:
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.4)
- NodaTime (>= 3.2.0)
- Remotion.Linq (>= 2.2.0)
NuGet packages (10)
Showing the top 5 NuGet packages that depend on Apache.Ignite:
Package | Downloads |
---|---|
Apache.Ignite.Linq
Apache Ignite LINQ Provider. Query distributed in-memory data in a strongly-typed manner and with IDE support. All Ignite SQL features are supported: distributed joins, groupings, aggregates, field queries, and more. |
|
Apache.Ignite.NLog
Apache Ignite NLog Logger. |
|
Apache.Ignite.Log4Net
Apache Ignite log4net Logger. |
|
Apache.Ignite.EntityFramework
Apache Ignite EntityFramework Second Level Cache: caches EF query results in a distributed in-memory cache. |
|
WorkflowEngine.NET-ProviderForIgnite
Contains dlls of Ignite Persistence Provider: IgniteProvider which implements interfaces: IPersistenceProvider, ISchemePersistenceProvider and IWorkflowGenerator. Steps for workflow runtime configuration with IgniteProvider: http://workflowenginenet.com/Documentation/Detail/howtoconnect in Create WorkflowRuntime section. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.0.0-nightly20241216-g4530... | 80 | 12/16/2024 |
3.0.0-nightly20241213-g7375... | 90 | 12/13/2024 |
3.0.0-nightly20231211-g9e4d... | 618 | 12/11/2023 |
3.0.0-nightly20230332 | 699 | 3/31/2023 |
3.0.0-nightly20230331 | 666 | 3/31/2023 |
3.0.0-nightly20230124 | 723 | 1/24/2023 |
3.0.0-beta1 | 675 | 11/17/2022 |
3.0.0-alpha3 | 914 | 10/17/2021 |
2.16.0 | 36,538 | 12/25/2023 |
2.15.0 | 159,043 | 5/4/2023 |
2.15.0-alpha20221117 | 1,224 | 11/17/2022 |
2.14.0 | 81,902 | 10/7/2022 |
2.13.0.20211025-nightly | 1,244 | 10/25/2021 |
2.13.0 | 65,726 | 4/26/2022 |
2.12.0 | 64,502 | 1/15/2022 |
2.11.1 | 38,762 | 12/21/2021 |
2.11.0 | 10,645 | 9/18/2021 |
2.11.0-alpha20210225 | 7,154 | 2/25/2021 |
2.11.0-alpha20210212 | 1,222 | 2/12/2021 |
2.11.0-alpha20210211 | 1,301 | 2/11/2021 |
2.11.0-alpha20210205 | 1,305 | 2/5/2021 |
2.11.0-alpha20210120 | 1,379 | 1/20/2021 |
2.10.0 | 93,999 | 3/16/2021 |
2.9.1 | 41,195 | 12/28/2020 |
2.9.0 | 44,499 | 10/22/2020 |
2.9.0-alpha20201001 | 1,635 | 10/1/2020 |
2.9.0-alpha20200710 | 1,637 | 7/10/2020 |
2.9.0-alpha20200403 | 2,271 | 4/3/2020 |
2.8.1 | 108,671 | 5/27/2020 |
2.8.0 | 43,307 | 3/4/2020 |
2.8.0-alpha20200122 | 2,238 | 1/22/2020 |
2.8.0-alpha20200109 | 1,942 | 1/9/2020 |
2.8.0-alpha20200108 | 1,936 | 1/8/2020 |
2.8.0-alpha20191218 | 2,125 | 12/18/2019 |
2.8.0-alpha20191203 | 1,569 | 12/3/2019 |
2.8.0-alpha20191118 | 1,671 | 11/17/2019 |
2.7.6 | 24,975 | 9/20/2019 |
2.7.5 | 31,157 | 6/18/2019 |
2.7.0 | 110,160 | 12/8/2018 |
2.6.0 | 162,224 | 7/18/2018 |
2.5.0 | 8,150 | 5/29/2018 |
2.4.0 | 31,760 | 3/12/2018 |
2.3.0 | 5,746 | 10/31/2017 |
2.2.0 | 5,084 | 9/19/2017 |
2.1.0 | 7,774 | 7/28/2017 |
2.0.0 | 3,871 | 5/3/2017 |
1.9.0 | 3,957 | 3/6/2017 |
1.8.0 | 3,899 | 12/8/2016 |
1.7.0 | 7,706 | 8/5/2016 |
1.6.0 | 3,137 | 5/23/2016 |