Skip to content

Commit

Permalink
Merge pull request #3 from uavorg/master
Browse files Browse the repository at this point in the history
merge with uavorg
  • Loading branch information
zhuang16384 authored Nov 3, 2017
2 parents 77b184f + d7a7880 commit 51185ee
Show file tree
Hide file tree
Showing 80 changed files with 6,559 additions and 214 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# UAVStack
UAVStack是由宜信技术研发中心推出的智能化服务技术栈,是研发运维一体化的解决方案。UAV是无人机的缩写,寓意无人机翱翔蓝天,智能的,透明的完成任务。
UAVStack是智能化服务技术栈,是研发运维一体化的解决方案。UAV是无人机的缩写,寓意无人机翱翔蓝天,智能的,透明的完成任务。
它包括任务机器人(代号HIT),全维监控(代号UAV.Monitor),应用性能管理(代号UAV.APM),服务治理(代号UAV.ServiceGovern),微服务计算(代号UAV.MSCP),用户体验管理(代号UAV.UEM)等。

UAVStack is an intelligent service technology stack launched by CreditEase Technology Research and Development Center. It is a solution for integration of R & D, operation and maintenance. UAV is the abbreviation of unmanned aerial vehicle (UAV), which means that unmanned aerial vehicle flies into the sky, and completes tasks intelligently and transparently.
UAVStack is an intelligent service technology stack. It is a solution for integration of R & D, operation and maintenance. UAV is the abbreviation of unmanned aerial vehicle (UAV), which means that unmanned aerial vehicle flies into the sky, and completes tasks intelligently and transparently.

It includes AIOps Robot (HIT),full dimension monitoring (UAV.Monitor), application performance management (UAV.APM), service governance (UAV.ServiceGovern), micro-service computing (UAV.MSCP), user experience management (UAV.UEM) etc..

Expand All @@ -13,7 +13,7 @@ UAVStack Open Source series includes UAV.Monitor, UAV.APM, UAV.ServiceGovern, UA

