ApacheIgnite:放置对象数据时发生关键错误

ApacheIgnite:放置对象数据时发生关键错误,ignite,Ignite,我正在尝试ApacheIgnite,但无法放置对象数据。 服务器是Java中的单个节点。客户端是.NET(C#)中的瘦客户端 这个版本是 服务器操作系统:Ubuntu 18.04 JAVA:openjdk版本11.0.11 点火:2.10.0 客户端操作系统:Windows 10 .NET:.NET Framework 4.6.2 点火:2.10.0(Nuget) 当客户端放置对象时,会引发以下异常 Apache.Ignite.Core.Client.IgniteClientException

我正在尝试ApacheIgnite,但无法放置对象数据。 服务器是Java中的单个节点。客户端是.NET(C#)中的瘦客户端

这个版本是

服务器操作系统:Ubuntu 18.04

JAVA:openjdk版本11.0.11

点火:2.10.0

客户端操作系统:Windows 10

.NET:.NET Framework 4.6.2

点火:2.10.0(Nuget)

当客户端放置对象时,会引发以下异常

Apache.Ignite.Core.Client.IgniteClientException
  HResult=0x80131500
  Message=class org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException: Failed to update keys (retry update if possible).: [100]
  Source=Apache.Ignite.Core
  Stack Trace:
   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.Cache.CacheClient`2.DoOutInOpAffinity[T](ClientOp opId, TK key, TV val, Func`2 readFunc)
   at Apache.Ignite.Core.Impl.Client.Cache.CacheClient`2.Put(TK key, TV val)
   at ignitetest.IgniteClientTest.EntityTest() in D:\SandboxRepos\dbtest\ignitetest\IgniteClientTest.cs:line 58
   at ignitetest.Program.Main(String[] args) in D:\SandboxRepos\dbtest\ignitetest\Program.cs:line 14
服务器上发生了相同的异常

[17:42:15,212][SEVERE][client-connector-#66][ClientListenerNioListener] Failed to process client request [req=o.a.i.i.processors.platform.client.cache.ClientCachePutRequest@54fb9e8b]
javax.cache.integration.CacheWriterException: class org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException: Failed to update keys (retry update if possible).: [100]
...
Caused by: class org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException: Failed to update keys (retry update if possible).: [100]
ignite的配置文件如下所示:

<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 id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="workDirectory" value="/usr/lib/ignite/ignite-data"/>
        <property name="cacheConfiguration">
            <list>
                <bean class="org.apache.ignite.configuration.CacheConfiguration">
                    <constructor-arg name="name" value="PatientCache"></constructor-arg>
                    <property name="cacheStoreFactory">
                        <bean
                            class="org.apache.ignite.cache.store.jdbc.CacheJdbcBlobStoreFactory">
                            <property name="dataSourceBean" value="postgresDataSouorceTestdb" />
                            <property name="createTableQuery" value="create table if not exists ENTRIES (akey bytea primary key, val bytea)" />
                        </bean>
                    </property>
                    <property name="writeThrough" value="true" />
                    <property name="readThrough" value="true" />
                </bean>
            </list>
        </property>
        <property name="binaryConfiguration">
            <bean class="org.apache.ignite.configuration.BinaryConfiguration">
                <property name="compactFooter" value="true"/>
                <property name="classNames">
                        <list>
                            <value>ignitetest.Patient</value>
                        </list>
                </property>
                <property name="nameMapper">
                    <bean class="org.apache.ignite.binary.BinaryBasicNameMapper">
                        <property name="simpleName" value="true"/>
                    </bean>
                </property>
            </bean>
        </property>
    </bean>
    <!-- <bean id="postgresDataSouorceTestdb" class="org.postgresql.ds.PGPoolingDataSource">...</bean> -->
</beans>
var cfg = new IgniteClientConfiguration {
    Endpoints = new[] { "10.1.1.1:10800" },
    BinaryConfiguration=new BinaryConfiguration() {
        CompactFooter=true,
        NameMapper= new BinaryBasicNameMapper { IsSimpleName = true }
    }
};

using (var client = Ignition.StartClient(cfg)) {
    client.GetBinary().GetBinaryType(typeof(Patient));
    var cache = client.GetOrCreateCache<string, Patient>("PatientCache");
    var pat = new Patient() { PatientId = "100", Name = "Test", Birthday = new DateTime(1980,5,1) };
    pat.Birthday = pat.Birthday.ToUniversalTime();
    cache.Put("100", pat);
}

using (var client = Ignition.StartClient(cfg)) {
    var cache = client.GetOrCreateCache<string, Patient>("PatientCache");
    var pat = cache.Get("100");
    System.Diagnostics.Debug.WriteLine("Patient:{0},{1},{2}",pat.PatientId,pat.Name,pat.Birthday);
}

检查,病人
客户机来源如下:

<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 id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="workDirectory" value="/usr/lib/ignite/ignite-data"/>
        <property name="cacheConfiguration">
            <list>
                <bean class="org.apache.ignite.configuration.CacheConfiguration">
                    <constructor-arg name="name" value="PatientCache"></constructor-arg>
                    <property name="cacheStoreFactory">
                        <bean
                            class="org.apache.ignite.cache.store.jdbc.CacheJdbcBlobStoreFactory">
                            <property name="dataSourceBean" value="postgresDataSouorceTestdb" />
                            <property name="createTableQuery" value="create table if not exists ENTRIES (akey bytea primary key, val bytea)" />
                        </bean>
                    </property>
                    <property name="writeThrough" value="true" />
                    <property name="readThrough" value="true" />
                </bean>
            </list>
        </property>
        <property name="binaryConfiguration">
            <bean class="org.apache.ignite.configuration.BinaryConfiguration">
                <property name="compactFooter" value="true"/>
                <property name="classNames">
                        <list>
                            <value>ignitetest.Patient</value>
                        </list>
                </property>
                <property name="nameMapper">
                    <bean class="org.apache.ignite.binary.BinaryBasicNameMapper">
                        <property name="simpleName" value="true"/>
                    </bean>
                </property>
            </bean>
        </property>
    </bean>
    <!-- <bean id="postgresDataSouorceTestdb" class="org.postgresql.ds.PGPoolingDataSource">...</bean> -->
</beans>
var cfg = new IgniteClientConfiguration {
    Endpoints = new[] { "10.1.1.1:10800" },
    BinaryConfiguration=new BinaryConfiguration() {
        CompactFooter=true,
        NameMapper= new BinaryBasicNameMapper { IsSimpleName = true }
    }
};

using (var client = Ignition.StartClient(cfg)) {
    client.GetBinary().GetBinaryType(typeof(Patient));
    var cache = client.GetOrCreateCache<string, Patient>("PatientCache");
    var pat = new Patient() { PatientId = "100", Name = "Test", Birthday = new DateTime(1980,5,1) };
    pat.Birthday = pat.Birthday.ToUniversalTime();
    cache.Put("100", pat);
}

using (var client = Ignition.StartClient(cfg)) {
    var cache = client.GetOrCreateCache<string, Patient>("PatientCache");
    var pat = cache.Get("100");
    System.Diagnostics.Debug.WriteLine("Patient:{0},{1},{2}",pat.PatientId,pat.Name,pat.Birthday);
}
var cfg=新的IgniteClientConfiguration{
端点=新[]{“10.1.1.1:10800”},
BinaryConfiguration=新的BinaryConfiguration(){
CompactFooter=true,
NameMapper=new BinaryBasicNameMapper{IsSimpleName=true}
}
};
使用(var客户端=Ignition.StartClient(cfg)){
GetBinary().GetBinaryType(typeof(Patient));
var cache=client.GetOrCreateCache(“PatientCache”);
var pat=new Patient(){PatientId=“100”,Name=“Test”,生日=new DateTime(1980,5,1)};
pat.birth=pat.birth.ToUniversalTime();
cache.Put(“100”,pat);
}
使用(var客户端=Ignition.StartClient(cfg)){
var cache=client.GetOrCreateCache(“PatientCache”);
var pat=cache.Get(“100”);
System.Diagnostics.Debug.WriteLine(“患者:{0},{1},{2}”,pat.PatientId,pat.Name,pat.birth);
}

当要注册的数据是字符串时,它已成功注册。我很难找出导致此问题的原因。

缓存更新在服务器上失败,因为
Patient
类不可序列化:

NotSerializableException:ignitetest.Patient

使
ignitetest。患者可序列化以解决问题。

请参阅日志中的内部异常-
CacheJdbcBlobStore
无法写入对象:

Caused by: javax.cache.integration.CacheWriterException: Failed to put object [key=100, val=ignitetest.Patient@2556bcf3]
            at org.apache.ignite.cache.store.jdbc.CacheJdbcBlobStore.write(CacheJdbcBlobStore.java:283)
            at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.put(GridCacheStoreManagerAdapter.java:585)
            ... 37 more
        Caused by: class org.apache.ignite.IgniteCheckedException: Failed to serialize object: ignitetest.Patient@2556bcf3
            at org.apache.ignite.marshaller.jdk.JdkMarshaller.marshal0(JdkMarshaller.java:102)
            at org.apache.ignite.marshaller.jdk.JdkMarshaller.marshal0(JdkMarshaller.java:109)
            at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.marshal(AbstractNodeNameAwareMarshaller.java:56)
            at org.apache.ignite.internal.util.IgniteUtils.marshal(IgniteUtils.java:10572)
            at org.apache.ignite.cache.store.jdbc.CacheJdbcBlobStore.toBytes(CacheJdbcBlobStore.java:565)
            at org.apache.ignite.cache.store.jdbc.CacheJdbcBlobStore.write(CacheJdbcBlobStore.java:268)
            ... 38 more
        Caused by: java.io.NotSerializableException: ignitetest.Patient
            at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1185)
            at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:349)
            at org.apache.ignite.marshaller.jdk.JdkMarshaller.marshal0(JdkMarshaller.java:97)

1.能否将整个服务器节点日志放在某个位置?2.你能提供一个我可以运行的复制器吗?看起来你的集群在缓存放置过程中消失了。@PavelTupitsyn谢谢,日志上传到。我将尝试准备一个可复制的环境,但这需要一些时间。谢谢!!JAVA中的Patient类中缺少可序列化接口。我更改并运行了它,它已成功保存。对不起,我犯了一个基本的错误。。。