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

Commit ff960d2

Browse files
committed
新增监控指标展示功能
- 该版本适配低于0.13版本的iotdb并提供数据库管理功能,但不提供监控管理(低于0.13版本iotdb不支持监控); - 仍然存在部分接口返回后端假数据,等待清华提供接口后替换为真实数据。
1 parent 161c24e commit ff960d2

9 files changed

Lines changed: 1846 additions & 55 deletions

File tree

backend/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
<dependency>
146146
<groupId>org.apache.iotdb</groupId>
147147
<artifactId>iotdb-session</artifactId>
148-
<version>0.12.1</version>
148+
<version>0.12.5</version>
149149
<exclusions>
150150
<exclusion>
151151
<artifactId>logback-classic</artifactId>
@@ -157,7 +157,7 @@
157157
<dependency>
158158
<groupId>org.apache.iotdb</groupId>
159159
<artifactId>iotdb-jdbc</artifactId>
160-
<version>0.12.1</version>
160+
<version>0.12.5</version>
161161
<exclusions>
162162
<exclusion>
163163
<artifactId>logback-classic</artifactId>

backend/src/main/java/org/apache/iotdb/admin/common/exception/ErrorCode.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ public class ErrorCode {
158158
public static final String SET_GROUP_FAIL = "IOTDB-0022";
159159
public static final String SET_GROUP_FAIL_MSG = "Failed to create storage group";
160160

161+
public static final String SET_GROUP_FAIL_EXISTS = "IOTDB-0095";
162+
public static final String SET_GROUP_FAIL__EXISTS_MSG =
163+
"Failed to create storage group, the storage group already exists";
164+
161165
public static final String DELETE_GROUP_FAIL = "IOTDB-0023";
162166
public static final String DELETE_GROUP_FAIL_MSG = "Failed to delete storage group";
163167

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ public ResponseEntity<Resource> downloadTemplateFile() throws BaseException {
115115
return getResponseEntity(resource);
116116
}
117117

118+
@ApiOperation("Download the query log file")
119+
@GetMapping("/downloadQueryLogFile")
120+
public ResponseEntity<Resource> downloadQueryLogFile(
121+
@RequestParam String SQLStatement, @RequestParam Long timeStamp) throws BaseException {
122+
Resource resource = new ClassPathResource("file/[Fake]QueryLog.txt");
123+
if (!resource.exists()) {
124+
throw new BaseException(ErrorCode.FILE_NOT_FOUND, ErrorCode.FILE_NOT_FOUND_MSG);
125+
}
126+
return getResponseEntity(resource);
127+
}
128+
118129
private ResponseEntity<Resource> getResponseEntity(Resource resource) {
119130
String contentType = "application/octet-stream";
120131

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ public BaseVO<DataCountVO> getDataCount(
8585
@GetMapping("/dataModel")
8686
@ApiOperation("Get IoTDB data model")
8787
public BaseVO<DataModelVO> getDataModel(
88-
@PathVariable("serverId") Integer serverId, HttpServletRequest request) throws BaseException {
88+
@PathVariable("serverId") Integer serverId,
89+
@RequestParam(value = "path", required = false, defaultValue = "root") String path,
90+
HttpServletRequest request)
91+
throws BaseException {
8992
check(request, serverId);
9093
Connection connection = connectionService.getById(serverId);
91-
DataModelVO dataModelVO = iotDBService.getDataModel(connection);
94+
DataModelVO dataModelVO = iotDBService.getDataModel(connection, path);
9295
return BaseVO.success("Get IoTDB data model successfully", dataModelVO);
9396
}
9497

@@ -164,7 +167,6 @@ public BaseVO saveStorageGroup(
164167
checkTtl(ttl, ttlUnit);
165168
Integer groupId = groupDTO.getGroupId();
166169
groupDTO.setGroupName(groupName);
167-
168170
List<String> groupNames = iotDBService.getAllStorageGroups(connection);
169171
if (groupId == null) {
170172
if (!groupNames.contains(groupDTO.getGroupName())) {
@@ -1121,9 +1123,7 @@ private void check(HttpServletRequest request, Integer serverId) throws BaseExce
11211123

11221124
private void checkParameter(String groupName) throws BaseException {
11231125
String checkName = StringUtils.removeStart(groupName, "root").toLowerCase();
1124-
if (!groupName.matches("^root\\.[^ ]+$")
1125-
|| checkName.contains(".root.")
1126-
|| checkName.matches("^[^ ]*\\.root$")) {
1126+
if (groupName.contains(".root.") || groupName.contains(".root")) {
11271127
throw new BaseException(ErrorCode.NO_SUP_CONTAIN_ROOT, ErrorCode.NO_SUP_CONTAIN_ROOT_MSG);
11281128
}
11291129
if (checkName.contains(".as.")
@@ -1229,6 +1229,9 @@ private String getTTL(Long time) {
12291229
}
12301230

12311231
private void checkTtl(Long ttl, String unit) throws BaseException {
1232+
if (ttl == null || unit == null) {
1233+
return;
1234+
}
12321235
if (Long.MAX_VALUE / switchTime(unit) < ttl) {
12331236
throw new BaseException(ErrorCode.TTL_OVER, ErrorCode.TTL_OVER_MSG);
12341237
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
@Data
2828
public class AuthorityPrivilegeDTO implements Serializable {
29+
2930
private List<String> privileges;
3031

3132
private List<String> cancelPrivileges;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525

2626
@Data
2727
public class DataCountVO implements Serializable {
28-
private Integer groupCount;
28+
private Integer storageGroupCount;
2929
private Integer deviceCount;
30-
private Integer measurementCount;
30+
private Integer monitorCount;
3131
private Integer dataCount;
32+
private String version;
3233
}

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
public interface IotDBService {
3131
DataCountVO getDataCount(Connection connection) throws BaseException;
3232

33-
DataModelVO getDataModel(Connection connection) throws BaseException;
33+
DataModelVO getDataModel(Connection connection, String path) throws BaseException;
3434

3535
List<String> getAllStorageGroups(Connection connection) throws BaseException;
3636

@@ -162,4 +162,22 @@ List<SqlResultVO> queryAll(Connection connection, List<String> sqls, Long timest
162162
void updatePwd(Connection connection, IotDBUser iotDBUser) throws BaseException;
163163

164164
void stopQuery(Integer serverId, Long timestamp) throws BaseException;
165+
166+
QueryInfoDTO getQueryInfoListByQueryClassificationId(
167+
Connection connection,
168+
Integer queryClassificationId,
169+
Integer pageSize,
170+
Integer pageNum,
171+
String filterString,
172+
Long startTime,
173+
Long endTime,
174+
Integer executionResult)
175+
throws BaseException;
176+
177+
MetricsDataForDiagramVO getMetricDataByMetricId(Connection connection, Integer metricId)
178+
throws BaseException;
179+
180+
List<QueryMetricsVO> getTopQueryMetricsData();
181+
182+
List<QueryMetricsVO> getSlowQueryMetricsData();
165183
}

0 commit comments

Comments
 (0)