Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
7cfde3a243
|
|
@ -34,6 +34,12 @@
|
|||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.ai.cloud</groupId>
|
||||
<artifactId>skywalking-protocol</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
|
|
@ -103,5 +109,10 @@
|
|||
<artifactId>hbase-client</artifactId>
|
||||
<version>1.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>1.8.7</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -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<String, BuriedPointEntry> traceLogMap = traceLogSer.queryLogByTraceId(traceId);
|
||||
Map<String, TraceLogEntry> traceLogMap = traceLogSer.queryLogByTraceId(traceId);
|
||||
|
||||
if (traceLogMap != null && traceLogMap.size() > 0) {
|
||||
List<BuriedPointEntry> valueList = new ArrayList<BuriedPointEntry>();
|
||||
List<TraceLogEntry> valueList = new ArrayList<TraceLogEntry>();
|
||||
valueList.addAll(traceLogMap.values());
|
||||
final List<Long> endTime = new ArrayList<Long>();
|
||||
endTime.add(0, 0l);
|
||||
Collections.sort(valueList, new Comparator<BuriedPointEntry>() {
|
||||
Collections.sort(valueList, new Comparator<TraceLogEntry>() {
|
||||
@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();
|
||||
}
|
||||
|
||||
/***
|
||||
* 退出
|
||||
|
|
|
|||
|
|
@ -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<String, BuriedPointEntry> queryLogByTraceId(String tableName, String traceId) throws IOException {
|
||||
public Map<String, TraceLogEntry> 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<String, BuriedPointEntry> traceLogMap = new HashMap<String, BuriedPointEntry>();
|
||||
Map<String, BuriedPointEntry> rpcMap = new HashMap<String, BuriedPointEntry>();
|
||||
Map<String, TraceLogEntry> traceLogMap = new HashMap<String, TraceLogEntry>();
|
||||
Map<String, TraceLogEntry> rpcMap = new HashMap<String, TraceLogEntry>();
|
||||
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<String, BuriedPointEntry> rpcMap, Map<String, BuriedPointEntry> traceLogMap) {
|
||||
private void computeRPCInfo(Map<String, TraceLogEntry> rpcMap, Map<String, TraceLogEntry> traceLogMap) {
|
||||
// 合并处理
|
||||
if (rpcMap.size() > 0) {
|
||||
for (Entry<String, BuriedPointEntry> rpcVO : rpcMap.entrySet()) {
|
||||
for (Entry<String, TraceLogEntry> 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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
package com.ai.cloud.dao.impl;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowCallbackHandler;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ai.cloud.dao.inter.IUserInfoMDAO;
|
||||
import com.ai.cloud.vo.mvo.UserInfoMVO;
|
||||
|
||||
@Repository
|
||||
public class UserInfoMDAO implements IUserInfoMDAO {
|
||||
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
private static Logger logger = LogManager.getLogger(UserInfoMDAO.class);
|
||||
|
||||
@Override
|
||||
public UserInfoMVO queryUserInfoByName(String userName) {
|
||||
final UserInfoMVO userInfo = new UserInfoMVO();
|
||||
String sql = "select uid,user_name,password from user_info where user_name = ? ";
|
||||
final Object[] params = new Object[] { userName };
|
||||
jdbcTemplate.query(sql, params, new RowCallbackHandler() {
|
||||
@Override
|
||||
public void processRow(ResultSet rs) throws SQLException {
|
||||
userInfo.setUid(rs.getString("uid"));
|
||||
userInfo.setUserName(rs.getString("user_name"));
|
||||
userInfo.setPassword(rs.getString("password"));
|
||||
}
|
||||
});
|
||||
logger.info("result : {}", userInfo);
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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<String, BuriedPointEntry> queryLogByTraceId(String tableName, String traceId) throws IOException;
|
||||
public Map<String, TraceLogEntry> queryLogByTraceId(String tableName, String traceId) throws IOException, IllegalAccessException, InvocationTargetException, NoSuchMethodException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package com.ai.cloud.dao.inter;
|
||||
|
||||
import com.ai.cloud.vo.mvo.UserInfoMVO;
|
||||
|
||||
public interface IUserInfoMDAO {
|
||||
|
||||
public UserInfoMVO queryUserInfoByName(String userName);
|
||||
|
||||
}
|
||||
|
|
@ -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<String, BuriedPointEntry> queryLogByTraceId(String traceId) throws IOException {
|
||||
public Map<String, TraceLogEntry> queryLogByTraceId(String traceId) throws IOException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
|
||||
return buriedPointSDAO.queryLogByTraceId(Constants.TABLE_NAME_CHAIN, traceId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package com.ai.cloud.service.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ai.cloud.dao.inter.IUserInfoMDAO;
|
||||
import com.ai.cloud.service.inter.IUserSer;
|
||||
import com.ai.cloud.vo.mvo.UserInfoMVO;
|
||||
|
||||
@Service
|
||||
public class UserSerImpl implements IUserSer {
|
||||
|
||||
@Autowired
|
||||
IUserInfoMDAO userInfoMDAO;
|
||||
|
||||
@Override
|
||||
public UserInfoMVO login(UserInfoMVO userInfo){
|
||||
String userName = userInfo.getUserName();
|
||||
userInfo = userInfoMDAO.queryUserInfoByName(userName);
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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<String, BuriedPointEntry> queryLogByTraceId(String traceId) throws IOException;
|
||||
public Map<String, TraceLogEntry> queryLogByTraceId(String traceId) throws IOException, IllegalAccessException, InvocationTargetException, NoSuchMethodException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package com.ai.cloud.service.inter;
|
||||
|
||||
import com.ai.cloud.vo.mvo.UserInfoMVO;
|
||||
|
||||
public interface IUserSer {
|
||||
|
||||
public UserInfoMVO login(UserInfoMVO userInfo);
|
||||
|
||||
}
|
||||
|
|
@ -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<String,String> SPAN_TYPE_MAP = new HashMap<String,String>(){{
|
||||
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<String,String> STATUS_CODE_MAP = new HashMap<String,String>(){{
|
||||
put("0", "OK");
|
||||
put("1", "FAIL");
|
||||
put("9", "MISSING");
|
||||
}};
|
||||
|
||||
|
||||
|
||||
|
||||
public static final String SPAN_TYPE_U = "U";
|
||||
/** SPAN_TYPE码表 */
|
||||
public static Map<String, String> SPAN_TYPE_MAP = new HashMap<String, String>() {
|
||||
{
|
||||
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<String, String> STATUS_CODE_MAP = new HashMap<String, String>() {
|
||||
{
|
||||
put("0", "OK");
|
||||
put("1", "FAIL");
|
||||
put("9", "MISSING");
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
package com.ai.cloud.util;
|
||||
|
||||
public class UrlConstants {
|
||||
|
||||
static class UserUrl{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<String, BuriedPointEntry> reMap, String colId,
|
||||
BuriedPointEntry tmpEntry) {
|
||||
public static void addCurNodeTreeMapKey(Map<String, TraceLogEntry> 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<String, BuriedPointEntry> reMap, String colId) {
|
||||
private static boolean addParentNodeTreeMapKey(Map<String, TraceLogEntry> 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<String, BuriedPointEntry> bpe = sdao.queryLogByTraceId(Constants.TABLE_NAME_CHAIN,
|
||||
"6305eb1d1e1b46529a7eb57912a5766e123");
|
||||
Map<String, TraceLogEntry> bpe = sdao.queryLogByTraceId(Constants.TABLE_NAME_CHAIN,
|
||||
"71e28364128847b3a12626966b60fd8f123");
|
||||
|
||||
List<BuriedPointEntry> keyList = new ArrayList<BuriedPointEntry>();
|
||||
List<TraceLogEntry> keyList = new ArrayList<TraceLogEntry>();
|
||||
|
||||
keyList.addAll(bpe.values());
|
||||
|
||||
Collections.sort(keyList, new Comparator<BuriedPointEntry>() {
|
||||
Collections.sort(keyList, new Comparator<TraceLogEntry>() {
|
||||
@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<String, BuriedPointEntry> reMap = new HashMap<String, BuriedPointEntry>();
|
||||
TraceLogEntry tmpEntry = null;
|
||||
Map<String, TraceLogEntry> reMap = new HashMap<String, TraceLogEntry>();
|
||||
long startTime = System.currentTimeMillis();
|
||||
logger.info("start time : {}", startTime);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<TimeLineEntry> timeLineList = new ArrayList<TimeLineEntry>();
|
||||
|
||||
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<TimeLineEntry> 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 + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 + "]";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<TimeLineEntry> timeLineList = new ArrayList<TimeLineEntry>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
Iterator<TimeLineEntry> 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<TimeLineEntry> getTimeLineList() {
|
||||
return timeLineList;
|
||||
}
|
||||
|
||||
public void setTimeLineList(List<TimeLineEntry> 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 + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.ai.cloud.vo.mvo;
|
||||
|
||||
public class UserInfoMVO {
|
||||
private String uid;
|
||||
|
||||
private String userName;
|
||||
|
||||
private String password;
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(String uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserInfoMVO [uid=" + uid + ", userName=" + userName + ", password=" + password + "]";
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
<!-- 注解事务类 -->
|
||||
<tx:annotation-driven transaction-manager="transactionManager" ></tx:annotation-driven>
|
||||
|
||||
<!--AOP 事务配置-->
|
||||
<tx:advice id="txAdvice" transaction-manager="transactionManager">
|
||||
|
|
@ -44,5 +45,10 @@
|
|||
<tx:method name="*" propagation="REQUIRED"/>
|
||||
</tx:attributes>
|
||||
</tx:advice>
|
||||
|
||||
|
||||
<aop:config>
|
||||
<aop:pointcut id="servicePointcut" expression="execution(* com.ai.cloud.service.inter.*.*(..))" />
|
||||
<aop:advisor pointcut-ref="servicePointcut" advice-ref="txAdvice"/>
|
||||
</aop:config>
|
||||
|
||||
</beans>
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@
|
|||
</div>
|
||||
<div class="collapse navbar-collapse">
|
||||
<!-- 菜单(不要太多) -->
|
||||
<@common.importMenuInfo menuInfo="${menuInfo}" />
|
||||
<@common.importMenuInfo menuInfo="${userInfo}" />
|
||||
|
||||
<!-- 搜索栏 -->
|
||||
<@common.importSearchInfo isLogin="${isLogin}" />
|
||||
<@common.importSearchInfo isLogin="${userInfo}" />
|
||||
|
||||
<!-- 登录/用户信息块 -->
|
||||
<@common.importUserInfo userInfo="${userInfo}" />
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
</div>
|
||||
|
||||
<div>
|
||||
<div class="text-center" style="height: 600px">
|
||||
<div class="text-center" style="height: 700px">
|
||||
<iframe id="showTraceLog" border=2 frameborder=0 width=100%
|
||||
height=100% marginheight=0 marginwidth=0 scrolling=yes src=""></iframe>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<#macro importMenuInfo menuInfo>
|
||||
<ul class="nav navbar-nav">
|
||||
<#assign text>
|
||||
${menuInfo}
|
||||
${userInfo}
|
||||
</#assign>
|
||||
<#assign json=text?eval />
|
||||
<#if json.isLogin == '1'>
|
||||
|
|
@ -22,9 +22,13 @@ ${menuInfo}
|
|||
|
||||
<#-- importSearchInfo -->
|
||||
<#macro importSearchInfo isLogin>
|
||||
<#assign text>
|
||||
${userInfo}
|
||||
</#assign>
|
||||
<#assign json=text?eval />
|
||||
<form class="navbar-form navbar-left" role="search">
|
||||
<div class="form-group">
|
||||
<#if isLogin == '1'>
|
||||
<#if json.isLogin == '1'>
|
||||
<input id="srchKey" type="text" class="form-control" style="width: 450px" placeholder="TraceId">
|
||||
<#else>
|
||||
<input id="srchKey" type="text" class="form-control" style="width: 750px" placeholder="TraceId">
|
||||
|
|
@ -62,46 +66,124 @@ ${userInfo}
|
|||
<#if valueList??>
|
||||
<div id="row">
|
||||
<div class="col-md-12">
|
||||
<h5 style="color:black">
|
||||
${traceId!}</br>
|
||||
调度入口IP:${(valueList[0].address)!},开始时间:${beginTime?number_to_datetime},${(valueList?size)!}条调用记录,消耗总时长:${(endTime - beginTime)!'0'} ms.<a id="originLog" href="#">显示原文</a>
|
||||
</h5>
|
||||
<div id="tableDiv">
|
||||
<table id="example-advanced">
|
||||
<caption>
|
||||
<a href="#" onclick="jQuery('#example-advanced').treetable('expandAll'); return false;">Expand all</a>
|
||||
|
||||
<a href="#" onclick="jQuery('#example-advanced').treetable('collapseAll'); return false;">Collapse all</a>
|
||||
<button type="button" class="btn btn-success" href="#" onclick="jQuery('#example-advanced').treetable('expandAll'); return false;">Expand all</button>
|
||||
|
||||
<button type="button" class="btn btn-warning" href="#" onclick="jQuery('#example-advanced').treetable('collapseAll'); return false;">Collapse all</button>
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-md-4" style="width: 16%">调用序列</th>
|
||||
<th class="col-md-1" style="width: 4%">类型</th>
|
||||
<th class="col-md-1" style="width: 4%">状态</th>
|
||||
<th class="col-md-3" style="width: 10%">业务信息</th>
|
||||
<th class="col-md-2" style="width: 8%">主机信息</th>
|
||||
<th class="col-md-3" style="width: 16%">时间轴</th>
|
||||
<th style="width: 25%">服务名</th>
|
||||
<th style="width: 5%">类型</th>
|
||||
<th style="width: 5%">状态</th>
|
||||
<th style="width: 20%">服务/方法</th>
|
||||
<th style="width: 15%">主机信息</th>
|
||||
<th style="width: 30%">时间轴</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<#list valueList as logInfo>
|
||||
<#if logInfo.colId == "0">
|
||||
<tr data-tt-id='${logInfo.colId!}'>
|
||||
<tr name='log' statusCodeStr="${logInfo.statusCodeStr!}" data-tt-id='${logInfo.colId!}'>
|
||||
<#else>
|
||||
<tr data-tt-id='${logInfo.colId!}' data-tt-parent-id='${logInfo.parentLevel!}'>
|
||||
<tr name='log' statusCodeStr="${logInfo.statusCodeStr!}" data-tt-id='${logInfo.colId!}' data-tt-parent-id='${logInfo.parentLevel!}'>
|
||||
</#if>
|
||||
<td><b>${logInfo.viewPointId!}</b></td>
|
||||
<td>${spanTypeMap[logInfo.spanType]!'-'}</td>
|
||||
<td>${statusCodeMap[logInfo.statusCode]!}</td>
|
||||
<td>${logInfo.businessKey!}</td>
|
||||
<td>${logInfo.address!}</td>
|
||||
<td>
|
||||
<#assign totalTime=(endTime-beginTime)>
|
||||
<#list logInfo.timeLineList as log>
|
||||
<div class="progress" beginTime="${beginTime}" endTime="${endTime}" total_time="${totalTime}" cost="${log.cost}" curStartTime="${log.startTime}" beforePer="${100*(log.startTime-beginTime)/totalTime}" curPer="${100*log.cost/33?int}">
|
||||
<div class="progress-bar" style="width: ${100*(log.startTime-beginTime)/totalTime}%"></div>
|
||||
<div class="progress-bar progress-bar-info" style="min-width: ${100*log.cost/totalTime}%;">${log.cost}ms</div></div>
|
||||
</#list>
|
||||
</td>
|
||||
<td><b>${logInfo.applicationIdStr!}</b></td>
|
||||
<td>${logInfo.spanTypeName!'UNKNOWN'}</td>
|
||||
<td>${logInfo.statusCodeName!'MISSING'}</td>
|
||||
<td>
|
||||
<a href="#" data-toggle="tooltip" data-placement="bottom" title="${logInfo.viewPointId!}">${logInfo.viewPointIdSub!}</a>
|
||||
</td>
|
||||
<td>${logInfo.address!}</td>
|
||||
<td>
|
||||
<#assign totalTime=(endTime-beginTime)*1.15>
|
||||
<div class="progress">
|
||||
<#if (logInfo.timeLineList?size=1)>
|
||||
<#list logInfo.timeLineList as log>
|
||||
<input type="hidden" beginTime="${beginTime}" endTime="${endTime}" total_time="${totalTime}" cost="${log.cost}" curStartTime="${log.startTime}" beforePer="${100*(log.startTime-beginTime)/totalTime}" curPer="${100*log.cost/totalTime}">
|
||||
<div class="progress-bar" style="width: ${100*(log.startTime-beginTime)/totalTime}%"></div>
|
||||
<div class="progress-bar progress-bar-b progress-bar-striped" style="color:black;min-width: ${100*log.cost/totalTime}%;"></div>
|
||||
<div class="progress-bar progress-split progress-bar-striped" style="color:black;"> ${log.cost}ms</div>
|
||||
</#list>
|
||||
</#if>
|
||||
|
||||
<#if (logInfo.timeLineList?size=2)>
|
||||
<#if (logInfo.timeLineList[1].startTime) < (logInfo.timeLineList[0].startTime)>
|
||||
<#--服务端开始时间 小于 客户端开始时间(异常,直接显示服务端时间轴)-->
|
||||
<#assign a=(logInfo.timeLineList[1].startTime - beginTime)! />
|
||||
<#assign b=(logInfo.timeLineList[1].cost)! />
|
||||
<input type="hidden" a="${a!}" b="${b!}" beginTime="${beginTime!}" totalTime="${totalTime!}">
|
||||
<div class="progress-bar" style="width: ${100*(a)/totalTime}%"></div>
|
||||
<div class="progress-bar progress-bar-b progress-bar-striped" style="color:black;min-width: ${100*(b)/totalTime}%;"></div>
|
||||
<div class="progress-bar progress-split progress-bar-striped" style="color:black;"> ${b}ms</div>
|
||||
<#elseif (logInfo.timeLineList[1].startTime >= logInfo.timeLineList[0].startTime) && ((logInfo.timeLineList[1].startTime) <= (logInfo.timeLineList[0].startTime + logInfo.timeLineList[0].cost))>
|
||||
<#--服务端开始时间 大于等于 客户端开始时间,并且 小于等于 客户端的结束时间-->
|
||||
<#if (logInfo.timeLineList[1].startTime + logInfo.timeLineList[1].cost) <= (logInfo.timeLineList[0].startTime + logInfo.timeLineList[0].cost)>
|
||||
<#--服务端结束时间 小于等于 客户端结束时间(客户端时间段包含服务端时间段)-->
|
||||
<#assign a=(logInfo.timeLineList[0].startTime - beginTime)! />
|
||||
<#assign b=(logInfo.timeLineList[1].startTime - logInfo.timeLineList[0].startTime)! />
|
||||
<#assign c=(logInfo.timeLineList[1].startTime + logInfo.timeLineList[1].cost - logInfo.timeLineList[1].startTime) />
|
||||
<#assign d=(logInfo.timeLineList[0].startTime + logInfo.timeLineList[0].cost - logInfo.timeLineList[1].startTime - logInfo.timeLineList[1].cost) />
|
||||
<input type="hidden" a="${a!}" b="${b!}" c="${c!}" d="${d!}" beginTime="${beginTime!}" totalTime="${totalTime!}">
|
||||
<div class="progress-bar" style="width: ${100*(a)/totalTime}%"></div>
|
||||
<div class="progress-bar progress-bar-b progress-bar-striped" style="color:black;min-width: ${100*(b)/totalTime}%;"></div>
|
||||
<div class="progress-bar progress-bar-a progress-bar-striped" style="color:black;min-width: ${100*(c)/totalTime}%;"></div>
|
||||
<div class="progress-bar progress-bar-b progress-bar-striped" style="color:black;min-width: ${100*(d)/totalTime}%;"></div>
|
||||
<div class="progress-bar progress-split progress-bar-striped" style="color:black;"> ${b}/${c}/${d}ms</div>
|
||||
<#else>
|
||||
<#--服务端开始时间 大于 客户端开始时间(客户端时间轴与服务端时间轴有一部分重合,重合后的部分算为服务端)-->
|
||||
<#assign a=(logInfo.timeLineList[0].startTime - beginTime) />
|
||||
<#assign b=(logInfo.timeLineList[1].startTime - logInfo.timeLineList[0].startTime) />
|
||||
<#assign c=(logInfo.timeLineList[1].startTime + logInfo.timeLineList[1].cost - logInfo.timeLineList[1].startTime) />
|
||||
<input type="hidden" a="${a!}" b="${b!}" c="${c!}" totalTime="${totalTime!}">
|
||||
<div class="progress-bar" style="width: ${100*(a)/totalTime}%"></div>
|
||||
<div class="progress-bar progress-bar-b progress-bar-striped" style="color:black;min-width: ${100*(b)/totalTime}%;"></div>
|
||||
<div class="progress-bar progress-bar-a progress-bar-striped" style="color:black;min-width: ${100*(c)/totalTime}%;"></div>
|
||||
<div class="progress-bar progress-split progress-bar-striped" style="color:black;"> ${a}ms->${b}ms->${c}ms</div>
|
||||
</#if>
|
||||
<#else>
|
||||
<#--服务端开始时间 大于 客户端结束始时间(客户端一段时间,一段空格,一段服务端时间)-->
|
||||
3333
|
||||
</#if>
|
||||
</#if>
|
||||
</div>
|
||||
</td>
|
||||
</#list>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
<#macro importOriginLog>
|
||||
<div id="originRow" style="display:none">
|
||||
<div class="col-md-12">
|
||||
<table class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:2%">#</th>
|
||||
<th style="width:98%">日志内容</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<#if valueList??>
|
||||
<tbody>
|
||||
<#list valueList as logInfo>
|
||||
<tr>
|
||||
<th scope="row">${logInfo_index}</th>
|
||||
<td>${logInfo.originData!}</td>
|
||||
</tr>
|
||||
</#list>
|
||||
</tbody>
|
||||
</#if>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</#macro>
|
||||
|
|
@ -19,15 +19,49 @@
|
|||
<form class="form-signin">
|
||||
<h2 class="form-signin-heading">登录</h2>
|
||||
<label for="inputEmail" class="sr-only">用户名/邮箱</label>
|
||||
<input type="text" class="form-control" placeholder="用户名"
|
||||
required autofocus>
|
||||
<input id="a" type="text" class="form-control" placeholder="用户名"
|
||||
autofocus>
|
||||
<label for="inputPassword" class="sr-only">密码</label>
|
||||
<input type="password" id="inputPassword"
|
||||
class="form-control" placeholder="密码" required>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">登录</button>
|
||||
<input id="b" type="password" id="inputPassword"
|
||||
class="form-control" placeholder="密码">
|
||||
<button id="login" class="btn btn-lg btn-primary btn-block" type="submit">登录</button>
|
||||
</form>
|
||||
</div>
|
||||
<!-- script references -->
|
||||
<@common.importJavaScript />
|
||||
<script type="text/javascript">
|
||||
$().ready(function(){
|
||||
$("#login").bind("click",function(){
|
||||
if($("#a").val() == ''){
|
||||
alert("请输入用户名");
|
||||
return false;
|
||||
}
|
||||
if($("#b").val() == ''){
|
||||
alert("请输入密码");
|
||||
return false;
|
||||
}
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '${base}/login/'+$("#a").val()+'/'+$("#b").val(),
|
||||
data:{},
|
||||
dataType: 'json',
|
||||
async : false,
|
||||
success: function(data){
|
||||
console.log(data);
|
||||
var result = data.result;
|
||||
if(result == 'OK'){
|
||||
alert(data.msg);
|
||||
parent.location.reload();
|
||||
}else{
|
||||
alert(data.msg);
|
||||
}
|
||||
},
|
||||
error: function(xhr, type){
|
||||
alert("验证失败");
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -14,20 +14,48 @@
|
|||
|
||||
<!-- show traceLogInfo -->
|
||||
<@common.dealTraceLog />
|
||||
|
||||
<!-- show traceLogInfo -->
|
||||
<@common.importOriginLog />
|
||||
|
||||
<!-- script references -->
|
||||
<@common.importJavaScript />
|
||||
<script>
|
||||
var table = $('#example-advanced').children();
|
||||
$("#example-advanced").treetable({ expandable: true , indent : 10, clickableNodeNames : true});
|
||||
|
||||
$("#example-advanced tr").click(function() {
|
||||
var selected = $(this).hasClass("highlight");
|
||||
$("#example-advanced tr").removeClass("highlight");
|
||||
if(!selected)
|
||||
$(this).addClass("highlight");
|
||||
});
|
||||
|
||||
$().ready(function(){
|
||||
var table = $('#example-advanced').children();
|
||||
$("#example-advanced").treetable({ expandable: true , indent : 10, clickableNodeNames : true});
|
||||
|
||||
$("#example-advanced tr").click(function() {
|
||||
var selected = $(this).hasClass("highlight");
|
||||
$("#example-advanced tr").removeClass("highlight");
|
||||
if(!selected)
|
||||
$(this).addClass("highlight");
|
||||
});
|
||||
|
||||
$("#originLog").bind("click",function(){
|
||||
if($(this).html() == "显示原文"){
|
||||
$("#originRow").slideDown("slow",function(){
|
||||
$("#tableDiv").slideUp("slow");
|
||||
});
|
||||
$(this).html("显示调用链");
|
||||
}else{
|
||||
$("#tableDiv").slideDown("slow",function(){
|
||||
$("#originRow").slideUp("slow");
|
||||
});
|
||||
$(this).html("显示原文");
|
||||
}
|
||||
});
|
||||
|
||||
$("tr[name='log']").each(function(){
|
||||
var code = $(this).attr("statusCodeStr");
|
||||
if(code != 0 || code=='' ){
|
||||
var node = $(this).attr("data-tt-id");
|
||||
$(this).css("color","red");
|
||||
}
|
||||
});
|
||||
|
||||
$('#example-advanced').treetable('expandAll');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ $().ready(function() {
|
|||
var traceId = $("#traceId").val();
|
||||
|
||||
/** 搞个默认值测试*/
|
||||
traceId = "933b360f94294833b6a82351d4ded676123";
|
||||
// traceId = "6fbbe463f5b74873aecaf9eb3511846e123";
|
||||
|
||||
changeFrameUrl("");
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ $().ready(function() {
|
|||
$("#srchKey").val(traceId);
|
||||
var srchKey = $("#srchKey").val();
|
||||
if (srchKey != "") {
|
||||
changeFrameUrl(baseUrl + "showTraceLog/" + srchKey);
|
||||
changeFrameUrl(baseUrl + "/showTraceLog/" + srchKey);
|
||||
}
|
||||
} else {
|
||||
$("#srchKey").val("");
|
||||
|
|
@ -28,14 +28,14 @@ $().ready(function() {
|
|||
$("#srchBtn").bind("click", function() {
|
||||
var srchKey = $("#srchKey").val();
|
||||
if (srchKey != "") {
|
||||
changeFrameUrl(baseUrl + "showTraceLog/" + srchKey);
|
||||
changeFrameUrl(baseUrl + "/showTraceLog/" + srchKey);
|
||||
}
|
||||
});
|
||||
|
||||
$("a[name='menuUrl']").each(function() {
|
||||
$(this).bind('click', function() {
|
||||
changeFrameUrl(baseUrl + $(this).attr("url"));
|
||||
changeFrameUrl(baseUrl + "/" + $(this).attr("url"));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue