Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
d099ab73
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看板
提交
d099ab73
编写于
4月 21, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove un necessary vload
上级
8e444435
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
194 addition
and
205 deletion
+194
-205
src/mnode/inc/mgmtDef.h
src/mnode/inc/mgmtDef.h
+25
-23
src/mnode/inc/mgmtDnode.h
src/mnode/inc/mgmtDnode.h
+2
-1
src/mnode/inc/mgmtUser.h
src/mnode/inc/mgmtUser.h
+2
-1
src/mnode/inc/mgmtVgroup.h
src/mnode/inc/mgmtVgroup.h
+3
-2
src/mnode/src/mgmtBalance.c
src/mnode/src/mgmtBalance.c
+2
-3
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+2
-2
src/mnode/src/mgmtDnode.c
src/mnode/src/mgmtDnode.c
+57
-67
src/mnode/src/mgmtMnode.c
src/mnode/src/mgmtMnode.c
+3
-3
src/mnode/src/mgmtProfile.c
src/mnode/src/mgmtProfile.c
+3
-3
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+2
-2
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+7
-9
src/mnode/src/mgmtUser.c
src/mnode/src/mgmtUser.c
+13
-9
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+50
-57
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+23
-23
未找到文件。
src/mnode/inc/mgmtDef.h
浏览文件 @
d099ab73
...
...
@@ -51,7 +51,6 @@ typedef struct SDnodeObj {
int8_t
reserved
[
15
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
SVnodeLoad
vload
[
TSDB_MAX_VNODES
];
uint32_t
moduleStatus
;
uint32_t
lastReboot
;
// time stamp for last reboot
float
score
;
// calc in balance function
...
...
@@ -72,13 +71,6 @@ typedef struct SMnodeObj {
SDnodeObj
*
pDnode
;
}
SMnodeObj
;
typedef
struct
{
int32_t
dnodeId
;
uint32_t
privateIp
;
uint32_t
publicIp
;
}
SVnodeGid
;
typedef
struct
{
char
tableId
[
TSDB_TABLE_ID_LEN
+
1
];
int8_t
type
;
...
...
@@ -120,24 +112,34 @@ typedef struct {
SSuperTableObj
*
superTable
;
}
SChildTableObj
;
typedef
struct
{
int32_t
dnodeId
;
int8_t
role
;
int8_t
reserved
[
3
];
SDnodeObj
*
pDnode
;
}
SVnodeGid
;
typedef
struct
SVgObj
{
uint32_t
vgId
;
char
dbName
[
TSDB_DB_NAME_LEN
+
1
];
int64_t
createdTime
;
SVnodeGid
vnodeGid
[
TSDB_VNODES_SUPPORT
];
int32_t
numOfVnodes
;
int32_t
lbDnodeId
;
int32_t
lbTime
;
int8_t
status
;
int8_t
inUse
;
int8_t
reserved
[
13
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
uint32_t
vgId
;
char
dbName
[
TSDB_DB_NAME_LEN
+
1
];
int64_t
createdTime
;
SVnodeGid
vnodeGid
[
TSDB_VNODES_SUPPORT
];
int32_t
numOfVnodes
;
int32_t
lbDnodeId
;
int32_t
lbTime
;
int8_t
status
;
int8_t
inUse
;
int8_t
reserved
[
13
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
struct
SVgObj
*
prev
,
*
next
;
struct
SDbObj
*
pDb
;
int32_t
numOfTables
;
void
*
idPool
;
SChildTableObj
**
tableList
;
int32_t
numOfTables
;
int64_t
totalStorage
;
int64_t
compStorage
;
int64_t
pointsWritten
;
void
*
idPool
;
SChildTableObj
**
tableList
;
}
SVgObj
;
typedef
struct
SDbObj
{
...
...
src/mnode/inc/mgmtDnode.h
浏览文件 @
d099ab73
...
...
@@ -35,7 +35,8 @@ void mgmtMonitorDnodeModule();
int32_t
mgmtGetDnodesNum
();
void
*
mgmtGetNextDnode
(
void
*
pNode
,
SDnodeObj
**
pDnode
);
void
mgmtReleaseDnode
(
SDnodeObj
*
pDnode
);
void
mgmtIncDnodeRef
(
SDnodeObj
*
pDnode
);
void
mgmtDecDnodeRef
(
SDnodeObj
*
pDnode
);
void
*
mgmtGetDnode
(
int32_t
dnodeId
);
void
*
mgmtGetDnodeByIp
(
uint32_t
ip
);
void
mgmtUpdateDnode
(
SDnodeObj
*
pDnode
);
...
...
src/mnode/inc/mgmtUser.h
浏览文件 @
d099ab73
...
...
@@ -24,7 +24,8 @@ extern "C" {
int32_t
mgmtInitUsers
();
void
mgmtCleanUpUsers
();
SUserObj
*
mgmtGetUser
(
char
*
name
);
void
mgmtReleaseUser
(
SUserObj
*
pUser
);
void
mgmtIncUserRef
(
SUserObj
*
pUser
);
void
mgmtDecUserRef
(
SUserObj
*
pUser
);
SUserObj
*
mgmtGetUserFromConn
(
void
*
pConn
,
bool
*
usePublicIp
);
int32_t
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
);
void
mgmtDropAllUsers
(
SAcctObj
*
pAcct
);
...
...
src/mnode/inc/mgmtVgroup.h
浏览文件 @
d099ab73
...
...
@@ -30,12 +30,13 @@ enum _TSDB_VG_STATUS {
int32_t
mgmtInitVgroups
();
void
mgmtCleanUpVgroups
();
SVgObj
*
mgmtGetVgroup
(
int32_t
vgId
);
void
mgmtReleaseVgroup
(
SVgObj
*
pVgroup
);
void
mgmtIncVgroupRef
(
SVgObj
*
pVgroup
);
void
mgmtDecVgroupRef
(
SVgObj
*
pVgroup
);
void
mgmtDropAllVgroups
(
SDbObj
*
pDropDb
);
void
*
mgmtGetNextVgroup
(
void
*
pNode
,
SVgObj
**
pVgroup
);
void
mgmtUpdateVgroup
(
SVgObj
*
pVgroup
);
void
mgmtUpdateVgroupStatus
(
SVgObj
*
pVgroup
,
int32_t
dnodeId
,
SVnodeLoad
*
pVload
);
void
mgmtUpdateVgroupStatus
(
SVgObj
*
pVgroup
,
SDnodeObj
*
dnodeId
,
SVnodeLoad
*
pVload
);
void
mgmtCreateVgroup
(
SQueuedMsg
*
pMsg
,
SDbObj
*
pDb
);
void
mgmtDropVgroup
(
SVgObj
*
pVgroup
,
void
*
ahandle
);
...
...
src/mnode/src/mgmtBalance.c
浏览文件 @
d099ab73
...
...
@@ -47,7 +47,7 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) {
vnodeUsage
=
usage
;
}
}
mgmt
ReleaseDnode
(
pDnode
);
mgmt
DecDnodeRef
(
pDnode
);
}
if
(
pSelDnode
==
NULL
)
{
...
...
@@ -56,8 +56,7 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) {
}
pVgroup
->
vnodeGid
[
0
].
dnodeId
=
pSelDnode
->
dnodeId
;
pVgroup
->
vnodeGid
[
0
].
privateIp
=
pSelDnode
->
privateIp
;
pVgroup
->
vnodeGid
[
0
].
publicIp
=
pSelDnode
->
publicIp
;
pVgroup
->
vnodeGid
[
0
].
pDnode
=
pSelDnode
;
mTrace
(
"dnode:%d, alloc one vnode to vgroup, openVnodes:%d"
,
pSelDnode
->
dnodeId
,
pSelDnode
->
openVnodes
);
return
TSDB_CODE_SUCCESS
;
...
...
src/mnode/src/mgmtDb.c
浏览文件 @
d099ab73
...
...
@@ -527,7 +527,7 @@ static int32_t mgmtGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn)
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
numOfRows
=
pUser
->
pAcct
->
acctInfo
.
numOfDbs
;
mgmt
ReleaseUser
(
pUser
);
mgmt
DecUserRef
(
pUser
);
return
0
;
}
...
...
@@ -647,7 +647,7 @@ static int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *
}
pShow
->
numOfReads
+=
numOfRows
;
mgmt
ReleaseUser
(
pUser
);
mgmt
DecUserRef
(
pUser
);
return
numOfRows
;
}
...
...
src/mnode/src/mgmtDnode.c
浏览文件 @
d099ab73
...
...
@@ -23,6 +23,7 @@
#include "tutil.h"
#include "tsocket.h"
#include "tbalance.h"
#include "tsync.h"
#include "dnode.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
...
...
@@ -139,7 +140,7 @@ static int32_t mgmtDnodeActionRestored() {
mgmtCreateDnode
(
ip
);
SDnodeObj
*
pDnode
=
mgmtGetDnodeByIp
(
ip
);
mgmtAddMnode
(
pDnode
->
dnodeId
);
mgmt
ReleaseDnode
(
pDnode
);
mgmt
DecDnodeRef
(
pDnode
);
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -215,13 +216,17 @@ void *mgmtGetDnodeByIp(uint32_t ip) {
if
(
ip
==
pDnode
->
privateIp
)
{
return
pDnode
;
}
mgmt
ReleaseDnode
(
pDnode
);
mgmt
DecDnodeRef
(
pDnode
);
}
return
NULL
;
}
void
mgmtReleaseDnode
(
SDnodeObj
*
pDnode
)
{
void
mgmtIncDnodeRef
(
SDnodeObj
*
pDnode
)
{
sdbIncRef
(
tsDnodeSdb
,
pDnode
);
}
void
mgmtDecDnodeRef
(
SDnodeObj
*
pDnode
)
{
sdbDecRef
(
tsDnodeSdb
,
pDnode
);
}
...
...
@@ -326,19 +331,21 @@ void mgmtProcessDnodeStatusMsg(SRpcMsg *rpcMsg) {
int32_t
openVnodes
=
htons
(
pStatus
->
openVnodes
);
for
(
int32_t
j
=
0
;
j
<
openVnodes
;
++
j
)
{
SVnodeLoad
*
pVload
=
&
pStatus
->
load
[
j
];
pDnode
->
vload
[
j
].
vgId
=
htonl
(
pVload
->
vgId
);
pDnode
->
vload
[
j
].
totalStorage
=
htobe64
(
pVload
->
totalStorage
);
pDnode
->
vload
[
j
].
compStorage
=
htobe64
(
pVload
->
compStorage
);
pDnode
->
vload
[
j
].
pointsWritten
=
htobe64
(
pVload
->
pointsWritten
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pDnode
->
vload
[
j
].
vgId
);
pVload
->
vgId
=
htonl
(
pVload
->
vgId
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pVload
->
vgId
);
if
(
pVgroup
==
NULL
)
{
SRpcIpSet
ipSet
=
mgmtGetIpSetFromIp
(
pDnode
->
privateIp
);
mPrint
(
"dnode:%d, vgroup:%d not exist in mnode, drop it"
,
pDnode
->
dnodeId
,
p
Dnode
->
vload
[
j
].
vgId
);
mgmtSendDropVnodeMsg
(
p
Dnode
->
vload
[
j
].
vgId
,
&
ipSet
,
NULL
);
mPrint
(
"dnode:%d, vgroup:%d not exist in mnode, drop it"
,
pDnode
->
dnodeId
,
p
Vload
->
vgId
);
mgmtSendDropVnodeMsg
(
p
Vload
->
vgId
,
&
ipSet
,
NULL
);
}
else
{
mgmtUpdateVgroupStatus
(
pVgroup
,
pDnode
->
dnodeId
,
pVload
);
mgmtReleaseVgroup
(
pVgroup
);
mgmtUpdateVgroupStatus
(
pVgroup
,
pDnode
,
pVload
);
if
(
pVload
->
role
==
TAOS_SYNC_ROLE_MASTER
)
{
pVgroup
->
totalStorage
=
htobe64
(
pVload
->
totalStorage
);
pVgroup
->
compStorage
=
htobe64
(
pVload
->
compStorage
);
pVgroup
->
pointsWritten
=
htobe64
(
pVload
->
pointsWritten
);
}
mgmtDecVgroupRef
(
pVgroup
);
}
}
...
...
@@ -348,7 +355,7 @@ void mgmtProcessDnodeStatusMsg(SRpcMsg *rpcMsg) {
balanceNotify
();
}
mgmt
ReleaseDnode
(
pDnode
);
mgmt
DecDnodeRef
(
pDnode
);
int32_t
contLen
=
sizeof
(
SDMStatusRsp
)
+
TSDB_MAX_VNODES
*
sizeof
(
SDMVgroupAccess
);
SDMStatusRsp
*
pRsp
=
rpcMallocCont
(
contLen
);
...
...
@@ -554,7 +561,7 @@ static int32_t mgmtGetDnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pCo
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
pNode
=
NULL
;
mgmt
ReleaseUser
(
pUser
);
mgmt
DecUserRef
(
pUser
);
return
0
;
}
...
...
@@ -604,7 +611,7 @@ static int32_t mgmtRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, voi
numOfRows
++
;
mgmt
ReleaseDnode
(
pDnode
);
mgmt
DecDnodeRef
(
pDnode
);
}
pShow
->
numOfReads
+=
numOfRows
;
...
...
@@ -661,7 +668,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
->
pNode
=
NULL
;
mgmt
ReleaseUser
(
pUser
);
mgmt
DecUserRef
(
pUser
);
return
0
;
}
...
...
@@ -712,7 +719,7 @@ int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pCo
numOfRows
++
;
}
mgmt
ReleaseDnode
(
pDnode
);
mgmt
DecDnodeRef
(
pDnode
);
}
pShow
->
numOfReads
+=
numOfRows
;
...
...
@@ -762,7 +769,7 @@ static int32_t mgmtGetConfigMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
pNode
=
NULL
;
mgmt
ReleaseUser
(
pUser
);
mgmt
DecUserRef
(
pUser
);
return
0
;
}
...
...
@@ -840,35 +847,18 @@ static int32_t mgmtGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pCo
if
(
pShow
->
payloadLen
>
0
)
{
uint32_t
ip
=
ip2uint
(
pShow
->
payload
);
pDnode
=
mgmtGetDnodeByIp
(
ip
);
if
(
NULL
==
pDnode
)
{
return
TSDB_CODE_NODE_OFFLINE
;
}
SVnodeLoad
*
pVnode
;
pShow
->
numOfRows
=
0
;
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_VNODES
;
i
++
)
{
pVnode
=
&
pDnode
->
vload
[
i
];
if
(
0
!=
pVnode
->
vgId
)
{
pShow
->
numOfRows
++
;
}
}
pShow
->
pNode
=
pDnode
;
}
else
{
while
(
true
)
{
pShow
->
pNode
=
mgmtGetNextDnode
(
pShow
->
pNode
,
(
SDnodeObj
**
)
&
pDnode
);
if
(
pDnode
==
NULL
)
break
;
pShow
->
numOfRows
+=
pDnode
->
openVnodes
;
if
(
0
==
pShow
->
numOfRows
)
return
TSDB_CODE_NODE_OFFLINE
;
}
mgmtGetNextDnode
(
NULL
,
(
SDnodeObj
**
)
&
pDnode
);
}
pShow
->
pNode
=
NULL
;
}
if
(
pDnode
!=
NULL
)
{
pShow
->
numOfRows
+=
pDnode
->
openVnodes
;
mgmtDecDnodeRef
(
pDnode
);
}
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
mgmtReleaseDnode
(
pDnode
)
;
mgmt
ReleaseUser
(
pUser
);
pShow
->
pNode
=
pDnode
;
mgmt
DecUserRef
(
pUser
);
return
0
;
}
...
...
@@ -881,35 +871,35 @@ static int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, voi
if
(
0
==
rows
)
return
0
;
if
(
pShow
->
payloadLen
)
{
// output the vnodes info of the designated dnode. And output all vnodes of this dnode, instead of rows (max 100)
pDnode
=
(
SDnodeObj
*
)(
pShow
->
pNode
);
if
(
pDnode
!=
NULL
)
{
SVnodeLoad
*
pVnode
;
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_VNODES
;
i
++
)
{
pVnode
=
&
pDnode
->
vload
[
i
];
if
(
0
==
pVnode
->
vgId
)
{
continue
;
pDnode
=
(
SDnodeObj
*
)(
pShow
->
pNode
);
if
(
pDnode
!=
NULL
)
{
void
*
pNode
=
NULL
;
SVgObj
*
pVgroup
;
while
(
1
)
{
pNode
=
mgmtGetNextVgroup
(
pNode
,
&
pVgroup
);
if
(
pVgroup
==
NULL
)
break
;
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
i
];
if
(
pVgid
->
pDnode
==
pDnode
)
{
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
uint32_t
*
)
pWrite
=
pVgroup
->
vgId
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
mgmtGetMnodeRoleStr
(
pVgid
->
role
));
cols
++
;
}
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
uint32_t
*
)
pWrite
=
pVnode
->
vgId
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
pVnode
->
status
?
"ready"
:
"offline"
);
cols
++
;
numOfRows
++
;
}
mgmtDecVgroupRef
(
pVgroup
);
}
}
else
{
// TODO: output all vnodes of all dnodes
numOfRows
=
0
;
}
pShow
->
numOfReads
+=
numOfRows
;
return
numOfRows
;
}
...
...
src/mnode/src/mgmtMnode.c
浏览文件 @
d099ab73
...
...
@@ -47,7 +47,7 @@ static int32_t mgmtMnodeActionInsert(SSdbOper *pOper) {
pMnode
->
pDnode
=
pDnode
;
pDnode
->
isMgmt
=
true
;
mgmt
ReleaseDnode
(
pDnode
);
mgmt
DecDnodeRef
(
pDnode
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -58,7 +58,7 @@ static int32_t mgmtMnodeActionDelete(SSdbOper *pOper) {
SDnodeObj
*
pDnode
=
mgmtGetDnode
(
pMnode
->
mnodeId
);
if
(
pDnode
==
NULL
)
return
TSDB_CODE_DNODE_NOT_EXIST
;
pDnode
->
isMgmt
=
false
;
mgmt
ReleaseDnode
(
pDnode
);
mgmt
DecDnodeRef
(
pDnode
);
mTrace
(
"mnode:%d, is dropped from sdb"
,
pMnode
->
mnodeId
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -314,7 +314,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
->
pNode
=
NULL
;
mgmt
ReleaseUser
(
pUser
);
mgmt
DecUserRef
(
pUser
);
return
0
;
}
...
...
src/mnode/src/mgmtProfile.c
浏览文件 @
d099ab73
...
...
@@ -790,12 +790,12 @@ void *mgmtMallocQueuedMsg(SRpcMsg *rpcMsg) {
void
mgmtFreeQueuedMsg
(
SQueuedMsg
*
pMsg
)
{
if
(
pMsg
!=
NULL
)
{
rpcFreeCont
(
pMsg
->
pCont
);
if
(
pMsg
->
pUser
)
mgmt
ReleaseUser
(
pMsg
->
pUser
);
if
(
pMsg
->
pUser
)
mgmt
DecUserRef
(
pMsg
->
pUser
);
if
(
pMsg
->
pDb
)
mgmtDecDbRef
(
pMsg
->
pDb
);
if
(
pMsg
->
pVgroup
)
mgmt
ReleaseVgroup
(
pMsg
->
pVgroup
);
if
(
pMsg
->
pVgroup
)
mgmt
DecVgroupRef
(
pMsg
->
pVgroup
);
if
(
pMsg
->
pTable
)
mgmtDecTableRef
(
pMsg
->
pTable
);
if
(
pMsg
->
pAcct
)
mgmtDecAcctRef
(
pMsg
->
pAcct
);
if
(
pMsg
->
pDnode
)
mgmt
ReleaseDnode
(
pMsg
->
pDnode
);
if
(
pMsg
->
pDnode
)
mgmt
DecDnodeRef
(
pMsg
->
pDnode
);
free
(
pMsg
);
}
}
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
d099ab73
...
...
@@ -371,11 +371,11 @@ static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secr
SUserObj
*
pUser
=
mgmtGetUser
(
user
);
if
(
pUser
==
NULL
)
{
*
secret
=
0
;
mgmt
ReleaseUser
(
pUser
);
mgmt
DecUserRef
(
pUser
);
return
TSDB_CODE_INVALID_USER
;
}
else
{
memcpy
(
secret
,
pUser
->
pass
,
TSDB_KEY_LEN
);
mgmt
ReleaseUser
(
pUser
);
mgmt
DecUserRef
(
pUser
);
return
TSDB_CODE_SUCCESS
;
}
}
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
d099ab73
...
...
@@ -97,7 +97,7 @@ static int32_t mgmtChildTableActionInsert(SSdbOper *pOper) {
mError
(
"ctable:%s, not in vgroup:%d"
,
pTable
->
info
.
tableId
,
pTable
->
vgId
);
return
TSDB_CODE_INVALID_VGROUP_ID
;
}
mgmt
ReleaseVgroup
(
pVgroup
);
mgmt
DecVgroupRef
(
pVgroup
);
SDbObj
*
pDb
=
mgmtGetDb
(
pVgroup
->
dbName
);
if
(
pDb
==
NULL
)
{
...
...
@@ -139,7 +139,7 @@ static int32_t mgmtChildTableActionDelete(SSdbOper *pOper) {
if
(
pVgroup
==
NULL
)
{
return
TSDB_CODE_INVALID_VGROUP_ID
;
}
mgmt
ReleaseVgroup
(
pVgroup
);
mgmt
DecVgroupRef
(
pVgroup
);
SDbObj
*
pDb
=
mgmtGetDb
(
pVgroup
->
dbName
);
if
(
pDb
==
NULL
)
{
...
...
@@ -275,7 +275,7 @@ static int32_t mgmtChildTableActionRestored() {
pNode
=
pLastNode
;
continue
;
}
mgmt
ReleaseVgroup
(
pVgroup
);
mgmt
DecVgroupRef
(
pVgroup
);
if
(
strcmp
(
pVgroup
->
dbName
,
pDb
->
name
)
!=
0
)
{
mError
(
"ctable:%s, db:%s not match with vgroup:%d db:%s sid:%d, discard it"
,
...
...
@@ -1194,17 +1194,15 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) {
pRsp
->
vgroups
[
vg
].
vgId
=
htonl
(
vgId
);
for
(
int32_t
vn
=
0
;
vn
<
pVgroup
->
numOfVnodes
;
++
vn
)
{
SDnodeObj
*
pDnode
=
mgmtGetDnode
(
pVgroup
->
vnodeGid
[
vn
].
dnodeId
)
;
SDnodeObj
*
pDnode
=
pVgroup
->
vnodeGid
[
vn
].
pDnode
;
if
(
pDnode
==
NULL
)
break
;
pRsp
->
vgroups
[
vg
].
ipAddr
[
vn
].
ip
=
htonl
(
pDnode
->
privateIp
);
pRsp
->
vgroups
[
vg
].
ipAddr
[
vn
].
port
=
htons
(
tsDnodeShellPort
);
pRsp
->
vgroups
[
vg
].
numOfIps
++
;
mgmtReleaseDnode
(
pDnode
);
}
mgmt
ReleaseVgroup
(
pVgroup
);
mgmt
DecVgroupRef
(
pVgroup
);
}
pRsp
->
numOfVgroups
=
htonl
(
vg
);
...
...
@@ -1613,7 +1611,7 @@ static int32_t mgmtDoGetChildTableMeta(SQueuedMsg *pMsg, STableMetaMsg *pMeta) {
pMeta
->
vgroup
.
ipAddr
[
i
].
port
=
htonl
(
tsDnodeShellPort
);
}
pMeta
->
vgroup
.
numOfIps
++
;
mgmt
ReleaseDnode
(
pDnode
);
mgmt
DecDnodeRef
(
pDnode
);
}
pMeta
->
vgroup
.
vgId
=
htonl
(
pVgroup
->
vgId
);
...
...
@@ -1742,7 +1740,7 @@ static SChildTableObj* mgmtGetTableByPos(uint32_t dnodeId, int32_t vnode, int32_
SChildTableObj
*
pTable
=
pVgroup
->
tableList
[
sid
];
mgmtIncTableRef
((
STableObj
*
)
pTable
);
mgmt
ReleaseVgroup
(
pVgroup
);
mgmt
DecVgroupRef
(
pVgroup
);
return
pTable
;
}
...
...
src/mnode/src/mgmtUser.c
浏览文件 @
d099ab73
...
...
@@ -150,7 +150,11 @@ SUserObj *mgmtGetUser(char *name) {
return
(
SUserObj
*
)
sdbGetRow
(
tsUserSdb
,
name
);
}
void
mgmtReleaseUser
(
SUserObj
*
pUser
)
{
void
mgmtIncUserRef
(
SUserObj
*
pUser
)
{
return
sdbIncRef
(
tsUserSdb
,
pUser
);
}
void
mgmtDecUserRef
(
SUserObj
*
pUser
)
{
return
sdbDecRef
(
tsUserSdb
,
pUser
);
}
...
...
@@ -183,7 +187,7 @@ int32_t mgmtCreateUser(SAcctObj *pAcct, char *name, char *pass) {
SUserObj
*
pUser
=
mgmtGetUser
(
name
);
if
(
pUser
!=
NULL
)
{
mTrace
(
"user:%s is already there"
,
name
);
mgmt
ReleaseUser
(
pUser
);
mgmt
DecUserRef
(
pUser
);
return
TSDB_CODE_USER_ALREADY_EXIST
;
}
...
...
@@ -273,7 +277,7 @@ static int32_t mgmtGetUserMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pCon
pShow
->
numOfRows
=
pUser
->
pAcct
->
acctInfo
.
numOfUsers
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
mgmt
ReleaseUser
(
pUser
);
mgmt
DecUserRef
(
pUser
);
return
0
;
}
...
...
@@ -308,7 +312,7 @@ static int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, void
cols
++
;
numOfRows
++
;
mgmt
ReleaseUser
(
pUser
);
mgmt
DecUserRef
(
pUser
);
}
pShow
->
numOfReads
+=
numOfRows
;
return
numOfRows
;
...
...
@@ -356,7 +360,7 @@ static void mgmtProcessAlterUserMsg(SQueuedMsg *pMsg) {
if
(
strcmp
(
pUser
->
user
,
"monitor"
)
==
0
||
(
strcmp
(
pUser
->
user
+
1
,
pUser
->
acct
)
==
0
&&
pUser
->
user
[
0
]
==
'_'
))
{
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_NO_RIGHTS
);
mgmt
ReleaseUser
(
pUser
);
mgmt
DecUserRef
(
pUser
);
return
;
}
...
...
@@ -432,7 +436,7 @@ static void mgmtProcessAlterUserMsg(SQueuedMsg *pMsg) {
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_NO_RIGHTS
);
}
mgmt
ReleaseUser
(
pUser
);
mgmt
DecUserRef
(
pUser
);
}
static
void
mgmtProcessDropUserMsg
(
SQueuedMsg
*
pMsg
)
{
...
...
@@ -449,7 +453,7 @@ static void mgmtProcessDropUserMsg(SQueuedMsg *pMsg) {
if
(
strcmp
(
pUser
->
user
,
"monitor"
)
==
0
||
strcmp
(
pUser
->
user
,
pUser
->
acct
)
==
0
||
(
strcmp
(
pUser
->
user
+
1
,
pUser
->
acct
)
==
0
&&
pUser
->
user
[
0
]
==
'_'
))
{
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_NO_RIGHTS
);
mgmt
ReleaseUser
(
pUser
);
mgmt
DecUserRef
(
pUser
);
return
;
}
...
...
@@ -478,7 +482,7 @@ static void mgmtProcessDropUserMsg(SQueuedMsg *pMsg) {
}
mgmtSendSimpleResp
(
pMsg
->
thandle
,
code
);
mgmt
ReleaseUser
(
pUser
);
mgmt
DecUserRef
(
pUser
);
}
void
mgmtDropAllUsers
(
SAcctObj
*
pAcct
)
{
...
...
@@ -504,7 +508,7 @@ void mgmtDropAllUsers(SAcctObj *pAcct) {
numOfUsers
++
;
}
mgmt
ReleaseUser
(
pUser
);
mgmt
DecUserRef
(
pUser
);
}
mTrace
(
"acct:%s, all users:%d is dropped from sdb"
,
pAcct
->
user
,
numOfUsers
);
...
...
src/mnode/src/mgmtVgroup.c
浏览文件 @
d099ab73
...
...
@@ -68,7 +68,6 @@ static int32_t mgmtVgroupActionInsert(SSdbOper *pOper) {
if
(
pDb
==
NULL
)
{
return
TSDB_CODE_INVALID_DB
;
}
mgmtDecDbRef
(
pDb
);
pVgroup
->
pDb
=
pDb
;
pVgroup
->
prev
=
NULL
;
...
...
@@ -91,15 +90,13 @@ static int32_t mgmtVgroupActionInsert(SSdbOper *pOper) {
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SDnodeObj
*
pDnode
=
mgmtGetDnode
(
pVgroup
->
vnodeGid
[
i
].
dnodeId
);
if
(
pDnode
!=
NULL
)
{
pVgroup
->
vnodeGid
[
i
].
privateIp
=
pDnode
->
privateIp
;
pVgroup
->
vnodeGid
[
i
].
publicIp
=
pDnode
->
publicIp
;
atomic_add_fetch_32
(
&
pDnode
->
openVnodes
,
1
);
mgmtReleaseDnode
(
pDnode
);
}
pVgroup
->
vnodeGid
[
i
].
pDnode
=
pDnode
;
atomic_add_fetch_32
(
&
pDnode
->
openVnodes
,
1
);
mgmtDecDnodeRef
(
pDnode
);
}
}
mgmtAddVgroupIntoDb
(
pVgroup
);
mgmtIncDbRef
(
pVgroup
->
pDb
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -115,10 +112,10 @@ static int32_t mgmtVgroupActionDelete(SSdbOper *pOper) {
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SDnodeObj
*
pDnode
=
mgmtGetDnode
(
pVgroup
->
vnodeGid
[
i
].
dnodeId
);
if
(
pDnode
)
{
if
(
pDnode
!=
NULL
)
{
atomic_sub_fetch_32
(
&
pDnode
->
openVnodes
,
1
);
}
mgmt
ReleaseDnode
(
pDnode
);
mgmt
DecDnodeRef
(
pDnode
);
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -150,6 +147,12 @@ static int32_t mgmtVgroupActionUpdate(SSdbOper *pOper) {
static
int32_t
mgmtVgroupActionEncode
(
SSdbOper
*
pOper
)
{
SVgObj
*
pVgroup
=
pOper
->
pObj
;
memcpy
(
pOper
->
rowData
,
pVgroup
,
tsVgUpdateSize
);
SVgObj
*
pTmpVgroup
=
pOper
->
rowData
;
for
(
int32_t
i
=
0
;
i
<
TSDB_VNODES_SUPPORT
;
++
i
)
{
pTmpVgroup
->
vnodeGid
[
i
].
pDnode
=
NULL
;
pTmpVgroup
->
vnodeGid
[
i
].
role
=
0
;
}
pOper
->
rowSize
=
tsVgUpdateSize
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -204,7 +207,11 @@ int32_t mgmtInitVgroups() {
return
0
;
}
void
mgmtReleaseVgroup
(
SVgObj
*
pVgroup
)
{
void
mgmtIncVgroupRef
(
SVgObj
*
pVgroup
)
{
return
sdbIncRef
(
tsVgroupSdb
,
pVgroup
);
}
void
mgmtDecVgroupRef
(
SVgObj
*
pVgroup
)
{
return
sdbDecRef
(
tsVgroupSdb
,
pVgroup
);
}
...
...
@@ -224,14 +231,15 @@ void mgmtUpdateVgroup(SVgObj *pVgroup) {
mgmtSendCreateVgroupMsg
(
pVgroup
,
NULL
);
}
void
mgmtUpdateVgroupStatus
(
SVgObj
*
pVgroup
,
int32_t
dnodeId
,
SVnodeLoad
*
pVload
)
{
if
(
pVload
->
role
==
TAOS_SYNC_ROLE_MASTER
)
{
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
i
];
if
(
pVgid
->
dnodeId
==
dnodeId
)
{
void
mgmtUpdateVgroupStatus
(
SVgObj
*
pVgroup
,
SDnodeObj
*
pDnode
,
SVnodeLoad
*
pVload
)
{
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
i
];
if
(
pVgid
->
pDnode
==
pDnode
)
{
pVgid
->
role
=
pVload
->
role
;
if
(
pVload
->
role
==
TAOS_SYNC_ROLE_MASTER
)
{
pVgroup
->
inUse
=
i
;
break
;
}
break
;
}
}
}
...
...
@@ -340,7 +348,7 @@ int32_t mgmtGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
mgmtDecTableRef
(
pTable
);
pVgroup
=
mgmtGetVgroup
(((
SChildTableObj
*
)
pTable
)
->
vgId
);
if
(
NULL
==
pVgroup
)
return
TSDB_CODE_INVALID_TABLE_ID
;
mgmt
ReleaseVgroup
(
pVgroup
);
mgmt
DecVgroupRef
(
pVgroup
);
maxReplica
=
pVgroup
->
numOfVnodes
>
maxReplica
?
pVgroup
->
numOfVnodes
:
maxReplica
;
}
else
{
SVgObj
*
pVgroup
=
pDb
->
pHead
;
...
...
@@ -391,27 +399,6 @@ int32_t mgmtGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
return
0
;
}
char
*
mgmtGetVnodeStatus
(
SVgObj
*
pVgroup
,
SVnodeGid
*
pVnode
)
{
SDnodeObj
*
pDnode
=
mgmtGetDnode
(
pVnode
->
dnodeId
);
if
(
pDnode
==
NULL
)
{
mError
(
"vgroup:%d, not exist in dnode:%d"
,
pVgroup
->
vgId
,
pDnode
->
dnodeId
);
return
"null"
;
}
mgmtReleaseDnode
(
pDnode
);
if
(
pDnode
->
status
==
TAOS_DN_STATUS_OFFLINE
)
{
return
"offline"
;
}
for
(
int
i
=
0
;
i
<
pDnode
->
openVnodes
;
++
i
)
{
if
(
pDnode
->
vload
[
i
].
vgId
==
pVgroup
->
vgId
)
{
return
pDnode
->
vload
[
i
].
status
?
"ready"
:
"offline"
;
}
}
return
"null"
;
}
int32_t
mgmtRetrieveVgroups
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
int32_t
numOfRows
=
0
;
SVgObj
*
pVgroup
=
NULL
;
...
...
@@ -453,19 +440,24 @@ int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pCo
*
(
int16_t
*
)
pWrite
=
pVgroup
->
vnodeGid
[
i
].
dnodeId
;
cols
++
;
tinet_ntoa
(
ipstr
,
pVgroup
->
vnodeGid
[
i
].
privateIp
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
ipstr
);
cols
++
;
SDnodeObj
*
pDnode
=
pVgroup
->
vnodeGid
[
i
].
pDnode
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
if
(
pVgroup
->
vnodeGid
[
i
].
dnodeId
!=
0
)
{
char
*
vnodeStatus
=
mgmtGetVnodeStatus
(
pVgroup
,
pVgroup
->
vnodeGid
+
i
);
strcpy
(
pWrite
,
vnodeStatus
);
if
(
pDnode
!=
NULL
)
{
tinet_ntoa
(
ipstr
,
pDnode
->
privateIp
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
ipstr
);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
mgmtGetMnodeRoleStr
(
pVgroup
->
vnodeGid
[
i
].
role
));
cols
++
;
}
else
{
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
"null"
);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
"null"
);
cols
++
;
}
cols
++
;
}
numOfRows
++
;
...
...
@@ -526,16 +518,17 @@ SMDCreateVnodeMsg *mgmtBuildCreateVnodeMsg(SVgObj *pVgroup) {
pCfg
->
commitLog
=
pDb
->
cfg
.
commitLog
;
pCfg
->
replications
=
(
int8_t
)
pVgroup
->
numOfVnodes
;
pCfg
->
quorum
=
1
;
pCfg
->
arbitratorIp
=
htonl
(
pVgroup
->
vnodeGid
[
0
].
privateIp
);
SMDVnodeDesc
*
pNodes
=
pVnode
->
nodes
;
for
(
int32_t
j
=
0
;
j
<
pVgroup
->
numOfVnodes
;
++
j
)
{
SDnodeObj
*
pDnode
=
mgmtGetDnode
(
pVgroup
->
vnodeGid
[
j
].
dnodeId
)
;
SDnodeObj
*
pDnode
=
pVgroup
->
vnodeGid
[
0
].
pDnode
;
if
(
pDnode
!=
NULL
)
{
pNodes
[
j
].
nodeId
=
htonl
(
pDnode
->
dnodeId
);
pNodes
[
j
].
nodeIp
=
htonl
(
pDnode
->
privateIp
);
strcpy
(
pNodes
[
j
].
nodeName
,
pDnode
->
dnodeName
);
mgmtReleaseDnode
(
pDnode
);
if
(
j
==
0
)
{
pCfg
->
arbitratorIp
=
htonl
(
pDnode
->
privateIp
);
}
}
}
...
...
@@ -549,7 +542,7 @@ SRpcIpSet mgmtGetIpSetFromVgroup(SVgObj *pVgroup) {
.
port
=
tsDnodeMnodePort
};
for
(
int
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
ipSet
.
ip
[
i
]
=
pVgroup
->
vnodeGid
[
i
].
privateIp
;
ipSet
.
ip
[
i
]
=
pVgroup
->
vnodeGid
[
i
].
p
Dnode
->
p
rivateIp
;
}
return
ipSet
;
}
...
...
@@ -580,7 +573,7 @@ void mgmtSendCreateVnodeMsg(SVgObj *pVgroup, SRpcIpSet *ipSet, void *ahandle) {
void
mgmtSendCreateVgroupMsg
(
SVgObj
*
pVgroup
,
void
*
ahandle
)
{
mTrace
(
"vgroup:%d, send create all vnodes msg, ahandle:%p"
,
pVgroup
->
vgId
,
ahandle
);
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SRpcIpSet
ipSet
=
mgmtGetIpSetFromIp
(
pVgroup
->
vnodeGid
[
i
].
privateIp
);
SRpcIpSet
ipSet
=
mgmtGetIpSetFromIp
(
pVgroup
->
vnodeGid
[
i
].
p
Dnode
->
p
rivateIp
);
mgmtSendCreateVnodeMsg
(
pVgroup
,
&
ipSet
,
ahandle
);
}
}
...
...
@@ -646,7 +639,7 @@ void mgmtSendDropVnodeMsg(int32_t vgId, SRpcIpSet *ipSet, void *ahandle) {
static
void
mgmtSendDropVgroupMsg
(
SVgObj
*
pVgroup
,
void
*
ahandle
)
{
mTrace
(
"vgroup:%d, send drop all vnodes msg, ahandle:%p"
,
pVgroup
->
vgId
,
ahandle
);
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SRpcIpSet
ipSet
=
mgmtGetIpSetFromIp
(
pVgroup
->
vnodeGid
[
i
].
privateIp
);
SRpcIpSet
ipSet
=
mgmtGetIpSetFromIp
(
pVgroup
->
vnodeGid
[
i
].
p
Dnode
->
p
rivateIp
);
mgmtSendDropVnodeMsg
(
pVgroup
->
vgId
,
&
ipSet
,
ahandle
);
}
}
...
...
@@ -697,7 +690,7 @@ static void mgmtProcessVnodeCfgMsg(SRpcMsg *rpcMsg) {
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_NOT_ACTIVE_VNODE
);
return
;
}
mgmt
ReleaseDnode
(
pDnode
);
mgmt
DecDnodeRef
(
pDnode
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pCfg
->
vgId
);
if
(
pVgroup
==
NULL
)
{
...
...
@@ -705,7 +698,7 @@ static void mgmtProcessVnodeCfgMsg(SRpcMsg *rpcMsg) {
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_NOT_ACTIVE_VNODE
);
return
;
}
mgmt
ReleaseVgroup
(
pVgroup
);
mgmt
DecVgroupRef
(
pVgroup
);
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_SUCCESS
);
...
...
@@ -721,7 +714,7 @@ void mgmtDropAllVgroups(SDbObj *pDropDb) {
SVgObj
*
pVgroup
=
NULL
;
while
(
1
)
{
mgmt
ReleaseVgroup
(
pVgroup
);
mgmt
DecVgroupRef
(
pVgroup
);
pNode
=
sdbFetchRow
(
tsVgroupSdb
,
pNode
,
(
void
**
)
&
pVgroup
);
if
(
pVgroup
==
NULL
)
break
;
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
d099ab73
...
...
@@ -408,82 +408,82 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) {
if
(
len
<=
0
)
{
free
(
content
);
fclose
(
fp
);
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, content is null"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, content is null"
,
pVnode
,
pVnode
->
vgId
);
return
false
;
}
cJSON
*
root
=
cJSON_Parse
(
content
);
if
(
root
==
NULL
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, invalid json format"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, invalid json format"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
cJSON
*
precision
=
cJSON_GetObjectItem
(
root
,
"precision"
);
if
(
!
precision
||
precision
->
type
!=
cJSON_Number
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, precision not found"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, precision not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
pVnode
->
tsdbCfg
.
precision
=
(
int8_t
)
precision
->
valueint
;
cJSON
*
compression
=
cJSON_GetObjectItem
(
root
,
"compression"
);
if
(
!
compression
||
compression
->
type
!=
cJSON_Number
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, compression not found"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, compression not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
pVnode
->
tsdbCfg
.
compression
=
(
int8_t
)
compression
->
valueint
;
cJSON
*
maxTables
=
cJSON_GetObjectItem
(
root
,
"maxTables"
);
if
(
!
maxTables
||
maxTables
->
type
!=
cJSON_Number
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, maxTables not found"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, maxTables not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
pVnode
->
tsdbCfg
.
maxTables
=
maxTables
->
valueint
;
cJSON
*
daysPerFile
=
cJSON_GetObjectItem
(
root
,
"daysPerFile"
);
if
(
!
daysPerFile
||
daysPerFile
->
type
!=
cJSON_Number
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, daysPerFile not found"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, daysPerFile not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
pVnode
->
tsdbCfg
.
daysPerFile
=
daysPerFile
->
valueint
;
cJSON
*
minRowsPerFileBlock
=
cJSON_GetObjectItem
(
root
,
"minRowsPerFileBlock"
);
if
(
!
minRowsPerFileBlock
||
minRowsPerFileBlock
->
type
!=
cJSON_Number
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, minRowsPerFileBlock not found"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, minRowsPerFileBlock not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
pVnode
->
tsdbCfg
.
minRowsPerFileBlock
=
minRowsPerFileBlock
->
valueint
;
cJSON
*
maxRowsPerFileBlock
=
cJSON_GetObjectItem
(
root
,
"maxRowsPerFileBlock"
);
if
(
!
maxRowsPerFileBlock
||
maxRowsPerFileBlock
->
type
!=
cJSON_Number
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, maxRowsPerFileBlock not found"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, maxRowsPerFileBlock not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
pVnode
->
tsdbCfg
.
maxRowsPerFileBlock
=
maxRowsPerFileBlock
->
valueint
;
cJSON
*
keep
=
cJSON_GetObjectItem
(
root
,
"k
eep"
);
if
(
!
keep
||
k
eep
->
type
!=
cJSON_Number
)
{
dError
(
"pVnode:%p vgId:%d, failed to
vnode cfg, k
eep not found"
,
pVnode
,
pVnode
->
vgId
);
cJSON
*
daysToKeep
=
cJSON_GetObjectItem
(
root
,
"daysToK
eep"
);
if
(
!
daysToKeep
||
daysToK
eep
->
type
!=
cJSON_Number
)
{
dError
(
"pVnode:%p vgId:%d, failed to
read vnode cfg, daysToK
eep not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
pVnode
->
tsdbCfg
.
keep
=
k
eep
->
valueint
;
pVnode
->
tsdbCfg
.
keep
=
daysToK
eep
->
valueint
;
cJSON
*
maxCacheSize
=
cJSON_GetObjectItem
(
root
,
"maxCacheSize"
);
if
(
!
maxCacheSize
||
maxCacheSize
->
type
!=
cJSON_Number
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, maxCacheSize not found"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, maxCacheSize not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
pVnode
->
tsdbCfg
.
maxCacheSize
=
maxCacheSize
->
valueint
;
cJSON
*
commitLog
=
cJSON_GetObjectItem
(
root
,
"commitLog"
);
if
(
!
commitLog
||
commitLog
->
type
!=
cJSON_Number
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, commitLog not found"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, commitLog not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
pVnode
->
walCfg
.
commitLog
=
(
int8_t
)
commitLog
->
valueint
;
cJSON
*
wals
=
cJSON_GetObjectItem
(
root
,
"wals"
);
if
(
!
wals
||
wals
->
type
!=
cJSON_Number
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, wals not found"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, wals not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
pVnode
->
walCfg
.
wals
=
(
int8_t
)
wals
->
valueint
;
...
...
@@ -491,34 +491,34 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) {
cJSON
*
arbitratorIp
=
cJSON_GetObjectItem
(
root
,
"arbitratorIp"
);
if
(
!
arbitratorIp
||
arbitratorIp
->
type
!=
cJSON_String
||
arbitratorIp
->
valuestring
==
NULL
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, arbitratorIp not found"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, arbitratorIp not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
pVnode
->
syncCfg
.
arbitratorIp
=
inet_addr
(
arbitratorIp
->
valuestring
);
cJSON
*
quorum
=
cJSON_GetObjectItem
(
root
,
"quorum"
);
if
(
!
quorum
||
quorum
->
type
!=
cJSON_Number
)
{
dError
(
"failed to vnode cfg, quorum not found"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"failed to
read
vnode cfg, quorum not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
pVnode
->
syncCfg
.
quorum
=
(
int8_t
)
quorum
->
valueint
;
cJSON
*
replica
=
cJSON_GetObjectItem
(
root
,
"replica"
);
if
(
!
replica
||
replica
->
type
!=
cJSON_Number
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, replica not found"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, replica not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
pVnode
->
syncCfg
.
replica
=
(
int8_t
)
replica
->
valueint
;
cJSON
*
nodeInfos
=
cJSON_GetObjectItem
(
root
,
"nodeInfos"
);
if
(
!
nodeInfos
||
nodeInfos
->
type
!=
cJSON_Array
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, nodeInfos not found"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, nodeInfos not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
int
size
=
cJSON_GetArraySize
(
nodeInfos
);
if
(
size
!=
pVnode
->
syncCfg
.
replica
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, nodeInfos size not matched"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, nodeInfos size not matched"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
...
...
@@ -528,21 +528,21 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) {
cJSON
*
nodeId
=
cJSON_GetObjectItem
(
nodeInfo
,
"nodeId"
);
if
(
!
nodeId
||
nodeId
->
type
!=
cJSON_Number
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, nodeId not found"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, nodeId not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
pVnode
->
syncCfg
.
nodeInfo
[
i
].
nodeId
=
nodeId
->
valueint
;
cJSON
*
nodeIp
=
cJSON_GetObjectItem
(
nodeInfo
,
"nodeIp"
);
if
(
!
nodeIp
||
nodeIp
->
type
!=
cJSON_String
||
nodeIp
->
valuestring
==
NULL
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, nodeIp not found"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, nodeIp not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
pVnode
->
syncCfg
.
nodeInfo
[
i
].
nodeIp
=
inet_addr
(
nodeIp
->
valuestring
);
cJSON
*
nodeName
=
cJSON_GetObjectItem
(
nodeInfo
,
"nodeName"
);
if
(
!
nodeName
||
nodeName
->
type
!=
cJSON_String
||
nodeName
->
valuestring
==
NULL
)
{
dError
(
"pVnode:%p vgId:%d, failed to vnode cfg, nodeName not found"
,
pVnode
,
pVnode
->
vgId
);
dError
(
"pVnode:%p vgId:%d, failed to
read
vnode cfg, nodeName not found"
,
pVnode
,
pVnode
->
vgId
);
goto
PARSE_OVER
;
}
strncpy
(
pVnode
->
syncCfg
.
nodeInfo
[
i
].
name
,
nodeName
->
valuestring
,
TSDB_NODE_NAME_LEN
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录