forked from apache/gravitino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[apache#2610] feat(kafka-catalog, core): Adapt the Kafka catalog to C…
…atalogOperationsDispatcher (apache#2694) ### What changes were proposed in this pull request? This PR add the Kafka catalog adaption to the CatalogOperationsDispatcher ### Why are the changes needed? Part of Kafka catalog support work Fix: apache#2610 ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? UTs
- Loading branch information
Showing
13 changed files
with
762 additions
and
19 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
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
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
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
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
76 changes: 76 additions & 0 deletions
76
core/src/main/java/com/datastrato/gravitino/catalog/EntityCombinedTopic.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,76 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
package com.datastrato.gravitino.catalog; | ||
|
||
import com.datastrato.gravitino.Audit; | ||
import com.datastrato.gravitino.messaging.Topic; | ||
import com.datastrato.gravitino.meta.AuditInfo; | ||
import com.datastrato.gravitino.meta.TopicEntity; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* A Topic class to represent a topic metadata object that combines the metadata both from {@link | ||
* Topic} and {@link TopicEntity}. | ||
*/ | ||
public class EntityCombinedTopic implements Topic { | ||
|
||
private final Topic topic; | ||
private final TopicEntity topicEntity; | ||
|
||
// Sets of properties that should be hidden from the user. | ||
private Set<String> hiddenProperties; | ||
|
||
private EntityCombinedTopic(Topic topic, TopicEntity topicEntity) { | ||
this.topic = topic; | ||
this.topicEntity = topicEntity; | ||
} | ||
|
||
public static EntityCombinedTopic of(Topic topic, TopicEntity topicEntity) { | ||
return new EntityCombinedTopic(topic, topicEntity); | ||
} | ||
|
||
public static EntityCombinedTopic of(Topic topic) { | ||
return new EntityCombinedTopic(topic, null); | ||
} | ||
|
||
public EntityCombinedTopic withHiddenPropertiesSet(Set<String> hiddenProperties) { | ||
this.hiddenProperties = hiddenProperties; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return topic.name(); | ||
} | ||
|
||
@Override | ||
public String comment() { | ||
return topic.comment(); | ||
} | ||
|
||
@Override | ||
public Map<String, String> properties() { | ||
return topic.properties().entrySet().stream() | ||
.filter(p -> !hiddenProperties.contains(p.getKey())) | ||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); | ||
} | ||
|
||
@Override | ||
public Audit auditInfo() { | ||
AuditInfo mergedAudit = | ||
AuditInfo.builder() | ||
.withCreator(topic.auditInfo().creator()) | ||
.withCreateTime(topic.auditInfo().createTime()) | ||
.withLastModifier(topic.auditInfo().lastModifier()) | ||
.withLastModifiedTime(topic.auditInfo().lastModifiedTime()) | ||
.build(); | ||
|
||
return topicEntity == null | ||
? topic.auditInfo() | ||
: mergedAudit.merge(topicEntity.auditInfo(), true /* overwrite */); | ||
} | ||
} |
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.