Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
359482be
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
359482be
编写于
3月 15, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shm
上级
143a3113
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
51 addition
and
35 deletion
+51
-35
include/os/osEnv.h
include/os/osEnv.h
+1
-0
source/dnode/mgmt/container/src/dndInt.c
source/dnode/mgmt/container/src/dndInt.c
+3
-0
source/dnode/mgmt/container/src/dndNode.c
source/dnode/mgmt/container/src/dndNode.c
+7
-4
source/dnode/mgmt/container/src/dndTransport.c
source/dnode/mgmt/container/src/dndTransport.c
+7
-6
source/dnode/mgmt/dnode/src/dmFile.c
source/dnode/mgmt/dnode/src/dmFile.c
+12
-12
source/dnode/mgmt/dnode/src/dmInt.c
source/dnode/mgmt/dnode/src/dmInt.c
+2
-2
source/dnode/mgmt/dnode/src/dmMsg.c
source/dnode/mgmt/dnode/src/dmMsg.c
+4
-4
source/dnode/mgmt/dnode/src/dmWorker.c
source/dnode/mgmt/dnode/src/dmWorker.c
+12
-7
source/dnode/mgmt/main/src/dndMain.c
source/dnode/mgmt/main/src/dndMain.c
+1
-0
source/os/src/osEnv.c
source/os/src/osEnv.c
+2
-0
未找到文件。
include/os/osEnv.h
浏览文件 @
359482be
...
...
@@ -45,6 +45,7 @@ extern SDiskSpace tsTempSpace;
void
osInit
();
void
osUpdate
();
void
osCleanup
();
bool
osLogSpaceAvailable
();
void
osSetTimezone
(
const
char
*
timezone
);
...
...
source/dnode/mgmt/container/src/dndInt.c
浏览文件 @
359482be
...
...
@@ -19,6 +19,7 @@
static
int8_t
once
=
DND_ENV_INIT
;
int32_t
dndInit
()
{
dDebug
(
"start to init dnode env"
);
if
(
atomic_val_compare_exchange_8
(
&
once
,
DND_ENV_INIT
,
DND_ENV_READY
)
!=
DND_ENV_INIT
)
{
terrno
=
TSDB_CODE_REPEAT_INIT
;
dError
(
"failed to init dnode env since %s"
,
terrstr
());
...
...
@@ -51,6 +52,7 @@ int32_t dndInit() {
}
void
dndCleanup
()
{
dDebug
(
"start to cleanup dnode env"
);
if
(
atomic_val_compare_exchange_8
(
&
once
,
DND_ENV_READY
,
DND_ENV_CLEANUP
)
!=
DND_ENV_READY
)
{
dError
(
"dnode env is already cleaned up"
);
return
;
...
...
@@ -121,5 +123,6 @@ TdFilePtr dndCheckRunning(char *dataDir) {
return
NULL
;
}
dDebug
(
"file:%s is locked"
,
filepath
);
return
pFile
;
}
source/dnode/mgmt/container/src/dndNode.c
浏览文件 @
359482be
...
...
@@ -45,7 +45,11 @@ static bool dndRequireNode(SMgmtWrapper *pMgmt) {
static
int32_t
dndOpenNode
(
SMgmtWrapper
*
pWrapper
)
{
return
(
*
pWrapper
->
fp
.
openFp
)(
pWrapper
);
}
static
void
dndCloseNode
(
SMgmtWrapper
*
pWrapper
)
{
(
*
pWrapper
->
fp
.
closeFp
)(
pWrapper
);
}
static
void
dndCloseNode
(
SMgmtWrapper
*
pWrapper
)
{
if
(
pWrapper
->
required
)
{
(
*
pWrapper
->
fp
.
closeFp
)(
pWrapper
);
}
}
static
void
dndClearMemory
(
SDnode
*
pDnode
)
{
for
(
ENodeType
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
...
...
@@ -243,7 +247,7 @@ int32_t dndRun(SDnode *pDnode) {
while
(
1
)
{
if
(
pDnode
->
event
==
DND_EVENT_STOP
)
{
dInfo
(
"dnode
object receive stop event
"
);
dInfo
(
"dnode
is about to stop
"
);
break
;
}
taosMsleep
(
100
);
...
...
@@ -302,8 +306,7 @@ void dndProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpSet) {
goto
_OVER
;
}
dTrace
(
"msg:%p, is created, app:%p RPC:%p user:%s, processd by %s"
,
pMsg
,
pRpc
->
ahandle
,
pRpc
->
handle
,
pMsg
->
user
,
pWrapper
->
name
);
dTrace
(
"msg:%p, is created, user:%s"
,
pMsg
,
pMsg
->
user
);
code
=
(
*
msgFp
)(
pWrapper
,
pMsg
);
_OVER:
...
...
source/dnode/mgmt/container/src/dndTransport.c
浏览文件 @
359482be
...
...
@@ -30,18 +30,18 @@ static void dndProcessResponse(void *parent, SRpcMsg *pRsp, SEpSet *pEpSet) {
if
(
dndGetStatus
(
pDnode
)
==
DND_STAT_STOPPED
)
{
if
(
pRsp
==
NULL
||
pRsp
->
pCont
==
NULL
)
return
;
dTrace
(
"
RPC %p, rsp:%s ignored since dnode exiting, app:%p"
,
pRsp
->
handle
,
TMSG_INFO
(
msgType
),
pRsp
->
ahandle
);
dTrace
(
"
rsp:%s ignored since dnode exiting, app:%p"
,
TMSG_INFO
(
msgType
),
pRsp
->
ahandle
);
rpcFreeCont
(
pRsp
->
pCont
);
return
;
}
SMsgHandle
*
pHandle
=
&
pMgmt
->
msgHandles
[
TMSG_INDEX
(
msgType
)];
if
(
pHandle
->
msgFp
!=
NULL
)
{
dTrace
(
"
RPC %p, rsp:%s will be processed by %s, code:0x%x app:%p"
,
pRsp
->
handle
,
TMSG_INFO
(
msgType
)
,
p
Handle
->
pWrapper
->
name
,
p
Rsp
->
code
&
0XFFFF
,
pRsp
->
ahandle
);
dTrace
(
"
rsp:%s will be processed by %s, code:0x%x app:%p"
,
TMSG_INFO
(
msgType
),
pHandle
->
pWrapper
->
name
,
pRsp
->
code
&
0XFFFF
,
pRsp
->
ahandle
);
dndProcessRpcMsg
(
pHandle
->
pWrapper
,
pRsp
,
pEpSet
);
}
else
{
dError
(
"
RPC %p, rsp:%s not processed, app:%p"
,
pRsp
->
handle
,
TMSG_INFO
(
msgType
),
pRsp
->
ahandle
);
dError
(
"
rsp:%s not processed, app:%p"
,
TMSG_INFO
(
msgType
),
pRsp
->
ahandle
);
rpcFreeCont
(
pRsp
->
pCont
);
}
}
...
...
@@ -258,12 +258,13 @@ int32_t dndInitMsgHandle(SDnode *pDnode) {
SMsgHandle
*
pHandle
=
&
pMgmt
->
msgHandles
[
msgIndex
];
if
(
pHandle
->
msgFp
!=
NULL
)
{
dError
(
"msg:%s
,
has multiple process nodes, prev node:%s, curr node:%s"
,
tMsgInfo
[
msgIndex
],
dError
(
"msg:%s has multiple process nodes, prev node:%s, curr node:%s"
,
tMsgInfo
[
msgIndex
],
pHandle
->
pWrapper
->
name
,
pWrapper
->
name
);
return
-
1
;
}
else
{
d
Debug
(
"msg:%s, will be processed by node:
%s"
,
tMsgInfo
[
msgIndex
],
pWrapper
->
name
);
d
Trace
(
"msg:%s will be processed by
%s"
,
tMsgInfo
[
msgIndex
],
pWrapper
->
name
);
pHandle
->
msgFp
=
msgFp
;
pHandle
->
pWrapper
=
pWrapper
;
}
}
}
...
...
source/dnode/mgmt/dnode/src/dmFile.c
浏览文件 @
359482be
...
...
@@ -16,9 +16,9 @@
#define _DEFAULT_SOURCE
#include "dmFile.h"
static
void
d
nd
PrintDnodes
(
SDnodeMgmt
*
pMgmt
);
static
bool
d
nd
IsEpChanged
(
SDnodeMgmt
*
pMgmt
,
const
char
*
ep
);
static
void
d
nd
ResetDnodes
(
SDnodeMgmt
*
pMgmt
,
SArray
*
pDnodeEps
);
static
void
d
m
PrintDnodes
(
SDnodeMgmt
*
pMgmt
);
static
bool
d
m
IsEpChanged
(
SDnodeMgmt
*
pMgmt
,
const
char
*
ep
);
static
void
d
m
ResetDnodes
(
SDnodeMgmt
*
pMgmt
,
SArray
*
pDnodeEps
);
int32_t
dmReadFile
(
SDnodeMgmt
*
pMgmt
)
{
int32_t
code
=
TSDB_CODE_DND_DNODE_READ_FILE_ERROR
;
...
...
@@ -130,14 +130,14 @@ int32_t dmReadFile(SDnodeMgmt *pMgmt) {
code
=
0
;
dInfo
(
"succcessed to read file %s"
,
file
);
d
nd
PrintDnodes
(
pMgmt
);
d
m
PrintDnodes
(
pMgmt
);
PRASE_DNODE_OVER:
if
(
content
!=
NULL
)
free
(
content
);
if
(
root
!=
NULL
)
cJSON_Delete
(
root
);
if
(
pFile
!=
NULL
)
taosCloseFile
(
&
pFile
);
if
(
d
nd
IsEpChanged
(
pMgmt
,
pMgmt
->
pDnode
->
cfg
.
localEp
))
{
if
(
d
m
IsEpChanged
(
pMgmt
,
pMgmt
->
pDnode
->
cfg
.
localEp
))
{
dError
(
"localEp %s different with %s and need reconfigured"
,
pMgmt
->
pDnode
->
cfg
.
localEp
,
file
);
return
-
1
;
}
...
...
@@ -149,7 +149,7 @@ PRASE_DNODE_OVER:
taosArrayPush
(
pMgmt
->
pDnodeEps
,
&
dnodeEp
);
}
d
nd
ResetDnodes
(
pMgmt
,
pMgmt
->
pDnodeEps
);
d
m
ResetDnodes
(
pMgmt
,
pMgmt
->
pDnodeEps
);
terrno
=
0
;
return
0
;
...
...
@@ -218,12 +218,12 @@ void dmUpdateDnodeEps(SDnodeMgmt *pMgmt, SArray *pDnodeEps) {
int32_t
numOfEpsOld
=
(
int32_t
)
taosArrayGetSize
(
pMgmt
->
pDnodeEps
);
if
(
numOfEps
!=
numOfEpsOld
)
{
d
nd
ResetDnodes
(
pMgmt
,
pDnodeEps
);
d
m
ResetDnodes
(
pMgmt
,
pDnodeEps
);
dmWriteFile
(
pMgmt
);
}
else
{
int32_t
size
=
numOfEps
*
sizeof
(
SDnodeEp
);
if
(
memcmp
(
pMgmt
->
pDnodeEps
->
pData
,
pDnodeEps
->
pData
,
size
)
!=
0
)
{
d
nd
ResetDnodes
(
pMgmt
,
pDnodeEps
);
d
m
ResetDnodes
(
pMgmt
,
pDnodeEps
);
dmWriteFile
(
pMgmt
);
}
}
...
...
@@ -231,7 +231,7 @@ void dmUpdateDnodeEps(SDnodeMgmt *pMgmt, SArray *pDnodeEps) {
taosWUnLockLatch
(
&
pMgmt
->
latch
);
}
static
void
d
nd
ResetDnodes
(
SDnodeMgmt
*
pMgmt
,
SArray
*
pDnodeEps
)
{
static
void
d
m
ResetDnodes
(
SDnodeMgmt
*
pMgmt
,
SArray
*
pDnodeEps
)
{
if
(
pMgmt
->
pDnodeEps
!=
pDnodeEps
)
{
SArray
*
tmp
=
pMgmt
->
pDnodeEps
;
pMgmt
->
pDnodeEps
=
taosArrayDup
(
pDnodeEps
);
...
...
@@ -259,10 +259,10 @@ static void dndResetDnodes(SDnodeMgmt *pMgmt, SArray *pDnodeEps) {
taosHashPut
(
pMgmt
->
dnodeHash
,
&
pDnodeEp
->
id
,
sizeof
(
int32_t
),
pDnodeEp
,
sizeof
(
SDnodeEp
));
}
d
nd
PrintDnodes
(
pMgmt
);
d
m
PrintDnodes
(
pMgmt
);
}
static
void
d
nd
PrintDnodes
(
SDnodeMgmt
*
pMgmt
)
{
static
void
d
m
PrintDnodes
(
SDnodeMgmt
*
pMgmt
)
{
int32_t
numOfEps
=
(
int32_t
)
taosArrayGetSize
(
pMgmt
->
pDnodeEps
);
dDebug
(
"print dnode ep list, num:%d"
,
numOfEps
);
for
(
int32_t
i
=
0
;
i
<
numOfEps
;
i
++
)
{
...
...
@@ -271,7 +271,7 @@ static void dndPrintDnodes(SDnodeMgmt *pMgmt) {
}
}
static
bool
d
nd
IsEpChanged
(
SDnodeMgmt
*
pMgmt
,
const
char
*
ep
)
{
static
bool
d
m
IsEpChanged
(
SDnodeMgmt
*
pMgmt
,
const
char
*
ep
)
{
bool
changed
=
false
;
taosRLockLatch
(
&
pMgmt
->
latch
);
...
...
source/dnode/mgmt/dnode/src/dmInt.c
浏览文件 @
359482be
...
...
@@ -141,11 +141,11 @@ int32_t dmInit(SMgmtWrapper *pWrapper) {
}
pWrapper
->
pMgmt
=
pMgmt
;
dInfo
(
"dnode-mgmt is initialized"
);
dndSetStatus
(
pDnode
,
DND_STAT_RUNNING
);
dmSendStatusReq
(
pMgmt
);
dndReportStartup
(
pDnode
,
"TDengine"
,
"initialized successfully"
);
dInfo
(
"dnode-mgmt is initialized"
);
return
0
;
}
...
...
source/dnode/mgmt/dnode/src/dmMsg.c
浏览文件 @
359482be
...
...
@@ -54,11 +54,11 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
SRpcMsg
rpcMsg
=
{.
pCont
=
pHead
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_MND_STATUS
,
.
ahandle
=
(
void
*
)
9527
};
pMgmt
->
statusSent
=
1
;
dTrace
(
"
pDnode:%p, send status req to mnode"
,
pDnod
e
);
dTrace
(
"
send status req to mnode, ahandle:%p"
,
rpcMsg
.
ahandl
e
);
dndSendReqToMnode
(
pMgmt
->
pDnode
,
&
rpcMsg
);
}
static
void
d
nd
UpdateDnodeCfg
(
SDnodeMgmt
*
pMgmt
,
SDnodeCfg
*
pCfg
)
{
static
void
d
m
UpdateDnodeCfg
(
SDnodeMgmt
*
pMgmt
,
SDnodeCfg
*
pCfg
)
{
if
(
pMgmt
->
dnodeId
==
0
)
{
dInfo
(
"set dnodeId:%d clusterId:%"
PRId64
,
pCfg
->
dnodeId
,
pCfg
->
clusterId
);
taosWLockLatch
(
&
pMgmt
->
latch
);
...
...
@@ -70,7 +70,7 @@ static void dndUpdateDnodeCfg(SDnodeMgmt *pMgmt, SDnodeCfg *pCfg) {
}
void
dmProcessStatusRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pRsp
)
{
SDnodeMgmt
*
pMgmt
=
dndGetWrapper
(
pDnode
,
M
NODE
)
->
pMgmt
;
SDnodeMgmt
*
pMgmt
=
dndGetWrapper
(
pDnode
,
D
NODE
)
->
pMgmt
;
if
(
pRsp
->
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pRsp
->
code
==
TSDB_CODE_MND_DNODE_NOT_EXIST
&&
!
pMgmt
->
dropped
&&
pMgmt
->
dnodeId
>
0
)
{
...
...
@@ -83,7 +83,7 @@ void dmProcessStatusRsp(SDnode *pDnode, SRpcMsg *pRsp) {
if
(
pRsp
->
pCont
!=
NULL
&&
pRsp
->
contLen
!=
0
&&
tDeserializeSStatusRsp
(
pRsp
->
pCont
,
pRsp
->
contLen
,
&
statusRsp
)
==
0
)
{
pMgmt
->
dver
=
statusRsp
.
dver
;
d
nd
UpdateDnodeCfg
(
pMgmt
,
&
statusRsp
.
dnodeCfg
);
d
m
UpdateDnodeCfg
(
pMgmt
,
&
statusRsp
.
dnodeCfg
);
dmUpdateDnodeEps
(
pMgmt
,
statusRsp
.
pDnodeEps
);
}
taosArrayDestroy
(
statusRsp
.
pDnodeEps
);
...
...
source/dnode/mgmt/dnode/src/dmWorker.c
浏览文件 @
359482be
...
...
@@ -23,7 +23,7 @@
#include "smInt.h"
#include "vmInt.h"
static
void
*
d
node
ThreadRoutine
(
void
*
param
)
{
static
void
*
d
m
ThreadRoutine
(
void
*
param
)
{
SDnodeMgmt
*
pMgmt
=
param
;
SDnode
*
pDnode
=
pMgmt
->
pDnode
;
int64_t
lastStatusTime
=
taosGetTimestampMs
();
...
...
@@ -54,8 +54,10 @@ static void *dnodeThreadRoutine(void *param) {
}
}
static
void
d
ndProcessMgmtQueue
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Msg
)
{
static
void
d
mProcessMgmtQueue
(
SDnode
*
pDnode
,
SNodeMsg
*
pNode
Msg
)
{
int32_t
code
=
0
;
SRpcMsg
*
pMsg
=
&
pNodeMsg
->
rpcMsg
;
dTrace
(
"msg:%p, will be processed in mgmt queue"
,
pNodeMsg
);
switch
(
pMsg
->
msgType
)
{
case
TDMT_DND_CREATE_MNODE
:
...
...
@@ -127,21 +129,23 @@ static void dndProcessMgmtQueue(SDnode *pDnode, SRpcMsg *pMsg) {
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
taosFreeQitem
(
pMsg
);
taosFreeQitem
(
p
Node
Msg
);
}
int32_t
dmStartWorker
(
SDnodeMgmt
*
pMgmt
)
{
if
(
dndInitWorker
(
pMgmt
->
pDnode
,
&
pMgmt
->
mgmtWorker
,
DND_WORKER_SINGLE
,
"dnode-mgmt"
,
1
,
1
,
dndProcessMgmtQueue
)
!=
0
)
{
if
(
dndInitWorker
(
pMgmt
->
pDnode
,
&
pMgmt
->
mgmtWorker
,
DND_WORKER_SINGLE
,
"dnode-mgmt"
,
1
,
1
,
dmProcessMgmtQueue
)
!=
0
)
{
dError
(
"failed to start dnode mgmt worker since %s"
,
terrstr
());
return
-
1
;
}
if
(
dndInitWorker
(
pMgmt
->
pDnode
,
&
pMgmt
->
statusWorker
,
DND_WORKER_SINGLE
,
"dnode-status"
,
1
,
1
,
dndProcessMgmtQueue
)
!=
0
)
{
if
(
dndInitWorker
(
pMgmt
->
pDnode
,
&
pMgmt
->
statusWorker
,
DND_WORKER_SINGLE
,
"dnode-status"
,
1
,
1
,
dmProcessMgmtQueue
)
!=
0
)
{
dError
(
"failed to start dnode mgmt worker since %s"
,
terrstr
());
return
-
1
;
}
pMgmt
->
threadId
=
taosCreateThread
(
d
node
ThreadRoutine
,
pMgmt
);
pMgmt
->
threadId
=
taosCreateThread
(
d
m
ThreadRoutine
,
pMgmt
);
if
(
pMgmt
->
threadId
==
NULL
)
{
dError
(
"failed to init dnode thread"
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -169,5 +173,6 @@ int32_t dmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
pWorker
=
&
pMgmt
->
statusWorker
;
}
dTrace
(
"msg:%p, will be written to worker %s"
,
pMsg
,
pWorker
->
name
);
return
dndWriteMsgToWorker
(
pWorker
,
pMsg
,
sizeof
(
SNodeMsg
));
}
\ No newline at end of file
source/dnode/mgmt/main/src/dndMain.c
浏览文件 @
359482be
...
...
@@ -85,6 +85,7 @@ static int32_t dndRunDnode() {
int32_t
code
=
dndRun
(
pDnode
);
dInfo
(
"start shutting down the TDengine service"
);
global
.
pDnode
=
NULL
;
dndClose
(
pDnode
);
dndCleanup
();
taosCloseLog
();
...
...
source/os/src/osEnv.c
浏览文件 @
359482be
...
...
@@ -101,6 +101,8 @@ void osUpdate() {
}
}
void
osCleanup
()
{}
bool
osLogSpaceAvailable
()
{
return
tsLogSpace
.
reserved
<=
tsLogSpace
.
size
.
avail
;
}
void
osSetTimezone
(
const
char
*
timezone
)
{
taosSetSystemTimezone
(
tsTimezone
,
tsTimezone
,
&
tsDaylight
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录