Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c018ea80
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看板
提交
c018ea80
编写于
3月 17, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shm
上级
0f6e5e01
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
78 addition
and
31 deletion
+78
-31
include/util/taoserror.h
include/util/taoserror.h
+2
-0
source/dnode/mgmt/container/inc/dnd.h
source/dnode/mgmt/container/inc/dnd.h
+2
-1
source/dnode/mgmt/container/inc/dndInt.h
source/dnode/mgmt/container/inc/dndInt.h
+3
-0
source/dnode/mgmt/container/src/dndExec.c
source/dnode/mgmt/container/src/dndExec.c
+28
-12
source/dnode/mgmt/container/src/dndInt.c
source/dnode/mgmt/container/src/dndInt.c
+0
-2
source/dnode/mgmt/container/src/dndMonitor.c
source/dnode/mgmt/container/src/dndMonitor.c
+4
-4
source/dnode/mgmt/container/src/dndMsg.c
source/dnode/mgmt/container/src/dndMsg.c
+5
-7
source/dnode/mgmt/container/src/dndObj.c
source/dnode/mgmt/container/src/dndObj.c
+27
-0
source/dnode/mgmt/container/src/dndTransport.c
source/dnode/mgmt/container/src/dndTransport.c
+4
-4
source/dnode/mgmt/dnode/src/dmMsg.c
source/dnode/mgmt/dnode/src/dmMsg.c
+1
-1
source/util/src/terror.c
source/util/src/terror.c
+2
-0
未找到文件。
include/util/taoserror.h
浏览文件 @
c018ea80
...
...
@@ -86,6 +86,8 @@ int32_t* taosGetErrno();
#define TSDB_CODE_INVALID_VERSION_STRING TAOS_DEF_ERROR_CODE(0, 0x0121)
#define TSDB_CODE_VERSION_NOT_COMPATIBLE TAOS_DEF_ERROR_CODE(0, 0x0122)
#define TSDB_CODE_COMPRESS_ERROR TAOS_DEF_ERROR_CODE(0, 0x0123)
#define TSDB_CODE_NODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0124)
#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0125)
//client
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
...
...
source/dnode/mgmt/container/inc/dnd.h
浏览文件 @
c018ea80
...
...
@@ -105,6 +105,7 @@ typedef struct SMgmtWrapper {
const
char
*
name
;
char
*
path
;
int32_t
refCount
;
SRWLatch
latch
;
bool
deployed
;
bool
dropped
;
bool
required
;
...
...
@@ -147,7 +148,7 @@ typedef struct SDnode {
EDndStatus
dndGetStatus
(
SDnode
*
pDnode
);
void
dndSetStatus
(
SDnode
*
pDnode
,
EDndStatus
stat
);
SMgmtWrapper
*
dnd
Get
Wrapper
(
SDnode
*
pDnode
,
ENodeType
nodeType
);
SMgmtWrapper
*
dnd
Acquire
Wrapper
(
SDnode
*
pDnode
,
ENodeType
nodeType
);
void
dndSetMsgHandle
(
SMgmtWrapper
*
pWrapper
,
int32_t
msgType
,
NodeMsgFp
nodeMsgFp
);
void
dndReportStartup
(
SDnode
*
pDnode
,
char
*
pName
,
char
*
pDesc
);
void
dndSendMonitorReport
(
SDnode
*
pDnode
);
...
...
source/dnode/mgmt/container/inc/dndInt.h
浏览文件 @
c018ea80
...
...
@@ -50,6 +50,9 @@ SDnode *dndCreate(const SDnodeOpt *pOption);
void
dndClose
(
SDnode
*
pDnode
);
void
dndHandleEvent
(
SDnode
*
pDnode
,
EDndEvent
event
);
SMgmtWrapper
*
dndAcquireWrapper
(
SDnode
*
pDnode
,
ENodeType
nodeType
);
void
dndReleaseWrapper
(
SMgmtWrapper
*
pWrapper
);
// dndTransport.c
int32_t
dndInitServer
(
SDnode
*
pDnode
);
void
dndCleanupServer
(
SDnode
*
pDnode
);
...
...
source/dnode/mgmt/container/src/dndExec.c
浏览文件 @
c018ea80
...
...
@@ -25,27 +25,40 @@ static void dndResetLog(SMgmtWrapper *pMgmt) {
taosInitLog
(
logname
,
1
);
}
static
bool
dndRequireNode
(
SMgmtWrapper
*
p
Mgmt
)
{
bool
required
=
(
*
p
Mgmt
->
fp
.
requiredFp
)(
pMgmt
);
static
bool
dndRequireNode
(
SMgmtWrapper
*
p
Wrapper
)
{
bool
required
=
(
*
p
Wrapper
->
fp
.
requiredFp
)(
pWrapper
);
if
(
!
required
)
{
dDebug
(
"node:%s, no need to start"
,
p
Mgmt
->
name
);
dDebug
(
"node:%s, no need to start"
,
p
Wrapper
->
name
);
}
else
{
dDebug
(
"node:%s, need to start"
,
p
Mgmt
->
name
);
dDebug
(
"node:%s, need to start"
,
p
Wrapper
->
name
);
}
return
required
;
}
int32_t
dndOpenNode
(
SMgmtWrapper
*
pWrapper
)
{
return
(
*
pWrapper
->
fp
.
openFp
)(
pWrapper
);
}
int32_t
dndOpenNode
(
SMgmtWrapper
*
pWrapper
)
{
int32_t
code
=
(
*
pWrapper
->
fp
.
openFp
)(
pWrapper
);
if
(
code
!=
0
)
{
dError
(
"node:%s, failed to open since %s"
,
pWrapper
->
name
,
terrstr
());
return
-
1
;
}
else
{
dDebug
(
"node:%s, has been opened"
,
pWrapper
->
name
);
}
pWrapper
->
deployed
=
true
;
return
0
;
}
void
dndCloseNode
(
SMgmtWrapper
*
pWrapper
)
{
if
(
pWrapper
->
required
)
{
taosWLockLatch
(
&
pWrapper
->
latch
);
if
(
pWrapper
->
deployed
)
{
(
*
pWrapper
->
fp
.
closeFp
)(
pWrapper
);
pWrapper
->
requir
ed
=
false
;
pWrapper
->
deploy
ed
=
false
;
}
if
(
pWrapper
->
pProc
)
{
taosProcCleanup
(
pWrapper
->
pProc
);
pWrapper
->
pProc
=
NULL
;
}
taosWUnLockLatch
(
&
pWrapper
->
latch
);
}
static
int32_t
dndRunInSingleProcess
(
SDnode
*
pDnode
)
{
...
...
@@ -70,13 +83,14 @@ static int32_t dndRunInSingleProcess(SDnode *pDnode) {
}
}
SMgmtWrapper
*
pWrapper
=
dndGetWrapper
(
pDnode
,
DNODE
);
if
(
dmStart
(
pWrapper
->
pMgmt
)
!=
0
)
{
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
DNODE
);
int32_t
code
=
dmStart
(
pWrapper
->
pMgmt
);
if
(
code
!=
0
)
{
dError
(
"failed to start dnode worker since %s"
,
terrstr
());
return
-
1
;
}
return
0
;
dndReleaseWrapper
(
pWrapper
);
return
code
;
}
static
void
dndClearNodesExecpt
(
SDnode
*
pDnode
,
ENodeType
except
)
{
...
...
@@ -184,12 +198,14 @@ static int32_t dndRunInMultiProcess(SDnode *pDnode) {
}
}
SMgmtWrapper
*
pWrapper
=
dnd
Get
Wrapper
(
pDnode
,
DNODE
);
SMgmtWrapper
*
pWrapper
=
dnd
Acquire
Wrapper
(
pDnode
,
DNODE
);
if
(
pWrapper
->
procType
==
PROC_PARENT
&&
dmStart
(
pWrapper
->
pMgmt
)
!=
0
)
{
dndReleaseWrapper
(
pWrapper
);
dError
(
"failed to start dnode worker since %s"
,
terrstr
());
return
-
1
;
}
dndReleaseWrapper
(
pWrapper
);
return
0
;
}
...
...
source/dnode/mgmt/container/src/dndInt.c
浏览文件 @
c018ea80
...
...
@@ -65,8 +65,6 @@ void dndCleanup() {
dInfo
(
"dnode env is cleaned up"
);
}
SMgmtWrapper
*
dndGetWrapper
(
SDnode
*
pDnode
,
ENodeType
nodeType
)
{
return
&
pDnode
->
wrappers
[
nodeType
];
}
void
dndSetMsgHandle
(
SMgmtWrapper
*
pWrapper
,
int32_t
msgType
,
NodeMsgFp
nodeMsgFp
)
{
pWrapper
->
msgFps
[
TMSG_INDEX
(
msgType
)]
=
nodeMsgFp
;
}
...
...
source/dnode/mgmt/container/src/dndMonitor.c
浏览文件 @
c018ea80
...
...
@@ -22,7 +22,7 @@ static int32_t dndGetMonitorDiskInfo(SDnode *pDnode, SMonDiskInfo *pInfo) {
tstrncpy
(
pInfo
->
tempdir
.
name
,
tsTempDir
,
sizeof
(
pInfo
->
tempdir
.
name
));
pInfo
->
tempdir
.
size
=
tsTempSpace
.
size
;
return
vmGetTfsMonitorInfo
(
dnd
Get
Wrapper
(
pDnode
,
VNODES
),
pInfo
);
return
vmGetTfsMonitorInfo
(
dnd
Acquire
Wrapper
(
pDnode
,
VNODES
),
pInfo
);
}
static
void
dndGetMonitorBasicInfo
(
SDnode
*
pDnode
,
SMonBasicInfo
*
pInfo
)
{
...
...
@@ -45,8 +45,8 @@ static void dndGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
taosGetCardInfo
(
&
pInfo
->
net_in
,
&
pInfo
->
net_out
);
taosGetProcIO
(
&
pInfo
->
io_read
,
&
pInfo
->
io_write
,
&
pInfo
->
io_read_disk
,
&
pInfo
->
io_write_disk
);
vmGetVnodeReqs
(
dnd
Get
Wrapper
(
pDnode
,
VNODES
),
pInfo
);
pInfo
->
has_mnode
=
(
dnd
Get
Wrapper
(
pDnode
,
MNODE
)
->
required
);
vmGetVnodeReqs
(
dnd
Acquire
Wrapper
(
pDnode
,
VNODES
),
pInfo
);
pInfo
->
has_mnode
=
(
dnd
Acquire
Wrapper
(
pDnode
,
MNODE
)
->
required
);
}
void
dndSendMonitorReport
(
SDnode
*
pDnode
)
{
...
...
@@ -63,7 +63,7 @@ void dndSendMonitorReport(SDnode *pDnode) {
SMonClusterInfo
clusterInfo
=
{
0
};
SMonVgroupInfo
vgroupInfo
=
{
0
};
SMonGrantInfo
grantInfo
=
{
0
};
if
(
mmGetMonitorInfo
(
dnd
Get
Wrapper
(
pDnode
,
MNODE
),
&
clusterInfo
,
&
vgroupInfo
,
&
grantInfo
)
==
0
)
{
if
(
mmGetMonitorInfo
(
dnd
Acquire
Wrapper
(
pDnode
,
MNODE
),
&
clusterInfo
,
&
vgroupInfo
,
&
grantInfo
)
==
0
)
{
monSetClusterInfo
(
pMonitor
,
&
clusterInfo
);
monSetVgroupInfo
(
pMonitor
,
&
vgroupInfo
);
monSetGrantInfo
(
pMonitor
,
&
grantInfo
);
...
...
source/dnode/mgmt/container/src/dndMsg.c
浏览文件 @
c018ea80
...
...
@@ -16,8 +16,6 @@
#define _DEFAULT_SOURCE
#include "dndInt.h"
static
int32_t
dndBuildMsg
(
SNodeMsg
*
pMsg
,
SRpcMsg
*
pRpc
,
SEpSet
*
pEpSet
)
{
SRpcConnInfo
connInfo
=
{
0
};
if
((
pRpc
->
msgType
&
1U
)
&&
rpcGetConnInfo
(
pRpc
->
handle
,
&
connInfo
)
!=
0
)
{
...
...
@@ -34,7 +32,7 @@ static int32_t dndBuildMsg(SNodeMsg *pMsg, SRpcMsg *pRpc, SEpSet *pEpSet) {
void
dndProcessRpcMsg
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRpc
,
SEpSet
*
pEpSet
)
{
if
(
pEpSet
&&
pEpSet
->
numOfEps
>
0
&&
pRpc
->
msgType
==
TDMT_MND_STATUS_RSP
)
{
dmUpdateMnodeEpSet
(
dnd
Get
Wrapper
(
pWrapper
->
pDnode
,
DNODE
)
->
pMgmt
,
pEpSet
);
dmUpdateMnodeEpSet
(
dnd
Acquire
Wrapper
(
pWrapper
->
pDnode
,
DNODE
)
->
pMgmt
,
pEpSet
);
}
int32_t
code
=
-
1
;
...
...
@@ -91,13 +89,13 @@ static SMgmtWrapper *dndGetWrapperFromMsg(SDnode *pDnode, SNodeMsg *pMsg) {
SMgmtWrapper
*
pWrapper
=
NULL
;
switch
(
pMsg
->
rpcMsg
.
msgType
)
{
case
TDMT_DND_CREATE_MNODE
:
return
dnd
Get
Wrapper
(
pDnode
,
MNODE
);
return
dnd
Acquire
Wrapper
(
pDnode
,
MNODE
);
case
TDMT_DND_CREATE_QNODE
:
return
dnd
Get
Wrapper
(
pDnode
,
QNODE
);
return
dnd
Acquire
Wrapper
(
pDnode
,
QNODE
);
case
TDMT_DND_CREATE_SNODE
:
return
dnd
Get
Wrapper
(
pDnode
,
SNODE
);
return
dnd
Acquire
Wrapper
(
pDnode
,
SNODE
);
case
TDMT_DND_CREATE_BNODE
:
return
dnd
Get
Wrapper
(
pDnode
,
BNODE
);
return
dnd
Acquire
Wrapper
(
pDnode
,
BNODE
);
default:
return
NULL
;
}
...
...
source/dnode/mgmt/container/src/dndObj.c
浏览文件 @
c018ea80
...
...
@@ -94,6 +94,7 @@ SDnode *dndCreate(const SDnodeOpt *pOption) {
}
pWrapper
->
procType
=
PROC_SINGLE
;
taosInitRWLatch
(
&
pWrapper
->
latch
);
}
code
=
0
;
...
...
@@ -136,3 +137,29 @@ void dndHandleEvent(SDnode *pDnode, EDndEvent event) {
dInfo
(
"dnode object receive event %d, data:%p"
,
event
,
pDnode
);
pDnode
->
event
=
event
;
}
SMgmtWrapper
*
dndAcquireWrapper
(
SDnode
*
pDnode
,
ENodeType
nodeType
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
nodeType
];
SMgmtWrapper
*
pRetWrapper
=
pWrapper
;
taosRLockLatch
(
&
pWrapper
->
latch
);
if
(
pWrapper
->
deployed
)
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
dTrace
(
"node:%s, is acquired, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
else
{
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
pRetWrapper
=
NULL
;
}
taosRUnLockLatch
(
&
pWrapper
->
latch
);
return
pRetWrapper
;
}
void
dndReleaseWrapper
(
SMgmtWrapper
*
pWrapper
)
{
if
(
pWrapper
==
NULL
)
return
;
taosRLockLatch
(
&
pWrapper
->
latch
);
int32_t
refCount
=
atomic_sub_fetch_32
(
&
pWrapper
->
refCount
,
1
);
taosRUnLockLatch
(
&
pWrapper
->
latch
);
dTrace
(
"node:%s, is released, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
\ No newline at end of file
source/dnode/mgmt/container/src/dndTransport.c
浏览文件 @
c018ea80
...
...
@@ -125,7 +125,7 @@ static void dndSendMsgToMnodeRecv(SDnode *pDnode, SRpcMsg *pRpcMsg, SRpcMsg *pRp
STransMgmt
*
pMgmt
=
&
pDnode
->
trans
;
SEpSet
epSet
=
{
0
};
dmGetMnodeEpSet
(
dnd
Get
Wrapper
(
pDnode
,
DNODE
)
->
pMgmt
,
&
epSet
);
dmGetMnodeEpSet
(
dnd
Acquire
Wrapper
(
pDnode
,
DNODE
)
->
pMgmt
,
&
epSet
);
rpcSendRecv
(
pMgmt
->
clientRpc
,
&
epSet
,
pRpcMsg
,
pRpcRsp
);
}
...
...
@@ -159,7 +159,7 @@ static int32_t dndRetrieveUserAuthInfo(void *parent, char *user, char *spi, char
return
0
;
}
if
(
mmGetUserAuth
(
dnd
Get
Wrapper
(
pDnode
,
MNODE
),
user
,
spi
,
encrypt
,
secret
,
ckey
)
==
0
)
{
if
(
mmGetUserAuth
(
dnd
Acquire
Wrapper
(
pDnode
,
MNODE
),
user
,
spi
,
encrypt
,
secret
,
ckey
)
==
0
)
{
dTrace
(
"user:%s, get auth from mnode, spi:%d encrypt:%d"
,
user
,
*
spi
,
*
encrypt
);
return
0
;
}
...
...
@@ -287,14 +287,14 @@ int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pReq) {
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
STransMgmt
*
pTrans
=
&
pDnode
->
trans
;
SEpSet
epSet
=
{
0
};
dmGetMnodeEpSet
(
dnd
Get
Wrapper
(
pDnode
,
DNODE
)
->
pMgmt
,
&
epSet
);
dmGetMnodeEpSet
(
dnd
Acquire
Wrapper
(
pDnode
,
DNODE
)
->
pMgmt
,
&
epSet
);
return
dndSendRpcReq
(
pTrans
,
&
epSet
,
pReq
);
}
}
void
dndSendRpcRsp
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRsp
)
{
if
(
pRsp
->
code
==
TSDB_CODE_DND_MNODE_NOT_DEPLOYED
||
pRsp
->
code
==
TSDB_CODE_APP_NOT_READY
)
{
SMgmtWrapper
*
pDnodeWrapper
=
dnd
Get
Wrapper
(
pWrapper
->
pDnode
,
DNODE
);
SMgmtWrapper
*
pDnodeWrapper
=
dnd
Acquire
Wrapper
(
pWrapper
->
pDnode
,
DNODE
);
dmSendRedirectRsp
(
pDnodeWrapper
->
pMgmt
,
pRsp
);
}
else
{
rpcSendResponse
(
pRsp
);
...
...
source/dnode/mgmt/dnode/src/dmMsg.c
浏览文件 @
c018ea80
...
...
@@ -42,7 +42,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
taosRUnLockLatch
(
&
pMgmt
->
latch
);
req
.
pVloads
=
taosArrayInit
(
TSDB_MAX_VNODES
,
sizeof
(
SVnodeLoad
));
vmGetVnodeLoads
(
dnd
Get
Wrapper
(
pDnode
,
VNODES
),
req
.
pVloads
);
vmGetVnodeLoads
(
dnd
Acquire
Wrapper
(
pDnode
,
VNODES
),
req
.
pVloads
);
int32_t
contLen
=
tSerializeSStatusReq
(
NULL
,
0
,
&
req
);
void
*
pHead
=
rpcMallocCont
(
contLen
);
...
...
source/util/src/terror.c
浏览文件 @
c018ea80
...
...
@@ -69,6 +69,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_APP_NOT_READY, "Database not ready")
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_FQDN_ERROR
,
"Unable to resolve FQDN"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_INVALID_VERSION
,
"Invalid app version"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_COMPRESS_ERROR
,
"Failed to compress msg"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NODE_ALREADY_DEPLOYED
,
"Node already deployed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NODE_NOT_DEPLOYED
,
"Node not deployed"
)
//common & util
TAOS_DEFINE_ERROR
(
TSDB_CODE_OPS_NOT_SUPPORT
,
"Operation not supported"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录