Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
ff9bdcfd
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看板
提交
ff9bdcfd
编写于
5月 13, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-149] replace sdb hash
上级
93260417
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
155 addition
and
138 deletion
+155
-138
src/mnode/inc/mgmtAcct.h
src/mnode/inc/mgmtAcct.h
+1
-1
src/mnode/inc/mgmtDb.h
src/mnode/inc/mgmtDb.h
+1
-1
src/mnode/inc/mgmtDef.h
src/mnode/inc/mgmtDef.h
+1
-1
src/mnode/inc/mgmtDnode.h
src/mnode/inc/mgmtDnode.h
+1
-1
src/mnode/inc/mgmtMnode.h
src/mnode/inc/mgmtMnode.h
+1
-1
src/mnode/inc/mgmtSdb.h
src/mnode/inc/mgmtSdb.h
+2
-1
src/mnode/inc/mgmtTable.h
src/mnode/inc/mgmtTable.h
+2
-2
src/mnode/inc/mgmtUser.h
src/mnode/inc/mgmtUser.h
+1
-1
src/mnode/inc/mgmtVgroup.h
src/mnode/inc/mgmtVgroup.h
+1
-1
src/mnode/src/mgmtAcct.c
src/mnode/src/mgmtAcct.c
+2
-2
src/mnode/src/mgmtBalance.c
src/mnode/src/mgmtBalance.c
+5
-2
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+10
-7
src/mnode/src/mgmtDnode.c
src/mnode/src/mgmtDnode.c
+19
-14
src/mnode/src/mgmtMnode.c
src/mnode/src/mgmtMnode.c
+12
-9
src/mnode/src/mgmtProfile.c
src/mnode/src/mgmtProfile.c
+9
-9
src/mnode/src/mgmtSdb.c
src/mnode/src/mgmtSdb.c
+13
-3
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+10
-3
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+31
-52
src/mnode/src/mgmtUser.c
src/mnode/src/mgmtUser.c
+7
-8
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+14
-16
src/util/inc/tcache.h
src/util/inc/tcache.h
+2
-0
src/util/src/tcache.c
src/util/src/tcache.c
+10
-3
未找到文件。
src/mnode/inc/mgmtAcct.h
浏览文件 @
ff9bdcfd
...
...
@@ -25,7 +25,7 @@ extern "C" {
int32_t
mgmtInitAccts
();
void
mgmtCleanUpAccts
();
void
*
mgmtGetAcct
(
char
*
acctName
);
void
*
mgmtGetNextAcct
(
void
*
p
Node
,
SAcctObj
**
pAcct
);
void
*
mgmtGetNextAcct
(
void
*
p
Iter
,
SAcctObj
**
pAcct
);
void
mgmtIncAcctRef
(
SAcctObj
*
pAcct
);
void
mgmtDecAcctRef
(
SAcctObj
*
pAcct
);
void
mgmtAddDbToAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
);
...
...
src/mnode/inc/mgmtDb.h
浏览文件 @
ff9bdcfd
...
...
@@ -32,7 +32,7 @@ int32_t mgmtInitDbs();
void
mgmtCleanUpDbs
();
SDbObj
*
mgmtGetDb
(
char
*
db
);
SDbObj
*
mgmtGetDbByTableId
(
char
*
db
);
void
*
mgmtGetNextDb
(
void
*
p
Node
,
SDbObj
**
pDb
);
void
*
mgmtGetNextDb
(
void
*
p
Iter
,
SDbObj
**
pDb
);
void
mgmtIncDbRef
(
SDbObj
*
pDb
);
void
mgmtDecDbRef
(
SDbObj
*
pDb
);
bool
mgmtCheckIsMonitorDB
(
char
*
db
,
char
*
monitordb
);
...
...
src/mnode/inc/mgmtDef.h
浏览文件 @
ff9bdcfd
...
...
@@ -223,7 +223,7 @@ typedef struct SAcctObj {
typedef
struct
{
int8_t
type
;
char
db
[
TSDB_DB_NAME_LEN
+
1
];
void
*
p
Node
;
void
*
p
Iter
;
int16_t
numOfColumns
;
int32_t
rowSize
;
int32_t
numOfRows
;
...
...
src/mnode/inc/mgmtDnode.h
浏览文件 @
ff9bdcfd
...
...
@@ -34,7 +34,7 @@ char* mgmtGetDnodeStatusStr(int32_t dnodeStatus);
void
mgmtMonitorDnodeModule
();
int32_t
mgmtGetDnodesNum
();
void
*
mgmtGetNextDnode
(
void
*
p
Node
,
SDnodeObj
**
pDnode
);
void
*
mgmtGetNextDnode
(
void
*
p
Iter
,
SDnodeObj
**
pDnode
);
void
mgmtIncDnodeRef
(
SDnodeObj
*
pDnode
);
void
mgmtDecDnodeRef
(
SDnodeObj
*
pDnode
);
void
*
mgmtGetDnode
(
int32_t
dnodeId
);
...
...
src/mnode/inc/mgmtMnode.h
浏览文件 @
ff9bdcfd
...
...
@@ -37,7 +37,7 @@ void mgmtDropMnodeLocal(int32_t dnodeId);
void
*
mgmtGetMnode
(
int32_t
mnodeId
);
int32_t
mgmtGetMnodesNum
();
void
*
mgmtGetNextMnode
(
void
*
p
Node
,
struct
SMnodeObj
**
pMnode
);
void
*
mgmtGetNextMnode
(
void
*
p
Iter
,
struct
SMnodeObj
**
pMnode
);
void
mgmtIncMnodeRef
(
struct
SMnodeObj
*
pMnode
);
void
mgmtDecMnodeRef
(
struct
SMnodeObj
*
pMnode
);
...
...
src/mnode/inc/mgmtSdb.h
浏览文件 @
ff9bdcfd
...
...
@@ -80,7 +80,8 @@ int32_t sdbDeleteRow(SSdbOper *pOper);
int32_t
sdbUpdateRow
(
SSdbOper
*
pOper
);
void
*
sdbGetRow
(
void
*
handle
,
void
*
key
);
void
*
sdbFetchRow
(
void
*
handle
,
void
*
pNode
,
void
**
ppRow
);
void
*
sdbFetchRow
(
void
*
handle
,
void
*
pIter
,
void
**
ppRow
);
void
sdbFreeIter
(
void
*
pIter
);
void
sdbIncRef
(
void
*
thandle
,
void
*
pRow
);
void
sdbDecRef
(
void
*
thandle
,
void
*
pRow
);
int64_t
sdbGetNumOfRows
(
void
*
handle
);
...
...
src/mnode/inc/mgmtTable.h
浏览文件 @
ff9bdcfd
...
...
@@ -27,8 +27,8 @@ void mgmtCleanUpTables();
void
*
mgmtGetTable
(
char
*
tableId
);
void
mgmtIncTableRef
(
void
*
pTable
);
void
mgmtDecTableRef
(
void
*
pTable
);
void
*
mgmtGetNextChildTable
(
void
*
p
Node
,
SChildTableObj
**
pTable
);
void
*
mgmtGetNextSuperTable
(
void
*
p
Node
,
SSuperTableObj
**
pTable
);
void
*
mgmtGetNextChildTable
(
void
*
p
Iter
,
SChildTableObj
**
pTable
);
void
*
mgmtGetNextSuperTable
(
void
*
p
Iter
,
SSuperTableObj
**
pTable
);
void
mgmtDropAllChildTables
(
SDbObj
*
pDropDb
);
void
mgmtDropAllSuperTables
(
SDbObj
*
pDropDb
);
...
...
src/mnode/inc/mgmtUser.h
浏览文件 @
ff9bdcfd
...
...
@@ -24,7 +24,7 @@ extern "C" {
int32_t
mgmtInitUsers
();
void
mgmtCleanUpUsers
();
SUserObj
*
mgmtGetUser
(
char
*
name
);
void
*
mgmtGetNextUser
(
void
*
p
Node
,
SUserObj
**
pUser
);
void
*
mgmtGetNextUser
(
void
*
p
Iter
,
SUserObj
**
pUser
);
void
mgmtIncUserRef
(
SUserObj
*
pUser
);
void
mgmtDecUserRef
(
SUserObj
*
pUser
);
SUserObj
*
mgmtGetUserFromConn
(
void
*
pConn
);
...
...
src/mnode/inc/mgmtVgroup.h
浏览文件 @
ff9bdcfd
...
...
@@ -35,7 +35,7 @@ void mgmtDecVgroupRef(SVgObj *pVgroup);
void
mgmtDropAllDbVgroups
(
SDbObj
*
pDropDb
,
bool
sendMsg
);
void
mgmtDropAllDnodeVgroups
(
SDnodeObj
*
pDropDnode
);
void
*
mgmtGetNextVgroup
(
void
*
p
Node
,
SVgObj
**
pVgroup
);
void
*
mgmtGetNextVgroup
(
void
*
p
Iter
,
SVgObj
**
pVgroup
);
void
mgmtUpdateVgroup
(
SVgObj
*
pVgroup
);
void
mgmtUpdateVgroupStatus
(
SVgObj
*
pVgroup
,
SDnodeObj
*
dnodeId
,
SVnodeLoad
*
pVload
);
...
...
src/mnode/src/mgmtAcct.c
浏览文件 @
ff9bdcfd
...
...
@@ -126,8 +126,8 @@ void *mgmtGetAcct(char *name) {
return
sdbGetRow
(
tsAcctSdb
,
name
);
}
void
*
mgmtGetNextAcct
(
void
*
p
Node
,
SAcctObj
**
pAcct
)
{
return
sdbFetchRow
(
tsAcctSdb
,
p
Node
,
(
void
**
)
pAcct
);
void
*
mgmtGetNextAcct
(
void
*
p
Iter
,
SAcctObj
**
pAcct
)
{
return
sdbFetchRow
(
tsAcctSdb
,
p
Iter
,
(
void
**
)
pAcct
);
}
void
mgmtIncAcctRef
(
SAcctObj
*
pAcct
)
{
...
...
src/mnode/src/mgmtBalance.c
浏览文件 @
ff9bdcfd
...
...
@@ -22,6 +22,7 @@
#include "mgmtInt.h"
#include "mgmtMnode.h"
#include "mgmtDnode.h"
#include "mgmtSdb.h"
#include "mgmtVgroup.h"
#ifndef _SYNC
...
...
@@ -33,13 +34,13 @@ void balanceUpdateMgmt() {}
void
balanceReset
()
{}
int32_t
balanceAllocVnodes
(
SVgObj
*
pVgroup
)
{
void
*
p
Node
=
NULL
;
void
*
p
Iter
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
SDnodeObj
*
pSelDnode
=
NULL
;
float
vnodeUsage
=
1000
.
0
;
while
(
1
)
{
p
Node
=
mgmtGetNextDnode
(
pNode
,
&
pDnode
);
p
Iter
=
mgmtGetNextDnode
(
pIter
,
&
pDnode
);
if
(
pDnode
==
NULL
)
break
;
if
(
pDnode
->
totalVnodes
>
0
&&
pDnode
->
openVnodes
<
pDnode
->
totalVnodes
)
{
...
...
@@ -55,6 +56,8 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) {
mgmtDecDnodeRef
(
pDnode
);
}
sdbFreeIter
(
pIter
);
if
(
pSelDnode
==
NULL
)
{
mError
(
"failed to alloc vnode to vgroup"
);
return
TSDB_CODE_NO_ENOUGH_DNODES
;
...
...
src/mnode/src/mgmtDb.c
浏览文件 @
ff9bdcfd
...
...
@@ -156,8 +156,8 @@ int32_t mgmtInitDbs() {
return
0
;
}
void
*
mgmtGetNextDb
(
void
*
p
Node
,
SDbObj
**
pDb
)
{
return
sdbFetchRow
(
tsDbSdb
,
p
Node
,
(
void
**
)
pDb
);
void
*
mgmtGetNextDb
(
void
*
p
Iter
,
SDbObj
**
pDb
)
{
return
sdbFetchRow
(
tsDbSdb
,
p
Iter
,
(
void
**
)
pDb
);
}
SDbObj
*
mgmtGetDb
(
char
*
db
)
{
...
...
@@ -583,7 +583,7 @@ static int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *
if
(
pUser
==
NULL
)
return
0
;
while
(
numOfRows
<
rows
)
{
pShow
->
p
Node
=
mgmtGetNextDb
(
pShow
->
pNode
,
&
pDb
);
pShow
->
p
Iter
=
mgmtGetNextDb
(
pShow
->
pIter
,
&
pDb
);
if
(
pDb
==
NULL
)
break
;
cols
=
0
;
...
...
@@ -865,14 +865,15 @@ static int32_t mgmtAlterDb(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
}
}
void
*
p
Node
=
NULL
;
void
*
p
Iter
=
NULL
;
while
(
1
)
{
SVgObj
*
pVgroup
=
NULL
;
p
Node
=
mgmtGetNextVgroup
(
pNode
,
&
pVgroup
);
p
Iter
=
mgmtGetNextVgroup
(
pIter
,
&
pVgroup
);
if
(
pVgroup
==
NULL
)
break
;
mgmtSendCreateVgroupMsg
(
pVgroup
,
NULL
);
mgmtDecVgroupRef
(
pVgroup
);
}
sdbFreeIter
(
pIter
);
if
(
oldReplica
!=
pDb
->
cfg
.
replications
)
{
balanceNotify
();
...
...
@@ -983,12 +984,12 @@ static void mgmtProcessDropDbMsg(SQueuedMsg *pMsg) {
void
mgmtDropAllDbs
(
SAcctObj
*
pAcct
)
{
int32_t
numOfDbs
=
0
;
SDbObj
*
pDb
=
NULL
;
void
*
p
Node
=
NULL
;
void
*
p
Iter
=
NULL
;
mPrint
(
"acct:%s, all dbs will be dropped from sdb"
,
pAcct
->
user
);
while
(
1
)
{
p
Node
=
mgmtGetNextDb
(
pNode
,
&
pDb
);
p
Iter
=
mgmtGetNextDb
(
pIter
,
&
pDb
);
if
(
pDb
==
NULL
)
break
;
if
(
pDb
->
pAcct
==
pAcct
)
{
...
...
@@ -1005,5 +1006,7 @@ void mgmtDropAllDbs(SAcctObj *pAcct) {
mgmtDecDbRef
(
pDb
);
}
sdbFreeIter
(
pIter
);
mPrint
(
"acct:%s, all dbs:%d is dropped from sdb"
,
pAcct
->
user
,
numOfDbs
);
}
src/mnode/src/mgmtDnode.c
浏览文件 @
ff9bdcfd
...
...
@@ -170,8 +170,8 @@ void mgmtCleanupDnodes() {
sdbCloseTable
(
tsDnodeSdb
);
}
void
*
mgmtGetNextDnode
(
void
*
p
Node
,
SDnodeObj
**
pDnode
)
{
return
sdbFetchRow
(
tsDnodeSdb
,
p
Node
,
(
void
**
)
pDnode
);
void
*
mgmtGetNextDnode
(
void
*
p
Iter
,
SDnodeObj
**
pDnode
)
{
return
sdbFetchRow
(
tsDnodeSdb
,
p
Iter
,
(
void
**
)
pDnode
);
}
int32_t
mgmtGetDnodesNum
()
{
...
...
@@ -184,17 +184,20 @@ void *mgmtGetDnode(int32_t dnodeId) {
void
*
mgmtGetDnodeByEp
(
char
*
ep
)
{
SDnodeObj
*
pDnode
=
NULL
;
void
*
p
Node
=
NULL
;
void
*
p
Iter
=
NULL
;
while
(
1
)
{
p
Node
=
mgmtGetNextDnode
(
pNode
,
&
pDnode
);
p
Iter
=
mgmtGetNextDnode
(
pIter
,
&
pDnode
);
if
(
pDnode
==
NULL
)
break
;
if
(
strcmp
(
ep
,
pDnode
->
dnodeEp
)
==
0
)
{
sdbFreeIter
(
pIter
);
return
pDnode
;
}
mgmtDecDnodeRef
(
pDnode
);
}
sdbFreeIter
(
pIter
);
return
NULL
;
}
...
...
@@ -530,7 +533,7 @@ static int32_t mgmtGetDnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pCo
pShow
->
numOfRows
=
mgmtGetDnodesNum
();
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
p
Node
=
NULL
;
pShow
->
p
Iter
=
NULL
;
mgmtDecUserRef
(
pUser
);
...
...
@@ -544,7 +547,7 @@ static int32_t mgmtRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, voi
char
*
pWrite
;
while
(
numOfRows
<
rows
)
{
pShow
->
p
Node
=
mgmtGetNextDnode
(
pShow
->
pNode
,
&
pDnode
);
pShow
->
p
Iter
=
mgmtGetNextDnode
(
pShow
->
pIter
,
&
pDnode
);
if
(
pDnode
==
NULL
)
break
;
cols
=
0
;
...
...
@@ -636,7 +639,7 @@ static int32_t mgmtGetModuleMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
pShow
->
numOfRows
=
mgmtGetDnodesNum
()
*
TSDB_MOD_MAX
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
p
Node
=
NULL
;
pShow
->
p
Iter
=
NULL
;
mgmtDecUserRef
(
pUser
);
return
0
;
...
...
@@ -648,7 +651,7 @@ int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pCo
while
(
numOfRows
<
rows
)
{
SDnodeObj
*
pDnode
=
NULL
;
pShow
->
p
Node
=
mgmtGetNextDnode
(
pShow
->
pNode
,
(
SDnodeObj
**
)
&
pDnode
);
pShow
->
p
Iter
=
mgmtGetNextDnode
(
pShow
->
pIter
,
(
SDnodeObj
**
)
&
pDnode
);
if
(
pDnode
==
NULL
)
break
;
for
(
int32_t
moduleType
=
0
;
moduleType
<
TSDB_MOD_MAX
;
++
moduleType
)
{
...
...
@@ -738,7 +741,7 @@ static int32_t mgmtGetConfigMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
}
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
p
Node
=
NULL
;
pShow
->
p
Iter
=
NULL
;
mgmtDecUserRef
(
pUser
);
return
0
;
...
...
@@ -821,7 +824,8 @@ static int32_t mgmtGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pCo
if
(
pShow
->
payloadLen
>
0
)
{
pDnode
=
mgmtGetDnodeByEp
(
pShow
->
payload
);
}
else
{
mgmtGetNextDnode
(
NULL
,
(
SDnodeObj
**
)
&
pDnode
);
void
*
pIter
=
mgmtGetNextDnode
(
NULL
,
(
SDnodeObj
**
)
&
pDnode
);
sdbFreeIter
(
pIter
);
}
if
(
pDnode
!=
NULL
)
{
...
...
@@ -830,7 +834,7 @@ static int32_t mgmtGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pCo
}
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
p
Node
=
pDnode
;
pShow
->
p
Iter
=
pDnode
;
mgmtDecUserRef
(
pUser
);
return
0
;
...
...
@@ -844,12 +848,12 @@ static int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, voi
if
(
0
==
rows
)
return
0
;
pDnode
=
(
SDnodeObj
*
)(
pShow
->
p
Node
);
pDnode
=
(
SDnodeObj
*
)(
pShow
->
p
Iter
);
if
(
pDnode
!=
NULL
)
{
void
*
p
Node
=
NULL
;
void
*
p
Iter
=
NULL
;
SVgObj
*
pVgroup
;
while
(
1
)
{
p
Node
=
mgmtGetNextVgroup
(
pNode
,
&
pVgroup
);
p
Iter
=
mgmtGetNextVgroup
(
pIter
,
&
pVgroup
);
if
(
pVgroup
==
NULL
)
break
;
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
...
...
@@ -869,6 +873,7 @@ static int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, voi
mgmtDecVgroupRef
(
pVgroup
);
}
sdbFreeIter
(
pIter
);
}
else
{
numOfRows
=
0
;
}
...
...
src/mnode/src/mgmtMnode.c
浏览文件 @
ff9bdcfd
...
...
@@ -95,11 +95,12 @@ static int32_t mgmtMnodeActionDecode(SSdbOper *pOper) {
static
int32_t
mgmtMnodeActionRestored
()
{
if
(
mgmtGetMnodesNum
()
==
1
)
{
SMnodeObj
*
pMnode
=
NULL
;
mgmtGetNextMnode
(
NULL
,
&
pMnode
);
void
*
pIter
=
mgmtGetNextMnode
(
NULL
,
&
pMnode
);
if
(
pMnode
!=
NULL
)
{
pMnode
->
role
=
TAOS_SYNC_ROLE_MASTER
;
mgmtDecMnodeRef
(
pMnode
);
}
sdbFreeIter
(
pIter
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -157,8 +158,8 @@ void mgmtDecMnodeRef(SMnodeObj *pMnode) {
sdbDecRef
(
tsMnodeSdb
,
pMnode
);
}
void
*
mgmtGetNextMnode
(
void
*
p
Node
,
SMnodeObj
**
pMnode
)
{
return
sdbFetchRow
(
tsMnodeSdb
,
p
Node
,
(
void
**
)
pMnode
);
void
*
mgmtGetNextMnode
(
void
*
p
Iter
,
SMnodeObj
**
pMnode
)
{
return
sdbFetchRow
(
tsMnodeSdb
,
p
Iter
,
(
void
**
)
pMnode
);
}
char
*
mgmtGetMnodeRoleStr
(
int32_t
role
)
{
...
...
@@ -177,10 +178,10 @@ char *mgmtGetMnodeRoleStr(int32_t role) {
}
void
mgmtGetMnodeIpSet
(
SRpcIpSet
*
ipSet
)
{
void
*
p
Node
=
NULL
;
void
*
p
Iter
=
NULL
;
while
(
1
)
{
SMnodeObj
*
pMnode
=
NULL
;
p
Node
=
mgmtGetNextMnode
(
pNode
,
&
pMnode
);
p
Iter
=
mgmtGetNextMnode
(
pIter
,
&
pMnode
);
if
(
pMnode
==
NULL
)
break
;
strcpy
(
ipSet
->
fqdn
[
ipSet
->
numOfIps
],
pMnode
->
pDnode
->
dnodeFqdn
);
...
...
@@ -194,6 +195,7 @@ void mgmtGetMnodeIpSet(SRpcIpSet *ipSet) {
mgmtDecMnodeRef
(
pMnode
);
}
sdbFreeIter
(
pIter
);
}
void
mgmtGetMnodeInfos
(
void
*
param
)
{
...
...
@@ -201,10 +203,10 @@ void mgmtGetMnodeInfos(void *param) {
mnodes
->
inUse
=
0
;
int32_t
index
=
0
;
void
*
p
Node
=
NULL
;
void
*
p
Iter
=
NULL
;
while
(
1
)
{
SMnodeObj
*
pMnode
=
NULL
;
p
Node
=
mgmtGetNextMnode
(
pNode
,
&
pMnode
);
p
Iter
=
mgmtGetNextMnode
(
pIter
,
&
pMnode
);
if
(
pMnode
==
NULL
)
break
;
mnodes
->
nodeInfos
[
index
].
nodeId
=
htonl
(
pMnode
->
mnodeId
);
...
...
@@ -216,6 +218,7 @@ void mgmtGetMnodeInfos(void *param) {
index
++
;
mgmtDecMnodeRef
(
pMnode
);
}
sdbFreeIter
(
pIter
);
mnodes
->
nodeNum
=
index
;
}
...
...
@@ -317,7 +320,7 @@ static int32_t mgmtGetMnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pCo
pShow
->
numOfRows
=
mgmtGetMnodesNum
();
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
p
Node
=
NULL
;
pShow
->
p
Iter
=
NULL
;
mgmtDecUserRef
(
pUser
);
return
0
;
...
...
@@ -330,7 +333,7 @@ static int32_t mgmtRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, voi
char
*
pWrite
;
while
(
numOfRows
<
rows
)
{
pShow
->
p
Node
=
mgmtGetNextMnode
(
pShow
->
pNode
,
&
pMnode
);
pShow
->
p
Iter
=
mgmtGetNextMnode
(
pShow
->
pIter
,
&
pMnode
);
if
(
pMnode
==
NULL
)
break
;
cols
=
0
;
...
...
src/mnode/src/mgmtProfile.c
浏览文件 @
ff9bdcfd
...
...
@@ -140,7 +140,7 @@ int32_t mgmtGetQueries(SShowObj *pShow, void *pConn) {
//
// // sorting based on useconds
//
// pShow->p
Node
= pQueryShow;
// pShow->p
Iter
= pQueryShow;
return
0
;
}
...
...
@@ -187,7 +187,7 @@ int32_t mgmtGetQueryMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
pShow
->
numOfRows
=
1000000
;
pShow
->
p
Node
=
NULL
;
pShow
->
p
Iter
=
NULL
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
mgmtGetQueries
(
pShow
,
pConn
);
...
...
@@ -252,7 +252,7 @@ int32_t mgmtRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, void *pCo
char
*
pWrite
;
int32_t
cols
=
0
;
SQueryShow
*
pQueryShow
=
(
SQueryShow
*
)
pShow
->
p
Node
;
SQueryShow
*
pQueryShow
=
(
SQueryShow
*
)
pShow
->
p
Iter
;
if
(
rows
>
pQueryShow
->
numOfQueries
-
pQueryShow
->
index
)
rows
=
pQueryShow
->
numOfQueries
-
pQueryShow
->
index
;
...
...
@@ -339,7 +339,7 @@ int32_t mgmtGetStreams(SShowObj *pShow, void *pConn) {
//
// // sorting based on useconds
//
// pShow->p
Node
= pStreamShow;
// pShow->p
Iter
= pStreamShow;
return
0
;
}
...
...
@@ -397,7 +397,7 @@ int32_t mgmtGetStreamMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
pShow
->
numOfRows
=
1000000
;
pShow
->
p
Node
=
NULL
;
pShow
->
p
Iter
=
NULL
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
mgmtGetStreams
(
pShow
,
pConn
);
...
...
@@ -409,7 +409,7 @@ int32_t mgmtRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, void *pCo
char
*
pWrite
;
int32_t
cols
=
0
;
SStreamShow
*
pStreamShow
=
(
SStreamShow
*
)
pShow
->
p
Node
;
SStreamShow
*
pStreamShow
=
(
SStreamShow
*
)
pShow
->
p
Iter
;
if
(
rows
>
pStreamShow
->
numOfStreams
-
pStreamShow
->
index
)
rows
=
pStreamShow
->
numOfStreams
-
pStreamShow
->
index
;
...
...
@@ -592,7 +592,7 @@ int mgmtGetConns(SShowObj *pShow, void *pConn) {
//
// // sorting based on useconds
//
// pShow->p
Node
= pConnShow;
// pShow->p
Iter
= pConnShow;
return
0
;
}
...
...
@@ -627,7 +627,7 @@ int32_t mgmtGetConnsMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
for
(
int
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
pShow
->
numOfRows
=
1000000
;
pShow
->
p
Node
=
NULL
;
pShow
->
p
Iter
=
NULL
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
mgmtGetConns
(
pShow
,
pConn
);
...
...
@@ -639,7 +639,7 @@ int32_t mgmtRetrieveConns(SShowObj *pShow, char *data, int32_t rows, void *pConn
char
*
pWrite
;
int32_t
cols
=
0
;
SConnShow
*
pConnShow
=
(
SConnShow
*
)
pShow
->
p
Node
;
SConnShow
*
pConnShow
=
(
SConnShow
*
)
pShow
->
p
Iter
;
if
(
rows
>
pConnShow
->
numOfConns
-
pConnShow
->
index
)
rows
=
pConnShow
->
numOfConns
-
pConnShow
->
index
;
...
...
src/mnode/src/mgmtSdb.c
浏览文件 @
ff9bdcfd
...
...
@@ -239,10 +239,10 @@ void sdbUpdateSync() {
}
if
(
index
==
0
)
{
void
*
p
Node
=
NULL
;
void
*
p
Iter
=
NULL
;
while
(
1
)
{
SMnodeObj
*
pMnode
=
NULL
;
p
Node
=
mgmtGetNextMnode
(
pNode
,
&
pMnode
);
p
Iter
=
mgmtGetNextMnode
(
pIter
,
&
pMnode
);
if
(
pMnode
==
NULL
)
break
;
syncCfg
.
nodeInfo
[
index
].
nodeId
=
pMnode
->
mnodeId
;
...
...
@@ -252,6 +252,7 @@ void sdbUpdateSync() {
mgmtDecMnodeRef
(
pMnode
);
}
sdbFreeIter
(
pIter
);
}
syncCfg
.
replica
=
index
;
...
...
@@ -666,7 +667,10 @@ void *sdbFetchRow(void *handle, void *pNode, void **ppRow) {
}
SSdbRow
*
pMeta
=
taosHashIterGet
(
pIter
);
if
(
pMeta
==
NULL
)
return
NULL
;
if
(
pMeta
==
NULL
)
{
taosHashDestroyIter
(
pIter
);
return
NULL
;
}
*
ppRow
=
pMeta
->
row
;
sdbIncRef
(
handle
,
pMeta
->
row
);
...
...
@@ -674,6 +678,12 @@ void *sdbFetchRow(void *handle, void *pNode, void **ppRow) {
return
pIter
;
}
void
sdbFreeIter
(
void
*
pIter
)
{
if
(
pIter
!=
NULL
)
{
taosHashDestroyIter
(
pIter
);
}
}
void
*
sdbOpenTable
(
SSdbTableDesc
*
pDesc
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
calloc
(
1
,
sizeof
(
SSdbTable
));
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
ff9bdcfd
...
...
@@ -48,6 +48,7 @@ static void mgmtProcessRetrieveMsg(SQueuedMsg *queuedMsg);
static
void
mgmtProcessHeartBeatMsg
(
SQueuedMsg
*
queuedMsg
);
static
void
mgmtProcessConnectMsg
(
SQueuedMsg
*
queuedMsg
);
static
void
mgmtProcessUseMsg
(
SQueuedMsg
*
queuedMsg
);
static
void
mgmtFreeShowObj
(
void
*
data
);
void
*
tsMgmtTmr
;
static
void
*
tsMgmtTranQhandle
=
NULL
;
...
...
@@ -65,7 +66,7 @@ int32_t mgmtInitShell() {
tsMgmtTmr
=
taosTmrInit
((
tsMaxShellConns
)
*
3
,
200
,
3600000
,
"MND"
);
tsMgmtTranQhandle
=
taosInitScheduler
(
tsMaxShellConns
,
1
,
"mnodeT"
);
tsQhandleCache
=
taosCacheInit
(
tsMgmtTmr
,
10
);
tsQhandleCache
=
taosCacheInit
WithCb
(
tsMgmtTmr
,
10
,
mgmtFreeShowObj
);
return
0
;
}
...
...
@@ -479,7 +480,7 @@ bool mgmtCheckQhandle(uint64_t qhandle) {
mTrace
(
"qhandle:%p is retrived"
,
qhandle
);
return
true
;
}
else
{
mTrace
(
"qhandle:%p is already
fre
ed"
,
qhandle
);
mTrace
(
"qhandle:%p is already
releas
ed"
,
qhandle
);
return
false
;
}
}
...
...
@@ -498,8 +499,14 @@ void* mgmtSaveQhandle(void *qhandle, int32_t size) {
return
NULL
;
}
static
void
mgmtFreeShowObj
(
void
*
data
)
{
SShowObj
*
pShow
=
data
;
//sdbFreeIter(pShow->pIter);
mTrace
(
"qhandle:%p is destroyed"
,
pShow
);
}
void
mgmtFreeQhandle
(
void
*
qhandle
,
bool
forceRemove
)
{
mTrace
(
"qhandle:%p is
fre
ed"
,
qhandle
);
mTrace
(
"qhandle:%p is
releas
ed"
,
qhandle
);
taosCacheRelease
(
tsQhandleCache
,
&
qhandle
,
forceRemove
);
}
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
ff9bdcfd
...
...
@@ -247,25 +247,19 @@ static int32_t mgmtChildTableActionDecode(SSdbOper *pOper) {
}
static
int32_t
mgmtChildTableActionRestored
()
{
void
*
pNode
=
NULL
;
void
*
pLastNode
=
NULL
;
void
*
pIter
=
NULL
;
SChildTableObj
*
pTable
=
NULL
;
while
(
1
)
{
pLastNode
=
pNode
;
mgmtDecTableRef
(
pTable
);
p
Node
=
mgmtGetNextChildTable
(
pNode
,
&
pTable
);
p
Iter
=
mgmtGetNextChildTable
(
pIter
,
&
pTable
);
if
(
pTable
==
NULL
)
break
;
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pTable
->
info
.
tableId
);
if
(
pDb
==
NULL
)
{
mError
(
"ctable:%s, failed to get db, discard it"
,
pTable
->
info
.
tableId
);
SSdbOper
desc
=
{
0
};
desc
.
type
=
SDB_OPER_LOCAL
;
desc
.
pObj
=
pTable
;
desc
.
table
=
tsChildTableSdb
;
SSdbOper
desc
=
{.
type
=
SDB_OPER_LOCAL
,
.
pObj
=
pTable
,
.
table
=
tsChildTableSdb
};
sdbDeleteRow
(
&
desc
);
pNode
=
pLastNode
;
continue
;
}
mgmtDecDbRef
(
pDb
);
...
...
@@ -274,12 +268,8 @@ static int32_t mgmtChildTableActionRestored() {
if
(
pVgroup
==
NULL
)
{
mError
(
"ctable:%s, failed to get vgId:%d sid:%d, discard it"
,
pTable
->
info
.
tableId
,
pTable
->
vgId
,
pTable
->
sid
);
pTable
->
vgId
=
0
;
SSdbOper
desc
=
{
0
};
desc
.
type
=
SDB_OPER_LOCAL
;
desc
.
pObj
=
pTable
;
desc
.
table
=
tsChildTableSdb
;
SSdbOper
desc
=
{.
type
=
SDB_OPER_LOCAL
,
.
pObj
=
pTable
,
.
table
=
tsChildTableSdb
};
sdbDeleteRow
(
&
desc
);
pNode
=
pLastNode
;
continue
;
}
mgmtDecVgroupRef
(
pVgroup
);
...
...
@@ -288,24 +278,16 @@ static int32_t mgmtChildTableActionRestored() {
mError
(
"ctable:%s, db:%s not match with vgId:%d db:%s sid:%d, discard it"
,
pTable
->
info
.
tableId
,
pDb
->
name
,
pTable
->
vgId
,
pVgroup
->
dbName
,
pTable
->
sid
);
pTable
->
vgId
=
0
;
SSdbOper
desc
=
{
0
};
desc
.
type
=
SDB_OPER_LOCAL
;
desc
.
pObj
=
pTable
;
desc
.
table
=
tsChildTableSdb
;
SSdbOper
desc
=
{.
type
=
SDB_OPER_LOCAL
,
.
pObj
=
pTable
,
.
table
=
tsChildTableSdb
};
sdbDeleteRow
(
&
desc
);
pNode
=
pLastNode
;
continue
;
}
if
(
pVgroup
->
tableList
==
NULL
)
{
mError
(
"ctable:%s, vgId:%d tableList is null"
,
pTable
->
info
.
tableId
,
pTable
->
vgId
);
pTable
->
vgId
=
0
;
SSdbOper
desc
=
{
0
};
desc
.
type
=
SDB_OPER_LOCAL
;
desc
.
pObj
=
pTable
;
desc
.
table
=
tsChildTableSdb
;
SSdbOper
desc
=
{.
type
=
SDB_OPER_LOCAL
,
.
pObj
=
pTable
,
.
table
=
tsChildTableSdb
};
sdbDeleteRow
(
&
desc
);
pNode
=
pLastNode
;
continue
;
}
...
...
@@ -314,18 +296,16 @@ static int32_t mgmtChildTableActionRestored() {
if
(
pSuperTable
==
NULL
)
{
mError
(
"ctable:%s, stable:%"
PRIu64
" not exist"
,
pTable
->
info
.
tableId
,
pTable
->
suid
);
pTable
->
vgId
=
0
;
SSdbOper
desc
=
{
0
};
desc
.
type
=
SDB_OPER_LOCAL
;
desc
.
pObj
=
pTable
;
desc
.
table
=
tsChildTableSdb
;
SSdbOper
desc
=
{.
type
=
SDB_OPER_LOCAL
,
.
pObj
=
pTable
,
.
table
=
tsChildTableSdb
};
sdbDeleteRow
(
&
desc
);
pNode
=
pLastNode
;
continue
;
}
mgmtDecTableRef
(
pSuperTable
);
}
}
sdbFreeIter
(
pIter
);
return
0
;
}
...
...
@@ -560,10 +540,10 @@ static void *mgmtGetSuperTable(char *tableId) {
static
void
*
mgmtGetSuperTableByUid
(
uint64_t
uid
)
{
SSuperTableObj
*
pStable
=
NULL
;
void
*
pNode
=
NULL
;
void
*
pIter
=
NULL
;
while
(
1
)
{
p
Node
=
mgmtGetNextSuperTable
(
pNode
,
&
pStable
);
p
Iter
=
mgmtGetNextSuperTable
(
pIter
,
&
pStable
);
if
(
pStable
==
NULL
)
break
;
if
(
pStable
->
uid
==
uid
)
{
return
pStable
;
...
...
@@ -571,6 +551,8 @@ static void *mgmtGetSuperTableByUid(uint64_t uid) {
mgmtDecTableRef
(
pStable
);
}
sdbFreeIter
(
pIter
);
return
NULL
;
}
...
...
@@ -588,12 +570,12 @@ void *mgmtGetTable(char *tableId) {
return
NULL
;
}
void
*
mgmtGetNextChildTable
(
void
*
p
Node
,
SChildTableObj
**
pTable
)
{
return
sdbFetchRow
(
tsChildTableSdb
,
p
Node
,
(
void
**
)
pTable
);
void
*
mgmtGetNextChildTable
(
void
*
p
Iter
,
SChildTableObj
**
pTable
)
{
return
sdbFetchRow
(
tsChildTableSdb
,
p
Iter
,
(
void
**
)
pTable
);
}
void
*
mgmtGetNextSuperTable
(
void
*
p
Node
,
SSuperTableObj
**
pTable
)
{
return
sdbFetchRow
(
tsSuperTableSdb
,
p
Node
,
(
void
**
)
pTable
);
void
*
mgmtGetNextSuperTable
(
void
*
p
Iter
,
SSuperTableObj
**
pTable
)
{
return
sdbFetchRow
(
tsSuperTableSdb
,
p
Iter
,
(
void
**
)
pTable
);
}
void
mgmtIncTableRef
(
void
*
p1
)
{
...
...
@@ -1122,7 +1104,7 @@ int32_t mgmtRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows, v
while
(
numOfRows
<
rows
)
{
mgmtDecTableRef
(
pTable
);
pShow
->
p
Node
=
mgmtGetNextSuperTable
(
pShow
->
pNode
,
&
pTable
);
pShow
->
p
Iter
=
mgmtGetNextSuperTable
(
pShow
->
pIter
,
&
pTable
);
if
(
pTable
==
NULL
)
break
;
if
(
strncmp
(
pTable
->
info
.
tableId
,
prefix
,
prefixLen
))
{
continue
;
...
...
@@ -1172,8 +1154,7 @@ int32_t mgmtRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows, v
}
void
mgmtDropAllSuperTables
(
SDbObj
*
pDropDb
)
{
void
*
pNode
=
NULL
;
void
*
pLastNode
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
numOfTables
=
0
;
int32_t
dbNameLen
=
strlen
(
pDropDb
->
name
);
SSuperTableObj
*
pTable
=
NULL
;
...
...
@@ -1181,8 +1162,7 @@ void mgmtDropAllSuperTables(SDbObj *pDropDb) {
mPrint
(
"db:%s, all super tables will be dropped from sdb"
,
pDropDb
->
name
);
while
(
1
)
{
pLastNode
=
pNode
;
pNode
=
mgmtGetNextSuperTable
(
pNode
,
&
pTable
);
pIter
=
mgmtGetNextSuperTable
(
pIter
,
&
pTable
);
if
(
pTable
==
NULL
)
break
;
if
(
strncmp
(
pDropDb
->
name
,
pTable
->
info
.
tableId
,
dbNameLen
)
==
0
)
{
...
...
@@ -1192,13 +1172,14 @@ void mgmtDropAllSuperTables(SDbObj *pDropDb) {
.
pObj
=
pTable
,
};
sdbDeleteRow
(
&
oper
);
pNode
=
pLastNode
;
numOfTables
++
;
}
mgmtDecTableRef
(
pTable
);
}
sdbFreeIter
(
pIter
);
mPrint
(
"db:%s, all super tables:%d is dropped from sdb"
,
pDropDb
->
name
,
numOfTables
);
}
...
...
@@ -1753,8 +1734,7 @@ static void mgmtGetChildTableMeta(SQueuedMsg *pMsg) {
}
void
mgmtDropAllChildTables
(
SDbObj
*
pDropDb
)
{
void
*
pNode
=
NULL
;
void
*
pLastNode
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
numOfTables
=
0
;
int32_t
dbNameLen
=
strlen
(
pDropDb
->
name
);
SChildTableObj
*
pTable
=
NULL
;
...
...
@@ -1762,8 +1742,7 @@ void mgmtDropAllChildTables(SDbObj *pDropDb) {
mPrint
(
"db:%s, all child tables will be dropped from sdb"
,
pDropDb
->
name
);
while
(
1
)
{
pLastNode
=
pNode
;
pNode
=
mgmtGetNextChildTable
(
pNode
,
&
pTable
);
pIter
=
mgmtGetNextChildTable
(
pIter
,
&
pTable
);
if
(
pTable
==
NULL
)
break
;
if
(
strncmp
(
pDropDb
->
name
,
pTable
->
info
.
tableId
,
dbNameLen
)
==
0
)
{
...
...
@@ -1773,26 +1752,25 @@ void mgmtDropAllChildTables(SDbObj *pDropDb) {
.
pObj
=
pTable
,
};
sdbDeleteRow
(
&
oper
);
pNode
=
pLastNode
;
numOfTables
++
;
}
mgmtDecTableRef
(
pTable
);
}
sdbFreeIter
(
pIter
);
mPrint
(
"db:%s, all child tables:%d is dropped from sdb"
,
pDropDb
->
name
,
numOfTables
);
}
static
void
mgmtDropAllChildTablesInStable
(
SSuperTableObj
*
pStable
)
{
void
*
pNode
=
NULL
;
void
*
pLastNode
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
numOfTables
=
0
;
SChildTableObj
*
pTable
=
NULL
;
mPrint
(
"stable:%s, all child tables will dropped from sdb"
,
pStable
->
info
.
tableId
,
numOfTables
);
while
(
1
)
{
pLastNode
=
pNode
;
pNode
=
mgmtGetNextChildTable
(
pNode
,
&
pTable
);
pIter
=
mgmtGetNextChildTable
(
pIter
,
&
pTable
);
if
(
pTable
==
NULL
)
break
;
if
(
pTable
->
superTable
==
pStable
)
{
...
...
@@ -1802,13 +1780,14 @@ static void mgmtDropAllChildTablesInStable(SSuperTableObj *pStable) {
.
pObj
=
pTable
,
};
sdbDeleteRow
(
&
oper
);
pNode
=
pLastNode
;
numOfTables
++
;
}
mgmtDecTableRef
(
pTable
);
}
sdbFreeIter
(
pIter
);
mPrint
(
"stable:%s, all child tables:%d is dropped from sdb"
,
pStable
->
info
.
tableId
,
numOfTables
);
}
...
...
@@ -2079,7 +2058,7 @@ static int32_t mgmtRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows,
while
(
numOfRows
<
rows
)
{
mgmtDecTableRef
(
pTable
);
pShow
->
p
Node
=
mgmtGetNextChildTable
(
pShow
->
pNode
,
&
pTable
);
pShow
->
p
Iter
=
mgmtGetNextChildTable
(
pShow
->
pIter
,
&
pTable
);
if
(
pTable
==
NULL
)
break
;
// not belong to current db
...
...
src/mnode/src/mgmtUser.c
浏览文件 @
ff9bdcfd
...
...
@@ -155,8 +155,8 @@ SUserObj *mgmtGetUser(char *name) {
return
(
SUserObj
*
)
sdbGetRow
(
tsUserSdb
,
name
);
}
void
*
mgmtGetNextUser
(
void
*
p
Node
,
SUserObj
**
pUser
)
{
return
sdbFetchRow
(
tsUserSdb
,
p
Node
,
(
void
**
)
pUser
);
void
*
mgmtGetNextUser
(
void
*
p
Iter
,
SUserObj
**
pUser
)
{
return
sdbFetchRow
(
tsUserSdb
,
p
Iter
,
(
void
**
)
pUser
);
}
void
mgmtIncUserRef
(
SUserObj
*
pUser
)
{
...
...
@@ -300,7 +300,7 @@ static int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, void
char
*
pWrite
;
while
(
numOfRows
<
rows
)
{
pShow
->
p
Node
=
mgmtGetNextUser
(
pShow
->
pNode
,
&
pUser
);
pShow
->
p
Iter
=
mgmtGetNextUser
(
pShow
->
pIter
,
&
pUser
);
if
(
pUser
==
NULL
)
break
;
cols
=
0
;
...
...
@@ -504,15 +504,13 @@ static void mgmtProcessDropUserMsg(SQueuedMsg *pMsg) {
}
void
mgmtDropAllUsers
(
SAcctObj
*
pAcct
)
{
void
*
pNode
=
NULL
;
void
*
pLastNode
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
numOfUsers
=
0
;
int32_t
acctNameLen
=
strlen
(
pAcct
->
user
);
SUserObj
*
pUser
=
NULL
;
while
(
1
)
{
pLastNode
=
pNode
;
pNode
=
mgmtGetNextUser
(
pNode
,
&
pUser
);
pIter
=
mgmtGetNextUser
(
pIter
,
&
pUser
);
if
(
pUser
==
NULL
)
break
;
if
(
strncmp
(
pUser
->
acct
,
pAcct
->
user
,
acctNameLen
)
==
0
)
{
...
...
@@ -522,13 +520,14 @@ void mgmtDropAllUsers(SAcctObj *pAcct) {
.
pObj
=
pUser
,
};
sdbDeleteRow
(
&
oper
);
pNode
=
pLastNode
;
numOfUsers
++
;
}
mgmtDecUserRef
(
pUser
);
}
sdbFreeIter
(
pIter
);
mTrace
(
"acct:%s, all users:%d is dropped from sdb"
,
pAcct
->
user
,
numOfUsers
);
}
...
...
src/mnode/src/mgmtVgroup.c
浏览文件 @
ff9bdcfd
...
...
@@ -288,8 +288,8 @@ SVgObj *mgmtGetAvailableVgroup(SDbObj *pDb) {
return
pDb
->
pHead
;
}
void
*
mgmtGetNextVgroup
(
void
*
p
Node
,
SVgObj
**
pVgroup
)
{
return
sdbFetchRow
(
tsVgroupSdb
,
p
Node
,
(
void
**
)
pVgroup
);
void
*
mgmtGetNextVgroup
(
void
*
p
Iter
,
SVgObj
**
pVgroup
)
{
return
sdbFetchRow
(
tsVgroupSdb
,
p
Iter
,
(
void
**
)
pVgroup
);
}
void
mgmtCreateVgroup
(
SQueuedMsg
*
pMsg
,
SDbObj
*
pDb
)
{
...
...
@@ -429,10 +429,10 @@ int32_t mgmtGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
if
(
NULL
==
pTable
)
{
pShow
->
numOfRows
=
pDb
->
numOfVgroups
;
pShow
->
p
Node
=
pDb
->
pHead
;
pShow
->
p
Iter
=
pDb
->
pHead
;
}
else
{
pShow
->
numOfRows
=
1
;
pShow
->
p
Node
=
pVgroup
;
pShow
->
p
Iter
=
pVgroup
;
}
mgmtDecDbRef
(
pDb
);
...
...
@@ -457,9 +457,9 @@ int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pCo
}
while
(
numOfRows
<
rows
)
{
pVgroup
=
(
SVgObj
*
)
pShow
->
p
Node
;
pVgroup
=
(
SVgObj
*
)
pShow
->
p
Iter
;
if
(
pVgroup
==
NULL
)
break
;
pShow
->
p
Node
=
(
void
*
)
pVgroup
->
next
;
pShow
->
p
Iter
=
(
void
*
)
pVgroup
->
next
;
cols
=
0
;
...
...
@@ -749,14 +749,12 @@ static void mgmtProcessVnodeCfgMsg(SRpcMsg *rpcMsg) {
}
void
mgmtDropAllDnodeVgroups
(
SDnodeObj
*
pDropDnode
)
{
void
*
pNode
=
NULL
;
void
*
pLastNode
=
NULL
;
void
*
pIter
=
NULL
;
SVgObj
*
pVgroup
=
NULL
;
int32_t
numOfVgroups
=
0
;
while
(
1
)
{
pLastNode
=
pNode
;
pNode
=
mgmtGetNextVgroup
(
pNode
,
&
pVgroup
);
pIter
=
mgmtGetNextVgroup
(
pIter
,
&
pVgroup
);
if
(
pVgroup
==
NULL
)
break
;
if
(
pVgroup
->
vnodeGid
[
0
].
dnodeId
==
pDropDnode
->
dnodeId
)
{
...
...
@@ -766,24 +764,23 @@ void mgmtDropAllDnodeVgroups(SDnodeObj *pDropDnode) {
.
pObj
=
pVgroup
,
};
sdbDeleteRow
(
&
oper
);
pNode
=
pLastNode
;
numOfVgroups
++
;
continue
;
}
mgmtDecVgroupRef
(
pVgroup
);
}
sdbFreeIter
(
pIter
);
}
void
mgmtDropAllDbVgroups
(
SDbObj
*
pDropDb
,
bool
sendMsg
)
{
void
*
pNode
=
NULL
;
void
*
pLastNode
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
numOfVgroups
=
0
;
SVgObj
*
pVgroup
=
NULL
;
mPrint
(
"db:%s, all vgroups will be dropped from sdb"
,
pDropDb
->
name
);
while
(
1
)
{
pLastNode
=
pNode
;
pNode
=
mgmtGetNextVgroup
(
pNode
,
&
pVgroup
);
pIter
=
mgmtGetNextVgroup
(
pIter
,
&
pVgroup
);
if
(
pVgroup
==
NULL
)
break
;
if
(
pVgroup
->
pDb
==
pDropDb
)
{
...
...
@@ -793,7 +790,6 @@ void mgmtDropAllDbVgroups(SDbObj *pDropDb, bool sendMsg) {
.
pObj
=
pVgroup
,
};
sdbDeleteRow
(
&
oper
);
pNode
=
pLastNode
;
numOfVgroups
++
;
if
(
sendMsg
)
{
...
...
@@ -804,5 +800,7 @@ void mgmtDropAllDbVgroups(SDbObj *pDropDb, bool sendMsg) {
mgmtDecVgroupRef
(
pVgroup
);
}
sdbFreeIter
(
pIter
);
mPrint
(
"db:%s, all vgroups:%d is dropped from sdb"
,
pDropDb
->
name
,
numOfVgroups
);
}
src/util/inc/tcache.h
浏览文件 @
ff9bdcfd
...
...
@@ -67,6 +67,7 @@ typedef struct {
void
*
pTimer
;
SCacheStatis
statistics
;
SHashObj
*
pHashTable
;
_hash_free_fn_t
freeFp
;
int
numOfElemsInTrash
;
// number of element in trash
int16_t
deleting
;
// set the deleting flag to stop refreshing ASAP.
T_REF_DECLARE
()
...
...
@@ -88,6 +89,7 @@ typedef struct {
* @return
*/
SCacheObj
*
taosCacheInit
(
void
*
tmrCtrl
,
int64_t
refreshTimeInSeconds
);
SCacheObj
*
taosCacheInitWithCb
(
void
*
tmrCtrl
,
int64_t
refreshTimeInSeconds
,
void
(
*
freeCb
)(
void
*
data
));
/**
* add data into cache
...
...
src/util/src/tcache.c
浏览文件 @
ff9bdcfd
...
...
@@ -149,6 +149,7 @@ static void taosRemoveFromTrash(SCacheObj *pCacheObj, STrashElem *pElem) {
}
pElem
->
pData
->
signature
=
0
;
if
(
pCacheObj
->
freeFp
)
pCacheObj
->
freeFp
(
pElem
->
pData
->
data
);
free
(
pElem
->
pData
);
free
(
pElem
);
}
...
...
@@ -210,7 +211,8 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo
int32_t
size
=
pNode
->
size
;
taosHashRemove
(
pCacheObj
->
pHashTable
,
pNode
->
key
,
pNode
->
keySize
);
uTrace
(
"key:%s is removed from cache,total:%d,size:%ldbytes"
,
pNode
->
key
,
pCacheObj
->
totalSize
,
size
);
uTrace
(
"key:%s is removed from cache,total:%d,size:%ldbytes"
,
pNode
->
key
,
pCacheObj
->
totalSize
,
size
);
if
(
pCacheObj
->
freeFp
)
pCacheObj
->
freeFp
(
pNode
->
data
);
free
(
pNode
);
}
...
...
@@ -380,7 +382,7 @@ static void taosCacheRefresh(void *handle, void *tmrId) {
}
}
SCacheObj
*
taosCacheInit
(
void
*
tmrCtrl
,
int64_t
refreshTime
)
{
SCacheObj
*
taosCacheInit
WithCb
(
void
*
tmrCtrl
,
int64_t
refreshTime
,
void
(
*
freeCb
)(
void
*
data
)
)
{
if
(
tmrCtrl
==
NULL
||
refreshTime
<=
0
)
{
return
NULL
;
}
...
...
@@ -399,8 +401,9 @@ SCacheObj *taosCacheInit(void *tmrCtrl, int64_t refreshTime) {
}
// set free cache node callback function for hash table
taosHashSetFreecb
(
pCacheObj
->
pHashTable
,
taosFreeNode
);
//
taosHashSetFreecb(pCacheObj->pHashTable, taosFreeNode);
pCacheObj
->
freeFp
=
freeCb
;
pCacheObj
->
refreshTime
=
refreshTime
*
1000
;
pCacheObj
->
tmrCtrl
=
tmrCtrl
;
...
...
@@ -419,6 +422,10 @@ SCacheObj *taosCacheInit(void *tmrCtrl, int64_t refreshTime) {
return
pCacheObj
;
}
SCacheObj
*
taosCacheInit
(
void
*
tmrCtrl
,
int64_t
refreshTime
)
{
return
taosCacheInitWithCb
(
tmrCtrl
,
refreshTime
,
NULL
);
}
void
*
taosCachePut
(
SCacheObj
*
pCacheObj
,
const
char
*
key
,
const
void
*
pData
,
size_t
dataSize
,
int
duration
)
{
SCacheDataNode
*
pNode
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录