Skip to content

Commit a2d4b13

Browse files
committed
job detail page fix bug
1. 优化jobdetail页面Key Prefix Info和TTL请求分别发2次问题 2. 优化jobdetail页面发送无用的获取数据请求 3. 优化jobdetail页面key过长时表格分页无法显示问题 4. 优化jobdetail页面非cluster分析结果时还发送折线图请求数据的问题 5. 修复jobdetail页面出现与非cluster分析结果对比的问题 6. 优化jobdetail页面折线图显示效果 7. jobdetail页面增加折线图可以选择前缀的功能
1 parent de2b769 commit a2d4b13

File tree

11 files changed

+263
-240
lines changed

11 files changed

+263
-240
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ selenium-debug.log
2626
*.njsproj
2727
*.sln
2828
redis-manger-ui/redis-manager-vue/package-lock.json
29+
redis-manager-dashboard/logs/
30+
redis-manager-dashboard/logs/

redis-manager-dashboard/src/main/java/com/newegg/ec/redis/controller/RDBAnalyzeController.java

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.newegg.ec.redis.controller;
22

3-
import com.alibaba.fastjson.JSONArray;
43
import com.alibaba.fastjson.JSONObject;
54

65
import com.newegg.ec.redis.entity.*;
@@ -257,34 +256,24 @@ public Result getAllScheduleId(@RequestParam Long analyzeResultId) {
257256
}
258257
}
259258

260-
// /**
261-
// * get all key_prefix
262-
// *
263-
// * @param clusterId
264-
// * @param scheduleId
265-
// * @return
266-
// */
267-
// @GetMapping("/all/key_prefix")
268-
// public Result getAllKeyPrefix(@RequestParam Long clusterId, @RequestParam(value = "scheduleId", required = false) Long scheduleId) {
269-
// try {
270-
// if (null == clusterId) {
271-
// return Result.failResult("clusterId should not null!");
272-
// }
273-
// RDBAnalyzeResult rdbAnalyzeResult;
274-
// if(null != scheduleId){
275-
// rdbAnalyzeResult = rdbAnalyzeResultService.selectResultByRIDandSID(clusterId, scheduleId);
276-
// } else {
277-
// rdbAnalyzeResult = rdbAnalyzeResultService.selectLatestResultByRID(clusterId);
278-
// }
279-
// if(null == rdbAnalyzeResult) {
280-
// return Result.successResult(null);
281-
// }
282-
// return Result.successResult(rdbAnalyzeResultService.getAllKeyPrefixByResult(rdbAnalyzeResult.getResult()));
283-
// } catch (Exception e) {
284-
// LOG.error("getAllKey_prefix failed!", e);
285-
// return Result.failResult("getAllKey_prefix failed!");
286-
// }
287-
// }
259+
/**
260+
* get all key_prefix
261+
*
262+
* @param analyzeResultId
263+
* @return
264+
*/
265+
@GetMapping("/all/key_prefix")
266+
public Result getAllKeyPrefix(@RequestParam Long analyzeResultId) {
267+
try {
268+
if (null == analyzeResultId) {
269+
return Result.failResult("analyzeResultId should not null!");
270+
}
271+
return Result.successResult(rdbAnalyzeResultService.getAllKeyPrefixById(analyzeResultId));
272+
} catch (Exception e) {
273+
LOG.error("getAllKey_prefix failed!", e);
274+
return Result.failResult("getAllKey_prefix failed!");
275+
}
276+
}
288277

289278

