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

RATIS-1078. Refactor DataStream classes. #210

Merged
merged 1 commit into from Sep 29, 2020
Merged

RATIS-1078. Refactor DataStream classes. #210

merged 1 commit into from Sep 29, 2020

Conversation

szetszwo
Copy link
Contributor

@@ -29,25 +29,22 @@

@Override
protected void decode(ChannelHandlerContext channelHandlerContext,
ByteBuf byteBuf, List<Object> list) throws Exception {
ByteBuf byteBuf, List<Object> list) {

if(byteBuf.readableBytes() >= 24){
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity: why this magical number 24?

Copy link
Contributor

@amaliujia amaliujia Sep 28, 2020

Choose a reason for hiding this comment

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

Ah I see. It seems that there are at least 3 long at the beginning of the buffer to serve as metadata. That's why here checks >= 24 bytes.

It will be useful to have javadoc on encode/decode functions to document the encoding format.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This may be a good suggestion but is not related to this issue.

@@ -1,4 +1,4 @@
/**
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure about this, most project use /**

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See https://www.apache.org/licenses/LICENSE-2.0

the text should be enclosed in the appropriate comment syntax for the file format.

It requires comment syntax. If we use /**, the license will be shown in the generated javadoc. It probably is not something that we want.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for /*. With /** IntelliJ IDEA also warns about "Dangling Javadoc comment".

}
} else{
Copy link
Contributor

Choose a reason for hiding this comment

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

if byteBuf.readableBytes() >= 24 is false, do we need to print err log ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This may be a good suggestion but is not related to this issue. This is a refactoring but not try to change anything to the code.

DataStreamRequestServer req = new DataStreamRequestServer(streamId,
dataOffset,
bf);
final DataStreamRequestByteBuf req = new DataStreamRequestByteBuf(streamId, dataOffset, bf);
byteBuf.readerIndex(byteBuf.readerIndex() + (int)dataLength);
byteBuf.markReaderIndex();
list.add(req);
} else {
byteBuf.resetReaderIndex();
Copy link
Contributor

Choose a reason for hiding this comment

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

if byteBuf.readableBytes() >= dataLength is false, do we need to print err log ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This may be a good suggestion but is not related to this issue. This is a refactoring but not try to change anything to the code.

}
} else{
Copy link
Contributor

Choose a reason for hiding this comment

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

if byteBuf.readableBytes() >= 24 is false, do we need to print err log ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This may be a good suggestion but is not related to this issue. This is a refactoring but not try to change anything to the code.

@runzhiwang
Copy link
Contributor

@szetszwo Thanks for the patch. It looks good to me overall. Just a few comments added inline.

@szetszwo
Copy link
Contributor Author

@runzhiwang , thanks for reviewing this. This issue is for refactoring but not try to change anything to the code as stated in the description of https://issues.apache.org/jira/browse/RATIS-1078 .

@amaliujia
Copy link
Contributor

LGTM as this is a just a refactoring. We can fix useful suggestions in the another Jira.

@runzhiwang runzhiwang merged commit 11689cd into apache:master Sep 29, 2020
@runzhiwang
Copy link
Contributor

runzhiwang commented Sep 29, 2020

@szetszwo Thanks for the patch, I have merged it. @amaliujia Thanks for review.

@szetszwo
Copy link
Contributor Author

@runzhiwang , @amaliujia thanks a lot for reviewing this.

symious pushed a commit to symious/ratis that referenced this pull request Feb 6, 2024
Co-authored-by: Tsz Wo Sze <tszwosze@Tszs-MacBook-Pro.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants