MINOR: Cleanups in storage module#20087
Conversation
m1a2st
left a comment
There was a problem hiding this comment.
Thanks for this PR, left some comments
| public record LoadedLogOffsets(long logStartOffset, long recoveryPoint, LogOffsetMetadata nextOffsetMetadata) { | ||
| public LoadedLogOffsets(final long logStartOffset, | ||
| final long recoveryPoint, | ||
| final LogOffsetMetadata nextOffsetMetadata) { |
There was a problem hiding this comment.
Should we remain equals(), hashCode(), toString() for this record?
There was a problem hiding this comment.
Removed equals() and hashCode()
| assertEquals(batch.timestampType(), TimestampType.CREATE_TIME); | ||
| assertEquals(TimestampType.CREATE_TIME, batch.timestampType()); | ||
| maybeCheckBaseTimestamp(timestampSeq.get(0), batch); | ||
| assertEquals(batch.maxTimestamp(), batch.maxTimestamp()); |
There was a problem hiding this comment.
This assertion also can remove
There was a problem hiding this comment.
I think there are the same issue at L365, L1811, We could update the actual value to TestUtils.toList(batch).stream().map(Record::timestamp).max(Long::compare).get(), the root cause is #16167
There was a problem hiding this comment.
I also found this issue while reviewing this PR and have already filed a MINOR to fix it before the comments. #20093
| public final short producerEpoch; | ||
|
|
||
| public LastRecord(OptionalLong lastDataOffset, short producerEpoch) { | ||
| public record LastRecord(OptionalLong lastDataOffset, short producerEpoch) { |
There was a problem hiding this comment.
Let's remove equals and hashCode.
|
@mimaison I think you meant the 'storage' module in the PR title. |
| import java.util.Iterator; | ||
|
|
||
| /** | ||
| * @param <R1> The type of records used to formulate the expectations. |
There was a problem hiding this comment.
The formatting of the type parameters in this javadoc comment is a little odd.
There was a problem hiding this comment.
I blame IntelliJ :) Fixed
| } | ||
|
|
||
| @Override | ||
| public String toString() { |
There was a problem hiding this comment.
the generated toString should be good enough I think
| return OptionalLong.of(content.brokerEpoch); | ||
| } catch (Exception e) { | ||
| logger.debug("Fail to read the clean shutdown file in " + cleanShutdownFile.toPath() + ":" + e); | ||
| logger.debug("Fail to read the clean shutdown file in {}:{}", cleanShutdownFile.toPath(), e); |
There was a problem hiding this comment.
the last parameter could be handled well if it is an exception object. Perhaps, we could use {} instead of {}:{}?
| } | ||
|
|
||
| @Override | ||
| public String toString() { |
There was a problem hiding this comment.
Not here as this also prints firstSeq and firstOffset which are not fields.
| public record CompletedTxn(long producerId, long firstOffset, long lastOffset, boolean isAborted) { | ||
|
|
||
| @Override | ||
| public String toString() { |
| IndexValue(T index) { | ||
| this.index = index; | ||
| } | ||
| private record IndexValue<T extends AbstractIndex>(T index) implements IndexWrapper { |
There was a problem hiding this comment.
There was an argument before for the "suitable" variables in a record class. I prefer to use record class only if all variables are immutable. That can ensure the hashCode and equals are consistent. What do you think? That is a kind of personal taste, so any feedback is welcomed
There was a problem hiding this comment.
Yeah it's a bit of a gray area. I'm happy to keep it as a regular class. I undid that change
|
@mimaison could you please fix the conflicts? |
79eb911 to
ffdc1a1
Compare
|
Rebased on trunk. The test failure, |
| return file.delete(); | ||
| } catch (final Exception e) { | ||
| LOGGER.error(format("Encountered error while deleting %s", file.getAbsolutePath())); | ||
| LOGGER.error("Encountered error while deleting {}", file.getAbsolutePath()); |
There was a problem hiding this comment.
Perhaps we should add the e to the logger
LOGGER.error("Encountered error while deleting {}", file.getAbsolutePath(), e);| public Integer getExpectedFromSecondTierCount() { | ||
| return expectedFromSecondTierCount; | ||
| } | ||
| public record ConsumableSpec(Long fetchOffset, Integer expectedTotalCount, Integer expectedFromSecondTierCount) { |
There was a problem hiding this comment.
I checked the usage of this class, and it appears using primitive types should be fine.
There was a problem hiding this comment.
Yep, I switched to primitive types in a bunch of classes
| public Integer getEventCount() { | ||
| return eventCount; | ||
| } | ||
| public record DeletableSpec(Integer sourceBrokerId, LocalTieredStorageEvent.EventType eventType, Integer eventCount) { |
| public RemoteFetchCount getFetchCount() { | ||
| return fetchCount; | ||
| } | ||
| public record FetchableSpec(Integer sourceBrokerId, RemoteFetchCount fetchCount) { |
| public List<ProducerRecord<String, String>> getRecords() { | ||
| return records; | ||
| } | ||
| public record OffloadableSpec(Integer sourceBrokerId, Integer baseOffset, |
chia7712
left a comment
There was a problem hiding this comment.
LGTM
I will file a separate minor PR, so we can focus on merging this large one first.
| .orElse(events); | ||
|
|
||
| RemoteFetchCount remoteFetchCount = remoteFetchSpec.getRemoteFetchCount(); | ||
| RemoteFetchCount.FetchCountAndOp expectedCountAndOp; |
There was a problem hiding this comment.
FetchCountAndOp could be rewritten as a record class
| this.t1 = t1; | ||
| this.t2 = t2; | ||
| } | ||
| private record Tuple2<T1, T2>(T1 t1, T2 t2) { |
There was a problem hiding this comment.
this could be replaced by Map.Entry
|
https://issues.apache.org/jira/browse/KAFKA-19513 will handle the flaky |
|
Thanks! |
Cleanups including: - Java 17 syntax, record and switch - assertEquals() order - javadoc Reviewers: Andrew Schofield <aschofield@confluent.io>, Jhen-Yung Hsu <jhenyunghsu@gmail.com>, Ken Huang <s7133700@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
Cleanups including:
Reviewers: Andrew Schofield aschofield@confluent.io, Jhen-Yung Hsu
jhenyunghsu@gmail.com, Ken Huang s7133700@gmail.com, Chia-Ping Tsai
chia7712@gmail.com