Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿信在这里
SkyWalking
提交
5828f286
S
SkyWalking
项目概览
阿信在这里
/
SkyWalking
与 Fork 源项目一致
Fork自
山不在高_有仙则灵 / 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,发现更多精彩内容 >>
提交
5828f286
编写于
10月 26, 2017
作者:
P
peng-yongsheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add server component
上级
fcea41f9
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
460 addition
and
0 deletion
+460
-0
apm-collector/apm-collector-component/server-component/src/main/java/org/skywalking/apm/collector/server/grpc/GRPCHandler.java
...org/skywalking/apm/collector/server/grpc/GRPCHandler.java
+27
-0
apm-collector/apm-collector-component/server-component/src/main/java/org/skywalking/apm/collector/server/grpc/GRPCServer.java
.../org/skywalking/apm/collector/server/grpc/GRPCServer.java
+73
-0
apm-collector/apm-collector-component/server-component/src/main/java/org/skywalking/apm/collector/server/grpc/GRPCServerException.java
...alking/apm/collector/server/grpc/GRPCServerException.java
+35
-0
apm-collector/apm-collector-component/server-component/src/main/java/org/skywalking/apm/collector/server/jetty/ArgumentsParseException.java
...g/apm/collector/server/jetty/ArgumentsParseException.java
+35
-0
apm-collector/apm-collector-component/server-component/src/main/java/org/skywalking/apm/collector/server/jetty/JettyHandler.java
...g/skywalking/apm/collector/server/jetty/JettyHandler.java
+174
-0
apm-collector/apm-collector-component/server-component/src/main/java/org/skywalking/apm/collector/server/jetty/JettyServer.java
...rg/skywalking/apm/collector/server/jetty/JettyServer.java
+81
-0
apm-collector/apm-collector-component/server-component/src/main/java/org/skywalking/apm/collector/server/jetty/JettyServerException.java
...king/apm/collector/server/jetty/JettyServerException.java
+35
-0
未找到文件。
apm-collector/apm-collector-component/server-component/src/main/java/org/skywalking/apm/collector/server/grpc/GRPCHandler.java
0 → 100644
浏览文件 @
5828f286
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.server.grpc
;
import
org.skywalking.apm.collector.core.framework.Handler
;
/**
* @author peng-yongsheng
*/
public
interface
GRPCHandler
extends
Handler
{
}
apm-collector/apm-collector-component/server-component/src/main/java/org/skywalking/apm/collector/server/grpc/GRPCServer.java
0 → 100644
浏览文件 @
5828f286
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.server.grpc
;
import
io.grpc.netty.NettyServerBuilder
;
import
java.io.IOException
;
import
java.net.InetSocketAddress
;
import
org.skywalking.apm.collector.core.framework.Handler
;
import
org.skywalking.apm.collector.core.server.Server
;
import
org.skywalking.apm.collector.core.server.ServerException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
GRPCServer
implements
Server
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
GRPCServer
.
class
);
private
final
String
host
;
private
final
int
port
;
private
io
.
grpc
.
Server
server
;
private
NettyServerBuilder
nettyServerBuilder
;
public
GRPCServer
(
String
host
,
int
port
)
{
this
.
host
=
host
;
this
.
port
=
port
;
}
@Override
public
String
hostPort
()
{
return
host
+
":"
+
port
;
}
@Override
public
String
serverClassify
()
{
return
"Google-RPC"
;
}
@Override
public
void
initialize
()
throws
ServerException
{
InetSocketAddress
address
=
new
InetSocketAddress
(
host
,
port
);
nettyServerBuilder
=
NettyServerBuilder
.
forAddress
(
address
);
logger
.
info
(
"Server started, host {} listening on {}"
,
host
,
port
);
}
@Override
public
void
start
()
throws
ServerException
{
try
{
server
=
nettyServerBuilder
.
build
();
server
.
start
();
}
catch
(
IOException
e
)
{
throw
new
GRPCServerException
(
e
.
getMessage
(),
e
);
}
}
@Override
public
void
addHandler
(
Handler
handler
)
{
nettyServerBuilder
.
addService
((
io
.
grpc
.
BindableService
)
handler
);
}
}
apm-collector/apm-collector-component/server-component/src/main/java/org/skywalking/apm/collector/server/grpc/GRPCServerException.java
0 → 100644
浏览文件 @
5828f286
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.server.grpc
;
import
org.skywalking.apm.collector.core.server.ServerException
;
/**
* @author peng-yongsheng
*/
public
class
GRPCServerException
extends
ServerException
{
public
GRPCServerException
(
String
message
)
{
super
(
message
);
}
public
GRPCServerException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
apm-collector/apm-collector-component/server-component/src/main/java/org/skywalking/apm/collector/server/jetty/ArgumentsParseException.java
0 → 100644
浏览文件 @
5828f286
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.server.jetty
;
import
org.skywalking.apm.collector.core.CollectorException
;
/**
* @author peng-yongsheng
*/
public
class
ArgumentsParseException
extends
CollectorException
{
public
ArgumentsParseException
(
String
message
)
{
super
(
message
);
}
public
ArgumentsParseException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
apm-collector/apm-collector-component/server-component/src/main/java/org/skywalking/apm/collector/server/jetty/JettyHandler.java
0 → 100644
浏览文件 @
5828f286
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.server.jetty
;
import
com.google.gson.JsonElement
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.util.Enumeration
;
import
javax.servlet.ServletConfig
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletResponse
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.skywalking.apm.collector.core.framework.Handler
;
import
org.skywalking.apm.collector.core.util.ObjectUtils
;
/**
* @author peng-yongsheng
*/
public
abstract
class
JettyHandler
extends
HttpServlet
implements
Handler
{
public
abstract
String
pathSpec
();
@Override
protected
final
void
doGet
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
try
{
reply
(
resp
,
doGet
(
req
));
}
catch
(
ArgumentsParseException
e
)
{
replyError
(
resp
,
e
.
getMessage
(),
HttpServletResponse
.
SC_BAD_REQUEST
);
}
}
protected
abstract
JsonElement
doGet
(
HttpServletRequest
req
)
throws
ArgumentsParseException
;
@Override
protected
final
void
doPost
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
try
{
reply
(
resp
,
doPost
(
req
));
}
catch
(
ArgumentsParseException
e
)
{
replyError
(
resp
,
e
.
getMessage
(),
HttpServletResponse
.
SC_BAD_REQUEST
);
}
}
protected
abstract
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
;
@Override
protected
final
void
doHead
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
super
.
doHead
(
req
,
resp
);
}
@Override
protected
final
long
getLastModified
(
HttpServletRequest
req
)
{
return
super
.
getLastModified
(
req
);
}
@Override
protected
final
void
doPut
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
super
.
doPut
(
req
,
resp
);
}
@Override
protected
final
void
doDelete
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
super
.
doDelete
(
req
,
resp
);
}
@Override
protected
final
void
doOptions
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
super
.
doOptions
(
req
,
resp
);
}
@Override
protected
final
void
doTrace
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
super
.
doTrace
(
req
,
resp
);
}
@Override
protected
final
void
service
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
super
.
service
(
req
,
resp
);
}
@Override
public
final
void
service
(
ServletRequest
req
,
ServletResponse
res
)
throws
ServletException
,
IOException
{
super
.
service
(
req
,
res
);
}
@Override
public
final
void
destroy
()
{
super
.
destroy
();
}
@Override
public
final
String
getInitParameter
(
String
name
)
{
return
super
.
getInitParameter
(
name
);
}
@Override
public
final
Enumeration
<
String
>
getInitParameterNames
()
{
return
super
.
getInitParameterNames
();
}
@Override
public
final
ServletConfig
getServletConfig
()
{
return
super
.
getServletConfig
();
}
@Override
public
final
ServletContext
getServletContext
()
{
return
super
.
getServletContext
();
}
@Override
public
final
String
getServletInfo
()
{
return
super
.
getServletInfo
();
}
@Override
public
final
void
init
(
ServletConfig
config
)
throws
ServletException
{
super
.
init
(
config
);
}
@Override
public
final
void
init
()
throws
ServletException
{
super
.
init
();
}
@Override
public
final
void
log
(
String
msg
)
{
super
.
log
(
msg
);
}
@Override
public
final
void
log
(
String
message
,
Throwable
t
)
{
super
.
log
(
message
,
t
);
}
@Override
public
final
String
getServletName
()
{
return
super
.
getServletName
();
}
private
void
reply
(
HttpServletResponse
response
,
JsonElement
resJson
)
throws
IOException
{
response
.
setContentType
(
"text/json"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
PrintWriter
out
=
response
.
getWriter
();
if
(
ObjectUtils
.
isNotEmpty
(
resJson
))
{
out
.
print
(
resJson
);
}
out
.
flush
();
out
.
close
();
}
private
void
replyError
(
HttpServletResponse
response
,
String
errorMessage
,
int
status
)
throws
IOException
{
response
.
setContentType
(
"text/plain"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setStatus
(
status
);
response
.
setHeader
(
"error-message"
,
errorMessage
);
PrintWriter
out
=
response
.
getWriter
();
out
.
flush
();
out
.
close
();
}
}
\ No newline at end of file
apm-collector/apm-collector-component/server-component/src/main/java/org/skywalking/apm/collector/server/jetty/JettyServer.java
0 → 100644
浏览文件 @
5828f286
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.server.jetty
;
import
java.net.InetSocketAddress
;
import
javax.servlet.http.HttpServlet
;
import
org.eclipse.jetty.servlet.ServletContextHandler
;
import
org.eclipse.jetty.servlet.ServletHolder
;
import
org.skywalking.apm.collector.core.framework.Handler
;
import
org.skywalking.apm.collector.core.server.Server
;
import
org.skywalking.apm.collector.core.server.ServerException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
JettyServer
implements
Server
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
JettyServer
.
class
);
private
final
String
host
;
private
final
int
port
;
private
final
String
contextPath
;
private
org
.
eclipse
.
jetty
.
server
.
Server
server
;
private
ServletContextHandler
servletContextHandler
;
public
JettyServer
(
String
host
,
int
port
,
String
contextPath
)
{
this
.
host
=
host
;
this
.
port
=
port
;
this
.
contextPath
=
contextPath
;
}
@Override
public
String
hostPort
()
{
return
host
+
":"
+
port
;
}
@Override
public
String
serverClassify
()
{
return
"Jetty"
;
}
@Override
public
void
initialize
()
throws
ServerException
{
server
=
new
org
.
eclipse
.
jetty
.
server
.
Server
(
new
InetSocketAddress
(
host
,
port
));
servletContextHandler
=
new
ServletContextHandler
(
ServletContextHandler
.
NO_SESSIONS
);
servletContextHandler
.
setContextPath
(
contextPath
);
logger
.
info
(
"http server root context path: {}"
,
contextPath
);
server
.
setHandler
(
servletContextHandler
);
}
@Override
public
void
addHandler
(
Handler
handler
)
{
ServletHolder
servletHolder
=
new
ServletHolder
();
servletHolder
.
setServlet
((
HttpServlet
)
handler
);
servletContextHandler
.
addServlet
(
servletHolder
,
((
JettyHandler
)
handler
).
pathSpec
());
}
@Override
public
void
start
()
throws
ServerException
{
try
{
server
.
start
();
}
catch
(
Exception
e
)
{
throw
new
JettyServerException
(
e
.
getMessage
(),
e
);
}
}
}
apm-collector/apm-collector-component/server-component/src/main/java/org/skywalking/apm/collector/server/jetty/JettyServerException.java
0 → 100644
浏览文件 @
5828f286
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.server.jetty
;
import
org.skywalking.apm.collector.core.server.ServerException
;
/**
* @author peng-yongsheng
*/
public
class
JettyServerException
extends
ServerException
{
public
JettyServerException
(
String
message
)
{
super
(
message
);
}
public
JettyServerException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录