Skip to content

Commit

Permalink
fix define resources when oap is in cluster model
Browse files Browse the repository at this point in the history
  • Loading branch information
wankai123 committed Nov 28, 2024
1 parent 955e402 commit 4e1f2af
Showing 1 changed file with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,16 @@ private void installTopNAggregation(MetadataRegistry.Schema schema, BanyanDBClie
}
return;
}
client.define(schema.getTopNSpec());
log.info("installed TopN schema for measure {}", schema.getMetadata().name());
try {
client.define(schema.getTopNSpec());
log.info("installed TopN schema for measure {}", schema.getMetadata().name());
} catch (BanyanDBException ex) {
if (ex.getStatus().equals(Status.Code.ALREADY_EXISTS)) {
log.info("TopNAggregation {} already created by another OAP node", schema.getTopNSpec());
} else {
throw ex;
}
}
}

/**
Expand Down Expand Up @@ -321,8 +329,16 @@ private void checkIndexRules(List<IndexRule> indexRules, BanyanDBClient client)
IndexRule hisIndexRule = client.findIndexRule(
indexRule.getMetadata().getGroup(), indexRule.getMetadata().getName());
if (hisIndexRule == null) {
client.define(indexRule);
log.info("new IndexRule created: {}", indexRule);
try {
client.define(indexRule);
log.info("new IndexRule created: {}", indexRule);
} catch (BanyanDBException ex) {
if (ex.getStatus().equals(Status.Code.ALREADY_EXISTS)) {
log.info("IndexRule {} already created by another OAP node", indexRule);
} else {
throw ex;
}
}
} else {
boolean equals = hisIndexRule.toBuilder()
.clearUpdatedAt()
Expand Down Expand Up @@ -367,8 +383,16 @@ private void checkIndexRuleBinding(List<IndexRule> indexRules,
.addAllRules(indexRuleNames).build();
IndexRuleBinding hisIndexRuleBinding = client.findIndexRuleBinding(group, name);
if (hisIndexRuleBinding == null) {
client.define(indexRuleBinding);
log.info("new IndexRuleBinding created: {}", indexRuleBinding);
try {
client.define(indexRuleBinding);
log.info("new IndexRuleBinding created: {}", indexRuleBinding);
} catch (BanyanDBException ex) {
if (ex.getStatus().equals(Status.Code.ALREADY_EXISTS)) {
log.info("IndexRuleBinding {} already created by another OAP node", indexRuleBinding);
} else {
throw ex;
}
}
} else {
boolean equals = hisIndexRuleBinding.toBuilder()
.clearUpdatedAt()
Expand Down Expand Up @@ -409,8 +433,16 @@ private void checkTopNAggregation(Model model, BanyanDBClient client) throws Ban
if (schema.getTopNSpec() != null) {
TopNAggregation topNAggregation = schema.getTopNSpec();
if (hisTopNAggregation == null) {
client.define(topNAggregation);
log.info("new TopNAggregation created: {}", topNAggregation);
try {
client.define(topNAggregation);
log.info("new TopNAggregation created: {}", topNAggregation);
} catch (BanyanDBException ex) {
if (ex.getStatus().equals(Status.Code.ALREADY_EXISTS)) {
log.info("TopNAggregation {} already created by another OAP node", topNAggregation);
} else {
throw ex;
}
}
} else {
boolean equals = hisTopNAggregation.toBuilder()
.clearUpdatedAt()
Expand Down

0 comments on commit 4e1f2af

Please sign in to comment.