Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5cb76602
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5cb76602
编写于
2月 27, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
communication from dnode to mgmt
上级
86402cc9
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
296 addition
and
410 deletion
+296
-410
src/dnode/src/dnodeMgmt.c
src/dnode/src/dnodeMgmt.c
+20
-15
src/inc/dnode.h
src/inc/dnode.h
+5
-0
src/inc/mnode.h
src/inc/mnode.h
+3
-1
src/inc/taoserror.h
src/inc/taoserror.h
+1
-0
src/inc/taosmsg.h
src/inc/taosmsg.h
+14
-7
src/mnode/inc/mgmtChildTable.h
src/mnode/inc/mgmtChildTable.h
+1
-1
src/mnode/inc/mgmtDnode.h
src/mnode/inc/mgmtDnode.h
+1
-0
src/mnode/inc/mgmtDnodeInt.h
src/mnode/inc/mgmtDnodeInt.h
+7
-11
src/mnode/inc/mgmtTable.h
src/mnode/inc/mgmtTable.h
+3
-0
src/mnode/inc/mgmtVgroup.h
src/mnode/inc/mgmtVgroup.h
+6
-0
src/mnode/src/mgmtChildTable.c
src/mnode/src/mgmtChildTable.c
+2
-2
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+2
-2
src/mnode/src/mgmtDnode.c
src/mnode/src/mgmtDnode.c
+3
-1
src/mnode/src/mgmtDnodeInt.c
src/mnode/src/mgmtDnodeInt.c
+138
-368
src/mnode/src/mgmtNormalTable.c
src/mnode/src/mgmtNormalTable.c
+1
-1
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+28
-0
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+61
-1
未找到文件。
src/dnode/src/dnodeMgmt.c
浏览文件 @
5cb76602
...
@@ -31,44 +31,49 @@ void (*dnodeInitMgmtIpFp)() = NULL;
...
@@ -31,44 +31,49 @@ void (*dnodeInitMgmtIpFp)() = NULL;
int32_t
(
*
dnodeInitMgmtFp
)()
=
NULL
;
int32_t
(
*
dnodeInitMgmtFp
)()
=
NULL
;
void
(
*
dnodeProcessStatusRspFp
)(
int8_t
*
pCont
,
int32_t
contLen
,
int8_t
msgType
,
void
*
pConn
)
=
NULL
;
void
(
*
dnodeProcessStatusRspFp
)(
int8_t
*
pCont
,
int32_t
contLen
,
int8_t
msgType
,
void
*
pConn
)
=
NULL
;
void
(
*
dnodeSendMsgToMnodeFp
)(
int8_t
msgType
,
void
*
pCont
,
int32_t
contLen
)
=
NULL
;
void
(
*
dnodeSendMsgToMnodeFp
)(
int8_t
msgType
,
void
*
pCont
,
int32_t
contLen
)
=
NULL
;
void
(
*
dnodeSendRspToMnodeFp
)(
void
*
handle
,
int32_t
code
,
void
*
pCont
,
int
contLen
)
=
NULL
;
static
int32_t
(
*
dnodeProcessMgmtMsgFp
[
TSDB_MSG_TYPE_MAX
])(
int8_t
*
pCont
,
int32_t
contLen
,
int8_t
msgType
,
void
*
pConn
);
static
int32_t
(
*
dnodeProcessMgmtMsgFp
[
TSDB_MSG_TYPE_MAX
])(
int8_t
*
pCont
,
int32_t
contLen
,
int8_t
msgType
,
void
*
pConn
);
static
void
dnodeInitProcessShellMsg
();
static
void
dnodeInitProcessShellMsg
();
static
void
dnodeSendMsgToMnodeQueueFp
(
SSchedMsg
*
sched
)
{
static
void
dnodeSendMsgToMnodeQueueFp
(
SSchedMsg
*
sched
)
{
int8_t
msgType
=
*
(
int8_t
*
)
(
sched
->
msg
-
sizeof
(
int32_t
)
-
sizeof
(
int8_t
));
int32_t
contLen
=
*
(
int32_t
*
)
(
sched
->
msg
-
4
);
int32_t
contLen
=
*
(
int32_t
*
)
(
sched
->
msg
-
sizeof
(
int8_t
));
int32_t
code
=
*
(
int32_t
*
)
(
sched
->
msg
-
8
);
int8_t
*
pCont
=
sched
->
msg
;
int8_t
msgType
=
*
(
int8_t
*
)
(
sched
->
msg
-
9
);
void
*
pConn
=
NULL
;
void
*
handle
=
sched
->
ahandle
;
int8_t
*
pCont
=
sched
->
msg
;
mgmtProcessMsgFromDnode
(
pCont
,
contLen
,
msgType
,
pConn
);
mgmtProcessMsgFromDnode
(
pCont
,
contLen
,
handle
,
code
);
rpcFreeCont
(
sched
->
msg
);
rpcFreeCont
(
sched
->
msg
);
}
}
void
dnodeSendMsgToMnode
(
int8_t
msgType
,
void
*
pCont
,
int32_t
contLen
)
{
void
dnodeSendMsgToMnode
(
int8_t
msgType
,
void
*
pCont
,
int32_t
contLen
,
void
*
ahandle
)
{
dTrace
(
"msg:%s is sent to mnode"
,
taosMsg
[
msgType
]);
dTrace
(
"msg:%s is sent to mnode"
,
taosMsg
[
msgType
]);
if
(
dnodeSendMsgToMnodeFp
)
{
if
(
dnodeSendMsgToMnodeFp
)
{
dnodeSendMsgToMnodeFp
(
msgType
,
pCont
,
contLen
);
dnodeSendMsgToMnodeFp
(
msgType
,
pCont
,
contLen
);
}
else
{
}
else
{
SSchedMsg
schedMsg
=
{
0
};
SSchedMsg
schedMsg
=
{
0
};
schedMsg
.
fp
=
dnodeSendMsgToMnodeQueueFp
;
schedMsg
.
fp
=
dnodeSendMsgToMnodeQueueFp
;
schedMsg
.
msg
=
pCont
;
schedMsg
.
msg
=
pCont
;
*
(
int8_t
*
)
(
pCont
-
sizeof
(
int32_t
)
-
sizeof
(
int8_t
))
=
msgType
;
schedMsg
.
ahandle
=
ahandle
;
*
(
int32_t
*
)
(
pCont
-
sizeof
(
int8_t
))
=
contLen
;
*
(
int32_t
*
)
(
pCont
-
4
)
=
contLen
;
*
(
int32_t
*
)
(
pCont
-
8
)
=
TSDB_CODE_SUCCESS
;
*
(
int8_t
*
)
(
pCont
-
9
)
=
msgType
;
taosScheduleTask
(
tsDnodeMgmtQhandle
,
&
schedMsg
);
taosScheduleTask
(
tsDnodeMgmtQhandle
,
&
schedMsg
);
}
}
}
}
void
dnodeSendRspToMnode
(
void
*
pConn
,
int8_t
msgType
,
int32_t
code
,
void
*
pCont
,
int32_t
contLen
)
{
void
dnodeSendRspToMnode
(
void
*
pConn
,
int8_t
msgType
,
int32_t
code
,
void
*
pCont
,
int32_t
contLen
)
{
dTrace
(
"rsp:%s is sent to mnode"
,
taosMsg
[
msgType
]);
dTrace
(
"rsp:%s is sent to mnode"
,
taosMsg
[
msgType
]);
if
(
tsIsCluster
)
{
if
(
dnodeSendRspToMnodeFp
)
{
rpcSendResponse
(
pConn
,
code
,
pCont
,
contLen
);
dnodeSendRspToMnodeFp
(
pConn
,
code
,
pCont
,
contLen
);
}
else
{
}
else
{
SSchedMsg
schedMsg
=
{
0
};
SSchedMsg
schedMsg
=
{
0
};
schedMsg
.
fp
=
dnodeSendMsgToMnodeFp
;
schedMsg
.
fp
=
dnodeSendMsgToMnodeFp
;
schedMsg
.
msg
=
pCont
;
schedMsg
.
msg
=
pCont
;
*
(
int8_t
*
)
(
pCont
-
sizeof
(
int32_t
)
-
sizeof
(
int8_t
))
=
msgType
;
*
(
int32_t
*
)
(
pCont
-
4
)
=
contLen
;
*
(
int32_t
*
)
(
pCont
-
sizeof
(
int8_t
))
=
contLen
;
*
(
int32_t
*
)
(
pCont
-
8
)
=
code
;
*
(
int8_t
*
)
(
pCont
-
9
)
=
msgType
;
taosScheduleTask
(
tsDnodeMgmtQhandle
,
&
schedMsg
);
taosScheduleTask
(
tsDnodeMgmtQhandle
,
&
schedMsg
);
}
}
}
}
...
@@ -88,7 +93,7 @@ void dnodeInitMgmtIp() {
...
@@ -88,7 +93,7 @@ void dnodeInitMgmtIp() {
}
}
}
}
void
dnodeProcessMsgFromMgmt
(
char
msgType
,
void
*
pCont
,
int
contLen
,
void
*
pConn
,
int32_t
code
)
{
void
dnodeProcessMsgFromMgmt
(
char
msgType
,
void
*
pCont
,
int
contLen
,
void
*
handle
,
int32_t
code
)
{
if
(
msgType
<
0
||
msgType
>=
TSDB_MSG_TYPE_MAX
)
{
if
(
msgType
<
0
||
msgType
>=
TSDB_MSG_TYPE_MAX
)
{
dError
(
"invalid msg type:%d"
,
msgType
);
dError
(
"invalid msg type:%d"
,
msgType
);
}
else
{
}
else
{
...
...
src/inc/dnode.h
浏览文件 @
5cb76602
...
@@ -46,6 +46,11 @@ extern void (*dnodeParseParameterK)();
...
@@ -46,6 +46,11 @@ extern void (*dnodeParseParameterK)();
extern
int32_t
(
*
dnodeCheckSystem
)();
extern
int32_t
(
*
dnodeCheckSystem
)();
// dnodeSystem
extern
void
*
tsDnodeMgmtQhandle
;
void
dnodeProcessMsgFromMgmt
(
char
msgType
,
void
*
pCont
,
int
contLen
,
void
*
pConn
,
int32_t
code
);
// dnodeModule
// dnodeModule
extern
void
(
*
dnodeStartModules
)();
extern
void
(
*
dnodeStartModules
)();
...
...
src/inc/mnode.h
浏览文件 @
5cb76602
...
@@ -258,11 +258,13 @@ typedef struct {
...
@@ -258,11 +258,13 @@ typedef struct {
//mgmtSystem
//mgmtSystem
int32_t
mgmtStartSystem
();
int32_t
mgmtStartSystem
();
void
mgmtCleanUpSystem
();
void
mgmtCleanUpSystem
();
void
mgmtProcessMsgFromDnode
(
int8_t
*
pCont
,
int32_t
contLen
,
int32_t
msgType
,
void
*
pConn
);
void
mgmtProcessMsgFromDnode
(
char
msgType
,
void
*
pCont
,
int
contLen
,
void
*
pConn
,
int32_t
code
);
extern
int32_t
(
*
mgmtInitSystem
)();
extern
int32_t
(
*
mgmtInitSystem
)();
extern
void
(
*
mgmtStopSystem
)();
extern
void
(
*
mgmtStopSystem
)();
extern
void
(
*
mgmtCleanUpRedirect
)();
extern
void
(
*
mgmtCleanUpRedirect
)();
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
src/inc/taoserror.h
浏览文件 @
5cb76602
...
@@ -162,6 +162,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_FAILED_TO_LOCK_RESOURCES, 0, 117, "failed to lock
...
@@ -162,6 +162,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_FAILED_TO_LOCK_RESOURCES, 0, 117, "failed to lock
TAOS_DEFINE_ERROR
(
TSDB_CODE_TABLE_ID_MISMATCH
,
0
,
118
,
"table id mismatch"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TABLE_ID_MISMATCH
,
0
,
118
,
"table id mismatch"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_QUERY_CACHE_ERASED
,
0
,
119
,
"query cache erased"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_QUERY_CACHE_ERASED
,
0
,
119
,
"query cache erased"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_MSG
,
0
,
120
,
"invalid message"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_MSG
,
0
,
120
,
"invalid message"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_TABLE_TYPE
,
0
,
121
,
"invalid table typee"
)
#ifdef TAOS_ERROR_C
#ifdef TAOS_ERROR_C
};
};
...
...
src/inc/taosmsg.h
浏览文件 @
5cb76602
...
@@ -240,10 +240,11 @@ typedef struct {
...
@@ -240,10 +240,11 @@ typedef struct {
int16_t
numOfTags
;
int16_t
numOfTags
;
int32_t
tagDataLen
;
int32_t
tagDataLen
;
int32_t
sqlDataLen
;
int32_t
sqlDataLen
;
int32_t
contLen
;
uint64_t
createdTime
;
uint64_t
createdTime
;
char
tableId
[
TSDB_TABLE_ID_LEN
+
1
];
char
tableId
[
TSDB_TABLE_ID_LEN
+
1
];
char
superTableId
[
TSDB_TABLE_ID_LEN
+
1
];
char
superTableId
[
TSDB_TABLE_ID_LEN
+
1
];
int8_t
data
[];
char
data
[];
}
SDCreateTableMsg
;
}
SDCreateTableMsg
;
typedef
struct
{
typedef
struct
{
...
@@ -325,9 +326,13 @@ typedef struct {
...
@@ -325,9 +326,13 @@ typedef struct {
short
vnode
;
short
vnode
;
int32_t
sid
;
int32_t
sid
;
uint64_t
uid
;
uint64_t
uid
;
char
tableId
[
TSDB_TABLE_ID_LEN
];
char
tableId
[
TSDB_TABLE_ID_LEN
+
1
];
}
SDRemoveTableMsg
;
}
SDRemoveTableMsg
;
typedef
struct
{
char
tableId
[
TSDB_TABLE_ID_LEN
+
1
];
}
SDRemoveSuperTableMsg
;
typedef
struct
{
typedef
struct
{
int32_t
vnode
;
int32_t
vnode
;
}
SFreeVnodeMsg
;
}
SFreeVnodeMsg
;
...
@@ -603,8 +608,8 @@ typedef struct {
...
@@ -603,8 +608,8 @@ typedef struct {
}
SSecIe
;
}
SSecIe
;
typedef
struct
{
typedef
struct
{
int32_t
dnode
;
//the ID
of dnode
uint32_t
dnode
;
//the ip
of dnode
int32_t
vnode
;
//the index of vnode
int32_t
vnode
;
//the index of vnode
uint32_t
ip
;
uint32_t
ip
;
}
SVPeerDesc
;
}
SVPeerDesc
;
...
@@ -616,7 +621,7 @@ typedef struct {
...
@@ -616,7 +621,7 @@ typedef struct {
typedef
struct
{
typedef
struct
{
int32_t
vnode
;
int32_t
vnode
;
SVnodeCfg
cfg
;
SVnodeCfg
cfg
;
SVPeerDesc
vpeerDesc
[];
SVPeerDesc
vpeerDesc
[
TSDB_MAX_MPEERS
];
}
SVPeersMsg
;
}
SVPeersMsg
;
typedef
struct
{
typedef
struct
{
...
@@ -732,11 +737,13 @@ typedef struct {
...
@@ -732,11 +737,13 @@ typedef struct {
}
SCreateMnodeMsg
,
SDropMnodeMsg
,
SCreateDnodeMsg
,
SDropDnodeMsg
;
}
SCreateMnodeMsg
,
SDropMnodeMsg
,
SCreateDnodeMsg
,
SDropDnodeMsg
;
typedef
struct
{
typedef
struct
{
int32_t
vnode
;
uint32_t
dnode
;
int32_t
sid
;
int32_t
vnode
;
int32_t
sid
;
}
STableCfgMsg
;
}
STableCfgMsg
;
typedef
struct
{
typedef
struct
{
uint32_t
dnode
;
int32_t
vnode
;
int32_t
vnode
;
}
SVpeerCfgMsg
;
}
SVpeerCfgMsg
;
...
...
src/mnode/inc/mgmtChildTable.h
浏览文件 @
5cb76602
...
@@ -35,7 +35,7 @@ int32_t mgmtCreateChildTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVgr
...
@@ -35,7 +35,7 @@ int32_t mgmtCreateChildTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVgr
int32_t
mgmtDropChildTable
(
SDbObj
*
pDb
,
SChildTableObj
*
pTable
);
int32_t
mgmtDropChildTable
(
SDbObj
*
pDb
,
SChildTableObj
*
pTable
);
int32_t
mgmtAlterChildTable
(
SDbObj
*
pDb
,
SAlterTableMsg
*
pAlter
);
int32_t
mgmtAlterChildTable
(
SDbObj
*
pDb
,
SAlterTableMsg
*
pAlter
);
int32_t
mgmtModifyChildTableTagValueByName
(
SChildTableObj
*
pTable
,
char
*
tagName
,
char
*
nContent
);
int32_t
mgmtModifyChildTableTagValueByName
(
SChildTableObj
*
pTable
,
char
*
tagName
,
char
*
nContent
);
int8_t
*
mgmtBuildCreateChildTableMsg
(
SChildTableObj
*
pTable
,
SVgObj
*
pVgroup
);
SCreateTableMsg
*
mgmtBuildCreateChildTableMsg
(
SChildTableObj
*
pTable
);
int32_t
mgmtGetChildTableMeta
(
SDbObj
*
pDb
,
SChildTableObj
*
pTable
,
STableMeta
*
pMeta
,
bool
usePublicIp
);
int32_t
mgmtGetChildTableMeta
(
SDbObj
*
pDb
,
SChildTableObj
*
pTable
,
STableMeta
*
pMeta
,
bool
usePublicIp
);
...
...
src/mnode/inc/mgmtDnode.h
浏览文件 @
5cb76602
...
@@ -57,6 +57,7 @@ extern bool (*mgmtCheckConfigShow)(SGlobalConfig *cfg);
...
@@ -57,6 +57,7 @@ extern bool (*mgmtCheckConfigShow)(SGlobalConfig *cfg);
extern
SDnodeObj
tsDnodeObj
;
extern
SDnodeObj
tsDnodeObj
;
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
src/mnode/inc/mgmtDnodeInt.h
浏览文件 @
5cb76602
...
@@ -26,23 +26,19 @@ extern "C" {
...
@@ -26,23 +26,19 @@ extern "C" {
extern
void
*
mgmtStatusTimer
;
extern
void
*
mgmtStatusTimer
;
int32_t
mgmtSendCreateTableMsg
(
SChildTableObj
*
pTable
,
SVgObj
*
pVgroup
);
void
mgmtSendCreateTableMsg
(
STableInfo
*
pTable
,
SRpcIpSet
*
ipSet
,
void
*
handle
);
int32_t
mgmtSendCreateNormalTableMsg
(
SNormalTableObj
*
pTable
,
SVgObj
*
pVgroup
);
void
mgmtSendRemoveTableMsg
(
STableInfo
*
pTable
,
SRpcIpSet
*
ipSet
,
void
*
handle
);
void
mgmtSendAlterStreamMsg
(
STableInfo
*
pTable
,
SRpcIpSet
*
ipSet
,
void
*
handle
);
void
mgmtSendVPeersMsg
(
SVgObj
*
pVgroup
,
int32_t
vnode
,
SRpcIpSet
*
ipSet
,
void
*
handle
);
void
mgmtSendOneFreeVnodeMsg
(
int32_t
vnode
,
SRpcIpSet
*
ipSet
,
void
*
handle
);
int
mgmtSendRemoveMeterMsgToDnode
(
STableInfo
*
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
int32_t
(
*
mgmtSendSimpleRspToDnode
)(
void
*
pConn
,
int32_t
msgType
,
int32_t
code
);
extern
int32_t
(
*
mgmtSendMsgToDnode
)(
int8_t
*
pCont
,
int32_t
contLen
,
int8_t
msgType
);
extern
int32_t
(
*
mgmtInitDnodeInt
)();
extern
int32_t
(
*
mgmtInitDnodeInt
)();
extern
void
(
*
mgmtCleanUpDnodeInt
)();
extern
void
(
*
mgmtCleanUpDnodeInt
)();
extern
void
(
*
mgmtProcessDnodeStatus
)(
void
*
handle
,
void
*
tmrId
);
extern
void
(
*
mgmtProcessDnodeStatus
)(
void
*
handle
,
void
*
tmrId
);
void
mgmtSendMsgToDnode
(
int8_t
msgType
,
void
*
pCont
,
int32_t
contLen
,
void
*
ahandle
);
void
mgmtSendRspToDnode
(
void
*
pConn
,
int8_t
msgType
,
int32_t
code
,
void
*
pCont
,
int32_t
contLen
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/mnode/inc/mgmtTable.h
浏览文件 @
5cb76602
...
@@ -41,6 +41,9 @@ void mgmtCleanUpMeters();
...
@@ -41,6 +41,9 @@ void mgmtCleanUpMeters();
void
mgmtAddTableIntoSuperTable
(
SSuperTableObj
*
pStable
);
void
mgmtAddTableIntoSuperTable
(
SSuperTableObj
*
pStable
);
void
mgmtRemoveTableFromSuperTable
(
SSuperTableObj
*
pStable
);
void
mgmtRemoveTableFromSuperTable
(
SSuperTableObj
*
pStable
);
SDCreateTableMsg
*
mgmtBuildCreateTableMsg
(
STableInfo
*
pTable
);
SDRemoveTableMsg
*
mgmtBuildRemoveTableMsg
(
STableInfo
*
pTable
);
SDRemoveSuperTableMsg
*
mgmtBuildRemoveSuperTableMsg
(
STableInfo
*
pTable
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/mnode/inc/mgmtVgroup.h
浏览文件 @
5cb76602
...
@@ -27,6 +27,7 @@ extern "C" {
...
@@ -27,6 +27,7 @@ extern "C" {
int32_t
mgmtInitVgroups
();
int32_t
mgmtInitVgroups
();
void
mgmtCleanUpVgroups
();
void
mgmtCleanUpVgroups
();
SVgObj
*
mgmtGetVgroup
(
int32_t
vgId
);
SVgObj
*
mgmtGetVgroup
(
int32_t
vgId
);
SVgObj
*
mgmtGetVgroupByVnode
(
uint32_t
dnode
,
int32_t
vnode
);
SVgObj
*
mgmtCreateVgroup
(
SDbObj
*
pDb
);
SVgObj
*
mgmtCreateVgroup
(
SDbObj
*
pDb
);
int32_t
mgmtDropVgroup
(
SDbObj
*
pDb
,
SVgObj
*
pVgroup
);
int32_t
mgmtDropVgroup
(
SDbObj
*
pDb
,
SVgObj
*
pVgroup
);
...
@@ -41,6 +42,11 @@ SVgObj *mgmtGetAvailVgroup(SDbObj *pDb, int32_t *sid);
...
@@ -41,6 +42,11 @@ SVgObj *mgmtGetAvailVgroup(SDbObj *pDb, int32_t *sid);
void
mgmtAddTableIntoVgroup
(
SVgObj
*
pVgroup
,
STableInfo
*
pTable
);
void
mgmtAddTableIntoVgroup
(
SVgObj
*
pVgroup
,
STableInfo
*
pTable
);
void
mgmtRemoveTableFromVgroup
(
SVgObj
*
pVgroup
,
STableInfo
*
pTable
);
void
mgmtRemoveTableFromVgroup
(
SVgObj
*
pVgroup
,
STableInfo
*
pTable
);
SVPeersMsg
*
mgmtBuildVpeersMsg
(
SVgObj
*
pVgroup
,
int32_t
vnode
);
SRpcIpSet
mgmtGetIpSetFromVgroup
(
SVgObj
*
pVgroup
);
SRpcIpSet
mgmtGetIpSetFromIp
(
uint32_t
ip
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
src/mnode/src/mgmtChildTable.c
浏览文件 @
5cb76602
...
@@ -273,7 +273,7 @@ void mgmtCleanUpChildTables() {
...
@@ -273,7 +273,7 @@ void mgmtCleanUpChildTables() {
sdbCloseTable
(
tsChildTableSdb
);
sdbCloseTable
(
tsChildTableSdb
);
}
}
int8_t
*
mgmtBuildCreateChildTableMsg
(
SChildTableObj
*
pTable
,
SVgObj
*
pVgroup
)
{
SCreateTableMsg
*
mgmtBuildCreateChildTableMsg
(
SChildTableObj
*
pTable
)
{
// SCreateTableMsg *pCreateTable = (SCreateTableMsg *) pMsg;
// SCreateTableMsg *pCreateTable = (SCreateTableMsg *) pMsg;
// memcpy(pCreateTable->tableId, pTable->tableId, TSDB_TABLE_ID_LEN);
// memcpy(pCreateTable->tableId, pTable->tableId, TSDB_TABLE_ID_LEN);
// memcpy(pCreateTable->superTableId, pTable->superTable->tableId, TSDB_TABLE_ID_LEN);
// memcpy(pCreateTable->superTableId, pTable->superTable->tableId, TSDB_TABLE_ID_LEN);
...
@@ -360,7 +360,7 @@ int32_t mgmtDropChildTable(SDbObj *pDb, SChildTableObj *pTable) {
...
@@ -360,7 +360,7 @@ int32_t mgmtDropChildTable(SDbObj *pDb, SChildTableObj *pTable) {
return
TSDB_CODE_OTHERS
;
return
TSDB_CODE_OTHERS
;
}
}
mgmtSendRemove
MeterMsgToDnode
((
STableInfo
*
)
pTable
,
pVgroup
);
mgmtSendRemove
TableMsg
((
STableInfo
*
)
pTable
,
pVgroup
);
sdbDeleteRow
(
tsChildTableSdb
,
pTable
);
sdbDeleteRow
(
tsChildTableSdb
,
pTable
);
...
...
src/mnode/src/mgmtDb.c
浏览文件 @
5cb76602
...
@@ -295,7 +295,7 @@ int32_t mgmtSetDbDropping(SDbObj *pDb) {
...
@@ -295,7 +295,7 @@ int32_t mgmtSetDbDropping(SDbObj *pDb) {
}
}
}
}
}
}
mgmtSendFreeVnodeMsg
(
pVgroup
);
mgmtSendFreeVnode
s
Msg
(
pVgroup
);
pVgroup
=
pVgroup
->
next
;
pVgroup
=
pVgroup
->
next
;
}
}
...
@@ -355,7 +355,7 @@ int32_t mgmtDropDb(SDbObj *pDb) {
...
@@ -355,7 +355,7 @@ int32_t mgmtDropDb(SDbObj *pDb) {
if
(
!
finished
)
{
if
(
!
finished
)
{
SVgObj
*
pVgroup
=
pDb
->
pHead
;
SVgObj
*
pVgroup
=
pDb
->
pHead
;
while
(
pVgroup
!=
NULL
)
{
while
(
pVgroup
!=
NULL
)
{
mgmtSendFreeVnodeMsg
(
pVgroup
);
mgmtSendFreeVnode
s
Msg
(
pVgroup
);
pVgroup
=
pVgroup
->
next
;
pVgroup
=
pVgroup
->
next
;
}
}
return
TSDB_CODE_ACTION_IN_PROGRESS
;
return
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
src/mnode/src/mgmtDnode.c
浏览文件 @
5cb76602
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "mgmtDnode.h"
#include "mgmtDnode.h"
#include "mgmtBalance.h"
#include "mgmtBalance.h"
#include "mgmtUser.h"
#include "mgmtUser.h"
#include "mgmtVgroup.h"
SDnodeObj
tsDnodeObj
;
SDnodeObj
tsDnodeObj
;
...
@@ -596,4 +597,5 @@ bool mgmtCheckConfigShowImp(SGlobalConfig *cfg) {
...
@@ -596,4 +597,5 @@ bool mgmtCheckConfigShowImp(SGlobalConfig *cfg) {
return
true
;
return
true
;
}
}
bool
(
*
mgmtCheckConfigShow
)(
SGlobalConfig
*
cfg
)
=
mgmtCheckConfigShowImp
;
bool
(
*
mgmtCheckConfigShow
)(
SGlobalConfig
*
cfg
)
=
mgmtCheckConfigShowImp
;
\ No newline at end of file
src/mnode/src/mgmtDnodeInt.c
浏览文件 @
5cb76602
...
@@ -15,428 +15,198 @@
...
@@ -15,428 +15,198 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "taoserror.h"
#include "mnode.h"
#include "tsched.h"
#include "tstatus.h"
#include "tsystem.h"
#include "tutil.h"
#include "dnode.h"
#include "dnode.h"
#include "m
gmtDnodeInt
.h"
#include "m
node
.h"
#include "mgmtBalance.h"
#include "mgmtBalance.h"
#include "mgmtDnode.h"
#include "mgmtDb.h"
#include "mgmtDb.h"
#include "mgmtVgroup.h"
#include "mgmtDnode.h"
#include "mgmtDnodeInt.h"
#include "mgmtTable.h"
#include "mgmtTable.h"
#include "tutil.h"
#include "mgmtVgroup.h"
#include "tstatus.h"
#include "tsystem.h"
void
(
*
mgmtSendMsgToDnodeFp
)(
int8_t
msgType
,
void
*
pCont
,
int32_t
contLen
,
void
*
ahandle
)
=
NULL
;
#include "tsched.h"
void
(
*
mgmtSendRspToDnodeFp
)(
void
*
handle
,
int32_t
code
,
void
*
pCont
,
int32_t
contLen
)
=
NULL
;
#include "taoserror.h"
void
*
mgmtStatusTimer
=
NULL
;
#include "dnodeSystem.h"
#include "mgmtChildTable.h"
static
void
mgmtSendMsgToDnodeQueueFp
(
SSchedMsg
*
sched
)
{
#include "mgmtNormalTable.h"
int32_t
contLen
=
*
(
int32_t
*
)
(
sched
->
msg
-
4
);
int32_t
code
=
*
(
int32_t
*
)
(
sched
->
msg
-
8
);
void
mgmtProcessMsgFromDnode
(
int8_t
*
pCont
,
int32_t
contLen
,
int32_t
msgType
,
void
*
pConn
);
int8_t
msgType
=
*
(
int8_t
*
)
(
sched
->
msg
-
9
);
int
mgmtSendVPeersMsg
(
SVgObj
*
pVgroup
);
void
*
ahandle
=
sched
->
ahandle
;
char
*
mgmtBuildVpeersIe
(
char
*
pMsg
,
SVgObj
*
pVgroup
,
int
vnode
);
int8_t
*
pCont
=
sched
->
msg
;
//char *mgmtBuildCreateMeterIe(STabObj *pTable, char *pMsg, int vnode);
extern
void
*
tsDnodeMgmtQhandle
;
dnodeProcessMsgFromMgmt
(
msgType
,
pCont
,
contLen
,
ahandle
,
code
);
void
*
mgmtStatusTimer
=
NULL
;
void
mgmtSendMsgToDnodeImpFp
(
SSchedMsg
*
sched
)
{
int8_t
msgType
=
*
(
int8_t
*
)
(
sched
->
msg
-
sizeof
(
int32_t
)
-
sizeof
(
int8_t
));
int32_t
contLen
=
*
(
int32_t
*
)
(
sched
->
msg
-
sizeof
(
int8_t
));
int8_t
*
pCont
=
sched
->
msg
;
void
*
pConn
=
NULL
;
dnodeProcessMsgFromMgmt
(
msgType
,
pCont
,
contLen
,
pConn
,
TSDB_CODE_SUCCESS
);
rpcFreeCont
(
sched
->
msg
);
rpcFreeCont
(
sched
->
msg
);
}
}
int32_t
mgmtSendMsgToDnodeImp
(
int8_t
*
pCont
,
int32_t
contLen
,
int8_t
msgTyp
e
)
{
void
mgmtSendMsgToDnode
(
int8_t
msgType
,
void
*
pCont
,
int32_t
contLen
,
void
*
ahandl
e
)
{
mTrace
(
"msg:%s is sent to dnode"
,
taosMsg
[
msgType
]);
mTrace
(
"msg:%s is sent to dnode"
,
taosMsg
[
msgType
]);
*
(
int8_t
*
)
(
pCont
-
sizeof
(
int32_t
)
-
sizeof
(
int8_t
))
=
msgType
;
if
(
mgmtSendMsgToDnodeFp
)
{
*
(
int32_t
*
)
(
pCont
-
sizeof
(
int8_t
))
=
contLen
;
mgmtSendMsgToDnodeFp
(
msgType
,
pCont
,
contLen
,
ahandle
);
}
else
{
SSchedMsg
schedMsg
=
{
0
};
SSchedMsg
schedMsg
=
{
0
};
schedMsg
.
fp
=
mgmtSendMsgToDnodeImpFp
;
schedMsg
.
fp
=
mgmtSendMsgToDnodeQueueFp
;
schedMsg
.
msg
=
pCont
;
schedMsg
.
msg
=
pCont
;
schedMsg
.
ahandle
=
ahandle
;
taosScheduleTask
(
tsDnodeMgmtQhandle
,
&
schedMsg
);
*
(
int32_t
*
)
(
pCont
-
4
)
=
contLen
;
*
(
int32_t
*
)
(
pCont
-
8
)
=
TSDB_CODE_SUCCESS
;
*
(
int8_t
*
)
(
pCont
-
9
)
=
msgType
;
taosScheduleTask
(
tsDnodeMgmtQhandle
,
&
schedMsg
);
}
}
return
TSDB_CODE_SUCCESS
;
void
mgmtSendRspToDnode
(
void
*
pConn
,
int8_t
msgType
,
int32_t
code
,
void
*
pCont
,
int32_t
contLen
)
{
mTrace
(
"rsp:%s is sent to dnode"
,
taosMsg
[
msgType
]);
if
(
mgmtSendRspToDnodeFp
)
{
mgmtSendRspToDnodeFp
(
pConn
,
code
,
pCont
,
contLen
);
}
else
{
SSchedMsg
schedMsg
=
{
0
};
schedMsg
.
fp
=
mgmtSendMsgToDnodeQueueFp
;
schedMsg
.
msg
=
pCont
;
*
(
int32_t
*
)
(
pCont
-
4
)
=
contLen
;
*
(
int32_t
*
)
(
pCont
-
8
)
=
code
;
*
(
int8_t
*
)
(
pCont
-
9
)
=
msgType
;
taosScheduleTask
(
tsDnodeMgmtQhandle
,
&
schedMsg
);
}
}
}
int32_t
(
*
mgmtSendMsgToDnode
)(
int8_t
*
pCont
,
int32_t
contLen
,
int8_t
msgType
)
=
mgmtSendMsgToDnodeImp
;
static
void
mgmtProcessTableCfgMsg
(
int8_t
msgType
,
int8_t
*
pCont
,
int32_t
contLen
,
void
*
pConn
)
{
STableCfgMsg
*
pCfg
=
(
STableCfgMsg
*
)
pCont
;
pCfg
->
dnode
=
htonl
(
pCfg
->
dnode
);
pCfg
->
vnode
=
htonl
(
pCfg
->
vnode
);
pCfg
->
sid
=
htonl
(
pCfg
->
sid
);
mTrace
(
"dnode:%s, vnode:%d, sid:%d, receive table config msg"
,
taosIpStr
(
pCfg
->
dnode
),
pCfg
->
vnode
,
pCfg
->
sid
);
if
(
!
sdbMaster
)
{
mError
(
"dnode:%s, vnode:%d, sid:%d, not master, redirect it"
,
taosIpStr
(
pCfg
->
dnode
),
pCfg
->
vnode
,
pCfg
->
sid
);
mgmtSendRspToDnode
(
pConn
,
msgType
+
1
,
TSDB_CODE_REDIRECT
,
NULL
,
0
);
return
;
}
int32_t
mgmtSendSimpleRspToDnodeImp
(
void
*
pConn
,
int32_t
msgType
,
int32_t
code
)
{
STableInfo
*
pTable
=
mgmtGetTableByPos
(
pCfg
->
dnode
,
pCfg
->
vnode
,
pCfg
->
sid
);
int8_t
*
pCont
=
rpcMallocCont
(
sizeof
(
int32_t
));
if
(
pTable
==
NULL
)
{
*
(
int32_t
*
)
pCont
=
code
;
mError
(
"dnode:%s, vnode:%d, sid:%d, table not found"
,
taosIpStr
(
pCfg
->
dnode
),
pCfg
->
vnode
,
pCfg
->
sid
);
mgmtSendRspToDnode
(
pConn
,
msgType
+
1
,
TSDB_CODE_INVALID_TABLE
,
NULL
,
0
);
return
;
}
mgmtSend
MsgToDnodeImp
(
pCont
,
sizeof
(
int32_t
),
msgType
);
mgmtSend
RspToDnode
(
pConn
,
msgType
+
1
,
TSDB_CODE_SUCCESS
,
NULL
,
0
);
return
TSDB_CODE_SUCCESS
;
mgmtSendCreateTableMsg
(
pTable
,
NULL
)
;
}
}
int32_t
(
*
mgmtSendSimpleRspToDnode
)(
void
*
pConn
,
int32_t
msgType
,
int32_t
code
)
=
mgmtSendSimpleRspToDnodeImp
;
static
void
mgmtProcessVnodeCfgMsg
(
int8_t
msgType
,
int8_t
*
pCont
,
int32_t
contLen
,
void
*
pConn
)
{
int32_t
mgmtProcessMeterCfgMsg
(
int8_t
*
pCont
,
int32_t
contLen
,
void
*
pConn
)
{
if
(
!
sdbMaster
)
{
if
(
!
sdbMaster
)
{
mgmtSend
SimpleRspToDnode
(
pConn
,
TSDB_MSG_TYPE_TABLE_CFG_RSP
,
TSDB_CODE_REDIRECT
);
mgmtSend
RspToDnode
(
pConn
,
msgType
+
1
,
TSDB_CODE_REDIRECT
,
NULL
,
0
);
return
TSDB_CODE_REDIRECT
;
return
;
}
}
S
TableCfgMsg
*
cfg
=
(
STableCfgMsg
*
)
pConn
;
S
VpeerCfgMsg
*
pCfg
=
(
SVpeerCfgMsg
*
)
pCont
;
int32_t
vnode
=
htonl
(
cfg
->
v
node
);
pCfg
->
dnode
=
htonl
(
pCfg
->
d
node
);
int32_t
sid
=
htonl
(
cfg
->
sid
);
pCfg
->
vnode
=
htonl
(
pCfg
->
vnode
);
STableInfo
*
pTable
=
mgmtGetTableByPos
(
0
,
vnode
,
sid
);
SVgObj
*
pVgroup
=
mgmtGetVgroupByVnode
(
pCfg
->
dnode
,
pCfg
->
vnode
);
if
(
pTable
==
NULL
)
{
if
(
pVgroup
==
NULL
)
{
mgmtSendSimpleRspToDnode
(
pConn
,
TSDB_MSG_TYPE_TABLE_CFG_RSP
,
TSDB_CODE_INVALID_TABLE
);
mTrace
(
"dnode:%s, vnode:%d, no vgroup info"
,
taosIpStr
(
pCfg
->
dnode
),
pCfg
->
vnode
);
return
TSDB_CODE_INVALID_TABLE_ID
;
mgmtSendRspToDnode
(
pConn
,
msgType
+
1
,
TSDB_CODE_NOT_ACTIVE_VNODE
,
NULL
,
0
);
return
;
}
}
int8_t
*
pCreateTableMsg
=
NULL
;
mgmtSendRspToDnode
(
pConn
,
msgType
+
1
,
TSDB_CODE_SUCCESS
,
NULL
,
0
);
if
(
pTable
->
type
==
TSDB_TABLE_TYPE_NORMAL_TABLE
)
{
mgmtSendVPeersMsg
(
pVgroup
,
pCfg
->
vnode
,
NULL
);
pCreateTableMsg
=
mgmtBuildCreateNormalTableMsg
((
SNormalTableObj
*
)
pTable
);
}
else
if
(
pTable
->
type
==
TSDB_TABLE_TYPE_CHILD_TABLE
)
{
pCreateTableMsg
=
mgmtBuildCreateNormalTableMsg
((
SNormalTableObj
*
)
pTable
);
}
else
if
(
pTable
->
type
==
TSDB_TABLE_TYPE_STREAM_TABLE
)
{
pCreateTableMsg
=
mgmtBuildCreateNormalTableMsg
((
SNormalTableObj
*
)
pTable
);
}
else
{}
if
(
pCreateTableMsg
!=
NULL
)
{
mgmtSendMsgToDnode
(
pCreateTableMsg
,
0
,
TSDB_MSG_TYPE_TABLE_CFG_RSP
);
return
TSDB_CODE_SUCCESS
;
}
else
{
mgmtSendSimpleRspToDnode
(
pConn
,
TSDB_MSG_TYPE_TABLE_CFG_RSP
,
TSDB_CODE_INVALID_TABLE
);
return
TSDB_CODE_INVALID_TABLE
;
}
}
}
int
mgmtProcessVpeerCfgMsg
(
int8_t
*
pCont
,
int32_t
contLen
,
void
*
pConn
)
{
static
void
mgmtProcessCreateTableRsp
(
int8_t
msgType
,
int8_t
*
pCont
,
int32_t
contLen
,
void
*
thandle
,
int32_t
code
)
{
// char * pMsg, *pStart;
mTrace
(
"create table rsp received, handle:%p code:%d"
,
thandle
,
code
);
// int msgLen = 0;
}
// SVpeerCfgMsg *pCfg = (SVpeerCfgMsg *)cont;
// SVgObj * pVgroup = NULL;
//
// if (!sdbMaster) {
// mgmtSendSimpleRspToDnode(pObj, TSDB_MSG_TYPE_VNODE_CFG_RSP, TSDB_CODE_REDIRECT);
// return 0;
// }
//
// int vnode = htonl(pCfg->vnode);
//
// pStart = taosBuildRspMsgToDnode(pObj, TSDB_MSG_TYPE_VNODE_CFG_RSP);
// if (pStart == NULL) {
// mgmtSendSimpleRspToDnode(pObj, TSDB_MSG_TYPE_VNODE_CFG_RSP, TSDB_CODE_SERV_OUT_OF_MEMORY);
// return 0;
// }
// pMsg = pStart;
//
// if (vnode < pObj->numOfVnodes) pVgroup = mgmtGetVgroup(pObj->vload[vnode].vgId);
//
// if (pVgroup) {
// *pMsg = 0;
// pMsg++;
// pMsg = mgmtBuildVpeersIe(pMsg, pVgroup, vnode);
// mTrace("dnode:%s, vnode:%d, vgroup:%d, send create vnode msg, code:%d", taosIpStr(pObj->privateIp), vnode, pVgroup->vgId, *pMsg);
// } else {
// mTrace("dnode:%s, vnode:%d, no vgroup info, vgroup:%d", taosIpStr(pObj->privateIp), vnode, pObj->vload[vnode].vgId);
// *pMsg = TSDB_CODE_NOT_ACTIVE_VNODE;
// pMsg++;
// *(int32_t *)pMsg = htonl(vnode);
// pMsg += sizeof(int32_t);
// }
//
// msgLen = pMsg - pStart;
// mgmtSendMsgToDnode(pObj, pStart, msgLen);
return
0
;
static
void
mgmtProcessRemoveTableRsp
(
int8_t
msgType
,
int8_t
*
pCont
,
int32_t
contLen
,
void
*
thandle
,
int32_t
code
)
{
mTrace
(
"remove table rsp received, handle:%p code:%d"
,
thandle
,
code
);
}
}
int
mgmtProcessCreateRsp
(
int8_t
*
pCont
,
int32_t
contLen
,
void
*
pConn
)
{
return
0
;
}
static
void
mgmtProcessFreeVnodeRsp
(
int8_t
msgType
,
int8_t
*
pCont
,
int32_t
contLen
,
void
*
thandle
,
int32_t
code
)
{
mTrace
(
"free vnode rsp received, handle:%p code:%d"
,
thandle
,
code
);
int
mgmtProcessFreeVnodeRsp
(
int8_t
*
pCont
,
int32_t
contLen
,
void
*
pConn
)
{
return
0
;
}
}
int
mgmtProcessVPeersRsp
(
int8_t
*
pCont
,
int32_t
contLen
,
void
*
pConn
)
{
// STaosRsp *pRsp = (STaosRsp *)msg;
//
// if (!sdbMaster) {
// mgmtSendSimpleRspToDnode(pObj, TSDB_MSG_TYPE_DNODE_VPEERS_RSP, TSDB_CODE_REDIRECT);
// return 0;
// }
//
// SDbObj *pDb = mgmtGetDb(pRsp->more);
// if (!pDb) {
// mError("dnode:%s, db:%s not find, code:%d", taosIpStr(pObj->privateIp), pRsp->more, pRsp->code);
// return 0;
// }
//
// if (pDb->vgStatus != TSDB_VG_STATUS_IN_PROGRESS) {
// mTrace("dnode:%s, db:%s vpeer rsp already disposed, vgroup status:%s code:%d",
// taosIpStr(pObj->privateIp), pRsp->more, taosGetVgroupStatusStr(pDb->vgStatus), pRsp->code);
// return 0;
// }
//
// if (pRsp->code == TSDB_CODE_SUCCESS) {
// pDb->vgStatus = TSDB_VG_STATUS_READY;
// mTrace("dnode:%s, db:%s vgroup is created in dnode", taosIpStr(pObj->privateIp), pRsp->more);
// return 0;
// }
//
// pDb->vgStatus = pRsp->code;
// mError("dnode:%s, db:%s vgroup init failed, code:%d %s",
// taosIpStr(pObj->privateIp), pRsp->more, pRsp->code, taosGetVgroupStatusStr(pDb->vgStatus));
return
0
;
static
void
mgmtProcessVPeersRsp
(
int8_t
msgType
,
int8_t
*
pCont
,
int32_t
contLen
,
void
*
thandle
,
int32_t
code
)
{
mTrace
(
"vpeers rsp received, handle:%p code:%d"
,
thandle
,
code
);
}
}
void
mgmtProcessMsgFromDnode
(
int8_t
*
pCont
,
int32_t
contLen
,
int32_t
msgType
,
void
*
pConn
)
{
void
mgmtProcessMsgFromDnode
(
char
msgType
,
void
*
pCont
,
int32_t
contLen
,
void
*
handle
,
int32_t
code
)
{
if
(
msgType
==
TSDB_MSG_TYPE_TABLE_CFG
)
{
if
(
msgType
==
TSDB_MSG_TYPE_TABLE_CFG
)
{
mgmtProcess
MeterCfgMsg
(
pCont
,
contLen
,
pConn
);
mgmtProcess
TableCfgMsg
(
msgType
,
pCont
,
contLen
,
handle
);
}
else
if
(
msgType
==
TSDB_MSG_TYPE_VNODE_CFG
)
{
}
else
if
(
msgType
==
TSDB_MSG_TYPE_VNODE_CFG
)
{
mgmtProcessV
peerCfgMsg
(
pCont
,
contLen
,
pConn
);
mgmtProcessV
nodeCfgMsg
(
msgType
,
pCont
,
contLen
,
handle
);
}
else
if
(
msgType
==
TSDB_MSG_TYPE_DNODE_CREATE_TABLE_RSP
)
{
}
else
if
(
msgType
==
TSDB_MSG_TYPE_DNODE_CREATE_TABLE_RSP
)
{
mgmtProcessCreate
Rsp
(
pCont
,
contLen
,
pConn
);
mgmtProcessCreate
TableRsp
(
msgType
,
pCont
,
contLen
,
handle
,
code
);
}
else
if
(
msgType
==
TSDB_MSG_TYPE_DNODE_REMOVE_TABLE_RSP
)
{
}
else
if
(
msgType
==
TSDB_MSG_TYPE_DNODE_REMOVE_TABLE_RSP
)
{
// do nothing
mgmtProcessRemoveTableRsp
(
msgType
,
pCont
,
contLen
,
handle
,
code
);
}
else
if
(
msgType
==
TSDB_MSG_TYPE_DNODE_VPEERS_RSP
)
{
}
else
if
(
msgType
==
TSDB_MSG_TYPE_DNODE_VPEERS_RSP
)
{
mgmtProcessVPeersRsp
(
pCont
,
contLen
,
pConn
);
mgmtProcessVPeersRsp
(
msgType
,
pCont
,
contLen
,
handle
,
code
);
}
else
if
(
msgType
==
TSDB_MSG_TYPE_DNODE_FREE_VNODE_RSP
)
{
}
else
if
(
msgType
==
TSDB_MSG_TYPE_DNODE_FREE_VNODE_RSP
)
{
mgmtProcessFreeVnodeRsp
(
pCont
,
contLen
,
pConn
);
mgmtProcessFreeVnodeRsp
(
msgType
,
pCont
,
contLen
,
handle
,
code
);
}
else
if
(
msgType
==
TSDB_MSG_TYPE_DNODE_CFG_RSP
)
{
}
else
if
(
msgType
==
TSDB_MSG_TYPE_DNODE_CFG_RSP
)
{
// do nothing;
}
else
if
(
msgType
==
TSDB_MSG_TYPE_ALTER_STREAM_RSP
)
{
}
else
if
(
msgType
==
TSDB_MSG_TYPE_ALTER_STREAM_RSP
)
{
// do nothing;
}
else
{
}
else
{
mError
(
"%s from dnode is not processed"
,
taosMsg
[
msgType
]);
mError
(
"%s from dnode is not processed"
,
taosMsg
[
msgType
]);
}
}
}
}
int32_t
mgmtSendCreateTableMsg
(
SChildTableObj
*
pTable
,
SVgObj
*
pVgroup
)
{
void
mgmtSendCreateTableMsg
(
STableInfo
*
pTable
,
SRpcIpSet
*
ipSet
,
void
*
handle
)
{
// uint64_t timeStamp = taosGetTimestampMs();
mTrace
(
"table:%s, sid:%d send create table msg, handle:%p"
,
pTable
->
tableId
,
pTable
->
sid
);
//
// for (int32_t index = 0; index < pVgroup->numOfVnodes; ++index) {
// SDnodeObj *pObj = mgmtGetDnode(pVgroup->vnodeGid[index].ip);
// if (pObj == NULL) {
// continue;
// }
//
// int8_t *pStart = taosBuildReqMsgToDnodeWithSize(pObj, TSDB_MSG_TYPE_DNODE_CREATE_CHILD_TABLE, 64000);
// if (pStart == NULL) {
// continue;
// }
//
// int8_t *pMsg = mgmtBuildCreateChildTableMsg(pTable, pStart, pVgroup->vnodeGid[index].vnode, tagDataLen, pTagData);
// int32_t msgLen = pMsg - pStart;
//
// mgmtSendMsgToDnode(pObj, pStart, msgLen);
// }
//
// pVgroup->lastCreate = timeStamp;
return
0
;
}
SDCreateTableMsg
*
pCreate
=
mgmtBuildCreateTableMsg
(
pTable
);
int32_t
mgmtSendCreateNormalTableMsg
(
SNormalTableObj
*
pTable
,
SVgObj
*
pVgroup
)
{
if
(
pCreate
!=
NULL
)
{
// uint64_t timeStamp = taosGetTimestampMs();
mgmtSendMsgToDnode
(
TSDB_MSG_TYPE_DNODE_CREATE_TABLE
,
pCreate
,
htonl
(
pCreate
->
contLen
),
handle
);
//
}
// for (int32_t index = 0; index < pVgroup->numOfVnodes; ++index) {
// SDnodeObj *pObj = mgmtGetDnode(pVgroup->vnodeGid[index].ip);
// if (pObj == NULL) {
// continue;
// }
//
// int8_t *pStart = taosBuildReqMsgToDnodeWithSize(pObj, TSDB_MSG_TYPE_DNODE_CREATE_CHILD_TABLE, 64000);
// if (pStart == NULL) {
// continue;
// }
//
// int8_t *pMsg = mgmtBuildCreateNormalTableMsg(pTable, pStart, pVgroup->vnodeGid[index].vnode);
// int32_t msgLen = pMsg - pStart;
//
// mgmtSendMsgToDnode(pObj, pStart, msgLen);
// }
//
// pVgroup->lastCreate = timeStamp;
// return 0;
return
0
;
}
int
mgmtSendRemoveMeterMsgToDnode
(
STableInfo
*
pTable
,
SVgObj
*
pVgroup
)
{
// SDRemoveTableMsg *pRemove;
// char * pMsg, *pStart;
// int i, msgLen = 0;
// SDnodeObj * pObj;
// char ipstr[20];
// uint64_t timeStamp;
//
// timeStamp = taosGetTimestampMs();
//
// for (i = 0; i < pVgroup->numOfVnodes; ++i) {
// //if (pVgroup->vnodeGid[i].ip == 0) continue;
//
// pObj = mgmtGetDnode(pVgroup->vnodeGid[i].ip);
// if (pObj == NULL) continue;
//
// pStart = taosBuildReqMsgToDnode(pObj, TSDB_MSG_TYPE_DNODE_REMOVE_CHILD_TABLE);
// if (pStart == NULL) continue;
// pMsg = pStart;
//
// pRemove = (SDRemoveTableMsg *)pMsg;
// pRemove->vnode = htons(pVgroup->vnodeGid[i].vnode);
// pRemove->sid = htonl(pTable->gid.sid);
// memcpy(pRemove->tableId, pTable->tableId, TSDB_TABLE_ID_LEN);
//
// pMsg += sizeof(SDRemoveTableMsg);
// msgLen = pMsg - pStart;
//
// mgmtSendMsgToDnode(pObj, pStart, msgLen);
//
// tinet_ntoa(ipstr, pVgroup->vnodeGid[i].ip);
// mTrace("dnode:%s vid:%d, send remove meter msg, sid:%d status:%d", ipstr, pVgroup->vnodeGid[i].vnode,
// pTable->gid.sid, pObj->status);
// }
//
// pVgroup->lastRemove = timeStamp;
return
0
;
}
}
int
mgmtSendAlterStreamMsgToDnode
(
void
*
pTable
,
SVgObj
*
pVgroup
)
{
void
mgmtSendRemoveTableMsg
(
STableInfo
*
pTable
,
SRpcIpSet
*
ipSet
,
void
*
handle
)
{
// SAlterStreamMsg *pAlter;
mTrace
(
"table:%s, sid:%d send remove table msg, handle:%p"
,
pTable
->
tableId
,
pTable
->
sid
);
// char * pMsg, *pStart;
// int i, msgLen = 0;
// SDnodeObj * pObj;
//
// for (i = 0; i < pVgroup->numOfVnodes; ++i) {
// if (pVgroup->vnodeGid[i].ip == 0) continue;
//
// pObj = mgmtGetDnode(pVgroup->vnodeGid[i].ip);
// if (pObj == NULL) continue;
//
// pStart = taosBuildReqMsgToDnode(pObj, TSDB_MSG_TYPE_ALTER_STREAM);
// if (pStart == NULL) continue;
// pMsg = pStart;
//
// pAlter = (SAlterStreamMsg *)pMsg;
// pAlter->vnode = htons(pVgroup->vnodeGid[i].vnode);
// pAlter->sid = htonl(pTable->gid.sid);
// pAlter->uid = pTable->uid;
// pAlter->status = pTable->status;
//
// pMsg += sizeof(SAlterStreamMsg);
// msgLen = pMsg - pStart;
//
// mgmtSendMsgToDnode(pObj, pStart, msgLen);
// }
return
0
;
}
char
*
mgmtBuildVpeersIe
(
char
*
pMsg
,
SVgObj
*
pVgroup
,
int
vnode
)
{
SDRemoveTableMsg
*
pRemove
=
mgmtBuildRemoveTableMsg
(
pTable
);
SVPeersMsg
*
pVPeers
=
(
SVPeersMsg
*
)
pMsg
;
if
(
pRemove
!=
NULL
)
{
SDbObj
*
pDb
;
mgmtSendMsgToDnode
(
TSDB_MSG_TYPE_DNODE_REMOVE_TABLE
,
pRemove
,
sizeof
(
SDRemoveTableMsg
),
handle
);
pDb
=
mgmtGetDb
(
pVgroup
->
dbName
);
pVPeers
->
vnode
=
htonl
(
vnode
);
pVPeers
->
cfg
=
pDb
->
cfg
;
SVnodeCfg
*
pCfg
=
&
pVPeers
->
cfg
;
pCfg
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pCfg
->
maxSessions
=
htonl
(
pCfg
->
maxSessions
);
pCfg
->
cacheBlockSize
=
htonl
(
pCfg
->
cacheBlockSize
);
pCfg
->
cacheNumOfBlocks
.
totalBlocks
=
htonl
(
pCfg
->
cacheNumOfBlocks
.
totalBlocks
);
pCfg
->
daysPerFile
=
htonl
(
pCfg
->
daysPerFile
);
pCfg
->
daysToKeep1
=
htonl
(
pCfg
->
daysToKeep1
);
pCfg
->
daysToKeep2
=
htonl
(
pCfg
->
daysToKeep2
);
pCfg
->
daysToKeep
=
htonl
(
pCfg
->
daysToKeep
);
pCfg
->
commitTime
=
htonl
(
pCfg
->
commitTime
);
pCfg
->
blocksPerTable
=
htons
(
pCfg
->
blocksPerTable
);
pCfg
->
replications
=
(
char
)
pVgroup
->
numOfVnodes
;
pCfg
->
rowsInFileBlock
=
htonl
(
pCfg
->
rowsInFileBlock
);
SVPeerDesc
*
vpeerDesc
=
pVPeers
->
vpeerDesc
;
pMsg
=
(
char
*
)(
pVPeers
->
vpeerDesc
);
for
(
int
j
=
0
;
j
<
pVgroup
->
numOfVnodes
;
++
j
)
{
vpeerDesc
[
j
].
ip
=
htonl
(
pVgroup
->
vnodeGid
[
j
].
ip
);
vpeerDesc
[
j
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
j
].
vnode
);
pMsg
+=
sizeof
(
SVPeerDesc
);
}
}
}
return
pMsg
;
void
mgmtSendAlterStreamMsg
(
STableInfo
*
pTable
,
SRpcIpSet
*
ipSet
,
void
*
handle
)
{
mTrace
(
"table:%s, sid:%d send alter stream msg, handle:%p"
,
pTable
->
tableId
,
pTable
->
sid
);
}
}
int
mgmtSendVPeersMsg
(
SVgObj
*
pVgroup
)
{
void
mgmtSendVPeersMsg
(
SVgObj
*
pVgroup
,
int32_t
vnode
,
SRpcIpSet
*
ipSet
,
void
*
handle
)
{
// SDnodeObj *pDnode;
mTrace
(
"vgroup:%d, vnode:%d send vpeer msg, handle:%p"
,
pVgroup
->
vgId
,
vnode
,
handle
);
// char * pMsg, *pStart;
// int msgLen = 0;
//
// for (int i = 0; i < pVgroup->numOfVnodes; ++i) {
// pDnode = mgmtGetDnode(pVgroup->vnodeGid[i].ip);
// if (pDnode == NULL) {
// mError("dnode:%s not there", taosIpStr(pVgroup->vnodeGid[i].ip));
// continue;
// }
//
// pDnode->vload[pVgroup->vnodeGid[i].vnode].vgId = pVgroup->vgId;
// mgmtUpdateDnode(pDnode);
//
// if (pDnode->thandle && pVgroup->numOfVnodes >= 1) {
// pStart = taosBuildReqMsgToDnode(pDnode, TSDB_MSG_TYPE_DNODE_VPEERS);
// if (pStart == NULL) continue;
// pMsg = mgmtBuildVpeersIe(pStart, pVgroup, pVgroup->vnodeGid[i].vnode);
// msgLen = pMsg - pStart;
//
// mgmtSendMsgToDnode(pDnode, pStart, msgLen);
// }
// }
return
0
;
SVPeersMsg
*
pVpeer
=
mgmtBuildVpeersMsg
(
pVgroup
,
vnode
);
if
(
pVpeer
!=
NULL
)
{
mgmtSendMsgToDnode
(
TSDB_MSG_TYPE_DNODE_VPEERS
,
pVpeer
,
sizeof
(
SVPeersMsg
),
handle
);
}
}
}
int
mgmtSendOneFreeVnodeMsg
(
SVnodeGid
*
pVnodeGid
)
{
void
mgmtSendOneFreeVnodeMsg
(
int32_t
vnode
,
SRpcIpSet
*
ipSet
,
void
*
handle
)
{
// SFreeVnodeMsg *pFreeVnode;
mTrace
(
"vnode:%d send free vnode msg, handle:%p"
,
vnode
,
handle
);
// char * pMsg, *pStart;
// int msgLen = 0;
// SDnodeObj * pDnode;
//
// pDnode = mgmtGetDnode(pVnodeGid->ip);
// if (pDnode == NULL) {
// mError("dnode:%s not there", taosIpStr(pVnodeGid->ip));
// return -1;
// }
//
// if (pDnode->thandle == NULL) {
// mTrace("dnode:%s offline, failed to send Vpeer msg", taosIpStr(pVnodeGid->ip));
// return -1;
// }
//
// pStart = taosBuildReqMsgToDnode(pDnode, TSDB_MSG_TYPE_DNODE_FREE_VNODE);
// if (pStart == NULL) return -1;
// pMsg = pStart;
//
// pFreeVnode = (SFreeVnodeMsg *)pMsg;
// pFreeVnode->vnode = htons(pVnodeGid->vnode);
//
// pMsg += sizeof(SFreeVnodeMsg);
//
// msgLen = pMsg - pStart;
// mgmtSendMsgToDnode(pDnode, pStart, msgLen);
return
0
;
SFreeVnodeMsg
*
pFreeVnode
=
rpcMallocCont
(
sizeof
(
SFreeVnodeMsg
));
if
(
pFreeVnode
!=
NULL
)
{
pFreeVnode
->
vnode
=
htonl
(
vnode
);
mgmtSendMsgToDnode
(
TSDB_MSG_TYPE_DNODE_FREE_VNODE
,
pFreeVnode
,
sizeof
(
SFreeVnodeMsg
),
handle
);
}
}
}
int
mgmtSendFreeVnodeMsg
(
SVgObj
*
pVgroup
)
{
void
mgmtSendFreeVnodesMsg
(
SVgObj
*
pVgroup
,
SRpcIpSet
*
ipSet
,
void
*
handle
)
{
for
(
int
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
mgmtSendOneFreeVnodeMsg
(
pVgroup
->
vnodeGid
+
i
);
SRpcIpSet
ipSet
=
mgmtGetIpSetFromIp
(
pVgroup
->
vnodeGid
[
i
].
ip
);
mgmtSendOneFreeVnodeMsg
(
pVgroup
->
vnodeGid
+
i
,
&
ipSet
,
handle
);
}
}
return
0
;
}
}
int
mgmtCfgDynamicOptions
(
SDnodeObj
*
pDnode
,
char
*
msg
)
{
int
32_t
mgmtCfgDynamicOptions
(
SDnodeObj
*
pDnode
,
char
*
msg
)
{
char
*
option
,
*
value
;
char
*
option
,
*
value
;
int
olen
,
valen
;
int
32_t
olen
,
valen
;
paGetToken
(
msg
,
&
option
,
&
olen
);
paGetToken
(
msg
,
&
option
,
&
olen
);
if
(
strncasecmp
(
option
,
"unremove"
,
8
)
==
0
)
{
if
(
strncasecmp
(
option
,
"unremove"
,
8
)
==
0
)
{
...
@@ -445,7 +215,7 @@ int mgmtCfgDynamicOptions(SDnodeObj *pDnode, char *msg) {
...
@@ -445,7 +215,7 @@ int mgmtCfgDynamicOptions(SDnodeObj *pDnode, char *msg) {
}
else
if
(
strncasecmp
(
option
,
"score"
,
5
)
==
0
)
{
}
else
if
(
strncasecmp
(
option
,
"score"
,
5
)
==
0
)
{
paGetToken
(
option
+
olen
+
1
,
&
value
,
&
valen
);
paGetToken
(
option
+
olen
+
1
,
&
value
,
&
valen
);
if
(
valen
>
0
)
{
if
(
valen
>
0
)
{
int
score
=
atoi
(
value
);
int
32_t
score
=
atoi
(
value
);
mTrace
(
"dnode:%s, custom score set from:%d to:%d"
,
taosIpStr
(
pDnode
->
privateIp
),
pDnode
->
customScore
,
score
);
mTrace
(
"dnode:%s, custom score set from:%d to:%d"
,
taosIpStr
(
pDnode
->
privateIp
),
pDnode
->
customScore
,
score
);
pDnode
->
customScore
=
score
;
pDnode
->
customScore
=
score
;
mgmtUpdateDnode
(
pDnode
);
mgmtUpdateDnode
(
pDnode
);
...
@@ -455,7 +225,7 @@ int mgmtCfgDynamicOptions(SDnodeObj *pDnode, char *msg) {
...
@@ -455,7 +225,7 @@ int mgmtCfgDynamicOptions(SDnodeObj *pDnode, char *msg) {
}
else
if
(
strncasecmp
(
option
,
"bandwidth"
,
9
)
==
0
)
{
}
else
if
(
strncasecmp
(
option
,
"bandwidth"
,
9
)
==
0
)
{
paGetToken
(
msg
,
&
value
,
&
valen
);
paGetToken
(
msg
,
&
value
,
&
valen
);
if
(
valen
>
0
)
{
if
(
valen
>
0
)
{
int
bandwidthMb
=
atoi
(
value
);
int
32_t
bandwidthMb
=
atoi
(
value
);
if
(
bandwidthMb
>=
0
&&
bandwidthMb
<
10000000
)
{
if
(
bandwidthMb
>=
0
&&
bandwidthMb
<
10000000
)
{
mTrace
(
"dnode:%s, bandwidth(Mb) set from:%d to:%d"
,
taosIpStr
(
pDnode
->
privateIp
),
pDnode
->
bandwidthMb
,
bandwidthMb
);
mTrace
(
"dnode:%s, bandwidth(Mb) set from:%d to:%d"
,
taosIpStr
(
pDnode
->
privateIp
),
pDnode
->
bandwidthMb
,
bandwidthMb
);
pDnode
->
bandwidthMb
=
bandwidthMb
;
pDnode
->
bandwidthMb
=
bandwidthMb
;
...
@@ -469,10 +239,10 @@ int mgmtCfgDynamicOptions(SDnodeObj *pDnode, char *msg) {
...
@@ -469,10 +239,10 @@ int mgmtCfgDynamicOptions(SDnodeObj *pDnode, char *msg) {
return
-
1
;
return
-
1
;
}
}
int
mgmtSendCfgDnodeMsg
(
char
*
cont
)
{
int
32_t
mgmtSendCfgDnodeMsg
(
char
*
cont
)
{
#ifdef CLUSTER
#ifdef CLUSTER
char
*
pMsg
,
*
pStart
;
char
*
pMsg
,
*
pStart
;
int
msgLen
=
0
;
int
32_t
msgLen
=
0
;
#endif
#endif
SDnodeObj
*
pDnode
;
SDnodeObj
*
pDnode
;
...
@@ -487,7 +257,7 @@ int mgmtSendCfgDnodeMsg(char *cont) {
...
@@ -487,7 +257,7 @@ int mgmtSendCfgDnodeMsg(char *cont) {
}
}
mTrace
(
"dnode:%s, dynamic option received, content:%s"
,
taosIpStr
(
pDnode
->
privateIp
),
pCfg
->
config
);
mTrace
(
"dnode:%s, dynamic option received, content:%s"
,
taosIpStr
(
pDnode
->
privateIp
),
pCfg
->
config
);
int
code
=
mgmtCfgDynamicOptions
(
pDnode
,
pCfg
->
config
);
int
32_t
code
=
mgmtCfgDynamicOptions
(
pDnode
,
pCfg
->
config
);
if
(
code
!=
-
1
)
{
if
(
code
!=
-
1
)
{
return
code
;
return
code
;
}
}
...
@@ -524,7 +294,7 @@ void mgmtProcessDnodeStatusImp(void *handle, void *tmrId) {
...
@@ -524,7 +294,7 @@ void mgmtProcessDnodeStatusImp(void *handle, void *tmrId) {
taosGetSysMemory(&memoryUsedMB);
taosGetSysMemory(&memoryUsedMB);
pObj->diskAvailable = tsAvailDataDirGB;
pObj->diskAvailable = tsAvailDataDirGB;
for (int vnode = 0; vnode < pObj->numOfVnodes; ++vnode) {
for (int
32_t
vnode = 0; vnode < pObj->numOfVnodes; ++vnode) {
SVnodeLoad *pVload = &(pObj->vload[vnode]);
SVnodeLoad *pVload = &(pObj->vload[vnode]);
SVnodeObj * pVnode = vnodeList + vnode;
SVnodeObj * pVnode = vnodeList + vnode;
...
...
src/mnode/src/mgmtNormalTable.c
浏览文件 @
5cb76602
...
@@ -387,7 +387,7 @@ int32_t mgmtDropNormalTable(SDbObj *pDb, SNormalTableObj *pTable) {
...
@@ -387,7 +387,7 @@ int32_t mgmtDropNormalTable(SDbObj *pDb, SNormalTableObj *pTable) {
return
TSDB_CODE_OTHERS
;
return
TSDB_CODE_OTHERS
;
}
}
mgmtSendRemove
MeterMsgToDnode
((
STableInfo
*
)
pTable
,
pVgroup
);
mgmtSendRemove
TableMsg
((
STableInfo
*
)
pTable
,
pVgroup
);
sdbDeleteRow
(
tsNormalTableSdb
,
pTable
);
sdbDeleteRow
(
tsNormalTableSdb
,
pTable
);
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
5cb76602
...
@@ -390,3 +390,31 @@ int32_t mgmtRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows, void *
...
@@ -390,3 +390,31 @@ int32_t mgmtRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows, void *
return
numOfRows
;
return
numOfRows
;
}
}
SDCreateTableMsg
*
mgmtBuildCreateTableMsg
(
STableInfo
*
pTable
)
{
SDCreateTableMsg
*
pCreate
=
NULL
;
if
(
pTable
->
type
==
TSDB_TABLE_TYPE_NORMAL_TABLE
)
{
pCreate
=
mgmtBuildCreateNormalTableMsg
((
SNormalTableObj
*
)
pTable
);
}
else
if
(
pTable
->
type
==
TSDB_TABLE_TYPE_CHILD_TABLE
)
{
pCreate
=
mgmtBuildCreateChildTableMsg
((
SChildTableObj
*
)
pTable
);
}
else
if
(
pTable
->
type
==
TSDB_TABLE_TYPE_STREAM_TABLE
)
{
pCreate
=
mgmtBuildCreateNormalTableMsg
((
SNormalTableObj
*
)
pTable
);
}
else
{
}
return
pCreate
;
}
SDRemoveTableMsg
*
mgmtBuildRemoveTableMsg
(
STableInfo
*
pTable
)
{
SDRemoveTableMsg
*
pRemove
=
NULL
;
if
(
pTable
->
type
==
TSDB_TABLE_TYPE_NORMAL_TABLE
)
{
pRemove
=
mgmtBuildCreateNormalTableMsg
((
SNormalTableObj
*
)
pTable
);
}
else
if
(
pTable
->
type
==
TSDB_TABLE_TYPE_CHILD_TABLE
)
{
pRemove
=
mgmtBuildCreateChildTableMsg
((
SChildTableObj
*
)
pTable
);
}
else
if
(
pTable
->
type
==
TSDB_TABLE_TYPE_STREAM_TABLE
)
{
pRemove
=
mgmtBuildCreateNormalTableMsg
((
SNormalTableObj
*
)
pTable
);
}
else
{
}
return
pRemove
;
}
\ No newline at end of file
src/mnode/src/mgmtVgroup.c
浏览文件 @
5cb76602
...
@@ -234,7 +234,7 @@ int32_t mgmtDropVgroup(SDbObj *pDb, SVgObj *pVgroup) {
...
@@ -234,7 +234,7 @@ int32_t mgmtDropVgroup(SDbObj *pDb, SVgObj *pVgroup) {
}
}
mTrace
(
"vgroup:%d, db:%s replica:%d is deleted"
,
pVgroup
->
vgId
,
pDb
->
name
,
pVgroup
->
numOfVnodes
);
mTrace
(
"vgroup:%d, db:%s replica:%d is deleted"
,
pVgroup
->
vgId
,
pDb
->
name
,
pVgroup
->
numOfVnodes
);
mgmtSendFreeVnodeMsg
(
pVgroup
);
mgmtSendFreeVnode
s
Msg
(
pVgroup
);
sdbDeleteRow
(
tsVgroupSdb
,
pVgroup
);
sdbDeleteRow
(
tsVgroupSdb
,
pVgroup
);
return
0
;
return
0
;
...
@@ -521,3 +521,63 @@ void mgmtRemoveTableFromVgroup(SVgObj *pVgroup, STableInfo *pTable) {
...
@@ -521,3 +521,63 @@ void mgmtRemoveTableFromVgroup(SVgObj *pVgroup, STableInfo *pTable) {
pVgroup
->
tableList
[
pTable
->
sid
]
=
NULL
;
pVgroup
->
tableList
[
pTable
->
sid
]
=
NULL
;
taosFreeId
(
pVgroup
->
idPool
,
pTable
->
sid
);
taosFreeId
(
pVgroup
->
idPool
,
pTable
->
sid
);
}
}
SVPeersMsg
*
mgmtBuildVpeersMsg
(
SVgObj
*
pVgroup
,
int32_t
vnode
)
{
SDbObj
*
pDb
=
mgmtGetDb
(
pVgroup
->
dbName
);
if
(
pDb
==
NULL
)
return
NULL
;
SVPeersMsg
*
pVPeers
=
rpcMallocCont
(
sizeof
(
SVPeersMsg
));
if
(
pVPeers
==
NULL
)
return
NULL
;
pVPeers
->
vnode
=
htonl
(
vnode
);
pVPeers
->
cfg
=
pDb
->
cfg
;
SVnodeCfg
*
pCfg
=
&
pVPeers
->
cfg
;
pCfg
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pCfg
->
maxSessions
=
htonl
(
pCfg
->
maxSessions
);
pCfg
->
cacheBlockSize
=
htonl
(
pCfg
->
cacheBlockSize
);
pCfg
->
cacheNumOfBlocks
.
totalBlocks
=
htonl
(
pCfg
->
cacheNumOfBlocks
.
totalBlocks
);
pCfg
->
daysPerFile
=
htonl
(
pCfg
->
daysPerFile
);
pCfg
->
daysToKeep1
=
htonl
(
pCfg
->
daysToKeep1
);
pCfg
->
daysToKeep2
=
htonl
(
pCfg
->
daysToKeep2
);
pCfg
->
daysToKeep
=
htonl
(
pCfg
->
daysToKeep
);
pCfg
->
commitTime
=
htonl
(
pCfg
->
commitTime
);
pCfg
->
blocksPerTable
=
htons
(
pCfg
->
blocksPerTable
);
pCfg
->
replications
=
(
char
)
pVgroup
->
numOfVnodes
;
pCfg
->
rowsInFileBlock
=
htonl
(
pCfg
->
rowsInFileBlock
);
SVPeerDesc
*
vpeerDesc
=
pVPeers
->
vpeerDesc
;
for
(
int32_t
j
=
0
;
j
<
pVgroup
->
numOfVnodes
;
++
j
)
{
vpeerDesc
[
j
].
ip
=
htonl
(
pVgroup
->
vnodeGid
[
j
].
ip
);
vpeerDesc
[
j
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
j
].
vnode
);
}
return
pVPeers
;
}
SVgObj
*
mgmtGetVgroupByVnode
(
uint32_t
dnode
,
int32_t
vnode
)
{
if
(
vnode
<
0
||
vnode
>=
TSDB_MAX_VNODES
)
{
return
NULL
;
}
SDnodeObj
*
pDnode
=
mgmtGetDnode
(
dnode
);
if
(
pDnode
==
NULL
)
{
return
NULL
;
}
int32_t
vgId
=
pDnode
->
vload
[
vnode
].
vgId
;
return
mgmtGetVgroup
(
vgId
);
}
SRpcIpSet
mgmtGetIpSetFromVgroup
(
SVgObj
*
pVgroup
)
{
SRpcIpSet
ipSet
=
{.
numOfIps
=
pVgroup
->
numOfVnodes
,
.
inUse
=
0
,
.
port
=
tsMgmtDnodePort
+
1
};
for
(
int
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
ipSet
.
ip
[
i
]
=
pVgroup
->
vnodeGid
[
i
].
ip
;
}
return
ipSet
;
}
SRpcIpSet
mgmtGetIpSetFromIp
(
uint32_t
ip
)
{
SRpcIpSet
ipSet
=
{.
ip
=
ip
,
.
numOfIps
=
1
,
.
inUse
=
0
,
.
port
=
tsMgmtDnodePort
+
1
};
return
ipSet
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录