You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "mimaison (via GitHub)" <gi...@apache.org> on 2024/10/30 09:40:58 UTC
[PR] MINOR: Various cleanups in metadata [kafka]
mimaison opened a new pull request, #17633:
URL: https://github.com/apache/kafka/pull/17633
### Committer Checklist (excluded from commit message)
- [ ] Verify design and implementation
- [ ] Verify test coverage and CI build status
- [ ] Verify documentation (including upgrade notes)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Various cleanups in metadata [kafka]
Posted by "mumrah (via GitHub)" <gi...@apache.org>.
mumrah commented on code in PR #17633:
URL: https://github.com/apache/kafka/pull/17633#discussion_r1822929049
##########
metadata/src/main/java/org/apache/kafka/controller/PeriodicTaskControlManager.java:
##########
@@ -206,7 +206,7 @@ private void reschedule(PeriodicTask task, boolean immediate, boolean error) {
long nextDelayTimeNs = nextDelayTimeNs(task, immediate, error);
long nextRunTimeNs = time.nanoseconds() + nextDelayTimeNs;
log.trace("rescheduling {} in {} ns (immediate = {}, error = {})",
- task.name(), nextDelayTimeNs, immediate);
+ task.name(), nextDelayTimeNs, immediate, error);
Review Comment:
nice find :)
##########
metadata/src/main/java/org/apache/kafka/metadata/util/SnapshotFileReader.java:
##########
@@ -130,17 +131,15 @@ private void handleControlBatch(FileChannelRecordBatch batch) {
try {
short typeId = ControlRecordType.parseTypeId(record.key());
ControlRecordType type = ControlRecordType.fromTypeId(typeId);
- switch (type) {
- case LEADER_CHANGE:
- LeaderChangeMessage message = new LeaderChangeMessage();
- message.read(new ByteBufferAccessor(record.value()), (short) 0);
- listener.handleLeaderChange(new LeaderAndEpoch(
+ if (Objects.requireNonNull(type) == ControlRecordType.LEADER_CHANGE) {
Review Comment:
Since ControlRecordType.fromTypeId always returns a non-null, we can just do `if(type == ControlRecordType.LEADER_CHANGE)`. Theoretically, using `Objects.requireNonNull(type)` changes the behavior by throwing instead of just logging an error.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Various cleanups in metadata [kafka]
Posted by "mimaison (via GitHub)" <gi...@apache.org>.
mimaison commented on code in PR #17633:
URL: https://github.com/apache/kafka/pull/17633#discussion_r1822977144
##########
metadata/src/main/java/org/apache/kafka/metadata/util/SnapshotFileReader.java:
##########
@@ -130,17 +131,15 @@ private void handleControlBatch(FileChannelRecordBatch batch) {
try {
short typeId = ControlRecordType.parseTypeId(record.key());
ControlRecordType type = ControlRecordType.fromTypeId(typeId);
- switch (type) {
- case LEADER_CHANGE:
- LeaderChangeMessage message = new LeaderChangeMessage();
- message.read(new ByteBufferAccessor(record.value()), (short) 0);
- listener.handleLeaderChange(new LeaderAndEpoch(
+ if (Objects.requireNonNull(type) == ControlRecordType.LEADER_CHANGE) {
Review Comment:
Right, I've reverted that change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Various cleanups in metadata [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 merged PR #17633:
URL: https://github.com/apache/kafka/pull/17633
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Various cleanups in metadata [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #17633:
URL: https://github.com/apache/kafka/pull/17633#discussion_r1822511436
##########
metadata/src/test/java/org/apache/kafka/controller/BrokerHeartbeatTrackerTest.java:
##########
@@ -43,12 +43,11 @@ private static BrokerHeartbeatTracker newBrokerHeartbeatTracker() {
private static final Set<BrokerIdAndEpoch> TEST_BROKERS;
static {
- Set<BrokerIdAndEpoch> brokers = new HashSet<>();
- Arrays.asList(
- new BrokerIdAndEpoch(0, 0L),
- new BrokerIdAndEpoch(1, 100L),
- new BrokerIdAndEpoch(2, 200L)
- ).forEach(brokers::add);
+ Set<BrokerIdAndEpoch> brokers = new HashSet<>(Arrays.asList(
Review Comment:
Maybe we can leverage `Set.of`
```java
private static final Set<BrokerIdAndEpoch> TEST_BROKERS = Set.of(
new BrokerIdAndEpoch(0, 0L),
new BrokerIdAndEpoch(1, 100L),
new BrokerIdAndEpoch(2, 200L)
);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Various cleanups in metadata [kafka]
Posted by "mimaison (via GitHub)" <gi...@apache.org>.
mimaison commented on code in PR #17633:
URL: https://github.com/apache/kafka/pull/17633#discussion_r1822719923
##########
metadata/src/test/java/org/apache/kafka/controller/BrokerHeartbeatTrackerTest.java:
##########
@@ -43,12 +43,11 @@ private static BrokerHeartbeatTracker newBrokerHeartbeatTracker() {
private static final Set<BrokerIdAndEpoch> TEST_BROKERS;
static {
- Set<BrokerIdAndEpoch> brokers = new HashSet<>();
- Arrays.asList(
- new BrokerIdAndEpoch(0, 0L),
- new BrokerIdAndEpoch(1, 100L),
- new BrokerIdAndEpoch(2, 200L)
- ).forEach(brokers::add);
+ Set<BrokerIdAndEpoch> brokers = new HashSet<>(Arrays.asList(
Review Comment:
Yeah I kind of refrained myself from using `Set.of()`/`List.of()` to not cause too many changes but in this case it makes sense to use `Set.of()` and remove the ugly `static` block. Done, thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org