Compare commits
3 Commits
main
...
feature/fi
Author | SHA1 | Date |
---|---|---|
|
f90a46f361 | |
|
062b58bba1 | |
|
d0b4c13cee |
|
@ -16,6 +16,14 @@ resource:
|
|||
user: root
|
||||
password: shulie@2020
|
||||
database: jmeter
|
||||
## 引擎包位置 引擎包可在github下载
|
||||
pressure.engine.install.dir: /Users/shulie/engine/pressure-engine.tar.gz
|
||||
## 引擎包工作目录 记录引擎包工作的配置文件 记录引擎包生成的日志(jtl,log)
|
||||
pressure.engine.task.dir: /Users/shulie/engine
|
||||
## 脚本管理 临时文件目录
|
||||
script.temp.path: /data/apps/tro-cloud/script/temp
|
||||
## 脚本管理 脚本文件目录
|
||||
script.path: /data/apps/tro-cloud/script/
|
||||
|
||||
## 配置cloud地址 即当前系统部署的url
|
||||
console.url: http://127.0.0.1:10010/tro-cloud
|
||||
|
|
|
@ -31,6 +31,8 @@ import org.springframework.data.redis.core.StringRedisTemplate;
|
|||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import org.springframework.data.redis.core.script.DefaultRedisScript;
|
||||
import org.springframework.data.redis.core.types.Expiration;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
|
@ -208,7 +210,10 @@ public class RedisClientUtils {
|
|||
*/
|
||||
public boolean hmset(String key, Map<String, Object> map) {
|
||||
try {
|
||||
stringRedisTemplate.opsForHash().putAll(key, map);
|
||||
//不影响其他的使用,用一个临时的template
|
||||
StringRedisTemplate redisTemplate = stringRedisTemplate;
|
||||
redisTemplate.setHashValueSerializer(RedisSerializer.json());
|
||||
redisTemplate.opsForHash().putAll(key, map);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package io.shulie.tro.web.app.conf;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import com.shulie.tesla.sequence.impl.DefaultSequence;
|
||||
import com.shulie.tesla.sequence.impl.DefaultSequenceDao;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author 无涯
|
||||
* @Package io.shulie.tro.web.app.conf
|
||||
* @date 2020/12/21 5:16 下午
|
||||
*/
|
||||
@Configuration
|
||||
public class TeslaConfig {
|
||||
|
||||
@Bean
|
||||
public DefaultSequence baseOrderLineSequence(DataSource dataSource) {
|
||||
DefaultSequenceDao defaultSequenceDao = new DefaultSequenceDao();
|
||||
defaultSequenceDao.setDataSource(dataSource);
|
||||
defaultSequenceDao.setStep(500);
|
||||
defaultSequenceDao.setTableName("t_tc_sequence");
|
||||
DefaultSequence defaultSequence = new DefaultSequence();
|
||||
defaultSequence.setSequenceDao(defaultSequenceDao);
|
||||
defaultSequence.setName("BASE_ORDER_LINE");
|
||||
return defaultSequence;
|
||||
}
|
||||
@Bean
|
||||
public DefaultSequence threadOrderLineSequence(DataSource dataSource) {
|
||||
DefaultSequenceDao defaultSequenceDao = new DefaultSequenceDao();
|
||||
defaultSequenceDao.setDataSource(dataSource);
|
||||
defaultSequenceDao.setStep(500);
|
||||
defaultSequenceDao.setTableName("t_tc_sequence");
|
||||
DefaultSequence defaultSequence = new DefaultSequence();
|
||||
defaultSequence.setSequenceDao(defaultSequenceDao);
|
||||
defaultSequence.setName("THREAD_ORDER_LINE");
|
||||
return defaultSequence;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package io.shulie.tro.web.app.controller.perfomanceanaly;
|
||||
|
||||
import io.shulie.tro.web.app.request.perfomanceanaly.MemoryAnalysisRequest;
|
||||
import io.shulie.tro.web.app.response.perfomanceanaly.DownloadDumpResponse;
|
||||
import io.shulie.tro.web.app.response.perfomanceanaly.MemoryAnalysisResponse;
|
||||
import io.shulie.tro.web.app.service.perfomanceanaly.MemoryAnalysisService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @ClassName MemoryAnalyController
|
||||
* @Description 内存分析
|
||||
* @Author qianshui
|
||||
* @Date 2020/11/4 上午11:05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/memory")
|
||||
@Api(tags = "内存分析")
|
||||
public class MemoryAnalyzeController {
|
||||
|
||||
@Autowired
|
||||
private MemoryAnalysisService memoryAnalysisService;
|
||||
|
||||
@PostMapping("/dump")
|
||||
@ApiOperation(value = "获取内存分析数据")
|
||||
public MemoryAnalysisResponse getMemoryDump(@RequestBody MemoryAnalysisRequest request) {
|
||||
return memoryAnalysisService.queryMemoryDump(request);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传到zk
|
||||
*/
|
||||
@GetMapping("/download/dump")
|
||||
@ApiOperation(value = "上传zk")
|
||||
public DownloadDumpResponse downloadDump(@RequestParam("agentId") String agentId) throws Throwable {
|
||||
return memoryAnalysisService.downloadDump(agentId);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package io.shulie.tro.web.app.controller.perfomanceanaly;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import io.shulie.tro.web.app.constant.AgentUrls;
|
||||
import io.shulie.tro.web.app.convert.performace.PerformanceBaseReqConvert;
|
||||
import io.shulie.tro.web.app.input.PerformanceBaseDataCreateInput;
|
||||
import io.shulie.tro.web.app.req.perfomanceanaly.PerformanceBaseDataReq;
|
||||
import io.shulie.tro.web.app.service.perfomanceanaly.PerformanceBaseDataService;
|
||||
import io.shulie.tro.web.app.service.perfomanceanaly.ThreadAnalyService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @ClassName PerformanceBaseDataController
|
||||
* @Description
|
||||
* @Author qianshui
|
||||
* @Date 2020/11/4 下午2:49
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = AgentUrls.PREFIX_URL)
|
||||
@Api(tags = "性能分析数据")
|
||||
public class PerformanceBaseDataController {
|
||||
|
||||
@Value("${performance.base.agent.frequency:1}")
|
||||
private String frequency;
|
||||
@Autowired
|
||||
private PerformanceBaseDataService performanceBaseDataService;
|
||||
@Autowired
|
||||
private ThreadAnalyService threadAnalyService;
|
||||
|
||||
private static AtomicInteger integer = new AtomicInteger();
|
||||
@PostMapping(value = AgentUrls.PERFORMANCE_BASE_URL)
|
||||
@ApiOperation(value = "接收agent写入数据")
|
||||
public void receivePerformanceBaseData(@RequestBody PerformanceBaseDataReq req) {
|
||||
if(integer.get() > 100000000) {
|
||||
integer.set(0);
|
||||
}
|
||||
if(integer.getAndIncrement() % Integer.parseInt(frequency) == 0) {
|
||||
PerformanceBaseDataCreateInput input = PerformanceBaseReqConvert.INSTANCE.reqToInput(req);
|
||||
performanceBaseDataService.cache(input);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 秒级别
|
||||
* @param second
|
||||
*/
|
||||
@GetMapping("/clear")
|
||||
@ApiOperation(value = "清理数据接口")
|
||||
public String clear(@RequestParam("second") Integer second) {
|
||||
performanceBaseDataService.clearData(Integer.valueOf(second));
|
||||
threadAnalyService.clearData(Integer.valueOf(second));
|
||||
return "清理成功";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package io.shulie.tro.web.app.controller.perfomanceanaly;
|
||||
|
||||
import io.shulie.tro.common.beans.page.PagingList;
|
||||
import io.shulie.tro.web.app.input.PressureMachineInput;
|
||||
import io.shulie.tro.web.app.request.perfomanceanaly.PressureMachineDeleteRequest;
|
||||
import io.shulie.tro.web.app.request.perfomanceanaly.PressureMachineInsertRequest;
|
||||
import io.shulie.tro.web.app.request.perfomanceanaly.PressureMachineLogQueryRequest;
|
||||
import io.shulie.tro.web.app.request.perfomanceanaly.PressureMachineUpdateRequest;
|
||||
import io.shulie.tro.web.app.response.perfomanceanaly.PressureMachineLogResponse;
|
||||
import io.shulie.tro.web.app.response.perfomanceanaly.PressureMachineResponse;
|
||||
import io.shulie.tro.web.app.service.perfomanceanaly.PressureMachineLogService;
|
||||
import io.shulie.tro.web.app.service.perfomanceanaly.PressureMachineService;
|
||||
import io.shulie.tro.web.data.param.machine.PressureMachineQueryParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Author: mubai
|
||||
* @Date: 2020-11-13 09:17
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/pressure/machine")
|
||||
@Api(tags = "压力机接口")
|
||||
public class PressureMachineController {
|
||||
|
||||
@Autowired
|
||||
private PressureMachineService pressureMachineService;
|
||||
|
||||
@Autowired
|
||||
private PressureMachineLogService machineLogService;
|
||||
|
||||
@PostMapping("/upload")
|
||||
@ApiOperation(value = "上报压力机信息")
|
||||
public void uploadMachineInfo(@RequestBody PressureMachineInsertRequest request) {
|
||||
PressureMachineInput input = new PressureMachineInput();
|
||||
BeanUtils.copyProperties(request, input);
|
||||
pressureMachineService.upload(input);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/log/info")
|
||||
@ApiOperation(value = "压力机日志趋势图")
|
||||
public PressureMachineLogResponse getPressureMachineLogChart(
|
||||
@RequestParam(value = "id", required = true) Long id,
|
||||
@RequestParam(value = "queryTime", required = true) String queryTime) {
|
||||
PressureMachineLogQueryRequest request = new PressureMachineLogQueryRequest();
|
||||
request.setMachineId(id);
|
||||
request.setQueryTime(queryTime);
|
||||
return machineLogService.queryByExample(request);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation(value = "修改压力机")
|
||||
public void update(@RequestBody PressureMachineUpdateRequest request) {
|
||||
pressureMachineService.update(request);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation(value = "删除压力机")
|
||||
public void delete(@RequestBody PressureMachineDeleteRequest request) {
|
||||
pressureMachineService.delete(request);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/list")
|
||||
@ApiOperation(value = "压力机列表")
|
||||
public PagingList<PressureMachineResponse> getPressureMachineList(
|
||||
@RequestParam(value = "name", required = false) String name,
|
||||
@RequestParam(value = "ip", required = false) String ip,
|
||||
@RequestParam(value = "flag", required = false) String flag,
|
||||
@RequestParam(value = "status", required = false) Integer status,
|
||||
@RequestParam(value = "order", required = false) Integer order,
|
||||
@RequestParam(value = "current", required = false, defaultValue = "0") Integer current,
|
||||
@RequestParam(value = "pageSize", required = false) Integer pageSize
|
||||
) {
|
||||
PressureMachineQueryParam request = new PressureMachineQueryParam();
|
||||
request.setName(name);
|
||||
request.setIp(ip);
|
||||
request.setFlag(flag);
|
||||
request.setStatus(status);
|
||||
request.setMachineUsageOrder(order);
|
||||
request.setCurrent(current + 1);
|
||||
request.setPageSize(pageSize);
|
||||
return pressureMachineService.queryByExample(request);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package io.shulie.tro.web.app.controller.perfomanceanaly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.shulie.tro.web.app.request.perfomanceanaly.PressureMachineStatisticsRequest;
|
||||
import io.shulie.tro.web.app.response.perfomanceanaly.PressureMachineStatisticsResponse;
|
||||
import io.shulie.tro.web.app.response.perfomanceanaly.TypeValueDateVo;
|
||||
import io.shulie.tro.web.app.service.perfomanceanaly.PressureMachineStatisticsService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Author: mubai
|
||||
* @Date: 2020-11-13 17:44
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/pressure/machine/statistics")
|
||||
@Api(tags = "压力机统计")
|
||||
public class PressureMachineStatisticsController {
|
||||
|
||||
@Autowired
|
||||
private PressureMachineStatisticsService pressureMachineStatisticsService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "压力机最新统计")
|
||||
public PressureMachineStatisticsResponse statistics() {
|
||||
return pressureMachineStatisticsService.getNewlyStatistics();
|
||||
}
|
||||
|
||||
@GetMapping(value = "/trend/chart")
|
||||
@ApiOperation(value = "压力机趋势图")
|
||||
public List<TypeValueDateVo> statisticsTrendChart(
|
||||
@RequestParam String startTime, @RequestParam String endTime) {
|
||||
PressureMachineStatisticsRequest request = new PressureMachineStatisticsRequest();
|
||||
request.setStartTime(startTime);
|
||||
request.setEndTime(endTime);
|
||||
request.setCurrent(0);
|
||||
request.setPageSize(-1);
|
||||
return pressureMachineStatisticsService.queryByExample(request);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package io.shulie.tro.web.app.controller.perfomanceanaly;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import io.shulie.tro.web.app.request.perfomanceanaly.PerformanceAnalyzeRequest;
|
||||
import io.shulie.tro.web.app.request.perfomanceanaly.ThreadCpuUseRateRequest;
|
||||
import io.shulie.tro.web.app.request.perfomanceanaly.ThreadListRequest;
|
||||
import io.shulie.tro.web.app.request.perfomanceanaly.ThreadStackRequest;
|
||||
import io.shulie.tro.web.app.response.common.SelectListResponse;
|
||||
import io.shulie.tro.web.app.response.perfomanceanaly.ProcessBaseDataResponse;
|
||||
import io.shulie.tro.web.app.response.perfomanceanaly.ThreadCpuChartResponse;
|
||||
import io.shulie.tro.web.app.response.perfomanceanaly.ThreadCpuUseRateChartResponse;
|
||||
import io.shulie.tro.web.app.response.perfomanceanaly.ThreadListResponse;
|
||||
import io.shulie.tro.web.app.response.perfomanceanaly.ThreadStackInfoResponse;
|
||||
import io.shulie.tro.web.app.service.perfomanceanaly.PerformanceBaseDataService;
|
||||
import io.shulie.tro.web.app.service.perfomanceanaly.ThreadAnalyService;
|
||||
import io.shulie.tro.web.app.service.report.impl.ReportApplicationService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @ClassName ThreadAnalyController
|
||||
* @Description 线程分析
|
||||
* @Author qianshui
|
||||
* @Date 2020/11/4 上午11:05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/thread")
|
||||
@Api(tags = "线程分析")
|
||||
public class ThreadAnalyzeController {
|
||||
|
||||
@Autowired
|
||||
private ReportApplicationService reportApplicationService;
|
||||
|
||||
@Autowired
|
||||
private PerformanceBaseDataService performanceBaseDataService;
|
||||
|
||||
@Autowired
|
||||
private ThreadAnalyService threadAnalyService;
|
||||
|
||||
@GetMapping("/application")
|
||||
@ApiOperation(value = "应用列表")
|
||||
public List<SelectListResponse> getApplicationList(Long reportId) {
|
||||
List<String> dataList = reportApplicationService.getReportApplication(reportId).getApplicationNames();
|
||||
Collections.sort(dataList);
|
||||
return convert(dataList);
|
||||
}
|
||||
|
||||
@GetMapping("/process")
|
||||
@ApiOperation(value = "进程名称列表")
|
||||
public List<SelectListResponse> getProcess(Long reportId, String appName) {
|
||||
return convert(performanceBaseDataService.getProcessName(reportId, appName));
|
||||
}
|
||||
|
||||
@GetMapping("/base")
|
||||
@ApiOperation(value = "基础信息")
|
||||
public ProcessBaseDataResponse getBaseData(PerformanceAnalyzeRequest request) {
|
||||
return threadAnalyService.getBaseData(request);
|
||||
}
|
||||
|
||||
@GetMapping("/analyze")
|
||||
@ApiOperation(value = "分析图表")
|
||||
public List<ThreadCpuChartResponse> getThreadAnalyze(PerformanceAnalyzeRequest request) {
|
||||
return threadAnalyService.getThreadAnalyze(request);
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value = "线程列表")
|
||||
public ThreadListResponse getThreadList(ThreadListRequest request) { return threadAnalyService.getThreadList(request);
|
||||
}
|
||||
|
||||
@PostMapping("/getThreadStackInfo")
|
||||
@ApiOperation(value = "获取线程栈信息")
|
||||
public ThreadStackInfoResponse getThreadStackInfo(@RequestBody ThreadStackRequest request) {
|
||||
ThreadStackInfoResponse response = new ThreadStackInfoResponse();
|
||||
response.setThreadStack(threadAnalyService.getThreadStackInfo(request.getLink()));
|
||||
return response;
|
||||
}
|
||||
|
||||
@GetMapping("/cpuUseRate")
|
||||
@ApiOperation(value = "线程cpu占用率图表")
|
||||
public List<ThreadCpuUseRateChartResponse> getThreadCpuUseRate(ThreadCpuUseRateRequest request) {
|
||||
return threadAnalyService.getThreadCpuUseRate(request);
|
||||
}
|
||||
|
||||
private List<SelectListResponse> convert(List<String> dataList) {
|
||||
if(CollectionUtils.isEmpty(dataList)) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
List<SelectListResponse> responses = Lists.newArrayList();
|
||||
dataList.stream().forEach(data -> {
|
||||
SelectListResponse temp = new SelectListResponse();
|
||||
temp.setLabel(data);
|
||||
temp.setValue(data);
|
||||
responses.add(temp);
|
||||
});
|
||||
return responses;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package io.shulie.tro.web.app.controller.perfomanceanaly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.shulie.tro.web.app.constant.AgentUrls;
|
||||
import io.shulie.tro.web.app.exception.ExceptionCode;
|
||||
import io.shulie.tro.web.app.exception.TroWebException;
|
||||
import io.shulie.tro.web.app.request.perfomanceanaly.TraceManageCreateRequest;
|
||||
import io.shulie.tro.web.app.request.perfomanceanaly.TraceManageDeployQueryRequest;
|
||||
import io.shulie.tro.web.app.request.perfomanceanaly.TraceManageQueryListRequest;
|
||||
import io.shulie.tro.web.app.response.perfomanceanaly.TraceManageCreateResponse;
|
||||
import io.shulie.tro.web.app.response.perfomanceanaly.TraceManageResponse;
|
||||
import io.shulie.tro.web.app.service.perfomanceanaly.TraceManageService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author zhaoyong
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = AgentUrls.PREFIX_URL)
|
||||
@Api(tags = "方法追踪")
|
||||
public class TraceManageController {
|
||||
|
||||
@Autowired
|
||||
private TraceManageService traceManageService;
|
||||
|
||||
@PostMapping("/traceManage/createTraceManage")
|
||||
@ApiOperation(value = "创建方法追踪,获取trace方法追踪凭证")
|
||||
public TraceManageCreateResponse createTraceManage(@RequestBody TraceManageCreateRequest traceManageCreateRequest)
|
||||
throws Exception {
|
||||
return traceManageService.createTraceManage(traceManageCreateRequest);
|
||||
}
|
||||
|
||||
@GetMapping("/traceManage/queryTraceManageDeploy")
|
||||
@ApiOperation(value = "查询方法追踪树状结构信息")
|
||||
public TraceManageResponse queryTraceManageDeploy(@ApiParam(value = "传入traceManageId 查询所有信息") Long id,
|
||||
@ApiParam(value = "追踪凭证id") String sampleId) {
|
||||
TraceManageDeployQueryRequest traceManageDeployQueryRequest = new TraceManageDeployQueryRequest();
|
||||
traceManageDeployQueryRequest.setId(id);
|
||||
traceManageDeployQueryRequest.setSampleId(sampleId);
|
||||
return traceManageService.queryTraceManageDeploy(traceManageDeployQueryRequest);
|
||||
}
|
||||
|
||||
@GetMapping("/traceManage/queryTraceManageList")
|
||||
@ApiOperation(value = "查询方法追踪列表信息")
|
||||
public List<TraceManageResponse> queryTraceManageList(@ApiParam(value = "报告id") Long reportId,
|
||||
@ApiParam(value = "进程名称") String processName) {
|
||||
if (StringUtils.isEmpty(processName)){
|
||||
throw new TroWebException(ExceptionCode.TRACE_MANAGE_PARAM_VALID_ERROR,"报告id为空");
|
||||
}
|
||||
if (reportId == null){
|
||||
throw new TroWebException(ExceptionCode.TRACE_MANAGE_PARAM_VALID_ERROR,"进程名称为空");
|
||||
}
|
||||
|
||||
TraceManageQueryListRequest traceManageQueryListRequest = new TraceManageQueryListRequest();
|
||||
traceManageQueryListRequest.setReportId(reportId);
|
||||
String[] split = StringUtils.split(processName, "|");
|
||||
traceManageQueryListRequest.setAgentId(split[1]);
|
||||
return traceManageService.queryTraceManageList(traceManageQueryListRequest);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -91,6 +91,11 @@ import io.shulie.tro.web.common.http.HttpWebClient;
|
|||
import io.shulie.tro.web.common.util.ActivityUtil;
|
||||
import io.shulie.tro.web.common.util.ActivityUtil.EntranceJoinEntity;
|
||||
import io.shulie.tro.web.common.util.JsonUtil;
|
||||
import io.shulie.tro.web.data.dao.application.ApplicationDAO;
|
||||
import io.shulie.tro.web.data.mapper.mysql.ApplicationApiManageMapper;
|
||||
import io.shulie.tro.web.data.mapper.mysql.BusinessLinkManageTableMapper;
|
||||
import io.shulie.tro.web.data.model.mysql.BusinessLinkManageTableEntity;
|
||||
import io.shulie.tro.web.data.result.application.ApplicationDetailResult;
|
||||
import io.shulie.tro.web.diff.api.scenemanage.SceneManageApi;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
@ -129,6 +134,9 @@ public class SceneManageServiceImpl implements SceneManageService {
|
|||
@Resource
|
||||
private TApplicationMntDao tApplicationMntDao;
|
||||
|
||||
@Resource
|
||||
private ApplicationDAO applicationDAO;
|
||||
|
||||
@Autowired
|
||||
private ApplicationBusinessActivityService applicationBusinessActivityService;
|
||||
|
||||
|
@ -147,6 +155,12 @@ public class SceneManageServiceImpl implements SceneManageService {
|
|||
@Autowired
|
||||
private SceneTagService sceneTagService;
|
||||
|
||||
@Resource
|
||||
private BusinessLinkManageTableMapper businessLinkManageTableMapper;
|
||||
|
||||
@Resource
|
||||
private ApplicationApiManageMapper applicationApiManageMapper;
|
||||
|
||||
@Override
|
||||
public ResponseResult<List<SceneManageWrapperResp>> getByIds(SceneManageQueryByIdsReq req) {
|
||||
return sceneManageApi.getByIds(req);
|
||||
|
@ -602,14 +616,37 @@ public class SceneManageServiceImpl implements SceneManageService {
|
|||
SceneBusinessActivityRef ref = new SceneBusinessActivityRef();
|
||||
ref.setBusinessActivityId(data.getBusinessActivityId());
|
||||
ref.setBusinessActivityName(data.getBusinessActivityName());
|
||||
List<String> ids = getAppIdsByNameAndUser(getAppsbyId(data.getBusinessActivityId()), null);
|
||||
ref.setApplicationIds(convertListToString(ids));
|
||||
//List<String> ids = getAppIdsByNameAndUser(getAppsbyId(data.getBusinessActivityId()), null);
|
||||
//ref.setApplicationIds(convertListToString(ids));
|
||||
//直接查询应用id赋值
|
||||
ref.setApplicationIds(getApplicationId(data.getBusinessActivityId()));
|
||||
ref.setGoalValue(buildGoalValue(data));
|
||||
businessActivityList.add(ref);
|
||||
});
|
||||
return businessActivityList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用活动id
|
||||
* @param businessActivityId 业务活动id
|
||||
* @return 应用活动id
|
||||
*/
|
||||
private String getApplicationId(Long businessActivityId){
|
||||
//根据业务活动id获取业务活动数据
|
||||
BusinessLinkManageTableEntity businessLinkManageTableEntity = businessLinkManageTableMapper.selectById(businessActivityId);
|
||||
if (businessLinkManageTableEntity == null) {
|
||||
return null;
|
||||
}
|
||||
EntranceJoinEntity entranceJoinEntity = ActivityUtil.covertEntrance(businessLinkManageTableEntity.getEntrace());
|
||||
List<String> appNames = Lists.newArrayList();
|
||||
appNames.add(entranceJoinEntity.getApplicationName());
|
||||
//通过业务活动名称获取应用信息
|
||||
List<ApplicationDetailResult> applicationList = applicationDAO.getApplicationList(appNames);
|
||||
List<String> applicationIds = Lists.newArrayList();
|
||||
applicationList.stream().forEach(c->applicationIds.add(String.valueOf(c.getApplicationId())));
|
||||
return convertListToString(applicationIds);
|
||||
}
|
||||
|
||||
private String buildGoalValue(SceneBusinessActivityRefVO vo) {
|
||||
Map<String, Object> map = Maps.newHashMap();
|
||||
map.put(SceneManageConstant.TPS, vo.getTargetTPS());
|
||||
|
|
|
@ -72,6 +72,12 @@
|
|||
<artifactId>tro-web-amdb-accessor</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.shulie.tesla</groupId>
|
||||
<artifactId>tesla-sequence</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.shulie.tro.web.data.dao.perfomanceanaly;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
@ -29,6 +28,7 @@ import javax.annotation.Resource;
|
|||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.pamirs.tro.common.util.DateUtils;
|
||||
import com.shulie.tesla.sequence.impl.DefaultSequence;
|
||||
import io.shulie.tro.utils.json.JsonHelper;
|
||||
import io.shulie.tro.web.common.vo.perfomanceanaly.PerformanceThreadDataVO;
|
||||
import io.shulie.tro.web.data.common.InfluxDBWriter;
|
||||
|
@ -42,6 +42,7 @@ import io.shulie.tro.web.data.result.perfomanceanaly.PerformanceBaseDataResult;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
|
@ -64,9 +65,19 @@ public class PerformanceBaseDataDAOImpl implements PerformanceBaseDataDAO {
|
|||
@Resource
|
||||
private PerformanceThreadStackDataMapper performanceThreadStackDataMapper;
|
||||
|
||||
@Autowired
|
||||
private DefaultSequence baseOrderLineSequence;
|
||||
|
||||
@Autowired
|
||||
private DefaultSequence threadOrderLineSequence;
|
||||
|
||||
@Override
|
||||
public void insert(PerformanceBaseDataParam param) {
|
||||
|
||||
long baseId = baseOrderLineSequence.nextValue();
|
||||
// 插入base数据
|
||||
influxWriterBase(param, baseId);
|
||||
// 插入thread数据
|
||||
influxWriterThread(param, baseId);
|
||||
}
|
||||
|
||||
private void influxWriterThread(PerformanceBaseDataParam param, Long baseId) {
|
||||
|
@ -77,8 +88,7 @@ public class PerformanceBaseDataDAOImpl implements PerformanceBaseDataDAO {
|
|||
if (StringUtils.isBlank(data.getThreadStatus())) {
|
||||
data.setThreadStatus(DEFAULT_THREAD_STATUS);
|
||||
}
|
||||
long threadId = 0L;
|
||||
//threadOrderLineSequence.nextValue();
|
||||
long threadId = threadOrderLineSequence.nextValue();
|
||||
// 记录关联关系
|
||||
PerformanceThreadStackDataEntity entity = new PerformanceThreadStackDataEntity();
|
||||
entity.setThreadStackLink(threadId);
|
||||
|
@ -105,7 +115,7 @@ public class PerformanceBaseDataDAOImpl implements PerformanceBaseDataDAO {
|
|||
long mid = System.currentTimeMillis();
|
||||
// threadStack 存入mysql thread_stack_link
|
||||
performanceThreadStackDataMapper.insertBatchSomeColumn(stackDataEntities);
|
||||
log.info("influxDBWriter运行时间:{},insertBatchSomeColumn运行时间:{},数据量:{}", mid - start,
|
||||
log.debug("influxDBWriter运行时间:{},insertBatchSomeColumn运行时间:{},数据量:{}", mid - start,
|
||||
System.currentTimeMillis() - mid, stackDataEntities.size());
|
||||
}
|
||||
|
||||
|
@ -239,3 +249,4 @@ public class PerformanceBaseDataDAOImpl implements PerformanceBaseDataDAO {
|
|||
influxDBWriter.query(influxDBSQL.toString(), PerformanceBaseDataResult.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue