Skip to content

Commit

Permalink
Add IT for BanyanDB schema install and update. (#12879)
Browse files Browse the repository at this point in the history
  • Loading branch information
wankai123 authored Dec 18, 2024
1 parent a3b563f commit e0d6411
Show file tree
Hide file tree
Showing 2 changed files with 339 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
@Slf4j
public class BanyanDBIndexInstaller extends ModelInstaller {
// BanyanDB group setting aligned with the OAP settings
private static final Set<String/*group name*/> GROUP_ALIGNED = new HashSet<>();
private static final Map<String/*group name*/, Map<String/*rule name*/, IndexRule>> GROUP_INDEX_RULES = new HashMap<>();
private final Set<String/*group name*/> groupAligned = new HashSet<>();
private final Map<String/*group name*/, Map<String/*rule name*/, IndexRule>> groupIndexRules = new HashMap<>();
private final BanyanDBStorageConfig config;

public BanyanDBIndexInstaller(Client client, ModuleManager moduleManager, BanyanDBStorageConfig config) {
Expand Down Expand Up @@ -239,7 +239,7 @@ private boolean checkResourceExistence(MetadataRegistry.SchemaMetadata metadata,
throw new IllegalStateException("unknown metadata kind: " + metadata.getKind());
}
if (!RunningMode.isNoInitMode()) {
if (!GROUP_ALIGNED.contains(metadata.getGroup())) {
if (!groupAligned.contains(metadata.getGroup())) {
// create the group if not exist
if (!resourceExist.hasGroup()) {
try {
Expand All @@ -262,7 +262,7 @@ private boolean checkResourceExistence(MetadataRegistry.SchemaMetadata metadata,
}
}
// mark the group as aligned
GROUP_ALIGNED.add(metadata.getGroup());
groupAligned.add(metadata.getGroup());
}
}
return resourceExist.hasResource();
Expand Down Expand Up @@ -317,7 +317,7 @@ private void checkIndexRuleConflicts(String modelName, IndexRule indexRule, Inde
* Otherwise, return false and mark the index rule as processed.
*/
private boolean checkIndexRuleProcessed(String modelName, IndexRule indexRule) {
Map<String, IndexRule> rules = GROUP_INDEX_RULES.computeIfAbsent(
Map<String, IndexRule> rules = groupIndexRules.computeIfAbsent(
indexRule.getMetadata().getGroup(), k -> new HashMap<>());
IndexRule existRule = rules.get(indexRule.getMetadata().getName());
if (existRule != null) {
Expand Down Expand Up @@ -457,7 +457,6 @@ private void checkIndexRules(String modelName, List<IndexRule> indexRules, Banya

/**
* Check if the index rule binding exists and update it if necessary.
* If the old index rule is not in the index rule binding, delete it.
*/
private void checkIndexRuleBinding(List<IndexRule> indexRules,
String group,
Expand Down
Loading

0 comments on commit e0d6411

Please sign in to comment.