Apache Ignite C#/.NET:计算作业失败,无法反序列化作业

Apache Ignite C#/.NET: Compute job failing, failed to deserialize job

我是 Apache Ignite 的新手,我试图遵循 Remote Assembly Loading example,但我 运行 遇到了一些错误。

首先,我在 Windows 控制台中 运行 Apache.Ignite.exe -ConfigFileName=[file path to Apache.Ignite.exe.config] 几次以启动集群,其中我的 Apache.Ignite.exe.config 文件看起来像:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <section name="igniteConfiguration" type="Apache.Ignite.Core.IgniteConfigurationSection, Apache.Ignite.Core" />
    </configSections>
    
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    </startup>

    <runtime>
        <gcServer enabled="true" />
    </runtime>

    <igniteConfiguration peerAssemblyLoadingMode='CurrentAppDomain' />

    <appSettings>
        <!-- Use Ignite configuration section defined above. -->
        <add key="Ignite.ConfigSectionName" value="igniteConfiguration" />
    </appSettings>

</configuration>

然后我有一个 .NET 控制台应用程序,其中我的 Program.cs 看起来像:

    class HelloAction : IComputeAction
    {
        public void Invoke()
        {
            Console.WriteLine("Hello, World!");
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var cfg = new IgniteConfiguration
            {
                PeerAssemblyLoadingMode = PeerAssemblyLoadingMode.CurrentAppDomain
            };

            using (var ignite = Ignition.Start(cfg))
            {
                ignite.GetCompute().Broadcast(new HelloAction());
            }
        }
    }

在我 运行 我的项目之后,我 运行 进入以下 错误 :

[SEVERE][sys-#61][] Failure in Java callback
class org.apache.ignite.IgniteException: Platform error:Apache.Ignite.Core.Common.IgniteException: Compute job has failed on remote node, examine InnerException for details.
 ---> Apache.Ignite.Core.Common.IgniteException: Failed to deserialize the job [errType=BadImageFormatException, errMsg=Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
 ---> Apache.Ignite.Core.Common.JavaException: class org.apache.ignite.IgniteException: Failed to deserialize the job [errType=BadImageFormatException, errMsg=Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
        at org.apache.ignite.internal.processors.platform.callback.PlatformCallbackUtils.inLongOutLong(Native Method)
        at org.apache.ignite.internal.processors.platform.callback.PlatformCallbackGateway.computeJobCreate(PlatformCallbackGateway.java:295)
        at org.apache.ignite.internal.processors.platform.compute.PlatformAbstractJob.createJob(PlatformAbstractJob.java:114)
        at org.apache.ignite.internal.processors.platform.compute.PlatformClosureJob.execute0(PlatformClosureJob.java:66)
        at org.apache.ignite.internal.processors.platform.compute.PlatformAbstractJob.execute(PlatformAbstractJob.java:80)
        at org.apache.ignite.internal.processors.job.GridJobWorker.call(GridJobWorker.java:598)
        at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:7077)
        at org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:592)
        at org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:521)
        at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:120)
        at org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1368)
        at org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:2122)
        at org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GrSystem.AggregateException: One or more errors occurred. (Compute job has failed on remote node, examine InnerException for details.)
 ---> Apache.Ignite.Core.Common.IgniteException: Compute job has failed on remote node, examine InnerException for details.
 ---> Apache.Ignite.Core.Common.IgniteException: Failed to deserialize the job [errType=BadImageFormatException, errMsg=Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
 ---> Apache.Ignite.Core.Common.JavaException: class org.apache.ignite.IgniteException: Failed to deserialize the job [errType=BadImageFormatException, errMsg=Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
        at org.apache.ignite.internal.processors.platform.callback.PlatformCallbackUtils.inLongOutLong(Native Method)
        at org.apache.ignite.internal.processors.platform.callback.PlatformCallbackGateway.computeJobCreate(PlatformCallbackGateway.java:295)
        at org.apache.ignite.internal.processors.platform.compute.PlatformAbstractJob.createJob(PlatformAbstractJob.java:114)
        at org.apache.ignite.internal.processors.platform.compute.PlatformClosureJob.execute0(PlatformClosureJob.java:66)
        at org.apache.ignite.internal.processors.platform.compute.PlatformAbstractJob.execute(PlatformAbstractJob.java:80)
        at org.apache.ignite.internal.processors.job.GridJobWorker.call(GridJobWorker.java:598)
        at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:7077)
        at org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:592)
        at org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:521)
        at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:120)
        at org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1368)
        at org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:2122)
        at org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1907)
        at org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:1528)
        at org.apache.ignite.internal.managers.communication.GridIoManager.access00(GridIoManager.java:241)
        at org.apache.ignite.internal.managers.communication.GridIoManager.execute(GridIoManager.java:1421)
        at org.apache.ignite.internal.managers.communication.TraceRunnable.run(TraceRunnable.java:55)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:830)

我想知道是什么导致了这个错误以及如何解决这个问题,谢谢!

看起来您正在使用 .NET Core 3.x,而 Apache.Ignite.exe 是使用经典 .NET Framework 构建的,因此存在兼容性问题。

Apache Ignite 也包含一个 .NET Core 二进制文件 - platforms/dotnet/bin/netcoreapp2.0/Apache.Ignite.dll,您可以试试。

但是,当使用对等程序集加载时,我建议 运行 在所有节点上使用完全相同的框架版本。为此,请避免使用预构建的二进制文件(Apache.Ignite.exeApache.Ignite.dll),并创建一个单独的程序来启动服务器节点:

class Program
{
    static void Main(string[] args)
    {
        var cfg = new IgniteConfiguration
        {
            PeerAssemblyLoadingMode = PeerAssemblyLoadingMode.CurrentAppDomain
        };

        using (var ignite = Ignition.Start(cfg))
        {
            Thread.Sleep(-1); // Wait forever
        }
    }
}