Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5c73c1ff
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
5c73c1ff
编写于
1月 06, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine heartbeat interface
上级
5d3f439a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
66 addition
and
66 deletion
+66
-66
source/client/inc/clientHb.h
source/client/inc/clientHb.h
+62
-59
source/client/src/clientHb.c
source/client/src/clientHb.c
+4
-7
未找到文件。
source/client/inc/clientHb.h
浏览文件 @
5c73c1ff
...
...
@@ -20,6 +20,8 @@
typedef
enum
{
mq
=
0
,
// type can be added here
//
HEARTBEAT_TYPE_MAX
}
EHbType
;
...
...
@@ -30,6 +32,60 @@ typedef struct SKlv {
void
*
value
;
}
SKlv
;
typedef
struct
SClientHbKey
{
int32_t
connId
;
int32_t
hbType
;
}
SClientHbKey
;
typedef
struct
SClientHbReq
{
SClientHbKey
hbKey
;
SHashObj
*
info
;
// hash<Slv.key, Sklv>
}
SClientHbReq
;
typedef
struct
SClientHbBatchReq
{
int64_t
reqId
;
SArray
*
reqs
;
// SArray<SClientHbReq>
}
SClientHbBatchReq
;
typedef
struct
SClientHbHandleResult
{
}
SClientHbHandleResult
;
typedef
struct
SClientHbRsp
{
int32_t
connId
;
int32_t
hbType
;
}
SClientHbRsp
;
typedef
struct
SClientHbBatchRsp
{
int64_t
reqId
;
int64_t
rspId
;
SArray
*
rsps
;
// SArray<SClientHbRsp>
}
SClientHbBatchRsp
;
typedef
int32_t
(
*
FHbRspHandle
)(
SClientHbRsp
*
pReq
);
typedef
int32_t
(
*
FGetConnInfo
)(
SClientHbKey
connKey
,
void
*
param
);
typedef
struct
SClientHbMgr
{
int8_t
inited
;
int32_t
reportInterval
;
// unit ms
int32_t
stats
;
SRWLatch
lock
;
SHashObj
*
activeInfo
;
// hash<SClientHbKey, SClientHbReq>
SHashObj
*
getInfoFuncs
;
// hash<SClientHbKey, FGetConnInfo>
FHbRspHandle
handle
[
HEARTBEAT_TYPE_MAX
];
// input queue
}
SClientHbMgr
;
static
SClientHbMgr
clientHbMgr
=
{
0
};
int
hbMgrInit
();
void
hbMgrCleanUp
();
int
hbHandleRsp
(
void
*
hbMsg
);
int
hbRegisterConn
(
SClientHbKey
connKey
,
FGetConnInfo
func
);
int
hbAddConnInfo
(
SClientHbKey
connKey
,
void
*
key
,
void
*
value
,
int32_t
keyLen
,
int32_t
valueLen
);
static
FORCE_INLINE
int
taosEncodeSKlv
(
void
**
buf
,
const
SKlv
*
pKlv
)
{
int
tlen
=
0
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pKlv
->
keyLen
);
...
...
@@ -40,18 +96,13 @@ static FORCE_INLINE int taosEncodeSKlv(void** buf, const SKlv* pKlv) {
}
static
FORCE_INLINE
void
*
taosDecodeSKlv
(
void
*
buf
,
SKlv
*
pKlv
)
{
buf
=
taosDecodeFixedI32
(
buf
,
&
pKlv
->
keyLen
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pKlv
->
keyLen
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pKlv
->
valueLen
);
buf
=
taosDecodeBinary
(
buf
,
&
pKlv
->
key
,
pKlv
->
keyLen
);
buf
=
taosDecodeBinary
(
buf
,
&
pKlv
->
value
,
pKlv
->
valueLen
);
return
buf
;
}
typedef
struct
SClientHbKey
{
int32_t
connId
;
int32_t
hbType
;
}
SClientHbKey
;
static
FORCE_INLINE
int
taosEncodeSClientHbKey
(
void
**
buf
,
const
SClientHbKey
*
pKey
)
{
int
tlen
=
0
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pKey
->
connId
);
...
...
@@ -65,18 +116,13 @@ static FORCE_INLINE void* taosDecodeSClientHbKey(void* buf, SClientHbKey* pKey)
return
buf
;
}
typedef
struct
SClientHbReq
{
SClientHbKey
hbKey
;
SHashObj
*
info
;
// hash<Sklv>
}
SClientHbReq
;
static
FORCE_INLINE
int
tSerializeSClientHbReq
(
void
**
buf
,
const
SClientHbReq
*
pReq
)
{
int
tlen
=
0
;
tlen
+=
taosEncodeSClientHbKey
(
buf
,
&
pReq
->
hbKey
);
void
*
pIter
=
NULL
;
void
*
data
;
SKlv
klv
;
SKlv
klv
;
data
=
taosHashIterate
(
pReq
->
info
,
pIter
);
while
(
data
!=
NULL
)
{
taosHashGetKey
(
data
,
&
klv
.
key
,
(
size_t
*
)
&
klv
.
keyLen
);
...
...
@@ -93,56 +139,13 @@ static FORCE_INLINE void* tDeserializeClientHbReq(void* buf, SClientHbReq* pReq)
ASSERT
(
pReq
->
info
!=
NULL
);
buf
=
taosDecodeSClientHbKey
(
buf
,
&
pReq
->
hbKey
);
//TODO: error handling
if
(
pReq
->
info
==
NULL
)
{
//
TODO: error handling
if
(
pReq
->
info
==
NULL
)
{
pReq
->
info
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
}
SKlv
klv
;
buf
=
taosDecodeSKlv
(
buf
,
&
klv
);
taosHashPut
(
pReq
->
info
,
klv
.
key
,
klv
.
keyLen
,
klv
.
value
,
klv
.
valueLen
);
return
buf
;
}
typedef
struct
SClientHbBatchReq
{
int64_t
reqId
;
SArray
*
reqs
;
// SArray<SClientHbReq>
}
SClientHbBatchReq
;
typedef
struct
SClientHbHandleResult
{
}
SClientHbHandleResult
;
typedef
struct
SClientHbRsp
{
int32_t
connId
;
int32_t
hbType
;
}
SClientHbRsp
;
typedef
struct
SClientHbBatchRsp
{
int64_t
reqId
;
int64_t
rspId
;
SArray
*
rsps
;
// SArray<SClientHbRsp>
}
SClientHbBatchRsp
;
typedef
int32_t
(
*
FHbRspHandle
)(
SClientHbReq
*
pReq
);
typedef
int32_t
(
*
FGetConnInfo
)(
int32_t
conn
,
void
*
self
);
typedef
struct
SClientHbMgr
{
int8_t
inited
;
int32_t
reportInterval
;
// unit ms
int32_t
stats
;
SRWLatch
lock
;
SHashObj
*
info
;
//hash<SClientHbKey, SClientHbReq>
FHbRspHandle
handle
[
HEARTBEAT_TYPE_MAX
];
// input queue
}
SClientHbMgr
;
static
SClientHbMgr
clientHbMgr
=
{
0
};
int
hbMgrInit
();
void
hbMgrCleanUp
();
int
registerConn
(
int32_t
connId
,
FGetConnInfo
func
,
FHbRspHandle
rspHandle
);
int
registerHbRspHandle
(
int32_t
connId
,
int32_t
hbType
,
FHbRspHandle
rspHandle
);
int
HbAddConnInfo
(
int32_t
connId
,
void
*
key
,
void
*
value
,
int32_t
keyLen
,
int32_t
valueLen
);
source/client/src/clientHb.c
浏览文件 @
5c73c1ff
...
...
@@ -15,7 +15,7 @@
#include "clientHb.h"
static
int32_t
mqHbRspHandle
(
SClientHbR
eq
*
pReq
)
{
static
int32_t
mqHbRspHandle
(
SClientHbR
sp
*
pReq
)
{
return
0
;
}
...
...
@@ -42,15 +42,12 @@ void hbMgrCleanUp() {
}
int
registerConn
(
int32_t
connId
,
FGetConnInfo
func
,
FHbRspHandle
rspHandle
)
{
return
0
;
}
int
registerHbRspHandle
(
int32_t
connId
,
int32_t
hbType
,
FHbRspHandle
rspHandle
)
{
int
hbRegisterConn
(
SClientHbKey
connKey
,
FGetConnInfo
func
)
{
return
0
;
}
int
HbAddConnInfo
(
int32_t
connId
,
void
*
key
,
void
*
value
,
int32_t
keyLen
,
int32_t
valueLen
)
{
int
hbAddConnInfo
(
SClientHbKey
connKey
,
void
*
key
,
void
*
value
,
int32_t
keyLen
,
int32_t
valueLen
)
{
//lock
//find req by connection id
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录