![Uavstack开源系列](https://uavorg.github.io/main/index/img/support/openSource.png)

# 更新公告 Project Updating Principle
# 更新模式 Project Updating Principle
* 开源系列源代码Issue更新,将与内部版本完全同步,最低频率每周一次
* 开源系列源代码相关的功能优化,将与内部版本完全同步,最低频率每周一次
* 开源系列源代码相关的新功能开放,会提前一周预告,并于下周内发布
Expand Down
4 changes: 2 additions & 2 deletions com.creditease.uav.base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.25.Final</version>
<version>4.1.11.Final</version>
</dependency>
</dependencies>

Expand Down Expand Up @@ -57,4 +57,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
app.title=基础集群管理
app.@eshead={"index":"1","title":"ES管理","file":"index.html"}
app.@jumpurl_1={"index":"2","title":"MQ管理","file":"jumpurl@http://uav.creditease.corp/rocket/cluster/list.do"}
app.@dbhead={"index":"3","title":"OpenTSDB管理","file":"index.html"}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
app.title=基础集群管理
app.@eshead={"index":"1","title":"ES管理","file":"index.html"}
app.@jumpurl_1={"index":"2","title":"MQ管理","file":"jumpurl@http://127.0.0.1:8080/rocket/cluster/list.do"}
app.@dbhead={"index":"3","title":"OpenTSDB管理","file":"index.html"}
36 changes: 36 additions & 0 deletions com.creditease.uav.console.buildComponent/config/web_pro.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,38 @@
<servlet-name>es-serlvet</servlet-name>
<url-pattern>/es/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>opentsdb-crdu-servlet</servlet-name>
<servlet-class>com.creditease.uav.opentsdb.OpenTSDBRestCRDUServlet</servlet-class>
<load-on-startup>2</load-on-startup>
<async-supported>true</async-supported>
</servlet>

<servlet-mapping>
<servlet-name>opentsdb-crdu-servlet</servlet-name>
<url-pattern>/db/*</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>opentsdb-agent-servlet</servlet-name>
<servlet-class>com.creditease.uav.opentsdb.OpenTSDBRestAgentServlet</servlet-class>
<load-on-startup>2</load-on-startup>
<async-supported>true</async-supported>
</servlet>

<servlet-mapping>
<servlet-name>opentsdb-agent-servlet</servlet-name>
<!-- <url-pattern>/db2/*</url-pattern>
<url-pattern>/s/*</url-pattern>
<url-pattern>/q/*</url-pattern> -->
<url-pattern>/db2/q</url-pattern>
<url-pattern>/db2/suggest</url-pattern>
<url-pattern>/db2/stats</url-pattern>
<url-pattern>/db2/logs</url-pattern>
<url-pattern>/db2/version</url-pattern>
<url-pattern>/db2/</url-pattern>
<url-pattern>/db2/aggregators</url-pattern>
</servlet-mapping>
<!-- jersey restful service END -->

<!-- filter START -->
Expand Down Expand Up @@ -202,6 +234,10 @@
<param-name>uav.apphub.sso.grafana.connection.info</param-name>
<param-value>{"api.url":"http://127.0.0.1:3000","web.url":"http://uav.creditease.corp/datacenter","datasource.opentsdb.url":"http://127.0.0.1:4242","datasource.elasticsearch.url":"http://127.0.0.1:9300","authorization.loginId":"apiuser","authorization.loginPwd":"Uav!630admin","authorization.register.defPwd":"1q@W3e","authorization.register.sleep.time":"2000"}</param-value>
</context-param>
<context-param>
<param-name>uav.app.opentsdb.http.client.params</param-name>
<param-value>{"max.con":50,"max.tot.con":200,"sock.time.out":10000,"con.time.out":10000,"req.time.out":10000}</param-value>
</context-param>
<context-param>
<param-name>uav.apphub.sso.white.list</param-name>
<!--
Expand Down
36 changes: 36 additions & 0 deletions com.creditease.uav.console.buildComponent/config/web_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,38 @@
<servlet-name>es-serlvet</servlet-name>
<url-pattern>/es/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>opentsdb-crdu-servlet</servlet-name>
<servlet-class>com.creditease.uav.opentsdb.OpenTSDBRestCRDUServlet</servlet-class>
<load-on-startup>2</load-on-startup>
<async-supported>true</async-supported>
</servlet>

<servlet-mapping>
<servlet-name>opentsdb-crdu-servlet</servlet-name>
<url-pattern>/db/*</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>opentsdb-agent-servlet</servlet-name>
<servlet-class>com.creditease.uav.opentsdb.OpenTSDBRestAgentServlet</servlet-class>
<load-on-startup>2</load-on-startup>
<async-supported>true</async-supported>
</servlet>

<servlet-mapping>
<servlet-name>opentsdb-agent-servlet</servlet-name>
<!-- <url-pattern>/db2/*</url-pattern>
<url-pattern>/s/*</url-pattern>
<url-pattern>/q/*</url-pattern> -->
<url-pattern>/db2/q</url-pattern>
<url-pattern>/db2/suggest</url-pattern>
<url-pattern>/db2/stats</url-pattern>
<url-pattern>/db2/logs</url-pattern>
<url-pattern>/db2/version</url-pattern>
<url-pattern>/db2/</url-pattern>
<url-pattern>/db2/aggregators</url-pattern>
</servlet-mapping>
<!-- jersey restful service END -->

<!-- filter START -->
Expand Down Expand Up @@ -206,6 +238,10 @@
<param-name>uav.apphub.sso.grafana.connection.info</param-name>
<param-value>{"api.url":"http://127.0.0.1:3000","web.url":"http://127.0.0.1:3000","datasource.opentsdb.url":"http://127.0.0.1:4243","datasource.elasticsearch.url":"http://127.0.0.1:9200","authorization.loginId":"apiuser","authorization.loginPwd":"apiuser","authorization.register.defPwd":"1q@W3e","authorization.register.sleep.time":"2000"}</param-value>
</context-param>
<context-param>
<param-name>uav.app.opentsdb.http.client.params</param-name>
<param-value>{"max.con":50,"max.tot.con":200,"sock.time.out":10000,"con.time.out":10000,"req.time.out":10000}</param-value>
</context-param>
<context-param>
<param-name>uav.apphub.sso.white.list</param-name>
<!--
Expand Down
6 changes: 6 additions & 0 deletions com.creditease.uav.console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
<artifactId>aredis-api</artifactId>
<version>1.4</version>
</dependency>

<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
package com.creditease.uav.opentsdb;

import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;

import com.creditease.agent.helpers.JSONHelper;
import com.creditease.agent.log.SystemLogger;
import com.creditease.agent.log.api.ISystemLogger;
import com.creditease.uav.httpasync.HttpAsyncClient;
import com.creditease.uav.httpasync.HttpAsyncClientFactory;
import com.creditease.uav.httpasync.HttpClientCallback;
import com.creditease.uav.httpasync.HttpClientCallbackResult;

public class OpenTSDBRestAgentServlet extends HttpServlet {

private static HttpAsyncClient httpAsyncClient = null;

private static final long serialVersionUID = 1441879223883391706L;

private static Map<String, String> info = null;

private static String url;

@SuppressWarnings("unchecked")
@Override
public void init() throws ServletException {

if (null == info) {
String esInfo = this.getInitParameter("db.info");
info = JSONHelper.toObject(esInfo, Map.class);
}

if (null == httpAsyncClient) {
Map<String, Integer> httpParamsMap = JSONHelper
.toObject(getServletContext().getInitParameter("uav.app.es.http.client.params"), Map.class);
httpAsyncClient = HttpAsyncClientFactory.build(httpParamsMap.get("max.con"),
httpParamsMap.get("max.tot.con"), httpParamsMap.get("sock.time.out"),
httpParamsMap.get("con.time.out"), httpParamsMap.get("req.time.out"));
}
}

@Override
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

String para_url = req.getParameter("url");
if (null != para_url) {
url = para_url;
}
if (url.endsWith("/")) {
url = url.substring(0, url.length() - 1);
}
// 获取请求资源
String proName = req.getServletContext().getContextPath();
String requestSource = req.getRequestURI();
requestSource = requestSource.substring(requestSource.indexOf(proName) + proName.length());
String queryString = req.getQueryString();

if (requestSource.startsWith("/db2")) {
requestSource = requestSource.substring(4);
}
if (requestSource.contains("queryDb")) {
requestSource = "/";
}
/**
* get url
*/
String forwarUrl;
if (queryString != null && !queryString.contains("url=")) {
forwarUrl = url + requestSource + "?" + queryString;
}
else {
forwarUrl = url + requestSource;
}
/**
* get method
*/
String method = req.getMethod();
/**
* get body
*/
ServletInputStream input = req.getInputStream();
httpAsyncClient.doAsyncHttpMethodWithReqAsync(method, forwarUrl, null, input, null, null, "application/json",
"utf-8", new OpenTSDBRestAgentServletCallBack(resp, forwarUrl), req);

}

}

class OpenTSDBRestAgentServletCallBack implements HttpClientCallback {

private HttpServletResponse resp;
private String url;

public OpenTSDBRestAgentServletCallBack(HttpServletResponse resp, String forwarUrl) {
super();
this.resp = resp;
this.url = forwarUrl;
}

@Override
public void completed(HttpClientCallbackResult result) {

resp(result);
}

@Override
public void failed(HttpClientCallbackResult result) {

resp(result);
}

private void resp(HttpClientCallbackResult result) {

if (null != result.getException()) {
ISystemLogger logger = SystemLogger.getLogger(OpenTSDBRestAgentServletCallBack.class);
logger.err(this, result.getException().getMessage(), result.getException());
}
else {
String respStr = result.getReplyDataAsString();
if (url.endsWith(".jpg") || url.endsWith(".png") || url.endsWith("&png")) {
downLoadImage(resp, url);
return;
}
try {
result.getResponseForRequestAsync().write(respStr.getBytes("UTF-8"));
result.getResponseForRequestAsync().flush();
result.getResponseForRequestAsync().close();
}
catch (IOException e) {
ISystemLogger logger = SystemLogger.getLogger(OpenTSDBRestAgentServletCallBack.class);
logger.err(this, result.getException().getMessage(), result.getException());
}

}

}

private void downLoadImage(HttpServletResponse resp, String url) {

HttpClient client = new HttpClient();
GetMethod get = null;
try {
String path = url;
get = new GetMethod(path);
int i = client.executeMethod(get);
if (200 == i) {
resp.setHeader("content-disposition", "attachment;fileName=" + URLEncoder.encode(path, "UTF-8"));
OutputStream out = null;
out = resp.getOutputStream();
out.write(get.getResponseBody());
out.flush();
out.close();
}
else {
ISystemLogger logger = SystemLogger.getLogger(OpenTSDBRestAgentServletCallBack.class);
logger.err(this, "no pic");
}
}
catch (Exception e) {
ISystemLogger logger = SystemLogger.getLogger(OpenTSDBRestAgentServletCallBack.class);
logger.err(this, e.getMessage());
}
finally {
get.releaseConnection();
client.getHttpConnectionManager().closeIdleConnections(0);
}
}
}
Loading

0 comments on commit 51185ee

Please sign in to comment.