cmccabe commented on code in PR #12571:
URL: https://github.com/apache/kafka/pull/12571#discussion_r957807838
##########
clients/src/test/java/org/apache/kafka/clients/admin/MockAdminClient.java:
##########
@@ -995,12 +1036,78 @@ public DescribeMetadataQuorumResult
describeMetadataQuorum(DescribeMetadataQuoru
@Override
public DescribeFeaturesResult describeFeatures(DescribeFeaturesOptions
options) {
- throw new UnsupportedOperationException("Not implemented yet");
+ Map<String, FinalizedVersionRange> finalizedFeatures = new HashMap<>();
+ Map<String, SupportedVersionRange> supportedFeatures = new HashMap<>();
+ for (Map.Entry<String, Short> entry : featureLevels.entrySet()) {
+ finalizedFeatures.put(entry.getKey(), new FinalizedVersionRange(
+ entry.getValue(), entry.getValue()));
+ supportedFeatures.put(entry.getKey(), new SupportedVersionRange(
+ minSupportedFeatureLevels.get(entry.getKey()),
+ maxSupportedFeatureLevels.get(entry.getKey())));
+ }
+ return new DescribeFeaturesResult(KafkaFuture.completedFuture(
+ new FeatureMetadata(finalizedFeatures,
+ Optional.of(123L),
+ supportedFeatures)));
}
@Override
- public UpdateFeaturesResult updateFeatures(Map<String, FeatureUpdate>
featureUpdates, UpdateFeaturesOptions options) {
- throw new UnsupportedOperationException("Not implemented yet");
+ public UpdateFeaturesResult updateFeatures(
+ Map<String, FeatureUpdate> featureUpdates,
+ UpdateFeaturesOptions options
+ ) {
+ Map<String, KafkaFuture<Void>> results = new HashMap<>();
+ for (Map.Entry<String, FeatureUpdate> entry :
featureUpdates.entrySet()) {
+ KafkaFutureImpl<Void> future = new KafkaFutureImpl<Void>();
+ String feature = entry.getKey();
+ try {
+ short cur = featureLevels.getOrDefault(feature, (short) 0);
+ short next = entry.getValue().maxVersionLevel();
+ short min = minSupportedFeatureLevels.getOrDefault(feature,
(short) 0);
+ short max = maxSupportedFeatureLevels.getOrDefault(feature,
(short) 0);
+ switch (entry.getValue().upgradeType()) {
+ case UNKNOWN:
+ throw new InvalidRequestException("Invalid upgrade
type.");
+ case UPGRADE:
+ if (cur > next) {
+ throw new InvalidUpdateVersionException("Can't
upgrade to lower version.");
+ }
+ break;
+ case SAFE_DOWNGRADE:
+ if (cur < next) {
+ throw new InvalidUpdateVersionException("Can't
downgrade to newer version.");
+ }
+ break;
+ case UNSAFE_DOWNGRADE:
+ if (cur < next) {
+ throw new InvalidUpdateVersionException("Can't
downgrade to newer version.");
+ }
+ while (next != cur) {
Review Comment:
yes, this is to artificially mark some versions as requiring an unsafe
downgrade.
--
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]