Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
16b137d7
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
16b137d7
编写于
7月 03, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-814] change the type of hashkey
上级
2fa3c656
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
20 addition
and
28 deletion
+20
-28
src/mnode/inc/mnodeProfile.h
src/mnode/inc/mnodeProfile.h
+1
-1
src/mnode/src/mnodeProfile.c
src/mnode/src/mnodeProfile.c
+12
-14
src/mnode/src/mnodeShow.c
src/mnode/src/mnodeShow.c
+4
-10
src/plugins/http/src/httpContext.c
src/plugins/http/src/httpContext.c
+1
-1
src/util/inc/tcache.h
src/util/inc/tcache.h
+1
-1
src/util/src/tcache.c
src/util/src/tcache.c
+1
-1
未找到文件。
src/mnode/inc/mnodeProfile.h
浏览文件 @
16b137d7
...
...
@@ -41,7 +41,7 @@ int32_t mnodeInitProfile();
void
mnodeCleanupProfile
();
SConnObj
*
mnodeCreateConn
(
char
*
user
,
uint32_t
ip
,
uint16_t
port
);
SConnObj
*
mnodeAccquireConn
(
u
int32_t
connId
,
char
*
user
,
uint32_t
ip
,
uint16_t
port
);
SConnObj
*
mnodeAccquireConn
(
int32_t
connId
,
char
*
user
,
uint32_t
ip
,
uint16_t
port
);
void
mnodeReleaseConn
(
SConnObj
*
pConn
);
int32_t
mnodeSaveQueryStreamList
(
SConnObj
*
pConn
,
SCMHeartBeatMsg
*
pHBMsg
);
...
...
src/mnode/src/mnodeProfile.c
浏览文件 @
16b137d7
...
...
@@ -43,7 +43,7 @@
extern
void
*
tsMnodeTmr
;
static
SCacheObj
*
tsMnodeConnCache
=
NULL
;
static
u
int32_t
tsConnIndex
=
0
;
static
int32_t
tsConnIndex
=
0
;
static
int32_t
mnodeGetQueryMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeRetrieveQueries
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
...
...
@@ -68,7 +68,7 @@ int32_t mnodeInitProfile() {
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_KILL_STREAM
,
mnodeProcessKillStreamMsg
);
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_KILL_CONN
,
mnodeProcessKillConnectionMsg
);
tsMnodeConnCache
=
taosCacheInitWithCb
(
TSDB_DATA_TYPE_
BINARY
,
CONN_CHECK_TIME
,
false
,
mnodeFreeConn
,
"profile
"
);
tsMnodeConnCache
=
taosCacheInitWithCb
(
TSDB_DATA_TYPE_
INT
,
CONN_CHECK_TIME
,
false
,
mnodeFreeConn
,
"conn
"
);
return
0
;
}
...
...
@@ -89,7 +89,7 @@ SConnObj *mnodeCreateConn(char *user, uint32_t ip, uint16_t port) {
return
NULL
;
}
u
int32_t
connId
=
atomic_add_fetch_32
(
&
tsConnIndex
,
1
);
int32_t
connId
=
atomic_add_fetch_32
(
&
tsConnIndex
,
1
);
if
(
connId
==
0
)
atomic_add_fetch_32
(
&
tsConnIndex
,
1
);
SConnObj
connObj
=
{
...
...
@@ -100,9 +100,7 @@ SConnObj *mnodeCreateConn(char *user, uint32_t ip, uint16_t port) {
};
tstrncpy
(
connObj
.
user
,
user
,
sizeof
(
connObj
.
user
));
char
key
[
10
];
int32_t
len
=
sprintf
(
key
,
"%u"
,
connId
);
SConnObj
*
pConn
=
taosCachePut
(
tsMnodeConnCache
,
key
,
len
,
&
connObj
,
sizeof
(
connObj
),
CONN_KEEP_TIME
);
SConnObj
*
pConn
=
taosCachePut
(
tsMnodeConnCache
,
&
connId
,
sizeof
(
int32_t
),
&
connObj
,
sizeof
(
connObj
),
CONN_KEEP_TIME
);
mDebug
(
"connId:%d, is created, user:%s ip:%s:%u"
,
connId
,
user
,
taosIpStr
(
ip
),
port
);
return
pConn
;
...
...
@@ -113,12 +111,9 @@ void mnodeReleaseConn(SConnObj *pConn) {
taosCacheRelease
(
tsMnodeConnCache
,
(
void
**
)
&
pConn
,
false
);
}
SConnObj
*
mnodeAccquireConn
(
uint32_t
connId
,
char
*
user
,
uint32_t
ip
,
uint16_t
port
)
{
char
key
[
10
];
int32_t
len
=
sprintf
(
key
,
"%u"
,
connId
);
SConnObj
*
mnodeAccquireConn
(
int32_t
connId
,
char
*
user
,
uint32_t
ip
,
uint16_t
port
)
{
uint64_t
expireTime
=
CONN_KEEP_TIME
*
1000
+
(
uint64_t
)
taosGetTimestampMs
();
SConnObj
*
pConn
=
taosCacheUpdateExpireTimeByName
(
tsMnodeConnCache
,
key
,
len
,
expireTime
);
SConnObj
*
pConn
=
taosCacheUpdateExpireTimeByName
(
tsMnodeConnCache
,
&
connId
,
sizeof
(
int32_t
),
expireTime
);
if
(
pConn
==
NULL
)
{
mError
(
"connId:%d, is already destroyed, user:%s ip:%s:%u"
,
connId
,
user
,
taosIpStr
(
ip
),
port
);
return
NULL
;
...
...
@@ -547,7 +542,8 @@ static int32_t mnodeProcessKillQueryMsg(SMnodeMsg *pMsg) {
int32_t
queryId
=
(
int32_t
)
strtol
(
queryIdStr
,
NULL
,
10
);
SConnObj
*
pConn
=
taosCacheAcquireByKey
(
tsMnodeConnCache
,
connIdStr
,
strlen
(
connIdStr
));
int32_t
connId
=
atoi
(
connIdStr
);
SConnObj
*
pConn
=
taosCacheAcquireByKey
(
tsMnodeConnCache
,
&
connId
,
sizeof
(
int32_t
));
if
(
pConn
==
NULL
)
{
mError
(
"connId:%s, failed to kill queryId:%d, conn not exist"
,
connIdStr
,
queryId
);
return
TSDB_CODE_MND_INVALID_CONN_ID
;
...
...
@@ -576,8 +572,9 @@ static int32_t mnodeProcessKillStreamMsg(SMnodeMsg *pMsg) {
}
int32_t
streamId
=
(
int32_t
)
strtol
(
streamIdStr
,
NULL
,
10
);
int32_t
connId
=
atoi
(
connIdStr
);
SConnObj
*
pConn
=
taosCacheAcquireByKey
(
tsMnodeConnCache
,
connIdStr
,
strlen
(
connIdStr
));
SConnObj
*
pConn
=
taosCacheAcquireByKey
(
tsMnodeConnCache
,
&
connId
,
sizeof
(
int32_t
));
if
(
pConn
==
NULL
)
{
mError
(
"connId:%s, failed to kill streamId:%d, conn not exist"
,
connIdStr
,
streamId
);
return
TSDB_CODE_MND_INVALID_CONN_ID
;
...
...
@@ -594,7 +591,8 @@ static int32_t mnodeProcessKillConnectionMsg(SMnodeMsg *pMsg) {
if
(
strcmp
(
pUser
->
user
,
TSDB_DEFAULT_USER
)
!=
0
)
return
TSDB_CODE_MND_NO_RIGHTS
;
SCMKillConnMsg
*
pKill
=
pMsg
->
rpcMsg
.
pCont
;
SConnObj
*
pConn
=
taosCacheAcquireByKey
(
tsMnodeConnCache
,
pKill
->
queryId
,
strlen
(
pKill
->
queryId
));
int32_t
connId
=
atoi
(
pKill
->
queryId
);
SConnObj
*
pConn
=
taosCacheAcquireByKey
(
tsMnodeConnCache
,
&
connId
,
sizeof
(
int32_t
));
if
(
pConn
==
NULL
)
{
mError
(
"connId:%s, failed to kill, conn not exist"
,
pKill
->
queryId
);
return
TSDB_CODE_MND_INVALID_CONN_ID
;
...
...
src/mnode/src/mnodeShow.c
浏览文件 @
16b137d7
...
...
@@ -65,7 +65,7 @@ int32_t mnodeInitShow() {
mnodeAddReadMsgHandle
(
TSDB_MSG_TYPE_CM_CONNECT
,
mnodeProcessConnectMsg
);
mnodeAddReadMsgHandle
(
TSDB_MSG_TYPE_CM_USE_DB
,
mnodeProcessUseMsg
);
tsMnodeShowCache
=
taosCacheInitWithCb
(
TSDB_DATA_TYPE_
BINARY
,
5
,
false
,
mnodeFreeShowObj
,
"show"
);
tsMnodeShowCache
=
taosCacheInitWithCb
(
TSDB_DATA_TYPE_
INT
,
5
,
false
,
mnodeFreeShowObj
,
"show"
);
return
0
;
}
...
...
@@ -364,10 +364,7 @@ static bool mnodeCheckShowFinished(SShowObj *pShow) {
}
static
bool
mnodeAccquireShowObj
(
SShowObj
*
pShow
)
{
char
key
[
10
];
int32_t
len
=
sprintf
(
key
,
"%d"
,
pShow
->
index
);
SShowObj
*
pSaved
=
taosCacheAcquireByKey
(
tsMnodeShowCache
,
key
,
len
);
SShowObj
*
pSaved
=
taosCacheAcquireByKey
(
tsMnodeShowCache
,
&
pShow
->
index
,
sizeof
(
int32_t
));
if
(
pSaved
==
pShow
)
{
mDebug
(
"%p, show is accquired from cache"
,
pShow
);
return
true
;
...
...
@@ -378,14 +375,11 @@ static bool mnodeAccquireShowObj(SShowObj *pShow) {
static
void
*
mnodePutShowObj
(
SShowObj
*
pShow
,
int32_t
size
)
{
if
(
tsMnodeShowCache
!=
NULL
)
{
char
key
[
10
];
pShow
->
index
=
atomic_add_fetch_32
(
&
tsShowObjIndex
,
1
);
int32_t
len
=
sprintf
(
key
,
"%d"
,
pShow
->
index
);
SShowObj
*
newQhandle
=
taosCachePut
(
tsMnodeShowCache
,
key
,
len
,
pShow
,
size
,
6
);
SShowObj
*
newQhandle
=
taosCachePut
(
tsMnodeShowCache
,
&
pShow
->
index
,
sizeof
(
int32_t
),
pShow
,
size
,
6
);
free
(
pShow
);
mDebug
(
"%p, show is put into cache, index:%
s"
,
newQhandle
,
key
);
mDebug
(
"%p, show is put into cache, index:%
d"
,
newQhandle
,
pShow
->
index
);
return
newQhandle
;
}
...
...
src/plugins/http/src/httpContext.c
浏览文件 @
16b137d7
...
...
@@ -58,7 +58,7 @@ static void httpDestroyContext(void *data) {
}
bool
httpInitContexts
()
{
tsHttpServer
.
contextCache
=
taosCacheInitWithCb
(
TSDB_DATA_TYPE_BI
NARY
,
2
,
false
,
httpDestroyContext
,
"restc"
);
tsHttpServer
.
contextCache
=
taosCacheInitWithCb
(
TSDB_DATA_TYPE_BI
GINT
,
2
,
false
,
httpDestroyContext
,
"restc"
);
if
(
tsHttpServer
.
contextCache
==
NULL
)
{
httpError
(
"failed to init context cache"
);
return
false
;
...
...
src/util/inc/tcache.h
浏览文件 @
16b137d7
...
...
@@ -129,7 +129,7 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen
* @param expireTime new expire time of data
* @return
*/
void
*
taosCacheUpdateExpireTimeByName
(
SCacheObj
*
pCacheObj
,
const
char
*
key
,
size_t
keyLen
,
uint64_t
expireTime
);
void
*
taosCacheUpdateExpireTimeByName
(
SCacheObj
*
pCacheObj
,
void
*
key
,
size_t
keyLen
,
uint64_t
expireTime
);
/**
* Add one reference count for the exist data, and assign this data for a new owner.
...
...
src/util/src/tcache.c
浏览文件 @
16b137d7
...
...
@@ -342,7 +342,7 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen
return
(
ptNode
!=
NULL
)
?
(
*
ptNode
)
->
data
:
NULL
;
}
void
*
taosCacheUpdateExpireTimeByName
(
SCacheObj
*
pCacheObj
,
const
char
*
key
,
size_t
keyLen
,
uint64_t
expireTime
)
{
void
*
taosCacheUpdateExpireTimeByName
(
SCacheObj
*
pCacheObj
,
void
*
key
,
size_t
keyLen
,
uint64_t
expireTime
)
{
if
(
pCacheObj
==
NULL
||
taosHashGetSize
(
pCacheObj
->
pHashTable
)
==
0
)
{
return
NULL
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录