Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
2cef97a8
S
SkyWalking
项目概览
山不在高_有仙则灵
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
12
Star
0
Fork
2
代码
文件
提交
分支
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,发现更多精彩内容 >>
未验证
提交
2cef97a8
编写于
2月 13, 2018
作者:
彭
彭勇升 pengys
提交者:
GitHub
2月 13, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #817 from peng-yongsheng/feature/heartbeat_test
Instance heart beat tested with elastic search.
上级
abb35159
a14207e6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
85 addition
and
9 deletion
+85
-9
apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/InstanceDiscoveryServiceHandler.java
...rpc/provider/handler/InstanceDiscoveryServiceHandler.java
+2
-0
apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/mock/RegisterMock.java
...lector/agent/grpc/provider/handler/mock/RegisterMock.java
+81
-9
apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/mock/TraceSegmentMock.java
...or/agent/grpc/provider/handler/mock/TraceSegmentMock.java
+2
-0
未找到文件。
apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/InstanceDiscoveryServiceHandler.java
浏览文件 @
2cef97a8
...
@@ -66,6 +66,8 @@ public class InstanceDiscoveryServiceHandler extends InstanceDiscoveryServiceGrp
...
@@ -66,6 +66,8 @@ public class InstanceDiscoveryServiceHandler extends InstanceDiscoveryServiceGrp
int
instanceId
=
request
.
getApplicationInstanceId
();
int
instanceId
=
request
.
getApplicationInstanceId
();
long
heartBeatTime
=
request
.
getHeartbeatTime
();
long
heartBeatTime
=
request
.
getHeartbeatTime
();
this
.
instanceHeartBeatService
.
heartBeat
(
instanceId
,
heartBeatTime
);
this
.
instanceHeartBeatService
.
heartBeat
(
instanceId
,
heartBeatTime
);
responseObserver
.
onNext
(
Downstream
.
getDefaultInstance
());
responseObserver
.
onCompleted
();
}
}
private
String
buildOsInfo
(
OSInfo
osinfo
)
{
private
String
buildOsInfo
(
OSInfo
osinfo
)
{
...
...
apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/mock/RegisterMock.java
浏览文件 @
2cef97a8
...
@@ -20,8 +20,12 @@ package org.apache.skywalking.apm.collector.agent.grpc.provider.handler.mock;
...
@@ -20,8 +20,12 @@ package org.apache.skywalking.apm.collector.agent.grpc.provider.handler.mock;
import
io.grpc.ManagedChannel
;
import
io.grpc.ManagedChannel
;
import
java.util.UUID
;
import
java.util.UUID
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.skywalking.apm.network.proto.Application
;
import
org.apache.skywalking.apm.network.proto.Application
;
import
org.apache.skywalking.apm.network.proto.ApplicationInstance
;
import
org.apache.skywalking.apm.network.proto.ApplicationInstance
;
import
org.apache.skywalking.apm.network.proto.ApplicationInstanceHeartbeat
;
import
org.apache.skywalking.apm.network.proto.ApplicationInstanceMapping
;
import
org.apache.skywalking.apm.network.proto.ApplicationMapping
;
import
org.apache.skywalking.apm.network.proto.ApplicationMapping
;
import
org.apache.skywalking.apm.network.proto.ApplicationRegisterServiceGrpc
;
import
org.apache.skywalking.apm.network.proto.ApplicationRegisterServiceGrpc
;
import
org.apache.skywalking.apm.network.proto.InstanceDiscoveryServiceGrpc
;
import
org.apache.skywalking.apm.network.proto.InstanceDiscoveryServiceGrpc
;
...
@@ -29,18 +33,24 @@ import org.apache.skywalking.apm.network.proto.OSInfo;
...
@@ -29,18 +33,24 @@ import org.apache.skywalking.apm.network.proto.OSInfo;
import
org.apache.skywalking.apm.network.proto.ServiceNameCollection
;
import
org.apache.skywalking.apm.network.proto.ServiceNameCollection
;
import
org.apache.skywalking.apm.network.proto.ServiceNameDiscoveryServiceGrpc
;
import
org.apache.skywalking.apm.network.proto.ServiceNameDiscoveryServiceGrpc
;
import
org.apache.skywalking.apm.network.proto.ServiceNameElement
;
import
org.apache.skywalking.apm.network.proto.ServiceNameElement
;
import
org.apache.skywalking.apm.network.proto.ServiceNameMappingCollection
;
import
org.apache.skywalking.apm.util.RunnableWithExceptionProtection
;
import
org.joda.time.DateTime
;
import
org.joda.time.DateTime
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
/**
* @author peng-yongsheng
* @author peng-yongsheng
*/
*/
class
RegisterMock
{
class
RegisterMock
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RegisterMock
.
class
);
private
ApplicationRegisterServiceGrpc
.
ApplicationRegisterServiceBlockingStub
applicationRegisterServiceBlockingStub
;
private
ApplicationRegisterServiceGrpc
.
ApplicationRegisterServiceBlockingStub
applicationRegisterServiceBlockingStub
;
private
InstanceDiscoveryServiceGrpc
.
InstanceDiscoveryServiceBlockingStub
instanceDiscoveryServiceBlockingStub
;
private
InstanceDiscoveryServiceGrpc
.
InstanceDiscoveryServiceBlockingStub
instanceDiscoveryServiceBlockingStub
;
private
ServiceNameDiscoveryServiceGrpc
.
ServiceNameDiscoveryServiceBlockingStub
serviceNameDiscoveryServiceBlockingStub
;
private
ServiceNameDiscoveryServiceGrpc
.
ServiceNameDiscoveryServiceBlockingStub
serviceNameDiscoveryServiceBlockingStub
;
void
mock
(
ManagedChannel
channel
)
{
void
mock
(
ManagedChannel
channel
)
throws
InterruptedException
{
applicationRegisterServiceBlockingStub
=
ApplicationRegisterServiceGrpc
.
newBlockingStub
(
channel
);
applicationRegisterServiceBlockingStub
=
ApplicationRegisterServiceGrpc
.
newBlockingStub
(
channel
);
instanceDiscoveryServiceBlockingStub
=
InstanceDiscoveryServiceGrpc
.
newBlockingStub
(
channel
);
instanceDiscoveryServiceBlockingStub
=
InstanceDiscoveryServiceGrpc
.
newBlockingStub
(
channel
);
serviceNameDiscoveryServiceBlockingStub
=
ServiceNameDiscoveryServiceGrpc
.
newBlockingStub
(
channel
);
serviceNameDiscoveryServiceBlockingStub
=
ServiceNameDiscoveryServiceGrpc
.
newBlockingStub
(
channel
);
...
@@ -48,10 +58,17 @@ class RegisterMock {
...
@@ -48,10 +58,17 @@ class RegisterMock {
registerProvider
();
registerProvider
();
}
}
private
void
registerConsumer
()
{
private
void
registerConsumer
()
throws
InterruptedException
{
Application
.
Builder
application
=
Application
.
newBuilder
();
Application
.
Builder
application
=
Application
.
newBuilder
();
application
.
setApplicationCode
(
"dubbox-consumer"
);
application
.
setApplicationCode
(
"dubbox-consumer"
);
ApplicationMapping
applicationMapping
=
applicationRegisterServiceBlockingStub
.
applicationCodeRegister
(
application
.
build
());
ApplicationMapping
applicationMapping
;
do
{
applicationMapping
=
applicationRegisterServiceBlockingStub
.
applicationCodeRegister
(
application
.
build
());
logger
.
debug
(
"application id: {}"
,
applicationMapping
.
getApplication
().
getValue
());
Thread
.
sleep
(
20
);
}
while
(
applicationMapping
.
getApplication
().
getValue
()
==
0
);
ApplicationInstance
.
Builder
instance
=
ApplicationInstance
.
newBuilder
();
ApplicationInstance
.
Builder
instance
=
ApplicationInstance
.
newBuilder
();
instance
.
setApplicationId
(
applicationMapping
.
getApplication
().
getValue
());
instance
.
setApplicationId
(
applicationMapping
.
getApplication
().
getValue
());
...
@@ -65,20 +82,37 @@ class RegisterMock {
...
@@ -65,20 +82,37 @@ class RegisterMock {
osInfo
.
addIpv4S
(
"10.0.0.3"
);
osInfo
.
addIpv4S
(
"10.0.0.3"
);
osInfo
.
addIpv4S
(
"10.0.0.4"
);
osInfo
.
addIpv4S
(
"10.0.0.4"
);
instance
.
setOsinfo
(
osInfo
);
instance
.
setOsinfo
(
osInfo
);
instanceDiscoveryServiceBlockingStub
.
registerInstance
(
instance
.
build
());
ApplicationInstanceMapping
instanceMapping
;
do
{
instanceMapping
=
instanceDiscoveryServiceBlockingStub
.
registerInstance
(
instance
.
build
());
logger
.
debug
(
"instance id: {}"
,
instanceMapping
.
getApplicationInstanceId
());
Thread
.
sleep
(
20
);
}
while
(
instanceMapping
.
getApplicationInstanceId
()
==
0
);
ServiceNameCollection
.
Builder
serviceNameCollection
=
ServiceNameCollection
.
newBuilder
();
ServiceNameCollection
.
Builder
serviceNameCollection
=
ServiceNameCollection
.
newBuilder
();
ServiceNameElement
.
Builder
serviceNameElement
=
ServiceNameElement
.
newBuilder
();
ServiceNameElement
.
Builder
serviceNameElement
=
ServiceNameElement
.
newBuilder
();
serviceNameElement
.
setApplicationId
(
applicationMapping
.
getApplication
().
getValue
());
serviceNameElement
.
setApplicationId
(
applicationMapping
.
getApplication
().
getValue
());
serviceNameElement
.
setServiceName
(
"org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()"
);
serviceNameElement
.
setServiceName
(
"org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()"
);
serviceNameCollection
.
addElements
(
serviceNameElement
);
serviceNameCollection
.
addElements
(
serviceNameElement
);
serviceNameDiscoveryServiceBlockingStub
.
discovery
(
serviceNameCollection
.
build
());
registerServiceName
(
serviceNameCollection
);
heartBeatScheduled
(
instanceMapping
.
getApplicationInstanceId
());
}
}
private
void
registerProvider
()
{
private
void
registerProvider
()
throws
InterruptedException
{
Application
.
Builder
application
=
Application
.
newBuilder
();
Application
.
Builder
application
=
Application
.
newBuilder
();
application
.
setApplicationCode
(
"dubbox-provider"
);
application
.
setApplicationCode
(
"dubbox-provider"
);
ApplicationMapping
applicationMapping
=
applicationRegisterServiceBlockingStub
.
applicationCodeRegister
(
application
.
build
());
ApplicationMapping
applicationMapping
;
do
{
applicationMapping
=
applicationRegisterServiceBlockingStub
.
applicationCodeRegister
(
application
.
build
());
logger
.
debug
(
"application id: {}"
,
applicationMapping
.
getApplication
().
getValue
());
Thread
.
sleep
(
20
);
}
while
(
applicationMapping
.
getApplication
().
getValue
()
==
0
);
ApplicationInstance
.
Builder
instance
=
ApplicationInstance
.
newBuilder
();
ApplicationInstance
.
Builder
instance
=
ApplicationInstance
.
newBuilder
();
instance
.
setApplicationId
(
applicationMapping
.
getApplication
().
getValue
());
instance
.
setApplicationId
(
applicationMapping
.
getApplication
().
getValue
());
...
@@ -92,13 +126,51 @@ class RegisterMock {
...
@@ -92,13 +126,51 @@ class RegisterMock {
osInfo
.
addIpv4S
(
"10.0.0.1"
);
osInfo
.
addIpv4S
(
"10.0.0.1"
);
osInfo
.
addIpv4S
(
"10.0.0.2"
);
osInfo
.
addIpv4S
(
"10.0.0.2"
);
instance
.
setOsinfo
(
osInfo
);
instance
.
setOsinfo
(
osInfo
);
instanceDiscoveryServiceBlockingStub
.
registerInstance
(
instance
.
build
());
ApplicationInstanceMapping
instanceMapping
;
do
{
instanceMapping
=
instanceDiscoveryServiceBlockingStub
.
registerInstance
(
instance
.
build
());
logger
.
debug
(
"instance id: {}"
,
instanceMapping
.
getApplicationInstanceId
());
Thread
.
sleep
(
20
);
}
while
(
instanceMapping
.
getApplicationInstanceId
()
==
0
);
ServiceNameCollection
.
Builder
serviceNameCollection
=
ServiceNameCollection
.
newBuilder
();
ServiceNameCollection
.
Builder
serviceNameCollection
=
ServiceNameCollection
.
newBuilder
();
ServiceNameElement
.
Builder
serviceNameElement
=
ServiceNameElement
.
newBuilder
();
ServiceNameElement
.
Builder
serviceNameElement
=
ServiceNameElement
.
newBuilder
();
serviceNameElement
.
setApplicationId
(
applicationMapping
.
getApplication
().
getValue
());
serviceNameElement
.
setApplicationId
(
applicationMapping
.
getApplication
().
getValue
());
serviceNameElement
.
setServiceName
(
"org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()"
);
serviceNameElement
.
setServiceName
(
"org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()"
);
serviceNameCollection
.
addElements
(
serviceNameElement
);
serviceNameCollection
.
addElements
(
serviceNameElement
);
serviceNameDiscoveryServiceBlockingStub
.
discovery
(
serviceNameCollection
.
build
());
registerServiceName
(
serviceNameCollection
);
heartBeatScheduled
(
instanceMapping
.
getApplicationInstanceId
());
}
private
void
registerServiceName
(
ServiceNameCollection
.
Builder
serviceNameCollection
)
throws
InterruptedException
{
ServiceNameMappingCollection
serviceNameMappingCollection
;
do
{
serviceNameMappingCollection
=
serviceNameDiscoveryServiceBlockingStub
.
discovery
(
serviceNameCollection
.
build
());
logger
.
debug
(
"service name mapping collection size: {}"
,
serviceNameMappingCollection
.
getElementsCount
());
if
(
serviceNameMappingCollection
.
getElementsCount
()
>
0
)
{
logger
.
debug
(
"service id: {}"
,
serviceNameMappingCollection
.
getElements
(
0
).
getServiceId
());
}
Thread
.
sleep
(
20
);
}
while
(
serviceNameMappingCollection
.
getElementsCount
()
==
0
||
serviceNameMappingCollection
.
getElements
(
0
).
getServiceId
()
==
0
);
}
private
void
heartBeatScheduled
(
int
instanceId
)
{
Executors
.
newSingleThreadScheduledExecutor
().
scheduleAtFixedRate
(
new
RunnableWithExceptionProtection
(()
->
heartBeat
(
instanceId
),
t
->
logger
.
error
(
"instance heart beat scheduled error."
,
t
)),
4
,
1
,
TimeUnit
.
SECONDS
);
}
private
void
heartBeat
(
int
instanceId
)
{
long
now
=
System
.
currentTimeMillis
();
logger
.
debug
(
"instance heart beat, instance id: {}, time: {}"
,
instanceId
,
now
);
ApplicationInstanceHeartbeat
.
Builder
heartbeat
=
ApplicationInstanceHeartbeat
.
newBuilder
();
heartbeat
.
setApplicationInstanceId
(
instanceId
);
heartbeat
.
setHeartbeatTime
(
now
);
instanceDiscoveryServiceBlockingStub
.
heartbeat
(
heartbeat
.
build
());
}
}
}
}
apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/mock/TraceSegmentMock.java
浏览文件 @
2cef97a8
...
@@ -83,6 +83,8 @@ public class TraceSegmentMock {
...
@@ -83,6 +83,8 @@ public class TraceSegmentMock {
while
(
sleeping
.
getValue
())
{
while
(
sleeping
.
getValue
())
{
Thread
.
sleep
(
200
);
Thread
.
sleep
(
200
);
}
}
Thread
.
sleep
(
200000
);
}
}
static
class
Sleeping
{
static
class
Sleeping
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录