Skip to content

Instantly share code, notes, and snippets.

@ptupitsyn
Last active May 3, 2023 05:32
Show Gist options
  • Save ptupitsyn/633bf86dd4beaf48d604fab97abb2dd1 to your computer and use it in GitHub Desktop.
Save ptupitsyn/633bf86dd4beaf48d604fab97abb2dd1 to your computer and use it in GitHub Desktop.
Ignite.NET REST API module usage
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Apache.Ignite" Version="2.14.0" />
</ItemGroup>
</Project>
using System.Runtime.InteropServices;
using Apache.Ignite.Core;
// 1. Install Ignite.NET from NuGet
// 2. Download zip distro to get the rest module jar: https://dlcdn.apache.org/ignite/2.14.0/apache-ignite-slim-2.14.0-bin.zip
// 3. Unpack the zip and note the path to the ignite-rest-http folder
// 4. Put your path below
var jarsDir = "/home/pavel/Downloads/apache-ignite-slim-2.14.0-bin/libs/optional/ignite-rest-http";
var classpathSeparator = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ";" : ":";
var classpath = string.Join(classpathSeparator, Directory.GetFiles(jarsDir, "*.jar"));
var cfg = new IgniteConfiguration
{
JvmClasspath = classpath
};
Ignition.Start(cfg);
// Test the REST API (https://ignite.apache.org/docs/latest/restapi):
var client = new HttpClient
{
BaseAddress = new Uri("http://localhost:8080/ignite")
};
var response = await client.GetStringAsync("?cmd=version");
Console.WriteLine("\n>>> API Response: " + response);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment