Skip to content

Commit 32807c8

Browse files
authored
BanyanDB: Separate the storage configuration to an independent file: bydb.yaml. (#13097)
1 parent f7da99d commit 32807c8

File tree

21 files changed

+582
-323
lines changed

21 files changed

+582
-323
lines changed

Diff for: apm-dist/src/main/assembly/binary.xml

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
<include>trace-sampling-policy-settings.yml</include>
6262
<include>hierarchy-definition.yml</include>
6363
<include>bydb.dependencies.properties</include>
64+
<include>bydb.yml</include>
6465
<include>oal/*.oal</include>
6566
<include>fetcher-prom-rules/*.yaml</include>
6667
<include>envoy-metrics-rules/**</include>

Diff for: docs/en/changes/changes.md

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
* BanyanDB: fix alarm query result without sort.
8080
* Add a component ID for Virtual thread executor.
8181
* Add more model installation log info for OAP storage initialization.
82+
* BanyanDB: Separate the storage configuration to an independent file: `bydb.yaml`.
8283

8384
#### UI
8485

Diff for: docs/en/setup/backend/storages/banyandb.md

+80-66
Original file line numberDiff line numberDiff line change
@@ -22,76 +22,90 @@ org.apache.skywalking.oap.server.library.module.ModuleStartException: Incompatib
2222
```
2323

2424
### Configuration
25+
In the `application.yml` file, select the BanyanDB storage provider:
2526

2627
```yaml
2728
storage:
2829
banyandb:
29-
# Targets is the list of BanyanDB servers, separated by commas.
30-
# Each target is a BanyanDB server in the format of `host:port`.
31-
# If BanyanDB is deployed as a standalone server, the target should be the IP address or domain name and port of the BanyanDB server.
32-
# If BanyanDB is deployed in a cluster, the targets should be the IP address or domain name and port of the `liaison` nodes, separated by commas.
33-
targets: ${SW_STORAGE_BANYANDB_TARGETS:127.0.0.1:17912}
34-
# The maximum number of records in a bulk write request.
35-
# A larger value can improve write performance but also increases OAP and BanyanDB Server memory usage.
36-
maxBulkSize: ${SW_STORAGE_BANYANDB_MAX_BULK_SIZE:10000}
37-
# The minimum seconds between two bulk flushes.
38-
# If the data in a bulk is less than maxBulkSize, the data will be flushed after this period.
39-
# If the data in a bulk exceeds maxBulkSize, the data will be flushed immediately.
40-
# A larger value can reduce write pressure on BanyanDB Server but increase data latency.
41-
flushInterval: ${SW_STORAGE_BANYANDB_FLUSH_INTERVAL:15}
42-
# The timeout in seconds for a bulk flush.
43-
flushTimeout: ${SW_STORAGE_BANYANDB_FLUSH_TIMEOUT:10}
44-
# The number of threads that write data to BanyanDB concurrently.
45-
# A higher value can improve write performance but also increases CPU usage on both OAP and BanyanDB Server.
46-
concurrentWriteThreads: ${SW_STORAGE_BANYANDB_CONCURRENT_WRITE_THREADS:15}
47-
# The maximum size of the dataset when the OAP loads cache, such as network aliases.
48-
resultWindowMaxSize: ${SW_STORAGE_BANYANDB_QUERY_MAX_WINDOW_SIZE:10000}
49-
# The maximum size of metadata per query.
50-
metadataQueryMaxSize: ${SW_STORAGE_BANYANDB_QUERY_MAX_SIZE:10000}
51-
# The maximum number of trace segments per query.
52-
segmentQueryMaxSize: ${SW_STORAGE_BANYANDB_QUERY_SEGMENT_SIZE:200}
53-
# The maximum number of profile task queries in a request.
54-
profileTaskQueryMaxSize: ${SW_STORAGE_BANYANDB_QUERY_PROFILE_TASK_SIZE:200}
55-
# The batch size for querying profile data.
56-
profileDataQueryBatchSize: ${SW_STORAGE_BANYANDB_QUERY_PROFILE_DATA_BATCH_SIZE:100}
57-
# If the BanyanDB server is configured with TLS, configure the TLS cert file path and enable TLS connection.
58-
sslTrustCAPath: ${SW_STORAGE_BANYANDB_SSL_TRUST_CA_PATH:""}
59-
# The group settings of record.
60-
# `gr` is the short name of the group settings of record.
61-
#
62-
# The "normal" section defines settings for datasets not specified in "super".
63-
# Each dataset will be grouped under a single group named "normal".
64-
grNormalShardNum: ${SW_STORAGE_BANYANDB_GR_NORMAL_SHARD_NUM:1}
65-
grNormalSIDays: ${SW_STORAGE_BANYANDB_GR_NORMAL_SI_DAYS:1}
66-
grNormalTTLDays: ${SW_STORAGE_BANYANDB_GR_NORMAL_TTL_DAYS:3}
67-
# "super" is a special dataset designed to store trace or log data that is too large for normal datasets.
68-
# Each super dataset will be a separate group in BanyanDB, following the settings defined in the "super" section.
69-
grSuperShardNum: ${SW_STORAGE_BANYANDB_GR_SUPER_SHARD_NUM:2}
70-
grSuperSIDays: ${SW_STORAGE_BANYANDB_GR_SUPER_SI_DAYS:1}
71-
grSuperTTLDays: ${SW_STORAGE_BANYANDB_GR_SUPER_TTL_DAYS:3}
72-
# The group settings of metrics.
73-
# `gm` is the short name of the group settings of metrics.
74-
#
75-
# OAP stores metrics based its granularity.
76-
# Valid values are "day", "hour", and "minute". That means metrics will be stored in the three separate groups.
77-
# Non-"minute" are governed by the "core.downsampling" setting.
78-
# For example, if "core.downsampling" is set to "hour", the "hour" will be used, while "day" are ignored.
79-
gmMinuteShardNum: ${SW_STORAGE_BANYANDB_GM_MINUTE_SHARD_NUM:2}
80-
gmMinuteSIDays: ${SW_STORAGE_BANYANDB_GM_MINUTE_SI_DAYS:1}
81-
gmMinuteTTLDays: ${SW_STORAGE_BANYANDB_GM_MINUTE_TTL_DAYS:7}
82-
gmHourShardNum: ${SW_STORAGE_BANYANDB_GM_HOUR_SHARD_NUM:1}
83-
gmHourSIDays: ${SW_STORAGE_BANYANDB_GM_HOUR_SI_DAYS:5}
84-
gmHourTTLDays: ${SW_STORAGE_BANYANDB_GM_HOUR_TTL_DAYS:15}
85-
gmDayShardNum: ${SW_STORAGE_BANYANDB_GM_DAY_SHARD_NUM:1}
86-
gmDaySIDays: ${SW_STORAGE_BANYANDB_GM_DAY_SI_DAYS:15}
87-
gmDayTTLDays: ${SW_STORAGE_BANYANDB_GM_DAY_TTL_DAYS:15}
88-
# If the metrics is marked as "index_mode", the metrics will be stored in the "index" group.
89-
# The "index" group is designed to store metrics that are used for indexing without value columns.
90-
# Such as `service_traffic`, `network_address_alias`, etc.
91-
# "index_mode" requires BanyanDB *0.8.0* or later.
92-
gmIndexShardNum: ${SW_STORAGE_BANYANDB_GM_INDEX_SHARD_NUM:2}
93-
gmIndexSIDays: ${SW_STORAGE_BANYANDB_GM_INDEX_SI_DAYS:15}
94-
gmIndexTTLDays: ${SW_STORAGE_BANYANDB_GM_INDEX_TTL_DAYS:15}
30+
```
31+
32+
Since 10.2.0, the banyandb configuration is separated to an independent configuration file: `bydb.yaml`:
33+
34+
```yaml
35+
global:
36+
# Targets is the list of BanyanDB servers, separated by commas.
37+
# Each target is a BanyanDB server in the format of `host:port`.
38+
# If BanyanDB is deployed as a standalone server, the target should be the IP address or domain name and port of the BanyanDB server.
39+
# If BanyanDB is deployed in a cluster, the targets should be the IP address or domain name and port of the `liaison` nodes, separated by commas.
40+
targets: ${SW_STORAGE_BANYANDB_TARGETS:127.0.0.1:17912}
41+
# The maximum number of records in a bulk write request.
42+
# A larger value can improve write performance but also increases OAP and BanyanDB Server memory usage.
43+
maxBulkSize: ${SW_STORAGE_BANYANDB_MAX_BULK_SIZE:10000}
44+
# The minimum seconds between two bulk flushes.
45+
# If the data in a bulk is less than maxBulkSize, the data will be flushed after this period.
46+
# If the data in a bulk exceeds maxBulkSize, the data will be flushed immediately.
47+
# A larger value can reduce write pressure on BanyanDB Server but increase data latency.
48+
flushInterval: ${SW_STORAGE_BANYANDB_FLUSH_INTERVAL:15}
49+
# The timeout in seconds for a bulk flush.
50+
flushTimeout: ${SW_STORAGE_BANYANDB_FLUSH_TIMEOUT:10}
51+
# The number of threads that write data to BanyanDB concurrently.
52+
# A higher value can improve write performance but also increases CPU usage on both OAP and BanyanDB Server.
53+
concurrentWriteThreads: ${SW_STORAGE_BANYANDB_CONCURRENT_WRITE_THREADS:15}
54+
# The maximum size of the dataset when the OAP loads cache, such as network aliases.
55+
resultWindowMaxSize: ${SW_STORAGE_BANYANDB_QUERY_MAX_WINDOW_SIZE:10000}
56+
# The maximum size of metadata per query.
57+
metadataQueryMaxSize: ${SW_STORAGE_BANYANDB_QUERY_MAX_SIZE:10000}
58+
# The maximum number of trace segments per query.
59+
segmentQueryMaxSize: ${SW_STORAGE_BANYANDB_QUERY_SEGMENT_SIZE:200}
60+
# The maximum number of profile task queries in a request.
61+
profileTaskQueryMaxSize: ${SW_STORAGE_BANYANDB_QUERY_PROFILE_TASK_SIZE:200}
62+
# The batch size for querying profile data.
63+
profileDataQueryBatchSize: ${SW_STORAGE_BANYANDB_QUERY_PROFILE_DATA_BATCH_SIZE:100}
64+
asyncProfilerTaskQueryMaxSize: ${SW_STORAGE_BANYANDB_ASYNC_PROFILER_TASK_QUERY_MAX_SIZE:200}
65+
# If the BanyanDB server is configured with TLS, configure the TLS cert file path and enable TLS connection.
66+
sslTrustCAPath: ${SW_STORAGE_BANYANDB_SSL_TRUST_CA_PATH:""}
67+
68+
groups:
69+
# The group settings of record.
70+
#
71+
# The "normal" section defines settings for datasets not specified in "super".
72+
# Each dataset will be grouped under a single group named "normal".
73+
recordsNormal:
74+
shardNum: ${SW_STORAGE_BANYANDB_GR_NORMAL_SHARD_NUM:1}
75+
segmentInterval: ${SW_STORAGE_BANYANDB_GR_NORMAL_SI_DAYS:1}
76+
ttl: ${SW_STORAGE_BANYANDB_GR_NORMAL_TTL_DAYS:3}
77+
# "super" is a special dataset designed to store trace or log data that is too large for normal datasets.
78+
# Each super dataset will be a separate group in BanyanDB, following the settings defined in the "super" section.
79+
recordsSuper:
80+
shardNum: ${SW_STORAGE_BANYANDB_GR_SUPER_SHARD_NUM:2}
81+
segmentInterval: ${SW_STORAGE_BANYANDB_GR_SUPER_SI_DAYS:1}
82+
ttl: ${SW_STORAGE_BANYANDB_GR_SUPER_TTL_DAYS:3}
83+
# The group settings of metrics.
84+
#
85+
# OAP stores metrics based its granularity.
86+
# Valid values are "day", "hour", and "minute". That means metrics will be stored in the three separate groups.
87+
# Non-"minute" are governed by the "core.downsampling" setting.
88+
# For example, if "core.downsampling" is set to "hour", the "hour" will be used, while "day" are ignored.
89+
metricsMin:
90+
shardNum: ${SW_STORAGE_BANYANDB_GM_MINUTE_SHARD_NUM:2}
91+
segmentInterval: ${SW_STORAGE_BANYANDB_GM_MINUTE_SI_DAYS:1}
92+
ttl: ${SW_STORAGE_BANYANDB_GM_MINUTE_TTL_DAYS:7}
93+
metricsHour:
94+
shardNum: ${SW_STORAGE_BANYANDB_GM_HOUR_SHARD_NUM:1}
95+
segmentInterval: ${SW_STORAGE_BANYANDB_GM_HOUR_SI_DAYS:5}
96+
ttl: ${SW_STORAGE_BANYANDB_GM_HOUR_TTL_DAYS:15}
97+
metricsDay:
98+
shardNum: ${SW_STORAGE_BANYANDB_GM_DAY_SHARD_NUM:1}
99+
segmentInterval: ${SW_STORAGE_BANYANDB_GM_DAY_SI_DAYS:15}
100+
ttl: ${SW_STORAGE_BANYANDB_GM_DAY_TTL_DAYS:15}
101+
# If the metrics is marked as "index_mode", the metrics will be stored in the "index" group.
102+
# The "index" group is designed to store metrics that are used for indexing without value columns.
103+
# Such as `service_traffic`, `network_address_alias`, etc.
104+
# "index_mode" requires BanyanDB *0.8.0* or later.
105+
metadata:
106+
shardNum: ${SW_STORAGE_BANYANDB_GM_INDEX_SHARD_NUM:2}
107+
segmentInterval: ${SW_STORAGE_BANYANDB_GM_INDEX_SI_DAYS:15}
108+
ttl: ${SW_STORAGE_BANYANDB_GM_INDEX_TTL_DAYS:15}
95109

96110
```
97111

Diff for: oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleDefine.java

+2-37
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@
1818

1919
package org.apache.skywalking.oap.server.library.module;
2020

21-
import java.lang.reflect.Field;
2221
import java.lang.reflect.InvocationTargetException;
23-
import java.util.Enumeration;
24-
import java.util.Properties;
2522
import java.util.ServiceLoader;
2623
import org.slf4j.Logger;
2724
import org.slf4j.LoggerFactory;
2825

26+
import static org.apache.skywalking.oap.server.library.util.YamlConfigLoaderUtils.copyProperties;
27+
2928
/**
3029
* A module definition.
3130
*/
@@ -113,40 +112,6 @@ void prepare(ModuleManager moduleManager,
113112
loadedProvider.prepare();
114113
}
115114

116-
private void copyProperties(ModuleConfig dest, Properties src, String moduleName,
117-
String providerName) throws IllegalAccessException {
118-
if (dest == null) {
119-
return;
120-
}
121-
Enumeration<?> propertyNames = src.propertyNames();
122-
while (propertyNames.hasMoreElements()) {
123-
String propertyName = (String) propertyNames.nextElement();
124-
Class<? extends ModuleConfig> destClass = dest.getClass();
125-
try {
126-
Field field = getDeclaredField(destClass, propertyName);
127-
field.setAccessible(true);
128-
field.set(dest, src.get(propertyName));
129-
} catch (NoSuchFieldException e) {
130-
LOGGER.warn(
131-
propertyName + " setting is not supported in " + providerName + " provider of " + moduleName + " module");
132-
}
133-
}
134-
}
135-
136-
private Field getDeclaredField(Class<?> destClass, String fieldName) throws NoSuchFieldException {
137-
if (destClass != null) {
138-
Field[] fields = destClass.getDeclaredFields();
139-
for (Field field : fields) {
140-
if (field.getName().equals(fieldName)) {
141-
return field;
142-
}
143-
}
144-
return getDeclaredField(destClass.getSuperclass(), fieldName);
145-
}
146-
147-
throw new NoSuchFieldException();
148-
}
149-
150115
@Override
151116
public final ModuleProvider provider() throws DuplicateProviderException, ProviderNotFoundException {
152117
if (loadedProvider == null) {

Diff for: oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleProvider.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ <T extends Service> T getService(Class<T> serviceType) throws ServiceNotProvided
143143
throw new ServiceNotProvidedException("Service " + serviceType.getName() + " should not be provided, based on moduleDefine define.");
144144
}
145145

146-
ModuleDefine getModule() {
146+
public ModuleDefine getModule() {
147147
return moduleDefine;
148148
}
149149

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.oap.server.library.util;
20+
21+
import java.lang.reflect.Field;
22+
import java.util.ArrayList;
23+
import java.util.Enumeration;
24+
import java.util.Properties;
25+
import lombok.extern.slf4j.Slf4j;
26+
import org.yaml.snakeyaml.Yaml;
27+
28+
@Slf4j
29+
public class YamlConfigLoaderUtils {
30+
31+
public static void replacePropertyAndLog(final String propertyName,
32+
final Object propertyValue,
33+
final Properties target,
34+
final Object providerName,
35+
final Yaml yaml) {
36+
final String valueString = PropertyPlaceholderHelper.INSTANCE.replacePlaceholders(
37+
String.valueOf(propertyValue), target);
38+
if (valueString.trim().length() == 0) {
39+
target.replace(propertyName, valueString);
40+
log.info("Provider={} config={} has been set as an empty string", providerName, propertyName);
41+
} else {
42+
// Use YAML to do data type conversion.
43+
final Object replaceValue = convertValueString(valueString, yaml);
44+
if (replaceValue != null) {
45+
target.replace(propertyName, replaceValue);
46+
}
47+
}
48+
}
49+
50+
public static Object convertValueString(final String valueString, final Yaml yaml) {
51+
try {
52+
Object replaceValue = yaml.load(valueString);
53+
if (replaceValue instanceof String || replaceValue instanceof Integer || replaceValue instanceof Long || replaceValue instanceof Boolean || replaceValue instanceof ArrayList) {
54+
return replaceValue;
55+
} else {
56+
return valueString;
57+
}
58+
} catch (Exception e) {
59+
log.warn("yaml convert value type error, use origin values string. valueString={}", valueString, e);
60+
return valueString;
61+
}
62+
}
63+
64+
public static void copyProperties(final Object dest,
65+
final Properties src,
66+
final String moduleName,
67+
final String providerName) throws IllegalAccessException {
68+
if (dest == null) {
69+
return;
70+
}
71+
Enumeration<?> propertyNames = src.propertyNames();
72+
while (propertyNames.hasMoreElements()) {
73+
String propertyName = (String) propertyNames.nextElement();
74+
Class<?> destClass = dest.getClass();
75+
try {
76+
Field field = getDeclaredField(destClass, propertyName);
77+
field.setAccessible(true);
78+
field.set(dest, src.get(propertyName));
79+
} catch (NoSuchFieldException e) {
80+
log.warn(
81+
propertyName + " setting is not supported in " + providerName + " provider of " + moduleName + " module");
82+
}
83+
}
84+
}
85+
86+
public static Field getDeclaredField(final Class<?> destClass, final String fieldName) throws NoSuchFieldException {
87+
if (destClass != null) {
88+
Field[] fields = destClass.getDeclaredFields();
89+
for (Field field : fields) {
90+
if (field.getName().equals(fieldName)) {
91+
return field;
92+
}
93+
}
94+
return getDeclaredField(destClass.getSuperclass(), fieldName);
95+
}
96+
97+
throw new NoSuchFieldException();
98+
}
99+
}

Diff for: oap-server/server-starter/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@
316316
<exclude>trace-sampling-policy-settings.yml</exclude>
317317
<exclude>hierarchy-definition.yml</exclude>
318318
<exclude>bydb.dependencies.properties</exclude>
319+
<exclude>bydb.yml</exclude>
319320
<exclude>oal/</exclude>
320321
<exclude>fetcher-prom-rules/</exclude>
321322
<exclude>envoy-metrics-rules/</exclude>

0 commit comments

Comments
 (0)