-
Notifications
You must be signed in to change notification settings - Fork 14.3k
KAFKA-19004:Move DelayedDeleteRecords to server-common module #19226
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
Conversation
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.
Thanks @gongxuanzhang for this PR, left some comments
} else { | ||
status.setAcksPending(false); | ||
} | ||
}); |
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 should remain this log trace("Initial partition status for %s is %s".format(topicPartition, status))
private static final Meter AGGREGATE_EXPIRATION_METER = METRICS_GROUP.newMeter("ExpiresPerSec", "requests", | ||
TimeUnit.SECONDS); | ||
|
||
public static void recordExpiration(TopicPartition 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.
This TopicPartition partition
doesn't use, I think we can remove it.
} | ||
|
||
|
||
public DeleteRecordsResponseData.DeleteRecordsPartitionResult getResponseStatus() { |
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.
It seems that the get prefix is rarely used in Kafka, should change to responseStatus
return responseStatus; | ||
} | ||
|
||
public long getRequiredOffset() { |
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.
ditto It seems that the get prefix is rarely used in Kafka, should change to requiredOffset
@m1a2st thanks for your review, i have changed the code. public static void recordExpiration(TopicPartition partition) {
AGGREGATE_EXPIRATION_METER.mark();
} |
@chia7712 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.
@gongxuanzhang thanks for this patch!
import java.util.function.BiConsumer; | ||
import java.util.function.Consumer; | ||
|
||
public class DeleteRecordsPartitionStatus { |
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 main class should be DelayedDeleteRecords
rather than DeleteRecordsPartitionStatus
// create delayed delete records operation | ||
val delayedDeleteRecords = new DelayedDeleteRecords(timeout, deleteRecordsStatus, this, responseCallback) | ||
val delayedDeleteRecords = new DeleteRecordsPartitionStatus.DelayedDeleteRecords(timeout, deleteRecordsStatus.asJava,onAcks , responseCallbackJava) |
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.
deleteRecordsStatus.asJava, onAcks, responseCallbackJava
status.responseStatus.setLowWatermark(lw) | ||
} | ||
} | ||
val responseCallbackJava: java.util.function.Consumer[util.Map[TopicPartition, DeleteRecordsPartitionResult]] = |
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.
It seems we don't need to create this object, right? we can pass response => responseCallback(response.asScala)
directly
} | ||
} | ||
|
||
private static class DelayedDeleteRecordsMetrics { |
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 don't need this static class as all static variables can be moved to DelayedDeleteRecords
} | ||
|
||
private static class DelayedDeleteRecordsMetrics { | ||
private static final KafkaMetricsGroup METRICS_GROUP = new KafkaMetricsGroup(DelayedDeleteRecordsMetrics.class); |
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.
this break the compatibility of metrics name, so please use "kafka.server.DelayedDeleteRecordsMetrics" instead
deleteRecordsStatus.forEach((k, status) -> { | ||
responseStatus.put(k, status.responseStatus()); | ||
}); | ||
responseCallback.accept(responseStatus); |
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.
responseCallback.accept(deleteRecordsStatus.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().responseStatus())));
private volatile boolean acksPending; | ||
|
||
public DeleteRecordsPartitionStatus(long requiredOffset, | ||
DeleteRecordsResponseData.DeleteRecordsPartitionResult responseStatus) { |
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.
could you please import DeleteRecordsResponseData.DeleteRecordsPartitionResult
?
@chia7712 PTAL |
*/ | ||
public class DelayedDeleteRecords extends DelayedOperation { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(DelayedDeleteRecords.class); |
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
Consumer<Map<TopicPartition, DeleteRecordsPartitionResult>> responseCallback) { | ||
super(delayMs); | ||
this.onAcksPending = onAcksPending; | ||
this.deleteRecordsStatus = new ConcurrentHashMap<>(deleteRecordsStatus); |
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.
why to copy deleteRecordsStatus
? it is immutable, right?
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'll make it immutable and avoid copying. Thanks
@chia7712 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.
Thanks for this patch, left some comments
import kafka.server.ReplicaManager.{AtMinIsrPartitionCountMetricName, FailedIsrUpdatesPerSecMetricName, IsrExpandsPerSecMetricName, IsrShrinksPerSecMetricName, LeaderCountMetricName, OfflineReplicaCountMetricName, PartitionCountMetricName, PartitionsWithLateTransactionsCountMetricName, ProducerIdCountMetricName, ReassigningPartitionsMetricName, UnderMinIsrPartitionCountMetricName, UnderReplicatedPartitionsMetricName, createLogReadResult, isListOffsetsTimestampUnsupported} | ||
import kafka.server.ReplicaManager._ |
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 think this change is unnecessary.
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's keep the explicit imports
import org.apache.kafka.server.common.{DirectoryEventHandler, RequestLocal, StopPartition, TopicOptionalIdPartition} | ||
import org.apache.kafka.server.common._ |
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 think this change is unnecessary.
import org.apache.kafka.storage.internals.log.{AppendOrigin, FetchDataInfo, LeaderHwChange, LogAppendInfo, LogConfig, LogDirFailureChannel, LogOffsetMetadata, LogReadInfo, OffsetResultHolder, RecordValidationException, RemoteLogReadResult, RemoteStorageFetchInfo, UnifiedLog => UnifiedLog, VerificationGuard} | ||
|
||
import org.apache.kafka.storage.internals.log._ |
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 think this change is unnecessary.
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.
Thanks for the PR. I left a few comments.
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.kafka.server.common; |
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.
Would the org.apache.kafka.server.purgatory
package be a better place for these classes? So it's next to the abstract class DelayedOperation
it's extending.
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.
+1 to org.apache.kafka.server.purgatory
*/ | ||
public class DelayedDeleteRecords extends DelayedOperation { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(DelayedDeleteRecords.class); |
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.
Should we keep kafka.server.DelayedDeleteRecords
as the logger name?
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 don't think changing the name will affect anything. Do we have a special need to keep the name
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.
Logger names are what users set in their log4j2 configuration. But it seems we've not consistently kept names for other classes we moved, so this is probably fine.
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.
thanks for your answer
import kafka.server.ReplicaManager.{AtMinIsrPartitionCountMetricName, FailedIsrUpdatesPerSecMetricName, IsrExpandsPerSecMetricName, IsrShrinksPerSecMetricName, LeaderCountMetricName, OfflineReplicaCountMetricName, PartitionCountMetricName, PartitionsWithLateTransactionsCountMetricName, ProducerIdCountMetricName, ReassigningPartitionsMetricName, UnderMinIsrPartitionCountMetricName, UnderReplicatedPartitionsMetricName, createLogReadResult, isListOffsetsTimestampUnsupported} | ||
import kafka.server.ReplicaManager._ |
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's keep the explicit imports
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.
@gongxuanzhang thanks for updating patch.
// create delayed delete records operation | ||
val delayedDeleteRecords = new DelayedDeleteRecords(timeout, deleteRecordsStatus, this, responseCallback) | ||
val delayedDeleteRecords = new DelayedDeleteRecords(timeout, deleteRecordsStatus.asJava, onAcks , response => responseCallback(response.asScala)) |
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.
sJava, onAcks , response =
-> sJava, onAcks, response =
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.
this is not addressed
|
||
@Override | ||
public void onExpiration() { | ||
deleteRecordsStatus.forEach((topicPartition, status) -> { |
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.
AGGREGATE_EXPIRATION_METER.mark(deleteRecordsStatus.values().stream().filter(DeleteRecordsPartitionStatus::acksPending).count());
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.
@gongxuanzhang WDYT?
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.
excellent!
status.acksPending = false | ||
} | ||
|
||
trace("Initial partition status for %s is %s".format(topicPartition, status)) |
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.
please keep this log
@@ -97,6 +97,7 @@ | |||
<subpackage name="purgatory"> | |||
<allow pkg="org.apache.kafka.server.metrics" /> | |||
<allow pkg="org.apache.kafka.server.util" /> | |||
<allow pkg="com.yammer.metrics" /> |
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.
Should this be com.yammer.metrics.core
?
@chia7712 PTAL |
…#19226) Reviewers: Mickael Maison <[email protected]>, Ken Huang <[email protected]>, Chia-Ping Tsai <[email protected]>
I was looking at #19390 and wondering whether we should put these classes in |
It seems |
|
|
Yes I meant We need to keep |
@gongxuanzhang WDYT? If you agree @mimaison's comment, could you please create a MINOR to address it? |
move DeleteRecordsPartitionStatus.scala to server-common module.
scala --> java
Reviewers: Mickael Maison [email protected], Ken Huang [email protected], Chia-Ping Tsai [email protected]