Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit 893c934

Browse files
committed
新增监控指标展示功能
- 解决大数据量场景的卡顿问题。
1 parent 21d9ebe commit 893c934

5 files changed

Lines changed: 188 additions & 76 deletions

File tree

backend/src/main/java/org/apache/iotdb/admin/controller/IotDBController.java

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ public BaseVO<DataModelVO> getDataModel(
9898
@GetMapping("/dataModel/detail")
9999
@ApiOperation("Get IoTDB data model in detail")
100100
public BaseVO<DataModelVO> getDataModelDetail(
101-
@PathVariable("serverId") Integer serverId,
102-
@RequestParam(value = "path", required = false, defaultValue = "root") String path,
103-
@RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
104-
@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
105-
HttpServletRequest request)
106-
throws BaseException {
101+
@PathVariable("serverId") Integer serverId,
102+
@RequestParam(value = "path", required = false, defaultValue = "root") String path,
103+
@RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
104+
@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
105+
HttpServletRequest request)
106+
throws BaseException {
107107
check(request, serverId);
108108
Connection connection = connectionService.getById(serverId);
109109
DataModelVO dataModelVO = iotDBService.getDataModelDetail(connection, path, pageSize, pageNum);
@@ -113,11 +113,11 @@ public BaseVO<DataModelVO> getDataModelDetail(
113113
@GetMapping("/storageGroups/info")
114114
@ApiOperation("Get information of the storage group list")
115115
public BaseVO<GroupInfoVO> getAllStorageGroupsInfo(
116-
@PathVariable("serverId") Integer serverId,
117-
@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
118-
@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
119-
HttpServletRequest request)
120-
throws BaseException {
116+
@PathVariable("serverId") Integer serverId,
117+
@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
118+
@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
119+
HttpServletRequest request)
120+
throws BaseException {
121121
check(request, serverId);
122122
Connection connection = connectionService.getById(serverId);
123123
List<String> groupNames = iotDBService.getAllStorageGroups(connection);
@@ -162,8 +162,6 @@ public BaseVO<List<StorageGroupVO>> getAllStorageGroups(
162162
String host = connection.getHost();
163163
for (String groupName : groupNames) {
164164
StorageGroupVO storageGroupVO = new StorageGroupVO();
165-
Integer id = groupService.getGroupId(host, groupName);
166-
storageGroupVO.setGroupId(id);
167165
storageGroupVO.setGroupName(groupName);
168166
storageGroupVOList.add(storageGroupVO);
169167
}
@@ -193,9 +191,9 @@ public BaseVO saveStorageGroup(
193191
Connection connection = connectionService.getById(serverId);
194192
Long ttl = groupDTO.getTtl();
195193
String ttlUnit = groupDTO.getTtlUnit();
196-
checkTtl(ttl, ttlUnit);
197194
Integer groupId = groupDTO.getGroupId();
198195
groupDTO.setGroupName(groupName);
196+
199197
List<String> groupNames = iotDBService.getAllStorageGroups(connection);
200198
if (groupId == null) {
201199
if (!groupNames.contains(groupDTO.getGroupName())) {
@@ -206,6 +204,7 @@ public BaseVO saveStorageGroup(
206204
groupService.updateStorageGroupInfo(connection, groupDTO);
207205
}
208206
if (ttl != null && ttlUnit != null) {
207+
checkTtl(ttl, ttlUnit);
209208
if (ttl >= 0) {
210209
Long times = switchTime(ttlUnit);
211210
iotDBService.saveGroupTtl(connection, groupName, ttl * times);
@@ -354,12 +353,19 @@ public BaseVO<List<NodeTreeVO>> getDevicesNodeTreeByGroup(
354353
public BaseVO<NodeTreeVO> getDevicesTreeByGroup(
355354
@PathVariable("serverId") Integer serverId,
356355
@PathVariable("groupName") String groupName,
356+
@RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
357+
@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
357358
HttpServletRequest request)
358359
throws BaseException {
359360
checkParameter(groupName);
360361
check(request, serverId);
361362
Connection connection = connectionService.getById(serverId);
362-
NodeTreeVO deviceList = iotDBService.getDeviceList(connection, groupName);
363+
NodeTreeVO deviceList = iotDBService.getDeviceList(connection, groupName, pageSize, pageNum);
364+
if (deviceList == null) {
365+
deviceList = new NodeTreeVO(groupName);
366+
}
367+
deviceList.setPageNum(pageNum);
368+
deviceList.setPageSize(pageSize);
363369
return BaseVO.success("Get successfully", deviceList);
364370
}
365371

@@ -461,8 +467,8 @@ public BaseVO<MeasuremtnInfoVO> getMeasurementsByDeviceName(
461467
@PathVariable("serverId") Integer serverId,
462468
@PathVariable("groupName") String groupName,
463469
@PathVariable("deviceName") String deviceName,
464-
@RequestParam("pageSize") Integer pageSize,
465-
@RequestParam("pageNum") Integer pageNum,
470+
@RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
471+
@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
466472
@RequestParam(value = "keyword", required = false) String keyword,
467473
HttpServletRequest request)
468474
throws BaseException {
@@ -475,17 +481,26 @@ public BaseVO<MeasuremtnInfoVO> getMeasurementsByDeviceName(
475481
List<MeasurementVO> measurementVOList = new ArrayList<>();
476482
String host = connection.getHost();
477483
if (measurementDTOList != null) {
484+
List<String> timeseriesList = new ArrayList<>();
485+
for (MeasurementDTO measurementDTO : measurementDTOList) {
486+
timeseriesList.add(measurementDTO.getTimeseries());
487+
}
488+
List<String> batchNewValue =
489+
iotDBService.getBatchLastMeasurementValue(connection, timeseriesList);
490+
List<String> batchDataCount =
491+
iotDBService.getBatchDataCount(connection, deviceName, timeseriesList);
492+
int index = 0;
478493
for (MeasurementDTO measurementDTO : measurementDTOList) {
479494
MeasurementVO measurementVO = new MeasurementVO();
480495
BeanUtils.copyProperties(measurementDTO, measurementVO);
481496
String description =
482497
measurementService.getDescription(host, measurementDTO.getTimeseries());
483-
String newValue =
484-
iotDBService.getLastMeasurementValue(connection, measurementDTO.getTimeseries());
485-
Integer dataCount =
486-
iotDBService.getOneDataCount(connection, deviceName, measurementDTO.getTimeseries());
487-
measurementVO.setDataCount(dataCount);
488-
measurementVO.setNewValue(newValue);
498+
if (batchNewValue.size() != 0) {
499+
measurementVO.setNewValue(batchNewValue.get(index));
500+
}
501+
if (batchDataCount.size() != 0) {
502+
measurementVO.setDataCount(Integer.parseInt(batchDataCount.get(index)));
503+
}
489504
measurementVO.setDescription(description);
490505
ObjectMapper mapper = new ObjectMapper();
491506
List<List<String>> tags = new ArrayList<>();
@@ -519,6 +534,7 @@ public BaseVO<MeasuremtnInfoVO> getMeasurementsByDeviceName(
519534
throw new BaseException(ErrorCode.GET_MSM_FAIL, ErrorCode.GET_MSM_FAIL_MSG);
520535
}
521536
measurementVOList.add(measurementVO);
537+
index++;
522538
}
523539
}
524540
MeasuremtnInfoVO measuremtnInfoVO = new MeasuremtnInfoVO();

backend/src/main/java/org/apache/iotdb/admin/model/dto/DataModelDetailDTO.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.apache.iotdb.admin.model.dto;
22

3-
import lombok.Data;
43
import org.apache.iotdb.admin.model.vo.DataModelVO;
54

5+
import lombok.Data;
6+
67
import java.io.Serializable;
78
import java.util.List;
89

backend/src/main/java/org/apache/iotdb/admin/model/vo/NodeTreeVO.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,19 @@ public class NodeTreeVO implements Serializable {
3131

3232
private List<NodeTreeVO> children;
3333

34+
private Integer pageSize;
35+
36+
private Integer pageNum;
37+
38+
private Integer total;
39+
// private List<String> childrenName;
40+
3441
public NodeTreeVO(String name) {
3542
this.name = name;
3643
}
3744

45+
public NodeTreeVO() {}
46+
3847
public List<NodeTreeVO> initChildren() {
3948
if (children == null) {
4049
children = new ArrayList<>();

backend/src/main/java/org/apache/iotdb/admin/service/IotDBService.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ CountDTO getMeasurementsByDevice(
6262

6363
void setIotDBRole(Connection connection, IotDBRole iotDBRole) throws BaseException;
6464

65-
DataModelVO getDataModelDetail(
66-
Connection connection, String path, Integer pageSize, Integer pageNum) throws BaseException;
67-
6865
UserRolesVO getRolesOfUser(Connection connection, String userName) throws BaseException;
6966

7067
void userGrant(Connection connection, String userName, UserGrantDTO userGrantDTO)
@@ -122,7 +119,9 @@ Integer getOneDataCount(Connection connection, String deviceName, String measure
122119

123120
List<NodeTreeVO> getDeviceNodeTree(Connection connection, String groupName) throws BaseException;
124121

125-
NodeTreeVO getDeviceList(Connection connection, String groupName) throws BaseException;
122+
NodeTreeVO getDeviceList(
123+
Connection connection, String groupName, Integer pageSize, Integer pageNum)
124+
throws BaseException;
126125

127126
List<String> getDeviceParents(Connection connection, String groupName, String deviceName)
128127
throws BaseException;
@@ -155,6 +154,8 @@ void upsertDataPrivileges(
155154
Connection connection, String userOrRole, String name, PrivilegeInfoDTO privilegeInfoDTO)
156155
throws BaseException;
157156

157+
public List<QueryMetricsVO> getSlowQueryMetricsData();
158+
158159
RecordVO getRecords(
159160
Connection connection, String deviceName, String timeseriesName, String dataType)
160161
throws BaseException;
@@ -164,9 +165,7 @@ List<SqlResultVO> queryAll(Connection connection, List<String> sqls, Long timest
164165

165166
void updatePwd(Connection connection, IotDBUser iotDBUser) throws BaseException;
166167

167-
void stopQuery(Integer serverId, Long timestamp) throws BaseException;
168-
169-
QueryInfoDTO getQueryInfoListByQueryClassificationId(
168+
public QueryInfoDTO getQueryInfoListByQueryClassificationId(
170169
Connection connection,
171170
Integer queryClassificationId,
172171
Integer pageSize,
@@ -177,10 +176,19 @@ QueryInfoDTO getQueryInfoListByQueryClassificationId(
177176
Integer executionResult)
178177
throws BaseException;
179178

180-
MetricsDataForDiagramVO getMetricDataByMetricId(Connection connection, Integer metricId)
179+
public List<QueryMetricsVO> getTopQueryMetricsData();
180+
181+
public MetricsDataForDiagramVO getMetricDataByMetricId(Connection connection, Integer metricId)
181182
throws BaseException;
182183

183-
List<QueryMetricsVO> getTopQueryMetricsData();
184+
void stopQuery(Integer serverId, Long timestamp) throws BaseException;
185+
186+
DataModelVO getDataModelDetail(
187+
Connection connection, String path, Integer pageSize, Integer pageNum) throws BaseException;
188+
189+
List<String> getBatchLastMeasurementValue(Connection connection, List<String> timeseriesList)
190+
throws BaseException;
184191

185-
List<QueryMetricsVO> getSlowQueryMetricsData();
192+
List<String> getBatchDataCount(
193+
Connection connection, String deviceName, List<String> timeseriesList) throws BaseException;
186194
}

0 commit comments

Comments
 (0)