I need to modify a class by adding two new parameters. This class is serialized with Kryo. I'm currently persisting the information related to this class, among other things, as an RDD, every time I stop my stream. When I restart the stream I load the information i previously persisted and use them to have consistency between when I stopped and when I restart.
Since the class I persist needs these new parameters, I changed the class and the serializer, by adding the new kryo.writeObject(output, object, ObjectSerializer)
and the kryo.readObject(input, classOf[Object], ObjectSerializer)
for the new parameters.
Now, whenever I restart my stream I obtain an exception: " Encountered unregistered class ...".
That seems obvious, because I try to deserialize an object which is not contained in the information I persisted when I stopped the stream. If I delete those data and start the stream as if it didn't have any previous run, then the exception does not occur.
Is there a way to avoid this exception? Maybe by specifying some default values in case those parameters are missing?
Thank You
EDIT:
I found something useful I didn't see before: Kryo issue 194.
This guy has implemented versioning by simply inserting a long defining which version of the deserializer he should be using. It's a simple solution but, since the company that wrote the code I'm working on didn't think about forward compatibility, I guess I'll have to throw out the window all the data that was persisted before the new serializer.
Please, let me know if you anyone could suggest a better solution.
EDIT 2:
Still having issues with this situation.
I tried to use the CompatibleFieldSerializer as described here :CompatibleFieldSerializer Example
So by registering this serializer and not the custom one that was previously used.
The result is that now, when reloading persisted data, it gives a java.lang.NullPointerException
.
Still no issues if no previous data where persisted. I can start my stream, serialize the new data, stop the stream, deserialize and restart my stream.
Still no clue on the resolution.