Skip to content
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

feature: support kryo codec #1437

Merged
merged 21 commits into from
Sep 9, 2019
Merged

feature: support kryo codec #1437

merged 21 commits into from
Sep 9, 2019

Conversation

jsbxyyx
Copy link
Member

@jsbxyyx jsbxyyx commented Aug 9, 2019

protocol kryo serializer

@codecov-io
Copy link

codecov-io commented Aug 9, 2019

Codecov Report

Merging #1437 into develop will increase coverage by 0.33%.
The diff coverage is 91.57%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #1437      +/-   ##
=============================================
+ Coverage      46.38%   46.72%   +0.33%     
- Complexity      1717     1730      +13     
=============================================
  Files            350      353       +3     
  Lines          12855    12949      +94     
  Branches        1619     1619              
=============================================
+ Hits            5963     6050      +87     
- Misses          6242     6246       +4     
- Partials         650      653       +3
Impacted Files Coverage Δ Complexity Δ
...e/src/main/java/io/seata/core/codec/CodecType.java 0% <0%> (ø) 0 <0> (ø) ⬇️
.../main/java/io/seata/codec/kryo/KryoSerializer.java 100% <100%> (ø) 4 <4> (?)
...o/src/main/java/io/seata/codec/kryo/KryoCodec.java 63.63% <63.63%> (ø) 3 <3> (?)
...ava/io/seata/codec/kryo/KryoSerializerFactory.java 97.1% <97.1%> (ø) 6 <6> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1f9615f...0409f04. Read the comment docs.

@ujjboy
Copy link
Contributor

ujjboy commented Aug 9, 2019

Duplicate with #1418, can you close one PR?

@jsbxyyx
Copy link
Member Author

jsbxyyx commented Aug 9, 2019

@ujjboy #1418 is undolog serializer,current pr is protocol serializer

@ujjboy
Copy link
Contributor

ujjboy commented Aug 9, 2019

@jsbxyyx sorry, I didn't notice that.

Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add module in maven-shade-plugin

Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add kryo-serializers and kryo dependency in all.pom , just like protostuff

@slievrly slievrly changed the title protocol kryo serializer feature: support kryo codec Aug 27, 2019
Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test function pass

KryoSerializer kryoSerializer = KryoSerializerFactory.getInstance().get();
try {
T t = kryoSerializer.deserialize(bytes);
return t;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return kryoSerializer.serialize(t);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

KryoSerializer kryoSerializer = KryoSerializerFactory.getInstance().get();
try {
byte[] bytes = kryoSerializer.serialize(t);
return bytes;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return kryoSerializer.serialize(t);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

ByteArrayOutputStream baos = new ByteArrayOutputStream();
Output output = new Output(baos);
kryo.writeClassAndObject(output, t);
output.close();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need flush?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close() inner call flush()

public <T> T deserialize(byte[] bytes) {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
Input input = new Input(bais);
input.close();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Close is called before kryo.readClassAndObject(input);Is there a problem?
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FileInputStream close and ByteArrayInputStream close implements different, here not problem.

Copy link
Member

@xingfudeshi xingfudeshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xingfudeshi xingfudeshi merged commit 031a99f into apache:develop Sep 9, 2019
@jsbxyyx jsbxyyx deleted the protocol_kryo branch September 9, 2019 12:49
@wangliang181230 wangliang181230 added this to the 0.8.1 milestone Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants