Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
12d1bf03
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
12d1bf03
编写于
2月 18, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pull telemetry by timer
上级
8a095004
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
71 deletion
+20
-71
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+3
-6
source/dnode/mnode/impl/src/mndTelem.c
source/dnode/mnode/impl/src/mndTelem.c
+11
-59
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+6
-6
未找到文件。
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
12d1bf03
...
@@ -56,12 +56,9 @@ typedef struct {
...
@@ -56,12 +56,9 @@ typedef struct {
}
SProfileMgmt
;
}
SProfileMgmt
;
typedef
struct
{
typedef
struct
{
int8_t
enable
;
int8_t
enable
;
pthread_mutex_t
lock
;
SRWLatch
lock
;
pthread_cond_t
cond
;
char
email
[
TSDB_FQDN_LEN
];
volatile
int32_t
exit
;
pthread_t
thread
;
char
email
[
TSDB_FQDN_LEN
];
}
STelemMgmt
;
}
STelemMgmt
;
typedef
struct
{
typedef
struct
{
...
...
source/dnode/mnode/impl/src/mndTelem.c
浏览文件 @
12d1bf03
...
@@ -234,32 +234,15 @@ static void mndSendTelemetryReport(SMnode* pMnode) {
...
@@ -234,32 +234,15 @@ static void mndSendTelemetryReport(SMnode* pMnode) {
taosCloseSocket
(
fd
);
taosCloseSocket
(
fd
);
}
}
static
void
*
mndTelemThreadFp
(
void
*
param
)
{
static
int32_t
mndProcessTelemTimer
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
aram
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
STelemMgmt
*
pMgmt
=
&
pMnode
->
telemMgmt
;
STelemMgmt
*
pMgmt
=
&
pMnode
->
telemMgmt
;
if
(
!
pMgmt
->
enable
)
return
0
;
struct
timespec
end
=
{
0
};
taosWLockLatch
(
&
pMgmt
->
lock
);
clock_gettime
(
CLOCK_REALTIME
,
&
end
);
mndSendTelemetryReport
(
pMnode
);
end
.
tv_sec
+=
300
;
// wait 5 minutes before send first report
taosWUnLockLatch
(
&
pMgmt
->
lock
);
return
0
;
setThreadName
(
"mnd-telem"
);
while
(
!
pMgmt
->
exit
)
{
int32_t
r
=
0
;
struct
timespec
ts
=
end
;
pthread_mutex_lock
(
&
pMgmt
->
lock
);
r
=
pthread_cond_timedwait
(
&
pMgmt
->
cond
,
&
pMgmt
->
lock
,
&
ts
);
pthread_mutex_unlock
(
&
pMgmt
->
lock
);
if
(
r
==
0
)
break
;
if
(
r
!=
ETIMEDOUT
)
continue
;
if
(
mndIsMaster
(
pMnode
))
{
mndSendTelemetryReport
(
pMnode
);
}
end
.
tv_sec
+=
REPORT_INTERVAL
;
}
return
NULL
;
}
}
static
void
mndGetEmail
(
SMnode
*
pMnode
,
char
*
filepath
)
{
static
void
mndGetEmail
(
SMnode
*
pMnode
,
char
*
filepath
)
{
...
@@ -280,43 +263,12 @@ static void mndGetEmail(SMnode* pMnode, char* filepath) {
...
@@ -280,43 +263,12 @@ static void mndGetEmail(SMnode* pMnode, char* filepath) {
int32_t
mndInitTelem
(
SMnode
*
pMnode
)
{
int32_t
mndInitTelem
(
SMnode
*
pMnode
)
{
STelemMgmt
*
pMgmt
=
&
pMnode
->
telemMgmt
;
STelemMgmt
*
pMgmt
=
&
pMnode
->
telemMgmt
;
pMgmt
->
enable
=
pMnode
->
cfg
.
enableTelem
;
pMgmt
->
enable
=
pMnode
->
cfg
.
enableTelem
;
taosInitRWLatch
(
&
pMgmt
->
lock
);
if
(
!
pMgmt
->
enable
)
return
0
;
pMgmt
->
exit
=
0
;
pthread_mutex_init
(
&
pMgmt
->
lock
,
NULL
);
pthread_cond_init
(
&
pMgmt
->
cond
,
NULL
);
pMgmt
->
email
[
0
]
=
0
;
mndGetEmail
(
pMnode
,
"/usr/local/taos/email"
);
mndGetEmail
(
pMnode
,
"/usr/local/taos/email"
);
pthread_attr_t
attr
;
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TELEM_TIMER
,
mndProcessTelemTimer
);
pthread_attr_init
(
&
attr
);
mDebug
(
"mnode telemetry is initialized"
);
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_JOINABLE
);
int32_t
code
=
pthread_create
(
&
pMgmt
->
thread
,
&
attr
,
mndTelemThreadFp
,
pMnode
);
pthread_attr_destroy
(
&
attr
);
if
(
code
!=
0
)
{
mDebug
(
"failed to create telemetry thread since :%s"
,
strerror
(
code
));
}
mInfo
(
"mnd telemetry is initialized"
);
return
0
;
return
0
;
}
}
void
mndCleanupTelem
(
SMnode
*
pMnode
)
{
void
mndCleanupTelem
(
SMnode
*
pMnode
)
{}
STelemMgmt
*
pMgmt
=
&
pMnode
->
telemMgmt
;
if
(
!
pMgmt
->
enable
)
return
;
if
(
taosCheckPthreadValid
(
pMgmt
->
thread
))
{
pthread_mutex_lock
(
&
pMgmt
->
lock
);
pMgmt
->
exit
=
1
;
pthread_cond_signal
(
&
pMgmt
->
cond
);
pthread_mutex_unlock
(
&
pMgmt
->
lock
);
pthread_join
(
pMgmt
->
thread
,
NULL
);
}
pthread_mutex_destroy
(
&
pMgmt
->
lock
);
pthread_cond_destroy
(
&
pMgmt
->
cond
);
}
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
12d1bf03
...
@@ -77,7 +77,7 @@ static void *mndBuildTimerMsg(int32_t *pContLen) {
...
@@ -77,7 +77,7 @@ static void *mndBuildTimerMsg(int32_t *pContLen) {
return
pReq
;
return
pReq
;
}
}
static
void
mnd
ExecuteTransaction
(
void
*
param
,
void
*
tmrId
)
{
static
void
mnd
PullupTrans
(
void
*
param
,
void
*
tmrId
)
{
SMnode
*
pMnode
=
param
;
SMnode
*
pMnode
=
param
;
if
(
mndIsMaster
(
pMnode
))
{
if
(
mndIsMaster
(
pMnode
))
{
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
...
@@ -86,7 +86,7 @@ static void mndExecuteTransaction(void *param, void *tmrId) {
...
@@ -86,7 +86,7 @@ static void mndExecuteTransaction(void *param, void *tmrId) {
pMnode
->
putReqToMWriteQFp
(
pMnode
->
pDnode
,
&
rpcMsg
);
pMnode
->
putReqToMWriteQFp
(
pMnode
->
pDnode
,
&
rpcMsg
);
}
}
taosTmrReset
(
mnd
ExecuteTransaction
,
TRNAS_TIMER_MS
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
transTimer
);
taosTmrReset
(
mnd
PullupTrans
,
TRNAS_TIMER_MS
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
transTimer
);
}
}
static
void
mndCalMqRebalance
(
void
*
param
,
void
*
tmrId
)
{
static
void
mndCalMqRebalance
(
void
*
param
,
void
*
tmrId
)
{
...
@@ -101,7 +101,7 @@ static void mndCalMqRebalance(void *param, void *tmrId) {
...
@@ -101,7 +101,7 @@ static void mndCalMqRebalance(void *param, void *tmrId) {
taosTmrReset
(
mndCalMqRebalance
,
MQ_TIMER_MS
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
mqTimer
);
taosTmrReset
(
mndCalMqRebalance
,
MQ_TIMER_MS
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
mqTimer
);
}
}
static
void
mnd
ExecuteTelemetry
(
void
*
param
,
void
*
tmrId
)
{
static
void
mnd
PullupTelem
(
void
*
param
,
void
*
tmrId
)
{
SMnode
*
pMnode
=
param
;
SMnode
*
pMnode
=
param
;
if
(
mndIsMaster
(
pMnode
))
{
if
(
mndIsMaster
(
pMnode
))
{
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
...
@@ -110,7 +110,7 @@ static void mndExecuteTelemetry(void *param, void *tmrId) {
...
@@ -110,7 +110,7 @@ static void mndExecuteTelemetry(void *param, void *tmrId) {
pMnode
->
putReqToMReadQFp
(
pMnode
->
pDnode
,
&
rpcMsg
);
pMnode
->
putReqToMReadQFp
(
pMnode
->
pDnode
,
&
rpcMsg
);
}
}
taosTmrReset
(
mnd
ExecuteTelemetry
,
TELEM_TIMER_MS
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
telemTimer
);
taosTmrReset
(
mnd
PullupTelem
,
TELEM_TIMER_MS
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
telemTimer
);
}
}
static
int32_t
mndInitTimer
(
SMnode
*
pMnode
)
{
static
int32_t
mndInitTimer
(
SMnode
*
pMnode
)
{
...
@@ -120,7 +120,7 @@ static int32_t mndInitTimer(SMnode *pMnode) {
...
@@ -120,7 +120,7 @@ static int32_t mndInitTimer(SMnode *pMnode) {
return
-
1
;
return
-
1
;
}
}
if
(
taosTmrReset
(
mnd
ExecuteTransaction
,
TRNAS_TIMER_MS
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
transTimer
))
{
if
(
taosTmrReset
(
mnd
PullupTrans
,
TRNAS_TIMER_MS
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
transTimer
))
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
...
@@ -130,7 +130,7 @@ static int32_t mndInitTimer(SMnode *pMnode) {
...
@@ -130,7 +130,7 @@ static int32_t mndInitTimer(SMnode *pMnode) {
return
-
1
;
return
-
1
;
}
}
if
(
taosTmrReset
(
mnd
CalMqRebalance
,
TELEM_TIMER_MS
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
telemTimer
))
{
if
(
taosTmrReset
(
mnd
PullupTelem
,
1000
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
telemTimer
))
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录