Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
SkyAPM
SkyAPM-php-sdk
提交
f9aa2efe
S
SkyAPM-php-sdk
项目概览
SkyAPM
/
SkyAPM-php-sdk
通知
14
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyAPM-php-sdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f9aa2efe
编写于
4月 28, 2019
作者:
G
goerzh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reduce heartbeat load
上级
23a9d20c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
18 deletion
+23
-18
src/report/Makefile
src/report/Makefile
+2
-2
src/report/report_client.cc
src/report/report_client.cc
+21
-16
未找到文件。
src/report/Makefile
浏览文件 @
f9aa2efe
...
...
@@ -46,8 +46,8 @@ OBJS = ../grpc/language-agent-v2/.libs/trace.o ../grpc/language-agent-v2/.libs/t
../grpc/register/.libs/InstancePing-grpc.o ../grpc/common/.libs/common.o ../grpc/common/.libs/common-grpc.o
\
../grpc/common/.libs/trace-common.o ../grpc/common/.libs/trace-common-grpc.o
report_client
:
$(OBJS)
$(CXX)
report_client.cpp
$^
$(LDFLAGS)
-Ideps
/boost
$(CXXFLAGS)
-o
$@
report_client
:
$(OBJS)
report_client.cc
$(CXX)
$^
$(LDFLAGS)
-Ideps
/boost
$(CXXFLAGS)
-o
$@
clean
:
rm
-rf
*
.o
*
.pb.cc
*
.pb.h report_client
\
...
...
src/report/report_client.c
pp
→
src/report/report_client.c
c
浏览文件 @
f9aa2efe
...
...
@@ -113,14 +113,14 @@ int main(int argc, char **argv) {
if
(
std
::
strncmp
(
"-h"
,
argv
[
i
],
sizeof
(
argv
[
i
])
-
1
)
==
0
||
std
::
strncmp
(
"--help"
,
argv
[
i
],
sizeof
(
argv
[
i
])
-
1
)
==
0
)
{
std
::
cout
<<
"report_client grpc log_path"
<<
std
::
endl
;
std
::
cout
<<
"e.g. report_client 12
0
.0.0.1:11800 /tmp"
<<
std
::
endl
;
std
::
cout
<<
"e.g. report_client 12
7
.0.0.1:11800 /tmp"
<<
std
::
endl
;
return
0
;
}
}
if
(
argc
==
1
)
{
std
::
cout
<<
"report_client grpc log_path"
<<
std
::
endl
;
std
::
cout
<<
"e.g. report_client 12
0
.0.0.1:11800 /tmp"
<<
std
::
endl
;
std
::
cout
<<
"e.g. report_client 12
7
.0.0.1:11800 /tmp"
<<
std
::
endl
;
return
0
;
}
...
...
@@ -130,6 +130,8 @@ int main(int argc, char **argv) {
std
::
map
<
int
,
std
::
string
>
instanceUUID
;
std
::
map
<
int
,
long
>
sendTime
;
uint64_t
index
=
0
;
while
(
1
)
{
struct
dirent
*
dir
;
...
...
@@ -138,24 +140,27 @@ int main(int argc, char **argv) {
std
::
cerr
<<
"open directory error"
;
return
0
;
}
index
+=
1
;
// heartbeat
for
(
auto
&
i
:
instancePid
)
{
struct
timeval
tv
;
gettimeofday
(
&
tv
,
NULL
);
if
(
tv
.
tv_sec
-
sendTime
[
i
.
first
]
>
40
)
{
kill
(
instancePid
[
i
.
first
],
0
);
if
(
index
%
3
==
0
)
{
struct
timeval
tv
;
gettimeofday
(
&
tv
,
NULL
);
// if (tv.tv_sec - sendTime[i.first] > 40) {
// kill(instancePid[i.first], 0);
// }
sendTime
[
i
.
first
]
=
tv
.
tv_sec
;
std
::
cout
<<
"send heartbeat ..."
<<
std
::
endl
;
ServiceInstancePingPkg
request
;
request
.
set_serviceinstanceid
(
i
.
first
);
request
.
set_time
(
tv
.
tv_sec
*
1000
+
tv
.
tv_usec
/
1000
);
request
.
set_serviceinstanceuuid
(
instanceUUID
[
i
.
first
]);
greeter
.
heartbeat
(
request
);
}
sendTime
[
i
.
first
]
=
tv
.
tv_sec
;
std
::
cout
<<
"send heartbeat ..."
<<
std
::
endl
;
ServiceInstancePingPkg
request
;
request
.
set_serviceinstanceid
(
i
.
first
);
request
.
set_time
(
tv
.
tv_sec
*
1000
+
tv
.
tv_usec
/
1000
);
request
.
set_serviceinstanceuuid
(
instanceUUID
[
i
.
first
]);
greeter
.
heartbeat
(
request
);
}
while
((
dir
=
readdir
(
dp
))
!=
NULL
)
{
...
...
@@ -331,7 +336,7 @@ int main(int argc, char **argv) {
}
closedir
(
dp
);
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
5
00
));
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
10
00
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录