Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
06a2b831
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看板
提交
06a2b831
编写于
3月 18, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shm
上级
326459ff
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
189 addition
and
38 deletion
+189
-38
include/dnode/snode/snode.h
include/dnode/snode/snode.h
+0
-1
source/dnode/mgmt/snode/inc/sm.h
source/dnode/mgmt/snode/inc/sm.h
+31
-0
source/dnode/mgmt/snode/inc/smInt.h
source/dnode/mgmt/snode/inc/smInt.h
+21
-31
source/dnode/mgmt/snode/src/smFile.c
source/dnode/mgmt/snode/src/smFile.c
+0
-0
source/dnode/mgmt/snode/src/smInt.c
source/dnode/mgmt/snode/src/smInt.c
+100
-3
source/dnode/mgmt/snode/src/smMsg.c
source/dnode/mgmt/snode/src/smMsg.c
+37
-3
source/dnode/mgmt/snode/src/smWorker.c
source/dnode/mgmt/snode/src/smWorker.c
+0
-0
未找到文件。
include/dnode/snode/snode.h
浏览文件 @
06a2b831
...
...
@@ -33,7 +33,6 @@ typedef struct {
}
SSnodeLoad
;
typedef
struct
{
int32_t
sver
;
int32_t
dnodeId
;
int64_t
clusterId
;
SMgmtWrapper
*
pWrapper
;
...
...
source/dnode/mgmt/snode/inc/sm.h
0 → 100644
浏览文件 @
06a2b831
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_DND_SNODE_H_
#define _TD_DND_SNODE_H_
#include "dnd.h"
#ifdef __cplusplus
extern
"C"
{
#endif
void
bmGetMgmtFp
(
SMgmtWrapper
*
pWrapper
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_DND_SNODE_H_*/
\ No newline at end of file
source/dnode/mgmt/snode/inc/smInt.h
浏览文件 @
06a2b831
...
...
@@ -16,47 +16,37 @@
#ifndef _TD_DND_SNODE_INT_H_
#define _TD_DND_SNODE_INT_H_
#include "
dnd
.h"
#include "
sm
.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
SSnodeMgmt
{
int32_t
refCount
;
int8_t
deployed
;
int8_t
dropped
;
int8_t
uniqueWorkerInUse
;
S
Snode
*
pSnode
;
SRWLatch
latch
;
SArray
*
uniqueWorkers
;
// SArray<SDnodeWorker*>
SDnodeWorker
sharedWorker
;
SSnode
*
pSnode
;
SDnode
*
pDnode
;
SMgmtWrapper
*
pWrapper
;
const
char
*
path
;
S
RWLatch
latch
;
int8_t
uniqueWorkerInUse
;
SArray
*
uniqueWorkers
;
// SArray<SDnodeWorker*>
SDnodeWorker
sharedWorker
;
}
SSnodeMgmt
;
void
smGetMgmtFp
(
SMgmtWrapper
*
pMgmt
);
// smInt.c
int32_t
smOpen
(
SMgmtWrapper
*
pWrapper
);
int32_t
smDrop
(
SMgmtWrapper
*
pWrapper
);
int32_t
dndInitSnode
(
SDnode
*
pDnode
);
void
dndCleanupSnode
(
SDnode
*
pDnode
);
void
dndProcessSnodeWriteMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
int32_t
smProcessCreateReq
(
SSnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
);
int32_t
smProcessDropReq
(
SSnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
);
void
smInitMsgHandles
(
SMgmtWrapper
*
pWrapper
);
int32_t
smStartWorker
(
SDnode
*
pDnode
);
void
smStopWorker
(
SDnode
*
pDnode
);
void
smInitMsgFp
(
SMnodeMgmt
*
pMgmt
);
void
smProcessRpcMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
int32_t
smPutMsgToWriteQueue
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
);
int32_t
smPutMsgToReadQueue
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
);
void
smConsumeChildQueue
(
SDnode
*
pDnode
,
SNodeMsg
*
pMsg
,
int32_t
msgLen
,
void
*
pCont
,
int32_t
contLen
);
void
smConsumeParentQueue
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
int32_t
msgLen
,
void
*
pCont
,
int32_t
contLen
);
void
smProcessWriteMsg
(
SDnode
*
pDnode
,
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
);
void
smProcessSyncMsg
(
SDnode
*
pDnode
,
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
);
void
smProcessReadMsg
(
SDnode
*
pDnode
,
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
);
// smMsg.c
void
smInitMsgHandles
(
SMgmtWrapper
*
pWrapper
);
int32_t
smProcessCreateReq
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
);
int32_t
smProcessDropReq
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
);
// smWorker.c
int32_t
smStartWorker
(
SQnodeMgmt
*
pMgmt
);
void
smStopWorker
(
SQnodeMgmt
*
pMgmt
);
int32_t
smProcessQueryMsg
(
SQnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
);
int32_t
smProcessFetchMsg
(
SQnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
);
#ifdef __cplusplus
}
...
...
source/dnode/mgmt/snode/src/smFile.c
已删除
100644 → 0
浏览文件 @
326459ff
source/dnode/mgmt/snode/src/smInt.c
浏览文件 @
06a2b831
...
...
@@ -18,13 +18,110 @@
static
int32_t
smRequire
(
SMgmtWrapper
*
pWrapper
,
bool
*
required
)
{
return
dndReadFile
(
pWrapper
,
required
);
}
static
void
smInitOption
(
SSnodeMgmt
*
pMgmt
,
SSnodeOpt
*
pOption
)
{
SDnode
*
pDnode
=
pMgmt
->
pDnode
;
pOption
->
pWrapper
=
pMgmt
->
pWrapper
;
pOption
->
sendReqFp
=
dndSendReqToDnode
;
pOption
->
sendMnodeReqFp
=
dndSendReqToMnode
;
pOption
->
dnodeId
=
pDnode
->
dnodeId
;
pOption
->
clusterId
=
pDnode
->
clusterId
;
}
static
int32_t
smOpenImp
(
SSnodeMgmt
*
pMgmt
)
{
SSnodeOpt
option
=
{
0
};
smInitOption
(
pMgmt
,
&
option
);
pMgmt
->
pSnode
=
sndOpen
(
pMgmt
->
path
,
&
option
);
if
(
pMgmt
->
pSnode
==
NULL
)
{
dError
(
"failed to open snode since %s"
,
terrstr
());
return
-
1
;
}
if
(
smStartWorker
(
pMgmt
)
!=
0
)
{
dError
(
"failed to start snode worker since %s"
,
terrstr
());
return
-
1
;
}
bool
deployed
=
true
;
if
(
dndWriteFile
(
pMgmt
->
pWrapper
,
deployed
)
!=
0
)
{
dError
(
"failed to write snode file since %s"
,
terrstr
());
return
-
1
;
}
return
0
;
}
static
void
smCloseImp
(
SSnodeMgmt
*
pMgmt
)
{
if
(
pMgmt
->
pSnode
!=
NULL
)
{
smStopWorker
(
pMgmt
);
sndClose
(
pMgmt
->
pSnode
);
pMgmt
->
pSnode
=
NULL
;
}
}
int32_t
smDrop
(
SMgmtWrapper
*
pWrapper
)
{
SSnodeMgmt
*
pMgmt
=
pWrapper
->
pMgmt
;
if
(
pMgmt
==
NULL
)
return
0
;
dInfo
(
"snode-mgmt start to drop"
);
bool
deployed
=
false
;
if
(
dndWriteFile
(
pWrapper
,
deployed
)
!=
0
)
{
dError
(
"failed to drop snode since %s"
,
terrstr
());
return
-
1
;
}
smCloseImp
(
pMgmt
);
taosRemoveDir
(
pMgmt
->
path
);
pWrapper
->
pMgmt
=
NULL
;
free
(
pMgmt
);
dInfo
(
"snode-mgmt is dropped"
);
return
0
;
}
static
void
smClose
(
SMgmtWrapper
*
pWrapper
)
{
SSnodeMgmt
*
pMgmt
=
pWrapper
->
pMgmt
;
if
(
pMgmt
==
NULL
)
return
;
dInfo
(
"snode-mgmt start to cleanup"
);
smCloseImp
(
pMgmt
);
pWrapper
->
pMgmt
=
NULL
;
free
(
pMgmt
);
dInfo
(
"snode-mgmt is cleaned up"
);
}
int32_t
smOpen
(
SMgmtWrapper
*
pWrapper
)
{
dInfo
(
"snode-mgmt start to init"
);
SSnodeMgmt
*
pMgmt
=
calloc
(
1
,
sizeof
(
SSnodeMgmt
));
if
(
pMgmt
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
pMgmt
->
path
=
pWrapper
->
path
;
pMgmt
->
pDnode
=
pWrapper
->
pDnode
;
pMgmt
->
pWrapper
=
pWrapper
;
pWrapper
->
pMgmt
=
pMgmt
;
int32_t
code
=
smOpenImp
(
pMgmt
);
if
(
code
!=
0
)
{
dError
(
"failed to init snode-mgmt since %s"
,
terrstr
());
smClose
(
pWrapper
);
}
else
{
dInfo
(
"snode-mgmt is initialized"
);
}
return
code
;
}
void
smGetMgmtFp
(
SMgmtWrapper
*
pWrapper
)
{
SMgmtFp
mgmtFp
=
{
0
};
mgmtFp
.
openFp
=
NULL
;
mgmtFp
.
closeFp
=
NULL
;
mgmtFp
.
openFp
=
smOpen
;
mgmtFp
.
closeFp
=
smClose
;
mgmtFp
.
createMsgFp
=
smProcessCreateReq
;
mgmtFp
.
dropMsgFp
=
smProcessDropReq
;
mgmtFp
.
requiredFp
=
smRequire
;
//
smInitMsgHandles(pWrapper);
smInitMsgHandles
(
pWrapper
);
pWrapper
->
name
=
"snode"
;
pWrapper
->
fp
=
mgmtFp
;
}
source/dnode/mgmt/snode/src/smMsg.c
浏览文件 @
06a2b831
...
...
@@ -16,8 +16,42 @@
#define _DEFAULT_SOURCE
#include "smInt.h"
int32_t
smProcessCreateReq
(
SSnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
return
0
;}
int32_t
smProcessDropReq
(
SSnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
return
0
;}
int32_t
smProcessCreateReq
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
)
{
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
SRpcMsg
*
pReq
=
&
pMsg
->
rpcMsg
;
void
smInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
SDCreateSnodeReq
createReq
=
{
0
};
if
(
tDeserializeSMCreateDropQSBNodeReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
createReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
if
(
createReq
.
dnodeId
!=
pDnode
->
dnodeId
)
{
terrno
=
TSDB_CODE_NODE_INVALID_OPTION
;
dError
(
"failed to create snode since %s, input:%d cur:%d"
,
terrstr
(),
createReq
.
dnodeId
,
pDnode
->
dnodeId
);
return
-
1
;
}
else
{
return
smOpen
(
pWrapper
);
}
}
int32_t
smProcessDropReq
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
)
{
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
SRpcMsg
*
pReq
=
&
pMsg
->
rpcMsg
;
SDDropSnodeReq
dropReq
=
{
0
};
if
(
tDeserializeSMCreateDropQSBNodeReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
dropReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
if
(
dropReq
.
dnodeId
!=
pDnode
->
dnodeId
)
{
terrno
=
TSDB_CODE_NODE_INVALID_OPTION
;
dError
(
"failed to drop snode since %s"
,
terrstr
());
return
-
1
;
}
else
{
return
smDrop
(
pWrapper
);
}
}
void
smInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{}
source/dnode/mgmt/snode/src/smWorker.c
已删除
100644 → 0
浏览文件 @
326459ff
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录