Make bydb depdendencies file checked and consistent. (#12961)
This commit is contained in:
parent
ca5c8b29e1
commit
d447c4534f
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
```
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue