流量统计增加活跃IPTOP10一个小时内的趋势,增加一个小时内TOP10最大值,增加接口错误处理

This commit is contained in:
zhanghongqing
2018-10-12 18:12:24 +08:00
parent 2fc5d87067
commit 6195d6042c
9 changed files with 1442 additions and 1228 deletions

View File

@@ -9,6 +9,7 @@
package com.nis.util.httpclient;
import java.io.IOException;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.net.URI;
import java.util.ArrayList;
@@ -67,7 +68,7 @@ public class HttpClientUtil {
* @throws IOException
* @throws ClientProtocolException
*/
public static String get(String url) throws ClientProtocolException, IOException{
public static String get(String url) throws Exception{
//实例化httpclient
CloseableHttpClient httpclient = HttpClients.createDefault();
//实例化get方法
@@ -75,19 +76,16 @@ public class HttpClientUtil {
//请求结果
CloseableHttpResponse response = null;
String content ="";
try {
logger.info("流量统计数据请求路径:"+url);
//执行get方法
response = httpclient.execute(httpget);
if(response.getStatusLine().getStatusCode()==HttpStatus.SC_OK){
content = EntityUtils.toString(response.getEntity(),"utf-8");
logger.debug("获取消息成功,相应内容如下: " + content);
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
logger.info("dashboard图表数据请求路径:"+url);
logger.info("获取流量统计数据成功,相应内容如下: " + content);
}else {
logger.error("获取消息失败,相应内容如下: " + content);
throw new ConnectException("流量统计服务接口连接错误"+content);
}
return content;
}
@@ -322,13 +320,13 @@ public class HttpClientUtil {
}
public static void main(String[] args) throws ClientProtocolException, IOException {
HttpClientUtil hd = new HttpClientUtil();
hd.get("http://10.0.6.115:9200/_sql?sql=select * from dfipportlog-2016-09-07-15 limit 1 10");
Map<String,String> map = new HashMap();
map.put("id","1");
hd.post("http://localhost:8080/springMVC/menu/getChildren.do",map);
}
// public static void main(String[] args) throws ClientProtocolException, IOException {
// HttpClientUtil hd = new HttpClientUtil();
//// hd.get("http://10.0.6.115:9200/_sql?sql=select * from dfipportlog-2016-09-07-15 limit 1 10");
// Map<String,String> map = new HashMap();
// map.put("id","1");
// hd.post("http://localhost:8080/springMVC/menu/getChildren.do",map);
//
// }
}