Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
codyshao
TDengine
提交
4b7e463b
T
TDengine
项目概览
codyshao
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
2
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4b7e463b
编写于
3月 19, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-15] refactor sdb
上级
75bd0eba
变更
23
展开全部
隐藏空白更改
内联
并排
Showing
23 changed file
with
300 addition
and
628 deletion
+300
-628
src/inc/mnode.h
src/inc/mnode.h
+0
-1
src/inc/sdb.h
src/inc/sdb.h
+0
-131
src/inc/taosdef.h
src/inc/taosdef.h
+10
-0
src/kit/CMakeLists.txt
src/kit/CMakeLists.txt
+2
-2
src/mnode/inc/mgmtMnode.h
src/mnode/inc/mgmtMnode.h
+5
-2
src/mnode/inc/mgmtSdb.h
src/mnode/inc/mgmtSdb.h
+43
-108
src/mnode/src/mgmtChildTable.c
src/mnode/src/mgmtChildTable.c
+5
-11
src/mnode/src/mgmtDClient.c
src/mnode/src/mgmtDClient.c
+1
-1
src/mnode/src/mgmtDServer.c
src/mnode/src/mgmtDServer.c
+1
-1
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+3
-9
src/mnode/src/mgmtDnode.c
src/mnode/src/mgmtDnode.c
+1
-1
src/mnode/src/mgmtMain.c
src/mnode/src/mgmtMain.c
+7
-5
src/mnode/src/mgmtMnode.c
src/mnode/src/mgmtMnode.c
+55
-15
src/mnode/src/mgmtNormalTable.c
src/mnode/src/mgmtNormalTable.c
+4
-11
src/mnode/src/mgmtSdb.c
src/mnode/src/mgmtSdb.c
+122
-249
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+12
-30
src/mnode/src/mgmtSuperTable.c
src/mnode/src/mgmtSuperTable.c
+3
-9
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+1
-0
src/mnode/src/mgmtUser.c
src/mnode/src/mgmtUser.c
+2
-8
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+2
-2
src/util/inc/tglobalcfg.h
src/util/inc/tglobalcfg.h
+0
-6
src/util/inc/tlog.h
src/util/inc/tlog.h
+19
-0
src/util/src/tglobalcfg.c
src/util/src/tglobalcfg.c
+2
-26
未找到文件。
src/inc/mnode.h
浏览文件 @
4b7e463b
...
...
@@ -25,7 +25,6 @@ extern "C" {
#include "taosdef.h"
#include "taosmsg.h"
#include "taoserror.h"
#include "sdb.h"
#include "tglobalcfg.h"
#include "thash.h"
#include "tidpool.h"
...
...
src/inc/sdb.h
已删除
100644 → 0
浏览文件 @
75bd0eba
/*
* 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 TDENGINE_SDB_H
#define TDENGINE_SDB_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "taosmsg.h"
#include "taosdef.h"
extern
uint16_t
tsMgmtMgmtPort
;
extern
uint16_t
tsMgmtSyncPort
;
extern
int
tsMgmtPeerHBTimer
;
// seconds
extern
char
*
sdbStatusStr
[];
extern
char
*
sdbRoleStr
[];
extern
int
sdbMaster
;
extern
SRpcIpSet
*
pSdbIpList
;
extern
SRpcIpSet
*
pSdbPublicIpList
;
extern
void
(
*
sdbWorkAsMasterCallback
)();
// this function pointer will be set by taosd
enum
_keytype
{
SDB_KEYTYPE_STRING
,
SDB_KEYTYPE_UINT32
,
SDB_KEYTYPE_AUTO
,
SDB_KEYTYPE_RECYCLE
,
SDB_KEYTYPE_MAX
};
#define SDB_ROLE_UNAPPROVED 0
#define SDB_ROLE_UNDECIDED 1
#define SDB_ROLE_MASTER 2
#define SDB_ROLE_SLAVE 3
#define SDB_STATUS_OFFLINE 0
#define SDB_STATUS_UNSYNCED 1
#define SDB_STATUS_SYNCING 2
#define SDB_STATUS_SERVING 3
#define SDB_STATUS_DELETED 4
enum
_sdbaction
{
SDB_TYPE_INSERT
,
SDB_TYPE_DELETE
,
SDB_TYPE_UPDATE
,
SDB_TYPE_DECODE
,
SDB_TYPE_ENCODE
,
SDB_TYPE_BEFORE_BATCH_UPDATE
,
SDB_TYPE_BATCH_UPDATE
,
SDB_TYPE_AFTER_BATCH_UPDATE
,
SDB_TYPE_RESET
,
SDB_TYPE_DESTROY
,
SDB_MAX_ACTION_TYPES
};
#define SDB_MAX_PEERS 4
typedef
struct
{
uint32_t
ip
;
uint32_t
publicIp
;
char
ipstr
[
20
];
char
zone
[
12
];
char
role
;
int64_t
createdTime
;
uint64_t
dbVersion
;
int64_t
lostTime
;
char
status
;
char
numOfMnodes
;
int
numOfDnodes
;
char
updateEnd
[
1
];
// internal
int
syncFd
;
void
*
hbTimer
;
void
*
pSync
;
}
SSdbPeer
;
extern
SSdbPeer
*
sdbPeer
[];
#define sdbInited (sdbPeer[0])
#define sdbStatus (sdbPeer[0]->status)
void
*
sdbOpenTable
(
int
maxRows
,
int32_t
maxRowSize
,
char
*
name
,
uint8_t
keyType
,
char
*
directory
,
void
*
(
*
appTool
)(
char
,
void
*
,
char
*
,
int
,
int
*
));
void
*
sdbGetRow
(
void
*
handle
,
void
*
key
);
int64_t
sdbInsertRow
(
void
*
handle
,
void
*
row
,
int
rowSize
);
int
sdbDeleteRow
(
void
*
handle
,
void
*
key
);
int
sdbUpdateRow
(
void
*
handle
,
void
*
row
,
int
updateSize
,
char
isUpdated
);
void
*
sdbFetchRow
(
void
*
handle
,
void
*
pNode
,
void
**
ppRow
);
int
sdbBatchUpdateRow
(
void
*
handle
,
void
*
row
,
int
rowSize
);
int64_t
sdbGetId
(
void
*
handle
);
int64_t
sdbGetNumOfRows
(
void
*
handle
);
void
sdbSaveSnapShot
(
void
*
handle
);
void
sdbCloseTable
(
void
*
handle
);
int
sdbRemovePeerByIp
(
uint32_t
ip
);
int
sdbInitPeers
(
char
*
directory
);
void
sdbCleanUpPeers
();
int64_t
sdbGetVersion
();
int32_t
sdbGetRunStatus
();
#define TSDB_MAX_NORMAL_TABLES 10000
#define TSDB_MAX_SUPER_TABLES 1000
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_SDB_H
src/inc/taosdef.h
浏览文件 @
4b7e463b
...
...
@@ -309,6 +309,16 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_SESSIONS_PER_VNODE (300)
#define TSDB_SESSIONS_PER_DNODE (TSDB_SESSIONS_PER_VNODE * TSDB_MAX_VNODES)
#define TSDB_MAX_MNODES 5
#define TSDB_MAX_DNODES 10
#define TSDB_MAX_ACCOUNTS 10
#define TSDB_MAX_USERS 20
#define TSDB_MAX_DBS 100
#define TSDB_MAX_VGROUPS 1000
#define TSDB_MAX_SUPER_TABLES 100
#define TSDB_MAX_NORMAL_TABLES 1000
#define TSDB_MAX_CHILD_TABLES 100000
enum
{
TSDB_PRECISION_MILLI
,
TSDB_PRECISION_MICRO
,
...
...
src/kit/CMakeLists.txt
浏览文件 @
4b7e463b
...
...
@@ -2,5 +2,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT
(
TDengine
)
ADD_SUBDIRECTORY
(
shell
)
ADD_SUBDIRECTORY
(
taosdemo
)
ADD_SUBDIRECTORY
(
taosdump
)
#
ADD_SUBDIRECTORY(taosdemo)
#
ADD_SUBDIRECTORY(taosdump)
src/mnode/inc/mgmtMnode.h
浏览文件 @
4b7e463b
...
...
@@ -20,9 +20,12 @@
extern
"C"
{
#endif
bool
mgmtCheckRedirect
(
void
*
handle
);
int32_t
mgmtInitMnodes
();
void
mgmtCleanupMnodes
();
void
mgmtGetMnodeIpList
(
SRpcIpSet
*
ipSet
);
bool
mgmtCheckRedirect
(
void
*
handle
);
void
mgmtGetMnodePrivateIpList
(
SRpcIpSet
*
ipSet
);
void
mgmtGetMnodePublicIpList
(
SRpcIpSet
*
ipSet
);
int32_t
mgmtAddMnode
(
uint32_t
privateIp
,
uint32_t
publicIp
);
int32_t
mgmtRemoveMnode
(
uint32_t
privateIp
);
...
...
src/mnode/inc/mgmtSdb.h
浏览文件 @
4b7e463b
...
...
@@ -13,8 +13,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _sdbint_header_
#define _sdbint_header_
#ifndef TDENGINE_MNODE_SDB_H
#define TDENGINE_MNODE_SDB_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <errno.h>
#include <pthread.h>
...
...
@@ -27,115 +31,46 @@
#include "hashint.h"
#include "hashstr.h"
#include "sdb.h"
#include "tchecksum.h"
#include "tlog.h"
#include "trpc.h"
#include "tutil.h"
#define sdbError(...) \
if (sdbDebugFlag & DEBUG_ERROR) { \
tprintf("ERROR MND-SDB ", 255, __VA_ARGS__); \
}
#define sdbWarn(...) \
if (sdbDebugFlag & DEBUG_WARN) { \
tprintf("WARN MND-SDB ", sdbDebugFlag, __VA_ARGS__); \
}
#define sdbTrace(...) \
if (sdbDebugFlag & DEBUG_TRACE) { \
tprintf("MND-SDB ", sdbDebugFlag, __VA_ARGS__); \
}
#define sdbPrint(...) \
{ tprintf("MND-SDB ", 255, __VA_ARGS__); }
#define mpeerError(...) \
if (sdbDebugFlag & DEBUG_ERROR) { \
tprintf("ERROR MND-MPEER ", 255, __VA_ARGS__); \
}
#define mpeerWarn(...) \
if (sdbDebugFlag & DEBUG_WARN) { \
tprintf("WARN MND-MPEER ", sdbDebugFlag, __VA_ARGS__); \
}
#define mpeerTrace(...) \
if (sdbDebugFlag & DEBUG_TRACE) { \
tprintf("MND-MPEER ", sdbDebugFlag, __VA_ARGS__); \
}
#define mpeerPrint(...) \
{ tprintf("MND-MPEER ", 255, __VA_ARGS__); }
#define sdbLError(...) taosLogError(__VA_ARGS__) sdbError(__VA_ARGS__)
#define sdbLWarn(...) taosLogWarn(__VA_ARGS__) sdbWarn(__VA_ARGS__)
#define sdbLPrint(...) taosLogPrint(__VA_ARGS__) sdbPrint(__VA_ARGS__)
#define SDB_MAX_PEERS 4
#define SDB_DELIMITER 0xFFF00F00
#define SDB_ENDCOMMIT 0xAFFFAAAF
typedef
struct
{
uint64_t
swVersion
;
int16_t
sdbFileVersion
;
char
reserved
[
6
];
TSCKSUM
checkSum
;
}
SSdbHeader
;
typedef
struct
{
char
type
;
// short rowSize;
char
*
row
;
}
SSdbUpdate
;
typedef
struct
_SSdbTable
{
SSdbHeader
header
;
int
maxRows
;
int
dbId
;
int32_t
maxRowSize
;
char
name
[
TSDB_DB_NAME_LEN
];
char
fn
[
128
];
int
keyType
;
uint32_t
autoIndex
;
int64_t
numOfRows
;
int64_t
id
;
int64_t
size
;
void
*
iHandle
;
int
fd
;
void
*
(
*
appTool
)(
char
,
void
*
,
char
*
,
int
,
int
*
);
pthread_mutex_t
mutex
;
SSdbUpdate
*
update
;
int
numOfUpdates
;
int
updatePos
;
}
SSdbTable
;
typedef
struct
{
int64_t
id
;
int64_t
offset
;
int
rowSize
;
void
*
row
;
}
SRowMeta
;
typedef
struct
{
int32_t
delimiter
;
int32_t
rowSize
;
int64_t
id
;
char
data
[];
}
SRowHead
;
typedef
struct
{
uint8_t
dbId
;
char
type
;
uint64_t
version
;
short
dataLen
;
char
data
[];
}
SForwardMsg
;
extern
SSdbTable
*
tableList
[];
extern
int
sdbMaxPeers
;
extern
int
sdbNumOfTables
;
extern
int64_t
sdbVersion
;
int
sdbForwardDbReqToPeer
(
SSdbTable
*
pTable
,
char
type
,
char
*
data
,
int
dataLen
);
int
mpeerRetrieveRows
(
int
fd
,
SSdbTable
*
pTable
,
uint64_t
version
);
void
sdbResetTable
(
SSdbTable
*
pTable
);
extern
const
int16_t
sdbFileVersion
;
enum
_keytype
{
SDB_KEYTYPE_STRING
,
SDB_KEYTYPE_AUTO
,
SDB_KEYTYPE_MAX
};
enum
_sdbaction
{
SDB_TYPE_INSERT
,
SDB_TYPE_DELETE
,
SDB_TYPE_UPDATE
,
SDB_TYPE_DECODE
,
SDB_TYPE_ENCODE
,
SDB_TYPE_DESTROY
,
SDB_MAX_ACTION_TYPES
};
uint64_t
sdbGetVersion
();
bool
sdbInServerState
();
bool
sdbIsMaster
();
void
*
sdbOpenTable
(
int32_t
maxRows
,
int32_t
maxRowSize
,
char
*
name
,
uint8_t
keyType
,
char
*
directory
,
void
*
(
*
appTool
)(
char
,
void
*
,
char
*
,
int32_t
,
int32_t
*
));
void
sdbCloseTable
(
void
*
handle
);
void
*
sdbGetRow
(
void
*
handle
,
void
*
key
);
void
*
sdbFetchRow
(
void
*
handle
,
void
*
pNode
,
void
**
ppRow
);
int64_t
sdbGetId
(
void
*
handle
);
int64_t
sdbGetNumOfRows
(
void
*
handle
);
int64_t
sdbInsertRow
(
void
*
handle
,
void
*
row
,
int32_t
rowSize
);
int32_t
sdbDeleteRow
(
void
*
handle
,
void
*
key
);
int32_t
sdbUpdateRow
(
void
*
handle
,
void
*
row
,
int32_t
updateSize
,
char
isUpdated
);
#ifdef __cplusplus
}
#endif
#endif
\ No newline at end of file
src/mnode/src/mgmtChildTable.c
浏览文件 @
4b7e463b
...
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosmsg.h"
#include "taosdef.h"
#include "tschemautil.h"
#include "tscompression.h"
#include "tskiplist.h"
...
...
@@ -26,10 +27,11 @@
#include "mgmtAcct.h"
#include "mgmtChildTable.h"
#include "mgmtDb.h"
#include "mgmtDClient.h"
#include "mgmtGrant.h"
#include "mgmtProfile.h"
#include "mgmtSdb.h"
#include "mgmtShell.h"
#include "mgmtDClient.h"
#include "mgmtSuperTable.h"
#include "mgmtTable.h"
#include "mgmtVgroup.h"
...
...
@@ -56,7 +58,6 @@ static void mgmtChildTableActionInit() {
mgmtChildTableActionFp
[
SDB_TYPE_UPDATE
]
=
mgmtChildTableActionUpdate
;
mgmtChildTableActionFp
[
SDB_TYPE_ENCODE
]
=
mgmtChildTableActionEncode
;
mgmtChildTableActionFp
[
SDB_TYPE_DECODE
]
=
mgmtChildTableActionDecode
;
mgmtChildTableActionFp
[
SDB_TYPE_RESET
]
=
mgmtChildTableActionReset
;
mgmtChildTableActionFp
[
SDB_TYPE_DESTROY
]
=
mgmtChildTableActionDestroy
;
}
...
...
@@ -93,7 +94,7 @@ void *mgmtChildTableActionInsert(void *row, char *str, int32_t size, int32_t *ss
return
NULL
;
}
if
(
!
sdb
Master
)
{
if
(
!
sdb
IsMaster
()
)
{
int32_t
sid
=
taosAllocateId
(
pVgroup
->
idPool
);
if
(
sid
!=
pTable
->
sid
)
{
mError
(
"ctable:%s, sid:%d is not matched from the master:%d"
,
pTable
->
tableId
,
sid
,
pTable
->
sid
);
...
...
@@ -311,13 +312,6 @@ void *mgmtBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableObj *pTab
}
void
*
mgmtCreateChildTable
(
SCMCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
tid
)
{
int32_t
numOfTables
=
sdbGetNumOfRows
(
tsChildTableSdb
);
if
(
numOfTables
>=
tsMaxTables
)
{
mError
(
"ctable:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
tableId
,
numOfTables
,
tsMaxTables
);
terrno
=
TSDB_CODE_TOO_MANY_TABLES
;
return
NULL
;
}
char
*
pTagData
=
(
char
*
)
pCreate
->
schema
;
// it is a tag key
SSuperTableObj
*
pSuperTable
=
mgmtGetSuperTable
(
pTagData
);
if
(
pSuperTable
==
NULL
)
{
...
...
@@ -338,7 +332,7 @@ void* mgmtCreateChildTable(SCMCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t
pTable
->
type
=
TSDB_CHILD_TABLE
;
pTable
->
createdTime
=
taosGetTimestampMs
();
pTable
->
uid
=
(((
uint64_t
)
pTable
->
vgId
)
<<
40
)
+
((((
uint64_t
)
pTable
->
sid
)
&
((
1ul
<<
24
)
-
1ul
))
<<
16
)
+
(
(
uint64_t
)
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
));
(
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
));
pTable
->
sid
=
tid
;
pTable
->
vgId
=
pVgroup
->
vgId
;
pTable
->
superTable
=
pSuperTable
;
...
...
src/mnode/src/mgmtDClient.c
浏览文件 @
4b7e463b
...
...
@@ -42,7 +42,7 @@ int32_t mgmtInitDClient() {
rpcInit
.
label
=
"MND-DC"
;
rpcInit
.
numOfThreads
=
1
;
rpcInit
.
cfp
=
mgmtProcessRspFromDnode
;
rpcInit
.
sessions
=
tsMaxDnodes
*
5
;
rpcInit
.
sessions
=
100
;
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
.
user
=
"mgmtDClient"
;
...
...
src/mnode/src/mgmtDServer.c
浏览文件 @
4b7e463b
...
...
@@ -45,7 +45,7 @@ int32_t mgmtInitDServer() {
rpcInit
.
label
=
"MND-DS"
;
rpcInit
.
numOfThreads
=
1
;
rpcInit
.
cfp
=
mgmtProcessMsgFromDnode
;
rpcInit
.
sessions
=
tsMaxDnodes
*
5
;
rpcInit
.
sessions
=
100
;
rpcInit
.
connType
=
TAOS_CONN_SERVER
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
.
afp
=
mgmtDServerRetrieveAuth
;
...
...
src/mnode/src/mgmtDb.c
浏览文件 @
4b7e463b
...
...
@@ -24,11 +24,12 @@
#include "mgmtBalance.h"
#include "mgmtDb.h"
#include "mgmtDnode.h"
#include "mgmtMnode.h"
#include "mgmtGrant.h"
#include "mgmtShell.h"
#include "mgmtMnode.h"
#include "mgmtNormalTable.h"
#include "mgmtChildTable.h"
#include "mgmtSdb.h"
#include "mgmtSuperTable.h"
#include "mgmtTable.h"
#include "mgmtUser.h"
...
...
@@ -62,7 +63,6 @@ static void mgmtDbActionInit() {
mgmtDbActionFp
[
SDB_TYPE_UPDATE
]
=
mgmtDbActionUpdate
;
mgmtDbActionFp
[
SDB_TYPE_ENCODE
]
=
mgmtDbActionEncode
;
mgmtDbActionFp
[
SDB_TYPE_DECODE
]
=
mgmtDbActionDecode
;
mgmtDbActionFp
[
SDB_TYPE_RESET
]
=
mgmtDbActionReset
;
mgmtDbActionFp
[
SDB_TYPE_DESTROY
]
=
mgmtDbActionDestroy
;
}
...
...
@@ -83,7 +83,7 @@ int32_t mgmtInitDbs() {
SDbObj
tObj
;
tsDbUpdateSize
=
tObj
.
updateEnd
-
(
char
*
)
&
tObj
;
tsDbSdb
=
sdbOpenTable
(
tsMaxDbs
,
tsDbUpdateSize
,
"dbs"
,
SDB_KEYTYPE_STRING
,
tsMnodeDir
,
mgmtDbAction
);
tsDbSdb
=
sdbOpenTable
(
TSDB_MAX_DBS
,
tsDbUpdateSize
,
"dbs"
,
SDB_KEYTYPE_STRING
,
tsMnodeDir
,
mgmtDbAction
);
if
(
tsDbSdb
==
NULL
)
{
mError
(
"failed to init db data"
);
return
-
1
;
...
...
@@ -252,12 +252,6 @@ static int32_t mgmtCheckDbParams(SCMCreateDbMsg *pCreate) {
}
static
int32_t
mgmtCreateDb
(
SAcctObj
*
pAcct
,
SCMCreateDbMsg
*
pCreate
)
{
int32_t
numOfDbs
=
sdbGetNumOfRows
(
tsDbSdb
);
if
(
numOfDbs
>=
tsMaxDbs
)
{
mWarn
(
"numOfDbs:%d, exceed tsMaxDbs:%d"
,
numOfDbs
,
tsMaxDbs
);
return
TSDB_CODE_TOO_MANY_DATABASES
;
}
int32_t
code
=
mgmtCheckDbLimit
(
pAcct
);
if
(
code
!=
0
)
{
return
code
;
...
...
src/mnode/src/mgmtDnode.c
浏览文件 @
4b7e463b
...
...
@@ -597,7 +597,7 @@ void mgmtProcessDnodeStatusMsg(SRpcMsg *rpcMsg) {
return
;
}
mgmtGetMnodeIpList
(
&
pRsp
->
ipList
);
mgmtGetMnode
Private
IpList
(
&
pRsp
->
ipList
);
pRsp
->
dnodeState
.
dnodeId
=
htonl
(
pDnode
->
dnodeId
);
pRsp
->
dnodeState
.
moduleStatus
=
htonl
(
pDnode
->
moduleStatus
);
...
...
src/mnode/src/mgmtMain.c
浏览文件 @
4b7e463b
...
...
@@ -25,6 +25,8 @@
#include "mgmtDClient.h"
#include "mgmtDnode.h"
#include "mgmtDServer.h"
#include "mgmtMnode.h"
#include "mgmtSdb.h"
#include "mgmtVgroup.h"
#include "mgmtUser.h"
#include "mgmtTable.h"
...
...
@@ -65,7 +67,7 @@ int32_t mgmtStartSystem() {
return
0
;
}
tsMgmtTmr
=
taosTmrInit
((
tsMax
Dnodes
+
tsMax
ShellConns
)
*
3
,
200
,
3600000
,
"MND"
);
tsMgmtTmr
=
taosTmrInit
((
tsMaxShellConns
)
*
3
,
200
,
3600000
,
"MND"
);
if
(
tsMgmtTmr
==
NULL
)
{
mError
(
"failed to init timer"
);
return
-
1
;
...
...
@@ -109,8 +111,8 @@ int32_t mgmtStartSystem() {
return
-
1
;
}
if
(
sdbInitPeers
(
tsMnodeDir
)
<
0
)
{
mError
(
"failed to init
peer
s"
);
if
(
mgmtInitMnodes
(
)
<
0
)
{
mError
(
"failed to init
mnode
s"
);
return
-
1
;
}
...
...
@@ -125,7 +127,7 @@ int32_t mgmtStartSystem() {
void
mgmtStopSystem
()
{
if
(
sdb
Master
)
{
if
(
sdb
IsMaster
()
)
{
mTrace
(
"it is a master mgmt node, it could not be stopped"
);
return
;
}
...
...
@@ -136,7 +138,7 @@ void mgmtStopSystem() {
void
mgmtCleanUpSystem
()
{
mPrint
(
"starting to clean up mgmt"
);
sdbCleanUpPeer
s
();
mgmtCleanupMnode
s
();
mgmtCleanupBalance
();
mgmtCleanUpShell
();
mgmtCleanupDClient
();
...
...
src/mnode/src/mgmtMnode.c
浏览文件 @
4b7e463b
...
...
@@ -18,48 +18,81 @@
#include "trpc.h"
#include "tschemautil.h"
#include "mgmtMnode.h"
#include "mgmtSdb.h"
#include "mgmtUser.h"
int32_t
(
*
mgmtAddMnodeFp
)(
uint32_t
privateIp
,
uint32_t
publicIp
)
=
NULL
;
int32_t
(
*
mgmtRemoveMnodeFp
)(
uint32_t
privateIp
)
=
NULL
;
int32_t
(
*
mgmtGetMnodesNumFp
)()
=
NULL
;
void
*
(
*
mgmtGetNextMnodeFp
)(
SShowObj
*
pShow
,
SMnodeObj
**
pMnode
)
=
NULL
;
int32_t
(
*
mpeerAddMnodeFp
)(
uint32_t
privateIp
,
uint32_t
publicIp
)
=
NULL
;
int32_t
(
*
mpeerRemoveMnodeFp
)(
uint32_t
privateIp
)
=
NULL
;
int32_t
(
*
mpeerGetMnodesNumFp
)()
=
NULL
;
void
*
(
*
mpeerGetNextMnodeFp
)(
SShowObj
*
pShow
,
SMnodeObj
**
pMnode
)
=
NULL
;
int32_t
(
*
mpeerInitMnodesFp
)()
=
NULL
;
void
(
*
mpeerCleanUpMnodesFp
)()
=
NULL
;
static
SMnodeObj
tsMnodeObj
=
{
0
};
static
int32_t
mgmtGetMnodeMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveMnodes
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
char
*
mgmtMnodeStatusStr
[]
=
{
"offline"
,
"unsynced"
,
"syncing"
,
"serving"
,
"null"
};
static
char
*
mgmtMnodeRoleStr
[]
=
{
"unauthed"
,
"undecided"
,
"master"
,
"slave"
,
"null"
};
int32_t
mgmtInitMnodes
()
{
if
(
mpeerInitMnodesFp
)
{
return
(
*
mpeerInitMnodesFp
)();
}
else
{
return
0
;
}
}
void
mgmtCleanupMnodes
()
{
if
(
mpeerCleanUpMnodesFp
)
{
(
*
mpeerCleanUpMnodesFp
)();
}
}
bool
mgmtCheckRedirect
(
void
*
handle
)
{
return
false
;
}
int32_t
mgmtAddMnode
(
uint32_t
privateIp
,
uint32_t
publicIp
)
{
if
(
m
gmt
AddMnodeFp
)
{
return
(
*
m
gmt
AddMnodeFp
)(
privateIp
,
publicIp
);
if
(
m
peer
AddMnodeFp
)
{
return
(
*
m
peer
AddMnodeFp
)(
privateIp
,
publicIp
);
}
else
{
return
0
;
}
}
int32_t
mgmtRemoveMnode
(
uint32_t
privateIp
)
{
if
(
m
gmt
RemoveMnodeFp
)
{
return
(
*
m
gmt
RemoveMnodeFp
)(
privateIp
);
if
(
m
peer
RemoveMnodeFp
)
{
return
(
*
m
peer
RemoveMnodeFp
)(
privateIp
);
}
else
{
return
0
;
}
}
static
int32_t
mgmtGetMnodesNum
()
{
if
(
m
gmt
GetMnodesNumFp
)
{
return
(
*
m
gmt
GetMnodesNumFp
)();
if
(
m
peer
GetMnodesNumFp
)
{
return
(
*
m
peer
GetMnodesNumFp
)();
}
else
{
return
1
;
}
}
static
void
*
mgmtGetNextMnode
(
SShowObj
*
pShow
,
SMnodeObj
**
pMnode
)
{
if
(
m
gmt
GetNextMnodeFp
)
{
return
(
*
m
gmt
GetNextMnodeFp
)(
pShow
,
pMnode
);
if
(
m
peer
GetNextMnodeFp
)
{
return
(
*
m
peer
GetNextMnodeFp
)(
pShow
,
pMnode
);
}
else
{
if
(
*
pMnode
==
NULL
)
{
*
pMnode
=
&
tsMnodeObj
;
...
...
@@ -149,11 +182,11 @@ static int32_t mgmtRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, voi
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
sdbStatusStr
[(
uint8_t
)
pMnode
->
status
]);
strcpy
(
pWrite
,
mgmtMnodeStatusStr
[
pMnode
->
status
]);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
sdbRoleStr
[(
uint8_t
)
pMnode
->
role
]);
strcpy
(
pWrite
,
mgmtMnodeRoleStr
[
pMnode
->
role
]);
cols
++
;
tinet_ntoa
(
ipstr
,
pMnode
->
publicIp
);
...
...
@@ -168,7 +201,14 @@ static int32_t mgmtRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, voi
return
numOfRows
;
}
void
mgmtGetMnodeIpList
(
SRpcIpSet
*
ipSet
)
{
void
mgmtGetMnodePrivateIpList
(
SRpcIpSet
*
ipSet
)
{
ipSet
->
inUse
=
0
;
ipSet
->
port
=
htons
(
tsMnodeDnodePort
);
ipSet
->
numOfIps
=
1
;
ipSet
->
ip
[
0
]
=
htonl
(
inet_addr
(
tsMasterIp
));
}
void
mgmtGetMnodePublicIpList
(
SRpcIpSet
*
ipSet
)
{
ipSet
->
inUse
=
0
;
ipSet
->
port
=
htons
(
tsMnodeDnodePort
);
ipSet
->
numOfIps
=
1
;
...
...
src/mnode/src/mgmtNormalTable.c
浏览文件 @
4b7e463b
...
...
@@ -27,6 +27,7 @@
#include "mgmtDClient.h"
#include "mgmtGrant.h"
#include "mgmtNormalTable.h"
#include "mgmtSdb.h"
#include "mgmtSuperTable.h"
#include "mgmtTable.h"
#include "mgmtVgroup.h"
...
...
@@ -55,7 +56,6 @@ static void mgmtNormalTableActionInit() {
mgmtNormalTableActionFp
[
SDB_TYPE_UPDATE
]
=
mgmtNormalTableActionUpdate
;
mgmtNormalTableActionFp
[
SDB_TYPE_ENCODE
]
=
mgmtNormalTableActionEncode
;
mgmtNormalTableActionFp
[
SDB_TYPE_DECODE
]
=
mgmtNormalTableActionDecode
;
mgmtNormalTableActionFp
[
SDB_TYPE_RESET
]
=
mgmtNormalTableActionReset
;
mgmtNormalTableActionFp
[
SDB_TYPE_DESTROY
]
=
mgmtNormalTableActionDestroy
;
}
...
...
@@ -98,7 +98,7 @@ void *mgmtNormalTableActionInsert(void *row, char *str, int32_t size, int32_t *s
return
NULL
;
}
if
(
!
sdb
Master
)
{
if
(
!
sdb
IsMaster
()
)
{
int32_t
sid
=
taosAllocateId
(
pVgroup
->
idPool
);
if
(
sid
!=
pTable
->
sid
)
{
mError
(
"sid:%d is not matched from the master:%d"
,
sid
,
pTable
->
sid
);
...
...
@@ -222,7 +222,7 @@ int32_t mgmtInitNormalTables() {
SNormalTableObj
tObj
;
tsNormalTableUpdateSize
=
tObj
.
updateEnd
-
(
int8_t
*
)
&
tObj
;
tsNormalTableSdb
=
sdbOpenTable
(
tsMaxTables
,
sizeof
(
SNormalTableObj
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
,
tsNormalTableSdb
=
sdbOpenTable
(
TSDB_MAX_NORMAL_TABLES
,
sizeof
(
SNormalTableObj
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
,
"ntables"
,
SDB_KEYTYPE_STRING
,
tsMnodeDir
,
mgmtNormalTableAction
);
if
(
tsNormalTableSdb
==
NULL
)
{
mError
(
"failed to init ntables data"
);
...
...
@@ -323,13 +323,6 @@ void *mgmtBuildCreateNormalTableMsg(SNormalTableObj *pTable) {
}
void
*
mgmtCreateNormalTable
(
SCMCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
)
{
int32_t
numOfTables
=
sdbGetNumOfRows
(
tsNormalTableSdb
);
if
(
numOfTables
>=
TSDB_MAX_NORMAL_TABLES
)
{
mError
(
"table:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
tableId
,
numOfTables
,
TSDB_MAX_NORMAL_TABLES
);
terrno
=
TSDB_CODE_TOO_MANY_TABLES
;
return
NULL
;
}
SNormalTableObj
*
pTable
=
(
SNormalTableObj
*
)
calloc
(
sizeof
(
SNormalTableObj
),
1
);
if
(
pTable
==
NULL
)
{
mError
(
"table:%s, failed to alloc memory"
,
pCreate
->
tableId
);
...
...
@@ -341,7 +334,7 @@ void *mgmtCreateNormalTable(SCMCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t
pTable
->
type
=
TSDB_NORMAL_TABLE
;
pTable
->
vgId
=
pVgroup
->
vgId
;
pTable
->
createdTime
=
taosGetTimestampMs
();
pTable
->
uid
=
(((
uint64_t
)
pTable
->
createdTime
)
<<
16
)
+
(
(
uint64_t
)
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
));
pTable
->
uid
=
(((
uint64_t
)
pTable
->
createdTime
)
<<
16
)
+
(
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
));
pTable
->
sid
=
sid
;
pTable
->
sversion
=
0
;
pTable
->
numOfColumns
=
htons
(
pCreate
->
numOfColumns
);
...
...
src/mnode/src/mgmtSdb.c
浏览文件 @
4b7e463b
此差异已折叠。
点击以展开。
src/mnode/src/mgmtShell.c
浏览文件 @
4b7e463b
...
...
@@ -32,6 +32,7 @@
#include "mgmtMnode.h"
#include "mgmtNormalTable.h"
#include "mgmtProfile.h"
#include "mgmtSdb.h"
#include "mgmtShell.h"
#include "mgmtSuperTable.h"
#include "mgmtTable.h"
...
...
@@ -63,7 +64,7 @@ int32_t mgmtInitShell() {
mgmtAddShellMsgHandle
(
TSDB_MSG_TYPE_CM_HEARTBEAT
,
mgmtProcessHeartBeatMsg
);
mgmtAddShellMsgHandle
(
TSDB_MSG_TYPE_CM_CONNECT
,
mgmtProcessConnectMsg
);
tsMgmtTranQhandle
=
taosInitScheduler
(
tsMax
Dnodes
+
tsMax
ShellConns
,
1
,
"mnodeT"
);
tsMgmtTranQhandle
=
taosInitScheduler
(
tsMaxShellConns
,
1
,
"mnodeT"
);
int32_t
numOfThreads
=
tsNumOfCores
*
tsNumOfThreadsPerCore
/
4
.
0
;
if
(
numOfThreads
<
1
)
{
...
...
@@ -131,7 +132,7 @@ void mgmtAddToShellQueue(SQueuedMsg *queuedMsg) {
}
static
void
mgmtProcessMsgFromShell
(
SRpcMsg
*
rpcMsg
)
{
if
(
sdbGetRunStatus
()
!=
SDB_STATUS_SERVING
)
{
if
(
!
sdbInServerState
()
)
{
mgmtProcessMsgWhileNotReady
(
rpcMsg
);
rpcFreeCont
(
rpcMsg
->
pCont
);
return
;
...
...
@@ -309,20 +310,10 @@ static void mgmtProcessHeartBeatMsg(SQueuedMsg *pMsg) {
return
;
}
pHBRsp
->
ipList
.
inUse
=
0
;
pHBRsp
->
ipList
.
port
=
htons
(
tsMnodeShellPort
);
pHBRsp
->
ipList
.
numOfIps
=
0
;
if
(
pSdbPublicIpList
!=
NULL
&&
pSdbIpList
!=
NULL
)
{
pHBRsp
->
ipList
.
numOfIps
=
htons
(
pSdbPublicIpList
->
numOfIps
);
if
(
connInfo
.
serverIp
==
tsPublicIpInt
)
{
for
(
int
i
=
0
;
i
<
pSdbPublicIpList
->
numOfIps
;
++
i
)
{
pHBRsp
->
ipList
.
ip
[
i
]
=
htonl
(
pSdbPublicIpList
->
ip
[
i
]);
}
}
else
{
for
(
int
i
=
0
;
i
<
pSdbIpList
->
numOfIps
;
++
i
)
{
pHBRsp
->
ipList
.
ip
[
i
]
=
htonl
(
pSdbIpList
->
ip
[
i
]);
}
}
if
(
connInfo
.
serverIp
==
tsPublicIpInt
)
{
mgmtGetMnodePublicIpList
(
&
pHBRsp
->
ipList
);
}
else
{
mgmtGetMnodePrivateIpList
(
&
pHBRsp
->
ipList
);
}
/*
...
...
@@ -411,20 +402,11 @@ static void mgmtProcessConnectMsg(SQueuedMsg *pMsg) {
strcpy
(
pConnectRsp
->
serverVersion
,
version
);
pConnectRsp
->
writeAuth
=
pUser
->
writeAuth
;
pConnectRsp
->
superAuth
=
pUser
->
superAuth
;
pConnectRsp
->
ipList
.
inUse
=
0
;
pConnectRsp
->
ipList
.
port
=
htons
(
tsMnodeShellPort
);
pConnectRsp
->
ipList
.
numOfIps
=
0
;
if
(
pSdbPublicIpList
!=
NULL
&&
pSdbIpList
!=
NULL
)
{
pConnectRsp
->
ipList
.
numOfIps
=
htons
(
pSdbPublicIpList
->
numOfIps
);
if
(
connInfo
.
serverIp
==
tsPublicIpInt
)
{
for
(
int
i
=
0
;
i
<
pSdbPublicIpList
->
numOfIps
;
++
i
)
{
pConnectRsp
->
ipList
.
ip
[
i
]
=
htonl
(
pSdbPublicIpList
->
ip
[
i
]);
}
}
else
{
for
(
int
i
=
0
;
i
<
pSdbIpList
->
numOfIps
;
++
i
)
{
pConnectRsp
->
ipList
.
ip
[
i
]
=
htonl
(
pSdbIpList
->
ip
[
i
]);
}
}
if
(
connInfo
.
serverIp
==
tsPublicIpInt
)
{
mgmtGetMnodePublicIpList
(
&
pConnectRsp
->
ipList
);
}
else
{
mgmtGetMnodePrivateIpList
(
&
pConnectRsp
->
ipList
);
}
connect_over:
...
...
src/mnode/src/mgmtSuperTable.c
浏览文件 @
4b7e463b
...
...
@@ -31,6 +31,7 @@
#include "mgmtGrant.h"
#include "mgmtShell.h"
#include "mgmtSuperTable.h"
#include "mgmtSdb.h"
#include "mgmtTable.h"
#include "mgmtUser.h"
#include "mgmtVgroup.h"
...
...
@@ -63,7 +64,6 @@ static void mgmtSuperTableActionInit() {
mgmtSuperTableActionFp
[
SDB_TYPE_UPDATE
]
=
mgmtSuperTableActionUpdate
;
mgmtSuperTableActionFp
[
SDB_TYPE_ENCODE
]
=
mgmtSuperTableActionEncode
;
mgmtSuperTableActionFp
[
SDB_TYPE_DECODE
]
=
mgmtSuperTableActionDecode
;
mgmtSuperTableActionFp
[
SDB_TYPE_RESET
]
=
mgmtSuperTableActionReset
;
mgmtSuperTableActionFp
[
SDB_TYPE_DESTROY
]
=
mgmtSuperTableActionDestroy
;
}
...
...
@@ -164,7 +164,7 @@ int32_t mgmtInitSuperTables() {
mgmtSuperTableActionInit
();
tsSuperTableSdb
=
sdbOpenTable
(
tsMaxTables
,
tsSuperTableUpdateSize
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
,
tsSuperTableSdb
=
sdbOpenTable
(
TSDB_MAX_SUPER_TABLES
,
tsSuperTableUpdateSize
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
,
"stables"
,
SDB_KEYTYPE_STRING
,
tsMnodeDir
,
mgmtSuperTableAction
);
if
(
tsSuperTableSdb
==
NULL
)
{
mError
(
"failed to init stables data"
);
...
...
@@ -201,12 +201,6 @@ void mgmtCleanUpSuperTables() {
}
int32_t
mgmtCreateSuperTable
(
SCMCreateTableMsg
*
pCreate
)
{
int32_t
numOfTables
=
sdbGetNumOfRows
(
tsSuperTableSdb
);
if
(
numOfTables
>=
TSDB_MAX_SUPER_TABLES
)
{
mError
(
"stable:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
tableId
,
numOfTables
,
TSDB_MAX_SUPER_TABLES
);
return
TSDB_CODE_TOO_MANY_TABLES
;
}
SSuperTableObj
*
pStable
=
(
SSuperTableObj
*
)
calloc
(
sizeof
(
SSuperTableObj
),
1
);
if
(
pStable
==
NULL
)
{
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
...
...
@@ -217,7 +211,7 @@ int32_t mgmtCreateSuperTable(SCMCreateTableMsg *pCreate) {
pStable
->
createdTime
=
taosGetTimestampMs
();
pStable
->
vgId
=
0
;
pStable
->
sid
=
0
;
pStable
->
uid
=
(((
uint64_t
)
pStable
->
createdTime
)
<<
16
)
+
(
(
uint64_t
)
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
));
pStable
->
uid
=
(((
uint64_t
)
pStable
->
createdTime
)
<<
16
)
+
(
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
));
pStable
->
sversion
=
0
;
pStable
->
numOfColumns
=
htons
(
pCreate
->
numOfColumns
);
pStable
->
numOfTags
=
htons
(
pCreate
->
numOfTags
);
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
4b7e463b
...
...
@@ -24,6 +24,7 @@
#include "mgmtMnode.h"
#include "mgmtNormalTable.h"
#include "mgmtProfile.h"
#include "mgmtSdb.h"
#include "mgmtShell.h"
#include "mgmtSuperTable.h"
#include "mgmtUser.h"
...
...
src/mnode/src/mgmtUser.c
浏览文件 @
4b7e463b
...
...
@@ -21,6 +21,7 @@
#include "mgmtAcct.h"
#include "mgmtGrant.h"
#include "mgmtMnode.h"
#include "mgmtSdb.h"
#include "mgmtShell.h"
#include "mgmtUser.h"
...
...
@@ -59,7 +60,7 @@ int32_t mgmtInitUsers() {
SUserObj
tObj
;
tsUserUpdateSize
=
tObj
.
updateEnd
-
(
int8_t
*
)
&
tObj
;
tsUserSdb
=
sdbOpenTable
(
tsMaxUsers
,
tsUserUpdateSize
,
"users"
,
SDB_KEYTYPE_STRING
,
tsMnodeDir
,
mgmtUserAction
);
tsUserSdb
=
sdbOpenTable
(
TSDB_MAX_USERS
,
tsUserUpdateSize
,
"users"
,
SDB_KEYTYPE_STRING
,
tsMnodeDir
,
mgmtUserAction
);
if
(
tsUserSdb
==
NULL
)
{
mError
(
"failed to init user data"
);
return
-
1
;
...
...
@@ -106,12 +107,6 @@ static int32_t mgmtUpdateUser(SUserObj *pUser) {
}
static
int32_t
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
)
{
int32_t
numOfUsers
=
sdbGetNumOfRows
(
tsUserSdb
);
if
(
numOfUsers
>=
tsMaxUsers
)
{
mWarn
(
"numOfUsers:%d, exceed tsMaxUsers:%d"
,
numOfUsers
,
tsMaxUsers
);
return
TSDB_CODE_TOO_MANY_USERS
;
}
int32_t
code
=
mgmtCheckUserLimit
(
pAcct
);
if
(
code
!=
0
)
{
return
code
;
...
...
@@ -257,7 +252,6 @@ static void mgmtUserActionInit() {
mgmtUserActionFp
[
SDB_TYPE_UPDATE
]
=
mgmtUserActionUpdate
;
mgmtUserActionFp
[
SDB_TYPE_ENCODE
]
=
mgmtUserActionEncode
;
mgmtUserActionFp
[
SDB_TYPE_DECODE
]
=
mgmtUserActionDecode
;
mgmtUserActionFp
[
SDB_TYPE_RESET
]
=
mgmtUserActionReset
;
mgmtUserActionFp
[
SDB_TYPE_DESTROY
]
=
mgmtUserActionDestroy
;
}
...
...
src/mnode/src/mgmtVgroup.c
浏览文件 @
4b7e463b
...
...
@@ -25,6 +25,7 @@
#include "mgmtDClient.h"
#include "mgmtDnode.h"
#include "mgmtProfile.h"
#include "mgmtSdb.h"
#include "mgmtShell.h"
#include "mgmtTable.h"
#include "mgmtVgroup.h"
...
...
@@ -58,7 +59,6 @@ static void mgmtVgroupActionInit() {
mgmtVgroupActionFp
[
SDB_TYPE_UPDATE
]
=
mgmtVgroupActionUpdate
;
mgmtVgroupActionFp
[
SDB_TYPE_ENCODE
]
=
mgmtVgroupActionEncode
;
mgmtVgroupActionFp
[
SDB_TYPE_DECODE
]
=
mgmtVgroupActionDecode
;
mgmtVgroupActionFp
[
SDB_TYPE_RESET
]
=
mgmtVgroupActionReset
;
mgmtVgroupActionFp
[
SDB_TYPE_DESTROY
]
=
mgmtVgroupActionDestroy
;
}
...
...
@@ -75,7 +75,7 @@ int32_t mgmtInitVgroups() {
mgmtVgroupActionInit
();
tsVgroupSdb
=
sdbOpenTable
(
tsMaxVGroups
,
tsVgUpdateSize
,
"vgroups"
,
SDB_KEYTYPE_AUTO
,
tsMnodeDir
,
mgmtVgroupAction
);
tsVgroupSdb
=
sdbOpenTable
(
TSDB_MAX_VGROUPS
,
tsVgUpdateSize
,
"vgroups"
,
SDB_KEYTYPE_AUTO
,
tsMnodeDir
,
mgmtVgroupAction
);
if
(
tsVgroupSdb
==
NULL
)
{
mError
(
"failed to init vgroups data"
);
return
-
1
;
...
...
src/util/inc/tglobalcfg.h
浏览文件 @
4b7e463b
...
...
@@ -103,13 +103,7 @@ extern int tsReplications;
extern
int
tsNumOfMPeers
;
extern
int
tsMaxShellConns
;
extern
int
tsMaxAccounts
;
extern
int
tsMaxUsers
;
extern
int
tsMaxDbs
;
extern
int
tsMaxTables
;
extern
int
tsMaxDnodes
;
extern
int
tsMaxVGroups
;
extern
char
tsMgmtZone
[];
extern
char
tsLocalIp
[];
extern
char
tsDefaultDB
[];
...
...
src/util/inc/tlog.h
浏览文件 @
4b7e463b
...
...
@@ -239,6 +239,25 @@ extern uint32_t cdebugFlag;
#define monitorLWarn(...) taosLogWarn(__VA_ARGS__) monitorWarn(__VA_ARGS__)
#define monitorLPrint(...) taosLogPrint(__VA_ARGS__) monitorPrint(__VA_ARGS__)
#define sdbError(...) \
if (sdbDebugFlag & DEBUG_ERROR) { \
tprintf("ERROR MND-SDB ", 255, __VA_ARGS__); \
}
#define sdbWarn(...) \
if (sdbDebugFlag & DEBUG_WARN) { \
tprintf("WARN MND-SDB ", sdbDebugFlag, __VA_ARGS__); \
}
#define sdbTrace(...) \
if (sdbDebugFlag & DEBUG_TRACE) { \
tprintf("MND-SDB ", sdbDebugFlag, __VA_ARGS__); \
}
#define sdbPrint(...) \
{ tprintf("MND-SDB ", 255, __VA_ARGS__); }
#define sdbLError(...) taosLogError(__VA_ARGS__) sdbError(__VA_ARGS__)
#define sdbLWarn(...) taosLogWarn(__VA_ARGS__) sdbWarn(__VA_ARGS__)
#define sdbLPrint(...) taosLogPrint(__VA_ARGS__) sdbPrint(__VA_ARGS__)
#ifdef __cplusplus
}
#endif
...
...
src/util/src/tglobalcfg.c
浏览文件 @
4b7e463b
...
...
@@ -112,13 +112,7 @@ int tsReplications = TSDB_REPLICA_MIN_NUM;
int
tsNumOfMPeers
=
3
;
int
tsMaxShellConns
=
2000
;
int
tsMaxAccounts
=
100
;
int
tsMaxUsers
=
1000
;
int
tsMaxDbs
=
1000
;
int
tsMaxTables
=
650000
;
int
tsMaxDnodes
=
1000
;
int
tsMaxVGroups
=
1000
;
char
tsMgmtZone
[
16
]
=
"rzone"
;
int
tsMaxTables
=
100000
;
char
tsLocalIp
[
TSDB_IPv4ADDR_LEN
]
=
{
0
};
char
tsDefaultDB
[
TSDB_DB_NAME_LEN
]
=
{
0
};
...
...
@@ -612,28 +606,10 @@ static void doInitGlobalConfig() {
1
,
8640000
,
0
,
TSDB_CFG_UTYPE_SECOND
);
// mgmt configs
tsInitConfigOption
(
cfg
++
,
"mgmtZone"
,
tsMgmtZone
,
TSDB_CFG_VTYPE_STRING
,
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
|
TSDB_CFG_CTYPE_B_CLUSTER
,
0
,
0
,
16
,
TSDB_CFG_UTYPE_NONE
);
tsInitConfigOption
(
cfg
++
,
"maxAccounts"
,
&
tsMaxAccounts
,
TSDB_CFG_VTYPE_INT
,
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
|
TSDB_CFG_CTYPE_B_CLUSTER
,
1
,
1000
,
0
,
TSDB_CFG_UTYPE_NONE
);
tsInitConfigOption
(
cfg
++
,
"maxUsers"
,
&
tsMaxUsers
,
TSDB_CFG_VTYPE_INT
,
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
,
1
,
1000
,
0
,
TSDB_CFG_UTYPE_NONE
);
tsInitConfigOption
(
cfg
++
,
"maxDbs"
,
&
tsMaxDbs
,
TSDB_CFG_VTYPE_INT
,
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
,
1
,
10000
,
0
,
TSDB_CFG_UTYPE_NONE
);
tsInitConfigOption
(
cfg
++
,
"maxTables"
,
&
tsMaxTables
,
TSDB_CFG_VTYPE_INT
,
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
,
1
,
100000000
,
0
,
TSDB_CFG_UTYPE_NONE
);
tsInitConfigOption
(
cfg
++
,
"maxDnodes"
,
&
tsMaxDnodes
,
TSDB_CFG_VTYPE_INT
,
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
|
TSDB_CFG_CTYPE_B_CLUSTER
,
1
,
1000
,
0
,
TSDB_CFG_UTYPE_NONE
);
tsInitConfigOption
(
cfg
++
,
"maxVGroups"
,
&
tsMaxVGroups
,
TSDB_CFG_VTYPE_INT
,
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
,
1
,
1000000
,
0
,
TSDB_CFG_UTYPE_NONE
);
tsInitConfigOption
(
cfg
++
,
"minSlidingTime"
,
&
tsMinSlidingTime
,
TSDB_CFG_VTYPE_INT
,
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
,
10
,
1000000
,
0
,
TSDB_CFG_UTYPE_MS
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录