Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
killuaz丶x
SkyWalking
提交
96197120
S
SkyWalking
项目概览
killuaz丶x
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
96197120
编写于
1月 21, 2018
作者:
P
peng-yongsheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Provide GraphQL jetty servlet do get method.
上级
6b3aa98b
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
259 addition
and
7 deletion
+259
-7
apm-collector/apm-collector-component/server-component/src/main/java/org/apache/skywalking/apm/collector/server/jetty/JettyHandler.java
...e/skywalking/apm/collector/server/jetty/JettyHandler.java
+3
-4
apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreator.java
...e/skywalking/apm/collector/ui/graphql/GraphQLCreator.java
+59
-0
apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/Alarm.java
...ache/skywalking/apm/collector/ui/graphql/alarm/Alarm.java
+16
-0
apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmQuery.java
...skywalking/apm/collector/ui/graphql/alarm/AlarmQuery.java
+5
-3
apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Duration.java
.../skywalking/apm/collector/ui/graphql/common/Duration.java
+23
-0
apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Pagination.java
...kywalking/apm/collector/ui/graphql/common/Pagination.java
+24
-0
apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreatorTestCase.java
...king/apm/collector/ui/graphql/GraphQLCreatorTestCase.java
+34
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java
...walking/apm/collector/ui/jetty/UIModuleJettyProvider.java
+3
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java
...alking/apm/collector/ui/jetty/handler/GraphQLHandler.java
+92
-0
未找到文件。
apm-collector/apm-collector-component/server-component/src/main/java/org/apache/skywalking/apm/collector/server/jetty/JettyHandler.java
浏览文件 @
96197120
...
...
@@ -16,7 +16,6 @@
*
*/
package
org.apache.skywalking.apm.collector.server.jetty
;
import
com.google.gson.JsonElement
;
...
...
@@ -61,7 +60,7 @@ public abstract class JettyHandler extends HttpServlet implements ServerHandler
}
}
protected
abstract
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
;
protected
abstract
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
,
IOException
;
@Override
protected
final
void
doHead
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
...
...
@@ -150,7 +149,7 @@ public abstract class JettyHandler extends HttpServlet implements ServerHandler
}
private
void
reply
(
HttpServletResponse
response
,
JsonElement
resJson
)
throws
IOException
{
response
.
setContentType
(
"
text
/json"
);
response
.
setContentType
(
"
application
/json"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
...
...
@@ -163,7 +162,7 @@ public abstract class JettyHandler extends HttpServlet implements ServerHandler
}
private
void
replyError
(
HttpServletResponse
response
,
String
errorMessage
,
int
status
)
throws
IOException
{
response
.
setContentType
(
"
text/plai
n"
);
response
.
setContentType
(
"
application/jso
n"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setStatus
(
status
);
response
.
setHeader
(
"error-message"
,
errorMessage
);
...
...
apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreator.java
0 → 100644
浏览文件 @
96197120
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.collector.ui.graphql
;
import
com.coxautodev.graphql.tools.SchemaParser
;
import
graphql.GraphQL
;
import
graphql.schema.GraphQLSchema
;
import
org.apache.skywalking.apm.collector.ui.graphql.alarm.AlarmQuery
;
import
org.apache.skywalking.apm.collector.ui.graphql.application.ApplicationQuery
;
import
org.apache.skywalking.apm.collector.ui.graphql.application.ConjecturalNode
;
import
org.apache.skywalking.apm.collector.ui.graphql.common.VisualUserNode
;
import
org.apache.skywalking.apm.collector.ui.graphql.config.ConfigMutation
;
import
org.apache.skywalking.apm.collector.ui.graphql.config.ConfigQuery
;
import
org.apache.skywalking.apm.collector.ui.graphql.overview.OverViewLayerQuery
;
import
org.apache.skywalking.apm.collector.ui.graphql.server.ServerQuery
;
import
org.apache.skywalking.apm.collector.ui.graphql.service.ServiceQuery
;
import
org.apache.skywalking.apm.collector.ui.graphql.trace.TraceQuery
;
/**
* @author peng-yongsheng
*/
public
class
GraphQLCreator
{
public
GraphQL
create
()
{
GraphQLSchema
schema
=
SchemaParser
.
newParser
()
.
file
(
"ui-graphql/alarm.graphqls"
)
.
file
(
"ui-graphql/application-layer.graphqls"
)
.
file
(
"ui-graphql/common.graphqls"
)
.
file
(
"ui-graphql/config.graphqls"
)
.
file
(
"ui-graphql/overview-layer.graphqls"
)
.
file
(
"ui-graphql/server-layer.graphqls"
)
.
file
(
"ui-graphql/service-layer.graphqls"
)
.
file
(
"ui-graphql/trace.graphqls"
)
.
resolvers
(
new
VersionQuery
(),
new
VersionMutation
(),
new
AlarmQuery
(),
new
ApplicationQuery
())
.
resolvers
(
new
OverViewLayerQuery
(),
new
ServerQuery
(),
new
ServiceQuery
(),
new
TraceQuery
())
.
resolvers
(
new
ConfigQuery
(),
new
ConfigMutation
())
.
dictionary
(
ConjecturalNode
.
class
,
VisualUserNode
.
class
)
.
build
()
.
makeExecutableSchema
();
return
GraphQL
.
newGraphQL
(
schema
).
build
();
}
}
apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/Alarm.java
浏览文件 @
96197120
...
...
@@ -26,4 +26,20 @@ import java.util.List;
public
class
Alarm
{
private
List
<
AlarmItem
>
items
;
private
Integer
count
;
public
List
<
AlarmItem
>
getItems
()
{
return
items
;
}
public
void
setItems
(
List
<
AlarmItem
>
items
)
{
this
.
items
=
items
;
}
public
Integer
getCount
()
{
return
count
;
}
public
void
setCount
(
Integer
count
)
{
this
.
count
=
count
;
}
}
apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmQuery.java
浏览文件 @
96197120
...
...
@@ -26,8 +26,10 @@ import org.apache.skywalking.apm.collector.ui.graphql.common.Pagination;
* @author peng-yongsheng
*/
public
class
AlarmQuery
implements
Query
{
public
Alarm
loadAlertList
(
String
keyword
,
AlarmType
alarmType
,
Duration
duration
,
Pagination
pagination
)
{
return
null
;
public
Alarm
loadAlertList
(
String
keyword
,
AlarmType
alarmType
,
Duration
duration
,
Pagination
pagination
)
{
Alarm
alarm
=
new
Alarm
();
alarm
.
setCount
(
0
);
return
alarm
;
}
}
apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Duration.java
浏览文件 @
96197120
...
...
@@ -27,4 +27,27 @@ public class Duration {
private
String
end
;
private
Step
step
;
public
String
getStart
()
{
return
start
;
}
public
void
setStart
(
String
start
)
{
this
.
start
=
start
;
}
public
String
getEnd
()
{
return
end
;
}
public
void
setEnd
(
String
end
)
{
this
.
end
=
end
;
}
public
Step
getStep
()
{
return
step
;
}
public
void
setStep
(
Step
step
)
{
this
.
step
=
step
;
}
}
apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Pagination.java
浏览文件 @
96197120
...
...
@@ -25,4 +25,28 @@ public class Pagination {
private
Integer
pageNum
;
private
Integer
pageSize
;
private
Boolean
needTotal
;
public
Integer
getPageNum
()
{
return
pageNum
;
}
public
void
setPageNum
(
Integer
pageNum
)
{
this
.
pageNum
=
pageNum
;
}
public
Integer
getPageSize
()
{
return
pageSize
;
}
public
void
setPageSize
(
Integer
pageSize
)
{
this
.
pageSize
=
pageSize
;
}
public
Boolean
getNeedTotal
()
{
return
needTotal
;
}
public
void
setNeedTotal
(
Boolean
needTotal
)
{
this
.
needTotal
=
needTotal
;
}
}
apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreatorTestCase.java
0 → 100644
浏览文件 @
96197120
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.collector.ui.graphql
;
import
graphql.GraphQL
;
import
org.junit.Test
;
/**
* @author peng-yongsheng
*/
public
class
GraphQLCreatorTestCase
{
@Test
public
void
test
()
{
GraphQLCreator
creator
=
new
GraphQLCreator
();
GraphQL
graphQL
=
creator
.
create
();
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java
浏览文件 @
96197120
...
...
@@ -33,6 +33,7 @@ import org.apache.skywalking.apm.collector.naming.service.NamingHandlerRegisterS
import
org.apache.skywalking.apm.collector.server.Server
;
import
org.apache.skywalking.apm.collector.storage.StorageModule
;
import
org.apache.skywalking.apm.collector.ui.UIModule
;
import
org.apache.skywalking.apm.collector.ui.jetty.handler.GraphQLHandler
;
import
org.apache.skywalking.apm.collector.ui.jetty.handler.SegmentTopGetHandler
;
import
org.apache.skywalking.apm.collector.ui.jetty.handler.SpanGetHandler
;
import
org.apache.skywalking.apm.collector.ui.jetty.handler.TraceDagGetHandler
;
...
...
@@ -110,5 +111,7 @@ public class UIModuleJettyProvider extends ModuleProvider {
jettyServer
.
addHandler
(
new
SpanGetHandler
(
getManager
()));
jettyServer
.
addHandler
(
new
TraceDagGetHandler
(
getManager
()));
jettyServer
.
addHandler
(
new
TraceStackGetHandler
(
getManager
()));
jettyServer
.
addHandler
(
new
GraphQLHandler
());
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java
0 → 100644
浏览文件 @
96197120
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.collector.ui.jetty.handler
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
graphql.ExecutionInput
;
import
graphql.ExecutionResult
;
import
graphql.GraphQL
;
import
graphql.GraphQLError
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.skywalking.apm.collector.core.util.CollectionUtils
;
import
org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException
;
import
org.apache.skywalking.apm.collector.server.jetty.JettyHandler
;
import
org.apache.skywalking.apm.collector.ui.graphql.GraphQLCreator
;
/**
* @author peng-yongsheng
*/
public
class
GraphQLHandler
extends
JettyHandler
{
private
final
Gson
gson
=
new
Gson
();
private
final
GraphQL
graphQL
;
private
static
final
String
QUERY
=
"query"
;
private
static
final
String
DATA
=
"data"
;
private
static
final
String
ERRORS
=
"errors"
;
public
GraphQLHandler
()
{
GraphQLCreator
creator
=
new
GraphQLCreator
();
this
.
graphQL
=
creator
.
create
();
}
@Override
public
String
pathSpec
()
{
return
"/graphql"
;
}
@Override
protected
JsonElement
doGet
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
return
execute
(
req
.
getParameter
(
QUERY
));
}
@Override
protected
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
,
IOException
{
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
req
.
getInputStream
()));
String
line
;
String
request
=
""
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
request
+=
line
;
}
return
execute
(
request
);
}
private
JsonObject
execute
(
String
request
)
{
ExecutionInput
executionInput
=
ExecutionInput
.
newExecutionInput
().
query
(
request
).
build
();
ExecutionResult
executionResult
=
graphQL
.
execute
(
executionInput
);
Object
data
=
executionResult
.
getData
();
List
<
GraphQLError
>
errors
=
executionResult
.
getErrors
();
JsonObject
jsonObject
=
new
JsonObject
();
jsonObject
.
addProperty
(
DATA
,
data
.
toString
());
if
(
CollectionUtils
.
isNotEmpty
(
errors
))
{
String
errorJsonStr
=
gson
.
toJson
(
errors
,
JsonArray
.
class
);
JsonArray
errorArray
=
gson
.
fromJson
(
errorJsonStr
,
JsonArray
.
class
);
jsonObject
.
add
(
ERRORS
,
errorArray
);
}
return
jsonObject
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录