kryo类型查找会有两种形式,一种是根据类名,一种是根据id和类名的映射。
如果只是根据类名进行映射,不会出现问题,性能稍差;如果想根据id和类名的映射,性能较好,但是id和class的关系,必须保证在server端和client端的顺序一致。
在dubbo中,当你使用optimizer="org.apache.dubbo.benchmark.serialize.SerializationOptimizerImpl"
配置时,就会针对SerializationOptimizerImpl中定义的class开启id和class映射。代码如下:
*```*

public Collection<Class> getSerializableClasses() {
    return Arrays.asList(User.class, Page.class, UserService.class);
}

*```*
*整个调用出现问题的原理可以看下图。*

[image: image.png]

所以解决办法有两种:
1.不要启用这个优化,也就是不要设置optimizer。
2.dubbo代码进行了初步的优化,进行了初步的测试,可以运行。原理如图:
[image: image.png]


原来的接口里有一个全局的映射表,这个逻辑不改变的前提下;针对部分接口维度的优化,可以新建一个id和class列表。这样可以实现功能,但是同时带来了新建和维护这个列表的成本。

victory <[email protected]> 于2018年12月12日周三 下午3:04写道:

> I find the how it is happen.  I will commit a pr to complete the kryo
> serialization.
> But if you want to control the registry class , there will be some constraint
> to use.
>
> llx206 <[email protected]> 于2018年12月6日周四 下午5:31写道:
>
>> @eoc2015 <https://github.com/eoc2015> ,是要修改dubbo的代码,才能解决吗?
>>
>> —
>> You are receiving this because you are subscribed to this thread.
>> Reply to this email directly, view it on GitHub
>> <https://github.com/apache/incubator-dubbo/issues/2881#issuecomment-444807244>,
>> or mute the thread
>> <https://github.com/notifications/unsubscribe-auth/AD5mbFEyKQDI5IDThVzoS9vXVpbHl20Dks5u2OPkgaJpZM4ZADEY>
>> .
>>
>
>
> --
>
> Best Regard!
> cvitory
>


-- 

Best Regard!
cvitory


[ Full content available at: 
https://github.com/apache/incubator-dubbo/issues/2881 ]
This message was relayed via gitbox.apache.org for 
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to