Authored by wangning

update

... ... @@ -11,13 +11,17 @@ import java.util.Map;
* Created by yoho on 2016/10/20.
*/
public interface ServiceAccessMapper {
Map<String,NewJavaApiInfoRep> getBaseDataByContext(String context,String startDateStr,String endDateStr);
Map<String,NewJavaApiInfoRep> getBaseDataByContext(NewJavaApiInfoReq req);
Map<String,List<String>> getTimeoutInfo(String context, String startDateStr, String endDateStr);
Map<String,List<String>> getTimeoutInfo(NewJavaApiInfoReq req);
Map<String,List> getGraphInfo(String context);
List<NewJavaApiDetailInfoRep> getDataByContextAndIP(NewJavaApiInfoReq req);
Map<String,List<String>> getTimeoutInfoByContextAndIp(NewJavaApiInfoReq req);
Map<String,NewJavaApiInfoRep> getDataByContextAndApiName(NewJavaApiInfoReq req);
Map<String,List<String>> getTimeoutInfoByContextAndApiName(NewJavaApiInfoReq req);
}
... ...
... ... @@ -9,9 +9,12 @@ import java.util.Map;
* Created by yoho on 2016/10/20.
*/
public interface ServiceServerExceptionMapper {
Map<String,List<String>> getErrorDataByContext(String context,String startDateStr,String endDateStr);
Map<String,List<String>> getErrorDataByContext(NewJavaApiInfoReq req);
Map<String,List> getGraphInfo(String context);
Map<String,List<String>> getErrorDataByContextAndIp(NewJavaApiInfoReq req);
//根据context获取错误信息列表
Map<String,List<String>> getErrorDataByContextAndApiName(NewJavaApiInfoReq req);
}
... ...
... ... @@ -22,16 +22,13 @@ import java.util.*;
*/
@Component
public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAccessMapper {
Logger log = LoggerFactory.getLogger(ServiceAccessMapperImpl.class);
//根据context获取总响应次数和平均耗时
@Override
public Map<String,NewJavaApiInfoRep> getBaseDataByContext(String context,String startDateStr,String endDateStr) {
public Map<String,NewJavaApiInfoRep> getBaseDataByContext(NewJavaApiInfoReq req) {
Map<String,NewJavaApiInfoRep> map = new HashMap<>();
String sql = String.format("select count(cost),mean(cost) from service_access where context = '%s' and time > '%s' and time < '%s' group by hostAddress",context,startDateStr,endDateStr);
// String sql = "select count(cost),mean(cost) from service_access group by hostAddress";
String sql = String.format("select count(cost),mean(cost) from service_access where context = '%s' and time > '%s' and time < '%s' group by hostAddress",req.getServiceName(),req.getStartTime(),req.getEndTime());
map.putAll(getDataByContext(InfluxDBContants.AWS,sql));
map.putAll(getDataByContext(InfluxDBContants.Q_CLOUD,sql));
... ... @@ -61,10 +58,9 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
@Override
public Map<String,List<String>> getTimeoutInfo(String context, String startDateStr, String endDateStr) {
public Map<String,List<String>> getTimeoutInfo(NewJavaApiInfoReq req) {
Map<String,List<String>> map = new HashMap();
String sql = String.format("select ip,stack from service_access where context='%s' and cost > 200 and time > '%s' and time < '%s'",context,startDateStr,endDateStr);
// String sql = "select ip,stack from service_access where context='gateway' and cost > 200";
String sql = String.format("select ip,stack from service_access where context='%s' and cost > 200 and time > '%s' and time < '%s'",req.getServiceName(),req.getStartTime(),req.getEndTime());
map.putAll(getTimeoutInfo(InfluxDBContants.AWS,sql));
map.putAll(getTimeoutInfo(InfluxDBContants.Q_CLOUD,sql));
return map;
... ... @@ -103,7 +99,6 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
public Map<String,List> getGraphInfo(String context){
Map<String,List> map = new HashMap();
String sql = String.format("SELECT mean(cost) FROM service_access WHERE time > now() - 10m and context = '%s' GROUP BY hostAddress,time(1m) fill(null)",context);
// String sql = "select mean(cost) from service_access where time > '2016-10-20 02:25:00' and time < '2016-10-20 02:51:00' and context = 'gateway' GROUP BY hostAddress,time(1m) fill(null)";
map.putAll(getGraphInfo(InfluxDBContants.AWS,sql));
map.putAll(getGraphInfo(InfluxDBContants.Q_CLOUD,sql));
return map;
... ... @@ -167,9 +162,9 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
}
if(StringUtils.isNotBlank(req.getIp())){
sql = String.format("select count(cost),mean(cost) from service_access where context = '%s' and hostAddress = '%s' group by event",req.getServiceName(),req.getIp());
sql = String.format("select count(cost),mean(cost) from service_access where context = '%s' and hostAddress = '%s' and time > '%s' and time < '%s' group by event",req.getServiceName(),req.getIp(),req.getStartTime(),req.getEndTime());
}else{
sql = String.format("select count(cost),mean(cost) from service_access where context = '%s' group by event",req.getServiceName());
sql = String.format("select count(cost),mean(cost) from service_access where context = '%s' and time > '%s' and time < '%s' group by event",req.getServiceName(),req.getStartTime(),req.getEndTime());
}
QueryResult queryResult = query(source, sql, InfluxDBContants.YOHO_EVENT);
... ... @@ -203,9 +198,9 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
}
if(StringUtils.isNotBlank(req.getIp())){
sql = String.format("select event,stack from service_access where context='%s' and cost > 200 and ip = '%s'",req.getServiceName(),req.getIp());
sql = String.format("select event,stack from service_access where context='%s' and cost > 200 and time > '%s' and time < '%s' and ip = '%s' ",req.getServiceName(),req.getStartTime(),req.getEndTime(),req.getIp());
}else{
sql = String.format("select event,stack from service_access where context='%s' and cost > 200 ",req.getServiceName());
sql = String.format("select event,stack from service_access where context='%s' and cost > 200 and time > '%s' and time < '%s'",req.getServiceName(),req.getStartTime(),req.getEndTime());
}
... ... @@ -236,4 +231,75 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
return map;
}
@Override
public Map<String,NewJavaApiInfoRep> getDataByContextAndApiName(NewJavaApiInfoReq req) {
Map<String,NewJavaApiInfoRep> map = new HashMap<>();
String sql = String.format("select count(cost),mean(cost) from service_access where context = '%s' and event = '%s' and time > '%s' and time < '%s' group by hostAddress",req.getServiceName(),req.getApiName(),req.getStartTime(),req.getEndTime());
map.putAll(getDataByContext(InfluxDBContants.AWS,sql));
map.putAll(getDataByContext(InfluxDBContants.Q_CLOUD,sql));
return map;
}
private Map<String,NewJavaApiInfoRep> getDataByContextAndApiName(String source,String sql) {
Map<String,NewJavaApiInfoRep> map = new HashMap<>();
QueryResult queryResult = query(source, sql, InfluxDBContants.YOHO_EVENT);
QueryResult.Result rel = queryResult.getResults().get(0);
List<QueryResult.Series> listSeries = rel.getSeries();
if(listSeries == null)
return map;
for(QueryResult.Series series : listSeries){
String hostAddress = series.getTags().get("hostAddress");
Double count = (Double)series.getValues().get(0).get(1);
Double mean = (Double)series.getValues().get(0).get(2);
NewJavaApiInfoRep newJavaApiInfoRep = new NewJavaApiInfoRep();
newJavaApiInfoRep.setTotalCount(count.intValue());
newJavaApiInfoRep.setAvgCost(mean.intValue());
map.put(hostAddress,newJavaApiInfoRep);
}
return map;
}
@Override
public Map<String,List<String>> getTimeoutInfoByContextAndApiName(NewJavaApiInfoReq req) {
Map<String,List<String>> map = new HashMap();
String sql = String.format("select ip,stack from service_access where context='%s' and event = '%s' and cost > 200 and time > '%s' and time < '%s'",req.getServiceName(),req.getApiName(),req.getStartTime(),req.getEndTime());
map.putAll(getTimeoutInfoByContextAndApiName(InfluxDBContants.AWS,sql));
map.putAll(getTimeoutInfoByContextAndApiName(InfluxDBContants.Q_CLOUD,sql));
return map;
}
private Map<String,List<String>> getTimeoutInfoByContextAndApiName(String source,String sql) {
Map<String,List<String>> map = new HashMap();
QueryResult queryResult = query(source, sql, InfluxDBContants.YOHO_EVENT);
QueryResult.Result rel = queryResult.getResults().get(0);
List<QueryResult.Series> listSeries = rel.getSeries();
if(listSeries == null)
return map;
QueryResult.Series series = listSeries.get(0);
List<List<Object>> values = series.getValues();
for (List<Object> objects : values){
if(objects.get(1) == null || objects.get(2) == null)
continue;
String ip = (String)objects.get(1);
String stack = (String)objects.get(2);
List<String> stackList = map.get(ip);
if(stackList == null){
stackList = new ArrayList<>();
stackList.add(stack);
map.put(ip,stackList);
}else{
stackList.add(stack);
}
}
return map;
}
}
... ...
... ... @@ -21,9 +21,9 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S
//根据context获取错误信息列表
@Override
public Map<String,List<String>> getErrorDataByContext(String context,String startDateStr,String endDateStr) {
public Map<String,List<String>> getErrorDataByContext(NewJavaApiInfoReq req) {
Map<String,List<String>> map = new HashMap();
String sql = String.format("select ip,stack from service_server_exception where context='%s' and time > '%s' and time < '%s'",context,startDateStr,endDateStr);
String sql = String.format("select ip,stack from service_server_exception where context='%s' and time > '%s' and time < '%s'",req.getServiceName(),req.getStartTime(),req.getEndTime());
// String sql = "select ip,stack from service_server_exception";
map.putAll(getDataByContext(InfluxDBContants.AWS,sql));
map.putAll(getDataByContext(InfluxDBContants.Q_CLOUD,sql));
... ... @@ -68,7 +68,6 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S
public Map<String,List> getGraphInfo(String context){
Map<String,List> map = new HashMap();
String sql = String.format("select count(stack) from service_server_exception where context = '%s' and time > now() - 10m GROUP BY hostAddress,time(1m) fill(null)",context);
// String sql = "select count(stack) from service_server_exception where time > '2016-10-20 12:04:00' and time < '2016-10-20 12:14:00' GROUP BY hostAddress,time(1m) fill(null)";
map.putAll(getGraphInfo(InfluxDBContants.AWS,sql));
map.putAll(getGraphInfo(InfluxDBContants.Q_CLOUD,sql));
return map;
... ... @@ -128,9 +127,9 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S
}
if(StringUtils.isNotBlank(req.getIp())){
sql = String.format("select event,stack from service_server_exception where context='%s' and hostAddress = '%s'",req.getServiceName(),req.getIp());
sql = String.format("select event,stack from service_server_exception where context='%s' and time > '%s' and time < '%s' and hostAddress = '%s'",req.getServiceName(),req.getStartTime(),req.getEndTime(),req.getIp());
}else{
sql = String.format("select event,stack from service_server_exception where context='%s'",req.getServiceName());
sql = String.format("select event,stack from service_server_exception where context='%s' and time > '%s' and time < '%s'",req.getServiceName(),req.getStartTime(),req.getEndTime());
}
QueryResult queryResult = query(source, sql, InfluxDBContants.YOMO_MONITOR);
... ... @@ -159,4 +158,45 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S
return map;
}
//根据context获取错误信息列表
@Override
public Map<String,List<String>> getErrorDataByContextAndApiName(NewJavaApiInfoReq req) {
Map<String,List<String>> map = new HashMap();
String sql = String.format("select ip,stack from service_server_exception where context='%s' and event = '%s' and time > '%s' and time < '%s'",req.getServiceName(),req.getApiName(),req.getStartTime(),req.getEndTime());
map.putAll(getDataByContext(InfluxDBContants.AWS,sql));
map.putAll(getDataByContext(InfluxDBContants.Q_CLOUD,sql));
return map;
}
private Map<String,List<String>> getDataByContextAndApiName(String source,String sql) {
Map<String,List<String>> map = new HashMap();
QueryResult queryResult = query(source, sql, InfluxDBContants.YOMO_MONITOR);
QueryResult.Result rel = queryResult.getResults().get(0);
List<QueryResult.Series> listSeries = rel.getSeries();
if(listSeries == null)
return map;
QueryResult.Series series = listSeries.get(0);
List<List<Object>> values = series.getValues();
for (List<Object> objects : values){
if(objects.get(1) == null || objects.get(2) == null)
continue;
String ip = objects.get(1).toString();
String stack = objects.get(2).toString();
List<String> stackList = map.get(ip);
if(stackList == null){
stackList = new ArrayList<>();
stackList.add(stack);
map.put(ip,stackList);
}else{
stackList.add(stack);
}
}
return map;
}
}
... ...
package com.monitor.javaserver.ctrl;
import com.monitor.common.util.HttpRestClient;
import com.monitor.influxdb.InluxDBSingle;
import com.monitor.influxdb.contants.InfluxDBContants;
import com.monitor.javaserver.service.NewJavaApiInfoService;
... ... @@ -39,27 +38,23 @@ public class NewJavaApiInfoCtrl {
@Autowired
private InluxDBSingle inluxDBSingle;
@Autowired
HttpRestClient httpRestClient;
private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
//根据serviceName和timeInterval查询每台ip的监控信息
@RequestMapping("/queryByServiceType")
@ResponseBody
public BaseResponse getJavaApiStatus(@RequestBody NewJavaApiInfoReq req) {
log.info("queryByServiceType accept pram : {},{},{}",req.getServiceType(),req.getServiceName(),req.getTimeInterval());
//influxdb使用的是utc时间
DateTime endDateTime = DateTime.now(DateTimeZone.UTC);
DateTime startDateTime = endDateTime.minusMinutes(req.getTimeInterval());
String startDateStr = startDateTime.toString(DATE_TIME_FORMAT);
String endDateStr = endDateTime.toString(DATE_TIME_FORMAT);
req.setStartTime(startDateTime.toString(DATE_TIME_FORMAT));
req.setEndTime(endDateTime.toString(DATE_TIME_FORMAT));
List<NewJavaApiInfoRep> list = newJavaApiInfoService.getJavaApiStatus(req,startDateStr,endDateStr);
List<NewJavaApiInfoRep> list = newJavaApiInfoService.getJavaApiStatus(req);
Map returnMap = new HashMap();
returnMap.put("startTime",startDateStr);
returnMap.put("endTime",endDateStr);
returnMap.put("startTime",req.getStartTime());
returnMap.put("endTime",req.getEndTime());
returnMap.put("content",list);
BaseResponse rep = new BaseResponse();
rep.setData(returnMap);
... ... @@ -93,7 +88,7 @@ public class NewJavaApiInfoCtrl {
@RequestMapping("/queryByServiceTypeAndIP")
@ResponseBody
public BaseResponse queryByServiceTypeAndIP(@RequestBody NewJavaApiInfoReq req) {
log.info("getIPList accept pram : {},{},{}",req.getCloudType(),req.getServiceType(),req.getServiceName(),req.getIp(),req.getStartTime(),req.getEndTime());
log.info("getIPList accept pram : {},{},{},{},{},{}",req.getCloudType(),req.getServiceType(),req.getServiceName(),req.getIp(),req.getStartTime(),req.getEndTime());
List<NewJavaApiDetailInfoRep> list = newJavaApiInfoService.queryByServiceTypeAndIP(req);
BaseResponse rep = new BaseResponse();
rep.setData(list);
... ... @@ -101,6 +96,25 @@ public class NewJavaApiInfoCtrl {
}
//根据context和apiName接口名查询该apiName详细信息
@RequestMapping("/queryByServiceTypeAndApiName")
@ResponseBody
public BaseResponse queryByServiceTypeAndApiName(@RequestBody NewJavaApiInfoReq req) {
log.info("getIPList accept pram : {},{},{},{},{}",req.getServiceType(),req.getServiceName(),req.getStartTime(),req.getEndTime(),req.getApiName());
List<NewJavaApiInfoRep> list = newJavaApiInfoService.queryByServiceTypeAndApiName(req);
BaseResponse rep = new BaseResponse();
rep.setData(list);
return rep;
}
@RequestMapping("/test")
@ResponseBody
public BaseResponse test() {
... ... @@ -136,9 +150,9 @@ public class NewJavaApiInfoCtrl {
for(int i = 0;i<strs.length;i++){
String ip = strs[i];
Point point = Point.measurement("service_access")
.tag("context","gateway").tag("event","/gateway").tag("host","/gateway")
.tag("context","gateway").tag("event","/gateway3").tag("host","/gateway")
.tag("hostAddress",ip).tag("src_service","app.product.promotion").tag("status_code","200")
.addField("cost", RandomUtils.nextInt(199) + 2000).addField("ip",ip)
.addField("cost", RandomUtils.nextInt(199) + 3000).addField("ip",ip)
.addField("stack","Total Delay [15004ms] /gateway +---[15004ms] - com.yoho.core.common.monitor.ThreadProfileInterceptor.preHandle - [enter:1476930300814,exit:1476930315818] +---[15004ms] - app.product.data. - [enter:1476930300814,exit:1476930315818]")
.build();
inluxDBSingle.getInfluxDBByName(InfluxDBContants.AWS).getInfluxDB()
... ... @@ -156,7 +170,7 @@ public class NewJavaApiInfoCtrl {
for(int i = 0;i<strs.length;i++){
String ip = strs[i];
Point point = Point.measurement("service_server_exception")
.tag("context","gateway").tag("event","/gateway").tag("host","/brower/favorite/isFavorite")
.tag("context","gateway").tag("event","/gateway1").tag("host","/brower/favorite/isFavorite")
.tag("hostAddress",ip).tag("service_name","brower/favorite/isFavorite")
.addField("ip",ip)
.addField("stack","org.apache.catalina\\n.connector.ClientAbortException: java.io.IOException: 断开的管道\\n\\tat org.apache.catalina.connector.OutputBuffer\\n.realWriteBytes(OutputBuffer.java:393)\\n\\tat org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk\\n.java:426)\\n\\tat org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:342)\\n\\tat org\\n.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:317)\\n\\tat org.apache.catalina.connector\\n.CoyoteOutputStream.flush(CoyoteOutputStream.java:110)\\n\\tat com.fasterxml.jackson.core.json.UTF8JsonGenerator\\n.flush(UTF8JsonGenerator.java:1022)\\n\\tat com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter\\n.java:891)\\n\\tat org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal\\n(AbstractJackson2HttpMessageConverter.java:264)\\n\\tat org.springframework.http.converter.AbstractGenericHttpMessageConverter\\n.write(AbstractGenericHttpMessageConverter.java:100)\\n\\tat org.springframework.web.servlet.mvc.method\\n.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor\\n.java:202)\\n\\tat org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor\\n.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:133)\\n\\tat org.springframework\\n.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor\\n.java:165)\\n\\tat org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue\\n(HandlerMethodReturnValueHandlerComposite.java:80)\\n\\tat org.springframework.web.servlet.mvc.method.annotation\\n.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:126)\\n\\tat org.springframework\\n.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter\\n.java:806)\\n\\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal\\n(RequestMappingHandlerAdapter.java:729)\\n\\tat org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter\\n.handle(AbstractHandlerMethodAdapter.java:85)\\n\\tat org.springframework.web.servlet.DispatcherServlet\\n.doDispatch(DispatcherServlet.java:959)\\n\\tat org.springframework.web.servlet.DispatcherServlet.doService\\n(DispatcherServlet.java:893)\\n\\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet\\n.java:970)\\n\\tat org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)\\n\\n\\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:648)\\n\\tat org.springframework.web.servlet\\n.FrameworkServlet.service(FrameworkServlet.java:846)\\n\\tat javax.servlet.http.HttpServlet.service(HttpServlet\\n.java:729)\\n\\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain\\n.java:291)\\n\\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java\\n:206)\\n\\tat org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)\\n\\tat org.apache.catalina\\n.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)\\n\\tat org.apache.catalina\\n.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)\\n\\tat org.springframework.web\\n.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)\\n\\tat org.springframework\\n.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\\n\\tat org.apache.catalina.core\\n.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)\\n\\tat org.apache.catalina.core\\n.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)\\n\\tat org.apache.catalina.core.StandardWrapperValve\\n.invoke(StandardWrapperValve.java:217)\\n\\tat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve\\n.java:106)\\n\\tat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502\\n)\\n\\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)\\n\\tat org.apache\\n.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)\\n\\tat org.apache.catalina.core.StandardEngineValve\\n.invoke(StandardEngineValve.java:88)\\n\\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter\\n.java:518)\\n\\tat org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java\\n:1091)\\n\\tat org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java\\n:673)\\n\\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)\\n\\tat\\n org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)\\n\\tat java.util.concurrent\\n.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\\n\\tat java.util.concurrent.ThreadPoolExecutor$Worker\\n.run(ThreadPoolExecutor.java:617)\\n\\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run\\n(TaskThread.java:61)\\n\\tat java.lang.Thread.run(Thread.java:745)\\nCaused by: java.io.IOException: 断开\\n的管道\\n\\tat sun.nio.ch.FileDispatcherImpl.write0(Native Method)\\n\\tat sun.nio.ch.SocketDispatcher.write\\n(SocketDispatcher.java:47)\\n\\tat sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)\\n\\tat sun.nio\\n.ch.IOUtil.write(IOUtil.java:65)\\n\\tat sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471\\n)\\n\\tat org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:124)\\n\\tat org.apache.tomcat.util\\n.net.NioBlockingSelector.write(NioBlockingSelector.java:101)\\n\\tat org.apache.tomcat.util.net.NioSelectorPool\\n.write(NioSelectorPool.java:172)\\n\\tat org.apache.coyote.http11.InternalNioOutputBuffer.writeToSocket\\n(InternalNioOutputBuffer.java:139)\\n\\tat org.apache.coyote.http11.InternalNioOutputBuffer.addToBB(InternalNioOutputBuffer\\n.java:197)\\n\\tat org.apache.coyote.http11.InternalNioOutputBuffer.access$000(InternalNioOutputBuffer\\n.java:41)\\n\\tat org.apache.coyote.http11.InternalNioOutputBuffer$SocketOutputBuffer.doWrite(InternalNioOutputBuffer\\n.java:320)\\n\\tat org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java\\n:118)\\n\\tat org.apache.coyote.http11.AbstractOutputBuffer.doWrite(AbstractOutputBuffer.java:256)\\n\\tat\\n org.apache.coyote.Response.doWrite(Response.java:501)\\n\\tat org.apache.catalina.connector.OutputBuffer\\n.realWriteBytes(OutputBuffer.java:388)\\n\\t... 47 more\\n")
... ...
... ... @@ -11,11 +11,13 @@ import java.util.Map;
* Created by yoho on 2016/10/20.
*/
public interface NewJavaApiInfoService {
List<NewJavaApiInfoRep> getJavaApiStatus(NewJavaApiInfoReq req,String startDateStr,String endDateStr);
List<NewJavaApiInfoRep> getJavaApiStatus(NewJavaApiInfoReq req);
Map getJavaApiGraph(NewJavaApiInfoReq req);
List<String> getIPList(NewJavaApiInfoReq req);
List<NewJavaApiDetailInfoRep> queryByServiceTypeAndIP(NewJavaApiInfoReq req);
List<NewJavaApiInfoRep> queryByServiceTypeAndApiName(NewJavaApiInfoReq req);
}
... ...
... ... @@ -42,18 +42,18 @@ public class NewJavaApiInfoServiceImpl implements NewJavaApiInfoService {
@Override
public List<NewJavaApiInfoRep> getJavaApiStatus(NewJavaApiInfoReq req,String startDateStr,String endDateStr) {
public List<NewJavaApiInfoRep> getJavaApiStatus(NewJavaApiInfoReq req) {
List<MObjectInfo> objectInfoList = getMObjectInfoList(req);
if(CollectionUtils.isEmpty(objectInfoList)){
return null;
}
//获取总请求次数和平均耗时
Map<String,NewJavaApiInfoRep> infoMap = serviceAccessMapper.getBaseDataByContext(req.getServiceName(),startDateStr,endDateStr);
Map<String,NewJavaApiInfoRep> infoMap = serviceAccessMapper.getBaseDataByContext(req);
//获取超时数据
Map<String,List<String>> timeoutInfoMap = serviceAccessMapper.getTimeoutInfo(req.getServiceName(),startDateStr,endDateStr);
Map<String,List<String>> timeoutInfoMap = serviceAccessMapper.getTimeoutInfo(req);
//获取异常数据
Map<String,List<String>> errorInfoMap = serviceServerExceptionMapper.getErrorDataByContext(req.getServiceName(),startDateStr,endDateStr);
Map<String,List<String>> errorInfoMap = serviceServerExceptionMapper.getErrorDataByContext(req);
//获取cpu、内存、带宽使用情况
Map vmInfoMap = vmInfoMapper.getVMInfo();
... ... @@ -191,6 +191,42 @@ public class NewJavaApiInfoServiceImpl implements NewJavaApiInfoService {
}
@Override
public List<NewJavaApiInfoRep> queryByServiceTypeAndApiName(NewJavaApiInfoReq req) {
List<MObjectInfo> objectInfoList = getMObjectInfoList(req);
if(CollectionUtils.isEmpty(objectInfoList)){
return null;
}
//获取总请求次数和平均耗时
Map<String,NewJavaApiInfoRep> infoMap = serviceAccessMapper.getDataByContextAndApiName(req);
//获取超时数据
Map<String,List<String>> timeoutInfoMap = serviceAccessMapper.getTimeoutInfoByContextAndIp(req);
//获取异常数据
Map<String,List<String>> errorInfoMap = serviceServerExceptionMapper.getErrorDataByContextAndApiName(req);
List<NewJavaApiInfoRep> returnList = new ArrayList<>();
for(MObjectInfo mObjectInfo :objectInfoList){
NewJavaApiInfoRep resp = new NewJavaApiInfoRep();
String ip = mObjectInfo.getMoHostIp();
resp.setIp(ip);
if(ip.startsWith("172")){
resp.setType("AWS");
}else{
resp.setType("QCloud");
}
resp.setTotalCount(infoMap.get(ip) == null ? 0 : infoMap.get(ip).getTotalCount());
resp.setAvgCost(infoMap.get(ip) == null ? 0 : infoMap.get(ip).getAvgCost());
resp.setErrorCount(errorInfoMap.get(ip) == null ? 0 : errorInfoMap.get(ip).size());
resp.setErrorInfo(errorInfoMap.get(ip));
resp.setTimeoutInfo(timeoutInfoMap.get(ip));
returnList.add(resp);
}
return returnList;
}
}
... ...
... ... @@ -22,6 +22,8 @@ public class NewJavaApiInfoReq {
//1:aws 2:qcloud
private int cloudType;
private String apiName;
public int getServiceType() {
return serviceType;
}
... ... @@ -85,4 +87,12 @@ public class NewJavaApiInfoReq {
public void setCloudType(int cloudType) {
this.cloudType = cloudType;
}
public String getApiName() {
return apiName;
}
public void setApiName(String apiName) {
this.apiName = apiName;
}
}
... ...