Authored by qinchao

去掉不用类

... ... @@ -29,20 +29,5 @@ public class InfluxDBQuery {
}
}
public Map<String,Object> queryWithCheckException(String influxDBName, String command, String database){
Map<String,Object> map=new HashMap<String,Object>();
String exceptionFlag="";
Query query = new Query(command, database);
try {
QueryResult queryResult = inluxDBSingle.getInfluxDBByName(influxDBName)
.getInfluxDB().query(query);
map.put("queryResult",queryResult);
} catch (Exception e) {
exceptionFlag="1";
logger.error("influxdb query failed! influxDBName:{},commond:{},database:{},exception{}",influxDBName,command,database,e);
}
map.put("exceptionFlag",exceptionFlag);
return map;
}
}
... ...
... ... @@ -10,6 +10,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* 写入事件到InfluxData中
* <p/>
... ... @@ -77,4 +80,21 @@ public class InfluxDataReporter {
return null;
}
}
public Map<String,Object> queryWithCheckException(String influxDBName, String command, String database){
Map<String,Object> map=new HashMap<String,Object>();
String exceptionFlag="";
Query query = new Query(command, database);
try {
QueryResult queryResult = inluxDBSingle.getInfluxDBByName(influxDBName)
.getInfluxDB().query(query);
map.put("queryResult",queryResult);
} catch (Exception e) {
exceptionFlag="1";
log.error("influxdb query failed! influxDBName:{},commond:{},database:{},exception{}",influxDBName,command,database,e);
}
map.put("exceptionFlag",exceptionFlag);
return map;
}
}
... ...
package com.monitor.influxdb.mapper.impl;
import com.monitor.influxdb.InfluxDBQuery;
import org.springframework.stereotype.Service;
/**
* Created by zhengyouwei on 2016/8/12.
*/
@Service("CommonQuery")
public class CommonQuery extends InfluxDBQuery{
}
package com.monitor.influxdb;
import com.monitor.influxdb.mapper.impl.CommonQuery;
import com.monitor.influxdb.util.QueryResultUtil;
import org.influxdb.dto.Pong;
import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
import org.junit.Before;
import org.junit.Test;
... ... @@ -11,12 +8,9 @@ import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.Iterator;
import java.util.List;
/**
... ... @@ -32,7 +26,7 @@ public class InfluxDBSimpleTest {
private InluxDBSingle inluxDBSingle;
@Autowired
private CommonQuery commonQuery;
private InfluxDataReporter commonQuery;
@Before
public void init() {
... ... @@ -62,7 +56,7 @@ public class InfluxDBSimpleTest {
}*/
String sql="select \"name\",number from test";
String db="gml_test";
QueryResult queryResult = commonQuery.query("test", sql, db);
QueryResult queryResult = commonQuery.queryResult("test", sql, db);
logger.info("{}",queryResult);
List<QueryResult.Series> seriesList = QueryResultUtil.getSeries(queryResult);
if (seriesList == null) {
... ...
package com.monitor.other.systemTest;
import com.monitor.common.util.TaskPlanRecord;
import com.monitor.influxdb.InfluxDataReporter;
import com.monitor.influxdb.contants.InfluxDBContants;
import com.monitor.influxdb.mapper.impl.CommonQuery;
import com.monitor.influxdb.util.QueryResultUtil;
import com.monitor.model.response.BaseResponse;
import org.influxdb.dto.QueryResult;
... ... @@ -21,7 +21,7 @@ import java.util.Calendar;
public class SystemTest {
@Autowired
private CommonQuery commonQuery;
private InfluxDataReporter commonQuery;
@RequestMapping("test")
@ResponseBody
... ... @@ -29,7 +29,7 @@ public class SystemTest {
Calendar calendar = Calendar.getInstance();
if(calendar.get(Calendar.HOUR_OF_DAY) > 9 && calendar.get(Calendar.HOUR_OF_DAY) < 21){
String command = "SELECT count(\"uid\") FROM \"yoho_payment_report\" WHERE time > now() - 15m and clientType = 'iphone'";
QueryResult queryResult = commonQuery.query(InfluxDBContants.AWS, command, InfluxDBContants.YOMO_MONITOR);
QueryResult queryResult = commonQuery.queryResult(InfluxDBContants.AWS, command, InfluxDBContants.YOMO_MONITOR);
int count = QueryResultUtil.getCount(queryResult);
if (TaskPlanRecord.getLast() != 0){
... ...
... ... @@ -3,7 +3,7 @@ package com.monitor.other.task;
import com.model.TaskModel;
import com.monitor.common.util.ApplicationUtil;
import com.monitor.influxdb.mapper.impl.CommonQuery;
import com.monitor.influxdb.InfluxDataReporter;
import com.monitor.influxdb.util.QueryResultUtil;
import com.monitor.mysql.mapper.TaskSheduleMapper;
import org.apache.commons.lang.StringUtils;
... ... @@ -111,7 +111,7 @@ public class SingleTask implements Runnable {
Map<String, List<List<Map<String, Object>>>> resultMap = new HashMap<>();
Map<String,Boolean> exceptionMap=new HashMap<String,Boolean>();
for (String influxdb : influxdbs) {
Map<String,Object> queryResultMap = ((CommonQuery)ApplicationUtil.getBean(CommonQuery.class)).queryWithCheckException(influxdb, sql, taskModel.getDatabase());
Map<String,Object> queryResultMap = ((InfluxDataReporter)ApplicationUtil.getBean(InfluxDataReporter.class)).queryWithCheckException(influxdb, sql, taskModel.getDatabase());
QueryResult queryResult = (QueryResult)queryResultMap.get("queryResult");
String exceptionFlag=(String)queryResultMap.get("exceptionFlag");
if("1".equals(exceptionFlag)){
... ...