Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
b0b119
TDengine
提交
9427e9d8
TDengine
项目概览
b0b119
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9427e9d8
编写于
2月 11, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sort out mnode
上级
ded484b5
变更
32
隐藏空白更改
内联
并排
Showing
32 changed file
with
524 addition
and
279 deletion
+524
-279
src/dnode/inc/dnodeMgmt.h
src/dnode/inc/dnodeMgmt.h
+0
-1
src/dnode/src/dnodeMgmt.c
src/dnode/src/dnodeMgmt.c
+1
-3
src/inc/dnode.h
src/inc/dnode.h
+3
-0
src/inc/mnode.h
src/inc/mnode.h
+0
-43
src/mnode/inc/mgmtAcct.h
src/mnode/inc/mgmtAcct.h
+3
-3
src/mnode/inc/mgmtBalance.h
src/mnode/inc/mgmtBalance.h
+0
-3
src/mnode/inc/mgmtConn.h
src/mnode/inc/mgmtConn.h
+32
-0
src/mnode/inc/mgmtDb.h
src/mnode/inc/mgmtDb.h
+37
-0
src/mnode/inc/mgmtDnode.h
src/mnode/inc/mgmtDnode.h
+59
-0
src/mnode/inc/mgmtDnodeInt.h
src/mnode/inc/mgmtDnodeInt.h
+51
-0
src/mnode/inc/mgmtGrant.h
src/mnode/inc/mgmtGrant.h
+3
-0
src/mnode/inc/mgmtProfile.h
src/mnode/inc/mgmtProfile.h
+3
-3
src/mnode/inc/mgmtSupertableQuery.h
src/mnode/inc/mgmtSupertableQuery.h
+1
-0
src/mnode/inc/mgmtSystem.h
src/mnode/inc/mgmtSystem.h
+3
-3
src/mnode/inc/mgmtTable.h
src/mnode/inc/mgmtTable.h
+8
-0
src/mnode/inc/mgmtUtil.h
src/mnode/inc/mgmtUtil.h
+8
-0
src/mnode/src/mgmtAcct.c
src/mnode/src/mgmtAcct.c
+2
-2
src/mnode/src/mgmtBalance.c
src/mnode/src/mgmtBalance.c
+3
-1
src/mnode/src/mgmtConn.c
src/mnode/src/mgmtConn.c
+1
-1
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+7
-5
src/mnode/src/mgmtDnode.c
src/mnode/src/mgmtDnode.c
+62
-6
src/mnode/src/mgmtDnodeInt.c
src/mnode/src/mgmtDnodeInt.c
+148
-10
src/mnode/src/mgmtDnodeInt.spec.c
src/mnode/src/mgmtDnodeInt.spec.c
+0
-149
src/mnode/src/mgmtGrant.c
src/mnode/src/mgmtGrant.c
+8
-1
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+53
-14
src/mnode/src/mgmtSupertableQuery.c
src/mnode/src/mgmtSupertableQuery.c
+2
-2
src/mnode/src/mgmtSystem.spec.c
src/mnode/src/mgmtSystem.spec.c
+0
-5
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+4
-4
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+5
-3
src/util/inc/textbuffer.h
src/util/inc/textbuffer.h
+16
-0
src/util/inc/tstatus.h
src/util/inc/tstatus.h
+1
-1
src/vnode/detail/inc/vnodeTagMgmt.h
src/vnode/detail/inc/vnodeTagMgmt.h
+0
-16
未找到文件。
src/dnode/inc/dnodeMgmt.h
浏览文件 @
9427e9d8
...
...
@@ -27,7 +27,6 @@ int vnodeProcessCreateMeterRequest(char *pMsg, int msgLen, SMgmtObj *pMgmtObj);
int
vnodeProcessRemoveMeterRequest
(
char
*
pMsg
,
int
msgLen
,
SMgmtObj
*
pMgmtObj
);
void
dnodeDistributeMsgFromMgmt
(
char
*
content
,
int
msgLen
,
int
msgType
,
SMgmtObj
*
pObj
);
void
mgmtProcessMsgFromDnodeSpec
(
SSchedMsg
*
sched
);
extern
void
*
dmQhandle
;
...
...
src/dnode/src/dnodeMgmt.c
浏览文件 @
9427e9d8
...
...
@@ -112,7 +112,7 @@ int32_t (*dnodeInitMgmt)() = dnodeInitMgmtImp;
void
dnodeInitMgmtIpImp
()
{}
void
(
*
dnodeInitMgmtIp
)()
=
dnodeInitMgmtIpImp
;
void
*
dnodeProcessMsgFromMgmtImp
(
SSchedMsg
*
sched
)
{
void
dnodeProcessMsgFromMgmtImp
(
SSchedMsg
*
sched
)
{
char
msgType
=
*
sched
->
msg
;
char
*
content
=
sched
->
msg
+
1
;
...
...
@@ -121,8 +121,6 @@ void* dnodeProcessMsgFromMgmtImp(SSchedMsg *sched) {
dnodeDistributeMsgFromMgmt
(
content
,
0
,
msgType
,
0
);
free
(
sched
->
msg
);
return
NULL
;
}
void
dnodeDistributeMsgFromMgmt
(
char
*
content
,
int
msgLen
,
int
msgType
,
SMgmtObj
*
pObj
)
{
...
...
src/inc/dnode.h
浏览文件 @
9427e9d8
...
...
@@ -54,6 +54,9 @@ extern void (*dnodeCleanupStorage)();
void
dnodeCheckDbRunning
(
const
char
*
dir
);
void
dnodeProcessMsgFromMgmtImp
(
SSchedMsg
*
sched
);
#ifdef __cplusplus
}
#endif
...
...
src/inc/mnode.h
浏览文件 @
9427e9d8
...
...
@@ -259,14 +259,6 @@ typedef struct {
extern
SAcctObj
acctObj
;
extern
SDnodeObj
dnodeObj
;
// dnodeInt API
int
mgmtInitDnodeInt
();
void
mgmtCleanUpDnodeInt
();
int
mgmtSendCreateMsgToVgroup
(
STabObj
*
pTable
,
SVgObj
*
pVgroup
);
int
mgmtSendRemoveMeterMsgToDnode
(
STabObj
*
pTable
,
SVgObj
*
pVgroup
);
int
mgmtSendVPeersMsg
(
SVgObj
*
pVgroup
);
int
mgmtSendFreeVnodeMsg
(
SVgObj
*
pVgroup
);
int
mgmtSendOneFreeVnodeMsg
(
SVnodeGid
*
pVnodeGid
);
// shell API
int
mgmtInitShell
();
...
...
@@ -290,13 +282,6 @@ int mgmtGetMetricMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
int
mgmtRetrieveMetrics
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
// DB API
int
mgmtInitDbs
();
int
mgmtUpdateDb
(
SDbObj
*
pDb
);
SDbObj
*
mgmtGetDb
(
char
*
db
);
SDbObj
*
mgmtGetDbByMeterId
(
char
*
db
);
int
mgmtCreateDb
(
SAcctObj
*
pAcct
,
SCreateDbMsg
*
pCreate
);
int
mgmtDropDbByName
(
SAcctObj
*
pAcct
,
char
*
name
,
short
ignoreNotExists
);
int
mgmtDropDb
(
SDbObj
*
pDb
);
/* void mgmtMonitorDbDrop(void *unused); */
void
mgmtMonitorDbDrop
(
void
*
unused
,
void
*
unusedt
);
int
mgmtAlterDb
(
SAcctObj
*
pAcct
,
SAlterDbMsg
*
pAlter
);
...
...
@@ -337,38 +322,12 @@ SSchema *mgmtGetTableSchema(STabObj *pTable); // get schema for a meter
// dnode API
int
mgmtInitDnodes
();
SDnodeObj
*
mgmtGetDnode
(
uint32_t
ip
);
int
mgmtCreateDnode
(
uint32_t
ip
);
int
mgmtDropDnode
(
SDnodeObj
*
pDnode
);
int
mgmtDropDnodeByIp
(
uint32_t
ip
);
int
mgmtUpdateDnode
(
SDnodeObj
*
pDnode
);
int
mgmtGetNextVnode
(
SVnodeGid
*
pVnodeGid
);
void
mgmtSetDnodeVgid
(
SVnodeGid
vnodeGid
[],
int
numOfVnodes
,
int
vgId
);
void
mgmtUnSetDnodeVgid
(
SVnodeGid
vnodeGid
[],
int
numOfVnodes
);
int
mgmtGetDnodeMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
mgmtRetrieveDnodes
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
void
mgmtCleanUpDnodes
();
int
mgmtSendCfgDnodeMsg
(
char
*
cont
);
void
mgmtSetDnodeMaxVnodes
(
SDnodeObj
*
pDnode
);
int
mgmtGetMnodeMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
mgmtRetrieveMnodes
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
int
mgmtGetModuleMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
mgmtRetrieveModules
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
int
mgmtGetConfigMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
mgmtRetrieveConfigs
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
int
mgmtGetConnsMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
mgmtRetrieveConns
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
int
mgmtGetScoresMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
mgmtRetrieveScores
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
int
grantGetGrantsMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
grantRetrieveGrants
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
int
mgmtGetVnodeMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
mgmtRetrieveVnodes
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
...
...
@@ -377,8 +336,6 @@ int mgmtRetrieveVnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn);
void
mgmtSetModuleInDnode
(
SDnodeObj
*
pDnode
,
int
moduleType
);
int
mgmtUnSetModuleInDnode
(
SDnodeObj
*
pDnode
,
int
moduleType
);
extern
int
(
*
mgmtGetMetaFp
[])(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
extern
int
(
*
mgmtRetrieveFp
[])(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
extern
int
tsDnodeUpdateSize
;
extern
int
tsVgUpdateSize
;
...
...
src/mnode/inc/mgmtAcct.h
浏览文件 @
9427e9d8
...
...
@@ -39,14 +39,14 @@ extern SAcctObj* (*mgmtGetAcct)(char *acctName);
extern
void
(
*
mgmtCreateRootAcct
)();
extern
int32_t
(
*
mgmtCheckUserLimit
)(
SAcctObj
*
pAcct
);
extern
int32_t
(
*
mgmtCheckDbLimit
)(
SAcctObj
*
pAcct
);
extern
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
);
extern
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
);
extern
void
(
*
mgmtCheckAcct
)();
extern
void
(
*
mgmtCleanUpAccts
)();
extern
int32_t
(
*
mgmtGetAcctMeta
)(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
extern
int32_t
(
*
mgmtRetrieveAccts
)(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
extern
int32_t
(
*
mgmtRetrieveAccts
)(
SShowObj
*
pShow
,
char
*
data
,
int
32_t
rows
,
SConnObj
*
pConn
);
#ifdef __cplusplus
}
#endif
#endif
// TDENGINE_MGMTSYSTEM_H
#endif
src/mnode/inc/mgmtBalance.h
浏览文件 @
9427e9d8
...
...
@@ -22,9 +22,6 @@ extern "C" {
#include "os.h"
#include "mnode.h"
#include "tglobalcfg.h"
#include "vnodeStatus.h"
#include "ttime.h"
extern
void
(
*
mgmtStartBalanceTimer
)(
int64_t
mseconds
);
extern
int32_t
(
*
mgmtInitBalance
)();
...
...
src/mnode/inc/mgmtConn.h
0 → 100644
浏览文件 @
9427e9d8
/*
* 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_MGMT_CONN_H
#define TDENGINE_MGMT_CONN_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "mnode.h"
int
mgmtGetConnsMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
mgmtRetrieveConns
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
#ifdef __cplusplus
}
#endif
#endif
src/mnode/
src/mgmtDnode.spec.c
→
src/mnode/
inc/mgmtDb.h
浏览文件 @
9427e9d8
...
...
@@ -13,58 +13,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "mnode.h"
#include "vnodeStatus.h"
#include "dnodeModule.h"
SDnodeObj
dnodeObj
;
extern
uint32_t
tsRebootTime
;
SDnodeObj
*
mgmtGetDnode
(
uint32_t
ip
)
{
return
&
dnodeObj
;
}
int
mgmtUpdateDnode
(
SDnodeObj
*
pDnode
)
{
return
0
;
}
void
mgmtCleanUpDnodes
()
{}
#ifndef TDENGINE_MGMT_DB_H
#define TDENGINE_MGMT_DB_H
int
mgmtInitDnodes
()
{
dnodeObj
.
privateIp
=
inet_addr
(
tsPrivateIp
);;
dnodeObj
.
createdTime
=
(
int64_t
)
tsRebootTime
*
1000
;
dnodeObj
.
lastReboot
=
tsRebootTime
;
dnodeObj
.
numOfCores
=
(
uint16_t
)
tsNumOfCores
;
dnodeObj
.
status
=
TSDB_DN_STATUS_READY
;
dnodeObj
.
alternativeRole
=
TSDB_DNODE_ROLE_ANY
;
dnodeObj
.
numOfTotalVnodes
=
tsNumOfTotalVnodes
;
dnodeObj
.
thandle
=
(
void
*
)(
1
);
//hack way
if
(
dnodeObj
.
numOfVnodes
==
TSDB_INVALID_VNODE_NUM
)
{
mgmtSetDnodeMaxVnodes
(
&
dnodeObj
);
mPrint
(
"dnode first access, set total vnodes:%d"
,
dnodeObj
.
numOfVnodes
);
}
return
0
;
}
#ifdef __cplusplus
extern
"C"
{
#endif
int
mgmtGetDnodesNum
()
{
return
1
;
}
#include "mnode.h"
void
*
mgmtGetNextDnode
(
SShowObj
*
pShow
,
SDnodeObj
**
pDnode
)
{
if
(
*
pDnode
==
NULL
)
{
*
pDnode
=
&
dnodeObj
;
}
else
{
*
pDnode
=
NULL
;
}
int
mgmtInitDbs
();
int
mgmtUpdateDb
(
SDbObj
*
pDb
);
SDbObj
*
mgmtGetDb
(
char
*
db
);
SDbObj
*
mgmtGetDbByMeterId
(
char
*
db
);
int
mgmtCreateDb
(
SAcctObj
*
pAcct
,
SCreateDbMsg
*
pCreate
);
int
mgmtDropDbByName
(
SAcctObj
*
pAcct
,
char
*
name
,
short
ignoreNotExists
);
int
mgmtDropDb
(
SDbObj
*
pDb
);
return
*
pDnode
;
#ifdef __cplusplus
}
#endif
int
mgmtGetScoresMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
return
TSDB_CODE_OPS_NOT_SUPPORT
;
}
int
mgmtRetrieveScores
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
)
{
return
0
;
}
void
mgmtSetDnodeUnRemove
(
SDnodeObj
*
pDnode
)
{}
bool
mgmtCheckConfigShow
(
SGlobalConfig
*
cfg
)
{
if
(
cfg
->
cfgType
&
TSDB_CFG_CTYPE_B_CLUSTER
)
return
false
;
if
(
cfg
->
cfgType
&
TSDB_CFG_CTYPE_B_NOT_PRINT
)
return
false
;
return
true
;
}
\ No newline at end of file
#endif
src/mnode/inc/mgmtDnode.h
0 → 100644
浏览文件 @
9427e9d8
/*
* 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_MGMT_DNODE_H
#define TDENGINE_MGMT_DNODE_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdint.h>
#include <stdbool.h>
#include "mnode.h"
int32_t
mgmtCreateDnode
(
uint32_t
ip
);
int32_t
mgmtDropDnode
(
SDnodeObj
*
pDnode
);
int32_t
mgmtDropDnodeByIp
(
uint32_t
ip
);
int32_t
mgmtGetNextVnode
(
SVnodeGid
*
pVnodeGid
);
void
mgmtSetDnodeVgid
(
SVnodeGid
vnodeGid
[],
int
numOfVnodes
,
int
vgId
);
void
mgmtUnSetDnodeVgid
(
SVnodeGid
vnodeGid
[],
int
numOfVnodes
);
int32_t
mgmtGetDnodeMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int32_t
mgmtRetrieveDnodes
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
int32_t
mgmtSendCfgDnodeMsg
(
char
*
cont
);
void
mgmtSetDnodeMaxVnodes
(
SDnodeObj
*
pDnode
);
int32_t
mgmtGetConfigMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int32_t
mgmtRetrieveConfigs
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
int32_t
mgmtGetModuleMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int32_t
mgmtRetrieveModules
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
extern
int32_t
(
*
mgmtInitDnodes
)();
extern
void
(
*
mgmtCleanUpDnodes
)();
extern
SDnodeObj
*
(
*
mgmtGetDnode
)(
uint32_t
ip
);
extern
int32_t
(
*
mgmtGetDnodesNum
)();
extern
void
*
(
*
mgmtGetNextDnode
)(
SShowObj
*
pShow
,
SDnodeObj
**
pDnode
);
extern
int32_t
(
*
mgmtUpdateDnode
)(
SDnodeObj
*
pDnode
);
extern
void
(
*
mgmtSetDnodeUnRemove
)(
SDnodeObj
*
pDnode
);
extern
int32_t
(
*
mgmtGetScoresMeta
)(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
extern
int32_t
(
*
mgmtRetrieveScores
)(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
extern
bool
(
*
mgmtCheckConfigShow
)(
SGlobalConfig
*
cfg
);
#ifdef __cplusplus
}
#endif
#endif
src/mnode/inc/mgmtDnodeInt.h
0 → 100644
浏览文件 @
9427e9d8
/*
* 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_MGMT_DNODE_INT_H
#define TDENGINE_MGMT_DNODE_INT_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdint.h>
#include <stdbool.h>
#include "mnode.h"
// dnodeInt API
int
mgmtSendCreateMsgToVgroup
(
STabObj
*
pTable
,
SVgObj
*
pVgroup
);
int
mgmtSendRemoveMeterMsgToDnode
(
STabObj
*
pTable
,
SVgObj
*
pVgroup
);
int
mgmtSendVPeersMsg
(
SVgObj
*
pVgroup
);
int
mgmtSendFreeVnodeMsg
(
SVgObj
*
pVgroup
);
int
mgmtSendOneFreeVnodeMsg
(
SVnodeGid
*
pVnodeGid
);
char
*
taosBuildRspMsgToDnode
(
SDnodeObj
*
pObj
,
char
type
);
char
*
taosBuildReqMsgToDnode
(
SDnodeObj
*
pObj
,
char
type
);
extern
char
*
(
*
taosBuildRspMsgToDnodeWithSize
)(
SDnodeObj
*
pObj
,
char
type
,
int32_t
size
);
extern
char
*
(
*
taosBuildReqMsgToDnodeWithSize
)(
SDnodeObj
*
pObj
,
char
type
,
int32_t
size
);
extern
int32_t
(
*
taosSendSimpleRspToDnode
)(
SDnodeObj
*
pObj
,
char
rsptype
,
char
code
);
extern
int32_t
(
*
taosSendMsgToDnode
)(
SDnodeObj
*
pObj
,
char
*
msg
,
int32_t
msgLen
);
extern
int32_t
(
*
mgmtInitDnodeInt
)();
extern
void
(
*
mgmtCleanUpDnodeInt
)();
extern
void
(
*
mgmtProcessDnodeStatus
)(
void
*
handle
,
void
*
tmrId
);
extern
void
(
*
mgmtProcessMsgFromDnodeSpec
)(
SSchedMsg
*
sched
);
#ifdef __cplusplus
}
#endif
#endif
src/mnode/inc/mgmtGrant.h
浏览文件 @
9427e9d8
...
...
@@ -22,6 +22,7 @@ extern "C" {
#include <stdint.h>
#include <stdbool.h>
#include "mnode.h"
extern
bool
(
*
mgmtCheckExpired
)();
extern
void
(
*
mgmtAddTimeSeries
)(
uint32_t
timeSeriesNum
);
...
...
@@ -29,6 +30,8 @@ extern void (*mgmtRestoreTimeSeries)(uint32_t timeseries);
extern
int32_t
(
*
mgmtCheckTimeSeries
)(
uint32_t
timeseries
);
extern
int32_t
(
*
mgmtCheckUserGrant
)();
extern
int32_t
(
*
mgmtCheckDbGrant
)();
extern
int32_t
(
*
mgmtGetGrantsMeta
)(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
extern
int32_t
(
*
mgmtRetrieveGrants
)(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
#ifdef __cplusplus
}
...
...
src/mnode/inc/mgmtProfile.h
浏览文件 @
9427e9d8
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_MGMTPROFILE_H
#define TDENGINE_MGMTPROFILE_H
#ifndef TDENGINE_MGMT
_
PROFILE_H
#define TDENGINE_MGMT
_
PROFILE_H
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -42,4 +42,4 @@ int mgmtKillConnection(char *qidstr, SConnObj *pConn);
}
#endif
#endif
// TDENGINE_MGMTPROFILE_H
#endif
\ No newline at end of file
src/mnode/inc/mgmtSupertableQuery.h
浏览文件 @
9427e9d8
...
...
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <stdint.h>
#include "mnode.h"
#include "tast.h"
int32_t
mgmtRetrieveMetersFromSuperTable
(
SSuperTableMetaMsg
*
pInfo
,
int32_t
tableIndex
,
tQueryResultset
*
pRes
);
int32_t
mgmtDoJoin
(
SSuperTableMetaMsg
*
pSuperTableMetaMsg
,
tQueryResultset
*
pRes
);
...
...
src/mnode/inc/mgmtSystem.h
浏览文件 @
9427e9d8
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_MGMTSYSTEM_H
#define TDENGINE_MGMTSYSTEM_H
#ifndef TDENGINE_MGMT
_
SYSTEM_H
#define TDENGINE_MGMT
_
SYSTEM_H
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -49,4 +49,4 @@ void mgmtCleanUpSystem();
}
#endif
#endif
// TDENGINE_MGMTSYSTEM_H
#endif
src/mnode/inc/mgmtTable.h
浏览文件 @
9427e9d8
...
...
@@ -16,6 +16,10 @@
#ifndef TBASE_MNODE_TABLE_H
#define TBASE_MNODE_TABLE_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
...
...
@@ -23,4 +27,8 @@
int32_t
mgmtFindTagCol
(
STabObj
*
pTable
,
const
char
*
tagName
);
#ifdef __cplusplus
}
#endif
#endif
src/mnode/inc/mgmtUtil.h
浏览文件 @
9427e9d8
...
...
@@ -16,6 +16,10 @@
#ifndef TBASE_MNODE_UTIL_H
#define TBASE_MNODE_UTIL_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
...
...
@@ -29,4 +33,8 @@ int32_t mgmtGetTagsLength(STabObj* pSuperTable, int32_t col);
bool
mgmtCheckIsMonitorDB
(
char
*
db
,
char
*
monitordb
);
int32_t
mgmtCheckDBParams
(
SCreateDbMsg
*
pCreate
);
#ifdef __cplusplus
}
#endif
#endif
src/mnode/src/mgmtAcct.c
浏览文件 @
9427e9d8
...
...
@@ -160,8 +160,8 @@ int32_t mgmtCheckDbLimitImp(SAcctObj *pAcct) {
}
int32_t
(
*
mgmtCheckDbLimit
)(
SAcctObj
*
pAcct
)
=
mgmtCheckDbLimitImp
;
int32_t
mgmtCheckTableLimitImp
(
SAcctObj
*
pAcct
)
{
return
0
;
}
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
)
=
mgmtCheckTableLimitImp
;
int32_t
mgmtCheckTableLimitImp
(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
)
{
return
0
;
}
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
)
=
mgmtCheckTableLimitImp
;
void
mgmtCheckAcctImp
()
{
SAcctObj
*
pAcct
=
&
acctObj
;
...
...
src/mnode/src/mgmtBalance.c
浏览文件 @
9427e9d8
...
...
@@ -15,8 +15,10 @@
#define _DEFAULT_SOURCE
#include "mgmtBalance.h"
#include "vnodeStatus.h"
#include "dnodeModule.h"
#include "tstatus.h"
#include "tglobalcfg.h"
#include "ttime.h"
void
mgmtStartBalanceTimerImp
(
int64_t
mseconds
)
{}
void
(
*
mgmtStartBalanceTimer
)(
int64_t
mseconds
)
=
mgmtStartBalanceTimerImp
;
...
...
src/mnode/src/mgmtConn.c
浏览文件 @
9427e9d8
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "m
node
.h"
#include "m
gmtConn
.h"
#include "taosmsg.h"
#include "tschemautil.h"
...
...
src/mnode/src/mgmtDb.c
浏览文件 @
9427e9d8
...
...
@@ -15,15 +15,19 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnode.h"
#include "mgmtDnode.h"
#include "mgmtDb.h"
#include "mgmtAcct.h"
#include "mgmtGrant.h"
#include "mgmtBalance.h"
#include "mgmtDnodeInt.h"
#include "mgmtUtil.h"
#include "tschemautil.h"
#include "vnodeStatus.h"
#include "tstatus.h"
#include "mnode.h"
void
*
dbSdb
=
NULL
;
extern
void
*
vgSdb
;
int
tsDbUpdateSize
;
void
*
(
*
mgmtDbActionFp
[
SDB_MAX_ACTION_TYPES
])(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
...
...
@@ -38,8 +42,6 @@ void *mgmtDbActionAfterBatchUpdate(void *row, char *str, int size, int *ssize);
void
*
mgmtDbActionReset
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtDbActionDestroy
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
int
mgmtCheckDbLimit
(
SAcctObj
*
pAcct
);
void
mgmtDbActionInit
()
{
mgmtDbActionFp
[
SDB_TYPE_INSERT
]
=
mgmtDbActionInsert
;
mgmtDbActionFp
[
SDB_TYPE_DELETE
]
=
mgmtDbActionDelete
;
...
...
src/mnode/src/mgmtDnode.c
浏览文件 @
9427e9d8
...
...
@@ -19,15 +19,12 @@
#include "dnodeSystem.h"
#include "mnode.h"
#include "mgmtDnode.h"
#include "mgmtBalance.h"
#include "tschemautil.h"
#include "
vnodeS
tatus.h"
#include "
ts
tatus.h"
#include "dnodeModule.h"
bool
mgmtCheckModuleInDnode
(
SDnodeObj
*
pDnode
,
int
moduleType
);
int
mgmtGetDnodesNum
();
void
*
mgmtGetNextDnode
(
SShowObj
*
pShow
,
SDnodeObj
**
pDnode
);
bool
mgmtCheckConfigShow
(
SGlobalConfig
*
cfg
);
void
mgmtSetDnodeMaxVnodes
(
SDnodeObj
*
pDnode
)
{
int
maxVnodes
=
pDnode
->
numOfCores
*
tsNumOfVnodesPerCore
;
maxVnodes
=
maxVnodes
>
TSDB_MAX_VNODES
?
TSDB_MAX_VNODES
:
maxVnodes
;
...
...
@@ -512,4 +509,63 @@ int mgmtRetrieveVnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
return
numOfRows
;
}
SDnodeObj
dnodeObj
;
extern
uint32_t
tsRebootTime
;
SDnodeObj
*
mgmtGetDnodeImp
(
uint32_t
ip
)
{
return
&
dnodeObj
;
}
SDnodeObj
*
(
*
mgmtGetDnode
)(
uint32_t
ip
)
=
mgmtGetDnodeImp
;
int32_t
mgmtUpdateDnodeImp
(
SDnodeObj
*
pDnode
)
{
return
0
;
}
int32_t
(
*
mgmtUpdateDnode
)(
SDnodeObj
*
pDnode
)
=
mgmtUpdateDnodeImp
;
void
mgmtCleanUpDnodesImp
()
{}
void
(
*
mgmtCleanUpDnodes
)()
=
mgmtCleanUpDnodesImp
;
int32_t
mgmtInitDnodesImp
()
{
dnodeObj
.
privateIp
=
inet_addr
(
tsPrivateIp
);;
dnodeObj
.
createdTime
=
(
int64_t
)
tsRebootTime
*
1000
;
dnodeObj
.
lastReboot
=
tsRebootTime
;
dnodeObj
.
numOfCores
=
(
uint16_t
)
tsNumOfCores
;
dnodeObj
.
status
=
TSDB_DN_STATUS_READY
;
dnodeObj
.
alternativeRole
=
TSDB_DNODE_ROLE_ANY
;
dnodeObj
.
numOfTotalVnodes
=
tsNumOfTotalVnodes
;
dnodeObj
.
thandle
=
(
void
*
)(
1
);
//hack way
if
(
dnodeObj
.
numOfVnodes
==
TSDB_INVALID_VNODE_NUM
)
{
mgmtSetDnodeMaxVnodes
(
&
dnodeObj
);
mPrint
(
"dnode first access, set total vnodes:%d"
,
dnodeObj
.
numOfVnodes
);
}
return
0
;
}
int32_t
(
*
mgmtInitDnodes
)()
=
mgmtInitDnodesImp
;
int32_t
mgmtGetDnodesNumImp
()
{
return
1
;
}
int32_t
(
*
mgmtGetDnodesNum
)()
=
mgmtGetDnodesNumImp
;
void
*
mgmtGetNextDnodeImp
(
SShowObj
*
pShow
,
SDnodeObj
**
pDnode
)
{
if
(
*
pDnode
==
NULL
)
{
*
pDnode
=
&
dnodeObj
;
}
else
{
*
pDnode
=
NULL
;
}
return
*
pDnode
;
}
void
*
(
*
mgmtGetNextDnode
)(
SShowObj
*
pShow
,
SDnodeObj
**
pDnode
)
=
mgmtGetNextDnodeImp
;
int32_t
mgmtGetScoresMetaImp
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
return
TSDB_CODE_OPS_NOT_SUPPORT
;
}
int32_t
(
*
mgmtGetScoresMeta
)(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
=
mgmtGetScoresMetaImp
;
int32_t
mgmtRetrieveScoresImp
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
)
{
return
0
;
}
int32_t
(
*
mgmtRetrieveScores
)(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
)
=
mgmtRetrieveScoresImp
;
void
mgmtSetDnodeUnRemoveImp
(
SDnodeObj
*
pDnode
)
{}
void
(
*
mgmtSetDnodeUnRemove
)(
SDnodeObj
*
pDnode
)
=
mgmtSetDnodeUnRemoveImp
;
bool
mgmtCheckConfigShowImp
(
SGlobalConfig
*
cfg
)
{
if
(
cfg
->
cfgType
&
TSDB_CFG_CTYPE_B_CLUSTER
)
return
false
;
if
(
cfg
->
cfgType
&
TSDB_CFG_CTYPE_B_NOT_PRINT
)
return
false
;
return
true
;
}
bool
(
*
mgmtCheckConfigShow
)(
SGlobalConfig
*
cfg
)
=
mgmtCheckConfigShowImp
;
\ No newline at end of file
src/mnode/src/mgmtDnodeInt.c
浏览文件 @
9427e9d8
...
...
@@ -16,25 +16,24 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "dnodeSystem.h"
#include "mnode.h"
#include "dnode.h"
#include "mgmtDnodeInt.h"
#include "mgmtBalance.h"
#include "mgmtDnode.h"
#include "mgmtDb.h"
#include "tutil.h"
#include "tstatus.h"
#include "tsystem.h"
#include "tsched.h"
#include "dnodeSystem.h"
void
mgmtProcessMsgFromDnode
(
char
*
content
,
int
msgLen
,
int
msgType
,
SDnodeObj
*
pObj
);
int
mgmtSendVPeersMsg
(
SVgObj
*
pVgroup
);
char
*
mgmtBuildVpeersIe
(
char
*
pMsg
,
SVgObj
*
pVgroup
,
int
vnode
);
char
*
mgmtBuildCreateMeterIe
(
STabObj
*
pTable
,
char
*
pMsg
,
int
vnode
);
/*
* functions for communicate between dnode and mnode
*/
char
*
taosBuildRspMsgToDnodeWithSize
(
SDnodeObj
*
pObj
,
char
type
,
int
size
);
char
*
taosBuildReqMsgToDnodeWithSize
(
SDnodeObj
*
pObj
,
char
type
,
int
size
);
char
*
taosBuildRspMsgToDnode
(
SDnodeObj
*
pObj
,
char
type
);
char
*
taosBuildReqMsgToDnode
(
SDnodeObj
*
pObj
,
char
type
);
int
taosSendSimpleRspToDnode
(
SDnodeObj
*
pObj
,
char
rsptype
,
char
code
);
int
taosSendMsgToDnode
(
SDnodeObj
*
pObj
,
char
*
msg
,
int
msgLen
);
int
mgmtProcessMeterCfgMsg
(
char
*
cont
,
int
contLen
,
SDnodeObj
*
pObj
)
{
char
*
pMsg
,
*
pStart
;
...
...
@@ -502,3 +501,142 @@ int mgmtSendCfgDnodeMsg(char *cont) {
#endif
return
0
;
}
/*
* functions for communicate between dnode and mnode
*/
extern
void
*
dmQhandle
;
void
*
mgmtStatusTimer
=
NULL
;
void
mgmtProcessMsgFromDnode
(
char
*
content
,
int
msgLen
,
int
msgType
,
SDnodeObj
*
pObj
);
char
*
taosBuildRspMsgToDnodeWithSizeImp
(
SDnodeObj
*
pObj
,
char
type
,
int32_t
size
)
{
char
*
pStart
=
(
char
*
)
malloc
(
size
);
if
(
pStart
==
NULL
)
{
return
NULL
;
}
*
pStart
=
type
;
return
pStart
+
1
;
}
char
*
(
*
taosBuildRspMsgToDnodeWithSize
)(
SDnodeObj
*
pObj
,
char
type
,
int32_t
size
)
=
taosBuildRspMsgToDnodeWithSizeImp
;
char
*
taosBuildReqMsgToDnodeWithSizeImp
(
SDnodeObj
*
pObj
,
char
type
,
int32_t
size
)
{
char
*
pStart
=
(
char
*
)
malloc
(
size
);
if
(
pStart
==
NULL
)
{
return
NULL
;
}
*
pStart
=
type
;
return
pStart
+
1
;
}
char
*
(
*
taosBuildReqMsgToDnodeWithSize
)(
SDnodeObj
*
pObj
,
char
type
,
int32_t
size
)
=
taosBuildReqMsgToDnodeWithSizeImp
;
char
*
taosBuildRspMsgToDnode
(
SDnodeObj
*
pObj
,
char
type
)
{
return
taosBuildRspMsgToDnodeWithSize
(
pObj
,
type
,
256
);
}
char
*
taosBuildReqMsgToDnode
(
SDnodeObj
*
pObj
,
char
type
)
{
return
taosBuildReqMsgToDnodeWithSize
(
pObj
,
type
,
256
);
}
int32_t
taosSendSimpleRspToDnodeImp
(
SDnodeObj
*
pObj
,
char
rsptype
,
char
code
)
{
return
0
;
}
int32_t
(
*
taosSendSimpleRspToDnode
)(
SDnodeObj
*
pObj
,
char
rsptype
,
char
code
)
=
taosSendSimpleRspToDnodeImp
;
int32_t
taosSendMsgToDnodeImp
(
SDnodeObj
*
pObj
,
char
*
msg
,
int32_t
msgLen
)
{
mTrace
(
"msg:%s is sent to dnode"
,
taosMsg
[(
uint8_t
)(
*
(
msg
-
1
))]);
/*
* Lite version has no message header, so minus one
*/
SSchedMsg
schedMsg
;
schedMsg
.
fp
=
dnodeProcessMsgFromMgmtImp
;
schedMsg
.
msg
=
msg
-
1
;
schedMsg
.
ahandle
=
NULL
;
schedMsg
.
thandle
=
NULL
;
taosScheduleTask
(
dmQhandle
,
&
schedMsg
);
return
0
;
}
int32_t
(
*
taosSendMsgToDnode
)(
SDnodeObj
*
pObj
,
char
*
msg
,
int
msgLen
)
=
taosSendMsgToDnodeImp
;
int32_t
mgmtInitDnodeIntImp
()
{
return
0
;
}
int32_t
(
*
mgmtInitDnodeInt
)()
=
mgmtInitDnodeIntImp
;
void
mgmtCleanUpDnodeIntImp
()
{}
void
(
*
mgmtCleanUpDnodeInt
)()
=
mgmtCleanUpDnodeIntImp
;
void
mgmtProcessDnodeStatusImp
(
void
*
handle
,
void
*
tmrId
)
{
/*
SDnodeObj *pObj = &dnodeObj;
pObj->openVnodes = tsOpenVnodes;
pObj->status = TSDB_DN_STATUS_READY;
float memoryUsedMB = 0;
taosGetSysMemory(&memoryUsedMB);
pObj->diskAvailable = tsAvailDataDirGB;
for (int vnode = 0; vnode < pObj->numOfVnodes; ++vnode) {
SVnodeLoad *pVload = &(pObj->vload[vnode]);
SVnodeObj * pVnode = vnodeList + vnode;
// wait vnode dropped
if (pVload->dropStatus == TSDB_VN_DROP_STATUS_DROPPING) {
if (vnodeList[vnode].cfg.maxSessions <= 0) {
pVload->dropStatus = TSDB_VN_DROP_STATUS_READY;
pVload->status = TSDB_VN_STATUS_OFFLINE;
mPrint("dnode:%s, vid:%d, drop finished", taosIpStr(pObj->privateIp), vnode);
taosTmrStart(mgmtMonitorDbDrop, 10000, NULL, mgmtTmr);
}
}
if (vnodeList[vnode].cfg.maxSessions <= 0) {
continue;
}
pVload->vnode = vnode;
pVload->status = TSDB_VN_STATUS_MASTER;
pVload->totalStorage = pVnode->vnodeStatistic.totalStorage;
pVload->compStorage = pVnode->vnodeStatistic.compStorage;
pVload->pointsWritten = pVnode->vnodeStatistic.pointsWritten;
uint32_t vgId = pVnode->cfg.vgId;
SVgObj *pVgroup = mgmtGetVgroup(vgId);
if (pVgroup == NULL) {
mError("vgroup:%d is not there, but associated with vnode %d", vgId, vnode);
pVload->dropStatus = TSDB_VN_DROP_STATUS_DROPPING;
continue;
}
SDbObj *pDb = mgmtGetDb(pVgroup->dbName);
if (pDb == NULL) {
mError("vgroup:%d not belongs to any database, vnode:%d", vgId, vnode);
continue;
}
if (pVload->vgId == 0 || pVload->dropStatus == TSDB_VN_DROP_STATUS_DROPPING) {
mError("vid:%d, mgmt not exist, drop it", vnode);
pVload->dropStatus = TSDB_VN_DROP_STATUS_DROPPING;
}
}
taosTmrReset(mgmtProcessDnodeStatus, tsStatusInterval * 1000, NULL, mgmtTmr, &mgmtStatusTimer);
if (mgmtStatusTimer == NULL) {
mError("Failed to start status timer");
}
*/
}
void
(
*
mgmtProcessDnodeStatus
)(
void
*
handle
,
void
*
tmrId
)
=
mgmtProcessDnodeStatusImp
;
void
mgmtProcessMsgFromDnodeSpecImp
(
SSchedMsg
*
sched
)
{
char
msgType
=
*
sched
->
msg
;
char
*
content
=
sched
->
msg
+
1
;
mTrace
(
"msg:%s is received from dnode"
,
taosMsg
[(
uint8_t
)
msgType
]);
mgmtProcessMsgFromDnode
(
content
,
0
,
msgType
,
mgmtGetDnode
(
0
));
free
(
sched
->
msg
);
}
void
(
*
mgmtProcessMsgFromDnodeSpec
)(
SSchedMsg
*
sched
)
=
mgmtProcessMsgFromDnodeSpecImp
;
src/mnode/src/mgmtDnodeInt.spec.c
已删除
100644 → 0
浏览文件 @
ded484b5
/*
* 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 <arpa/inet.h>
#include <endian.h>
#include "dnodeSystem.h"
#include "mnode.h"
#include "tsched.h"
#include "tutil.h"
#include "vnode.h"
#include "tsystem.h"
#include "vnodeStatus.h"
extern
void
*
dmQhandle
;
void
*
mgmtStatusTimer
=
NULL
;
void
mgmtProcessMsgFromDnode
(
char
*
content
,
int
msgLen
,
int
msgType
,
SDnodeObj
*
pObj
);
void
*
dnodeProcessMsgFromMgmtImp
(
SSchedMsg
*
sched
);
char
*
taosBuildRspMsgToDnodeWithSize
(
SDnodeObj
*
pObj
,
char
type
,
int
size
)
{
char
*
pStart
=
(
char
*
)
malloc
(
size
);
if
(
pStart
==
NULL
)
{
return
NULL
;
}
*
pStart
=
type
;
return
pStart
+
1
;
}
char
*
taosBuildReqMsgToDnodeWithSize
(
SDnodeObj
*
pObj
,
char
type
,
int
size
)
{
char
*
pStart
=
(
char
*
)
malloc
(
size
);
if
(
pStart
==
NULL
)
{
return
NULL
;
}
*
pStart
=
type
;
return
pStart
+
1
;
}
char
*
taosBuildRspMsgToDnode
(
SDnodeObj
*
pObj
,
char
type
)
{
return
taosBuildRspMsgToDnodeWithSize
(
pObj
,
type
,
256
);
}
char
*
taosBuildReqMsgToDnode
(
SDnodeObj
*
pObj
,
char
type
)
{
return
taosBuildReqMsgToDnodeWithSize
(
pObj
,
type
,
256
);
}
int
taosSendSimpleRspToDnode
(
SDnodeObj
*
pObj
,
char
rsptype
,
char
code
)
{
return
0
;
}
int
taosSendMsgToDnode
(
SDnodeObj
*
pObj
,
char
*
msg
,
int
msgLen
)
{
mTrace
(
"msg:%s is sent to dnode"
,
taosMsg
[(
uint8_t
)(
*
(
msg
-
1
))]);
/*
* Lite version has no message header, so minus one
*/
SSchedMsg
schedMsg
;
schedMsg
.
fp
=
dnodeProcessMsgFromMgmtImp
;
schedMsg
.
msg
=
msg
-
1
;
schedMsg
.
ahandle
=
NULL
;
schedMsg
.
thandle
=
NULL
;
taosScheduleTask
(
dmQhandle
,
&
schedMsg
);
return
0
;
}
int
mgmtInitDnodeInt
()
{
return
0
;
}
void
mgmtCleanUpDnodeInt
()
{}
void
mgmtProcessDnodeStatus
(
void
*
handle
,
void
*
tmrId
)
{
SDnodeObj
*
pObj
=
&
dnodeObj
;
pObj
->
openVnodes
=
tsOpenVnodes
;
pObj
->
status
=
TSDB_DN_STATUS_READY
;
float
memoryUsedMB
=
0
;
taosGetSysMemory
(
&
memoryUsedMB
);
pObj
->
diskAvailable
=
tsAvailDataDirGB
;
for
(
int
vnode
=
0
;
vnode
<
pObj
->
numOfVnodes
;
++
vnode
)
{
SVnodeLoad
*
pVload
=
&
(
pObj
->
vload
[
vnode
]);
SVnodeObj
*
pVnode
=
vnodeList
+
vnode
;
// wait vnode dropped
if
(
pVload
->
dropStatus
==
TSDB_VN_DROP_STATUS_DROPPING
)
{
if
(
vnodeList
[
vnode
].
cfg
.
maxSessions
<=
0
)
{
pVload
->
dropStatus
=
TSDB_VN_DROP_STATUS_READY
;
pVload
->
status
=
TSDB_VN_STATUS_OFFLINE
;
mPrint
(
"dnode:%s, vid:%d, drop finished"
,
taosIpStr
(
pObj
->
privateIp
),
vnode
);
taosTmrStart
(
mgmtMonitorDbDrop
,
10000
,
NULL
,
mgmtTmr
);
}
}
if
(
vnodeList
[
vnode
].
cfg
.
maxSessions
<=
0
)
{
continue
;
}
pVload
->
vnode
=
vnode
;
pVload
->
status
=
TSDB_VN_STATUS_MASTER
;
pVload
->
totalStorage
=
pVnode
->
vnodeStatistic
.
totalStorage
;
pVload
->
compStorage
=
pVnode
->
vnodeStatistic
.
compStorage
;
pVload
->
pointsWritten
=
pVnode
->
vnodeStatistic
.
pointsWritten
;
uint32_t
vgId
=
pVnode
->
cfg
.
vgId
;
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
vgId
);
if
(
pVgroup
==
NULL
)
{
mError
(
"vgroup:%d is not there, but associated with vnode %d"
,
vgId
,
vnode
);
pVload
->
dropStatus
=
TSDB_VN_DROP_STATUS_DROPPING
;
continue
;
}
SDbObj
*
pDb
=
mgmtGetDb
(
pVgroup
->
dbName
);
if
(
pDb
==
NULL
)
{
mError
(
"vgroup:%d not belongs to any database, vnode:%d"
,
vgId
,
vnode
);
continue
;
}
if
(
pVload
->
vgId
==
0
||
pVload
->
dropStatus
==
TSDB_VN_DROP_STATUS_DROPPING
)
{
mError
(
"vid:%d, mgmt not exist, drop it"
,
vnode
);
pVload
->
dropStatus
=
TSDB_VN_DROP_STATUS_DROPPING
;
}
}
taosTmrReset
(
mgmtProcessDnodeStatus
,
tsStatusInterval
*
1000
,
NULL
,
mgmtTmr
,
&
mgmtStatusTimer
);
if
(
mgmtStatusTimer
==
NULL
)
{
mError
(
"Failed to start status timer"
);
}
}
void
mgmtProcessMsgFromDnodeSpec
(
SSchedMsg
*
sched
)
{
char
msgType
=
*
sched
->
msg
;
char
*
content
=
sched
->
msg
+
1
;
mTrace
(
"msg:%s is received from dnode"
,
taosMsg
[(
uint8_t
)
msgType
]);
mgmtProcessMsgFromDnode
(
content
,
0
,
msgType
,
mgmtGetDnode
(
0
));
free
(
sched
->
msg
);
}
src/mnode/src/mgmtGrant.c
浏览文件 @
9427e9d8
...
...
@@ -35,4 +35,11 @@ int32_t mgmtCheckTimeSeriesImp(uint32_t timeseries) { return 0; }
int32_t
(
*
mgmtCheckTimeSeries
)(
uint32_t
timeseries
)
=
mgmtCheckTimeSeriesImp
;
bool
mgmtCheckExpiredImp
()
{
return
false
;
}
bool
(
*
mgmtCheckExpired
)()
=
mgmtCheckExpiredImp
;
\ No newline at end of file
bool
(
*
mgmtCheckExpired
)()
=
mgmtCheckExpiredImp
;
int32_t
mgmtGetGrantsMetaImp
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
return
TSDB_CODE_OPS_NOT_SUPPORT
;
}
int32_t
(
*
mgmtGetGrantsMeta
)(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
=
mgmtGetGrantsMetaImp
;
int32_t
mgmtRetrieveGrantsImp
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
)
{
return
0
;
}
int32_t
(
*
mgmtRetrieveGrants
)(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
)
=
mgmtRetrieveGrantsImp
;
src/mnode/src/mgmtShell.c
浏览文件 @
9427e9d8
...
...
@@ -18,14 +18,28 @@
#include "dnodeSystem.h"
#include "mnode.h"
#include "mgmtAcct.h"
#include "mgmtBalance.h"
#include "mgmtConn.h"
#include "mgmtDb.h"
#include "mgmtDnode.h"
#include "mgmtGrant.h"
#include "mgmtProfile.h"
#include "mgmtTable.h"
#include "mgmtUtil.h"
#include "taosmsg.h"
#include "tlog.h"
#include "
vnodeS
tatus.h"
#include "
ts
tatus.h"
#define MAX_LEN_OF_METER_META (sizeof(SMultiMeterMeta) + sizeof(SSchema) * TSDB_MAX_COLUMNS + sizeof(SSchema) * TSDB_MAX_TAGS + TSDB_MAX_TAGS_LEN)
typedef
int32_t
(
*
GetMateFp
)(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
typedef
int32_t
(
*
RetrieveMetaFp
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
SConnObj
*
pConn
);
static
GetMateFp
*
mgmtGetMetaFp
;
static
RetrieveMetaFp
*
mgmtRetrieveFp
;
static
void
mgmtInitShowMsgFp
();
void
*
pShellConn
=
NULL
;
SConnObj
*
connList
;
void
*
mgmtProcessMsgFromShell
(
char
*
msg
,
void
*
ahandle
,
void
*
thandle
);
...
...
@@ -61,6 +75,7 @@ int mgmtInitShell() {
SRpcInit
rpcInit
;
mgmtInitProcessShellMsg
();
mgmtInitShowMsgFp
();
int
size
=
sizeof
(
SConnObj
)
*
tsMaxShellConns
;
connList
=
(
SConnObj
*
)
malloc
(
size
);
...
...
@@ -879,19 +894,43 @@ int mgmtProcessUseDbMsg(char *pMsg, int msgLen, SConnObj *pConn) {
return
0
;
}
int
(
*
mgmtGetMetaFp
[])(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
=
{
mgmtGetAcctMeta
,
mgmtGetUserMeta
,
mgmtGetDbMeta
,
mgmtGetTableMeta
,
mgmtGetDnodeMeta
,
mgmtGetMnodeMeta
,
mgmtGetVgroupMeta
,
mgmtGetMetricMeta
,
mgmtGetModuleMeta
,
mgmtGetQueryMeta
,
mgmtGetStreamMeta
,
mgmtGetConfigMeta
,
mgmtGetConnsMeta
,
mgmtGetScoresMeta
,
grantGetGrantsMeta
,
mgmtGetVnodeMeta
,
};
int
(
*
mgmtRetrieveFp
[])(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
)
=
{
mgmtRetrieveAccts
,
mgmtRetrieveUsers
,
mgmtRetrieveDbs
,
mgmtRetrieveMeters
,
mgmtRetrieveDnodes
,
mgmtRetrieveMnodes
,
mgmtRetrieveVgroups
,
mgmtRetrieveMetrics
,
mgmtRetrieveModules
,
mgmtRetrieveQueries
,
mgmtRetrieveStreams
,
mgmtRetrieveConfigs
,
mgmtRetrieveConns
,
mgmtRetrieveScores
,
grantRetrieveGrants
,
mgmtRetrieveVnodes
,
};
static
void
mgmtInitShowMsgFp
()
{
mgmtGetMetaFp
=
(
GetMateFp
*
)
malloc
(
TSDB_MGMT_TABLE_MAX
*
sizeof
(
GetMateFp
));
mgmtGetMetaFp
[
TSDB_MGMT_TABLE_ACCT
]
=
mgmtGetAcctMeta
;
mgmtGetMetaFp
[
TSDB_MGMT_TABLE_USER
]
=
mgmtGetUserMeta
;
mgmtGetMetaFp
[
TSDB_MGMT_TABLE_DB
]
=
mgmtGetDbMeta
;
mgmtGetMetaFp
[
TSDB_MGMT_TABLE_TABLE
]
=
mgmtGetTableMeta
;
mgmtGetMetaFp
[
TSDB_MGMT_TABLE_DNODE
]
=
mgmtGetDnodeMeta
;
mgmtGetMetaFp
[
TSDB_MGMT_TABLE_MNODE
]
=
mgmtGetMnodeMeta
;
mgmtGetMetaFp
[
TSDB_MGMT_TABLE_VGROUP
]
=
mgmtGetVgroupMeta
;
mgmtGetMetaFp
[
TSDB_MGMT_TABLE_METRIC
]
=
mgmtGetMetricMeta
;
mgmtGetMetaFp
[
TSDB_MGMT_TABLE_MODULE
]
=
mgmtGetModuleMeta
;
mgmtGetMetaFp
[
TSDB_MGMT_TABLE_QUERIES
]
=
mgmtGetQueryMeta
;
mgmtGetMetaFp
[
TSDB_MGMT_TABLE_STREAMS
]
=
mgmtGetStreamMeta
;
mgmtGetMetaFp
[
TSDB_MGMT_TABLE_CONFIGS
]
=
mgmtGetConfigMeta
;
mgmtGetMetaFp
[
TSDB_MGMT_TABLE_CONNS
]
=
mgmtGetConnsMeta
;
mgmtGetMetaFp
[
TSDB_MGMT_TABLE_SCORES
]
=
mgmtGetScoresMeta
;
mgmtGetMetaFp
[
TSDB_MGMT_TABLE_GRANTS
]
=
mgmtGetGrantsMeta
;
mgmtGetMetaFp
[
TSDB_MGMT_TABLE_VNODES
]
=
mgmtGetVnodeMeta
;
mgmtRetrieveFp
=
(
RetrieveMetaFp
*
)
malloc
(
TSDB_MGMT_TABLE_MAX
*
sizeof
(
RetrieveMetaFp
));
mgmtRetrieveFp
[
TSDB_MGMT_TABLE_ACCT
]
=
mgmtRetrieveAccts
;
mgmtRetrieveFp
[
TSDB_MGMT_TABLE_USER
]
=
mgmtRetrieveUsers
;
mgmtRetrieveFp
[
TSDB_MGMT_TABLE_DB
]
=
mgmtRetrieveDbs
;
mgmtRetrieveFp
[
TSDB_MGMT_TABLE_TABLE
]
=
mgmtRetrieveMeters
;
mgmtRetrieveFp
[
TSDB_MGMT_TABLE_DNODE
]
=
mgmtRetrieveDnodes
;
mgmtRetrieveFp
[
TSDB_MGMT_TABLE_MNODE
]
=
mgmtRetrieveMnodes
;
mgmtRetrieveFp
[
TSDB_MGMT_TABLE_VGROUP
]
=
mgmtRetrieveVgroups
;
mgmtRetrieveFp
[
TSDB_MGMT_TABLE_METRIC
]
=
mgmtRetrieveMetrics
;
mgmtRetrieveFp
[
TSDB_MGMT_TABLE_MODULE
]
=
mgmtRetrieveModules
;
mgmtRetrieveFp
[
TSDB_MGMT_TABLE_QUERIES
]
=
mgmtRetrieveQueries
;
mgmtRetrieveFp
[
TSDB_MGMT_TABLE_STREAMS
]
=
mgmtRetrieveStreams
;
mgmtRetrieveFp
[
TSDB_MGMT_TABLE_CONFIGS
]
=
mgmtRetrieveConfigs
;
mgmtRetrieveFp
[
TSDB_MGMT_TABLE_CONNS
]
=
mgmtRetrieveConns
;
mgmtRetrieveFp
[
TSDB_MGMT_TABLE_SCORES
]
=
mgmtRetrieveScores
;
mgmtRetrieveFp
[
TSDB_MGMT_TABLE_GRANTS
]
=
mgmtRetrieveGrants
;
mgmtRetrieveFp
[
TSDB_MGMT_TABLE_VNODES
]
=
mgmtRetrieveVnodes
;
}
int
mgmtProcessShowMsg
(
char
*
pMsg
,
int
msgLen
,
SConnObj
*
pConn
)
{
SShowMsg
*
pShowMsg
=
(
SShowMsg
*
)
pMsg
;
...
...
src/mnode/src/mgmtSupertableQuery.c
浏览文件 @
9427e9d8
...
...
@@ -15,13 +15,13 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnode.h"
#include "mgmtUtil.h"
#include "textbuffer.h"
#include "tschemautil.h"
#include "tsqlfunction.h"
#include "vnodeTagMgmt.h"
#include "tast.h"
//#include "vnodeTagMgmt.h"
typedef
struct
SSyntaxTreeFilterSupporter
{
SSchema
*
pTagSchema
;
...
...
src/mnode/src/mgmtSystem.spec.c
浏览文件 @
9427e9d8
...
...
@@ -36,8 +36,3 @@ void mgmtStopSystem() {}
void
mgmtCleanUpRedirect
()
{}
int
grantGetGrantsMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
return
TSDB_CODE_OPS_NOT_SUPPORT
;
}
int
grantRetrieveGrants
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
)
{
return
0
;
}
src/mnode/src/mgmtTable.c
浏览文件 @
9427e9d8
...
...
@@ -20,6 +20,9 @@
#include "mgmtAcct.h"
#include "mgmtGrant.h"
#include "mgmtUtil.h"
#include "mgmtDb.h"
#include "mgmtDnodeInt.h"
#include "mgmtSupertableQuery.h"
#include "taosmsg.h"
#include "tast.h"
#include "textbuffer.h"
...
...
@@ -28,8 +31,7 @@
#include "tskiplist.h"
#include "tsqlfunction.h"
#include "ttime.h"
#include "vnodeTagMgmt.h"
#include "vnodeStatus.h"
#include "tstatus.h"
extern
int64_t
sdbVersion
;
...
...
@@ -93,8 +95,6 @@ int32_t mgmtMeterDropColumnByName(STabObj *pTable, const char *name);
static
int
dropMeterImp
(
SDbObj
*
pDb
,
STabObj
*
pTable
,
SAcctObj
*
pAcct
);
static
void
dropAllMetersOfMetric
(
SDbObj
*
pDb
,
STabObj
*
pMetric
,
SAcctObj
*
pAcct
);
int
mgmtCheckTableLimit
(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
);
void
mgmtMeterActionInit
()
{
mgmtMeterActionFp
[
SDB_TYPE_INSERT
]
=
mgmtMeterActionInsert
;
mgmtMeterActionFp
[
SDB_TYPE_DELETE
]
=
mgmtMeterActionDelete
;
...
...
src/mnode/src/mgmtVgroup.c
浏览文件 @
9427e9d8
...
...
@@ -17,9 +17,13 @@
#include "os.h"
#include "mnode.h"
#include "mgmtBalance.h"
#include "mgmtDb.h"
#include "mgmtDnode.h"
#include "mgmtDnodeInt.h"
#include "tschemautil.h"
#include "tlog.h"
#include "
vnodeS
tatus.h"
#include "
ts
tatus.h"
void
*
vgSdb
=
NULL
;
int
tsVgUpdateSize
;
...
...
@@ -39,8 +43,6 @@ void *mgmtVgroupActionBatchUpdate(void *row, char *str, int size, int *ssize);
void
*
mgmtVgroupActionAfterBatchUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtVgroupActionReset
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtVgroupActionDestroy
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
bool
mgmtCheckVnodeReady
(
SDnodeObj
*
pDnode
,
SVgObj
*
pVgroup
,
SVnodeGid
*
pVnode
);
char
*
mgmtGetVnodeStatus
(
SVgObj
*
pVgroup
,
SVnodeGid
*
pVnode
);
void
mgmtVgroupActionInit
()
{
mgmtVgroupActionFp
[
SDB_TYPE_INSERT
]
=
mgmtVgroupActionInsert
;
...
...
src/util/inc/textbuffer.h
浏览文件 @
9427e9d8
...
...
@@ -123,6 +123,22 @@ typedef struct tExtMemBuffer {
EXT_BUFFER_FLUSH_MODEL
flushModel
;
}
tExtMemBuffer
;
typedef
struct
tTagSchema
{
struct
SSchema
*
pSchema
;
int32_t
numOfCols
;
int32_t
colOffset
[];
}
tTagSchema
;
typedef
struct
tSidSet
{
int32_t
numOfSids
;
int32_t
numOfSubSet
;
SMeterSidExtInfo
**
pSids
;
int32_t
*
starterPos
;
// position of each subgroup, generated according to
tTagSchema
*
pTagSchema
;
tOrderIdx
orderIdx
;
}
tSidSet
;
void
getTmpfilePath
(
const
char
*
fileNamePattern
,
char
*
dstPath
);
/*
...
...
src/util/inc/tstatus.h
浏览文件 @
9427e9d8
...
...
@@ -19,7 +19,7 @@
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdint.h>
#include <stdbool.h>
#include "taoserror.h"
...
...
src/vnode/detail/inc/vnodeTagMgmt.h
浏览文件 @
9427e9d8
...
...
@@ -33,22 +33,6 @@ extern "C" {
* 1. we implement a quick sort algorithm, may remove it later.
*/
typedef
struct
tTagSchema
{
struct
SSchema
*
pSchema
;
int32_t
numOfCols
;
int32_t
colOffset
[];
}
tTagSchema
;
typedef
struct
tSidSet
{
int32_t
numOfSids
;
int32_t
numOfSubSet
;
SMeterSidExtInfo
**
pSids
;
int32_t
*
starterPos
;
// position of each subgroup, generated according to
tTagSchema
*
pTagSchema
;
tOrderIdx
orderIdx
;
}
tSidSet
;
typedef
int32_t
(
*
__ext_compar_fn_t
)(
const
void
*
p1
,
const
void
*
p2
,
void
*
param
);
tSidSet
*
tSidSetCreate
(
struct
SMeterSidExtInfo
**
pMeterSidExtInfo
,
int32_t
numOfMeters
,
SSchema
*
pSchema
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录