提交部分统计结果代码
This commit is contained in:
parent
5781b55f19
commit
f24c01556c
|
|
@ -1,11 +1,20 @@
|
|||
package com.ai.cloud.skywalking.web.controller;
|
||||
|
||||
import com.ai.cloud.skywalking.web.common.BaseController;
|
||||
import com.ai.cloud.skywalking.web.dto.CallChainTree;
|
||||
import com.ai.cloud.skywalking.web.dto.LoginUserInfo;
|
||||
import com.ai.cloud.skywalking.web.service.inter.IAnalysisResultService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* Created by xin on 16-4-5.
|
||||
*/
|
||||
|
|
@ -13,15 +22,37 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||
@Controller
|
||||
public class AnalysisResultController extends BaseController {
|
||||
|
||||
private Logger logger = LogManager.getLogger(AnalysisResultController.class);
|
||||
|
||||
@Autowired
|
||||
private IAnalysisResultService analysisResultService;
|
||||
|
||||
@RequestMapping("/anlsResult")
|
||||
public String analysisResult() {
|
||||
return "anls-result/analysisResult";
|
||||
}
|
||||
|
||||
//@RequestMapping(value = "/load/{anlsDate}", produces = "application/json; charset=UTF-8")
|
||||
//@ResponseBody
|
||||
public String loadAnalysisResult(@PathVariable("anlsDate") String anlsDate) {
|
||||
|
||||
return null;
|
||||
/**
|
||||
* Analysis Type: MONTH, DAY, HOUR
|
||||
* analysis Date: 2015-07 2015-07-17 2015-07-17:18
|
||||
*/
|
||||
@RequestMapping(value = "/load/{treeId}/{analyType}/{analyDate}", produces = "application/json; charset=UTF-8")
|
||||
@ResponseBody
|
||||
public String loadAnalysisResult(HttpServletRequest request,
|
||||
@PathVariable("treeId") String treeId,
|
||||
@PathVariable("analyType") String analyType,
|
||||
@PathVariable("analyDate") String analyDate) {
|
||||
JSONObject result = new JSONObject();
|
||||
try {
|
||||
LoginUserInfo userInfo = fetchLoginUserInfoFromSession(request);
|
||||
CallChainTree callChainTree = analysisResultService.
|
||||
fetchAnalysisResult(treeId, analyType, analyDate);
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to load treeId[{}], anlysisType:[{}], anlyDate:[{}]", treeId, analyType, analyDate);
|
||||
logger.error(e);
|
||||
result.put("code", "500");
|
||||
result.put("message", "Fatal error");
|
||||
}
|
||||
return result.toJSONString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ package com.ai.cloud.skywalking.web.controller;
|
|||
|
||||
import com.ai.cloud.skywalking.web.common.BaseController;
|
||||
import com.ai.cloud.skywalking.web.dto.AnlyResult;
|
||||
import com.ai.cloud.skywalking.web.dto.CallChainNode;
|
||||
import com.ai.cloud.skywalking.web.entity.BreviaryChainNode;
|
||||
import com.ai.cloud.skywalking.web.dto.LoginUserInfo;
|
||||
import com.ai.cloud.skywalking.web.dto.TraceTreeInfo;
|
||||
import com.ai.cloud.skywalking.web.entity.CallChainTree;
|
||||
import com.ai.cloud.skywalking.web.entity.BreviaryChainTree;
|
||||
import com.ai.cloud.skywalking.web.service.inter.ICallChainTreeService;
|
||||
import com.ai.cloud.skywalking.web.service.inter.ITraceTreeService;
|
||||
import com.ai.cloud.skywalking.web.util.Constants;
|
||||
|
|
@ -95,23 +95,23 @@ public class SearchController extends BaseController {
|
|||
try {
|
||||
if (StringUtil.isBlank(key)) {
|
||||
jsonObject.put("code", "200");
|
||||
jsonObject.put("result", JSON.toJSONString(new ArrayList<CallChainTree>()));
|
||||
jsonObject.put("result", JSON.toJSONString(new ArrayList<BreviaryChainTree>()));
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
|
||||
LoginUserInfo loginUserInfo = fetchLoginUserInfoFromSession(request);
|
||||
|
||||
List<CallChainTree> callChainTreeList =
|
||||
List<BreviaryChainTree> acronymousChainTreeWithGuessNodeList =
|
||||
callChainTreeService.queryCallChainTreeByKey(loginUserInfo.getUid(), key, pageSize);
|
||||
//List<CallChainTree> callChainTreeList = generateCallChainTree();
|
||||
//List<BreviaryChainTree> acronymousChainTreeWithGuessNodeList = generateCallChainTree();
|
||||
JsonObject result = new JsonObject();
|
||||
if (callChainTreeList.size() > Constants.MAX_ANALYSIS_RESULT_PAGE_SIZE) {
|
||||
if (acronymousChainTreeWithGuessNodeList.size() > Constants.MAX_ANALYSIS_RESULT_PAGE_SIZE) {
|
||||
result.addProperty("hasNextPage", true);
|
||||
callChainTreeList.remove(callChainTreeList.size() - 1);
|
||||
acronymousChainTreeWithGuessNodeList.remove(acronymousChainTreeWithGuessNodeList.size() - 1);
|
||||
} else {
|
||||
result.addProperty("hasNexPage", false);
|
||||
}
|
||||
JsonElement jsonElements = new JsonParser().parse(new Gson().toJson(callChainTreeList));
|
||||
JsonElement jsonElements = new JsonParser().parse(new Gson().toJson(acronymousChainTreeWithGuessNodeList));
|
||||
result.add("children", jsonElements);
|
||||
jsonObject.put("code", "200");
|
||||
jsonObject.put("result", result.toString());
|
||||
|
|
@ -123,29 +123,29 @@ public class SearchController extends BaseController {
|
|||
return jsonObject.toJSONString();
|
||||
}
|
||||
|
||||
private List<CallChainTree> generateCallChainTree() {
|
||||
List<CallChainTree> callChainTrees = new ArrayList<CallChainTree>();
|
||||
CallChainTree chainTree = new CallChainTree("test");
|
||||
private List<BreviaryChainTree> generateCallChainTree() {
|
||||
List<BreviaryChainTree> acronymousChainTreeWithGuessNodes = new ArrayList<BreviaryChainTree>();
|
||||
BreviaryChainTree chainTree = new BreviaryChainTree("test");
|
||||
chainTree.setEntranceViewpoint("test");
|
||||
chainTree.setTreeId("test tree id");
|
||||
List<CallChainNode> callChainNodes = new ArrayList<>();
|
||||
CallChainNode callChainNode = new CallChainNode("0.0", "test view point id", true);
|
||||
CallChainNode callChainNode1 = new CallChainNode("0.0.0", "test view point id", true);
|
||||
CallChainNode callChainNode2 = new CallChainNode("0.1", "test view point id", true);
|
||||
CallChainNode callChainNode3 = new CallChainNode("0.2", "test view point id", true);
|
||||
callChainNodes.add(callChainNode);
|
||||
callChainNodes.add(callChainNode1);
|
||||
callChainNodes.add(callChainNode2);
|
||||
callChainNodes.add(callChainNode3);
|
||||
chainTree.setNodes(callChainNodes);
|
||||
callChainTrees.add(chainTree);
|
||||
List<BreviaryChainNode> breviaryChainNodes = new ArrayList<>();
|
||||
BreviaryChainNode breviaryChainNode = new BreviaryChainNode("0.0", "test view point id", true);
|
||||
BreviaryChainNode breviaryChainNode1 = new BreviaryChainNode("0.0.0", "test view point id", true);
|
||||
BreviaryChainNode breviaryChainNode2 = new BreviaryChainNode("0.1", "test view point id", true);
|
||||
BreviaryChainNode breviaryChainNode3 = new BreviaryChainNode("0.2", "test view point id", true);
|
||||
breviaryChainNodes.add(breviaryChainNode);
|
||||
breviaryChainNodes.add(breviaryChainNode1);
|
||||
breviaryChainNodes.add(breviaryChainNode2);
|
||||
breviaryChainNodes.add(breviaryChainNode3);
|
||||
chainTree.setNodes(breviaryChainNodes);
|
||||
acronymousChainTreeWithGuessNodes.add(chainTree);
|
||||
AnlyResult anlyResult = new AnlyResult();
|
||||
anlyResult.setTotalCostTime(1000);
|
||||
anlyResult.setTotalCall(20);
|
||||
anlyResult.setHumanInterruptionNumber(10);
|
||||
anlyResult.setCorrectNumber(10);
|
||||
chainTree.setEntranceAnlyResult(anlyResult);
|
||||
return callChainTrees;
|
||||
return acronymousChainTreeWithGuessNodes;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ package com.ai.cloud.skywalking.web.dao.impl;
|
|||
|
||||
import com.ai.cloud.skywalking.web.dao.inter.ICallChainTreeDao;
|
||||
import com.ai.cloud.skywalking.web.dto.AnlyResult;
|
||||
import com.ai.cloud.skywalking.web.entity.CallChainTree;
|
||||
import com.ai.cloud.skywalking.web.dto.CallChainTree;
|
||||
import com.ai.cloud.skywalking.web.dto.CallChainTreeNode;
|
||||
import com.ai.cloud.skywalking.web.entity.BreviaryChainTree;
|
||||
import com.ai.cloud.skywalking.web.util.HBaseUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
|
|
@ -26,7 +28,7 @@ import java.util.Map;
|
|||
@Repository
|
||||
public class CallChainTreeDao implements ICallChainTreeDao {
|
||||
|
||||
private Logger logger = LogManager.getLogger(CallChainTree.class);
|
||||
private Logger logger = LogManager.getLogger(BreviaryChainTree.class);
|
||||
|
||||
@Autowired
|
||||
private HBaseUtils hBaseUtils;
|
||||
|
|
@ -42,7 +44,7 @@ public class CallChainTreeDao implements ICallChainTreeDao {
|
|||
Result result = table.get(get);
|
||||
if (result.rawCells().length == 0) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
return new AnlyResult(calendar.get(Calendar.YEAR) + "",(calendar.get(Calendar.MONTH)+1) + "");
|
||||
return new AnlyResult(calendar.get(Calendar.YEAR) + "", (calendar.get(Calendar.MONTH) + 1) + "");
|
||||
}
|
||||
AnlyResult anlyResult = null;
|
||||
Cell cell = result.getColumnLatestCell("chain_summary".getBytes(), columnName.getBytes());
|
||||
|
|
@ -55,14 +57,34 @@ public class CallChainTreeDao implements ICallChainTreeDao {
|
|||
Map<String, AnlyResult> resultMap = new Gson().fromJson(jsonObject.getAsJsonObject("summaryValueMap"),
|
||||
new TypeToken<Map<String, AnlyResult>>() {
|
||||
}.getType());
|
||||
anlyResult = resultMap.get((Calendar.getInstance().get(Calendar.MONTH)+1) + "");
|
||||
anlyResult = resultMap.get((Calendar.getInstance().get(Calendar.MONTH) + 1) + "");
|
||||
}
|
||||
|
||||
if(anlyResult == null){
|
||||
if (anlyResult == null) {
|
||||
anlyResult = new AnlyResult();
|
||||
}
|
||||
anlyResult.setYearOfAnlyResult((Calendar.getInstance().get(Calendar.YEAR)) + "");
|
||||
anlyResult.setMonthOfAnlyResult((Calendar.getInstance().get(Calendar.MONTH)+1) + "");
|
||||
anlyResult.setMonthOfAnlyResult((Calendar.getInstance().get(Calendar.MONTH) + 1) + "");
|
||||
return anlyResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallChainTree queryAnalysisCallTree(String tableName, String rowKey, String loadKey) throws IOException {
|
||||
Table table = hBaseUtils.getConnection().getTable(TableName.valueOf(tableName));
|
||||
Get get = new Get(rowKey.getBytes());
|
||||
Result result = table.get(get);
|
||||
if (result.rawCells().length == 0) {
|
||||
return null;
|
||||
}
|
||||
CallChainTree chainTree = new CallChainTree();
|
||||
for (Cell cell : result.rawCells()) {
|
||||
String qualifierStr = Bytes.toString(cell.getQualifierArray(),
|
||||
cell.getQualifierOffset(), cell.getQualifierLength());
|
||||
String valueStr = Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
|
||||
CallChainTreeNode callChainTreeNode = new CallChainTreeNode(qualifierStr, valueStr, loadKey);
|
||||
chainTree.addNode(callChainTreeNode);
|
||||
}
|
||||
|
||||
return chainTree;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ai.cloud.skywalking.web.dao.inter;
|
||||
|
||||
import com.ai.cloud.skywalking.web.dto.AnlyResult;
|
||||
import com.ai.cloud.skywalking.web.dto.CallChainTree;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
@ -9,4 +10,6 @@ import java.io.IOException;
|
|||
*/
|
||||
public interface ICallChainTreeDao {
|
||||
AnlyResult queryEntranceAnlyResult(String entranceColumnName, String treeId) throws IOException;
|
||||
|
||||
CallChainTree queryAnalysisCallTree(String tableName, String rowKey, String loadKey) throws IOException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package com.ai.cloud.skywalking.web.dto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by xin on 16-4-25.
|
||||
*/
|
||||
public class CallChainTree {
|
||||
|
||||
private String treeId;
|
||||
private List<CallChainTreeNode> callChainTreeNodeList;
|
||||
|
||||
public CallChainTree() {
|
||||
callChainTreeNodeList = new ArrayList<CallChainTreeNode>();
|
||||
}
|
||||
|
||||
public void addNode(CallChainTreeNode callChainTreeNode) {
|
||||
callChainTreeNodeList.add(callChainTreeNode);
|
||||
}
|
||||
|
||||
public void setTreeId(String treeId) {
|
||||
this.treeId = treeId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.ai.cloud.skywalking.web.dto;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by xin on 16-4-25.
|
||||
*/
|
||||
public class CallChainTreeNode {
|
||||
|
||||
private String traceLevelId;
|
||||
private String viewPoint;
|
||||
private AnlyResult anlyResult;
|
||||
|
||||
public CallChainTreeNode(String qualifierStr, String valueStr, String loadKey) {
|
||||
String[] qualifierArray = qualifierStr.split("@");
|
||||
traceLevelId = qualifierArray[0];
|
||||
viewPoint = qualifierArray[1];
|
||||
JsonObject jsonObject = (JsonObject) new JsonParser().parse(valueStr);
|
||||
Map<String, AnlyResult> resultMap = new Gson().fromJson(jsonObject.getAsJsonObject("summaryValueMap"),
|
||||
new TypeToken<Map<String, AnlyResult>>() {
|
||||
}.getType());
|
||||
anlyResult = resultMap.get(loadKey);
|
||||
|
||||
}
|
||||
|
||||
public String getTraceLevelId() {
|
||||
return traceLevelId;
|
||||
}
|
||||
|
||||
public String getViewPoint() {
|
||||
return viewPoint;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
package com.ai.cloud.skywalking.web.dto;
|
||||
package com.ai.cloud.skywalking.web.entity;
|
||||
|
||||
import com.ai.cloud.skywalking.web.util.ViewPointBeautiUtil;
|
||||
|
||||
/**
|
||||
* Created by xin on 16-4-14.
|
||||
*/
|
||||
public class CallChainNode {
|
||||
public class BreviaryChainNode {
|
||||
private String traceLevelId="";
|
||||
private String viewPoint;
|
||||
private boolean isGuess;
|
||||
public CallChainNode(String traceLevelId, String viewPoint, boolean isGuess) {
|
||||
public BreviaryChainNode(String traceLevelId, String viewPoint, boolean isGuess) {
|
||||
this.traceLevelId = traceLevelId;
|
||||
this.viewPoint = viewPoint;
|
||||
this.isGuess = isGuess;
|
||||
|
|
@ -42,7 +42,7 @@ public class CallChainNode {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
CallChainNode that = (CallChainNode) o;
|
||||
BreviaryChainNode that = (BreviaryChainNode) o;
|
||||
|
||||
return traceLevelId != null ? traceLevelId.equals(that.traceLevelId) : that.traceLevelId == null;
|
||||
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
package com.ai.cloud.skywalking.web.entity;
|
||||
|
||||
import com.ai.cloud.skywalking.web.dto.AnlyResult;
|
||||
import com.ai.cloud.skywalking.web.dto.CallChainNode;
|
||||
import com.ai.cloud.skywalking.web.util.ViewPointBeautiUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -9,15 +8,15 @@ import java.util.*;
|
|||
/**
|
||||
* Created by xin on 16-4-6.
|
||||
*/
|
||||
public class CallChainTree {
|
||||
public class BreviaryChainTree {
|
||||
private String treeId;
|
||||
private String entranceViewpoint;
|
||||
private List<CallChainNode> nodes;
|
||||
private List<BreviaryChainNode> nodes;
|
||||
private AnlyResult entranceAnlyResult;
|
||||
|
||||
public CallChainTree(String treeId) {
|
||||
public BreviaryChainTree(String treeId) {
|
||||
this.treeId = treeId;
|
||||
nodes = new ArrayList<CallChainNode>();
|
||||
nodes = new ArrayList<BreviaryChainNode>();
|
||||
}
|
||||
|
||||
public void setEntranceAnlyResult(AnlyResult entranceAnlyResult) {
|
||||
|
|
@ -26,8 +25,8 @@ public class CallChainTree {
|
|||
|
||||
public void addHitNodes(Map<String, String> nodes) {
|
||||
for (Map.Entry<String, String> entry : nodes.entrySet()) {
|
||||
CallChainNode callChainNode = new CallChainNode(entry.getKey(), entry.getValue(), false);
|
||||
this.nodes.add(callChainNode);
|
||||
BreviaryChainNode breviaryChainNode = new BreviaryChainNode(entry.getKey(), entry.getValue(), false);
|
||||
this.nodes.add(breviaryChainNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -37,23 +36,23 @@ public class CallChainTree {
|
|||
//
|
||||
}
|
||||
|
||||
for (CallChainNode chainNode : nodes) {
|
||||
for (BreviaryChainNode chainNode : nodes) {
|
||||
//高亮
|
||||
chainNode.beautiViewPointString(searchKey);
|
||||
}
|
||||
}
|
||||
|
||||
public void sortNodes() {
|
||||
Collections.sort(nodes, new Comparator<CallChainNode>() {
|
||||
Collections.sort(nodes, new Comparator<BreviaryChainNode>() {
|
||||
@Override
|
||||
public int compare(CallChainNode o1, CallChainNode o2) {
|
||||
public int compare(BreviaryChainNode o1, BreviaryChainNode o2) {
|
||||
return o1.getTraceLevelId().compareTo(o2.getTraceLevelId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addGuessNodesAndRemoveDuplicate(List<CallChainNode> nodes) {
|
||||
for (CallChainNode node : nodes) {
|
||||
public void addGuessNodesAndRemoveDuplicate(List<BreviaryChainNode> nodes) {
|
||||
for (BreviaryChainNode node : nodes) {
|
||||
if (!this.nodes.contains(node)) {
|
||||
this.nodes.add(node);
|
||||
}
|
||||
|
|
@ -68,7 +67,7 @@ public class CallChainTree {
|
|||
return entranceAnlyResult;
|
||||
}
|
||||
|
||||
public List<CallChainNode> getNodes() {
|
||||
public List<BreviaryChainNode> getNodes() {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +83,7 @@ public class CallChainTree {
|
|||
this.treeId = treeId;
|
||||
}
|
||||
|
||||
public void setNodes(List<CallChainNode> nodes) {
|
||||
public void setNodes(List<BreviaryChainNode> nodes) {
|
||||
this.nodes = nodes;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
package com.ai.cloud.skywalking.web.service.impl;
|
||||
|
||||
import com.ai.cloud.skywalking.web.dao.inter.ICallChainTreeDao;
|
||||
import com.ai.cloud.skywalking.web.dto.CallChainTree;
|
||||
import com.ai.cloud.skywalking.web.service.inter.IAnalysisResultService;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by xin on 16-4-25.
|
||||
*/
|
||||
@Service
|
||||
public class AnalysisResultService implements IAnalysisResultService {
|
||||
|
||||
private Logger logger = LogManager.getLogger(AnalysisResultService.class);
|
||||
|
||||
@Autowired
|
||||
private ICallChainTreeDao callChainTreeDao;
|
||||
|
||||
@Override
|
||||
public CallChainTree fetchAnalysisResult(String treeId, String analyType, String analyDate) throws ParseException, IOException {
|
||||
String tableName = null;
|
||||
String rowKey = null;
|
||||
String loadKey = null;
|
||||
if ("MONTH".equals(analyType)) {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
|
||||
Date date = format.parse(analyDate);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
rowKey = treeId + "/" + calendar.get(Calendar.YEAR);
|
||||
loadKey = (calendar.get(Calendar.MONTH) + 1) + "";
|
||||
tableName = "sw-chain-1month-summary";
|
||||
} else if ("DAY".equals(analyType)) {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date date = format.parse(analyDate);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
rowKey = treeId + "/" + calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1)
|
||||
+ "-" + calendar.get(Calendar.DAY_OF_MONTH);
|
||||
loadKey = calendar.get(Calendar.DAY_OF_MONTH) + "";
|
||||
tableName = "sw-chain-1day-summary";
|
||||
} else if ("HOUR".equals(analyType)) {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd:HH");
|
||||
Date date = format.parse(analyDate);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
rowKey = treeId + "/" + calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1)
|
||||
+ "-" + calendar.get(Calendar.DAY_OF_MONTH);
|
||||
loadKey = calendar.get(Calendar.HOUR) + "";
|
||||
tableName = "sw-chain-1hour-summary";
|
||||
}
|
||||
|
||||
if (tableName == null || rowKey == null) {
|
||||
throw new RuntimeException("tableName or analyType cannot be find.");
|
||||
}
|
||||
|
||||
logger.info("fetchAnalysisResult: tableName :{}, rowKey : {}, loadKey:{}", tableName, rowKey, loadKey);
|
||||
CallChainTree callChainTree = callChainTreeDao.queryAnalysisCallTree(tableName, rowKey, loadKey);
|
||||
callChainTree.setTreeId(treeId);
|
||||
return callChainTree;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,9 +3,9 @@ package com.ai.cloud.skywalking.web.service.impl;
|
|||
import com.ai.cloud.skywalking.web.dao.inter.ICallChainTreeDao;
|
||||
import com.ai.cloud.skywalking.web.dao.inter.IChainDetailDao;
|
||||
import com.ai.cloud.skywalking.web.dto.AnlyResult;
|
||||
import com.ai.cloud.skywalking.web.dto.CallChainNode;
|
||||
import com.ai.cloud.skywalking.web.entity.BreviaryChainNode;
|
||||
import com.ai.cloud.skywalking.web.dto.HitTreeInfo;
|
||||
import com.ai.cloud.skywalking.web.entity.CallChainTree;
|
||||
import com.ai.cloud.skywalking.web.entity.BreviaryChainTree;
|
||||
import com.ai.cloud.skywalking.web.service.inter.ICallChainTreeService;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
|
@ -29,11 +29,11 @@ public class CallChainTreeService implements ICallChainTreeService {
|
|||
private ICallChainTreeDao chainTreeDao;
|
||||
|
||||
@Override
|
||||
public List<CallChainTree> queryCallChainTreeByKey(String uid, String viewpoint, int pageSize) throws SQLException, IOException {
|
||||
List<CallChainTree> trees = new ArrayList<CallChainTree>();
|
||||
public List<BreviaryChainTree> queryCallChainTreeByKey(String uid, String viewpoint, int pageSize) throws SQLException, IOException {
|
||||
List<BreviaryChainTree> trees = new ArrayList<BreviaryChainTree>();
|
||||
List<HitTreeInfo> hitTrees = chainDetailDao.queryChainTreeIds(uid, viewpoint, pageSize);
|
||||
for (HitTreeInfo hitTree : hitTrees) {
|
||||
CallChainTree chainTree = new CallChainTree(hitTree.getTreeId());
|
||||
BreviaryChainTree chainTree = new BreviaryChainTree(hitTree.getTreeId());
|
||||
chainTree.setEntranceViewpoint(chainDetailDao.queryChainViewPoint("0", hitTree.getTreeId(), uid));
|
||||
|
||||
chainTree.addHitNodes(hitTree.getHitTraceLevelId());
|
||||
|
|
@ -50,18 +50,18 @@ public class CallChainTreeService implements ICallChainTreeService {
|
|||
return trees;
|
||||
}
|
||||
|
||||
private List<CallChainNode> doGuessNodes(HitTreeInfo hitTraceLevelIds) throws SQLException {
|
||||
List<CallChainNode> guessNodes = new ArrayList<CallChainNode>();
|
||||
private List<BreviaryChainNode> doGuessNodes(HitTreeInfo hitTraceLevelIds) throws SQLException {
|
||||
List<BreviaryChainNode> guessNodes = new ArrayList<BreviaryChainNode>();
|
||||
for (String traceLevelId : hitTraceLevelIds.getHitTraceLevelId().keySet()) {
|
||||
//
|
||||
CallChainNode preTraceLevelNode = guessPreTraceLevelId(traceLevelId, hitTraceLevelIds.getTreeId(), hitTraceLevelIds.getUid());
|
||||
BreviaryChainNode preTraceLevelNode = guessPreTraceLevelId(traceLevelId, hitTraceLevelIds.getTreeId(), hitTraceLevelIds.getUid());
|
||||
if (preTraceLevelNode != null) {
|
||||
guessNodes.add(preTraceLevelNode);
|
||||
logger.info("treeId:{}, traceLevelId :{}, preTraceLevelId:{}", hitTraceLevelIds.getTreeId(), traceLevelId, preTraceLevelNode.getTraceLevelId());
|
||||
}
|
||||
|
||||
//
|
||||
CallChainNode nextTraceLevelNode = guessNextTraceLevelId(traceLevelId, hitTraceLevelIds.getTreeId(), hitTraceLevelIds.getUid());
|
||||
BreviaryChainNode nextTraceLevelNode = guessNextTraceLevelId(traceLevelId, hitTraceLevelIds.getTreeId(), hitTraceLevelIds.getUid());
|
||||
if (nextTraceLevelNode != null) {
|
||||
guessNodes.add(nextTraceLevelNode);
|
||||
logger.info("treeId:{}, traceLevelId :{}, nextTraceLevelId:{}", hitTraceLevelIds.getTreeId(), traceLevelId, nextTraceLevelNode.getTraceLevelId());
|
||||
|
|
@ -72,7 +72,7 @@ public class CallChainTreeService implements ICallChainTreeService {
|
|||
return guessNodes;
|
||||
}
|
||||
|
||||
private CallChainNode guessNextTraceLevelId(String traceLevelId, String treeId, String uid) throws SQLException {
|
||||
private BreviaryChainNode guessNextTraceLevelId(String traceLevelId, String treeId, String uid) throws SQLException {
|
||||
String[] levelIdArray = traceLevelId.split("\\.");
|
||||
if (traceLevelId.lastIndexOf('.') == -1) {
|
||||
return null;
|
||||
|
|
@ -83,7 +83,7 @@ public class CallChainTreeService implements ICallChainTreeService {
|
|||
String subLevelId = parentLevelId + "." + (Integer.parseInt(levelIdArray[levelIdArray.length - 1]) + 1);
|
||||
String tmpViewpoint = chainDetailDao.queryChainViewPoint(subLevelId,
|
||||
treeId, uid);
|
||||
CallChainNode result = null;
|
||||
BreviaryChainNode result = null;
|
||||
if (tmpViewpoint == null) {
|
||||
levelIdArray = parentLevelId.split("\\.");
|
||||
if (levelIdArray.length != 1) {
|
||||
|
|
@ -97,27 +97,27 @@ public class CallChainTreeService implements ICallChainTreeService {
|
|||
}
|
||||
|
||||
if (tmpViewpoint != null) {
|
||||
result = new CallChainNode(subLevelId, tmpViewpoint, true);
|
||||
result = new BreviaryChainNode(subLevelId, tmpViewpoint, true);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private CallChainNode guessPreTraceLevelId(String traceLevelId, String treeId, String uid) throws SQLException {
|
||||
private BreviaryChainNode guessPreTraceLevelId(String traceLevelId, String treeId, String uid) throws SQLException {
|
||||
String[] levelIdArray = traceLevelId.split("\\.");
|
||||
if (levelIdArray.length <= 2) {
|
||||
//上级节点为根节点,不用臆测,页面自动展示
|
||||
return null;
|
||||
}
|
||||
|
||||
CallChainNode result = null;
|
||||
BreviaryChainNode result = null;
|
||||
String parentLevelId = traceLevelId.substring(0, traceLevelId.lastIndexOf('.'));
|
||||
if ("0".equals(levelIdArray[levelIdArray.length - 1])) {
|
||||
// 本机节点为0,找父级
|
||||
String tmpViewpoint = chainDetailDao.queryChainViewPoint(parentLevelId,
|
||||
treeId, uid);
|
||||
if (tmpViewpoint != null) {
|
||||
result = new CallChainNode(parentLevelId, tmpViewpoint, true);
|
||||
result = new BreviaryChainNode(parentLevelId, tmpViewpoint, true);
|
||||
}
|
||||
} else {
|
||||
// 本机节点不为0,找上级
|
||||
|
|
@ -125,7 +125,7 @@ public class CallChainTreeService implements ICallChainTreeService {
|
|||
String tmpViewpoint = chainDetailDao.queryChainViewPoint(preLevelId,
|
||||
treeId, uid);
|
||||
if (tmpViewpoint != null) {
|
||||
result = new CallChainNode(preLevelId, tmpViewpoint, true);
|
||||
result = new BreviaryChainNode(preLevelId, tmpViewpoint, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
package com.ai.cloud.skywalking.web.service.inter;
|
||||
|
||||
import com.ai.cloud.skywalking.web.dto.CallChainTree;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* Created by xin on 16-4-25.
|
||||
*/
|
||||
public interface IAnalysisResultService {
|
||||
CallChainTree fetchAnalysisResult(String treeId, String analyType, String analyDate) throws ParseException, IOException;
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.ai.cloud.skywalking.web.service.inter;
|
||||
|
||||
import com.ai.cloud.skywalking.web.entity.CallChainTree;
|
||||
import com.ai.cloud.skywalking.web.entity.BreviaryChainTree;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -10,5 +10,5 @@ import java.util.List;
|
|||
* Created by xin on 16-4-6.
|
||||
*/
|
||||
public interface ICallChainTreeService {
|
||||
List<CallChainTree> queryCallChainTreeByKey(String uid, String viewpoint, int pageSize) throws SQLException, IOException;
|
||||
List<BreviaryChainTree> queryCallChainTreeByKey(String uid, String viewpoint, int pageSize) throws SQLException, IOException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,58 +1,26 @@
|
|||
<#macro anlyResultTmpl>
|
||||
<script type="text/x-jsrender" id="anlyResultPanelTmpl">
|
||||
<div class="row">
|
||||
<div class="col-md-8" id="anlyResultmPanel">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
</script>
|
||||
</#macro>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
|
||||
<#macro anlyResultDisplayTmpl>
|
||||
<script type="text/x-jsrender" id="anlyResultDisplayTmpl">
|
||||
<div class="row">
|
||||
<h4><a>{{>entranceViewpoint}}</a></h4>
|
||||
<p>
|
||||
{{for nodes}}
|
||||
{{if isPrintSlipDot}}
|
||||
<span style="margin-left:15%">....</span></br>
|
||||
{{/if}}
|
||||
<span style="margin-left:{{>marginLeftSize}}px" data={{>traceLevelId}}>{{>viewPoint}}</span></br>
|
||||
{{/for}}
|
||||
<span style="margin-left:15%">....</span></br>
|
||||
</p>
|
||||
<p style="font-color">{{>entranceAnlyResult.yearOfAnlyResult}}年{{>entranceAnlyResult.monthOfAnlyResult}}月已经被调用{{>entranceAnlyResult.totalCall}}次
|
||||
成功<span class="text-success"><strong>{{>entranceAnlyResult.correctNumber}}</strong></span>次
|
||||
失败<span class="text-danger"><strong>{{>entranceAnlyResult.humanInterruptionNumber}}</strong></span>次
|
||||
成功调用率<span class="
|
||||
{{if correctRate >= 99.00}}
|
||||
text-success
|
||||
{{else correctRate >= 97}}
|
||||
text-warning
|
||||
{{else}}
|
||||
text-danger
|
||||
{{/if}}
|
||||
"><strong>{{>correctRate}}%</strong></span>
|
||||
<a class="pull-right"><ins>more</ins></a></p>
|
||||
<hr/>
|
||||
</div>
|
||||
</script>
|
||||
</#macro>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<@common.importResources />
|
||||
<script src="${_base}/bower_components/jquery-ui/jquery-ui.min.js"></script>
|
||||
<link rel="stylesheet" href="${_base}/bower_components/jquery-treetable/css/jquery.treetable.theme.default.css"/>
|
||||
<script src="${_base}/bower_components/jquery-treetable/jquery.treetable.js"></script>
|
||||
<link href="${_base}/bower_components/jquery-treetable/css/jquery.treetable.css" rel="stylesheet"/>
|
||||
<link href="${_base}/bower_components/skywalking/css/tracelog.css" rel="stylesheet"/>
|
||||
<script src="${_base}/bower_components/skywalking/js/tracelog.js"></script>
|
||||
<script src="${_base}/bower_components/skywalking/js/application.js"></script>
|
||||
<script src="${_base}/bower_components/skywalking/js/analysisresult.js"></script>
|
||||
<link href="${_base}/bower_components/bootstrap-toggle/css/bootstrap-toggle.min.css" rel="stylesheet">
|
||||
<script src="${_base}/bower_components/bootstrap-toggle/js/bootstrap-toggle.min.js"></script>
|
||||
</head>
|
||||
|
||||
<#macro pageInfoTmpl>
|
||||
<script type="text/x-jsrender" id="pageInfoTmpl">
|
||||
<input type="hidden" value="{{>pageSize}}" id="pageSize"/>
|
||||
<nav>
|
||||
<ul class="pager">
|
||||
{{if hasPreviousPage}}
|
||||
<li><a href="javascript:void(0);" id="doPreviousPageBtn">Previous</a></li>
|
||||
{{/if}}
|
||||
{{if hasNextPage}}
|
||||
<li disabled><a href="javascript:void(0);" id="doNextPageBtn">Next</a></li>
|
||||
{{/if}}
|
||||
</ul>
|
||||
</nav>
|
||||
</script>
|
||||
</#macro>
|
||||
<body style="padding-top:80px">
|
||||
<@common.navbar/>
|
||||
<div class="container" id="mainPanel">
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
<#macro anlyResultTmpl>
|
||||
<script type="text/x-jsrender" id="anlyResultPanelTmpl">
|
||||
<div class="row">
|
||||
<div class="col-md-8" id="anlyResultmPanel">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
</script>
|
||||
</#macro>
|
||||
|
||||
<#macro anlyResultDisplayTmpl>
|
||||
<script type="text/x-jsrender" id="anlyResultDisplayTmpl">
|
||||
<div class="row">
|
||||
<h4><a>{{>entranceViewpoint}}</a></h4>
|
||||
<p>
|
||||
{{for nodes}}
|
||||
{{if isPrintSlipDot}}
|
||||
<span style="margin-left:15%">....</span></br>
|
||||
{{/if}}
|
||||
<span style="margin-left:{{>marginLeftSize}}px" data={{>traceLevelId}}>{{>viewPoint}}</span></br>
|
||||
{{/for}}
|
||||
<span style="margin-left:15%">....</span></br>
|
||||
</p>
|
||||
<p style="font-color">{{>entranceAnlyResult.yearOfAnlyResult}}年{{>entranceAnlyResult.monthOfAnlyResult}}月已经被调用{{>entranceAnlyResult.totalCall}}次
|
||||
成功<span class="text-success"><strong>{{>entranceAnlyResult.correctNumber}}</strong></span>次
|
||||
失败<span class="text-danger"><strong>{{>entranceAnlyResult.humanInterruptionNumber}}</strong></span>次
|
||||
成功调用率<span class="
|
||||
{{if correctRate >= 99.00}}
|
||||
text-success
|
||||
{{else correctRate >= 97}}
|
||||
text-warning
|
||||
{{else}}
|
||||
text-danger
|
||||
{{/if}}
|
||||
"><strong>{{>correctRate}}%</strong></span>
|
||||
<a class="pull-right"><ins>more</ins></a></p>
|
||||
<hr/>
|
||||
</div>
|
||||
</script>
|
||||
</#macro>
|
||||
|
||||
<#macro pageInfoTmpl>
|
||||
<script type="text/x-jsrender" id="pageInfoTmpl">
|
||||
<input type="hidden" value="{{>pageSize}}" id="pageSize"/>
|
||||
<nav>
|
||||
<ul class="pager">
|
||||
{{if hasPreviousPage}}
|
||||
<li><a href="javascript:void(0);" id="doPreviousPageBtn">Previous</a></li>
|
||||
{{/if}}
|
||||
{{if hasNextPage}}
|
||||
<li disabled><a href="javascript:void(0);" id="doNextPageBtn">Next</a></li>
|
||||
{{/if}}
|
||||
</ul>
|
||||
</nav>
|
||||
</script>
|
||||
</#macro>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<#import "./common/traceInfo.ftl" as traceInfo>
|
||||
<#import "./usr/applications/applicationMaintain.ftl" as applicationMaintain>
|
||||
<#import "./usr/authfile/auth.ftl" as auth>
|
||||
<#import "./anls-result/analysisResult.ftl" as anlyResult>
|
||||
<#import "anls-result/analysisSearchResult.ftl" as anlyResult>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue