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

KAFKA-4549: Change to call flush method before writeEndMark method in close method of KafkaLZ4BlockOutputStream #2265

Closed
wants to merge 5 commits into from

Conversation

fossamagna
Copy link
Contributor

No description provided.

@fossamagna
Copy link
Contributor Author

@jkreps @dpkp

@asfbot
Copy link

asfbot commented Dec 16, 2016

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.11/184/
Test PASSed (JDK 8 and Scala 2.11).

@asfbot
Copy link

asfbot commented Dec 16, 2016

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/183/
Test FAILed (JDK 8 and Scala 2.12).

@asfbot
Copy link

asfbot commented Dec 16, 2016

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk7-scala2.10/182/
Test FAILed (JDK 7 and Scala 2.10).

@fossamagna
Copy link
Contributor Author

@granthenke

@fossamagna fossamagna changed the title KAFKA-4549: Change to call flush method before writeEndMark method in close method KAFKA-4549: Change to call flush method before writeEndMark method in close method in KafkaLZ4BlockOutputStream Dec 21, 2016
@fossamagna fossamagna changed the title KAFKA-4549: Change to call flush method before writeEndMark method in close method in KafkaLZ4BlockOutputStream KAFKA-4549: Change to call flush method before writeEndMark method in close method of KafkaLZ4BlockOutputStream Dec 21, 2016
@fossamagna
Copy link
Contributor Author

Can you please review @junrao @ijuma thanks.

Copy link
Contributor

@junrao junrao left a comment

Choose a reason for hiding this comment

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

@fossamagna : Thanks for finding this. Left a couple of comments.

flush();
writeEndMark();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we call flush() again after writeEndMark()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have a point. We should call flush in consideration of actually may be not flushed EndMark after writeEndMark().
I add call flush() after writeEndMark().

@@ -64,7 +64,7 @@ public void testKafkaLZ4() throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
KafkaLZ4BlockOutputStream lz4 = new KafkaLZ4BlockOutputStream(output, this.useBrokenFlagDescriptorChecksum);
lz4.write(this.payload, 0, this.payload.length);
lz4.flush();
lz4.close();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also add code to verify the end mark?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I add code to verify the end mark.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, it would be good to verify that flush still behaves as expected if called without close.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I add test pattern without close.

It's consideration that EndMark bytes may not be flushed after writeEndMark().
@asfbot
Copy link

asfbot commented Dec 22, 2016

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.11/360/
Test PASSed (JDK 8 and Scala 2.11).

@asfbot
Copy link

asfbot commented Dec 22, 2016

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk7-scala2.10/358/
Test FAILed (JDK 7 and Scala 2.10).

@asfbot
Copy link

asfbot commented Dec 22, 2016

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/359/
Test PASSed (JDK 8 and Scala 2.12).

@fossamagna
Copy link
Contributor Author

Thanks for the review @junrao. I add test code to verify the end mark.

Copy link
Contributor

@ijuma ijuma left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. I left a couple of comments.

@@ -64,7 +64,7 @@ public void testKafkaLZ4() throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
KafkaLZ4BlockOutputStream lz4 = new KafkaLZ4BlockOutputStream(output, this.useBrokenFlagDescriptorChecksum);
lz4.write(this.payload, 0, this.payload.length);
lz4.flush();
lz4.close();
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, it would be good to verify that flush still behaves as expected if called without close.

@@ -259,6 +259,7 @@ private void ensureNotFinished() {
@Override
public void close() throws IOException {
if (!finished) {
flush();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need to call flush here? It's a bit odd to have to do it twice. Would writeBlock be enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. It is enough if writeBlock () is called.

@fossamagna
Copy link
Contributor Author

@ijuma Thanks for the review. I have updated the PR.

@asfbot
Copy link

asfbot commented Dec 26, 2016

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk7-scala2.10/387/
Test PASSed (JDK 7 and Scala 2.10).

@asfbot
Copy link

asfbot commented Dec 26, 2016

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/388/
Test FAILed (JDK 8 and Scala 2.12).

@asfbot
Copy link

asfbot commented Dec 26, 2016

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.11/389/
Test FAILed (JDK 8 and Scala 2.11).

@asfgit asfgit closed this in 88a439e Dec 28, 2016
@ijuma
Copy link
Contributor

ijuma commented Dec 28, 2016

Thanks for the PR, LGTM. Merged to trunk after fixing the assertions to have expected and actual in the right order (an issue that existed before this PR).

soenkeliebau pushed a commit to soenkeliebau/kafka that referenced this pull request Feb 7, 2017
…tStream.close()

Author: MURAKAMI Masahiko <fossamagna2@gmail.com>

Reviewers: Jun Rao <junrao@gmail.com>, Ismael Juma <ismael@juma.me.uk>

Closes apache#2265 from fossamagna/fix-lz4outputstream-close
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