Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f76dbd58
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看板
提交
f76dbd58
编写于
10月 17, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
create file for mnode
上级
59dc24f7
变更
41
隐藏空白更改
内联
并排
Showing
41 changed file
with
742 addition
and
118 deletion
+742
-118
include/common/tglobal.h
include/common/tglobal.h
+0
-2
include/server/mnode/mnode.h
include/server/mnode/mnode.h
+1
-2
source/common/src/tglobal.c
source/common/src/tglobal.c
+0
-2
source/server/dnode/src/dnodeMain.c
source/server/dnode/src/dnodeMain.c
+1
-1
source/server/mnode/inc/mnodeAcct.h
source/server/mnode/inc/mnodeAcct.h
+3
-0
source/server/mnode/inc/mnodeAuth.h
source/server/mnode/inc/mnodeAuth.h
+3
-0
source/server/mnode/inc/mnodeBalance.h
source/server/mnode/inc/mnodeBalance.h
+3
-0
source/server/mnode/inc/mnodeCluster.h
source/server/mnode/inc/mnodeCluster.h
+3
-0
source/server/mnode/inc/mnodeDb.h
source/server/mnode/inc/mnodeDb.h
+3
-0
source/server/mnode/inc/mnodeDef.h
source/server/mnode/inc/mnodeDef.h
+294
-1
source/server/mnode/inc/mnodeDnode.h
source/server/mnode/inc/mnodeDnode.h
+3
-0
source/server/mnode/inc/mnodeFunc.h
source/server/mnode/inc/mnodeFunc.h
+6
-3
source/server/mnode/inc/mnodeMnode.h
source/server/mnode/inc/mnodeMnode.h
+3
-0
source/server/mnode/inc/mnodeOper.h
source/server/mnode/inc/mnodeOper.h
+30
-0
source/server/mnode/inc/mnodeProfile.h
source/server/mnode/inc/mnodeProfile.h
+32
-0
source/server/mnode/inc/mnodeSdb.h
source/server/mnode/inc/mnodeSdb.h
+7
-2
source/server/mnode/inc/mnodeShow.h
source/server/mnode/inc/mnodeShow.h
+32
-0
source/server/mnode/inc/mnodeStable.h
source/server/mnode/inc/mnodeStable.h
+32
-0
source/server/mnode/inc/mnodeSync.h
source/server/mnode/inc/mnodeSync.h
+3
-0
source/server/mnode/inc/mnodeUser.h
source/server/mnode/inc/mnodeUser.h
+3
-0
source/server/mnode/inc/mnodeVgroup.h
source/server/mnode/inc/mnodeVgroup.h
+3
-0
source/server/mnode/inc/mnodeWorker.h
source/server/mnode/inc/mnodeWorker.h
+3
-0
source/server/mnode/src/mnodeAcct.c
source/server/mnode/src/mnodeAcct.c
+3
-0
source/server/mnode/src/mnodeAuth.c
source/server/mnode/src/mnodeAuth.c
+3
-0
source/server/mnode/src/mnodeBalance.c
source/server/mnode/src/mnodeBalance.c
+3
-0
source/server/mnode/src/mnodeCluster.c
source/server/mnode/src/mnodeCluster.c
+3
-0
source/server/mnode/src/mnodeDb.c
source/server/mnode/src/mnodeDb.c
+3
-0
source/server/mnode/src/mnodeDnode.c
source/server/mnode/src/mnodeDnode.c
+3
-0
source/server/mnode/src/mnodeFunc.c
source/server/mnode/src/mnodeFunc.c
+3
-0
source/server/mnode/src/mnodeMnode.c
source/server/mnode/src/mnodeMnode.c
+3
-0
source/server/mnode/src/mnodeOper.c
source/server/mnode/src/mnodeOper.c
+3
-0
source/server/mnode/src/mnodeProfile.c
source/server/mnode/src/mnodeProfile.c
+21
-0
source/server/mnode/src/mnodeSdb.c
source/server/mnode/src/mnodeSdb.c
+29
-0
source/server/mnode/src/mnodeShow.c
source/server/mnode/src/mnodeShow.c
+21
-0
source/server/mnode/src/mnodeStable.c
source/server/mnode/src/mnodeStable.c
+21
-0
source/server/mnode/src/mnodeSync.c
source/server/mnode/src/mnodeSync.c
+3
-0
source/server/mnode/src/mnodeUser.c
source/server/mnode/src/mnodeUser.c
+3
-0
source/server/mnode/src/mnodeVgroup.c
source/server/mnode/src/mnodeVgroup.c
+21
-0
source/server/mnode/src/mnodeWorker.c
source/server/mnode/src/mnodeWorker.c
+3
-0
source/server/mnode/src/mondeInt.c
source/server/mnode/src/mondeInt.c
+121
-105
source/util/src/terror.c
source/util/src/terror.c
+4
-0
未找到文件。
include/common/tglobal.h
浏览文件 @
f76dbd58
...
...
@@ -151,8 +151,6 @@ extern int8_t tsPrintAuth;
extern
int8_t
tscEmbedded
;
extern
char
tsVnodeDir
[];
extern
char
tsMnodeDir
[];
extern
char
tsMnodeBakDir
[];
extern
char
tsMnodeTmpDir
[];
extern
int64_t
tsTickPerDay
[
3
];
extern
int32_t
tsTopicBianryLen
;
...
...
include/server/mnode/mnode.h
浏览文件 @
f76dbd58
...
...
@@ -79,10 +79,9 @@ void mnodeCleanup();
/**
* Deploy mnode instances in dnode.
*
* @param minfos, server information used to deploy the mnode instance.
* @return Error Code.
*/
int32_t
mnodeDeploy
(
struct
SMInfos
*
minfos
);
int32_t
mnodeDeploy
();
/**
* Delete the mnode instance deployed in dnode.
...
...
source/common/src/tglobal.c
浏览文件 @
f76dbd58
...
...
@@ -201,8 +201,6 @@ int8_t tscEmbedded = 0;
char
tsVnodeDir
[
PATH_MAX
]
=
{
0
};
char
tsDnodeDir
[
PATH_MAX
]
=
{
0
};
char
tsMnodeDir
[
PATH_MAX
]
=
{
0
};
char
tsMnodeTmpDir
[
PATH_MAX
]
=
{
0
};
char
tsMnodeBakDir
[
PATH_MAX
]
=
{
0
};
int32_t
tsDiskCfgNum
=
0
;
int32_t
tsTopicBianryLen
=
16000
;
...
...
source/server/dnode/src/dnodeMain.c
浏览文件 @
f76dbd58
...
...
@@ -237,7 +237,7 @@ static int32_t dnodeStartMnode(SRpcMsg *pMsg) {
if
(
mnodeIsServing
())
return
0
;
return
mnodeDeploy
(
&
pCfg
->
mnodes
);
return
mnodeDeploy
();
}
void
dnodeProcessCreateMnodeReq
(
SRpcMsg
*
pMsg
)
{
...
...
source/server/mnode/inc/mnodeAcct.h
浏览文件 @
f76dbd58
...
...
@@ -22,6 +22,9 @@
extern
"C"
{
#endif
int32_t
mnodeInitAcct
();
void
mnodeCleanupAcct
();
#ifdef __cplusplus
}
#endif
...
...
source/server/mnode/inc/mnodeAuth.h
浏览文件 @
f76dbd58
...
...
@@ -22,6 +22,9 @@
extern
"C"
{
#endif
int32_t
mnodeInitAuth
();
void
mnodeCleanupAuth
();
#ifdef __cplusplus
}
#endif
...
...
source/server/mnode/inc/mnodeBalance.h
浏览文件 @
f76dbd58
...
...
@@ -22,6 +22,9 @@
extern
"C"
{
#endif
int32_t
mnodeInitBalance
();
void
mnodeCleanupBalance
();
#ifdef __cplusplus
}
#endif
...
...
source/server/mnode/inc/mnodeCluster.h
浏览文件 @
f76dbd58
...
...
@@ -22,6 +22,9 @@
extern
"C"
{
#endif
int32_t
mnodeInitCluster
();
void
mnodeCleanupCluster
();
#ifdef __cplusplus
}
#endif
...
...
source/server/mnode/inc/mnodeDb.h
浏览文件 @
f76dbd58
...
...
@@ -22,6 +22,9 @@
extern
"C"
{
#endif
int32_t
mnodeInitDb
();
void
mnodeCleanupDb
();
#ifdef __cplusplus
}
#endif
...
...
source/server/mnode/inc/mnodeDef.h
浏览文件 @
f76dbd58
...
...
@@ -16,12 +16,305 @@
#ifndef _TD_MNODE_DEF_H_
#define _TD_MNODE_DEF_H_
#include "mnodeInt.h"
#include "taosmsg.h"
#include "tlog.h"
#include "trpc.h"
#include "ttimer.h"
#include "mnode.h"
#ifdef __cplusplus
extern
"C"
{
#endif
extern
int32_t
mDebugFlag
;
// mnode log function
#define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ", 255, __VA_ARGS__); }}
#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ", 255, __VA_ARGS__); }}
#define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("MND WARN ", 255, __VA_ARGS__); }}
#define mInfo(...) { if (mDebugFlag & DEBUG_INFO) { taosPrintLog("MND ", 255, __VA_ARGS__); }}
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }}
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }}
// #define mLError(...) { monSaveLog(2, __VA_ARGS__); mError(__VA_ARGS__) }
// #define mLWarn(...) { monSaveLog(1, __VA_ARGS__); mWarn(__VA_ARGS__) }
// #define mLInfo(...) { monSaveLog(0, __VA_ARGS__); mInfo(__VA_ARGS__) }
#define mLError(...) {mError(__VA_ARGS__) }
#define mLWarn(...) {mWarn(__VA_ARGS__) }
#define mLInfo(...) {mInfo(__VA_ARGS__) }
typedef
struct
SClusterObj
SClusterObj
;
typedef
struct
SDnodeObj
SDnodeObj
;
typedef
struct
SMnodeObj
SMnodeObj
;
typedef
struct
SAcctObj
SAcctObj
;
typedef
struct
SUserObj
SUserObj
;
typedef
struct
SDbObj
SDbObj
;
typedef
struct
SVgObj
SVgObj
;
typedef
struct
SSTableObj
SSTableObj
;
typedef
struct
SFuncObj
SFuncObj
;
typedef
struct
SOperObj
SOperObj
;
typedef
struct
SMnMsg
SMnMsg
;
typedef
enum
{
MN_SDB_START
=
0
,
MN_SDB_CLUSTER
=
1
,
MN_SDB_DNODE
=
2
,
MN_SDB_MNODE
=
3
,
MN_SDB_ACCT
=
4
,
MN_SDB_AUTH
=
5
,
MN_SDB_USER
=
6
,
MN_SDB_DB
=
7
,
MN_SDB_VGROUP
=
8
,
MN_SDB_STABLE
=
9
,
MN_SDB_FUNC
=
10
,
MN_SDB_OPER
=
11
,
MN_SDB_MAX
=
12
}
EMnSdb
;
typedef
enum
{
MN_OP_START
=
0
,
MN_OP_INSERT
=
1
,
MN_OP_UPDATE
=
2
,
MN_OP_DELETE
=
3
,
MN_OP_MAX
=
4
}
EMnOp
;
typedef
enum
{
MN_KEY_START
=
0
,
MN_KEY_BINARY
=
1
,
MN_KEY_INT32
=
2
,
MN_KEY_INT64
=
3
,
MN_KEY_MAX
}
EMnKey
;
typedef
enum
{
MN_AUTH_ACCT_START
=
0
,
MN_AUTH_ACCT_USER
,
MN_AUTH_ACCT_DNODE
,
MN_AUTH_ACCT_MNODE
,
MN_AUTH_ACCT_DB
,
MN_AUTH_ACCT_TABLE
,
MN_AUTH_ACCT_MAX
}
EMnAuthAcct
;
typedef
enum
{
MN_AUTH_OP_START
=
0
,
MN_AUTH_OP_CREATE_USER
,
MN_AUTH_OP_ALTER_USER
,
MN_AUTH_OP_DROP_USER
,
MN_AUTH_MAX
}
EMnAuthOp
;
typedef
enum
{
MN_STATUS_UNINIT
=
0
,
MN_STATUS_INIT
=
1
,
MN_STATUS_READY
=
2
,
MN_STATUS_CLOSING
=
3
}
EMnStatus
;
typedef
struct
SClusterObj
{
int64_t
id
;
char
uid
[
TSDB_CLUSTER_ID_LEN
];
int64_t
createdTime
;
int64_t
updateTime
;
}
SClusterObj
;
typedef
struct
SDnodeObj
{
int32_t
id
;
int32_t
vnodes
;
int64_t
createdTime
;
int64_t
updateTime
;
int64_t
lastAccess
;
int64_t
lastReboot
;
// time stamp for last reboot
char
fqdn
[
TSDB_FQDN_LEN
];
char
ep
[
TSDB_EP_LEN
];
uint16_t
port
;
int16_t
numOfCores
;
// from dnode status msg
int8_t
alternativeRole
;
// from dnode status msg, 0-any, 1-mgmt, 2-dnode
int8_t
status
;
// set in balance function
int8_t
offlineReason
;
}
SDnodeObj
;
typedef
struct
SMnodeObj
{
int32_t
id
;
int8_t
status
;
int8_t
role
;
int32_t
roleTerm
;
int64_t
roleTime
;
int64_t
createdTime
;
int64_t
updateTime
;
SDnodeObj
*
pDnode
;
}
SMnodeObj
;
typedef
struct
{
int32_t
maxUsers
;
int32_t
maxDbs
;
int32_t
maxTimeSeries
;
int32_t
maxConnections
;
int32_t
maxStreams
;
int32_t
maxPointsPerSecond
;
int64_t
maxStorage
;
// In unit of GB
int64_t
maxQueryTime
;
// In unit of hour
int64_t
maxInbound
;
int64_t
maxOutbound
;
int8_t
accessState
;
// Configured only by command
}
SAcctCfg
;
typedef
struct
{
int64_t
totalStorage
;
// Total storage wrtten from this account
int64_t
compStorage
;
// Compressed storage on disk
int64_t
queryTime
;
int64_t
totalPoints
;
int64_t
inblound
;
int64_t
outbound
;
int64_t
sKey
;
int32_t
numOfUsers
;
int32_t
numOfDbs
;
int32_t
numOfTimeSeries
;
int32_t
numOfPointsPerSecond
;
int32_t
numOfConns
;
int32_t
numOfQueries
;
int32_t
numOfStreams
;
int8_t
accessState
;
// Checked by mgmt heartbeat message
}
SAcctInfo
;
typedef
struct
SAcctObj
{
char
acct
[
TSDB_USER_LEN
];
int64_t
createdTime
;
int64_t
updateTime
;
int32_t
acctId
;
int8_t
status
;
SAcctCfg
cfg
;
SAcctInfo
info
;
}
SAcctObj
;
typedef
struct
SUserObj
{
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_KEY_LEN
];
char
acct
[
TSDB_USER_LEN
];
int64_t
createdTime
;
int64_t
updateTime
;
int8_t
rootAuth
;
SAcctObj
*
pAcct
;
}
SUserObj
;
typedef
struct
{
int32_t
cacheBlockSize
;
int32_t
totalBlocks
;
int32_t
maxTables
;
int32_t
daysPerFile
;
int32_t
daysToKeep0
;
int32_t
daysToKeep1
;
int32_t
daysToKeep2
;
int32_t
minRowsPerFileBlock
;
int32_t
maxRowsPerFileBlock
;
int32_t
commitTime
;
int32_t
fsyncPeriod
;
int8_t
precision
;
int8_t
compression
;
int8_t
walLevel
;
int8_t
replications
;
int8_t
quorum
;
int8_t
update
;
int8_t
cacheLastRow
;
int8_t
dbType
;
int16_t
partitions
;
}
SDbCfg
;
typedef
struct
SDbObj
{
char
name
[
TSDB_ACCT_ID_LEN
+
TSDB_DB_NAME_LEN
];
char
acct
[
TSDB_USER_LEN
];
int64_t
createdTime
;
int64_t
updateTime
;
SDbCfg
cfg
;
int8_t
status
;
int32_t
numOfVgroups
;
int32_t
numOfTables
;
int32_t
numOfSuperTables
;
int32_t
vgListSize
;
int32_t
vgListIndex
;
SVgObj
**
vgList
;
SAcctObj
*
pAcct
;
}
SDbObj
;
typedef
struct
{
int32_t
dnodeId
;
int8_t
role
;
SDnodeObj
*
pDnode
;
}
SVnodeGid
;
typedef
struct
SVgObj
{
uint32_t
vgId
;
int32_t
numOfVnodes
;
int64_t
createdTime
;
int64_t
updateTime
;
int32_t
lbDnodeId
;
int32_t
lbTime
;
char
dbName
[
TSDB_ACCT_ID_LEN
+
TSDB_DB_NAME_LEN
];
int8_t
inUse
;
int8_t
accessState
;
int8_t
status
;
SVnodeGid
vnodeGid
[
TSDB_MAX_REPLICA
];
int32_t
vgCfgVersion
;
int8_t
compact
;
int32_t
numOfTables
;
int64_t
totalStorage
;
int64_t
compStorage
;
int64_t
pointsWritten
;
SDbObj
*
pDb
;
}
SVgObj
;
typedef
struct
SSTableObj
{
char
tableId
[
TSDB_TABLE_NAME_LEN
];
uint64_t
uid
;
int64_t
createdTime
;
int64_t
updateTime
;
int32_t
numOfColumns
;
// used by normal table
int32_t
numOfTags
;
SSchema
*
schema
;
}
SSTableObj
;
typedef
struct
SFuncObj
{
char
name
[
TSDB_FUNC_NAME_LEN
];
char
path
[
128
];
int32_t
contLen
;
char
cont
[
TSDB_FUNC_CODE_LEN
];
int32_t
funcType
;
int32_t
bufSize
;
int64_t
createdTime
;
uint8_t
resType
;
int16_t
resBytes
;
int64_t
sig
;
int16_t
type
;
}
SFuncObj
;
typedef
struct
{
int8_t
type
;
int8_t
maxReplica
;
int16_t
numOfColumns
;
int32_t
index
;
int32_t
rowSize
;
int32_t
numOfRows
;
int32_t
numOfReads
;
uint16_t
payloadLen
;
void
*
pIter
;
void
*
pVgIter
;
void
**
ppShow
;
char
db
[
TSDB_ACCT_ID_LEN
+
TSDB_DB_NAME_LEN
];
int16_t
offset
[
TSDB_MAX_COLUMNS
];
int32_t
bytes
[
TSDB_MAX_COLUMNS
];
char
payload
[];
}
SShowObj
;
typedef
struct
{
int32_t
len
;
void
*
rsp
;
}
SMnRsp
;
typedef
struct
SMnMsg
{
void
(
*
fp
)(
SMnMsg
*
pMsg
,
int32_t
code
);
SUserObj
*
pUser
;
int16_t
received
;
int16_t
successed
;
int16_t
expected
;
int16_t
retry
;
int32_t
code
;
int64_t
createdTime
;
SMnRsp
rpcRsp
;
SRpcMsg
rpcMsg
;
char
pCont
[];
}
SMnReq
;
#ifdef __cplusplus
}
#endif
...
...
source/server/mnode/inc/mnodeDnode.h
浏览文件 @
f76dbd58
...
...
@@ -22,6 +22,9 @@
extern
"C"
{
#endif
int32_t
mnodeInitDnode
();
void
mnodeCleanupDnode
();
#ifdef __cplusplus
}
#endif
...
...
source/server/mnode/inc/mnode
Table
.h
→
source/server/mnode/inc/mnode
Func
.h
浏览文件 @
f76dbd58
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_MNODE_
TABLE
_H_
#define _TD_MNODE_
TABLE
_H_
#ifndef _TD_MNODE_
FUNC
_H_
#define _TD_MNODE_
FUNC
_H_
#include "mnodeInt.h"
...
...
@@ -22,8 +22,11 @@
extern
"C"
{
#endif
int32_t
mnodeInitFunc
();
void
mnodeCleanupFunc
();
#ifdef __cplusplus
}
#endif
#endif
/*_TD_MNODE_
TABLE
_H_*/
#endif
/*_TD_MNODE_
FUNC
_H_*/
source/server/mnode/inc/mnodeMnode.h
浏览文件 @
f76dbd58
...
...
@@ -22,6 +22,9 @@
extern
"C"
{
#endif
int32_t
mnodeInitMnode
();
void
mnodeCleanupMnode
();
#ifdef __cplusplus
}
#endif
...
...
source/server/mnode/inc/mnodeOper.h
0 → 100644
浏览文件 @
f76dbd58
/*
* 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_MNODE_OPER_H_
#define _TD_MNODE_OPER_H_
#ifdef __cplusplus
extern
"C"
{
#endif
int32_t
mnodeInitOper
();
void
mnodeCleanupOper
();
#ifdef __cplusplus
}
#endif
#endif
/*_TD_MNODE_OPER_H_*/
source/server/mnode/inc/mnodeProfile.h
0 → 100644
浏览文件 @
f76dbd58
/*
* 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_MNODE_PROFILE_H_
#define _TD_MNODE_PROFILE_H_
#include "mnodeInt.h"
#ifdef __cplusplus
extern
"C"
{
#endif
int32_t
mnodeInitProfile
();
void
mnodeCleanupProfile
();
#ifdef __cplusplus
}
#endif
#endif
/*_TD_MNODE_PROFILE_H_*/
source/server/mnode/inc/mnodeSdb.h
浏览文件 @
f76dbd58
...
...
@@ -22,9 +22,14 @@
extern
"C"
{
#endif
int32_t
sdbInit
();
void
sdbCleanup
();
int32_t
mnodeInitSdb
();
void
mnodeCleanupSdb
();
int32_t
mnodeDeploySdb
();
void
mnodeUnDeploySdb
();
int32_t
mnodeReadSdb
();
int32_t
mnodeCommitSdb
();
#ifdef __cplusplus
}
...
...
source/server/mnode/inc/mnodeShow.h
0 → 100644
浏览文件 @
f76dbd58
/*
* 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_MNODE_SHOW_H_
#define _TD_MNODE_SHOW_H_
#include "mnodeInt.h"
#ifdef __cplusplus
extern
"C"
{
#endif
int32_t
mnodeInitShow
();
void
mnodeCleanUpShow
();
#ifdef __cplusplus
}
#endif
#endif
/*_TD_MNODE_SHOW_H_*/
source/server/mnode/inc/mnodeStable.h
0 → 100644
浏览文件 @
f76dbd58
/*
* 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_MNODE_STABLE_H_
#define _TD_MNODE_STABLE_H_
#include "mnodeInt.h"
#ifdef __cplusplus
extern
"C"
{
#endif
int32_t
mnodeInitStable
();
void
mnodeCleanupStable
();
#ifdef __cplusplus
}
#endif
#endif
/*_TD_MNODE_STABLE_H_*/
source/server/mnode/inc/mnodeSync.h
浏览文件 @
f76dbd58
...
...
@@ -22,6 +22,9 @@
extern
"C"
{
#endif
int32_t
mnodeInitSync
();
void
mnodeCleanUpSync
();
#ifdef __cplusplus
}
#endif
...
...
source/server/mnode/inc/mnodeUser.h
浏览文件 @
f76dbd58
...
...
@@ -22,6 +22,9 @@
extern
"C"
{
#endif
int32_t
mnodeInitUser
();
void
mnodeCleanupUser
();
#ifdef __cplusplus
}
#endif
...
...
source/server/mnode/inc/mnodeVgroup.h
浏览文件 @
f76dbd58
...
...
@@ -22,6 +22,9 @@
extern
"C"
{
#endif
int32_t
mnodeInitVgroup
();
void
mnodeCleanupVgroup
();
#ifdef __cplusplus
}
#endif
...
...
source/server/mnode/inc/mnodeWorker.h
浏览文件 @
f76dbd58
...
...
@@ -22,6 +22,9 @@
extern
"C"
{
#endif
int32_t
mnodeInitWorker
();
void
mnodeCleanupWorker
();
#ifdef __cplusplus
}
#endif
...
...
source/server/mnode/src/mnodeAcct.c
浏览文件 @
f76dbd58
...
...
@@ -16,3 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitAcct
()
{
return
0
;
}
void
mnodeCleanupAcct
()
{}
source/server/mnode/src/mnodeAuth.c
浏览文件 @
f76dbd58
...
...
@@ -16,3 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitAuth
()
{
return
0
;
}
void
mnodeCleanupAuth
()
{}
\ No newline at end of file
source/server/mnode/src/mnodeBalance.c
浏览文件 @
f76dbd58
...
...
@@ -16,3 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitBalance
()
{
return
0
;
}
void
mnodeCleanupBalance
()
{}
\ No newline at end of file
source/server/mnode/src/mnodeCluster.c
浏览文件 @
f76dbd58
...
...
@@ -16,3 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitCluster
()
{
return
0
;
}
void
mnodeCleanupCluster
()
{}
\ No newline at end of file
source/server/mnode/src/mnodeDb.c
浏览文件 @
f76dbd58
...
...
@@ -16,3 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitDb
()
{
return
0
;
}
void
mnodeCleanupDb
()
{}
\ No newline at end of file
source/server/mnode/src/mnodeDnode.c
浏览文件 @
f76dbd58
...
...
@@ -16,3 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitDnode
()
{
return
0
;
}
void
mnodeCleanupDnode
()
{}
\ No newline at end of file
source/server/mnode/src/mnode
Table
.c
→
source/server/mnode/src/mnode
Func
.c
浏览文件 @
f76dbd58
...
...
@@ -16,3 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitFunc
()
{
return
0
;
}
void
mnodeCleanupFunc
()
{}
\ No newline at end of file
source/server/mnode/src/mnodeMnode.c
浏览文件 @
f76dbd58
...
...
@@ -16,3 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitMnode
()
{
return
0
;
}
void
mnodeCleanupMnode
()
{}
\ No newline at end of file
source/server/mnode/src/mnode
Vgruop
.c
→
source/server/mnode/src/mnode
Oper
.c
浏览文件 @
f76dbd58
...
...
@@ -16,3 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitOper
()
{
return
0
;
}
void
mnodeCleanupOper
()
{}
\ No newline at end of file
source/server/mnode/src/mnodeProfile.c
0 → 100644
浏览文件 @
f76dbd58
/*
* 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/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitProfile
()
{
return
0
;
}
void
mnodeCleanupProfile
()
{}
\ No newline at end of file
source/server/mnode/src/mnodeSdb.c
浏览文件 @
f76dbd58
...
...
@@ -16,3 +16,32 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitSdb
()
{
return
0
;
}
void
mnodeCleanupSdb
()
{}
int32_t
mnodeDeploySdb
()
{
// if (!taosMkDir())
// if (pMinfos == NULL) { // first deploy
// tsMint.dnodeId = 1;
// bool getuid = taosGetSystemUid(tsMint.clusterId);
// if (!getuid) {
// strcpy(tsMint.clusterId, "tdengine3.0");
// mError("deploy new mnode but failed to get uid, set to default val %s", tsMint.clusterId);
// } else {
// mDebug("deploy new mnode and uid is %s", tsMint.clusterId);
// }
// } else { // todo
// }
// if (mkdir(tsMnodeDir, 0755) != 0 && errno != EEXIST) {
// mError("failed to init mnode dir:%s, reason:%s", tsMnodeDir, strerror(errno));
// return -1;
// }
return
0
;
}
void
mnodeUnDeploySdb
()
{}
int32_t
mnodeReadSdb
()
{
return
0
;
}
int32_t
mnodeCommitSdb
()
{
return
0
;
}
\ No newline at end of file
source/server/mnode/src/mnodeShow.c
0 → 100644
浏览文件 @
f76dbd58
/*
* 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/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitShow
()
{
return
0
;
}
void
mnodeCleanUpShow
()
{}
\ No newline at end of file
source/server/mnode/src/mnodeStable.c
0 → 100644
浏览文件 @
f76dbd58
/*
* 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/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitStable
()
{
return
0
;
}
void
mnodeCleanupStable
()
{}
\ No newline at end of file
source/server/mnode/src/mnodeSync.c
浏览文件 @
f76dbd58
...
...
@@ -16,3 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitSync
()
{
return
0
;
}
void
mnodeCleanUpSync
()
{}
\ No newline at end of file
source/server/mnode/src/mnodeUser.c
浏览文件 @
f76dbd58
...
...
@@ -16,3 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitUser
()
{
return
0
;
}
void
mnodeCleanupUser
()
{}
\ No newline at end of file
source/server/mnode/src/mnodeVgroup.c
0 → 100644
浏览文件 @
f76dbd58
/*
* 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/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitVgroup
()
{
return
0
;
}
void
mnodeCleanupVgroup
()
{}
\ No newline at end of file
source/server/mnode/src/mnodeWorker.c
浏览文件 @
f76dbd58
...
...
@@ -16,3 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnodeInt.h"
int32_t
mnodeInitWorker
()
{
return
0
;
}
void
mnodeCleanupWorker
()
{}
\ No newline at end of file
source/server/mnode/src/mondeInt.c
浏览文件 @
f76dbd58
...
...
@@ -17,22 +17,23 @@
#include "os.h"
#include "tglobal.h"
#include "tstep.h"
#include "mnodeInt.h"
#include "mnodeAcct.h"
#include "mnodeAuth.h"
#include "mnodeBalance.h"
#include "mnodeCluster.h"
#include "mnodeDb.h"
#include "mnodeDnode.h"
#include "mnodeFunc.h"
#include "mnodeMnode.h"
#include "mnodeOper.h"
#include "mnodeProfile.h"
#include "mnodeSdb.h"
#include "mnodeShow.h"
#include "mnodeTable.h"
#include "mnodeStable.h"
#include "mnodeSync.h"
#include "mnodeUser.h"
#include "mnodeVgroup.h"
#include "mnodeWorker.h"
#include "mnodeDb.h"
#include "mnodeRaft.h"
static
struct
{
int32_t
state
;
...
...
@@ -40,7 +41,8 @@ static struct {
char
clusterId
[
TSDB_CLUSTER_ID_LEN
];
tmr_h
timer
;
SMnodeFp
fp
;
SSteps
*
steps
;
SSteps
*
steps1
;
SSteps
*
steps2
;
}
tsMint
;
tmr_h
mnodeGetTimer
()
{
return
tsMint
.
timer
;
}
...
...
@@ -49,7 +51,7 @@ int32_t mnodeGetDnodeId() { return tsMint.dnodeId; }
char
*
mnodeGetClusterId
()
{
return
tsMint
.
clusterId
;
}
bool
mnodeIsServing
()
{
return
tsMint
.
state
==
TAOS_
MN_STATUS_READY
;
}
bool
mnodeIsServing
()
{
return
tsMint
.
state
==
MN_STATUS_READY
;
}
void
mnodeSendMsgToDnode
(
struct
SRpcEpSet
*
epSet
,
struct
SRpcMsg
*
rpcMsg
)
{
(
*
tsMint
.
fp
.
SendMsgToDnode
)(
epSet
,
rpcMsg
);
...
...
@@ -75,50 +77,6 @@ static int32_t mnodeSetPara(SMnodePara para) {
return
0
;
}
static
bool
mnodeNeedDeploy
()
{
if
(
tsMint
.
dnodeId
>
0
)
return
false
;
if
(
tsMint
.
clusterId
[
0
]
!=
0
)
return
false
;
if
(
strcmp
(
tsFirst
,
tsLocalEp
)
!=
0
)
return
false
;
return
true
;
}
static
bool
mnodeIsDeployed
()
{
struct
stat
dirstat
;
char
filename
[
PATH_MAX
+
20
]
=
{
0
};
snprintf
(
filename
,
sizeof
(
filename
),
"%s/wal/wal0"
,
tsMnodeDir
);
return
(
stat
(
filename
,
&
dirstat
)
==
0
);
}
int32_t
mnodeDeploy
(
struct
SMInfos
*
pMinfos
)
{
if
(
pMinfos
==
NULL
)
{
// first deploy
tsMint
.
dnodeId
=
1
;
bool
getuid
=
taosGetSystemUid
(
tsMint
.
clusterId
);
if
(
!
getuid
)
{
strcpy
(
tsMint
.
clusterId
,
"tdengine3.0"
);
mError
(
"deploy new mnode but failed to get uid, set to default val %s"
,
tsMint
.
clusterId
);
}
else
{
mDebug
(
"deploy new mnode and uid is %s"
,
tsMint
.
clusterId
);
}
}
else
{
// todo
}
if
(
mkdir
(
tsMnodeDir
,
0755
)
!=
0
&&
errno
!=
EEXIST
)
{
mError
(
"failed to init mnode dir:%s, reason:%s"
,
tsMnodeDir
,
strerror
(
errno
));
return
-
1
;
}
return
0
;
}
void
mnodeUnDeploy
()
{
if
(
remove
(
tsMnodeDir
)
!=
0
)
{
mInfo
(
"failed to remove mnode file, reason:%s"
,
strerror
(
errno
));
}
else
{
mInfo
(
"mnode file is removed"
);
}
}
static
int32_t
mnodeInitTimer
()
{
if
(
tsMint
.
timer
==
NULL
)
{
tsMint
.
timer
=
taosTmrInit
(
tsMaxShellConns
,
200
,
3600000
,
"MND"
);
...
...
@@ -134,95 +92,153 @@ static void mnodeCleanupTimer() {
}
}
static
int32_t
mnodeInitStep
s
()
{
struct
SSteps
*
steps
=
taosStepInit
(
20
,
NULL
);
static
int32_t
mnodeInitStep
1
()
{
struct
SSteps
*
steps
=
taosStepInit
(
16
,
NULL
);
if
(
steps
==
NULL
)
return
-
1
;
taosStepAdd
(
steps
,
"mnode-timer"
,
mnodeInitTimer
,
NULL
);
taosStepAdd
(
steps
,
"mnode-worker"
,
mnodeInitWorker
,
NULL
);
taosStepAdd
(
steps
,
"mnode-sdbref"
,
sdbInitRef
,
sdbCleanUpRef
);
taosStepAdd
(
steps
,
"mnode-profile"
,
mnodeInitProfile
,
mnodeCleanupProfile
);
taosStepAdd
(
steps
,
"mnode-funcs"
,
mnodeInitFuncs
,
mnodeCleanupFuncs
);
taosStepAdd
(
steps
,
"mnode-dnodes"
,
mnodeInitDnodes
,
mnodeCleanupDnodes
);
taosStepAdd
(
steps
,
"mnode-dbs"
,
mnodeInitDbs
,
mnodeCleanupDbs
);
taosStepAdd
(
steps
,
"mnode-vgroups"
,
mnodeInitVgroups
,
mnodeCleanupVgroups
);
taosStepAdd
(
steps
,
"mnode-tables"
,
mnodeInitTables
,
mnodeCleanupTables
);
taosStepAdd
(
steps
,
"mnode-mnodes"
,
mnodeInitMnodes
,
mnodeCleanupMnodes
);
taosStepAdd
(
steps
,
"mnode-sdb"
,
sdbInit
,
sdbCleanUp
);
taosStepAdd
(
steps
,
"mnode-balance"
,
bnInit
,
bnCleanUp
);
taosStepAdd
(
steps
,
"mnode-grant"
,
grantInit
,
grantCleanUp
);
taosStepAdd
(
steps
,
"mnode-show"
,
mnodeInitShow
,
mnodeCleanUpShow
);
taosStepAdd
(
steps
,
"mnode-kv"
,
mnodeInitKv
,
mnodeCleanupKv
);
taosStepAdd
(
steps
,
"mnode-raft"
,
mnodeInitRaft
,
mnodeCleanupRaft
);
taosStepAdd
(
steps
,
"mnode-sdb"
,
mnodeInitSdb
,
mnodeCleanupSdb
);
taosStepAdd
(
steps
,
"mnode-cluster"
,
mnodeInitCluster
,
mnodeCleanupCluster
);
taosStepAdd
(
steps
,
"mnode-users"
,
mnodeInitUsers
,
mnodeCleanupUsers
);
taosStepAdd
(
steps
,
"mnode-worker"
,
NULL
,
mnodeCleanupWorker
);
taosStepAdd
(
steps
,
"mnode-timer"
,
NULL
,
mnodeCleanupTimer
);
taosStepAdd
(
steps
,
"mnode-dnode"
,
mnodeInitDnode
,
mnodeCleanupDnode
);
taosStepAdd
(
steps
,
"mnode-mnode"
,
mnodeInitMnode
,
mnodeCleanupMnode
);
taosStepAdd
(
steps
,
"mnode-acct"
,
mnodeInitAcct
,
mnodeCleanupAcct
);
taosStepAdd
(
steps
,
"mnode-auth"
,
mnodeInitAuth
,
mnodeCleanupAuth
);
taosStepAdd
(
steps
,
"mnode-user"
,
mnodeInitUser
,
mnodeCleanupUser
);
taosStepAdd
(
steps
,
"mnode-db"
,
mnodeInitDb
,
mnodeCleanupDb
);
taosStepAdd
(
steps
,
"mnode-vgroup"
,
mnodeInitVgroup
,
mnodeCleanupVgroup
);
taosStepAdd
(
steps
,
"mnode-stable"
,
mnodeInitStable
,
mnodeCleanupStable
);
taosStepAdd
(
steps
,
"mnode-func"
,
mnodeInitFunc
,
mnodeCleanupFunc
);
taosStepAdd
(
steps
,
"mnode-oper"
,
mnodeInitOper
,
mnodeCleanupOper
);
tsMint
.
steps1
=
steps
;
return
taosStepExec
(
tsMint
.
steps1
);
}
static
int32_t
mnodeInitStep2
()
{
struct
SSteps
*
steps
=
taosStepInit
(
12
,
NULL
);
if
(
steps
==
NULL
)
return
-
1
;
taosStepAdd
(
steps
,
"mnode-timer"
,
mnodeInitTimer
,
NULL
);
taosStepAdd
(
steps
,
"mnode-worker"
,
mnodeInitWorker
,
NULL
);
taosStepAdd
(
steps
,
"mnode-balance"
,
mnodeInitBalance
,
mnodeCleanupBalance
);
taosStepAdd
(
steps
,
"mnode-profile"
,
mnodeInitProfile
,
mnodeCleanupProfile
);
taosStepAdd
(
steps
,
"mnode-show"
,
mnodeInitShow
,
mnodeCleanUpShow
);
taosStepAdd
(
steps
,
"mnode-sync"
,
mnodeInitSync
,
mnodeCleanUpSync
);
taosStepAdd
(
steps
,
"mnode-worker"
,
NULL
,
mnodeCleanupWorker
);
taosStepAdd
(
steps
,
"mnode-timer"
,
NULL
,
mnodeCleanupTimer
);
tsMint
.
steps2
=
steps
;
return
taosStepExec
(
tsMint
.
steps2
);
}
tsMint
.
steps
=
steps
;
return
taosStepExec
(
tsMint
.
steps
);
static
void
mnodeCleanupStep1
()
{
taosStepCleanup
(
tsMint
.
steps1
);
}
static
void
mnodeCleanupStep2
()
{
taosStepCleanup
(
tsMint
.
steps2
);
}
static
bool
mnodeNeedDeploy
()
{
if
(
tsMint
.
dnodeId
>
0
)
return
false
;
if
(
tsMint
.
clusterId
[
0
]
!=
0
)
return
false
;
if
(
strcmp
(
tsFirst
,
tsLocalEp
)
!=
0
)
return
false
;
return
true
;
}
static
void
mnodeCleanupSteps
()
{
taosStepCleanup
(
tsMint
.
steps
);
}
int32_t
mnodeDeploy
()
{
if
(
tsMint
.
state
!=
MN_STATUS_UNINIT
)
{
mError
(
"failed to deploy mnode since its deployed"
);
return
0
;
}
else
{
tsMint
.
state
=
MN_STATUS_INIT
;
}
if
(
tsMint
.
dnodeId
<=
0
||
tsMint
.
clusterId
[
0
]
==
0
)
{
mError
(
"failed to deploy mnode since cluster not ready"
);
return
TSDB_CODE_MND_NOT_READY
;
}
mInfo
(
"starting to deploy mnode"
);
int32_t
code
=
mnodeInitStep1
();
if
(
code
!=
0
)
{
mError
(
"failed to deploy mnode since init step1 error"
);
tsMint
.
state
=
MN_STATUS_UNINIT
;
return
TSDB_CODE_MND_SDB_ERROR
;
}
code
=
mnodeInitStep2
();
if
(
code
!=
0
)
{
mnodeCleanupStep1
();
mError
(
"failed to deploy mnode since init step2 error"
);
tsMint
.
state
=
MN_STATUS_UNINIT
;
return
TSDB_CODE_MND_SDB_ERROR
;
}
mDebug
(
"mnode is deployed and waiting for raft to confirm"
);
tsMint
.
state
=
MN_STATUS_READY
;
return
0
;
}
void
mnodeUnDeploy
()
{
mnodeUnDeploySdb
();
mnodeCleanup
();
}
int32_t
mnodeInit
(
SMnodePara
para
)
{
int32_t
code
=
0
;
if
(
tsMint
.
state
!=
TAOS_MN_STATUS_UNINIT
)
{
if
(
tsMint
.
state
!=
MN_STATUS_UNINIT
)
{
return
0
;
}
else
{
tsMint
.
state
=
TAOS_
MN_STATUS_INIT
;
tsMint
.
state
=
MN_STATUS_INIT
;
}
code
=
mnodeSetPara
(
para
);
mInfo
(
"starting to initialize mnode ..."
);
int32_t
code
=
mnodeSetPara
(
para
);
if
(
code
!=
0
)
{
tsMint
.
state
=
TAOS_
MN_STATUS_UNINIT
;
tsMint
.
state
=
MN_STATUS_UNINIT
;
return
code
;
}
bool
needDeploy
=
mnodeNeedDeploy
();
bool
deployed
=
mnodeIsDeployed
();
code
=
mnodeInitStep1
();
if
(
code
!=
0
)
{
tsMint
.
state
=
MN_STATUS_UNINIT
;
return
-
1
;
}
if
(
!
deployed
)
{
if
(
needDeploy
)
{
code
=
mnodeDeploy
(
NULL
);
code
=
mnodeReadSdb
();
if
(
code
!=
0
)
{
if
(
mnodeNeedDeploy
())
{
code
=
mnodeDeploySdb
();
if
(
code
!=
0
)
{
tsMint
.
state
=
TAOS_MN_STATUS_UNINIT
;
return
code
;
mnodeCleanupStep1
();
tsMint
.
state
=
MN_STATUS_UNINIT
;
return
-
1
;
}
}
else
{
tsMint
.
state
=
TAOS_MN_STATUS_UNINIT
;
return
0
;
mnodeCleanupStep1
();
tsMint
.
state
=
MN_STATUS_UNINIT
;
return
-
1
;
}
}
mInfo
(
"starting to initialize mnode ..."
);
code
=
mnodeInitSteps
();
code
=
mnodeInitStep2
();
if
(
code
!=
0
)
{
tsMint
.
state
=
TAOS_MN_STATUS_UNINIT
;
mnodeCleanupStep1
();
tsMint
.
state
=
MN_STATUS_UNINIT
;
return
-
1
;
}
// todo
grantReset
(
TSDB_GRANT_ALL
,
0
);
sdbUpdateSync
(
NULL
);
tsMint
.
state
=
TAOS_MN_STATUS_READY
;
tsMint
.
state
=
MN_STATUS_READY
;
mInfo
(
"mnode is initialized successfully"
);
return
0
;
}
void
mnodeCleanup
()
{
if
(
tsMint
.
state
!=
TAOS_MN_STATUS_UNINIT
&&
tsMint
.
state
!=
TAOS_
MN_STATUS_CLOSING
)
{
if
(
tsMint
.
state
!=
MN_STATUS_UNINIT
&&
tsMint
.
state
!=
MN_STATUS_CLOSING
)
{
mInfo
(
"starting to clean up mnode"
);
tsMint
.
state
=
TAOS_MN_STATUS_CLOSING
;
mnodeCleanupSteps
();
tsMint
.
state
=
MN_STATUS_CLOSING
;
mnodeCleanupStep2
();
mnodeCleanupStep1
();
tsMint
.
state
=
TAOS_
MN_STATUS_UNINIT
;
tsMint
.
state
=
MN_STATUS_UNINIT
;
mInfo
(
"mnode is cleaned up"
);
}
}
...
...
source/util/src/terror.c
浏览文件 @
f76dbd58
...
...
@@ -177,6 +177,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_PASS_FORMAT, "Invalid password form
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_NO_USER_FROM_CONN
,
"Can not get user from conn"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TOO_MANY_USERS
,
"Too many users"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_MNODE_ALREADY_EXIST
,
"Mnode already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_MNODE_NOT_EXIST
,
"Mnode not there"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TABLE_ALREADY_EXIST
,
"Table already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_TABLE_ID
,
"Table name too long"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_TABLE_NAME
,
"Table does not exist"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录