From a6ac3fad21de3c6b23cf5963cb67b9edfda0e8a8 Mon Sep 17 00:00:00 2001 From: Administrator <55846420@qq.com> Date: Tue, 1 Dec 2015 21:13:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?webUi=E9=85=8D=E5=90=88API=E6=94=B9?= =?UTF-8?q?=E9=80=A0=EF=BC=8C=E6=94=AF=E6=8C=81=E7=99=BB=E5=BD=95=EF=BC=8C?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2traceId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- skywalking-webui/pom.xml | 11 + .../controller/HelloSkyWalkingUICtl.java | 66 +++++- .../ai/cloud/dao/impl/BuriedPointSDAO.java | 36 ++- .../ai/cloud/dao/inter/IBuriedPointSDAO.java | 5 +- .../service/impl/QueryTraceLogSerImpl.java | 5 +- .../service/inter/IQueryTraceLogSer.java | 5 +- .../java/com/ai/cloud/util/Constants.java | 64 +++--- .../com/ai/cloud/util/common/RequestUtil.java | 4 +- .../com/ai/cloud/util/common/SortUtil.java | 33 +-- .../cloud/util/view/BaseFreeMarkerView.java | 23 +- .../com/ai/cloud/vo/mvo/BuriedPointEntry.java | 172 -------------- .../com/ai/cloud/vo/mvo/TimeLineEntry.java | 5 + .../com/ai/cloud/vo/mvo/TraceLogEntry.java | 213 ++++++++++++++++++ .../src/main/resources/jdbc.properties | 6 +- .../resources/spring/application-jdbc.xml | 14 +- .../src/main/webapp/css/traceLog.css | 12 +- .../src/main/webapp/ftl/index.ftl | 6 +- .../main/webapp/ftl/lib/ai.cloud/common.ftl | 134 ++++++++--- .../src/main/webapp/ftl/login.ftl | 44 +++- .../src/main/webapp/ftl/traceLog.ftl | 48 +++- .../src/main/webapp/js/webui-0.1.js | 10 +- 21 files changed, 609 insertions(+), 307 deletions(-) delete mode 100644 skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/BuriedPointEntry.java create mode 100644 skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/TraceLogEntry.java diff --git a/skywalking-webui/pom.xml b/skywalking-webui/pom.xml index b3f1c8bb6..13fb935b3 100644 --- a/skywalking-webui/pom.xml +++ b/skywalking-webui/pom.xml @@ -34,6 +34,12 @@ + + com.ai.cloud + skywalking-protocol + 1.0-SNAPSHOT + + org.springframework spring-webmvc @@ -103,5 +109,10 @@ hbase-client 1.1.2 + + org.aspectj + aspectjweaver + 1.8.7 + \ No newline at end of file diff --git a/skywalking-webui/src/main/java/com/ai/cloud/controller/HelloSkyWalkingUICtl.java b/skywalking-webui/src/main/java/com/ai/cloud/controller/HelloSkyWalkingUICtl.java index b0e7705bb..4df417c04 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/controller/HelloSkyWalkingUICtl.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/controller/HelloSkyWalkingUICtl.java @@ -9,6 +9,9 @@ import java.util.Comparator; import java.util.List; import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -16,12 +19,15 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; import com.ai.cloud.service.inter.IQueryTraceLogSer; +import com.ai.cloud.service.inter.IUserSer; import com.ai.cloud.util.Constants; -import com.ai.cloud.vo.mvo.BuriedPointEntry; - -import freemarker.template.SimpleSequence; +import com.ai.cloud.vo.mvo.TraceLogEntry; +import com.ai.cloud.vo.mvo.UserInfoMVO; +import com.alibaba.fastjson.JSONObject; /** * 首面请求处理 @@ -35,6 +41,9 @@ public class HelloSkyWalkingUICtl { @Autowired IQueryTraceLogSer traceLogSer; + + @Autowired + IUserSer userSer; private static Logger logger = LogManager.getLogger(HelloSkyWalkingUICtl.class); @@ -92,16 +101,16 @@ public class HelloSkyWalkingUICtl { @RequestMapping(value = "/showTraceLog/{traceId}") public String showTraceLog(ModelMap root, @PathVariable("traceId") String traceId) throws Exception { // traceId = "bcb759bc12db474aa54bc4bea605cb81123"; - Map traceLogMap = traceLogSer.queryLogByTraceId(traceId); + Map traceLogMap = traceLogSer.queryLogByTraceId(traceId); if (traceLogMap != null && traceLogMap.size() > 0) { - List valueList = new ArrayList(); + List valueList = new ArrayList(); valueList.addAll(traceLogMap.values()); final List endTime = new ArrayList(); endTime.add(0, 0l); - Collections.sort(valueList, new Comparator() { + Collections.sort(valueList, new Comparator() { @Override - public int compare(BuriedPointEntry arg0, BuriedPointEntry arg1) { + public int compare(TraceLogEntry arg0, TraceLogEntry arg1) { /** 顺道取出日志最大的结束时间 */ if (endTime.get(0) < arg0.getEndDate()) { endTime.set(0, arg0.getEndDate()); @@ -112,11 +121,12 @@ public class HelloSkyWalkingUICtl { return arg0.getColId().compareTo(arg1.getColId()); } }); - // int m = 1; - // for (BuriedPointEntry tmpEntry : valueList) { - // logger.info("sort result level:{} : {}", m++, tmpEntry); - // } + int m = 1; + for (TraceLogEntry tmpEntry : valueList) { + logger.info("sort result level:{} : {}", m++, tmpEntry); + } long beginTime = valueList.get(0).getStartDate(); + root.put("traceId", traceId); root.put("valueList", valueList); root.put("spanTypeMap", Constants.SPAN_TYPE_MAP); root.put("statusCodeMap", Constants.STATUS_CODE_MAP); @@ -134,9 +144,41 @@ public class HelloSkyWalkingUICtl { * @throws Exception */ @RequestMapping(value = "/login") - public String login(ModelMap root) throws Exception { + public String loginPage(ModelMap root) throws Exception { return "login"; } + + /*** + * 登录页面 + * + * @param root + * @return + * @throws Exception + */ + + @RequestMapping(value = "/login/{userName}/{password}", method = RequestMethod.POST, produces="application/json; charset=UTF-8") + @ResponseBody + public String loginAction(HttpServletRequest request, ModelMap root, @PathVariable("userName") String userName, @PathVariable("password") String password) throws Exception { + UserInfoMVO userInfo = new UserInfoMVO(); + userInfo.setUserName(userName); + userInfo.setPassword(password); + UserInfoMVO reUserInfo = userSer.login(userInfo); + JSONObject json = new JSONObject(); + if(reUserInfo != null && password.equals(reUserInfo.getPassword())){ + json.put("result", "OK"); + json.put("msg", "登录成功"); + + HttpSession session = request.getSession(); + session.setAttribute("isLogin", "1"); + session.setAttribute("uid", reUserInfo.getUid()); + session.setAttribute("userName", reUserInfo.getUserName()); + session.setAttribute("menuList", ""); + }else{ + json.put("result", "FAIL"); + json.put("msg", "用户名或者密码错误"); + } + return json.toJSONString(); + } /*** * 退出 diff --git a/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/BuriedPointSDAO.java b/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/BuriedPointSDAO.java index 7438e8f4c..3a64ba6ca 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/BuriedPointSDAO.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/dao/impl/BuriedPointSDAO.java @@ -4,6 +4,7 @@ package com.ai.cloud.dao.impl; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -22,8 +23,8 @@ import com.ai.cloud.dao.inter.IBuriedPointSDAO; import com.ai.cloud.util.Constants; import com.ai.cloud.util.HBaseConnectionUtil; import com.ai.cloud.util.common.SortUtil; -import com.ai.cloud.vo.mvo.BuriedPointEntry; -import com.sun.tools.internal.ws.wsdl.framework.Entity; +import com.ai.cloud.util.common.StringUtil; +import com.ai.cloud.vo.mvo.TraceLogEntry; /** * @@ -43,20 +44,22 @@ public class BuriedPointSDAO implements IBuriedPointSDAO { * @param traceId * @return * @throws IOException + * @throws NoSuchMethodException + * @throws InvocationTargetException + * @throws IllegalAccessException */ - public Map queryLogByTraceId(String tableName, String traceId) throws IOException { + public Map queryLogByTraceId(String tableName, String traceId) throws IOException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { Table table = HBaseConnectionUtil.getConnection().getTable(TableName.valueOf(tableName)); Get g = new Get(Bytes.toBytes(traceId)); Result r = table.get(g); - Map traceLogMap = new HashMap(); - Map rpcMap = new HashMap(); + Map traceLogMap = new HashMap(); + Map rpcMap = new HashMap(); for (Cell cell : r.rawCells()) { if (cell.getValueArray().length > 0) { String colId = Bytes.toString(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); - BuriedPointEntry tmpEntry = BuriedPointEntry.convert( + TraceLogEntry tmpEntry = TraceLogEntry.convert( Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()), colId); - System.out.println("=========" + tmpEntry); // 特殊处理RPC的服务端信息 if (colId.endsWith(Constants.RPC_END_FLAG)) { rpcMap.put(colId.substring(0, colId.lastIndexOf(Constants.RPC_END_FLAG)), tmpEntry); @@ -75,13 +78,26 @@ public class BuriedPointSDAO implements IBuriedPointSDAO { * @param rpcMap * @param traceLogMap */ - private void computeRPCInfo(Map rpcMap, Map traceLogMap) { + private void computeRPCInfo(Map rpcMap, Map traceLogMap) { // 合并处理 if (rpcMap.size() > 0) { - for (Entry rpcVO : rpcMap.entrySet()) { + for (Entry rpcVO : rpcMap.entrySet()) { String colId = rpcVO.getKey(); if(traceLogMap.containsKey(colId)){ - BuriedPointEntry logVO = traceLogMap.get(colId); + TraceLogEntry logVO = traceLogMap.get(colId); + TraceLogEntry serverLog = rpcVO.getValue(); + //如果RPC client端为空,则用server端信息 + if(StringUtil.isBlank(logVO.getStatusCodeStr()) || Constants.STATUS_CODE_9.equals(logVO.getStatusCodeStr())){ + serverLog.setColId(colId); + traceLogMap.put(colId, serverLog); + }else{ + TraceLogEntry clientLog = traceLogMap.get(colId); + //客户端RPC显示特殊处理 + clientLog.setApplicationIdStr(clientLog.getApplicationIdStr() + " --> " + serverLog.getApplicationIdStr()); + clientLog.setViewPointId(serverLog.getViewPointId()); + clientLog.setViewPointIdSub(serverLog.getViewPointIdSub()); + clientLog.setAddress(serverLog.getAddress()); + } logVO.addTimeLine(rpcVO.getValue().getStartDate(), rpcVO.getValue().getCost()); } } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/dao/inter/IBuriedPointSDAO.java b/skywalking-webui/src/main/java/com/ai/cloud/dao/inter/IBuriedPointSDAO.java index 43e7c2a73..95ccd8bd4 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/dao/inter/IBuriedPointSDAO.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/dao/inter/IBuriedPointSDAO.java @@ -4,9 +4,10 @@ package com.ai.cloud.dao.inter; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.util.Map; -import com.ai.cloud.vo.mvo.BuriedPointEntry; +import com.ai.cloud.vo.mvo.TraceLogEntry; /** * @@ -16,6 +17,6 @@ import com.ai.cloud.vo.mvo.BuriedPointEntry; */ public interface IBuriedPointSDAO { - public Map queryLogByTraceId(String tableName, String traceId) throws IOException; + public Map queryLogByTraceId(String tableName, String traceId) throws IOException, IllegalAccessException, InvocationTargetException, NoSuchMethodException; } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/service/impl/QueryTraceLogSerImpl.java b/skywalking-webui/src/main/java/com/ai/cloud/service/impl/QueryTraceLogSerImpl.java index f332882a4..a6e30a2cc 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/service/impl/QueryTraceLogSerImpl.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/service/impl/QueryTraceLogSerImpl.java @@ -4,6 +4,7 @@ package com.ai.cloud.service.impl; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; @@ -12,7 +13,7 @@ import org.springframework.stereotype.Service; import com.ai.cloud.dao.inter.IBuriedPointSDAO; import com.ai.cloud.service.inter.IQueryTraceLogSer; import com.ai.cloud.util.Constants; -import com.ai.cloud.vo.mvo.BuriedPointEntry; +import com.ai.cloud.vo.mvo.TraceLogEntry; /** * @@ -27,7 +28,7 @@ public class QueryTraceLogSerImpl implements IQueryTraceLogSer { IBuriedPointSDAO buriedPointSDAO; @Override - public Map queryLogByTraceId(String traceId) throws IOException { + public Map queryLogByTraceId(String traceId) throws IOException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { return buriedPointSDAO.queryLogByTraceId(Constants.TABLE_NAME_CHAIN, traceId); } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/service/inter/IQueryTraceLogSer.java b/skywalking-webui/src/main/java/com/ai/cloud/service/inter/IQueryTraceLogSer.java index 45cea8b27..889381763 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/service/inter/IQueryTraceLogSer.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/service/inter/IQueryTraceLogSer.java @@ -4,9 +4,10 @@ package com.ai.cloud.service.inter; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.util.Map; -import com.ai.cloud.vo.mvo.BuriedPointEntry; +import com.ai.cloud.vo.mvo.TraceLogEntry; /** * @@ -16,6 +17,6 @@ import com.ai.cloud.vo.mvo.BuriedPointEntry; */ public interface IQueryTraceLogSer { - public Map queryLogByTraceId(String traceId) throws IOException; + public Map queryLogByTraceId(String traceId) throws IOException, IllegalAccessException, InvocationTargetException, NoSuchMethodException; } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/util/Constants.java b/skywalking-webui/src/main/java/com/ai/cloud/util/Constants.java index 37a1f0bcc..2943b2000 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/util/Constants.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/util/Constants.java @@ -8,50 +8,54 @@ import java.util.Map; /** * 常量类 + * * @author tz * @date 2015年11月10日 下午2:51:25 * @version V0.1 */ public class Constants { - + public static final String VERSION_STR = "version"; - + public static final String VERSION_VAL = "0.1"; - - /** hbase集群*/ + + /** hbase集群 */ public static final String QUORUM = "10.1.235.197,10.1.235.198,10.1.235.199"; - /** zk端口*/ + /** zk端口 */ public static final String CLIENT_PORT = "29181"; - /** hbase表名*/ + /** hbase表名 */ public static final String TABLE_NAME_CHAIN = "sw-call-chain"; - /**层级分割符*/ + /** 层级分割符 */ public static final char VAL_SPLIT_CHAR = '.'; - /** RPC远端调用节点结束标识*/ + /** RPC远端调用节点结束标识 */ public static final String RPC_END_FLAG = "-S"; - + public static final String SPAN_TYPE_M = "M"; public static final String SPAN_TYPE_J = "J"; public static final String SPAN_TYPE_W = "W"; public static final String SPAN_TYPE_D = "D"; - /** SPAN_TYPE码表*/ - public static Map SPAN_TYPE_MAP = new HashMap(){{ - put("M", "JAVA"); - put("J", "JDBC"); - put("W", "WEB SERVLET"); - put("D", "DUBBO/DUBBOX"); - }}; - - public static final char STATUS_CODE_0 = '0'; - public static final char STATUS_CODE_1 = '1'; - public static final char STATUS_CODE_9 = '9'; - /** STATUS_CODE码表*/ - public static Map STATUS_CODE_MAP = new HashMap(){{ - put("0", "OK"); - put("1", "FAIL"); - put("9", "MISSING"); - }}; - - - - + public static final String SPAN_TYPE_U = "U"; + /** SPAN_TYPE码表 */ + public static Map SPAN_TYPE_MAP = new HashMap() { + { + put("M", "JAVA"); + put("J", "JDBC"); + put("W", "WEB"); + put("D", "DUBBO"); + put("U", "UNKNOWN"); + } + }; + + public static final String STATUS_CODE_0 = "0"; + public static final String STATUS_CODE_1 = "1"; + public static final String STATUS_CODE_9 = "9"; + /** STATUS_CODE码表 */ + public static Map STATUS_CODE_MAP = new HashMap() { + { + put("0", "OK"); + put("1", "FAIL"); + put("9", "MISSING"); + } + }; + } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/util/common/RequestUtil.java b/skywalking-webui/src/main/java/com/ai/cloud/util/common/RequestUtil.java index 2275a48d9..0f1fd492b 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/util/common/RequestUtil.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/util/common/RequestUtil.java @@ -14,13 +14,13 @@ import javax.servlet.http.HttpServletRequest; public class RequestUtil { /*** * 获取web应用根路径 + * * @param request * @return */ public static String getAppWebBase(HttpServletRequest request) { String path = request.getContextPath(); - String base = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path - + "/"; + String base = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; return base; } } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/util/common/SortUtil.java b/skywalking-webui/src/main/java/com/ai/cloud/util/common/SortUtil.java index c7037936d..e2cb45e53 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/util/common/SortUtil.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/util/common/SortUtil.java @@ -4,6 +4,7 @@ package com.ai.cloud.util.common; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -18,7 +19,7 @@ import org.junit.Test; import com.ai.cloud.dao.impl.BuriedPointSDAO; import com.ai.cloud.util.Constants; -import com.ai.cloud.vo.mvo.BuriedPointEntry; +import com.ai.cloud.vo.mvo.TraceLogEntry; /** * @@ -37,8 +38,8 @@ public class SortUtil { * @param colId * @param tmpEntry */ - public static void addCurNodeTreeMapKey(Map reMap, String colId, - BuriedPointEntry tmpEntry) { + public static void addCurNodeTreeMapKey(Map reMap, String colId, + TraceLogEntry tmpEntry) { reMap.put(colId, tmpEntry); // 根据当前Id查找上级,如果不存在,插入空,再看上级,如果不存在还插入空,直到根"0" while (colId.indexOf(Constants.VAL_SPLIT_CHAR) > -1) { @@ -56,13 +57,12 @@ public class SortUtil { * @param colId * @return */ - private static boolean addParentNodeTreeMapKey(Map reMap, String colId) { + private static boolean addParentNodeTreeMapKey(Map reMap, String colId) { if (reMap.containsKey(colId)) { - logger.info("key hash exist: {}", colId); return false; } else { // 增加虚拟节点 - reMap.put(colId, BuriedPointEntry.addLostBuriedPointEntry(colId)); + reMap.put(colId, TraceLogEntry.addLostBuriedPointEntry(colId)); // 根据当前Id查找上级,如果不存在,插入空,再看上级,如果不存在还插入空,直到根"0" while (colId.indexOf(Constants.VAL_SPLIT_CHAR) > -1) { colId = colId.substring(0, colId.lastIndexOf(Constants.VAL_SPLIT_CHAR)); @@ -78,27 +78,30 @@ public class SortUtil { * 测试读取hbase 测试自动补充父级节点 测试排序 * * @throws IOException + * @throws NoSuchMethodException + * @throws InvocationTargetException + * @throws IllegalAccessException * */ @Test - public void testSelectByTraceId() throws IOException { + public void testSelectByTraceId() throws IOException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { BuriedPointSDAO sdao = new BuriedPointSDAO(); - Map bpe = sdao.queryLogByTraceId(Constants.TABLE_NAME_CHAIN, - "6305eb1d1e1b46529a7eb57912a5766e123"); + Map bpe = sdao.queryLogByTraceId(Constants.TABLE_NAME_CHAIN, + "71e28364128847b3a12626966b60fd8f123"); - List keyList = new ArrayList(); + List keyList = new ArrayList(); keyList.addAll(bpe.values()); - Collections.sort(keyList, new Comparator() { + Collections.sort(keyList, new Comparator() { @Override - public int compare(BuriedPointEntry arg0, BuriedPointEntry arg1) { + public int compare(TraceLogEntry arg0, TraceLogEntry arg1) { return arg0.getColId().compareTo(arg1.getColId()); } }); int m = 1; - for (BuriedPointEntry tmpEntry : keyList) { + for (TraceLogEntry tmpEntry : keyList) { logger.info("sort result level:{} : {}", m++, tmpEntry); } @@ -125,8 +128,8 @@ public class SortUtil { } String colId = sb.toString(); - BuriedPointEntry tmpEntry = null; - Map reMap = new HashMap(); + TraceLogEntry tmpEntry = null; + Map reMap = new HashMap(); long startTime = System.currentTimeMillis(); logger.info("start time : {}", startTime); diff --git a/skywalking-webui/src/main/java/com/ai/cloud/util/view/BaseFreeMarkerView.java b/skywalking-webui/src/main/java/com/ai/cloud/util/view/BaseFreeMarkerView.java index c038e1742..68c5e136d 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/util/view/BaseFreeMarkerView.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/util/view/BaseFreeMarkerView.java @@ -3,12 +3,14 @@ package com.ai.cloud.util.view; import java.util.Map; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.web.servlet.view.freemarker.FreeMarkerView; import com.ai.cloud.util.common.RequestUtil; +import com.ai.cloud.util.common.StringUtil; /** * 自定义视图处理类 @@ -31,11 +33,26 @@ public class BaseFreeMarkerView extends FreeMarkerView { String base = RequestUtil.getAppWebBase(request); model.put(CONTEXT_PATH, base); - model.put("userInfo", "{'isLogin':'0','uid':'10000','userName':'tanzhen'}"); + HttpSession session = request.getSession(); - model.put("isLogin", "{'isLogin':'0'}"); + String isLogin = (String) session.getAttribute("isLogin"); + if(StringUtil.isBlank(isLogin)){ + isLogin = "0"; + } + String uid = (String) session.getAttribute("uid"); + if(StringUtil.isBlank(uid)){ + uid = "0"; + } + String userName = (String) session.getAttribute("userName"); + if(StringUtil.isBlank(userName)){ + userName = ""; + } + String menuList = (String) session.getAttribute("menuList"); + if(StringUtil.isBlank(menuList)){ + menuList = ""; + } - model.put("menuInfo", "{'isLogin':'0','uid':'10000','menuList':'tanzhen'}"); + model.put("userInfo", "{'isLogin':'" + isLogin + "','uid':'" + uid + "','userName':'" + userName + "','menuList':'" + menuList + "'}"); super.exposeHelpers(model, request); } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/BuriedPointEntry.java b/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/BuriedPointEntry.java deleted file mode 100644 index 1d5ebbad5..000000000 --- a/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/BuriedPointEntry.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.ai.cloud.vo.mvo; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import com.ai.cloud.util.Constants; - -/*** - * hbase存储的链路信息模型 - * - * @author tz - * @date 2015年11月18日 下午5:45:14 - * @version V0.1 - */ -public class BuriedPointEntry { - private String traceId; - private String parentLevel; - private int levelId; - private String viewPointId; - private long startDate; - private long cost; - private String address; - private char statusCode = Constants.STATUS_CODE_9; - private String exceptionStack; - private char spanType; - private boolean isReceiver = false; - private String businessKey; - private String processNo; - - private String colId; - private long endDate; - private List timeLineList = new ArrayList(); - - private BuriedPointEntry() { - - } - - public String getTraceId() { - return traceId; - } - - public String getParentLevel() { - return parentLevel; - } - - public int getLevelId() { - return levelId; - } - - public String getViewPointId() { - return viewPointId; - } - - public long getStartDate() { - return startDate; - } - - public long getCost() { - return cost; - } - - public String getAddress() { - return address; - } - - public char getStatusCode() { - return statusCode; - } - - public String getExceptionStack() { - return exceptionStack; - } - - public char getSpanType() { - return spanType; - } - - public boolean isReceiver() { - return isReceiver; - } - - public String getBusinessKey() { - return businessKey; - } - - public String getProcessNo() { - return processNo; - } - - public String getColId() { - return colId; - } - - public void setColId(String colId) { - this.colId = colId; - } - - public long getEndDate() { - return endDate; - } - - public List getTimeLineList() { - return timeLineList; - } - - private static BuriedPointEntry convert(String str) { - BuriedPointEntry result = new BuriedPointEntry(); - String[] fieldValues = str.split("\\^\\~"); - result.traceId = fieldValues[0].trim(); - result.parentLevel = fieldValues[1].trim(); - result.levelId = Integer.valueOf(fieldValues[2]); - result.viewPointId = fieldValues[3].trim(); - result.startDate = Long.valueOf(fieldValues[4]); - result.cost = Long.parseLong(fieldValues[5]); - result.address = fieldValues[6].trim(); - result.statusCode = fieldValues[7].charAt(0); - result.exceptionStack = fieldValues[8].trim(); - result.spanType = fieldValues[9].charAt(0); - result.isReceiver = Boolean.getBoolean(fieldValues[10]); - result.businessKey = fieldValues[11].trim(); - result.processNo = fieldValues[12].trim(); - return result; - } - - /*** - * 增加时间轴信息 - * @param startDate - * @param cost - */ - public void addTimeLine(long startDate, long cost) { - timeLineList.add(new TimeLineEntry(startDate, cost)); - } - - public static BuriedPointEntry convert(String str, String colId) { - BuriedPointEntry result = convert(str); - result.addTimeLine(result.startDate, result.cost); - result.colId = colId; - result.endDate = result.startDate + result.cost; - return result; - } - - /*** - * 补充丢失的链路信息 - * - * @param colId - * @return - */ - public static BuriedPointEntry addLostBuriedPointEntry(String colId) { - BuriedPointEntry result = new BuriedPointEntry(); - result.colId = colId; - if (colId.indexOf(Constants.VAL_SPLIT_CHAR) > -1) { - result.parentLevel = colId.substring(0, colId.lastIndexOf(Constants.VAL_SPLIT_CHAR)); - } else { - result.parentLevel = ""; - } - result.timeLineList.add(new TimeLineEntry()); - - // 其它默认值 - return result; - } - - @Override - public String toString() { - return "BuriedPointEntry [colId=" + colId + ", traceId=" + traceId + ", parentLevel=" + parentLevel - + ", levelId=" + levelId + ", viewPointId=" + viewPointId + ", startDate=" + startDate + ", cost=" - + cost + ", address=" + address + ", statusCode=" + statusCode + ", exceptionStack=" + exceptionStack - + ", spanType=" + spanType + ", isReceiver=" + isReceiver + ", businessKey=" + businessKey - + ", processNo=" + processNo + "]"; - } - -} diff --git a/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/TimeLineEntry.java b/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/TimeLineEntry.java index 49b80630f..a021c44c3 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/TimeLineEntry.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/TimeLineEntry.java @@ -40,4 +40,9 @@ public class TimeLineEntry { public void setCost(long cost) { this.cost = cost; } + + @Override + public String toString() { + return "TimeLineEntry [startTime=" + startTime + ", cost=" + cost + "]"; + } } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/TraceLogEntry.java b/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/TraceLogEntry.java new file mode 100644 index 000000000..b2e693af7 --- /dev/null +++ b/skywalking-webui/src/main/java/com/ai/cloud/vo/mvo/TraceLogEntry.java @@ -0,0 +1,213 @@ +package com.ai.cloud.vo.mvo; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.commons.beanutils.PropertyUtils; + +import com.ai.cloud.skywalking.protocol.Span; +import com.ai.cloud.util.Constants; +import com.ai.cloud.util.common.StringUtil; + +/*** + * hbase存储的链路信息模型 + * + * @author tz + * @date 2015年11月18日 下午5:45:14 + * @version V0.1 + */ +public class TraceLogEntry extends Span { + + private String colId; + + private long endDate; + + private List timeLineList = new ArrayList() { + private static final long serialVersionUID = 1L; + + @Override + public String toString() { + Iterator it = this.iterator(); + return it.hasNext() ? it.next().toString() : ""; + }; + }; + + private String spanTypeStr; + + private String spanTypeName; + + private String statusCodeStr; + + private String statusCodeName; + + private String applicationIdStr; + + private String viewPointIdSub; + + private TraceLogEntry() { + + } + + private TraceLogEntry(String str) { + super(str); + } + + public String getColId() { + return colId; + } + + public void setColId(String colId) { + this.colId = colId; + } + + public long getEndDate() { + return endDate; + } + + public void setEndDate(long endDate) { + this.endDate = endDate; + } + + public List getTimeLineList() { + return timeLineList; + } + + public void setTimeLineList(List timeLineList) { + this.timeLineList = timeLineList; + } + + public String getSpanTypeStr() { + return spanTypeStr; + } + + public void setSpanTypeStr(String spanTypeStr) { + this.spanTypeStr = spanTypeStr; + } + + public String getSpanTypeName() { + return spanTypeName; + } + + public void setSpanTypeName(String spanTypeName) { + this.spanTypeName = spanTypeName; + } + + public String getStatusCodeStr() { + return statusCodeStr; + } + + public void setStatusCodeStr(String statusCodeStr) { + this.statusCodeStr = statusCodeStr; + } + + public String getStatusCodeName() { + return statusCodeName; + } + + public void setStatusCodeName(String statusCodeName) { + this.statusCodeName = statusCodeName; + } + + public String getApplicationIdStr() { + return applicationIdStr; + } + + public void setApplicationIdStr(String applicationIdStr) { + this.applicationIdStr = applicationIdStr; + } + + public String getViewPointIdSub() { + return viewPointIdSub; + } + + public void setViewPointIdSub(String viewPointIdSub) { + this.viewPointIdSub = viewPointIdSub; + } + + private static TraceLogEntry convert(String str) + throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + TraceLogEntry result = new TraceLogEntry(str); + + // 处理类型key-value + String spanTypeStr = String.valueOf(result.getSpanType()); + if (StringUtil.isBlank(spanTypeStr) || Constants.SPAN_TYPE_MAP.containsKey(spanTypeStr)) { + result.spanTypeStr = Constants.SPAN_TYPE_U; + } + String spanTypeName = Constants.SPAN_TYPE_MAP.get(spanTypeStr); + result.spanTypeStr = spanTypeStr; + result.spanTypeName = spanTypeName; + + // 处理状态key-value + String statusCodeStr = String.valueOf(result.getStatusCode()); + if (StringUtil.isBlank(statusCodeStr) || Constants.STATUS_CODE_MAP.containsKey(statusCodeStr)) { + result.statusCodeStr = Constants.STATUS_CODE_9; + } + String statusCodeName = Constants.STATUS_CODE_MAP.get(statusCodeStr); + result.statusCodeStr = statusCodeStr; + result.statusCodeName = statusCodeName; + + result.applicationIdStr = result.applicationId; + if (!StringUtil.isBlank(result.viewPointId) && result.viewPointId.length() > 40) { + result.viewPointIdSub = result.viewPointId.substring(0, 20) + "..." + + result.viewPointId.substring(result.viewPointId.length() - 20); + } else { + result.viewPointIdSub = result.viewPointId; + } + + result.addTimeLine(result.startDate, result.cost); + result.endDate = result.startDate + result.cost; + return result; + } + + /*** + * 增加时间轴信息 + * + * @param startDate + * @param cost + */ + public void addTimeLine(long startDate, long cost) { + timeLineList.add(new TimeLineEntry(startDate, cost)); + } + + public static TraceLogEntry convert(String str, String colId) + throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + TraceLogEntry result = convert(str); + result.colId = colId; + return result; + } + + /*** + * 补充丢失的链路信息 + * + * @param colId + * @return + */ + public static TraceLogEntry addLostBuriedPointEntry(String colId) { + TraceLogEntry result = new TraceLogEntry(); + result.colId = colId; + if (colId.indexOf(Constants.VAL_SPLIT_CHAR) > -1) { + result.parentLevel = colId.substring(0, colId.lastIndexOf(Constants.VAL_SPLIT_CHAR)); + } else { + result.parentLevel = ""; + } + result.timeLineList.add(new TimeLineEntry()); + + // 其它默认值 + return result; + } + + @Override + public String toString() { + return "TraceLogEntry [colId=" + colId + ", endDate=" + endDate + ", timeLineList=" + timeLineList + + ", spanTypeStr=" + spanTypeStr + ", spanTypeName=" + spanTypeName + ", statusCodeStr=" + statusCodeStr + + ", statusCodeName=" + statusCodeName + ", applicationIdStr=" + applicationIdStr + ", viewPointIdSub=" + + viewPointIdSub + ", traceId=" + traceId + ", parentLevel=" + parentLevel + ", levelId=" + levelId + + ", viewPointId=" + viewPointId + ", startDate=" + startDate + ", cost=" + cost + ", address=" + + address + ", statusCode=" + statusCode + ", exceptionStack=" + exceptionStack + ", spanType=" + + spanType + ", isReceiver=" + isReceiver + ", businessKey=" + businessKey + ", processNo=" + processNo + + ", applicationId=" + applicationId + ", originData=" + originData + "]"; + } + +} diff --git a/skywalking-webui/src/main/resources/jdbc.properties b/skywalking-webui/src/main/resources/jdbc.properties index 2cbdf3dac..e2a8c694f 100644 --- a/skywalking-webui/src/main/resources/jdbc.properties +++ b/skywalking-webui/src/main/resources/jdbc.properties @@ -1,7 +1,7 @@ jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://10.1.228.202:31316/test -jdbc.username=devrdbusr21 -jdbc.password=devrdbusr21 +jdbc.url=jdbc:mysql://10.1.228.200:31306/test +jdbc.username=devrdbusr13 +jdbc.password=devrdbusr13 jdbc.maxTotal=200 jdbc.maxIdle=50 jdbc.maxWaitMillis=1000 diff --git a/skywalking-webui/src/main/resources/spring/application-jdbc.xml b/skywalking-webui/src/main/resources/spring/application-jdbc.xml index f356a0353..265dbc87c 100644 --- a/skywalking-webui/src/main/resources/spring/application-jdbc.xml +++ b/skywalking-webui/src/main/resources/spring/application-jdbc.xml @@ -4,6 +4,7 @@ xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:lang="http://www.springframework.org/schema/lang" + xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context @@ -11,7 +12,9 @@ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/tx - http://www.springframework.org/schema/tx/spring-tx-3.0.xsd + http://www.springframework.org/schema/tx/spring-tx-3.0.xsd + http://www.springframework.org/schema/aop + http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd"> @@ -35,8 +38,6 @@ class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> - - @@ -44,5 +45,10 @@ - + + + + + + \ No newline at end of file diff --git a/skywalking-webui/src/main/webapp/css/traceLog.css b/skywalking-webui/src/main/webapp/css/traceLog.css index 69eba7d2a..68ad03612 100644 --- a/skywalking-webui/src/main/webapp/css/traceLog.css +++ b/skywalking-webui/src/main/webapp/css/traceLog.css @@ -13,9 +13,19 @@ body { } .progress-bar-white { background-image: none; - background-color: FFFFFF; + background-color: #FFFFFF; } .highlight { background-color: #D8ECF6; } +.progress-bar-a { + background-color: #f0ad4e; +} +.progress-bar-b { + background-color: #5cb85c; +} +.progress-bar-c { + background-color: #5bc0de; +} + diff --git a/skywalking-webui/src/main/webapp/ftl/index.ftl b/skywalking-webui/src/main/webapp/ftl/index.ftl index a0d1e1d61..a6b9a013a 100644 --- a/skywalking-webui/src/main/webapp/ftl/index.ftl +++ b/skywalking-webui/src/main/webapp/ftl/index.ftl @@ -21,10 +21,10 @@
-
+
diff --git a/skywalking-webui/src/main/webapp/ftl/lib/ai.cloud/common.ftl b/skywalking-webui/src/main/webapp/ftl/lib/ai.cloud/common.ftl index 325a17f48..36ee399ed 100644 --- a/skywalking-webui/src/main/webapp/ftl/lib/ai.cloud/common.ftl +++ b/skywalking-webui/src/main/webapp/ftl/lib/ai.cloud/common.ftl @@ -10,7 +10,7 @@ <#macro importMenuInfo menuInfo>