我正在尝试在我的Ignite键和值对象中使用java.util.Date
类型字段。但是,当我开始使用Java代码在同一Ignite缓存中缓存数据时,出现以下错误。
[12:43:01,485][SEVERE][pool-8-thread-1][] Message is ignored due to an error [msg=MessageAndMetadata(test1,2,Message(magic = 1, attributes = 0, CreateTime = -1, crc = 3705259101, key = java.nio.HeapByteBuffer[pos=0 lim=4 cap=3288], payload = java.nio.HeapByteBuffer[pos=0 lim=3280 cap=3280]),302,kafka.serializer.DefaultDecoder@2d50c6a2,kafka.serializer.DefaultDecoder@1ff7596c,-1,CreateTime)]
class org.apache.ignite.binary.BinaryObjectException: Binary type has different field types [typeName=test.demo.DataKey, fieldName=tstamp, fieldTypeName1=String, fieldTypeName2=Date]
at org.apache.ignite.internal.binary.BinaryUtils.mergeMetadata(BinaryUtils.java:1027)
at org.apache.ignite.internal.processors.cache.binary.BinaryMetadataTransport$MetadataUpdateProposedListener.onCustomEvent(BinaryMetadataTransport.java:293)
at org.apache.ignite.internal.processors.cache.binary.BinaryMetadataTransport$MetadataUpdateProposedListener.onCustomEvent(BinaryMetadataTransport.java:258)
at org.apache.ignite.internal.managers.discovery.GridDiscoveryManager$4.onDiscovery0(GridDiscoveryManager.java:707)
at org.apache.ignite.internal.managers.discovery.GridDiscoveryManager$4.onDiscovery(GridDiscoveryManager.java:589)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.notifyDiscoveryListener(ServerImpl.java:5479)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processCustomMessage(ServerImpl.java:5305)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processMessage(ServerImpl.java:2765)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processMessage(ServerImpl.java:2536)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$MessageWorkerAdapter.body(ServerImpl.java:6775)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.body(ServerImpl.java:2621)
at org.apache.ignite.spi.IgniteSpiThread.run(IgniteSpiThread.java:62)
DataKey
是Ignite缓存键,其定义如下,
package test.demo;
import java.util.Date;
public class DataKey{
private Long sess_id ;
private Long s_id;
private Long version;
private Date tstamp;
public DataKey(Long sess_id, Long s_id, Long version,
Date tstamp) {
super();
this.sess_id = sess_id;
this.s_id = s_id;
this.version = version;
this.tstamp = tstamp;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((s_id == null) ? 0 : s_id.hashCode());
result = prime * result
+ ((sess_id == null) ? 0 : sess_id.hashCode());
result = prime * result
+ ((tstamp == null) ? 0 : tstamp.hashCode());
result = prime * result + ((version == null) ? 0 : version.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
DataKey other = (DataKey) obj;
if (s_id == null) {
if (other.s_id != null)
return false;
} else if (!s_id.equals(other.s_id))
return false;
if (sess_id == null) {
if (other.sess_id != null)
return false;
} else if (!sess_id.equals(other.sess_id))
return false;
if (tstamp == null) {
if (other.tstamp != null)
return false;
} else if (!tstamp.equals(other.tstamp))
return false;
if (version == null) {
if (other.version != null)
return false;
} else if (!version.equals(other.version))
return false;
return true;
}
}
如链接http://apache-ignite-users.70518.x6.nabble.com/Binary-type-has-different-fields-error-td21540.html中所述,我什至从$IGNITE_HOME/work/
目录中删除了内容,然后重新启动了该节点。但是仍然存在错误。
是什么导致此错误?如果java.util.Date
类型字段仅用于缓存值(而不用于键),也会发生相同的错误。
答案 0 :(得分:1)
是否有可能正在运行其他节点,这些节点部署了旧版本的代码,其中timestamp
是String
?
请注意,在您的代码段中为tstamp
,但在错误消息中为timestamp
。有机会有些混乱吗?清除它,删除所有节点上的work/
,然后重试。
答案 1 :(得分:0)
问题出在ignitevisor
中。我使用了Node Singleton
的Ignite服务部署模式,其中在群集中的每个Ignite实例上部署了应用程序。同时,配置也已应用于ignitevisor
。现在,在下一次运行期间,ignitevisor
是ON
的旧配置。因此,当我使用Node Singleton
服务部署模式在群集上部署新应用程序时,新旧<key, value>
对象类型之间会发生冲突,因为ignitevisor
保留了旧配置。