290279
/**
@@ -367,9 +356,13 @@ public Result getPrefixKeyByMem(@RequestParam Long analyzeResultId,
367356
*/
368357
@GetMapping("/line/prefix/{type}")
369358
public Result getPrefixLineByCountOrMem(@PathVariable String type, @RequestParam Long analyzeResultId,
370-
@RequestParam(value = "prefixKey", required = false) String prefixKey) {
359+
@RequestParam(value = "prefixKey", required = false) String prefixKey,
360+
@RequestParam(value = "top", required = false) Integer top) {
371361
try {
372-
JSONArray result = rdbAnalyzeResultService.getPrefixLineByCountOrMem(analyzeResultId, type, 20, prefixKey);
362+
if (null == top || top == 0) {
363+
top = 10;
364+
}
365+
JSONObject result = rdbAnalyzeResultService.getPrefixLineByCountOrMem(analyzeResultId, type, top, prefixKey);
373366
return Result.successResult(result);
374367
}
375368
catch (Exception e) {

redis-manager-dashboard/src/main/java/com/newegg/ec/redis/plugin/alert/dao/IAlertChannelDao.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package com.newegg.ec.redis.plugin.alert.dao;
22

33
import com.newegg.ec.redis.plugin.alert.entity.AlertChannel;
4-
import jdk.nashorn.internal.objects.annotations.Where;
54
import org.apache.ibatis.annotations.*;
6-
import org.springframework.stereotype.Component;
75

86
import java.util.List;
97

redis-manager-dashboard/src/main/java/com/newegg/ec/redis/service/IRdbAnalyzeResultService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.newegg.ec.redis.service;
22

33
import com.alibaba.fastjson.JSONArray;
4+
import com.alibaba.fastjson.JSONObject;
45
import com.newegg.ec.redis.entity.Cluster;
56
import com.newegg.ec.redis.entity.RDBAnalyze;
67
import com.newegg.ec.redis.entity.RDBAnalyzeResult;
@@ -16,7 +17,7 @@ public interface IRdbAnalyzeResultService {
1617
List<RDBAnalyzeResult> selectList(Long groupId);
1718
RDBAnalyzeResult reportDataWriteToDb(RDBAnalyze rdbAnalyze, Map<String, Set<String>> data);
1819
Object getListStringFromResult(Long analyzeResultId, String key) throws Exception;
19-
JSONArray getPrefixLineByCountOrMem(Long analyzeResultId, String type, int top, String prefixKey);
20+
JSONObject getPrefixLineByCountOrMem(Long analyzeResultId, String type, int top, String prefixKey);
2021
JSONArray getPrefixType(Long analyzeResultId) throws Exception;
2122
Map<String, ReportData> getReportDataLatest(Long clusterId);
2223
void createRdbAnalyzeResultTable();

redis-manager-dashboard/src/main/java/com/newegg/ec/redis/service/impl/RdbAnalyzeResultService.java

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -238,32 +238,41 @@ public RDBAnalyzeResult reportDataWriteToDb(RDBAnalyze rdbAnalyze, Map<String, S
238238
return null;
239239
}
240240

241+
/**
242+
* get all keyPrefix by analyzeResultId
243+
* @param analyzeResultId id
244+
* @return List<JSONObject>
245+
*/
246+
public List<JSONObject> getAllKeyPrefixById(Long analyzeResultId) {
247+
RDBAnalyzeResult result = selectResultById(analyzeResultId);
248+
return getAllKeyPrefixByResult(result.getResult());
249+
}
241250

242-
// /**
243-
// * get list keyPrefix
244-
// * @param result result
245-
// * @return List<String> keyPrefix
246-
// */
247-
// public List<JSONObject> getAllKeyPrefixByResult(String result){
248-
// List<JSONObject> resultJsonObj = new ArrayList<>(500);
249-
// if(null == result || "".equals(result.trim())) {
250-
// return resultJsonObj;
251-
// }
252-
// JSONArray jsonArray = getJSONArrayFromResultByKey(result, IAnalyzeDataConverse.PREFIX_KEY_BY_COUNT);
253-
// if(null == jsonArray) {
254-
// return resultJsonObj;
255-
// }
256-
// JSONObject oneRow;
257-
// JSONObject jsonObject;
258-
// for(Object obj : jsonArray) {
259-
// oneRow = (JSONObject) obj;
260-
// jsonObject = new JSONObject();
261-
// jsonObject.put("value", oneRow.getString("prefixKey"));
262-
// jsonObject.put("label", oneRow.getString("prefixKey"));
263-
// resultJsonObj.add(jsonObject);
264-
// }
265-
// return resultJsonObj;
266-
// }
251+
/**
252+
* get list keyPrefix
253+
* @param result result
254+
* @return List<String> keyPrefix
255+
*/
256+
private List<JSONObject> getAllKeyPrefixByResult(String result){
257+
List<JSONObject> resultJsonObj = new ArrayList<>(500);
258+
if(null == result || "".equals(result.trim())) {
259+
return resultJsonObj;
260+
}
261+
JSONArray jsonArray = getJSONArrayFromResultByKey(result, IAnalyzeDataConverse.PREFIX_KEY_BY_COUNT);
262+
if(null == jsonArray) {
263+
return resultJsonObj;
264+
}
265+
JSONObject oneRow;
266+
JSONObject jsonObject;
267+
for(Object obj : jsonArray) {
268+
oneRow = (JSONObject) obj;
269+
jsonObject = new JSONObject();
270+
jsonObject.put("value", oneRow.getString("prefixKey"));
271+
jsonObject.put("label", oneRow.getString("prefixKey"));
272+
resultJsonObj.add(jsonObject);
273+
}
274+
return resultJsonObj;
275+
}
267276

268277
// /**
269278
// * gong zhe xian tu shi yong,
@@ -363,7 +372,8 @@ private JSONArray getTopKeyFromResultByKey(String result, Long startNum) {
363372
* @return JSONArray
364373
*/
365374
@Override
366-
public JSONArray getPrefixLineByCountOrMem(Long analyzeResultId, String type, int top, String prefixKey) {
375+
public JSONObject getPrefixLineByCountOrMem(Long analyzeResultId, String type, int top, String prefixKey) {
376+
JSONObject jsonResultObject = new JSONObject();
367377
String sortColumn = getSortColumn(type);
368378
// RDBAnalyzeResult rdbAnalyzeLatestResult = selectLatestResultByRID(clusterId);
369379
RDBAnalyzeResult rdbAnalyzeLatestResult = selectResultById(analyzeResultId);
@@ -382,6 +392,15 @@ public JSONArray getPrefixLineByCountOrMem(Long analyzeResultId, String type, in
382392
// except Latest RDBAnalyzeResult
383393
List<RDBAnalyzeResult> rdbAnalyzeResultList = selectRecentlyResultByIdExceptSelf(analyzeResultId,
384394
rdbAnalyzeLatestResult.getClusterId(), rdbAnalyzeLatestResult.getScheduleId());
395+
// 过滤掉非集群模式的分析结果
396+
rdbAnalyzeResultList = rdbAnalyzeResultList.stream().filter(rdbAnalyzeResult -> {
397+
JSONObject object = JSONObject.parseObject(rdbAnalyzeResult.getAnalyzeConfig());
398+
JSONArray array = object.getJSONArray("nodes");
399+
if (array.size() == 1 && "-1".equals(array.getString(0))) {
400+
return true;
401+
}
402+
return false;
403+
}).collect(Collectors.toList());
385404
// key :prefixKey
386405
Map<String, Map<String, JSONObject>> resultMap = new HashMap<>(7);
387406
Map<String, JSONObject> latest = getMapJSONByResult(rdbAnalyzeLatestResult, arrayResult);
@@ -423,7 +442,9 @@ public JSONArray getPrefixLineByCountOrMem(Long analyzeResultId, String type, in
423442
arrayJsonObj.put("key", prefix);
424443
result.add(arrayJsonObj);
425444
}
426-
return result;
445+
jsonResultObject.put("time", scheduleList);
446+
jsonResultObject.put("data", result);
447+
return jsonResultObject;
427448

428449
}
429450

@@ -458,7 +479,7 @@ private Map<String, JSONObject> getMapJSONByResult(RDBAnalyzeResult rdbAnalyzeRe
458479
private List<String> getcolumnKeyList(String prefixKey, List<JSONObject> resultObjecList, String columnName,
459480
int top) {
460481
List<String> prefixKeyList = new ArrayList<>(10);
461-
if (null == prefixKey) {
482+
if (null == prefixKey || "".equals(prefixKey)) {
462483
if (top == -1) {
463484
top = resultObjecList.size();
464485
}

redis-manager-ui/redis-manager-vue/src/api/rctapi.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ export const getAnalyzeResults = (groupId) => RCTAPI(`/rdb/results?groupId=${gro
113113

114114
export const getPieByType = (analyzeResultId) => RCTAPI('/rdb/chart/DataTypeAnalyze', 'GET', {analyzeResultId})
115115

116-
export const getPrefixKeysCount = (analyzeResultId) => RCTAPI('/rdb/line/prefix/PrefixKeyByCount', 'GET', {analyzeResultId})
116+
export const getPrefixKeysCount = (analyzeResultId, prefixKey) => RCTAPI('/rdb/line/prefix/PrefixKeyByCount', 'GET', {analyzeResultId, prefixKey})
117117

118-
export const getPrefixKeysMemory = (analyzeResultId) => RCTAPI('/rdb/line/prefix/PrefixKeyByMemory', 'GET', {analyzeResultId})
118+
export const getPrefixKeysMemory = (analyzeResultId, prefixKey) => RCTAPI('/rdb/line/prefix/PrefixKeyByMemory', 'GET', {analyzeResultId, prefixKey})
119119

120120
export const getTop1000KeysByPrefix = (analyzeResultId) => API('/rdb/table/prefix', 'GET', {analyzeResultId})
121121

@@ -136,3 +136,5 @@ export const getTimeData = (analyzeResultId) => RCTAPI('/rdb/all/schedule_id', '
136136
export const getScheduleDetail = (id) => API(`/rdb/schedule_detail/${id}`)
137137

138138
export const cancelAnalyzeTask = (id, scheduleID) => API(`/rdb/cance_job/${id}/${scheduleID}`)
139+
140+
export const getSelectKeys = (analyzeResultId) => RCTAPI('/rdb/all/key_prefix', 'GET', { analyzeResultId })

redis-manager-ui/redis-manager-vue/src/components/rct/JobResultDetail.vue

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,22 @@
88
<!-- <el-row class="echart-wrapper" id="monitor-charts"> -->
99
<KeyByTypePie pieType="count" :resultId="resultId"></KeyByTypePie>
1010
<KeyByTypePie pieType="memory" :resultId="resultId"></KeyByTypePie>
11-
<PrefixKeysCount v-show="isCluster" :resultId="resultId"></PrefixKeysCount>
12-
<PrefixKeysMemory v-show="isCluster" :resultId="resultId"></PrefixKeysMemory>
11+
<div v-if="isCluster">
12+
<el-col class="chart-item">
13+
<el-card shadow="hover" class="box-card">
14+
<el-select v-model="selectPrefixValue" filterable clearable placeholder="select key">
15+
<el-option
16+
v-for="item in selectOptions"
17+
:key="item.value"
18+
:label="item.label"
19+
:value="item.value">
20+
</el-option>
21+
</el-select>
22+
</el-card>
23+
</el-col>
24+
<PrefixKeysCount :resultId="resultId" :selectPrefixValue="selectPrefixValue"></PrefixKeysCount>
25+
<PrefixKeysMemory :resultId="resultId" :selectPrefixValue="selectPrefixValue"></PrefixKeysMemory>
26+
</div>
1327
<Tables :resultId="resultId" :tableObj="top1000keysPrefix" :initData="initTop1000Keys"/>
1428
<Tables :resultId="resultId" :tableObj="keysTTL" :initData="initKeysTTL"/>
1529
<Top1000KeysByType :resultId="resultId"></Top1000KeysByType>
@@ -27,7 +41,8 @@ import KeyByTypePie from '@/components/rct/chart/KeyByTypePie'
2741
import Top1000KeysByType from '@/components/rct/chart/Top1000KeysByType'
2842
import Tables from '@/components/rct/chart/Table'
2943
import { formatBytes, formatterInput } from '@/utils/format.js'
30-
import { getTop1000KeysByPrefix, getKeysTTLInfo } from '@/api/rctapi.js'
44+
import { getTop1000KeysByPrefix, getKeysTTLInfo, getSelectKeys } from '@/api/rctapi.js'
45+
import { error } from 'highcharts'
3146
export default {
3247
beforeCreate: function () {
3348
document.querySelector('body').setAttribute('style', 'overflow:auto')
@@ -45,14 +60,18 @@ export default {
4560
4661
data () {
4762
return {
63+
selectPrefixValue: '',
64+
selectOptions: [],
4865
isCluster: '',
4966
analyseResults: [],
5067
name: '',
5168
top1000keysPrefix: {
5269
columns: [{
5370
label: 'Prefix',
5471
type: 'String',
55-
prop: 'prefixKey'
72+
prop: 'prefixKey',
73+
show_tooltip: true,
74+
min_width: '200px'
5675
}, {
5776
label: 'Count',
5877
sort: true,
@@ -68,13 +87,15 @@ export default {
6887
}],
6988
searchVis: true,
7089
searchColumn: 'prefixKey',
71-
title: 'Top 1000 Largest Keys By Custom Prefixes'
90+
title: 'Key Prefix Info'
7291
},
7392
keysTTL: {
7493
columns: [{
7594
label: 'Prefix',
7695
prop: 'prefix',
77-
type: 'String'
96+
type: 'String',
97+
show_tooltip: true,
98+
min_width: '200px'
7899
}, {
79100
label: 'TTL',
80101
sort: true,
@@ -126,6 +147,15 @@ export default {
126147
let analyzeConfigObj = JSON.parse(analyzeConfig)
127148
if (!analyzeConfigObj.nodes || analyzeConfigObj.nodes[0] === '-1') {
128149
this.isCluster = true
150+
getSelectKeys(this.resultId).then(res => {
151+
if (res.code === 0) {
152+
this.selectOptions = res.data
153+
} else {
154+
console.error(res.message)
155+
}
156+
}).catch(error => {
157+
console.error(error)
158+
})
129159
} else {
130160
this.isCluster = false
131161
}

0 commit comments

Comments
 (0)