diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/controller/AnalysisResultController.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/controller/AnalysisResultController.java index 86c2e34cf..060ab5f9a 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/controller/AnalysisResultController.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/controller/AnalysisResultController.java @@ -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(); } } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/controller/SearchController.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/controller/SearchController.java index 71e32dda5..87b01ec8a 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/controller/SearchController.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/controller/SearchController.java @@ -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())); + jsonObject.put("result", JSON.toJSONString(new ArrayList())); return jsonObject.toJSONString(); } LoginUserInfo loginUserInfo = fetchLoginUserInfoFromSession(request); - List callChainTreeList = + List acronymousChainTreeWithGuessNodeList = callChainTreeService.queryCallChainTreeByKey(loginUserInfo.getUid(), key, pageSize); - //List callChainTreeList = generateCallChainTree(); + //List 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 generateCallChainTree() { - List callChainTrees = new ArrayList(); - CallChainTree chainTree = new CallChainTree("test"); + private List generateCallChainTree() { + List acronymousChainTreeWithGuessNodes = new ArrayList(); + BreviaryChainTree chainTree = new BreviaryChainTree("test"); chainTree.setEntranceViewpoint("test"); chainTree.setTreeId("test tree id"); - List 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 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; } } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dao/impl/CallChainTreeDao.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dao/impl/CallChainTreeDao.java index 7d3092db5..8f5e3a3e8 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dao/impl/CallChainTreeDao.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dao/impl/CallChainTreeDao.java @@ -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 resultMap = new Gson().fromJson(jsonObject.getAsJsonObject("summaryValueMap"), new TypeToken>() { }.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; + } } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dao/inter/ICallChainTreeDao.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dao/inter/ICallChainTreeDao.java index a5d1acd99..7f430bc76 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dao/inter/ICallChainTreeDao.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dao/inter/ICallChainTreeDao.java @@ -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; } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dto/CallChainTree.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dto/CallChainTree.java new file mode 100644 index 000000000..72ee8092b --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dto/CallChainTree.java @@ -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 callChainTreeNodeList; + + public CallChainTree() { + callChainTreeNodeList = new ArrayList(); + } + + public void addNode(CallChainTreeNode callChainTreeNode) { + callChainTreeNodeList.add(callChainTreeNode); + } + + public void setTreeId(String treeId) { + this.treeId = treeId; + } +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dto/CallChainTreeNode.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dto/CallChainTreeNode.java new file mode 100644 index 000000000..ecfbea632 --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dto/CallChainTreeNode.java @@ -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 resultMap = new Gson().fromJson(jsonObject.getAsJsonObject("summaryValueMap"), + new TypeToken>() { + }.getType()); + anlyResult = resultMap.get(loadKey); + + } + + public String getTraceLevelId() { + return traceLevelId; + } + + public String getViewPoint() { + return viewPoint; + } +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dto/CallChainNode.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/entity/BreviaryChainNode.java similarity index 84% rename from skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dto/CallChainNode.java rename to skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/entity/BreviaryChainNode.java index ede75e76a..bc89843e5 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dto/CallChainNode.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/entity/BreviaryChainNode.java @@ -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; diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/entity/CallChainTree.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/entity/BreviaryChainTree.java similarity index 69% rename from skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/entity/CallChainTree.java rename to skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/entity/BreviaryChainTree.java index 919cb5b84..28250ed56 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/entity/CallChainTree.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/entity/BreviaryChainTree.java @@ -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 nodes; + private List nodes; private AnlyResult entranceAnlyResult; - public CallChainTree(String treeId) { + public BreviaryChainTree(String treeId) { this.treeId = treeId; - nodes = new ArrayList(); + nodes = new ArrayList(); } public void setEntranceAnlyResult(AnlyResult entranceAnlyResult) { @@ -26,8 +25,8 @@ public class CallChainTree { public void addHitNodes(Map nodes) { for (Map.Entry 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() { + Collections.sort(nodes, new Comparator() { @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 nodes) { - for (CallChainNode node : nodes) { + public void addGuessNodesAndRemoveDuplicate(List 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 getNodes() { + public List getNodes() { return nodes; } @@ -84,7 +83,7 @@ public class CallChainTree { this.treeId = treeId; } - public void setNodes(List nodes) { + public void setNodes(List nodes) { this.nodes = nodes; } } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/impl/AnalysisResultService.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/impl/AnalysisResultService.java new file mode 100644 index 000000000..d2d185a4d --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/impl/AnalysisResultService.java @@ -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; + } +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/impl/CallChainTreeService.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/impl/CallChainTreeService.java index dc3ba0312..aca4fbcc9 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/impl/CallChainTreeService.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/impl/CallChainTreeService.java @@ -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 queryCallChainTreeByKey(String uid, String viewpoint, int pageSize) throws SQLException, IOException { - List trees = new ArrayList(); + public List queryCallChainTreeByKey(String uid, String viewpoint, int pageSize) throws SQLException, IOException { + List trees = new ArrayList(); List 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 doGuessNodes(HitTreeInfo hitTraceLevelIds) throws SQLException { - List guessNodes = new ArrayList(); + private List doGuessNodes(HitTreeInfo hitTraceLevelIds) throws SQLException { + List guessNodes = new ArrayList(); 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); } } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/inter/IAnalysisResultService.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/inter/IAnalysisResultService.java new file mode 100644 index 000000000..f29b090dc --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/inter/IAnalysisResultService.java @@ -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; +} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/inter/ICallChainTreeService.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/inter/ICallChainTreeService.java index 48a1f8002..6004db5a4 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/inter/ICallChainTreeService.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/inter/ICallChainTreeService.java @@ -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 queryCallChainTreeByKey(String uid, String viewpoint, int pageSize) throws SQLException, IOException; + List queryCallChainTreeByKey(String uid, String viewpoint, int pageSize) throws SQLException, IOException; } diff --git a/skywalking-webui/src/main/webapp/pages/anls-result/analysisResult.ftl b/skywalking-webui/src/main/webapp/pages/anls-result/analysisResult.ftl index 7d60e80f9..5e9cd8599 100644 --- a/skywalking-webui/src/main/webapp/pages/anls-result/analysisResult.ftl +++ b/skywalking-webui/src/main/webapp/pages/anls-result/analysisResult.ftl @@ -1,58 +1,26 @@ -<#macro anlyResultTmpl> - - + + -<#macro anlyResultDisplayTmpl> - - + + + +<@common.importResources /> + + + + + + + + + + + -<#macro pageInfoTmpl> - - \ No newline at end of file + +<@common.navbar/> +
+ +
+ + \ No newline at end of file diff --git a/skywalking-webui/src/main/webapp/pages/anls-result/analysisSearchResult.ftl b/skywalking-webui/src/main/webapp/pages/anls-result/analysisSearchResult.ftl new file mode 100644 index 000000000..7d60e80f9 --- /dev/null +++ b/skywalking-webui/src/main/webapp/pages/anls-result/analysisSearchResult.ftl @@ -0,0 +1,58 @@ +<#macro anlyResultTmpl> + + + +<#macro anlyResultDisplayTmpl> + + + +<#macro pageInfoTmpl> + + \ No newline at end of file diff --git a/skywalking-webui/src/main/webapp/pages/anls-result/anlysisResult b/skywalking-webui/src/main/webapp/pages/anls-result/anlysisResult new file mode 100644 index 000000000..e69de29bb diff --git a/skywalking-webui/src/main/webapp/pages/main.ftl b/skywalking-webui/src/main/webapp/pages/main.ftl index 8fabbbbbf..98d5d9d5a 100644 --- a/skywalking-webui/src/main/webapp/pages/main.ftl +++ b/skywalking-webui/src/main/webapp/pages/main.ftl @@ -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>