Make bydb depdendencies file checked and consistent. (#12961)

This commit is contained in:
吴晟 Wu Sheng 2025-01-13 17:47:15 +08:00 committed by GitHub
parent ca5c8b29e1
commit d447c4534f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 0 deletions

View File

@ -60,6 +60,7 @@
<include>metadata-service-mapping.yaml</include>
<include>trace-sampling-policy-settings.yml</include>
<include>hierarchy-definition.yml</include>
<include>bydb.dependencies.properties</include>
<include>oal/*.oal</include>
<include>fetcher-prom-rules/*.yaml</include>
<include>envoy-metrics-rules/**</include>

View File

@ -10,6 +10,7 @@ bydb.version=x.y
# BanyanDB API version is the version number of the BanyanDB query APIs
# OAP server has bundled implementation of BanyanDB Java client.
# Please check BanyanDB documentation for the API version compatibility.
# https://skywalking.apache.org/docs/skywalking-banyandb/next/installation/versions
# Each `bydb.api.version` could have multiple compatible release version(`bydb.version`).
bydb.api.version=x.y
```

View File

@ -19,5 +19,6 @@ bydb.version=0.8
# BanyanDB API version is the version number of the BanyanDB query APIs
# OAP server has bundled implementation of BanyanDB Java client.
# Please check BanyanDB documentation for the API version compatibility.
# https://skywalking.apache.org/docs/skywalking-banyandb/next/installation/versions
# Each `bydb.api.version` could have multiple compatible release version(`bydb.version`).
bydb.api.version=0.8

View File

@ -21,9 +21,11 @@ package org.apache.skywalking.oap.server.storage.plugin.banyandb;
import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.banyandb.common.v1.BanyandbCommon;
import org.apache.skywalking.banyandb.common.v1.BanyandbCommon.Group;
@ -75,6 +77,22 @@ public class BanyanDBStorageClient implements Client, HealthCheckable {
@Override
public void connect() throws Exception {
this.client.connect();
final Properties properties = new Properties();
try (final InputStream resourceAsStream
= BanyanDBStorageClient.class.getClassLoader()
.getResourceAsStream(
"bydb.dependencies.properties")) {
if (resourceAsStream == null) {
throw new IllegalStateException("bydb.dependencies.properties not found");
}
properties.load(resourceAsStream);
}
final String expectedApiVersion = properties.getProperty("bydb.api.version");
if (!Arrays.stream(COMPATIBLE_SERVER_API_VERSIONS).anyMatch(v -> v.equals(expectedApiVersion))) {
throw new IllegalStateException("Inconsistent versions between bydb.dependencies.properties and codes(" +
String.join(", ", COMPATIBLE_SERVER_API_VERSIONS) + ").");
}
BanyandbCommon.APIVersion apiVersion;
try {
apiVersion = this.client.getAPIVersion();