Skip to content

Commit

Permalink
job detail page fix bug
Browse files Browse the repository at this point in the history
1. 优化jobdetail页面Key Prefix Info和TTL请求分别发2次问题
2. 优化jobdetail页面发送无用的获取数据请求
3. 优化jobdetail页面key过长时表格分页无法显示问题
4. 优化jobdetail页面非cluster分析结果时还发送折线图请求数据的问题
5. 修复jobdetail页面出现与非cluster分析结果对比的问题
6. 优化jobdetail页面折线图显示效果
7. jobdetail页面增加折线图可以选择前缀的功能
  • Loading branch information
Dr-kyle committed May 10, 2020
1 parent de2b769 commit a2d4b13
Show file tree
Hide file tree
Showing 11 changed files with 263 additions and 240 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ selenium-debug.log
*.njsproj
*.sln
redis-manger-ui/redis-manager-vue/package-lock.json
redis-manager-dashboard/logs/
redis-manager-dashboard/logs/
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.newegg.ec.redis.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import com.newegg.ec.redis.entity.*;
Expand Down Expand Up @@ -257,34 +256,24 @@ public Result getAllScheduleId(@RequestParam Long analyzeResultId) {
}
}

// /**
// * get all key_prefix
// *
// * @param clusterId
// * @param scheduleId
// * @return
// */
// @GetMapping("/all/key_prefix")
// public Result getAllKeyPrefix(@RequestParam Long clusterId, @RequestParam(value = "scheduleId", required = false) Long scheduleId) {
// try {
// if (null == clusterId) {
// return Result.failResult("clusterId should not null!");
// }
// RDBAnalyzeResult rdbAnalyzeResult;
// if(null != scheduleId){
// rdbAnalyzeResult = rdbAnalyzeResultService.selectResultByRIDandSID(clusterId, scheduleId);
// } else {
// rdbAnalyzeResult = rdbAnalyzeResultService.selectLatestResultByRID(clusterId);
// }
// if(null == rdbAnalyzeResult) {
// return Result.successResult(null);
// }
// return Result.successResult(rdbAnalyzeResultService.getAllKeyPrefixByResult(rdbAnalyzeResult.getResult()));
// } catch (Exception e) {
// LOG.error("getAllKey_prefix failed!", e);
// return Result.failResult("getAllKey_prefix failed!");
// }
// }
/**
* get all key_prefix
*
* @param analyzeResultId
* @return
*/
@GetMapping("/all/key_prefix")
public Result getAllKeyPrefix(@RequestParam Long analyzeResultId) {
try {
if (null == analyzeResultId) {
return Result.failResult("analyzeResultId should not null!");
}
return Result.successResult(rdbAnalyzeResultService.getAllKeyPrefixById(analyzeResultId));
} catch (Exception e) {
LOG.error("getAllKey_prefix failed!", e);
return Result.failResult("getAllKey_prefix failed!");
}
}


