Hi Dmitry,

Thanks for your response!  

I want to confirm my understanding - 
If I disable compact footer and add your POJOs in BinaryConfiguration, I will 
be deserialize back the serialized object after I stop grid and removed the 
local files that hold the marshaller cache (I believe they are located in the 
tmp folder).

Questions:
1. >> Second case, if you by some reason want to use BinaryObject directly. You 
should be aware that fact you can read and add fields, but you will not be able 
to enlist them..... Again, hopefully, you can solve this with 
BinaryConfiguration
I don't get the 'enlist' part in this sentence.  Does that mean I cannot turn 
them back into POJO even if I list my POJO in BinaryConfiguration?  Or this has 
something to do with BinaryObject.

2. Regarding BinaryObject, I have a regular POJO user class that does not 
implement Binarylizable and Externalizable,  and has no 'writeObject' and 
'readObject' method (BinaryContext.canUseReflectiveSerializer).  I see that its 
BinaryClassDescriptor  has a mode of BinaryWriteMode.OBJECT, not 
BinaryWriteMode.BINARY_OBJ.  Does not mean I cannot use it as BinaryObject?  
From reading the doc, looks like all sample objects will be serialized as 
BinaryObject automatically 
(https://apacheignite.readme.io/docs/binary-marshaller).  However, that is not 
what I am seeing in the code.

3. The error log shows that OptimizedMarshaller is being called.  Since all my 
classes are neither Binarylizable nor Externalizable, does that mean the 
marshalling error is related to versioning of an Ignite class?

Caused by: org.apache.ignite.IgniteCheckedException: Failed to deserialize 
object with given class loader: 
[clsLdr=org.apache.ignite.internal.processors.cache.GridCacheDeploymentManager$CacheClassLoader@3bc180c9,
 err=Unexpected error occurred during unmarshalling of an instance of the 
class: java.time.Ser. Check that all nodes are running the same version of 
Ignite and that all nodes have GridOptimizedMarshaller configured with 
identical optimized classes lists, if any (see setClassNames and 
setClassNamesPath methods). If your serialized classes implement 
java.io.Externalizable interface, verify that serialization logic is correct.]
        at 
org.apache.ignite.internal.marshaller.optimized.OptimizedMarshaller.unmarshal0(OptimizedMarshaller.java:236)
 ~[ignite-core-2.3.0-clsa.20180130.59.jar:2.3.0-clsa.20180130.59]
        at

Please note that I ask these questions because I need to look into an issue 
that happened some time ago.  I have the log with me, but I am not able to 
reproduce the issue.  That's why I try to understand more.

Thanks,
Calvin

-----Original Message-----
From: dkarachentsev [mailto:dkarachent...@gridgain.com] 
Sent: Wednesday, June 27, 2018 8:52 PM
To: user@ignite.apache.org
Subject: Re: Best practice for class versioning: marshaller error

Hi Calvin,

BinaryMarshaller can solve that issue with involving a few more. 
First of all, you will need to disable compact footer to let each
BinaryObject has it's schema in footer.

If you need just put/get POJOs everything will be fine. But you need to
enlist your POJO in BinaryConfiguration [1], because Ignite identifies type
with typeId, that is by default hash from full class name. So each
BinaryObject keeps only typeId. To find proper class to which it should be
deserialized, Ignite needs mapping class name -> typeId. This mapping keeps
in marshaller cache that holds in memory and in local files. Anyway you can
stop grid, remove Ignite files and ran into issue that you cannot
deserialize object, because Ignite cannot find class name for some typeId.
And as I said, you need to enlist this class in BinaryConfiguration, that
Ignite will read on start and fill marshaller cache.

Second case, if you by some reason want to use BinaryObject directly. You
should be aware that fact you can read and add fields, but you will not be
able to enlist them. Because here used the same approach: field name
converts to fieldId. Mapping fieldName -> fieldId is called meta info and
stored in local meta cache. Again, hopefully, you can solve this with
BinaryConfiguration.

In summary, BinaryMarshaller is OK with different schema, but you need
disable compact footer and add your POJOs in BinaryConfiguration.

[1]
https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/BinaryConfiguration.html

Thanks!
-Dmitry



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
The content of this communication is intended for the recipient and is subject 
to CLSA Legal and Regulatory Notices.
These can be viewed at https://www.clsa.com/disclaimer.html or sent to you upon 
request.
Please consider before printing. CLSA is ISO14001 certified and committed to 
reducing its impact on the environment.

Reply via email to