Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6b0fc4aa
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6b0fc4aa
编写于
7月 01, 2023
作者:
K
kailixu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: code optimization
上级
067a8334
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
46 deletion
+34
-46
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+1
-2
source/client/src/clientHb.c
source/client/src/clientHb.c
+33
-44
未找到文件。
source/client/inc/clientInt.h
浏览文件 @
6b0fc4aa
...
...
@@ -33,7 +33,6 @@ extern "C" {
#include "tmsg.h"
#include "tmsgtype.h"
#include "trpc.h"
#include "tsimplehash.h"
#include "tconfig.h"
...
...
@@ -86,7 +85,7 @@ typedef struct {
TdThread
thread
;
TdThreadMutex
lock
;
// used when app init and cleanup
SHashObj
*
appSummary
;
S
SHashObj
*
appHbHash
;
// key: clusterId
S
HashObj
*
appHbHash
;
// key: clusterId
SArray
*
appHbMgrs
;
// SArray<SAppHbMgr*> one for each cluster
FHbReqHandle
reqHandle
[
CONN_TYPE__MAX
];
FHbRspHandle
rspHandle
[
CONN_TYPE__MAX
];
...
...
source/client/src/clientHb.c
浏览文件 @
6b0fc4aa
...
...
@@ -18,7 +18,6 @@
#include "clientLog.h"
#include "scheduler.h"
#include "trpc.h"
#include "tsimplehash.h"
typedef
struct
{
union
{
...
...
@@ -35,11 +34,38 @@ static SClientHbMgr clientHbMgr = {0};
static
int32_t
hbCreateThread
();
static
void
hbStopThread
();
static
int32_t
hbUpdateUserAuthInfo
(
SAppHbMgr
*
pAppHbMgr
,
SUserAuthBatchRsp
*
batchRsp
);
static
int32_t
hbMqHbReqHandle
(
SClientHbKey
*
connKey
,
void
*
param
,
SClientHbReq
*
req
)
{
return
0
;
}
static
int32_t
hbMqHbRspHandle
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbRsp
*
pRsp
)
{
return
0
;
}
static
int32_t
hbProcessUserAuthInfoRsp
(
void
*
value
,
int32_t
valueLen
,
struct
SCatalog
*
pCatalog
,
SAppHbMgr
*
pAppHbMgr
)
{
int32_t
code
=
0
;
SUserAuthBatchRsp
batchRsp
=
{
0
};
if
(
tDeserializeSUserAuthBatchRsp
(
value
,
valueLen
,
&
batchRsp
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
int32_t
numOfBatchs
=
taosArrayGetSize
(
batchRsp
.
pArray
);
for
(
int32_t
i
=
0
;
i
<
numOfBatchs
;
++
i
)
{
SGetUserAuthRsp
*
rsp
=
taosArrayGet
(
batchRsp
.
pArray
,
i
);
tscDebug
(
"hb user auth rsp, user:%s, version:%d"
,
rsp
->
user
,
rsp
->
version
);
catalogUpdateUserAuthInfo
(
pCatalog
,
rsp
);
}
if
(
numOfBatchs
>
0
)
hbUpdateUserAuthInfo
(
pAppHbMgr
,
&
batchRsp
);
atomic_val_compare_exchange_8
(
&
pAppHbMgr
->
connHbFlag
,
1
,
2
);
taosArrayDestroy
(
batchRsp
.
pArray
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
hbUpdateUserAuthInfo
(
SAppHbMgr
*
pAppHbMgr
,
SUserAuthBatchRsp
*
batchRsp
)
{
SClientHbReq
*
pReq
=
NULL
;
while
((
pReq
=
taosHashIterate
(
pAppHbMgr
->
activeInfo
,
pReq
)))
{
...
...
@@ -81,32 +107,6 @@ static int32_t hbUpdateUserAuthInfo(SAppHbMgr *pAppHbMgr, SUserAuthBatchRsp *bat
return
0
;
}
static
int32_t
hbProcessUserAuthInfoRsp
(
void
*
value
,
int32_t
valueLen
,
struct
SCatalog
*
pCatalog
,
SAppHbMgr
*
pAppHbMgr
)
{
int32_t
code
=
0
;
SUserAuthBatchRsp
batchRsp
=
{
0
};
if
(
tDeserializeSUserAuthBatchRsp
(
value
,
valueLen
,
&
batchRsp
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
int32_t
numOfBatchs
=
taosArrayGetSize
(
batchRsp
.
pArray
);
for
(
int32_t
i
=
0
;
i
<
numOfBatchs
;
++
i
)
{
SGetUserAuthRsp
*
rsp
=
taosArrayGet
(
batchRsp
.
pArray
,
i
);
tscDebug
(
"hb user auth rsp, user:%s, version:%d"
,
rsp
->
user
,
rsp
->
version
);
catalogUpdateUserAuthInfo
(
pCatalog
,
rsp
);
}
if
(
numOfBatchs
>
0
)
hbUpdateUserAuthInfo
(
pAppHbMgr
,
&
batchRsp
);
atomic_val_compare_exchange_8
(
&
pAppHbMgr
->
connHbFlag
,
1
,
2
);
taosArrayDestroy
(
batchRsp
.
pArray
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
hbGenerateVgInfoFromRsp
(
SDBVgInfo
**
pInfo
,
SUseDbRsp
*
rsp
)
{
int32_t
code
=
0
;
SDBVgInfo
*
vgInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SDBVgInfo
));
...
...
@@ -612,22 +612,12 @@ int32_t hbGetExpiredUserInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, S
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
STscObj
*
pTscObj
=
(
STscObj
*
)
acquireTscObj
(
connKey
->
tscRid
);
if
(
NULL
==
pTscObj
)
{
tscWarn
(
"tscObj rid %"
PRIx64
" not exist"
,
connKey
->
tscRid
);
return
TSDB_CODE_APP_ERROR
;
}
if
(
userNum
<=
0
)
{
// printf("%s:%d hb get expired: [User:%s] NNNNo user since user num: %d, second:%d\n", __func__, __LINE__, pTscObj->user, userNum,
// taosGetTimestampSec());
taosMemoryFree
(
users
);
releaseTscObj
(
connKey
->
tscRid
);
return
TSDB_CODE_SUCCESS
;
}
releaseTscObj
(
connKey
->
tscRid
);
for
(
int32_t
i
=
0
;
i
<
userNum
;
++
i
)
{
SUserAuthVersion
*
user
=
&
users
[
i
];
user
->
version
=
htonl
(
user
->
version
);
...
...
@@ -766,7 +756,7 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req
hbGetQueryBasicInfo
(
connKey
,
req
);
if
(
hbParam
->
reqCnt
==
0
)
{
if
(
!
tSimple
HashGet
(
clientHbMgr
.
appHbHash
,
&
hbParam
->
clusterId
,
sizeof
(
hbParam
->
clusterId
)))
{
if
(
!
taos
HashGet
(
clientHbMgr
.
appHbHash
,
&
hbParam
->
clusterId
,
sizeof
(
hbParam
->
clusterId
)))
{
code
=
hbGetExpiredUserInfo
(
connKey
,
pCatalog
,
req
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
...
...
@@ -923,9 +913,9 @@ static void *hbThreadFunc(void *param) {
if
(
sz
>
0
)
{
hbGatherAppInfo
();
if
(
sz
>
1
&&
!
clientHbMgr
.
appHbHash
)
{
clientHbMgr
.
appHbHash
=
t
SimpleHashInit
(
0
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_UBIGINT
)
);
clientHbMgr
.
appHbHash
=
t
aosHashInit
(
0
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_UBIGINT
),
false
,
HASH_NO_LOCK
);
}
t
Simple
HashClear
(
clientHbMgr
.
appHbHash
);
t
aos
HashClear
(
clientHbMgr
.
appHbHash
);
}
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
...
...
@@ -978,7 +968,7 @@ static void *hbThreadFunc(void *param) {
asyncSendMsgToServer
(
pAppInstInfo
->
pTransporter
,
&
epSet
,
&
transporterId
,
pInfo
);
tFreeClientHbBatchReq
(
pReq
);
// hbClearReqInfo(pAppHbMgr);
t
Simple
HashPut
(
clientHbMgr
.
appHbHash
,
&
pAppHbMgr
->
pAppInstInfo
->
clusterId
,
sizeof
(
uint64_t
),
NULL
,
0
);
t
aos
HashPut
(
clientHbMgr
.
appHbHash
,
&
pAppHbMgr
->
pAppInstInfo
->
clusterId
,
sizeof
(
uint64_t
),
NULL
,
0
);
atomic_add_fetch_32
(
&
pAppHbMgr
->
reportCnt
,
1
);
}
...
...
@@ -986,7 +976,6 @@ static void *hbThreadFunc(void *param) {
taosMsleep
(
HEARTBEAT_INTERVAL
);
}
return
NULL
;
}
...
...
@@ -1099,10 +1088,10 @@ void appHbMgrCleanup(void) {
hbFreeAppHbMgr
(
pTarget
);
}
clientHbMgr
.
appHbMgrs
=
taosArrayDestroy
(
clientHbMgr
.
appHbMgrs
);
tSimpleHashCleanup
(
clientHbMgr
.
appHbHash
);
clientHbMgr
.
appHbHash
=
NULL
;
taosHashCleanup
(
clientHbMgr
.
appSummary
);
taosHashCleanup
(
clientHbMgr
.
appHbHash
);
clientHbMgr
.
appSummary
=
NULL
;
clientHbMgr
.
appHbHash
=
NULL
;
}
int
hbMgrInit
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录