-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes to support better separation between applying global and type serialization #7
Conversation
…l custom serialization configuration against specific type serialization
@wneild: many thanks for your contribution. There are some integration tests failing, you can run them locally by calling Some more thoughts: I think the separation between Global / Type-specific serializers is useful when you are creating a custom subclass. However I quite like to have a single out-of-the-box implementation - it makes the default user experience smoother - just a single class to deal with. Smooth user experience is one of the core features of this project. Here is a proposal:
What do you think? |
… added Global/Type-specific UserSerializer abstract implementations
@jerrinot thanks for the feedback! Good suggestion, I've fixed the tests I missed and made those changes. The only thing I'm not sure on is the constructor argument for |
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
|
||
public abstract class AbstractSerializer<T> implements StreamSerializer<T>, HazelcastInstanceAware { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this probably should be package private, not public
. We do not want users to create own subclasses of this class.
import info.jerrinot.subzero.internal.PropertyUserSerializer; | ||
import info.jerrinot.subzero.internal.strategy.TypedKryoStrategy; | ||
|
||
public abstract class AbstractTypeSpecificUserSerializer<T> extends AbstractSerializer<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaDoc is needed here. with a description when and how-to extend this class
* @param serializerClazz Class of global serializer implementation to use | ||
* @return Hazelcast configuration. | ||
*/ | ||
public static <T> Config useAsGlobalSerializer(Config config, Class<? extends AbstractGlobalUserSerializer> serializerClazz) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not add this method. Methods in the SubZero
class are for user-convenience. For a quick-start if the default SubZero is good enough for you. If you are implementing own serializer then you do not need the convenience.
I expect majority of users won't/shouldn't need to create custom subclasses. The extra methods here could be confusing for new users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I see it, SubZero is all about providing convenience, so I'm not convinced about not having some convenience method to add custom serialization configuration. The alternative is forcing the user to write out what's already available internally to SubZero class when registering the custom global serializer to hazelcast, which seems a waste.
I couldn't comment on how widely used custom serialization is (probably about 10% of Kryo users going by github stars https://github.com/magro/kryo-serializers) but I will remove the methods if you're not convinced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, makes sense. let's keep it in.
|
||
import info.jerrinot.subzero.internal.strategy.GlobalKryoStrategy; | ||
|
||
public abstract class AbstractGlobalUserSerializer<T> extends AbstractSerializer<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaDoc is missing. I think users will need to extend this classes if and only if
- they need to register custom Kryo serializers
- the out-of-the-box way to register custom serializers (=properties for now) is not sufficient.
Is this correct? Do you see any other user-case?
@wneild: thanks for the updated PR. It looks good! I made some minor comments, please let me know what do you think about them. Also +1 to |
…y of AbstractSerializer to package private
good work, many thanks! |
Changes include: