cmccabe commented on code in PR #12177:
URL: https://github.com/apache/kafka/pull/12177#discussion_r876325079
##########
metadata/src/main/java/org/apache/kafka/controller/QuorumController.java:
##########
@@ -1735,17 +1742,38 @@ public CompletableFuture<UpdateFeaturesResponseData>
updateFeatures(
ControllerRequestContext context,
UpdateFeaturesRequestData request
) {
- return appendWriteEvent("updateFeatures", context.deadlineNs(), () -> {
- Map<String, Short> updates = new HashMap<>();
- Map<String, FeatureUpdate.UpgradeType> upgradeTypes = new
HashMap<>();
- request.featureUpdates().forEach(featureUpdate -> {
- String featureName = featureUpdate.feature();
- upgradeTypes.put(featureName,
FeatureUpdate.UpgradeType.fromCode(featureUpdate.upgradeType()));
- updates.put(featureName, featureUpdate.maxVersionLevel());
- });
- return featureControl.updateFeatures(updates, upgradeTypes,
clusterControl.brokerSupportedVersions(),
- request.validateOnly());
+ final AtomicLong offsetToSnapshot = new AtomicLong(0L);
+ return appendWriteEvent("updateFeatures", context.deadlineNs(), new
ControllerWriteOperation<Map<String, ApiError>>() {
+ @Override
+ public ControllerResult<Map<String, ApiError>>
generateRecordsAndResult() throws Exception {
+ Map<String, Short> updates = new HashMap<>();
+ Map<String, FeatureUpdate.UpgradeType> upgradeTypes = new
HashMap<>();
+ request.featureUpdates().forEach(featureUpdate -> {
+ String featureName = featureUpdate.feature();
+ upgradeTypes.put(featureName,
FeatureUpdate.UpgradeType.fromCode(featureUpdate.upgradeType()));
+ updates.put(featureName, featureUpdate.maxVersionLevel());
+ });
+ return featureControl.updateFeatures(updates, upgradeTypes,
clusterControl.brokerSupportedVersions(),
+ request.validateOnly());
+ }
+
+ @Override
+ public void processBatchEndOffset(long previousBatchEndOffset,
long offset) {
+ log.debug("Offset before metadata.version update {}. Offset
after update {}", previousBatchEndOffset, offset);
+ offsetToSnapshot.set(previousBatchEndOffset);
+ }
+
}).thenApply(result -> {
+ // The future that this chained callback is attached to is
completed synchronously from the Raft thread via
Review Comment:
Can you add a quick explanation of why we want the snapshot (can just be one
line)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]