Authored by jack.xue

fix type bug

@@ -44,17 +44,20 @@ public class NginxService { @@ -44,17 +44,20 @@ public class NginxService {
44 BaseResponse response = new BaseResponse(); 44 BaseResponse response = new BaseResponse();
45 45
46 List<NginxView> nginxViewList = new ArrayList<>(); 46 List<NginxView> nginxViewList = new ArrayList<>();
47 -  
48 - for (Map.Entry<Integer, MObjectInfo> oneMObject : InterVar.moMaps.entrySet()) {  
49 -  
50 - if (StringUtils.equals(InterVar.AWS_TYPE, request.getType()) && oneMObject.getValue().getMoHostIp().startsWith(InterVar.AWS_PREFIX)) {  
51 -  
52 - nginxViewList.add(buildNginxView(oneMObject.getValue()));  
53 - } else if (StringUtils.equals(InterVar.QC_TYPE, request.getType()) && oneMObject.getValue().getMoHostIp().startsWith(InterVar.QC_PREFIX)) {  
54 -  
55 - nginxViewList.add(buildNginxView(oneMObject.getValue()));  
56 - } else {  
57 - 47 + if (StringUtils.equals(InterVar.AWS_TYPE, request.getType())) {
  48 + for (Map.Entry<Integer, MObjectInfo> oneMObject : InterVar.moMaps.entrySet()) {
  49 + if (oneMObject.getValue().getMoHostIp().startsWith(InterVar.AWS_PREFIX)) {
  50 + nginxViewList.add(buildNginxView(oneMObject.getValue()));
  51 + }
  52 + }
  53 + } else if (StringUtils.equals(InterVar.QC_TYPE, request.getType())) {
  54 + for (Map.Entry<Integer, MObjectInfo> oneMObject : InterVar.moMaps.entrySet()) {
  55 + if (oneMObject.getValue().getMoHostIp().startsWith(InterVar.QC_PREFIX)) {
  56 + nginxViewList.add(buildNginxView(oneMObject.getValue()));
  57 + }
  58 + }
  59 + } else {
  60 + for (Map.Entry<Integer, MObjectInfo> oneMObject : InterVar.moMaps.entrySet()) {
58 nginxViewList.add(buildNginxView(oneMObject.getValue())); 61 nginxViewList.add(buildNginxView(oneMObject.getValue()));
59 } 62 }
60 } 63 }
@@ -327,7 +330,6 @@ public class NginxService { @@ -327,7 +330,6 @@ public class NginxService {
327 } 330 }
328 331
329 332
330 -  
331 @RequestMapping(value = "/errTab") 333 @RequestMapping(value = "/errTab")
332 public BaseResponse queryErrTab(@RequestBody NginxTypeRequest request) { 334 public BaseResponse queryErrTab(@RequestBody NginxTypeRequest request) {
333 BaseResponse response = new BaseResponse(); 335 BaseResponse response = new BaseResponse();
@@ -372,5 +374,4 @@ public class NginxService { @@ -372,5 +374,4 @@ public class NginxService {
372 } 374 }
373 375
374 376
375 -  
376 } 377 }
@@ -17,7 +17,7 @@ public class ApiJob extends BaseLogJob { @@ -17,7 +17,7 @@ public class ApiJob extends BaseLogJob {
17 17
18 public ApiJob(InfluxComp influxComp, String type) { 18 public ApiJob(InfluxComp influxComp, String type) {
19 19
20 - super(influxComp, InterVar.APIACCESSMEASURE); 20 + super(influxComp, InterVar.APIACCESSMEASURE, type);
21 21
22 this.type = type; 22 this.type = type;
23 } 23 }
@@ -5,10 +5,12 @@ import com.monitor.middleware.nginx.constant.InterVar; @@ -5,10 +5,12 @@ import com.monitor.middleware.nginx.constant.InterVar;
5 import com.monitor.middleware.nginx.model.ApiSeriesModel; 5 import com.monitor.middleware.nginx.model.ApiSeriesModel;
6 import com.monitor.middleware.nginx.model.ApiStaModel; 6 import com.monitor.middleware.nginx.model.ApiStaModel;
7 import com.monitor.middleware.rabbitmq.component.InfluxComp; 7 import com.monitor.middleware.rabbitmq.component.InfluxComp;
  8 +import org.apache.commons.lang.StringUtils;
8 import org.aspectj.lang.annotation.After; 9 import org.aspectj.lang.annotation.After;
9 import org.influxdb.dto.BatchPoints; 10 import org.influxdb.dto.BatchPoints;
10 import org.influxdb.dto.Point; 11 import org.influxdb.dto.Point;
11 import org.influxdb.dto.QueryResult; 12 import org.influxdb.dto.QueryResult;
  13 +import org.jboss.netty.util.internal.StringUtil;
12 14
13 import java.text.DecimalFormat; 15 import java.text.DecimalFormat;
14 import java.util.*; 16 import java.util.*;
@@ -30,15 +32,19 @@ public class BaseLogJob implements Callable { @@ -30,15 +32,19 @@ public class BaseLogJob implements Callable {
30 32
31 protected List<ApiSeriesModel> apiSeriesModelList = new ArrayList<>(); 33 protected List<ApiSeriesModel> apiSeriesModelList = new ArrayList<>();
32 34
  35 + private String type;
  36 +
33 DecimalFormat format = new DecimalFormat("0.00"); 37 DecimalFormat format = new DecimalFormat("0.00");
34 38
35 protected String measureName; 39 protected String measureName;
36 40
37 - public BaseLogJob(InfluxComp influxComp, String measureName) { 41 + public BaseLogJob(InfluxComp influxComp, String measureName, String type) {
38 42
39 this.influxComp = influxComp; 43 this.influxComp = influxComp;
40 44
41 this.measureName = measureName; 45 this.measureName = measureName;
  46 +
  47 + this.type = type;
42 } 48 }
43 49
44 public void doTask() { 50 public void doTask() {
@@ -208,6 +214,9 @@ public class BaseLogJob implements Callable { @@ -208,6 +214,9 @@ public class BaseLogJob implements Callable {
208 214
209 for (List<Object> oneRow : oneSeries.getValues()) { 215 for (List<Object> oneRow : oneSeries.getValues()) {
210 216
  217 + if (!StringUtils.equals(type, queryLocation(oneRow.get(KINDEXMAPS.get("log_ip")).toString()))) {
  218 + continue;
  219 + }
211 ApiSeriesModel apiSeriesModel = new ApiSeriesModel(); 220 ApiSeriesModel apiSeriesModel = new ApiSeriesModel();
212 221
213 apiSeriesModel.setLogIp(oneRow.get(KINDEXMAPS.get("log_ip")).toString()); 222 apiSeriesModel.setLogIp(oneRow.get(KINDEXMAPS.get("log_ip")).toString());
@@ -219,6 +228,7 @@ public class BaseLogJob implements Callable { @@ -219,6 +228,7 @@ public class BaseLogJob implements Callable {
219 apiSeriesModel.setStatus(oneRow.get(KINDEXMAPS.get("request_status")).toString()); 228 apiSeriesModel.setStatus(oneRow.get(KINDEXMAPS.get("request_status")).toString());
220 229
221 apiSeriesModelList.add(apiSeriesModel); 230 apiSeriesModelList.add(apiSeriesModel);
  231 +
222 } 232 }
223 } 233 }
224 } 234 }
@@ -326,6 +336,15 @@ public class BaseLogJob implements Callable { @@ -326,6 +336,15 @@ public class BaseLogJob implements Callable {
326 } 336 }
327 } 337 }
328 338
  339 +
  340 + private String queryLocation(String ip) {
  341 + if (ip.startsWith(InterVar.AWS_PREFIX)) {
  342 + return InterVar.AWS_TYPE;
  343 + } else {
  344 + return InterVar.QC_TYPE;
  345 + }
  346 + }
  347 +
329 @Override 348 @Override
330 public Object call() throws Exception { 349 public Object call() throws Exception {
331 doTask(); 350 doTask();
@@ -206,6 +206,10 @@ public class ErrorLogJob implements Callable { @@ -206,6 +206,10 @@ public class ErrorLogJob implements Callable {
206 206
207 for (List<Object> oneRow : oneSeries.getValues()) { 207 for (List<Object> oneRow : oneSeries.getValues()) {
208 208
  209 + if(!StringUtils.equals(type,queryLocation(oneRow.get(KINDEMAPS.get("log_ip")).toString())))
  210 + {
  211 + continue;
  212 + }
209 ErrorSeriesModel errorSeriesModel = new ErrorSeriesModel(); 213 ErrorSeriesModel errorSeriesModel = new ErrorSeriesModel();
210 214
211 errorSeriesModel.setLogIp(oneRow.get(KINDEMAPS.get("log_ip")).toString()); 215 errorSeriesModel.setLogIp(oneRow.get(KINDEMAPS.get("log_ip")).toString());
@@ -214,7 +218,7 @@ public class ErrorLogJob implements Callable { @@ -214,7 +218,7 @@ public class ErrorLogJob implements Callable {
214 218
215 if (errorSeriesModel.getMessage().contains("Lua")) { 219 if (errorSeriesModel.getMessage().contains("Lua")) {
216 220
217 - errorSeriesModel.setType("LUA"); 221 + errorSeriesModel.setType("Lua");
218 222
219 } else if (errorSeriesModel.getMessage().contains(": Connection")) { 223 } else if (errorSeriesModel.getMessage().contains(": Connection")) {
220 224
@@ -229,8 +233,12 @@ public class ErrorLogJob implements Callable { @@ -229,8 +233,12 @@ public class ErrorLogJob implements Callable {
229 } 233 }
230 234
231 235
232 - public void callPercent() {  
233 - 236 + private String queryLocation(String ip) {
  237 + if (ip.startsWith(InterVar.AWS_PREFIX)) {
  238 + return InterVar.AWS_TYPE;
  239 + } else {
  240 + return InterVar.QC_TYPE;
  241 + }
234 } 242 }
235 243
236 } 244 }
@@ -15,7 +15,7 @@ public class ServiceJob extends BaseLogJob { @@ -15,7 +15,7 @@ public class ServiceJob extends BaseLogJob {
15 private String type; 15 private String type;
16 16
17 public ServiceJob(InfluxComp influxComp, String type) { 17 public ServiceJob(InfluxComp influxComp, String type) {
18 - super(influxComp, InterVar.SERACCESSMEASURE); 18 + super(influxComp, InterVar.SERACCESSMEASURE, type);
19 19
20 this.type = type; 20 this.type = type;
21 } 21 }
@@ -52,7 +52,7 @@ public class ServiceJob extends BaseLogJob { @@ -52,7 +52,7 @@ public class ServiceJob extends BaseLogJob {
52 52
53 InterVar.Aws_NGINX_SERVICE_HASH_MAP.putAll(this.resultMap); 53 InterVar.Aws_NGINX_SERVICE_HASH_MAP.putAll(this.resultMap);
54 } else { 54 } else {
55 - 55 +
56 InterVar.QC_NGINX_SERVICE_HASH_MAP.clear(); 56 InterVar.QC_NGINX_SERVICE_HASH_MAP.clear();
57 57
58 InterVar.QC_NGINX_SERVICE_HASH_MAP.putAll(this.resultMap); 58 InterVar.QC_NGINX_SERVICE_HASH_MAP.putAll(this.resultMap);