Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve] deprecate support iotdb 0.* version #2032

Merged
merged 1 commit into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions home/docs/start/iotdb-init.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Apache HertzBeat (incubating)'s historical data storage relies on the time serie

> It is recommended to use VictoriaMetrics as metrics storage.

Apache IoTDB is a software system that integrates the collection, storage, management and analysis of time series data of the Internet of Things. We use it to store and analyze the historical data of monitoring metrics collected. Support V0.13+ version and V1.0.+ version.
Apache IoTDB is a software system that integrates the collection, storage, management and analysis of time series data of the Internet of Things. We use it to store and analyze the historical data of monitoring metrics collected. Support V1.0.+ version.

**Note⚠️ Time series database is optional, but production environment configuration is strongly recommended to provide more complete historical chart functions and high performance**

Expand Down Expand Up @@ -58,8 +58,6 @@ warehouse:
rpc-port: 6667
username: root
password: root
# config.org.apache.hertzbeat.warehouse.IotDbVersion: V_0_13 || V_1_0
version: V_1_0
query-timeout-in-ms: -1
# default '7776000000'(90days,unit:ms,-1:no-expire)
expire-time: '7776000000'
Expand All @@ -81,8 +79,6 @@ warehouse:
node-urls: ['127.0.0.1:6667','127.0.0.2:6667','127.0.0.3:6667']
username: root
password: root
# V_0_13 || V_1_0
version: V_1_0
# if iotdb version >= 0.13 use default queryTimeoutInMs = -1; else use default queryTimeoutInMs = 0
query-timeout-in-ms: -1
# Data storage time: default '7776000000' (90 days, in milliseconds, -1 means never expire)
Expand All @@ -93,14 +89,14 @@ Configuration parameters:


| Parameter Name | Description |
| ------------------- | ----------------------------------------------------------------------------------------- |
| ------------------- |-------------------------------------------------------------------------------------------|
| enabled | Whether to enable |
| host | IoTDB database address |
| rpc-port | IoTDB database port |
| node-urls | IoTDB cluster addresses |
| username | IoTDB database account |
| password | IoTDB database password |
| version | IoTDB database version, V_0_13 or V_1_0 |
| version | deprecated |
| query-timeout-in-ms | Query timeout |
| expire-time | Data storage time, default '7776000000' (90 days, in milliseconds, -1 means never expire) |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Apache HertzBeat (incubating) 的历史数据存储依赖时序数据库,任

> 我们推荐使用并长期支持 VictoriaMetrics 作为存储。

Apache IoTDB是一体化收集、存储、管理与分析物联网时序数据的软件系统,我们使用其存储分析采集到的监控指标历史数据。支持V0.12 - V0.13版本,推荐使用V0.13.*版本
Apache IoTDB是一体化收集、存储、管理与分析物联网时序数据的软件系统,我们使用其存储分析采集到的监控指标历史数据。支持V1.*版本,废弃V0.*版本的支持

**注意⚠️ 时序数据库安装配置为可选项,但强烈建议生产环境配置,以提供更完善的历史图表功能,高性能和稳定性**

