Anyone Here Used Apache Ignite to Setup Caching

koeks525

Executive Member
Joined
Jul 14, 2012
Messages
6,011
Reaction score
1,196
Location
Canada
Hi Peeps,

Has anyone here used Apache Ignite as their caching solution for their apps before? I am new to Apache Ignite, and thought it would be fun to give it a try... don't go too hard on me :). For the past day and a half, I have been trying to make sense of the error I get when I try to add items to the cache:

To give a bit of context, the set up I have is a Linux Ubuntu VPS. I have installed Apache Ignite on it and set the config file. I have also enabled the apache-ignite service such that it uses the configuration file I provide to it (more on that in this thread). What I wanted to do is to call my Apache Ignite cluster remotely when I need to add/remove items from the cache (from my .NET app on my Mac, without having to install Apache Ignite on my Mac).

Code:
Apache.Ignite.Core.Client.IgniteClientException: Platforms are not available [nodeId=ed26d3dd-9b6e-4adb-9885-448b265121f7] (Use Apache.Ignite.Core.Ignition.Start() or Apache.Ignite.exe to start Ignite.NET nodes; ignite::Ignition::Start() or ignite.exe to start Ignite C++ nodes).
   at Apache.Ignite.Core.Impl.Client.Cache.CacheClient`2.HandleError[T](ClientStatusCode status, String msg)
   at Apache.Ignite.Core.Impl.Client.ClientSocket.DecodeResponse[T](BinaryHeapStream stream, Func`2 readFunc, Func`3 errorFunc)
   at Apache.Ignite.Core.Impl.Client.ClientSocket.DoOutInOp[T](ClientOp opId, Action`1 writeAction, Func`2 readFunc, Func`3 errorFunc)
   at Apache.Ignite.Core.Impl.Client.ClientFailoverSocket.DoOutInOp[T](ClientOp opId, Action`1 writeAction, Func`2 readFunc, Func`3 errorFunc)
   at Apache.Ignite.Core.Impl.Client.Cache.CacheClient`2.DoOutInOp[T](ClientOp opId, Action`1 writeAction, Func`2 readFunc)
   at Apache.Ignite.Core.Impl.Client.Cache.CacheClient`2.Query(ScanQuery`2 scanQuery)

The code that causes this failure is my .NET Web App (Backend For Frontend):

C#:
public async Task<AuthClient> FetchById(string id)
    {
        Ignition.ClientMode = true;
        using var igniteClient = IgniteClientCreator.Create(_igniteClientSetting);
        var cache = igniteClient.GetOrCreateCache<string, AuthClient>(CacheNames.AuthorizationClientNames);

        var cacheCursor =
            cache.Query(new ScanQuery<string, AuthClient>(new FetchAuthClientByIdQueryFilter(id)));

        if (cacheCursor.GetAll().Any()) return cacheCursor.GetAll().First().Value;
        var client = await _openIddictManager.FindByClientIdAsync(id).ConfigureAwait(false);

        switch (client)
        {

            case null:

                throw new Exception($"Could not find client with id: {id}.");

            case OpenIddictApplicationDescriptor applicationDescriptor:

                await cache.PutAsync(id, new AuthClient

                {

                    ClientId = applicationDescriptor.ClientId!,

                    ClientSecret = applicationDescriptor.ClientSecret!,

                    ClientName = applicationDescriptor.DisplayName!,

                    IsDevelopmentClient = applicationDescriptor.DisplayName!.Contains("dev", StringComparison.InvariantCultureIgnoreCase)

                }).ConfigureAwait(false);

                break;
        }
        throw new Exception("The type of client could not be determined.");
    }

I have a static helper class that I created which sets up the IIgniteClient instance. I provide it the username, password, host (IP address of the Linux VPS), and the port (10800) where Apache Ignite is on.

C#:
public static class IgniteClientCreator
{
    public static IIgniteClient Create(IgniteClientSetting configuration)
    {
        var hostAddress = configuration.Host;
        var port = configuration.Port;

        var clientConfiguration = new IgniteClientConfiguration
        {
            UserName = configuration.Username,
            Password = configuration.Password,
            EnableClusterDiscovery = true,
            EnablePartitionAwareness = true,
            Endpoints = new List<string> { $"{hostAddress}:{port}" },
        };

        return Ignition.StartClient(clientConfiguration);
    }
}

The config file I have setup for apache ignite looks like this:

XML:
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="workDirectory" value="/var/apache-ignite/work"/>
        <property name="authenticationEnabled" value="true"/>

        <property name="clientConnectorConfiguration">
            <bean class="org.apache.ignite.configuration.ClientConnectorConfiguration">
                <property name="port" value="10800"/>
                <property name="thinClientEnabled" value="true"/>
            </bean>
        </property>
      
        <property name="dataStorageConfiguration">
            <bean class="org.apache.ignite.configuration.DataStorageConfiguration">
                <property name="defaultDataRegionConfiguration">
                    <bean class="org.apache.ignite.configuration.DataRegionConfiguration">
                        <property name="persistenceEnabled" value="true"/>
                    </bean>
                </property>
            </bean>
        </property>
    </bean>
</beans>

I have thought of a number of things about what is happening here:

1. Could it be that the error I am getting is due to the fact I have not created a separate Ignite.NET node and added that to my Apache Ignite cluster? If this is the case, then I suppose I would need to create another console app of some sort which starts the .NET node. Is there a way I could create this standalone .NET Ignite node and have it start as a service on Linux Ubuntu? The documentation talks about doing something like that: Ignite.NET Configuration Options | Ignite Documentation (apache.org). EDIT: I am thinking this is probably the cause of my problems; I have not actually created .NET server node. It seems like I have a cluster setup on Ubuntu VPS, but it has no server nodes on it.

2. I could load the config file in my existing app and start an ignite .net node from it. What does that mean if you have a remote node that you want to access?

3. I could just forget about Apache Ignite and switch to something simpler :whistling:

Has anyone else worked with Apache Ignite?
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X