-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#2468] feat(kafka-catalog): support topic operations for Kafka catal…
…og (#2615) ### What changes were proposed in this pull request? This PR proposes to add the topic operations support for the Kafka catalog. ### Why are the changes needed? This is a part of the work to support messaging management in Gravitino Fix: #2468 ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? Add UTs to cover the codes.
- Loading branch information
Showing
11 changed files
with
1,063 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
321 changes: 312 additions & 9 deletions
321
...ng-kafka/src/main/java/com/datastrato/gravitino/catalog/kafka/KafkaCatalogOperations.java
Large diffs are not rendered by default.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
...alog-messaging-kafka/src/main/java/com/datastrato/gravitino/catalog/kafka/KafkaTopic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
package com.datastrato.gravitino.catalog.kafka; | ||
|
||
import static com.datastrato.gravitino.catalog.kafka.KafkaTopicPropertiesMetadata.PARTITION_COUNT; | ||
|
||
import com.datastrato.gravitino.connector.BaseTopic; | ||
import java.util.Optional; | ||
import org.apache.kafka.clients.admin.NewTopic; | ||
|
||
public class KafkaTopic extends BaseTopic { | ||
|
||
public NewTopic toKafkaTopic(KafkaTopicPropertiesMetadata propertiesMetadata) { | ||
Optional<Integer> partitionCount = | ||
Optional.ofNullable((int) propertiesMetadata.getOrDefault(properties(), PARTITION_COUNT)); | ||
Optional<Short> replicationFactor = | ||
Optional.ofNullable( | ||
(short) | ||
propertiesMetadata.getOrDefault( | ||
properties(), KafkaTopicPropertiesMetadata.REPLICATION_FACTOR)); | ||
return new NewTopic(name, partitionCount, replicationFactor); | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder extends BaseTopicBuilder<Builder, KafkaTopic> { | ||
|
||
@Override | ||
protected KafkaTopic internalBuild() { | ||
KafkaTopic topic = new KafkaTopic(); | ||
topic.name = name; | ||
topic.comment = comment; | ||
topic.properties = properties; | ||
topic.auditInfo = auditInfo; | ||
return topic; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.