Expand Down Expand Up @@ -60,9 +60,7 @@ warehouse:
rpc-port: 6667
username: root
password: root
# V_0_13 || V_1_0
version: V_1_0
# if iotdb version >= 0.13 use default queryTimeoutInMs = -1; else use default queryTimeoutInMs = 0
# use default queryTimeoutInMs = -1
query-timeout-in-ms: -1
# 数据存储时间:默认'7776000000'(90天,单位为毫秒,-1代表永不过期)
expire-time: '7776000000'
Expand All @@ -83,8 +81,6 @@ warehouse:
node-urls: ['127.0.0.1:6667','127.0.0.2:6667','127.0.0.3:6667'']
username: root
password: root
# V_0_13 || V_1_0
version: V_1_0
# if iotdb version >= 0.13 use default queryTimeoutInMs = -1; else use default queryTimeoutInMs = 0
query-timeout-in-ms: -1
# 数据存储时间:默认'7776000000'(90天,单位为毫秒,-1代表永不过期)
Expand All @@ -94,16 +90,16 @@ warehouse:
参数说明:


| 参数名称 | 参数说明 |
| ------------------- | ---------------------------------------------------------------- |
| enabled | 是否启用 |
| host | IoTDB数据库地址 |
| rpc-port | IoTDB数据库端口 |
| node-urls | IoTDB集群地址 |
| username | IoTDB数据库账户 |
| password | IoTDB数据库密码 |
| version | IoTDB数据库版本,V_0_13 、 V_1_0 |
| query-timeout-in-ms | 查询超时时间 |
| 参数名称 | 参数说明 |
| ------------------- |-------------------------------------------|
| enabled | 是否启用 |
| host | IoTDB数据库地址 |
| rpc-port | IoTDB数据库端口 |
| node-urls | IoTDB集群地址 |
| username | IoTDB数据库账户 |
| password | IoTDB数据库密码 |
| version | IoTDB数据库版本,已废弃,仅支持V1.* |
| query-timeout-in-ms | 查询超时时间 |
| expire-time | 数据存储时间,默认'7776000000'(90天,单位为毫秒,-1代表永不过期) |

> 如果集群配置`node-urls`和单机配置同时设置,以集群`node-urls`配置稳准
Expand Down
2 changes: 0 additions & 2 deletions manager/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ warehouse:
rpc-port: 6667
username: root
password: root
# config.org.apache.hertzbeat.warehouse.IotDbVersion: V_0_13 || V_1_0
version: V_1_0
query-timeout-in-ms: -1
# data expire time, unit:ms, default '7776000000'(90 days, -1:never expire)
expire-time: '7776000000'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ public class IotDbDataStorage extends AbstractHistoryDataStorage {

private static final String SHOW_DATABASE = "show databases %s";

/**
* create database (version 1.0.*)
*/
private static final String CREATE_DATABASE = "create database %s";

private static final String SET_TTL = "set ttl to %s %s";
Expand All @@ -81,8 +78,6 @@ public class IotDbDataStorage extends AbstractHistoryDataStorage {

private SessionPool sessionPool;

private IotDbVersion version;

private long queryTimeoutInMs;

public IotDbDataStorage(IotDbProperties iotDbProperties) {
Expand All @@ -107,25 +102,26 @@ private boolean initIotDbSession(IotDbProperties properties) {
if (properties.zoneId() != null) {
builder.zoneId(properties.zoneId());
}
if (properties.version() != null) {
this.version = properties.version();
}
this.queryTimeoutInMs = properties.queryTimeoutInMs();
this.sessionPool = builder.build();
boolean available = checkConnection();
if (available) {
available = this.createDatabase();
if (available) {
this.initTtl(properties.expireTime());
log.info("IotDB session pool init success");
}
if (!available) {
log.error("IotDB session pool init error with check connection");
return available;
}
available = this.createDatabase();
if (!available) {
log.error("IotDB session pool init error with create database");
return available;
}
this.initTtl(properties.expireTime());
log.info("IotDB session pool init success");
return available;
}

private boolean checkConnection() {
try {
this.sessionPool.executeQueryStatement(SHOW_STORAGE_GROUP);
this.sessionPool.executeNonQueryStatement(SHOW_STORAGE_GROUP);
return true;
} catch (Exception e) {
log.error(e.getMessage(), e);
Expand All @@ -136,15 +132,12 @@ private boolean checkConnection() {
private boolean createDatabase() {
SessionDataSetWrapper dataSet = null;
try {
// v1.0.* create database
if (IotDbVersion.V_1_0.equals(this.version)) {
String showDatabaseSql = String.format(SHOW_DATABASE, STORAGE_GROUP);
dataSet = this.sessionPool.executeQueryStatement(showDatabaseSql);
// root.hertzbeat database not exist
if (!dataSet.hasNext()) {
String createDatabaseSql = String.format(CREATE_DATABASE, STORAGE_GROUP);
this.sessionPool.executeNonQueryStatement(createDatabaseSql);
}
// if root.hertzbeat database not exist, create database
String showDatabaseSql = String.format(SHOW_DATABASE, STORAGE_GROUP);
dataSet = this.sessionPool.executeQueryStatement(showDatabaseSql);
if (!dataSet.hasNext()) {
String createDatabaseSql = String.format(CREATE_DATABASE, STORAGE_GROUP);
this.sessionPool.executeNonQueryStatement(createDatabaseSql);
}
} catch (IoTDBConnectionException | StatementExecutionException e) {
log.error("create database error, error: {}", e.getMessage());
Expand Down Expand Up @@ -188,7 +181,6 @@ public void saveData(CollectRep.MetricsData metricsData) {
List<MeasurementSchema> schemaList = new ArrayList<>();

// todo Measurement schema is a data structure that is generated on the client side, and encoding and compression have no effect
// todo Do you want to use the specified data structure, or do you want to create a timeSeries or template manually
List<CollectRep.Field> fieldsList = metricsData.getFieldsList();
for (CollectRep.Field field : fieldsList) {
MeasurementSchema schema = new MeasurementSchema();
Expand All @@ -198,6 +190,8 @@ public void saveData(CollectRep.MetricsData metricsData) {
schema.setType(TSDataType.DOUBLE);
} else if (field.getType() == CommonConstants.TYPE_STRING) {
schema.setType(TSDataType.TEXT);
} else {
continue;
}
schemaList.add(schema);
}
Expand Down Expand Up @@ -421,7 +415,7 @@ private String getDeviceId(String app, String metrics, Long monitorId, String la
String deviceId = STORAGE_GROUP + "."
+ (useQuote ? addQuote(app) : app) + "."
+ (useQuote ? addQuote(metrics) : metrics) + "."
+ ((IotDbVersion.V_1_0.equals(version) || useQuote) ? addQuote(monitorId.toString()) : monitorId.toString());
+ addQuote(monitorId.toString());
if (labels != null && !labels.isEmpty() && !labels.equals(CommonConstants.NULL_VALUE)) {
deviceId += "." + addQuote(labels);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public record IotDbProperties(@DefaultValue("false") boolean enabled,
String password,
List<String> nodeUrls,
ZoneId zoneId,
IotDbVersion version,
long queryTimeoutInMs,
String expireTime) {
}

This file was deleted.

Loading