Apache ignite:A 放置对象数据时出现关键错误
Apache ignite:A key error occurs when putting object data
我正在尝试 Apache ignite,但无法放入对象数据。
服务器是 Java 中的单个节点。客户端是 .NET(C#) 中的瘦客户端。
这个版本是
服务器 OS:Ubuntu 18.04
JAVA:openjdk 版本 11.0.11
点燃:2.10.0
客户OS:Windows10
.NET:.NET Framework 4.6.2
ignite: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);
}
当注册数据为字符串时,注册成功。我无法弄清楚是什么原因造成的。
服务器上的缓存更新失败,因为 Patient
class 不可序列化:
NotSerializableException: ignitetest.Patient
使 ignitetest.Patient
可序列化以解决问题。
查看日志中的内部异常 - 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)
我正在尝试 Apache ignite,但无法放入对象数据。 服务器是 Java 中的单个节点。客户端是 .NET(C#) 中的瘦客户端。
这个版本是
服务器 OS:Ubuntu 18.04
JAVA:openjdk 版本 11.0.11
点燃:2.10.0
客户OS:Windows10
.NET:.NET Framework 4.6.2
ignite: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);
}
当注册数据为字符串时,注册成功。我无法弄清楚是什么原因造成的。
服务器上的缓存更新失败,因为 Patient
class 不可序列化:
NotSerializableException: ignitetest.Patient
使 ignitetest.Patient
可序列化以解决问题。
查看日志中的内部异常 - 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)