Open iswarezwp opened 2 months ago
My guess is that DeviceStreamReceiver
is deployed, but Ignite has no way of knowing that it depends on MyDouble
(because of generic type erasure).
And peer class loading does not work for cache objects.
Try adding the following method to the receiver to retrieve the value from the entry and see if it helps:
private static MyDouble getValue(Map.Entry entry) {
return (MyDouble)entry.getValue();
}
@ptupitsyn Thank you very much, I modified the DeviceStreamReceiver
:
public static class DeviceStreamReceiver implements StreamReceiver<String, MyDouble> {
private IgniteCache<String, Instrument> instCache;
public DeviceStreamReceiver(IgniteCache<String, Instrument> cache) {
instCache = cache;
}
@Override
public void receive(IgniteCache<String, MyDouble> cache, Collection<Map.Entry<String, MyDouble>> entries) {
//CommunicationTrackKafkaProducer producer = CommunicationTrackKafkaProducer.getInstance();
for (Map.Entry<String, MyDouble> entry : entries) {
String symbol = entry.getKey();
MyDouble tick = getValue(entry);
Instrument inst = instCache.get(symbol);
if (inst == null)
inst = new Instrument(symbol);
// Don't populate market cache, as we don't use it for querying.
// Update cached instrument based on the latest market tick.
inst.update(tick.getValue());
instCache.put(symbol, inst);
}
}
private static MyDouble getValue(Map.Entry<String, MyDouble> entry) {
return (MyDouble)entry.getValue();
}
}
and, still got the same error:
Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException: com.nimblex.StreamVisitorExample$MyDouble
at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:741)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize0(BinaryReaderExImpl.java:1772)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1731)
at org.apache.ignite.internal.binary.BinaryObjectImpl.deserializeValue(BinaryObjectImpl.java:866)
at org.apache.ignite.internal.binary.BinaryObjectImpl.value(BinaryObjectImpl.java:198)
at org.apache.ignite.internal.processors.cache.CacheObjectUtils.unwrapBinary(CacheObjectUtils.java:199)
at org.apache.ignite.internal.processors.cache.CacheObjectUtils.unwrapBinaryIfNeeded(CacheObjectUtils.java:78)
at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinaryIfNeeded(CacheObjectContext.java:138)
at org.apache.ignite.internal.processors.datastreamer.DataStreamerEntry$1.getValue(DataStreamerEntry.java:96)
at com.nimblex.StreamVisitorExample$DeviceStreamReceiver.getValue(StreamVisitorExample.java:159)
at com.nimblex.StreamVisitorExample$DeviceStreamReceiver.receive(StreamVisitorExample.java:143)
at org.apache.ignite.internal.processors.datastreamer.DataStreamerUpdateJob.call(DataStreamerUpdateJob.java:141)
at org.apache.ignite.internal.processors.datastreamer.DataStreamProcessor.localUpdate(DataStreamProcessor.java:394)
at org.apache.ignite.internal.processors.datastreamer.DataStreamProcessor.processRequest(DataStreamProcessor.java:299)
at org.apache.ignite.internal.processors.datastreamer.DataStreamProcessor.access$000(DataStreamProcessor.java:60)
at org.apache.ignite.internal.processors.datastreamer.DataStreamProcessor$1.onMessage(DataStreamProcessor.java:90)
... 8 more
Caused by: java.lang.ClassNotFoundException: com.nimblex.StreamVisitorExample$MyDouble
at java.net.URLClassLoader.findClass(URLClassLoader.java:407)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:9373)
at org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:9311)
at org.apache.ignite.internal.MarshallerContextImpl.getClass(MarshallerContextImpl.java:384)
at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:717)
I added two lines of code at the beginning of the function, MyDouble
can be accessed here. The problem seems to be with the datastreamer.DataStreamerEntry$1.getValue
@Override
public void receive(IgniteCache<String, MyDouble> cache, Collection<Map.Entry<String, MyDouble>> entries) {
//CommunicationTrackKafkaProducer producer = CommunicationTrackKafkaProducer.getInstance();
MyDouble value = new MyDouble(null);
System.out.println("Just for test: "+value.toString());
for (Map.Entry<String, MyDouble> entry : entries) {
String symbol = entry.getKey();
MyDouble tick = getValue(entry);
Instrument inst = instCache.get(symbol);
if (inst == null)
inst = new Instrument(symbol);
// Don't populate market cache, as we don't use it for querying.
// Update cached instrument based on the latest market tick.
inst.update(tick.getValue());
instCache.put(symbol, inst);
}
}
error message:
Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException: com.nimblex.StreamVisitorExample$MyDouble
at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:741)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize0(BinaryReaderExImpl.java:1772)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1731)
at org.apache.ignite.internal.binary.BinaryObjectImpl.deserializeValue(BinaryObjectImpl.java:866)
at org.apache.ignite.internal.binary.BinaryObjectImpl.value(BinaryObjectImpl.java:198)
at org.apache.ignite.internal.processors.cache.CacheObjectUtils.unwrapBinary(CacheObjectUtils.java:199)
at org.apache.ignite.internal.processors.cache.CacheObjectUtils.unwrapBinaryIfNeeded(CacheObjectUtils.java:78)
at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinaryIfNeeded(CacheObjectContext.java:138)
at org.apache.ignite.internal.processors.datastreamer.DataStreamerEntry$1.getValue(DataStreamerEntry.java:96)
at com.nimblex.StreamVisitorExample$DeviceStreamReceiver.getValue(StreamVisitorExample.java:161)
at com.nimblex.StreamVisitorExample$DeviceStreamReceiver.receive(StreamVisitorExample.java:145)
at org.apache.ignite.internal.processors.datastreamer.DataStreamerUpdateJob.call(DataStreamerUpdateJob.java:141)
at org.apache.ignite.internal.processors.datastreamer.DataStreamProcessor.localUpdate(DataStreamProcessor.java:394)
at org.apache.ignite.internal.processors.datastreamer.DataStreamProcessor.processRequest(DataStreamProcessor.java:299)
at org.apache.ignite.internal.processors.datastreamer.DataStreamProcessor.access$000(DataStreamProcessor.java:60)
at org.apache.ignite.internal.processors.datastreamer.DataStreamProcessor$1.onMessage(DataStreamProcessor.java:90)
... 8 more
Caused by: java.lang.ClassNotFoundException: com.nimblex.StreamVisitorExample$MyDouble
at java.net.URLClassLoader.findClass(URLClassLoader.java:407)
issue
When I use IgniteDataStreamer with user defined class, like this:
I got the following error, it seems that the
MyDouble
class is not send to remote node:code
The code is modifed from https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java