使用Cluser Singleton服务的Multile Ignite客户端连接到远程Ignite服务器无法封送发现数据

时间:2018-04-16 18:19:11

标签: ignite

我有2台Ignite服务器,当我创建一个点火客户端时, 它将连接到两个服务器,它可以正常工作,没有错误。

在ignite客户端java代码中,它创建了一个集群单例服务

但是如果我使用相同的代码创建第二个点燃客户端,那么 客户端也将调用该函数来创建集群单例服务(我认为点燃可能知道这个服务已经有了,并且不会再次创建,如果我错了就纠正我),并且在服务器之一,它会转储以下内容错误(另一个很好):



[02:05:30,912][SEVERE][tcp-disco-msg-worker-#2][TcpDiscoverySpi] Failed to marshal discovery data 
[comp=0, data=DiscoveryData [nodeId=bb2beed3-38e9-4134-a898-b4aab8705c8c, items=[DiscoveryDataItem 
[routineId=6be10471-bdfb-47e0-881a-aa9cf285cead, prjPred=IgniteAllNodesPredicate [], 
hnd=CacheContinuousQueryHandlerV2 [rmtFilterFactory=com.test.simple.IgniteMatchClusterSingletonService$3@39812ce8, 
rmtFilterFactoryDep=null, types=0], bufSize=1, interval=0, autoUnsubscribe=true], DiscoveryDataItem
 [routineId=c0582fdc-0539-4c41-8238-f15d426af475, prjPred=IgniteAllNodesPredicate [], 
hnd=CacheContinuousQueryHandler [cacheName=datastructures_ATOMIC_PARTITIONED_0@default-ds-group, 
rmtFilter=o.a.i.i.processors.cache.datastructures.CacheDataStructuresManager$QueueHeaderPredicate@4e5687a1, 
rmtFilterDep=null, internal=true, notifyExisting=true, oldValRequired=true, sync=false, ignoreExpired=true,
 taskHash=0, skipPrimaryCheck=false, locCache=false, keepBinary=false, ackBuf=CacheContinuousQueryAcknowledgeBuffer
 [size=0, updateCntrs={}, topVers=[]], cacheId=474336146, initTopVer=AffinityTopologyVersion [topVer=5, minorTopVer=10], 
nodeLeft=false, ignoreClsNotFound=false, asyncCb=false, nodeId=bb2beed3-38e9-4134-a898-b4aab8705c8c, 
routineId=c0582fdc-0539-4c41-8238-f15d426af475], bufSize=1, interval=0, autoUnsubscribe=true], DiscoveryDataItem 
[routineId=a2ad72c7-cd07-4fd5-bb51-adf33d344238, prjPred=EqualsClusterNodeIdPredicate 
[nodeId=bb2beed3-38e9-4134-a898-b4aab8705c8c], hnd=CacheContinuousQueryHandler [cacheName=ignite-sys-cache, 
rmtFilter=null, rmtFilterDep=null, internal=true, notifyExisting=true, oldValRequired=true, sync=false, 
ignoreExpired=true, taskHash=0, skipPrimaryCheck=true, locCache=false, keepBinary=false, 
ackBuf=CacheContinuousQueryAcknowledgeBuffer [size=0, updateCntrs={}, topVers=[]], cacheId=-2100569601, 
initTopVer=null, nodeLeft=false, ignoreClsNotFound=false, asyncCb=false, nodeId=bb2beed3-38e9-4134-a898-b4aab8705c8c,
 routineId=a2ad72c7-cd07-4fd5-bb51-adf33d344238], bufSize=1, interval=0, autoUnsubscribe=true]]]]
class org.apache.ignite.IgniteCheckedException: Failed to serialize object: DiscoveryData [nodeId=bb2beed3-38e9-4134-a898-b4aab8705c8c,
 items=[DiscoveryDataItem [routineId=6be10471-bdfb-47e0-881a-aa9cf285cead, prjPred=IgniteAllNodesPredicate [],
 hnd=CacheContinuousQueryHandlerV2 [rmtFilterFactory=com.test.simple.IgniteMatchClusterSingletonService$3@39812ce8, 
rmtFilterFactoryDep=null, types=0], bufSize=1, interval=0, autoUnsubscribe=true], DiscoveryDataItem 
[routineId=c0582fdc-0539-4c41-8238-f15d426af475, prjPred=IgniteAllNodesPredicate [], hnd=CacheContinuousQueryHandler 
[cacheName=datastructures_ATOMIC_PARTITIONED_0@default-ds-group, 
rmtFilter=org.apache.ignite.internal.processors.cache.datastructures.CacheDataStructuresManager$QueueHeaderPredicate@4e5687a1, 
rmtFilterDep=null, internal=true, notifyExisting=true, oldValRequired=true, sync=false, ignoreExpired=true, 
taskHash=0, skipPrimaryCheck=false, locCache=false, keepBinary=false, ackBuf=CacheContinuousQueryAcknowledgeBuffer 
[size=0, updateCntrs={}, topVers=[]], cacheId=474336146, initTopVer=AffinityTopologyVersion [topVer=5, minorTopVer=10], 
nodeLeft=false, ignoreClsNotFound=false, asyncCb=false, nodeId=bb2beed3-38e9-4134-a898-b4aab8705c8c, 
routineId=c0582fdc-0539-4c41-8238-f15d426af475], bufSize=1, interval=0, autoUnsubscribe=true], DiscoveryDataItem 
[routineId=a2ad72c7-cd07-4fd5-bb51-adf33d344238, prjPred=EqualsClusterNodeIdPredicate [nodeId=bb2beed3-38e9-4134-a898-b4aab8705c8c], 
hnd=CacheContinuousQueryHandler [cacheName=ignite-sys-cache, rmtFilter=null, rmtFilterDep=null, internal=true, notifyExisting=true, 
oldValRequired=true, sync=false, ignoreExpired=true, taskHash=0, skipPrimaryCheck=true, locCache=false, keepBinary=false, 
ackBuf=CacheContinuousQueryAcknowledgeBuffer [size=0, updateCntrs={}, topVers=[]], cacheId=-2100569601, initTopVer=null, 
nodeLeft=false, ignoreClsNotFound=false, asyncCb=false, nodeId=bb2beed3-38e9-4134-a898-b4aab8705c8c, 
routineId=a2ad72c7-cd07-4fd5-bb51-adf33d344238], bufSize=1, interval=0, autoUnsubscribe=true]]]
	at org.apache.ignite.marshaller.jdk.JdkMarshaller.marshal0(JdkMarshaller.java:103)
	at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.marshal(AbstractNodeNameAwareMarshaller.java:70)
	at org.apache.ignite.marshaller.jdk.JdkMarshaller.marshal0(JdkMarshaller.java:117)
	at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.marshal(AbstractNodeNameAwareMarshaller.java:58)
	at org.apache.ignite.spi.discovery.tcp.internal.DiscoveryDataPacket.marshalData(DiscoveryDataPacket.java:311)
	at org.apache.ignite.spi.discovery.tcp.internal.DiscoveryDataPacket.marshalGridNodeData(DiscoveryDataPacket.java:87)
	at org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.collectExchangeData(TcpDiscoverySpi.java:1897)
	at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processNodeAddedMessage(ServerImpl.java:4173)
	at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processMessage(ServerImpl.java:2706)
	at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processMessage(ServerImpl.java:2519)
	at org.apache.ignite.spi.discovery.tcp.ServerImpl$MessageWorkerAdapter.body(ServerImpl.java:6707)
	at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.body(ServerImpl.java:2602)
	at org.apache.ignite.spi.IgniteSpiThread.run(IgniteSpiThread.java:62)
Caused by: java.io.NotSerializableException: com.test.simple.IgniteMatchClusterSingletonService$2
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
	at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
	at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
	at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
	at org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandlerV2.writeExternal(CacheContinuousQueryHandlerV2.java:157)
	at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1459)
	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1430)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
	at org.apache.ignite.internal.processors.continuous.GridContinuousProcessor$DiscoveryDataItem.writeExternal(GridContinuousProcessor.java:1853)
	at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1459)
	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1430)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
	at org.apache.ignite.internal.util.IgniteUtils.writeCollection(IgniteUtils.java:1754)
	at org.apache.ignite.internal.processors.continuous.GridContinuousProcessor$DiscoveryData.writeExternal(GridContinuousProcessor.java:1772)
	at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1459)
	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1430)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
	at org.apache.ignite.marshaller.jdk.JdkMarshaller.marshal0(JdkMarshaller.java:98)
	... 12 more




1 个答案:

答案 0 :(得分:4)

根本原因清楚地显示在堆栈跟踪中:

Caused by: java.io.NotSerializableException: com.test.simple.IgniteMatchClusterSingletonService$2

有一个匿名类(com.test.simple.IgniteMatchClusterSingletonService$2)不是Serializable,而是与服务实例一起序列化。

如果这是预期的,那么您需要确保此类确实实现了Serializable。否则,请更改代码,以便不通过网络发送此类的实例。

一般情况下,我建议避免对可以序列化的任何内容使用匿名类或lambda。它们通常包含一个封闭类的链接,这使得更难理解序列化的内容和不序列化的内容。切换到内部静态类以避免这种情况。