/**
Expand Down Expand Up @@ -367,9 +356,13 @@ public Result getPrefixKeyByMem(@RequestParam Long analyzeResultId,
*/
@GetMapping("/line/prefix/{type}")
public Result getPrefixLineByCountOrMem(@PathVariable String type, @RequestParam Long analyzeResultId,
@RequestParam(value = "prefixKey", required = false) String prefixKey) {
@RequestParam(value = "prefixKey", required = false) String prefixKey,
@RequestParam(value = "top", required = false) Integer top) {
try {
JSONArray result = rdbAnalyzeResultService.getPrefixLineByCountOrMem(analyzeResultId, type, 20, prefixKey);
if (null == top || top == 0) {
top = 10;
}
JSONObject result = rdbAnalyzeResultService.getPrefixLineByCountOrMem(analyzeResultId, type, top, prefixKey);
return Result.successResult(result);
}
catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.newegg.ec.redis.plugin.alert.dao;

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

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.newegg.ec.redis.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.newegg.ec.redis.entity.Cluster;
import com.newegg.ec.redis.entity.RDBAnalyze;
import com.newegg.ec.redis.entity.RDBAnalyzeResult;
Expand All @@ -16,7 +17,7 @@ public interface IRdbAnalyzeResultService {
List<RDBAnalyzeResult> selectList(Long groupId);
RDBAnalyzeResult reportDataWriteToDb(RDBAnalyze rdbAnalyze, Map<String, Set<String>> data);
Object getListStringFromResult(Long analyzeResultId, String key) throws Exception;
JSONArray getPrefixLineByCountOrMem(Long analyzeResultId, String type, int top, String prefixKey);
JSONObject getPrefixLineByCountOrMem(Long analyzeResultId, String type, int top, String prefixKey);
JSONArray getPrefixType(Long analyzeResultId) throws Exception;
Map<String, ReportData> getReportDataLatest(Long clusterId);
void createRdbAnalyzeResultTable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,32 +238,41 @@ public RDBAnalyzeResult reportDataWriteToDb(RDBAnalyze rdbAnalyze, Map<String, S
return null;
}

/**
* get all keyPrefix by analyzeResultId
* @param analyzeResultId id
* @return List<JSONObject>
*/
public List<JSONObject> getAllKeyPrefixById(Long analyzeResultId) {
RDBAnalyzeResult result = selectResultById(analyzeResultId);
return getAllKeyPrefixByResult(result.getResult());
}

// /**
// * get list keyPrefix
// * @param result result
// * @return List<String> keyPrefix
// */
// public List<JSONObject> getAllKeyPrefixByResult(String result){
// List<JSONObject> resultJsonObj = new ArrayList<>(500);
// if(null == result || "".equals(result.trim())) {
// return resultJsonObj;
// }
// JSONArray jsonArray = getJSONArrayFromResultByKey(result, IAnalyzeDataConverse.PREFIX_KEY_BY_COUNT);
// if(null == jsonArray) {
// return resultJsonObj;
// }
// JSONObject oneRow;
// JSONObject jsonObject;
// for(Object obj : jsonArray) {
// oneRow = (JSONObject) obj;
// jsonObject = new JSONObject();
// jsonObject.put("value", oneRow.getString("prefixKey"));
// jsonObject.put("label", oneRow.getString("prefixKey"));
// resultJsonObj.add(jsonObject);
// }
// return resultJsonObj;
// }
/**
* get list keyPrefix
* @param result result
* @return List<String> keyPrefix
*/
private List<JSONObject> getAllKeyPrefixByResult(String result){
List<JSONObject> resultJsonObj = new ArrayList<>(500);
if(null == result || "".equals(result.trim())) {
return resultJsonObj;
}
JSONArray jsonArray = getJSONArrayFromResultByKey(result, IAnalyzeDataConverse.PREFIX_KEY_BY_COUNT);
if(null == jsonArray) {
return resultJsonObj;
}
JSONObject oneRow;
JSONObject jsonObject;
for(Object obj : jsonArray) {
oneRow = (JSONObject) obj;
jsonObject = new JSONObject();
jsonObject.put("value", oneRow.getString("prefixKey"));
jsonObject.put("label", oneRow.getString("prefixKey"));
resultJsonObj.add(jsonObject);
}
return resultJsonObj;
}

// /**
// * gong zhe xian tu shi yong,
Expand Down Expand Up @@ -363,7 +372,8 @@ private JSONArray getTopKeyFromResultByKey(String result, Long startNum) {
* @return JSONArray
*/
@Override
public JSONArray getPrefixLineByCountOrMem(Long analyzeResultId, String type, int top, String prefixKey) {
public JSONObject getPrefixLineByCountOrMem(Long analyzeResultId, String type, int top, String prefixKey) {
JSONObject jsonResultObject = new JSONObject();
String sortColumn = getSortColumn(type);
// RDBAnalyzeResult rdbAnalyzeLatestResult = selectLatestResultByRID(clusterId);
RDBAnalyzeResult rdbAnalyzeLatestResult = selectResultById(analyzeResultId);
Expand All @@ -382,6 +392,15 @@ public JSONArray getPrefixLineByCountOrMem(Long analyzeResultId, String type, in
// except Latest RDBAnalyzeResult
List<RDBAnalyzeResult> rdbAnalyzeResultList = selectRecentlyResultByIdExceptSelf(analyzeResultId,
rdbAnalyzeLatestResult.getClusterId(), rdbAnalyzeLatestResult.getScheduleId());
// 过滤掉非集群模式的分析结果
rdbAnalyzeResultList = rdbAnalyzeResultList.stream().filter(rdbAnalyzeResult -> {
JSONObject object = JSONObject.parseObject(rdbAnalyzeResult.getAnalyzeConfig());
JSONArray array = object.getJSONArray("nodes");
if (array.size() == 1 && "-1".equals(array.getString(0))) {
return true;
}
return false;
}).collect(Collectors.toList());
// key :prefixKey
Map<String, Map<String, JSONObject>> resultMap = new HashMap<>(7);
Map<String, JSONObject> latest = getMapJSONByResult(rdbAnalyzeLatestResult, arrayResult);
Expand Down Expand Up @@ -423,7 +442,9 @@ public JSONArray getPrefixLineByCountOrMem(Long analyzeResultId, String type, in
arrayJsonObj.put("key", prefix);
result.add(arrayJsonObj);
}
return result;
jsonResultObject.put("time", scheduleList);
jsonResultObject.put("data", result);
return jsonResultObject;

}

Expand Down Expand Up @@ -458,7 +479,7 @@ private Map<String, JSONObject> getMapJSONByResult(RDBAnalyzeResult rdbAnalyzeRe
private List<String> getcolumnKeyList(String prefixKey, List<JSONObject> resultObjecList, String columnName,
int top) {
List<String> prefixKeyList = new ArrayList<>(10);
if (null == prefixKey) {
if (null == prefixKey || "".equals(prefixKey)) {
if (top == -1) {
top = resultObjecList.size();
}
Expand Down
6 changes: 4 additions & 2 deletions redis-manager-ui/redis-manager-vue/src/api/rctapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ export const getAnalyzeResults = (groupId) => RCTAPI(`/rdb/results?groupId=${gro

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

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

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

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

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

export const cancelAnalyzeTask = (id, scheduleID) => API(`/rdb/cance_job/${id}/${scheduleID}`)

export const getSelectKeys = (analyzeResultId) => RCTAPI('/rdb/all/key_prefix', 'GET', { analyzeResultId })
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,22 @@
<!-- <el-row class="echart-wrapper" id="monitor-charts"> -->
<KeyByTypePie pieType="count" :resultId="resultId"></KeyByTypePie>
<KeyByTypePie pieType="memory" :resultId="resultId"></KeyByTypePie>
<PrefixKeysCount v-show="isCluster" :resultId="resultId"></PrefixKeysCount>
<PrefixKeysMemory v-show="isCluster" :resultId="resultId"></PrefixKeysMemory>
<div v-if="isCluster">
<el-col class="chart-item">
<el-card shadow="hover" class="box-card">
<el-select v-model="selectPrefixValue" filterable clearable placeholder="select key">
<el-option
v-for="item in selectOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-card>
</el-col>
<PrefixKeysCount :resultId="resultId" :selectPrefixValue="selectPrefixValue"></PrefixKeysCount>
<PrefixKeysMemory :resultId="resultId" :selectPrefixValue="selectPrefixValue"></PrefixKeysMemory>
</div>
<Tables :resultId="resultId" :tableObj="top1000keysPrefix" :initData="initTop1000Keys"/>
<Tables :resultId="resultId" :tableObj="keysTTL" :initData="initKeysTTL"/>
<Top1000KeysByType :resultId="resultId"></Top1000KeysByType>
Expand All @@ -27,7 +41,8 @@ import KeyByTypePie from '@/components/rct/chart/KeyByTypePie'
import Top1000KeysByType from '@/components/rct/chart/Top1000KeysByType'
import Tables from '@/components/rct/chart/Table'
import { formatBytes, formatterInput } from '@/utils/format.js'
import { getTop1000KeysByPrefix, getKeysTTLInfo } from '@/api/rctapi.js'
import { getTop1000KeysByPrefix, getKeysTTLInfo, getSelectKeys } from '@/api/rctapi.js'
import { error } from 'highcharts'
export default {
beforeCreate: function () {
document.querySelector('body').setAttribute('style', 'overflow:auto')
Expand All @@ -45,14 +60,18 @@ export default {
data () {
return {
selectPrefixValue: '',
selectOptions: [],
isCluster: '',
analyseResults: [],
name: '',
top1000keysPrefix: {
columns: [{
label: 'Prefix',
type: 'String',
prop: 'prefixKey'
prop: 'prefixKey',
show_tooltip: true,
min_width: '200px'
}, {
label: 'Count',
sort: true,
Expand All @@ -68,13 +87,15 @@ export default {
}],
searchVis: true,
searchColumn: 'prefixKey',
title: 'Top 1000 Largest Keys By Custom Prefixes'
title: 'Key Prefix Info'
},
keysTTL: {
columns: [{
label: 'Prefix',
prop: 'prefix',
type: 'String'
type: 'String',
show_tooltip: true,
min_width: '200px'
}, {
label: 'TTL',
sort: true,
Expand Down Expand Up @@ -126,6 +147,15 @@ export default {
let analyzeConfigObj = JSON.parse(analyzeConfig)
if (!analyzeConfigObj.nodes || analyzeConfigObj.nodes[0] === '-1') {
this.isCluster = true
getSelectKeys(this.resultId).then(res => {
if (res.code === 0) {
this.selectOptions = res.data
} else {
console.error(res.message)
}
}).catch(error => {
console.error(error)
})
} else {
this.isCluster = false
}
Expand Down
Loading

0 comments on commit a2d4b13

Please sign in to comment.