not clear how to set the kryo-initializer in the config
Zhen-hao opened this issue · 2 comments
Zhen-hao commented
I put
akka-kryo-serialization.kryo-initializer = "com.esotericsoftware.kryo.serializers.TaggedFieldSerializer"
in my config file. but got
[error] java.lang.IllegalStateException: Configured class class com.esotericsoftware.kryo.serializers.TaggedFieldSerialize
r does not extend DefaultKryoInitializer
Maybe I didn't understand it from the doc. Do I need to create a class in my source code?
nvollmar commented
akka-kryo-serialization.kryo-initializer
expects an KryoInitializer (extending the DefaultKryoInitializer
) to do your custom initialization.
If you want to change the field serializer you need to create. your XyzKyroInitializer
extending DefaultKryoInitializer
and then override preInit
method:
class XyzKyroInitializer extends DefaultKryoInitializer {
def preInit(kryo: ScalaKryo): Unit = {
kryo.setDefaultSerializer(classOf[com.esotericsoftware.kryo.serializers.TaggedFieldSerializer[_]])
}
}
and the configure that one:
akka-kryo-serialization.kryo-initializer = "com.example.XyzKyroInitializer"
Maybe we should improve the documentation with such an example :)
Zhen-hao commented
Thank you so much!
feel free to close it since there is a work in progress