Search code examples
c#ignite

Apache Ignite - NPE when dotnet client tries to create cache on server


I'm trying to get setup using Apache Ignite. I have a dotnet core client application that is attempting to either get a cache (ignite.GetCache<int, CacheThing>("test-cache") or create a cache (ignite.CreateCache<int, CacheThing>).

In both cases the result is the same error (see below).

Apache Ignite Server

I am using a docker container from https://hub.docker.com/r/apacheignite/ignite/, and am using the apache/ignite:2.6.0 tag.

Client code (dotnetcore)

The client is attempting to create a cache using a custom dotnet core assembly for the schema definition.

class Program
    {
        public static bool ClientDisconnected = false;

        static void Main(string[] args)
        {
            Console.WriteLine("Starting client");
            string x = typeof(CacheStoreFactory).FullName;
            Console.WriteLine("Cache factory: " + x);
            var cfg = new IgniteConfiguration
            {
                SpringConfigUrl = "ignite.config",
                JvmOptions = new[]
                {
                    "-Xdebug","-DIGNITE_QUIET=false"
                },
            };

            /*
            var cfg = new IgniteConfiguration()
            {
                ClientMode = true,
                JvmOptions = new[]
                {
                    "-Xdebug","-DIGNITE_QUIET=false"
                },
                BinaryConfiguration = new BinaryConfiguration
                {
                    Types = new List<string>
                    {
                        typeof(CacheStoreFactory).FullName,
                    }
                },
            };
             */


            Console.WriteLine("Ignite -> Start");
            using (IIgnite ignite = Ignition.Start(cfg))
            {
                Console.WriteLine("Destroy test-cache");


                //ignite.DestroyCache("test-cache");
                //ICache<int, CacheThing> cache = ignite.GetCache<int, CacheThing>("test-cache");


                ICache<int, CacheThing> cache = ignite.CreateCache<int, CacheThing>(new CacheConfiguration
                {
                    Name = "test-cache",
                    ReadThrough = true,
                    WriteThrough = true,
                    KeepBinaryInStore = true,
                    CacheStoreFactory = new CacheStoreFactory()
                });





                ignite.ClientDisconnected += (sender, eventArgs) =>
                {
                    ClientDisconnected = true;

                    Console.WriteLine("Client disconnected.");
                };

                ignite.ClientReconnected += (sender, eventArgs) =>
                {
                    ClientDisconnected = false;

                    Console.WriteLine("Client reconnected.");
                };

                Object retrieved = cache.Get(1);

                Console.WriteLine(retrieved);

                Console.WriteLine("Press enter to quit client");
                Console.ReadLine();
            }
        }
    }

Client error

    at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.load(GridCacheStoreManagerAdapter.java:293)
    at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadAllFromStore(GridCacheStoreManagerAdapter.java:434)
    at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadAll(GridCacheStoreManagerAdapter.java:400)
    at org.apache.ignite.internal.processors.cache.GridCacheAdapter$18.call(GridCacheAdapter.java:2046)
    at org.apache.ignite.internal.processors.cache.GridCacheAdapter$18.call(GridCacheAdapter.java:2044)
    at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6695)
    at org.apache.ignite.internal.processors.closure.GridClosureProcessor$2.body(GridClosureProcessor.java:967)
    at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
    at org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetCacheStore.doInvoke(PlatformDotNetCacheStore.java:469)
    at org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetCacheStore.load(PlatformDotNetCacheStore.java:176)
    at org.apache.ignite.internal.processors.cache.CacheStoreBalancingWrapper.load(CacheStoreBalancingWrapper.java:98)
    at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadFromStore(GridCacheStoreManagerAdapter.java:327)
    ... 11 more
   --- End of inner exception stack trace ---
   at Apache.Ignite.Core.Impl.PlatformJniTarget.InStreamOutLong[TR](Int32 type, Action`1 outAction, Func`3 inAction, Func`2 readErrorAction)
   at SpikeCD750.Program.Main(String[] args) in /home/anton/git/ignite-readthrough/SpikeCD750/Program.cs:line 85

Server Error

server_1  | [03:07:20,337][SEVERE][sys-#81][GridDhtAtomicCache] <test-cache> Failed processing get request: GridNearSingleGetRequest [futId=1535944038969, key=KeyCacheObjectImpl [part=1, val=1, hasValBytes=true], flags=1, topVer=AffinityTopologyVersion [topVer=6, minorTopVer=0], subjId=f91be4be-6ca6-4b70-8264-6dc5fee43357, taskNameHash=0, createTtl=-1, accessTtl=-1]
server_1  | class org.apache.ignite.IgniteCheckedException: java.lang.NullPointerException
server_1  |     at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadFromStore(GridCacheStoreManagerAdapter.java:338)
server_1  |     at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.load(GridCacheStoreManagerAdapter.java:293)
server_1  |     at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadAllFromStore(GridCacheStoreManagerAdapter.java:434)
server_1  |     at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadAll(GridCacheStoreManagerAdapter.java:400)
server_1  |     at org.apache.ignite.internal.processors.cache.GridCacheAdapter$18.call(GridCacheAdapter.java:2046)
server_1  |     at org.apache.ignite.internal.processors.cache.GridCacheAdapter$18.call(GridCacheAdapter.java:2044)
server_1  |     at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6695)
server_1  |     at org.apache.ignite.internal.processors.closure.GridClosureProcessor$2.body(GridClosureProcessor.java:967)
server_1  |     at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
server_1  |     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
server_1  |     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
server_1  |     at java.lang.Thread.run(Thread.java:748)
server_1  | Caused by: javax.cache.integration.CacheLoaderException: java.lang.NullPointerException
server_1  |     ... 12 more
server_1  | Caused by: java.lang.NullPointerException
server_1  |     at org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetCacheStore.doInvoke(PlatformDotNetCacheStore.java:469)
server_1  |     at org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetCacheStore.load(PlatformDotNetCacheStore.java:176)
server_1  |     at org.apache.ignite.internal.processors.cache.CacheStoreBalancingWrapper.load(CacheStoreBalancingWrapper.java:98)
server_1  |     at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadFromStore(GridCacheStoreManagerAdapter.java:327)
server_1  |     ... 11 more

Is it even possible for a dotnet client to create a cache in the Apache Ignite java server?


Solution

  • .NET Cache Store can not be deployed on Java-only node.

    Docker container contains Java-only Ignite, and you create a custom Cache Store in your C# code.

    So unless Ignite team releases a Docker image running Ignite.NET, you have to create a custom docker image, or start Ignite.NET server nodes in some other way.