Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bugfix/specify_collector' into b…
Browse files Browse the repository at this point in the history
…ugfix/specify_collector
  • Loading branch information
Calvin979 committed Jul 19, 2024
2 parents cf36a43 + 347f021 commit 593bcfd
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@Component
public class WareHouseApplicationReadyListener {

private Optional<AbstractHistoryDataStorage> historyDataStorage;
private final Optional<AbstractHistoryDataStorage> historyDataStorage;

public WareHouseApplicationReadyListener(Optional<AbstractHistoryDataStorage> historyDataStorage) {
this.historyDataStorage = historyDataStorage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ protected void startPersistentDataStorage() {
if (metricsData == null) {
continue;
}
if (historyDataWriter.isPresent()) {
historyDataWriter.get().saveData(metricsData);
}

historyDataWriter.ifPresent(dataWriter -> dataWriter.saveData(metricsData));
} catch (Exception e) {
log.error(e.getMessage(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class IotDbDataStorage extends AbstractHistoryDataStorage {
private static final String NEVER_EXPIRE = "-1";

/**
* storage group (存储组)
* storage group
*/
private static final String STORAGE_GROUP = "root.hertzbeat";

Expand Down Expand Up @@ -379,9 +379,9 @@ private void handleHistoryIntervalSelect(String selectSql, String instance,
}

/**
* 获取deviceId下的所有设备
* Query all devices by deviceId
*
* @param deviceId 设备/实体
* @param deviceId deviceId
*/
private List<String> queryAllDevices(String deviceId) {
String showDevicesSql = String.format(SHOW_DEVICES, deviceId + ".*");
Expand All @@ -406,10 +406,10 @@ private List<String> queryAllDevices(String deviceId) {
}

/**
* gets the device ID
* 有instanceId的使用 ${group}.${app}.${metrics}.${monitor}.${labels} 的方式
* 否则使用 ${group}.${app}.${metrics}.${monitor} 的方式
* 查询时可以通过 ${group}.${app}.${metrics}.${monitor}.* 的方式获取所有instance数据
* use ${group}.${app}.${metrics}.${monitor}.${labels} to get device id if there is a way to get instanceId
* otherwise use ${group}.${app}.${metrics}.${monitor}
*
* Use ${group}.${app}.${metrics}.${monitor}.* to get all instance data when you tend to query
*/
private String getDeviceId(String app, String metrics, Long monitorId, String labels, boolean useQuote) {
String deviceId = STORAGE_GROUP + "."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ public TdEngineDataStorage(TdEngineProperties tdEngineProperties) {
}

/**
* {@code TdEngine} 初始化数据库
* {@code TdEngine} init TdEngineDatabase
*
* @param tdEngineProperties {@link TdEngineProperties} 对象实例
* @param tdEngineProperties {@link TdEngineProperties}
*/
private void initTdEngineDatabase(final TdEngineProperties tdEngineProperties) throws SQLException {
final Properties parseResultProperties = com.taosdata.jdbc.utils.StringUtils.parseUrl(tdEngineProperties.url(), null);
Expand Down Expand Up @@ -376,7 +376,7 @@ public Map<String, List<Value>> getHistoryIntervalMetricData(Long monitorId, Str
instances.add(label);
}
if (instances.isEmpty()) {
// 若未指定instance,需查询当前指标数据前1周有多少个instance
// need to confirm that how many instances of current metrics one week ago
String queryInstanceSql = String.format(QUERY_INSTANCE_SQL, table);
Connection connection = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,12 @@ private boolean initRedisClient(RedisProperties redisProperties) {
log.error("init error, please config Warehouse redis props in application.yml");
return false;
}
RedisProperties redisProp = redisProperties;
RedisURI.Builder uriBuilder = RedisURI.builder()
.withHost(redisProp.host())
.withPort(redisProp.port())
.withHost(redisProperties.host())
.withPort(redisProperties.port())
.withTimeout(Duration.of(10, ChronoUnit.SECONDS));
if (redisProp.password() != null && !"".equals(redisProp.password())) {
uriBuilder.withPassword(redisProp.password().toCharArray());
if (redisProperties.password() != null && !"".equals(redisProperties.password())) {
uriBuilder.withPassword(redisProperties.password().toCharArray());
}
try {
redisClient = RedisClient.create(uriBuilder.build());
Expand Down

0 comments on commit 593bcfd

Please sign in to comment.