-
Notifications
You must be signed in to change notification settings - Fork 132
Update Kafka Client to 2.8.0 #1588
Update Kafka Client to 2.8.0 #1588
Conversation
@eolivelli:Thanks for your contribution. For this PR, do we need to update docs? |
436e36c
to
109f697
Compare
kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/KafkaCommandDecoder.java
Outdated
Show resolved
Hide resolved
...java/io/streamnative/pulsar/handlers/kop/coordinator/transaction/CorrelationIdGenerator.java
Outdated
Show resolved
Hide resolved
Overall, LGTM. I will wait for the unit's test to pass. |
@Demogorgon314 @BewareMyPower this patch is finally ready for review. |
Codecov Report
@@ Coverage Diff @@
## master #1588 +/- ##
============================================
- Coverage 15.34% 14.98% -0.36%
Complexity 592 592
============================================
Files 164 164
Lines 11913 12199 +286
Branches 1102 1112 +10
============================================
Hits 1828 1828
- Misses 9931 10217 +286
Partials 154 154
|
CI passed |
Set<String> members = new HashSet<>(); | ||
if (!data.memberId().isEmpty()) { | ||
// old clients | ||
members.add(data.memberId()); | ||
} | ||
data.members().forEach(memberIdentity -> { | ||
members.add(memberIdentity.memberId()); | ||
}); |
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.
We can use functional style here
Set<String> members = data.members().stream()
.map(LeaveGroupRequestData.MemberIdentity::memberId)
.collect(Collectors.toSet());
if (!data.memberId().isEmpty()) {
// old clients
members.add(data.memberId());
}
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.
sure
kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/KafkaRequestHandler.java
Outdated
Show resolved
Hide resolved
kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/KafkaRequestHandler.java
Outdated
Show resolved
Hide resolved
kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/KafkaRequestHandler.java
Outdated
Show resolved
Hide resolved
kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/KafkaRequestHandler.java
Outdated
Show resolved
Hide resolved
.filter(p -> p.partitionIndex() == topicPartition1.partition()) | ||
.findFirst() | ||
.get() | ||
.errorCode(), | ||
Errors.UNKNOWN_TOPIC_OR_PARTITION); |
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.
Errors.UNKNOWN_TOPIC_OR_PARTITION); | |
Errors.UNKNOWN_TOPIC_OR_PARTITION.code()); |
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.
good catch
.filter(p -> p.partitionIndex() == topicPartition2.partition()) | ||
.findFirst() | ||
.get() | ||
.errorCode(), | ||
Errors.UNKNOWN_TOPIC_OR_PARTITION); |
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.
Errors.UNKNOWN_TOPIC_OR_PARTITION); | |
Errors.UNKNOWN_TOPIC_OR_PARTITION.code()); |
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.
fixed
Errors.UNKNOWN_TOPIC_OR_PARTITION); | ||
|
||
// invalid partition id 1. | ||
CompletableFuture<AbstractResponse> invalidResponse2 = new CompletableFuture<>(); | ||
checkInvalidPartition(invalidResponse2, topicName, 1); | ||
TopicPartition topicPartition2 = new TopicPartition(topicName, 1); | ||
AbstractResponse response2 = invalidResponse2.get(); | ||
assertEquals(((OffsetCommitResponse) response2).responseData().get(topicPartition2), | ||
assertEquals(((OffsetCommitResponse) response2) |
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.
assertEquals(((OffsetCommitResponse) response2) | |
assertEquals(((OffsetCommitResponse) response2) |
Adjust indent.
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.
fixed
@@ -680,6 +680,7 @@ public void testDescribeConfigFailed() throws PulsarAdminException { | |||
try { | |||
describeConfigsResult.all().get(); | |||
} catch (Exception ex) { | |||
log.error("Error", ex); |
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.
log.error("Error", ex); |
Remove this line because the exception is expected. Or just use log.info("Error: {}", ex.getMessage()
. BTW, I found here we should add a fail()
in the try
block.
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.
fixed
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.
@BewareMyPower I didn't add "fail()" for this PR, because with "fail()" actually the test will fail.
We can address this problem in the test in a follow up work.
it is not strictly related to this patch
tests/src/test/java/io/streamnative/pulsar/handlers/kop/KafkaListenerNameTest.java
Outdated
Show resolved
Hide resolved
tests/src/test/java/io/streamnative/pulsar/handlers/kop/KafkaListenerNameTest.java
Outdated
Show resolved
Hide resolved
My review is done, PTAL. |
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.
Thank you @BewareMyPower for you quick feedback
I have addressed all of your comments.
@@ -680,6 +680,7 @@ public void testDescribeConfigFailed() throws PulsarAdminException { | |||
try { | |||
describeConfigsResult.all().get(); | |||
} catch (Exception ex) { | |||
log.error("Error", ex); |
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.
fixed
tests/src/test/java/io/streamnative/pulsar/handlers/kop/KafkaListenerNameTest.java
Outdated
Show resolved
Hide resolved
tests/src/test/java/io/streamnative/pulsar/handlers/kop/KafkaListenerNameTest.java
Outdated
Show resolved
Hide resolved
Set<String> members = new HashSet<>(); | ||
if (!data.memberId().isEmpty()) { | ||
// old clients | ||
members.add(data.memberId()); | ||
} | ||
data.members().forEach(memberIdentity -> { | ||
members.add(memberIdentity.memberId()); | ||
}); |
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.
sure
@BewareMyPower what about the "snyk" failures ? before my last commit it was passing |
1 similar comment
@BewareMyPower what about the "snyk" failures ? before my last commit it was passing |
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.
LGTM. Just left some small comments.
kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/KafkaRequestHandler.java
Outdated
Show resolved
Hide resolved
kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/KafkaRequestHandler.java
Outdated
Show resolved
Hide resolved
kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/KafkaRequestHandler.java
Outdated
Show resolved
Hide resolved
...pl/src/main/java/io/streamnative/pulsar/handlers/kop/coordinator/group/GroupCoordinator.java
Outdated
Show resolved
Hide resolved
) { | ||
return validateGroupStatus(groupId, ApiKeys.LEAVE_GROUP).map(CompletableFuture::completedFuture | ||
).orElseGet(() -> groupManager.getGroup(groupId).map(group -> group.inLock(() -> { | ||
if (group.is(Dead) || !group.has(memberId)) { | ||
if (group.is(Dead)) { | ||
return CompletableFuture.completedFuture(Errors.UNKNOWN_MEMBER_ID); |
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 error should be Errors.COORDINATOR_NOT_AVAILABLE
?
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.
previously it was UNKNOWN_MEMBER_ID, I didn't want to change the behaviour
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.
Sure, I just found the Kafka 2.8 code is using Errors.COORDINATOR_NOT_AVAILABLE
. We can change it in next PR if necessary.
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.
let me follow up with another patch on this
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.
@Demogorgon314 finally I updated this value in this PR
kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/utils/KafkaResponseUtils.java
Outdated
Show resolved
Hide resolved
kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/utils/KafkaResponseUtils.java
Outdated
Show resolved
Hide resolved
kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/utils/KafkaResponseUtils.java
Outdated
Show resolved
Hide resolved
tests/src/test/java/io/streamnative/pulsar/handlers/kop/KafkaApisTest.java
Outdated
Show resolved
Hide resolved
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 have addresses your comments.
I hope I haven't missed any of them
thank you @Demogorgon314 @BewareMyPower
kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/KafkaRequestHandler.java
Outdated
Show resolved
Hide resolved
kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/KafkaRequestHandler.java
Outdated
Show resolved
Hide resolved
kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/KafkaRequestHandler.java
Outdated
Show resolved
Hide resolved
) { | ||
return validateGroupStatus(groupId, ApiKeys.LEAVE_GROUP).map(CompletableFuture::completedFuture | ||
).orElseGet(() -> groupManager.getGroup(groupId).map(group -> group.inLock(() -> { | ||
if (group.is(Dead) || !group.has(memberId)) { | ||
if (group.is(Dead)) { | ||
return CompletableFuture.completedFuture(Errors.UNKNOWN_MEMBER_ID); |
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.
previously it was UNKNOWN_MEMBER_ID, I didn't want to change the behaviour
...pl/src/main/java/io/streamnative/pulsar/handlers/kop/coordinator/group/GroupCoordinator.java
Outdated
Show resolved
Hide resolved
.filter(p -> p.partitionIndex() == topicPartition1.partition()) | ||
.findFirst() | ||
.get() | ||
.errorCode(), | ||
Errors.UNKNOWN_TOPIC_OR_PARTITION); |
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.
good catch
Errors.UNKNOWN_TOPIC_OR_PARTITION); | ||
|
||
// invalid partition id 1. | ||
CompletableFuture<AbstractResponse> invalidResponse2 = new CompletableFuture<>(); | ||
checkInvalidPartition(invalidResponse2, topicName, 1); | ||
TopicPartition topicPartition2 = new TopicPartition(topicName, 1); | ||
AbstractResponse response2 = invalidResponse2.get(); | ||
assertEquals(((OffsetCommitResponse) response2).responseData().get(topicPartition2), | ||
assertEquals(((OffsetCommitResponse) response2) |
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.
fixed
.filter(p -> p.partitionIndex() == topicPartition2.partition()) | ||
.findFirst() | ||
.get() | ||
.errorCode(), | ||
Errors.UNKNOWN_TOPIC_OR_PARTITION); |
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.
fixed
tests/src/test/java/io/streamnative/pulsar/handlers/kop/KafkaApisTest.java
Outdated
Show resolved
Hide resolved
@@ -680,6 +680,7 @@ public void testDescribeConfigFailed() throws PulsarAdminException { | |||
try { | |||
describeConfigsResult.all().get(); | |||
} catch (Exception ex) { | |||
log.error("Error", ex); |
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.
@BewareMyPower I didn't add "fail()" for this PR, because with "fail()" actually the test will fail.
We can address this problem in the test in a follow up work.
it is not strictly related to this patch
The tests that failed on CI pass on my laptop |
@BewareMyPower is the failed test a flaky test ? |
This reverts commit 47d4995.
Co-authored-by: Yunze Xu <xyzinfernity@163.com>
de820da
to
214bae8
Compare
I have rebased on master |
@eolivelli I can reproduce this failed test in my locally. |
I will run the test many times. thanks for your feedback. |
@Demogorgon314 I have fixed the test. |
@BewareMyPower @Demogorgon314 can you please restart CI ? |
the same test did not fail here |
All tests passed. |
Summary of changes: - Bump client dependency from 2.1.x to 2.8.x - The Java Model for all the Request/Response changed to a Fluent/Builder style, this requires many changes - NotLeaderForPartitionException -> NotLeaderOrFollowerException - Copy new version of MockTime from Kafka codebase - ListOffsetRequest -> ListOffsetsRequest, ListOffsetResponse -> ListOffsetsResponse - LeaveGroup -> now support multiple members (cherry picked from commit 66efad6)
Summary of changes: - Bump client dependency from 2.1.x to 2.8.x - The Java Model for all the Request/Response changed to a Fluent/Builder style, this requires many changes - NotLeaderForPartitionException -> NotLeaderOrFollowerException - Copy new version of MockTime from Kafka codebase - ListOffsetRequest -> ListOffsetsRequest, ListOffsetResponse -> ListOffsetsResponse - LeaveGroup -> now support multiple members (cherry picked from commit 66efad6)
Summary of changes: