0
votes

I have 2 Ignite server, and when I create a ignite client, it will connect to the two server and it works fine with no error.

In the ignite client java code, it create a cluster singleton service

But if i create a second ignite client with the same code, the client will also call the function to create the cluster singleton service(i think ignite may know this service has one already, and will not create again, correct me if i am wrong), and in the one of the server, it dumps the following errors(another is fine):

[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

1 Answers

4
votes

The root cause is clearly shown in the stack trace:

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

There is an anonymous class (com.test.simple.IgniteMatchClusterSingletonService$2) that is not Serializable, but gets serialized along with the service instance.

If this is expected, then you need to make sure this class does implement Serializable. Otherwise, change the code so that instance of this class is not sent across network.

In general, I would recommend to avoid using anonymous classes or lambdas for anything that can be serialized. They typically contain a link to enclosing class which makes it more difficult to understand what is serialized and what is not. Switch to inner static classes to avoid that.