Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
loser646
TDengine
提交
b87ac4ab
T
TDengine
项目概览
loser646
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b87ac4ab
编写于
3月 21, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
差异文件
[td-32] merge code
上级
caec8c50
fcf29f14
变更
36
显示空白变更内容
内联
并排
Showing
36 changed file
with
923 addition
and
769 deletion
+923
-769
src/dnode/inc/dnodeMClient.h
src/dnode/inc/dnodeMClient.h
+4
-2
src/dnode/inc/dnodeMgmt.h
src/dnode/inc/dnodeMgmt.h
+1
-0
src/dnode/inc/dnodeModule.h
src/dnode/inc/dnodeModule.h
+1
-0
src/dnode/src/dnodeMClient.c
src/dnode/src/dnodeMClient.c
+136
-10
src/dnode/src/dnodeMain.c
src/dnode/src/dnodeMain.c
+2
-2
src/dnode/src/dnodeMgmt.c
src/dnode/src/dnodeMgmt.c
+161
-96
src/dnode/src/dnodeMnode.c
src/dnode/src/dnodeMnode.c
+10
-9
src/dnode/src/dnodeModule.c
src/dnode/src/dnodeModule.c
+38
-5
src/dnode/src/dnodeShell.c
src/dnode/src/dnodeShell.c
+3
-3
src/dnode/src/dnodeWrite.c
src/dnode/src/dnodeWrite.c
+1
-1
src/inc/mnode.h
src/inc/mnode.h
+45
-33
src/inc/taosdef.h
src/inc/taosdef.h
+1
-0
src/inc/taosmsg.h
src/inc/taosmsg.h
+15
-16
src/mnode/inc/mgmtBalance.h
src/mnode/inc/mgmtBalance.h
+1
-0
src/mnode/inc/mgmtDServer.h
src/mnode/inc/mgmtDServer.h
+0
-15
src/mnode/inc/mgmtDnode.h
src/mnode/inc/mgmtDnode.h
+2
-1
src/mnode/inc/mgmtMnode.h
src/mnode/inc/mgmtMnode.h
+5
-0
src/mnode/inc/mgmtVgroup.h
src/mnode/inc/mgmtVgroup.h
+3
-3
src/mnode/src/mgmtAcct.c
src/mnode/src/mgmtAcct.c
+3
-3
src/mnode/src/mgmtBalance.c
src/mnode/src/mgmtBalance.c
+17
-21
src/mnode/src/mgmtChildTable.c
src/mnode/src/mgmtChildTable.c
+23
-22
src/mnode/src/mgmtDClient.c
src/mnode/src/mgmtDClient.c
+0
-87
src/mnode/src/mgmtDServer.c
src/mnode/src/mgmtDServer.c
+0
-273
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+2
-2
src/mnode/src/mgmtDnode.c
src/mnode/src/mgmtDnode.c
+148
-89
src/mnode/src/mgmtMnode.c
src/mnode/src/mgmtMnode.c
+154
-0
src/mnode/src/mgmtNormalTable.c
src/mnode/src/mgmtNormalTable.c
+1
-1
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+1
-1
src/mnode/src/mgmtSuperTable.c
src/mnode/src/mgmtSuperTable.c
+0
-2
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+51
-12
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+82
-38
src/util/inc/ihash.h
src/util/inc/ihash.h
+1
-1
src/util/src/ihash.c
src/util/src/ihash.c
+3
-12
src/util/src/tglobalcfg.c
src/util/src/tglobalcfg.c
+1
-1
src/util/src/tstatus.c
src/util/src/tstatus.c
+7
-7
src/vnode/tsdb/inc/tsdb.h
src/vnode/tsdb/inc/tsdb.h
+0
-1
未找到文件。
src/dnode/inc/dnodeMClient.h
浏览文件 @
b87ac4ab
...
@@ -22,6 +22,8 @@ extern "C" {
...
@@ -22,6 +22,8 @@ extern "C" {
int32_t
dnodeInitMClient
();
int32_t
dnodeInitMClient
();
void
dnodeCleanupMClient
();
void
dnodeCleanupMClient
();
void
dnodeSendMsgToMnode
(
SRpcMsg
*
rpcMsg
);
uint32_t
dnodeGetMnodeMasteIp
();
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/dnode/inc/dnodeMgmt.h
浏览文件 @
b87ac4ab
...
@@ -23,6 +23,7 @@ extern "C" {
...
@@ -23,6 +23,7 @@ extern "C" {
int32_t
dnodeInitMgmt
();
int32_t
dnodeInitMgmt
();
void
dnodeCleanupMgmt
();
void
dnodeCleanupMgmt
();
void
dnodeMgmt
(
SRpcMsg
*
rpcMsg
);
void
dnodeMgmt
(
SRpcMsg
*
rpcMsg
);
void
dnodeUpdateDnodeId
(
int32_t
dnodeId
);
void
*
dnodeGetVnode
(
int32_t
vgId
);
void
*
dnodeGetVnode
(
int32_t
vgId
);
int32_t
dnodeGetVnodeStatus
(
void
*
pVnode
);
int32_t
dnodeGetVnodeStatus
(
void
*
pVnode
);
...
...
src/dnode/inc/dnodeModule.h
浏览文件 @
b87ac4ab
...
@@ -23,6 +23,7 @@ extern "C" {
...
@@ -23,6 +23,7 @@ extern "C" {
int32_t
dnodeInitModules
();
int32_t
dnodeInitModules
();
void
dnodeCleanUpModules
();
void
dnodeCleanUpModules
();
void
dnodeStartModules
();
void
dnodeStartModules
();
void
dnodeProcessModuleStatus
(
uint32_t
moduleStatus
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/dnode/src/dnodeMClient.c
浏览文件 @
b87ac4ab
...
@@ -18,15 +18,34 @@
...
@@ -18,15 +18,34 @@
#include "taosmsg.h"
#include "taosmsg.h"
#include "tlog.h"
#include "tlog.h"
#include "trpc.h"
#include "trpc.h"
#include "tutil.h"
#include "dnode.h"
#include "dnode.h"
#include "dnodeMClient.h"
#include "dnodeModule.h"
#include "dnodeMgmt.h"
static
void
(
*
dnodeProcessMgmtRspFp
[
TSDB_MSG_TYPE_MAX
])(
SRpcMsg
*
);
static
bool
dnodeReadMnodeIpList
();
static
void
dnodeSaveMnodeIpList
();
static
void
dnodeProcessRspFromMnode
(
SRpcMsg
*
pMsg
);
static
void
dnodeProcessRspFromMnode
(
SRpcMsg
*
pMsg
);
static
void
dnodeProcessStatusRsp
(
SRpcMsg
*
pMsg
);
static
void
dnodeProcessStatusRsp
(
SRpcMsg
*
pMsg
);
static
void
*
tsDnodeMClientRpc
;
static
void
(
*
tsDnodeProcessMgmtRspFp
[
TSDB_MSG_TYPE_MAX
])(
SRpcMsg
*
);
static
void
*
tsDnodeMClientRpc
=
NULL
;
static
SRpcIpSet
tsDnodeMnodeIpList
=
{
0
};
int32_t
dnodeInitMClient
()
{
int32_t
dnodeInitMClient
()
{
dnodeProcessMgmtRspFp
[
TSDB_MSG_TYPE_DM_STATUS_RSP
]
=
dnodeProcessStatusRsp
;
if
(
!
dnodeReadMnodeIpList
())
{
dTrace
(
"failed to read mnode iplist, set it from cfg file"
);
memset
(
&
tsDnodeMnodeIpList
,
0
,
sizeof
(
SRpcIpSet
));
tsDnodeMnodeIpList
.
port
=
tsMnodeDnodePort
;
tsDnodeMnodeIpList
.
numOfIps
=
1
;
tsDnodeMnodeIpList
.
ip
[
0
]
=
inet_addr
(
tsMasterIp
);
if
(
tsSecondIp
[
0
])
{
tsDnodeMnodeIpList
.
numOfIps
=
2
;
tsDnodeMnodeIpList
.
ip
[
1
]
=
inet_addr
(
tsSecondIp
);
}
}
tsDnodeProcessMgmtRspFp
[
TSDB_MSG_TYPE_DM_STATUS_RSP
]
=
dnodeProcessStatusRsp
;
SRpcInit
rpcInit
;
SRpcInit
rpcInit
;
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
...
@@ -35,17 +54,20 @@ int32_t dnodeInitMClient() {
...
@@ -35,17 +54,20 @@ int32_t dnodeInitMClient() {
rpcInit
.
label
=
"DND-MC"
;
rpcInit
.
label
=
"DND-MC"
;
rpcInit
.
numOfThreads
=
1
;
rpcInit
.
numOfThreads
=
1
;
rpcInit
.
cfp
=
dnodeProcessRspFromMnode
;
rpcInit
.
cfp
=
dnodeProcessRspFromMnode
;
rpcInit
.
sessions
=
TSDB_SESSIONS_PER_DNODE
;
rpcInit
.
sessions
=
100
;
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
2000
;
rpcInit
.
user
=
"t"
;
rpcInit
.
ckey
=
"key"
;
rpcInit
.
secret
=
"secret"
;
tsDnodeMClientRpc
=
rpcOpen
(
&
rpcInit
);
tsDnodeMClientRpc
=
rpcOpen
(
&
rpcInit
);
if
(
tsDnodeMClientRpc
==
NULL
)
{
if
(
tsDnodeMClientRpc
==
NULL
)
{
dError
(
"failed to init
connection from mgm
t"
);
dError
(
"failed to init
mnode rpc clien
t"
);
return
-
1
;
return
-
1
;
}
}
dPrint
(
"
client connection to mgm
t is opened"
);
dPrint
(
"
mnode rpc clien
t is opened"
);
return
0
;
return
0
;
}
}
...
@@ -53,18 +75,122 @@ void dnodeCleanupMClient() {
...
@@ -53,18 +75,122 @@ void dnodeCleanupMClient() {
if
(
tsDnodeMClientRpc
)
{
if
(
tsDnodeMClientRpc
)
{
rpcClose
(
tsDnodeMClientRpc
);
rpcClose
(
tsDnodeMClientRpc
);
tsDnodeMClientRpc
=
NULL
;
tsDnodeMClientRpc
=
NULL
;
dPrint
(
"mnode rpc client is closed"
);
}
}
}
}
static
void
dnodeProcessRspFromMnode
(
SRpcMsg
*
pMsg
)
{
static
void
dnodeProcessRspFromMnode
(
SRpcMsg
*
pMsg
)
{
if
(
d
nodeProcessMgmtRspFp
[
pMsg
->
msgType
])
{
if
(
tsD
nodeProcessMgmtRspFp
[
pMsg
->
msgType
])
{
(
*
d
nodeProcessMgmtRspFp
[
pMsg
->
msgType
])(
pMsg
);
(
*
tsD
nodeProcessMgmtRspFp
[
pMsg
->
msgType
])(
pMsg
);
}
else
{
}
else
{
dError
(
"%s is not processed in mclient"
,
taosMsg
[
pMsg
->
msgType
]);
dError
(
"%s is not processed in m
node rpc
client"
,
taosMsg
[
pMsg
->
msgType
]);
}
}
rpcFreeCont
(
pMsg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
}
}
static
void
dnodeProcessStatusRsp
(
SRpcMsg
*
pMsg
)
{
static
void
dnodeProcessStatusRsp
(
SRpcMsg
*
pMsg
)
{
if
(
pMsg
->
code
!=
TSDB_CODE_SUCCESS
)
{
dError
(
"status rsp is received, error:%s"
,
tstrerror
(
pMsg
->
code
));
return
;
}
SDMStatusRsp
*
pStatusRsp
=
pMsg
->
pCont
;
if
(
pStatusRsp
->
ipList
.
numOfIps
<=
0
)
{
dError
(
"status msg is invalid, num of ips is %d"
,
pStatusRsp
->
ipList
.
numOfIps
);
return
;
}
pStatusRsp
->
ipList
.
port
=
htons
(
pStatusRsp
->
ipList
.
port
);
for
(
int32_t
i
=
0
;
i
<
pStatusRsp
->
ipList
.
numOfIps
;
++
i
)
{
pStatusRsp
->
ipList
.
ip
[
i
]
=
htonl
(
pStatusRsp
->
ipList
.
ip
[
i
]);
}
//dTrace("status msg is received, result:%s", tstrerror(pMsg->code));
if
(
memcmp
(
&
(
pStatusRsp
->
ipList
),
&
tsDnodeMnodeIpList
,
sizeof
(
SRpcIpSet
))
!=
0
)
{
dPrint
(
"mnode ip list is changed, numOfIps:%d inUse:%d"
,
pStatusRsp
->
ipList
.
numOfIps
,
pStatusRsp
->
ipList
.
inUse
);
memcpy
(
&
tsDnodeMnodeIpList
,
&
pStatusRsp
->
ipList
,
sizeof
(
SRpcIpSet
));
for
(
int32_t
i
=
0
;
i
<
tsDnodeMnodeIpList
.
numOfIps
;
++
i
)
{
dPrint
(
"mnode index:%d ip:%s"
,
i
,
taosIpStr
(
tsDnodeMnodeIpList
.
ip
[
i
]));
}
dnodeSaveMnodeIpList
();
}
SDnodeState
*
pState
=
&
pStatusRsp
->
dnodeState
;
pState
->
numOfVnodes
=
htonl
(
pState
->
numOfVnodes
);
pState
->
moduleStatus
=
htonl
(
pState
->
moduleStatus
);
pState
->
createdTime
=
htonl
(
pState
->
createdTime
);
pState
->
dnodeId
=
htonl
(
pState
->
dnodeId
);
dnodeProcessModuleStatus
(
pState
->
moduleStatus
);
dnodeUpdateDnodeId
(
pState
->
dnodeId
);
}
void
dnodeSendMsgToMnode
(
SRpcMsg
*
rpcMsg
)
{
rpcSendRequest
(
tsDnodeMClientRpc
,
&
tsDnodeMnodeIpList
,
rpcMsg
);
}
static
bool
dnodeReadMnodeIpList
()
{
char
ipFile
[
TSDB_FILENAME_LEN
]
=
{
0
};
sprintf
(
ipFile
,
"%s/iplist"
,
tsDnodeDir
);
FILE
*
fp
=
fopen
(
ipFile
,
"r"
);
if
(
!
fp
)
return
false
;
char
option
[
32
]
=
{
0
};
int32_t
value
=
0
;
int32_t
num
=
0
;
num
=
fscanf
(
fp
,
"%s %d"
,
option
,
&
value
);
if
(
num
!=
2
)
return
false
;
if
(
strcmp
(
option
,
"inUse"
)
!=
0
)
return
false
;
tsDnodeMnodeIpList
.
inUse
=
(
int8_t
)
value
;;
num
=
fscanf
(
fp
,
"%s %d"
,
option
,
&
value
);
if
(
num
!=
2
)
return
false
;
if
(
strcmp
(
option
,
"numOfIps"
)
!=
0
)
return
false
;
tsDnodeMnodeIpList
.
numOfIps
=
(
int8_t
)
value
;
num
=
fscanf
(
fp
,
"%s %d"
,
option
,
&
value
);
if
(
num
!=
2
)
return
false
;
if
(
strcmp
(
option
,
"port"
)
!=
0
)
return
false
;
tsDnodeMnodeIpList
.
port
=
(
uint16_t
)
value
;
for
(
int32_t
i
=
0
;
i
<
tsDnodeMnodeIpList
.
numOfIps
;
i
++
)
{
num
=
fscanf
(
fp
,
"%s %d"
,
option
,
&
value
);
if
(
num
!=
2
)
return
false
;
if
(
strncmp
(
option
,
"ip"
,
2
)
!=
0
)
return
false
;
tsDnodeMnodeIpList
.
ip
[
i
]
=
(
uint32_t
)
value
;
}
fclose
(
fp
);
dPrint
(
"read mnode iplist successed"
);
for
(
int32_t
i
=
0
;
i
<
tsDnodeMnodeIpList
.
numOfIps
;
i
++
)
{
dPrint
(
"mnode index:%d ip:%s"
,
i
,
taosIpStr
(
tsDnodeMnodeIpList
.
ip
[
i
]));
}
return
true
;
}
static
void
dnodeSaveMnodeIpList
()
{
char
ipFile
[
TSDB_FILENAME_LEN
]
=
{
0
};
sprintf
(
ipFile
,
"%s/iplist"
,
tsDnodeDir
);
FILE
*
fp
=
fopen
(
ipFile
,
"w"
);
if
(
!
fp
)
return
;
fprintf
(
fp
,
"inUse %d
\n
"
,
tsDnodeMnodeIpList
.
inUse
);
fprintf
(
fp
,
"numOfIps %d
\n
"
,
tsDnodeMnodeIpList
.
numOfIps
);
fprintf
(
fp
,
"port %u
\n
"
,
tsDnodeMnodeIpList
.
port
);
for
(
int32_t
i
=
0
;
i
<
tsDnodeMnodeIpList
.
numOfIps
;
i
++
)
{
fprintf
(
fp
,
"ip%d %u
\n
"
,
i
,
tsDnodeMnodeIpList
.
ip
[
i
]);
}
fclose
(
fp
);
dPrint
(
"save mnode iplist successed"
);
}
uint32_t
dnodeGetMnodeMasteIp
()
{
return
tsDnodeMnodeIpList
.
ip
[
0
];
}
}
\ No newline at end of file
src/dnode/src/dnodeMain.c
浏览文件 @
b87ac4ab
...
@@ -175,9 +175,9 @@ static int32_t dnodeInitSystem() {
...
@@ -175,9 +175,9 @@ static int32_t dnodeInitSystem() {
if
(
dnodeInitModules
()
!=
0
)
return
-
1
;
if
(
dnodeInitModules
()
!=
0
)
return
-
1
;
if
(
dnodeInitRead
()
!=
0
)
return
-
1
;
if
(
dnodeInitRead
()
!=
0
)
return
-
1
;
if
(
dnodeInitWrite
()
!=
0
)
return
-
1
;
if
(
dnodeInitWrite
()
!=
0
)
return
-
1
;
if
(
dnodeInitMgmt
()
!=
0
)
return
-
1
;
if
(
dnodeInitMnode
()
!=
0
)
return
-
1
;
if
(
dnodeInitMClient
()
!=
0
)
return
-
1
;
if
(
dnodeInitMClient
()
!=
0
)
return
-
1
;
if
(
dnodeInitMnode
()
!=
0
)
return
-
1
;
if
(
dnodeInitMgmt
()
!=
0
)
return
-
1
;
if
(
dnodeInitShell
()
!=
0
)
return
-
1
;
if
(
dnodeInitShell
()
!=
0
)
return
-
1
;
dnodeStartModules
();
dnodeStartModules
();
...
...
src/dnode/src/dnodeMgmt.c
浏览文件 @
b87ac4ab
...
@@ -22,16 +22,18 @@
...
@@ -22,16 +22,18 @@
#include "trpc.h"
#include "trpc.h"
#include "tstatus.h"
#include "tstatus.h"
#include "tsdb.h"
#include "tsdb.h"
#include "ttime.h"
#include "ttimer.h"
#include "ttimer.h"
#include "dnodeMClient.h"
#include "dnodeMgmt.h"
#include "dnodeMgmt.h"
#include "dnodeRead.h"
#include "dnodeRead.h"
#include "dnodeWrite.h"
#include "dnodeWrite.h"
typedef
struct
{
typedef
struct
{
int32_t
vgId
;
// global vnode group ID
int32_t
vgId
;
// global vnode group ID
int32_t
vnode
;
int32_t
status
;
// status: master, slave, notready, deleting
int32_t
refCount
;
// reference count
int32_t
refCount
;
// reference count
int8_t
dirty
;
int8_t
status
;
// status: master, slave, notready, deleting
int64_t
version
;
int64_t
version
;
void
*
wworker
;
void
*
wworker
;
void
*
rworker
;
void
*
rworker
;
...
@@ -48,6 +50,7 @@ static int32_t dnodeOpenVnode(int32_t vnode, char *rootDir);
...
@@ -48,6 +50,7 @@ static int32_t dnodeOpenVnode(int32_t vnode, char *rootDir);
static
void
dnodeCleanupVnode
(
SVnodeObj
*
pVnode
);
static
void
dnodeCleanupVnode
(
SVnodeObj
*
pVnode
);
static
int32_t
dnodeCreateVnode
(
SMDCreateVnodeMsg
*
cfg
);
static
int32_t
dnodeCreateVnode
(
SMDCreateVnodeMsg
*
cfg
);
static
void
dnodeDropVnode
(
SVnodeObj
*
pVnode
);
static
void
dnodeDropVnode
(
SVnodeObj
*
pVnode
);
static
void
dnodeDoDropVnode
(
SVnodeObj
*
pVnode
);
static
void
dnodeProcessCreateVnodeMsg
(
SRpcMsg
*
pMsg
);
static
void
dnodeProcessCreateVnodeMsg
(
SRpcMsg
*
pMsg
);
static
void
dnodeProcessDropVnodeMsg
(
SRpcMsg
*
pMsg
);
static
void
dnodeProcessDropVnodeMsg
(
SRpcMsg
*
pMsg
);
static
void
dnodeProcessAlterVnodeMsg
(
SRpcMsg
*
pMsg
);
static
void
dnodeProcessAlterVnodeMsg
(
SRpcMsg
*
pMsg
);
...
@@ -55,12 +58,18 @@ static void dnodeProcessAlterStreamMsg(SRpcMsg *pMsg);
...
@@ -55,12 +58,18 @@ static void dnodeProcessAlterStreamMsg(SRpcMsg *pMsg);
static
void
dnodeProcessConfigDnodeMsg
(
SRpcMsg
*
pMsg
);
static
void
dnodeProcessConfigDnodeMsg
(
SRpcMsg
*
pMsg
);
static
void
(
*
dnodeProcessMgmtMsgFp
[
TSDB_MSG_TYPE_MAX
])(
SRpcMsg
*
pMsg
);
static
void
(
*
dnodeProcessMgmtMsgFp
[
TSDB_MSG_TYPE_MAX
])(
SRpcMsg
*
pMsg
);
static
void
dnodeSendStatusMsg
(
void
*
handle
,
void
*
tmrId
);
static
void
dnodeSendStatusMsg
(
void
*
handle
,
void
*
tmrId
);
static
void
dnodeReadDnodeId
();
static
void
*
tsDnodeVnodesHash
=
NULL
;
static
void
*
tsDnodeVnodesHash
=
NULL
;
static
void
*
tsDnodeTmr
=
NULL
;
static
void
*
tsDnodeTmr
=
NULL
;
static
void
*
tsStatusTimer
=
NULL
;
static
void
*
tsStatusTimer
=
NULL
;
static
uint32_t
tsRebootTime
;
static
int32_t
tsDnodeId
=
0
;
static
char
tsDnodeName
[
TSDB_DNODE_NAME_LEN
];
int32_t
dnodeInitMgmt
()
{
int32_t
dnodeInitMgmt
()
{
dnodeReadDnodeId
();
dnodeProcessMgmtMsgFp
[
TSDB_MSG_TYPE_MD_CREATE_VNODE
]
=
dnodeProcessCreateVnodeMsg
;
dnodeProcessMgmtMsgFp
[
TSDB_MSG_TYPE_MD_CREATE_VNODE
]
=
dnodeProcessCreateVnodeMsg
;
dnodeProcessMgmtMsgFp
[
TSDB_MSG_TYPE_MD_DROP_VNODE
]
=
dnodeProcessDropVnodeMsg
;
dnodeProcessMgmtMsgFp
[
TSDB_MSG_TYPE_MD_DROP_VNODE
]
=
dnodeProcessDropVnodeMsg
;
dnodeProcessMgmtMsgFp
[
TSDB_MSG_TYPE_MD_ALTER_VNODE
]
=
dnodeProcessAlterVnodeMsg
;
dnodeProcessMgmtMsgFp
[
TSDB_MSG_TYPE_MD_ALTER_VNODE
]
=
dnodeProcessAlterVnodeMsg
;
...
@@ -73,6 +82,8 @@ int32_t dnodeInitMgmt() {
...
@@ -73,6 +82,8 @@ int32_t dnodeInitMgmt() {
return
-
1
;
return
-
1
;
}
}
tsRebootTime
=
taosGetTimestampSec
();
tsDnodeTmr
=
taosTmrInit
(
100
,
200
,
60000
,
"DND-DM"
);
tsDnodeTmr
=
taosTmrInit
(
100
,
200
,
60000
,
"DND-DM"
);
if
(
tsDnodeTmr
==
NULL
)
{
if
(
tsDnodeTmr
==
NULL
)
{
dError
(
"failed to init dnode timer"
);
dError
(
"failed to init dnode timer"
);
...
@@ -80,13 +91,6 @@ int32_t dnodeInitMgmt() {
...
@@ -80,13 +91,6 @@ int32_t dnodeInitMgmt() {
}
}
taosTmrReset
(
dnodeSendStatusMsg
,
500
,
NULL
,
tsDnodeTmr
,
&
tsStatusTimer
);
taosTmrReset
(
dnodeSendStatusMsg
,
500
,
NULL
,
tsDnodeTmr
,
&
tsStatusTimer
);
SMDCreateVnodeMsg
cfg
;
cfg
.
cfg
.
vgId
=
1
;
cfg
.
cfg
.
precision
=
0
;
cfg
.
vnode
=
1
;
cfg
.
cfg
.
maxSessions
=
1000
;
cfg
.
cfg
.
daysPerFile
=
10
;
return
dnodeOpenVnodes
();
return
dnodeOpenVnodes
();
}
}
...
@@ -96,8 +100,16 @@ void dnodeCleanupMgmt() {
...
@@ -96,8 +100,16 @@ void dnodeCleanupMgmt() {
tsStatusTimer
=
NULL
;
tsStatusTimer
=
NULL
;
}
}
if
(
tsDnodeTmr
!=
NULL
)
{
taosTmrCleanUp
(
tsDnodeTmr
);
tsDnodeTmr
=
NULL
;
}
dnodeCleanupVnodes
();
dnodeCleanupVnodes
();
if
(
tsDnodeVnodesHash
==
NULL
)
{
taosCleanUpIntHash
(
tsDnodeVnodesHash
);
taosCleanUpIntHash
(
tsDnodeVnodesHash
);
tsDnodeVnodesHash
=
NULL
;
}
}
}
void
dnodeMgmt
(
SRpcMsg
*
pMsg
)
{
void
dnodeMgmt
(
SRpcMsg
*
pMsg
)
{
...
@@ -113,7 +125,7 @@ void dnodeMgmt(SRpcMsg *pMsg) {
...
@@ -113,7 +125,7 @@ void dnodeMgmt(SRpcMsg *pMsg) {
rpcSendResponse
(
&
rsp
);
rpcSendResponse
(
&
rsp
);
}
}
rpcFreeCont
(
pMsg
->
pCont
);
// free the received message
rpcFreeCont
(
pMsg
->
pCont
);
}
}
void
*
dnodeGetVnode
(
int32_t
vgId
)
{
void
*
dnodeGetVnode
(
int32_t
vgId
)
{
...
@@ -152,8 +164,13 @@ void *dnodeGetVnodeTsdb(void *pVnode) {
...
@@ -152,8 +164,13 @@ void *dnodeGetVnodeTsdb(void *pVnode) {
return
((
SVnodeObj
*
)
pVnode
)
->
tsdb
;
return
((
SVnodeObj
*
)
pVnode
)
->
tsdb
;
}
}
void
dnodeReleaseVnode
(
void
*
pVnode
)
{
void
dnodeReleaseVnode
(
void
*
pVnodeRaw
)
{
atomic_sub_fetch_32
(
&
((
SVnodeObj
*
)
pVnode
)
->
refCount
,
1
);
SVnodeObj
*
pVnode
=
pVnodeRaw
;
int32_t
count
=
atomic_sub_fetch_32
(
&
pVnode
->
refCount
,
1
);
if
(
count
==
0
&&
pVnode
->
dirty
)
{
dnodeDoDropVnode
(
pVnode
);
}
}
}
static
int32_t
dnodeOpenVnodes
()
{
static
int32_t
dnodeOpenVnodes
()
{
...
@@ -171,8 +188,8 @@ static int32_t dnodeOpenVnodes() {
...
@@ -171,8 +188,8 @@ static int32_t dnodeOpenVnodes() {
int32_t
vnode
=
atoi
(
de
->
d_name
+
5
);
int32_t
vnode
=
atoi
(
de
->
d_name
+
5
);
if
(
vnode
==
0
)
continue
;
if
(
vnode
==
0
)
continue
;
char
vnodeDir
[
TSDB_FILENAME_LEN
];
char
vnodeDir
[
TSDB_FILENAME_LEN
*
3
];
s
printf
(
vnodeDir
,
"%s/%s"
,
tsVnodeDir
,
de
->
d_name
);
s
nprintf
(
vnodeDir
,
TSDB_FILENAME_LEN
*
3
,
"%s/%s"
,
tsVnodeDir
,
de
->
d_name
);
int32_t
code
=
dnodeOpenVnode
(
vnode
,
vnodeDir
);
int32_t
code
=
dnodeOpenVnode
(
vnode
,
vnodeDir
);
if
(
code
==
0
)
{
if
(
code
==
0
)
{
numOfVnodes
++
;
numOfVnodes
++
;
...
@@ -181,7 +198,7 @@ static int32_t dnodeOpenVnodes() {
...
@@ -181,7 +198,7 @@ static int32_t dnodeOpenVnodes() {
}
}
closedir
(
dir
);
closedir
(
dir
);
dPrint
(
"
all vnodes is opened, num
:%d"
,
numOfVnodes
);
dPrint
(
"
dnode mgmt is opened, vnodes
:%d"
,
numOfVnodes
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -189,7 +206,7 @@ typedef void (*CleanupFp)(char *);
...
@@ -189,7 +206,7 @@ typedef void (*CleanupFp)(char *);
static
void
dnodeCleanupVnodes
()
{
static
void
dnodeCleanupVnodes
()
{
int32_t
num
=
taosGetIntHashSize
(
tsDnodeVnodesHash
);
int32_t
num
=
taosGetIntHashSize
(
tsDnodeVnodesHash
);
taosCleanUpIntHashWithFp
(
tsDnodeVnodesHash
,
(
CleanupFp
)
dnodeCleanupVnode
);
taosCleanUpIntHashWithFp
(
tsDnodeVnodesHash
,
(
CleanupFp
)
dnodeCleanupVnode
);
dPrint
(
"
all vnodes is opened, num
:%d"
,
num
);
dPrint
(
"
dnode mgmt is closed, vnodes
:%d"
,
num
);
}
}
static
int32_t
dnodeOpenVnode
(
int32_t
vnode
,
char
*
rootDir
)
{
static
int32_t
dnodeOpenVnode
(
int32_t
vnode
,
char
*
rootDir
)
{
...
@@ -203,9 +220,8 @@ static int32_t dnodeOpenVnode(int32_t vnode, char *rootDir) {
...
@@ -203,9 +220,8 @@ static int32_t dnodeOpenVnode(int32_t vnode, char *rootDir) {
//STsdbRepoInfo *tsdbInfo = tsdbGetStatus(pTsdb);
//STsdbRepoInfo *tsdbInfo = tsdbGetStatus(pTsdb);
SVnodeObj
vnodeObj
;
SVnodeObj
vnodeObj
=
{
0
};
vnodeObj
.
vgId
=
vnode
;
//tsdbInfo->tsdbCfg.vgId;
vnodeObj
.
vgId
=
vnode
;
//tsdbInfo->tsdbCfg.tsdbId;
vnodeObj
.
vnode
=
vnode
;
//tsdbInfo->tsdbCfg.tsdbId;
vnodeObj
.
status
=
TSDB_VN_STATUS_NOT_READY
;
vnodeObj
.
status
=
TSDB_VN_STATUS_NOT_READY
;
vnodeObj
.
refCount
=
1
;
vnodeObj
.
refCount
=
1
;
vnodeObj
.
version
=
0
;
vnodeObj
.
version
=
0
;
...
@@ -219,7 +235,7 @@ static int32_t dnodeOpenVnode(int32_t vnode, char *rootDir) {
...
@@ -219,7 +235,7 @@ static int32_t dnodeOpenVnode(int32_t vnode, char *rootDir) {
taosAddIntHash
(
tsDnodeVnodesHash
,
vnodeObj
.
vgId
,
(
char
*
)
(
&
vnodeObj
));
taosAddIntHash
(
tsDnodeVnodesHash
,
vnodeObj
.
vgId
,
(
char
*
)
(
&
vnodeObj
));
dTrace
(
"open vnode:%d in %s"
,
vnodeObj
.
v
node
,
rootDir
);
dTrace
(
"open vnode:%d in %s"
,
vnodeObj
.
v
gId
,
rootDir
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -248,14 +264,13 @@ static void dnodeCleanupVnode(SVnodeObj *pVnode) {
...
@@ -248,14 +264,13 @@ static void dnodeCleanupVnode(SVnodeObj *pVnode) {
pVnode
->
tsdb
=
NULL
;
pVnode
->
tsdb
=
NULL
;
}
}
dTrace
(
"cleanup vnode:%d"
,
pVnode
->
v
node
);
dTrace
(
"cleanup vnode:%d"
,
pVnode
->
v
gId
);
}
}
static
int32_t
dnodeCreateVnode
(
SMDCreateVnodeMsg
*
pVnodeCfg
)
{
static
int32_t
dnodeCreateVnode
(
SMDCreateVnodeMsg
*
pVnodeCfg
)
{
STsdbCfg
tsdbCfg
=
{
0
};
STsdbCfg
tsdbCfg
=
{
0
};
tsdbCfg
.
vgId
=
pVnodeCfg
->
cfg
.
vgId
;
tsdbCfg
.
precision
=
pVnodeCfg
->
cfg
.
precision
;
tsdbCfg
.
precision
=
pVnodeCfg
->
cfg
.
precision
;
tsdbCfg
.
tsdbId
=
pVnodeCfg
->
vnode
;
tsdbCfg
.
tsdbId
=
pVnodeCfg
->
cfg
.
vgId
;
tsdbCfg
.
maxTables
=
pVnodeCfg
->
cfg
.
maxSessions
;
tsdbCfg
.
maxTables
=
pVnodeCfg
->
cfg
.
maxSessions
;
tsdbCfg
.
daysPerFile
=
pVnodeCfg
->
cfg
.
daysPerFile
;
tsdbCfg
.
daysPerFile
=
pVnodeCfg
->
cfg
.
daysPerFile
;
tsdbCfg
.
minRowsPerFileBlock
=
-
1
;
tsdbCfg
.
minRowsPerFileBlock
=
-
1
;
...
@@ -290,13 +305,12 @@ static int32_t dnodeCreateVnode(SMDCreateVnodeMsg *pVnodeCfg) {
...
@@ -290,13 +305,12 @@ static int32_t dnodeCreateVnode(SMDCreateVnodeMsg *pVnodeCfg) {
void
*
pTsdb
=
tsdbCreateRepo
(
rootDir
,
&
tsdbCfg
,
NULL
);
void
*
pTsdb
=
tsdbCreateRepo
(
rootDir
,
&
tsdbCfg
,
NULL
);
if
(
pTsdb
==
NULL
)
{
if
(
pTsdb
==
NULL
)
{
dError
(
"vgroup:%d, failed to create tsdb in vnode
:%d, reason:%s"
,
pVnodeCfg
->
cfg
.
vgId
,
pVnodeCfg
->
vnode
,
tstrerror
(
terrno
));
dError
(
"vgroup:%d, failed to create tsdb in vnode
, reason:%s"
,
pVnodeCfg
->
cfg
.
vgId
,
tstrerror
(
terrno
));
return
terrno
;
return
terrno
;
}
}
SVnodeObj
vnodeObj
;
SVnodeObj
vnodeObj
=
{
0
}
;
vnodeObj
.
vgId
=
pVnodeCfg
->
cfg
.
vgId
;
vnodeObj
.
vgId
=
pVnodeCfg
->
cfg
.
vgId
;
vnodeObj
.
vnode
=
pVnodeCfg
->
vnode
;
vnodeObj
.
status
=
TSDB_VN_STATUS_NOT_READY
;
vnodeObj
.
status
=
TSDB_VN_STATUS_NOT_READY
;
vnodeObj
.
refCount
=
1
;
vnodeObj
.
refCount
=
1
;
vnodeObj
.
version
=
0
;
vnodeObj
.
version
=
0
;
...
@@ -310,18 +324,11 @@ static int32_t dnodeCreateVnode(SMDCreateVnodeMsg *pVnodeCfg) {
...
@@ -310,18 +324,11 @@ static int32_t dnodeCreateVnode(SMDCreateVnodeMsg *pVnodeCfg) {
taosAddIntHash
(
tsDnodeVnodesHash
,
vnodeObj
.
vgId
,
(
char
*
)
(
&
vnodeObj
));
taosAddIntHash
(
tsDnodeVnodesHash
,
vnodeObj
.
vgId
,
(
char
*
)
(
&
vnodeObj
));
dPrint
(
"vgroup:%d, vnode:%d is created"
,
pVnodeCfg
->
cfg
.
vgId
,
pVnodeCfg
->
vnode
);
dPrint
(
"vgroup:%d, vnode:%d is created"
,
vnodeObj
.
vgId
,
vnodeObj
.
vgId
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
dnodeDropVnode
(
SVnodeObj
*
pVnode
)
{
static
void
dnodeDoDropVnode
(
SVnodeObj
*
pVnode
)
{
pVnode
->
status
=
TSDB_VN_STATUS_NOT_READY
;
int32_t
count
=
atomic_sub_fetch_32
(
&
pVnode
->
refCount
,
1
);
if
(
count
>
0
)
{
// wait refcount
}
if
(
pVnode
->
tsdb
)
{
if
(
pVnode
->
tsdb
)
{
tsdbDropRepo
(
pVnode
->
tsdb
);
tsdbDropRepo
(
pVnode
->
tsdb
);
pVnode
->
tsdb
=
NULL
;
pVnode
->
tsdb
=
NULL
;
...
@@ -331,21 +338,33 @@ static void dnodeDropVnode(SVnodeObj *pVnode) {
...
@@ -331,21 +338,33 @@ static void dnodeDropVnode(SVnodeObj *pVnode) {
taosDeleteIntHash
(
tsDnodeVnodesHash
,
pVnode
->
vgId
);
taosDeleteIntHash
(
tsDnodeVnodesHash
,
pVnode
->
vgId
);
}
}
static
void
dnodeDropVnode
(
SVnodeObj
*
pVnode
)
{
pVnode
->
status
=
TSDB_VN_STATUS_NOT_READY
;
pVnode
->
dirty
=
true
;
int32_t
count
=
atomic_sub_fetch_32
(
&
pVnode
->
refCount
,
1
);
if
(
count
>
0
)
{
dTrace
(
"vgroup:%d, vnode will be dropped until refcount:%d is 0"
,
pVnode
->
vgId
,
count
);
return
;
}
dnodeDoDropVnode
(
pVnode
);
}
static
void
dnodeProcessCreateVnodeMsg
(
SRpcMsg
*
rpcMsg
)
{
static
void
dnodeProcessCreateVnodeMsg
(
SRpcMsg
*
rpcMsg
)
{
SRpcMsg
rpcRsp
=
{.
handle
=
rpcMsg
->
handle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
SRpcMsg
rpcRsp
=
{.
handle
=
rpcMsg
->
handle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
SMDCreateVnodeMsg
*
pCreate
=
rpcMsg
->
pCont
;
SMDCreateVnodeMsg
*
pCreate
=
rpcMsg
->
pCont
;
pCreate
->
vnode
=
htonl
(
pCreate
->
vnode
);
pCreate
->
cfg
.
vgId
=
htonl
(
pCreate
->
cfg
.
vgId
);
pCreate
->
cfg
.
vgId
=
htonl
(
pCreate
->
cfg
.
vgId
);
pCreate
->
cfg
.
maxSessions
=
htonl
(
pCreate
->
cfg
.
maxSessions
);
pCreate
->
cfg
.
maxSessions
=
htonl
(
pCreate
->
cfg
.
maxSessions
);
pCreate
->
cfg
.
daysPerFile
=
htonl
(
pCreate
->
cfg
.
daysPerFile
);
pCreate
->
cfg
.
daysPerFile
=
htonl
(
pCreate
->
cfg
.
daysPerFile
);
dTrace
(
"vgroup:%d, start to create vnode:%d
"
,
pCreate
->
cfg
.
vgId
,
pCreate
->
vnode
);
dTrace
(
"vgroup:%d, start to create vnode:%d
in dnode"
,
pCreate
->
cfg
.
vgId
,
pCreate
->
cfg
.
vgId
);
SVnodeObj
*
pVnodeObj
=
(
SVnodeObj
*
)
taosGetIntHashData
(
tsDnodeVnodesHash
,
pCreate
->
cfg
.
vgId
);
SVnodeObj
*
pVnodeObj
=
(
SVnodeObj
*
)
taosGetIntHashData
(
tsDnodeVnodesHash
,
pCreate
->
cfg
.
vgId
);
if
(
pVnodeObj
!=
NULL
)
{
if
(
pVnodeObj
!=
NULL
)
{
rpcRsp
.
code
=
TSDB_CODE_SUCCESS
;
rpcRsp
.
code
=
TSDB_CODE_SUCCESS
;
dPrint
(
"vgroup:%d, vnode
:%d is already exist"
,
pCreate
->
cfg
.
vgId
,
pCreate
->
vnode
);
dPrint
(
"vgroup:%d, vnode
is already exist"
,
pCreate
->
cfg
.
vgId
);
}
else
{
}
else
{
rpcRsp
.
code
=
dnodeCreateVnode
(
pCreate
);
rpcRsp
.
code
=
dnodeCreateVnode
(
pCreate
);
}
}
...
@@ -359,6 +378,8 @@ static void dnodeProcessDropVnodeMsg(SRpcMsg *rpcMsg) {
...
@@ -359,6 +378,8 @@ static void dnodeProcessDropVnodeMsg(SRpcMsg *rpcMsg) {
SMDDropVnodeMsg
*
pDrop
=
rpcMsg
->
pCont
;
SMDDropVnodeMsg
*
pDrop
=
rpcMsg
->
pCont
;
pDrop
->
vgId
=
htonl
(
pDrop
->
vgId
);
pDrop
->
vgId
=
htonl
(
pDrop
->
vgId
);
dTrace
(
"vgroup:%d, start to drop vnode in dnode"
,
pDrop
->
vgId
);
SVnodeObj
*
pVnodeObj
=
(
SVnodeObj
*
)
taosGetIntHashData
(
tsDnodeVnodesHash
,
pDrop
->
vgId
);
SVnodeObj
*
pVnodeObj
=
(
SVnodeObj
*
)
taosGetIntHashData
(
tsDnodeVnodesHash
,
pDrop
->
vgId
);
if
(
pVnodeObj
!=
NULL
)
{
if
(
pVnodeObj
!=
NULL
)
{
dnodeDropVnode
(
pVnodeObj
);
dnodeDropVnode
(
pVnodeObj
);
...
@@ -374,11 +395,12 @@ static void dnodeProcessAlterVnodeMsg(SRpcMsg *rpcMsg) {
...
@@ -374,11 +395,12 @@ static void dnodeProcessAlterVnodeMsg(SRpcMsg *rpcMsg) {
SRpcMsg
rpcRsp
=
{.
handle
=
rpcMsg
->
handle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
SRpcMsg
rpcRsp
=
{.
handle
=
rpcMsg
->
handle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
SMDCreateVnodeMsg
*
pCreate
=
rpcMsg
->
pCont
;
SMDCreateVnodeMsg
*
pCreate
=
rpcMsg
->
pCont
;
pCreate
->
vnode
=
htonl
(
pCreate
->
vnode
);
pCreate
->
cfg
.
vgId
=
htonl
(
pCreate
->
cfg
.
vgId
);
pCreate
->
cfg
.
vgId
=
htonl
(
pCreate
->
cfg
.
vgId
);
pCreate
->
cfg
.
maxSessions
=
htonl
(
pCreate
->
cfg
.
maxSessions
);
pCreate
->
cfg
.
maxSessions
=
htonl
(
pCreate
->
cfg
.
maxSessions
);
pCreate
->
cfg
.
daysPerFile
=
htonl
(
pCreate
->
cfg
.
daysPerFile
);
pCreate
->
cfg
.
daysPerFile
=
htonl
(
pCreate
->
cfg
.
daysPerFile
);
dTrace
(
"vgroup:%d, start to alter vnode in dnode"
,
pCreate
->
cfg
.
vgId
);
SVnodeObj
*
pVnodeObj
=
(
SVnodeObj
*
)
taosGetIntHashData
(
tsDnodeVnodesHash
,
pCreate
->
cfg
.
vgId
);
SVnodeObj
*
pVnodeObj
=
(
SVnodeObj
*
)
taosGetIntHashData
(
tsDnodeVnodesHash
,
pCreate
->
cfg
.
vgId
);
if
(
pVnodeObj
!=
NULL
)
{
if
(
pVnodeObj
!=
NULL
)
{
rpcRsp
.
code
=
TSDB_CODE_SUCCESS
;
rpcRsp
.
code
=
TSDB_CODE_SUCCESS
;
...
@@ -401,66 +423,109 @@ static void dnodeProcessAlterStreamMsg(SRpcMsg *pMsg) {
...
@@ -401,66 +423,109 @@ static void dnodeProcessAlterStreamMsg(SRpcMsg *pMsg) {
}
}
static
void
dnodeProcessConfigDnodeMsg
(
SRpcMsg
*
pMsg
)
{
static
void
dnodeProcessConfigDnodeMsg
(
SRpcMsg
*
pMsg
)
{
// SCfgDnodeMsg *pCfg = (SCfgDnodeMsg *)pCont;
SMDCfgDnodeMsg
*
pCfg
=
(
SMDCfgDnodeMsg
*
)
pMsg
->
pCont
;
//
int32_t
code
=
tsCfgDynamicOptions
(
pCfg
->
config
);
// int32_t code = tsCfgDynamicOptions(pCfg->config);
// dnodeSendRspToMnode(pConn, msgType + 1, code, NULL, 0);
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
handle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
code
,
.
msgType
=
0
};
rpcSendResponse
(
&
rpcRsp
);
}
static
void
dnodeBuildVloadMsg
(
char
*
pNode
,
void
*
param
)
{
SVnodeObj
*
pVnode
=
(
SVnodeObj
*
)
pNode
;
if
(
pVnode
->
dirty
)
return
;
SDMStatusMsg
*
pStatus
=
param
;
if
(
pStatus
->
openVnodes
>=
TSDB_MAX_VNODES
)
return
;
SVnodeLoad
*
pLoad
=
&
pStatus
->
load
[
pStatus
->
openVnodes
++
];
pLoad
->
vgId
=
htonl
(
pVnode
->
vgId
);
pLoad
->
vnode
=
htonl
(
pVnode
->
vgId
);
pLoad
->
status
=
pVnode
->
status
;
}
}
static
void
dnodeSendStatusMsg
(
void
*
handle
,
void
*
tmrId
)
{
static
void
dnodeSendStatusMsg
(
void
*
handle
,
void
*
tmrId
)
{
taosTmrReset
(
dnodeSendStatusMsg
,
tsStatusInterval
*
1000
,
NULL
,
tsDnodeTmr
,
&
tsStatusTimer
);
if
(
tsDnodeTmr
==
NULL
)
{
dError
(
"dnode timer is already released"
);
return
;
}
if
(
tsStatusTimer
==
NULL
)
{
if
(
tsStatusTimer
==
NULL
)
{
taosTmrReset
(
dnodeSendStatusMsg
,
tsStatusInterval
*
1000
,
NULL
,
tsDnodeTmr
,
&
tsStatusTimer
);
dError
(
"failed to start status timer"
);
dError
(
"failed to start status timer"
);
return
;
return
;
}
}
// int32_t contLen = sizeof(SDMStatusMsg) + dnodeGetVnodesNum() * sizeof(SVnodeLoad);
int32_t
contLen
=
sizeof
(
SDMStatusMsg
)
+
TSDB_MAX_VNODES
*
sizeof
(
SVnodeLoad
);
// SDMStatusMsg *pStatus = rpcMallocCont(contLen);
SDMStatusMsg
*
pStatus
=
rpcMallocCont
(
contLen
);
// if (pStatus == NULL) {
if
(
pStatus
==
NULL
)
{
// dError("Failed to malloc status message");
taosTmrReset
(
dnodeSendStatusMsg
,
tsStatusInterval
*
1000
,
NULL
,
tsDnodeTmr
,
&
tsStatusTimer
);
// return;
dError
(
"failed to malloc status message"
);
// }
return
;
//
}
// int32_t totalVnodes = dnodeGetVnodesNum();
//
strcpy
(
pStatus
->
dnodeName
,
tsDnodeName
);
// pStatus->version = htonl(tsVersion);
pStatus
->
version
=
htonl
(
tsVersion
);
// pStatus->privateIp = htonl(inet_addr(tsPrivateIp));
pStatus
->
dnodeId
=
htonl
(
tsDnodeId
);
// pStatus->publicIp = htonl(inet_addr(tsPublicIp));
pStatus
->
privateIp
=
htonl
(
inet_addr
(
tsPrivateIp
));
// pStatus->lastReboot = htonl(tsRebootTime);
pStatus
->
publicIp
=
htonl
(
inet_addr
(
tsPublicIp
));
// pStatus->numOfTotalVnodes = htons((uint16_t) tsNumOfTotalVnodes);
pStatus
->
lastReboot
=
htonl
(
tsRebootTime
);
// pStatus->openVnodes = htons((uint16_t) totalVnodes);
pStatus
->
numOfTotalVnodes
=
htons
((
uint16_t
)
tsNumOfTotalVnodes
);
// pStatus->numOfCores = htons((uint16_t) tsNumOfCores);
pStatus
->
numOfCores
=
htons
((
uint16_t
)
tsNumOfCores
);
// pStatus->diskAvailable = tsAvailDataDirGB;
pStatus
->
diskAvailable
=
tsAvailDataDirGB
;
// pStatus->alternativeRole = (uint8_t) tsAlternativeRole;
pStatus
->
alternativeRole
=
(
uint8_t
)
tsAlternativeRole
;
//
// SVnodeLoad *pLoad = (SVnodeLoad *)pStatus->load;
taosVisitIntHashWithFp
(
tsDnodeVnodesHash
,
dnodeBuildVloadMsg
,
pStatus
);
contLen
=
sizeof
(
SDMStatusMsg
)
+
pStatus
->
openVnodes
*
sizeof
(
SVnodeLoad
);
//TODO loop all vnodes
pStatus
->
openVnodes
=
htons
(
pStatus
->
openVnodes
);
// for (int32_t vnode = 0, count = 0; vnode <= totalVnodes; ++vnode) {
// if (vnodeList[vnode].cfg.maxSessions <= 0) continue;
SRpcMsg
rpcMsg
=
{
//
.
pCont
=
pStatus
,
// SVnodeObj *pVnode = vnodeList + vnode;
.
contLen
=
contLen
,
// pLoad->vnode = htonl(vnode);
.
msgType
=
TSDB_MSG_TYPE_DM_STATUS
// pLoad->vgId = htonl(pVnode->cfg.vgId);
};
// pLoad->status = (uint8_t)vnodeList[vnode].vnodeStatus;
// pLoad->syncStatus =(uint8_t)vnodeList[vnode].syncStatus;
dnodeSendMsgToMnode
(
&
rpcMsg
);
// pLoad->accessState = (uint8_t)(pVnode->accessState);
taosTmrReset
(
dnodeSendStatusMsg
,
tsStatusInterval
*
1000
,
NULL
,
tsDnodeTmr
,
&
tsStatusTimer
);
// pLoad->totalStorage = htobe64(pVnode->vnodeStatistic.totalStorage);
// pLoad->compStorage = htobe64(pVnode->vnodeStatistic.compStorage);
// if (pVnode->vnodeStatus == TSDB_VN_STATUS_MASTER) {
// pLoad->pointsWritten = htobe64(pVnode->vnodeStatistic.pointsWritten);
// } else {
// pLoad->pointsWritten = htobe64(0);
// }
// pLoad++;
//
// if (++count >= tsOpenVnodes) {
// break;
// }
// }
// dnodeSendMsgToMnode(TSDB_MSG_TYPE_STATUS, pStatus, contLen);
}
}
static
void
dnodeReadDnodeId
()
{
char
dnodeIdFile
[
TSDB_FILENAME_LEN
]
=
{
0
};
sprintf
(
dnodeIdFile
,
"%s/dnodeId"
,
tsDnodeDir
);
FILE
*
fp
=
fopen
(
dnodeIdFile
,
"r"
);
if
(
!
fp
)
return
;
char
option
[
32
]
=
{
0
};
int32_t
value
=
0
;
int32_t
num
=
0
;
num
=
fscanf
(
fp
,
"%s %d"
,
option
,
&
value
);
if
(
num
!=
2
)
return
;
if
(
strcmp
(
option
,
"dnodeId"
)
!=
0
)
return
;
tsDnodeId
=
value
;;
fclose
(
fp
);
dPrint
(
"read dnodeId:%d successed"
,
tsDnodeId
);
}
static
void
dnodeSaveDnodeId
()
{
char
dnodeIdFile
[
TSDB_FILENAME_LEN
]
=
{
0
};
sprintf
(
dnodeIdFile
,
"%s/dnodeId"
,
tsDnodeDir
);
FILE
*
fp
=
fopen
(
dnodeIdFile
,
"w"
);
if
(
!
fp
)
return
;
fprintf
(
fp
,
"dnodeId %d
\n
"
,
tsDnodeId
);
fclose
(
fp
);
dPrint
(
"save dnodeId successed"
);
}
void
dnodeUpdateDnodeId
(
int32_t
dnodeId
)
{
if
(
tsDnodeId
==
0
)
{
dPrint
(
"dnodeId is set to %d"
,
dnodeId
);
tsDnodeId
=
dnodeId
;
dnodeSaveDnodeId
();
}
}
src/dnode/src/dnodeMnode.c
浏览文件 @
b87ac4ab
...
@@ -40,32 +40,33 @@ int32_t dnodeInitMnode() {
...
@@ -40,32 +40,33 @@ int32_t dnodeInitMnode() {
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
rpcInit
.
localIp
=
tsAnyIp
?
"0.0.0.0"
:
tsPrivateIp
;
rpcInit
.
localIp
=
tsAnyIp
?
"0.0.0.0"
:
tsPrivateIp
;
rpcInit
.
localPort
=
tsDnodeMnodePort
;
rpcInit
.
localPort
=
tsDnodeMnodePort
;
rpcInit
.
label
=
"DND-
mgmt
"
;
rpcInit
.
label
=
"DND-
MS
"
;
rpcInit
.
numOfThreads
=
1
;
rpcInit
.
numOfThreads
=
1
;
rpcInit
.
cfp
=
dnodeProcessMsgFromMnode
;
rpcInit
.
cfp
=
dnodeProcessMsgFromMnode
;
rpcInit
.
sessions
=
TSDB_SESSIONS_PER_DNODE
;
rpcInit
.
sessions
=
100
;
rpcInit
.
connType
=
TAOS_CONN_SERVER
;
rpcInit
.
connType
=
TAOS_CONN_SERVER
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
15
00
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
20
00
;
tsDnodeMnodeRpc
=
rpcOpen
(
&
rpcInit
);
tsDnodeMnodeRpc
=
rpcOpen
(
&
rpcInit
);
if
(
tsDnodeMnodeRpc
==
NULL
)
{
if
(
tsDnodeMnodeRpc
==
NULL
)
{
dError
(
"failed to init
connection from mgmt
"
);
dError
(
"failed to init
mnode rpc server
"
);
return
-
1
;
return
-
1
;
}
}
dPrint
(
"
connection to mgmt
is opened"
);
dPrint
(
"
mnode rpc server
is opened"
);
return
0
;
return
0
;
}
}
void
dnodeCleanupMnode
()
{
void
dnodeCleanupMnode
()
{
if
(
tsDnodeMnodeRpc
)
{
if
(
tsDnodeMnodeRpc
)
{
rpcClose
(
tsDnodeMnodeRpc
);
rpcClose
(
tsDnodeMnodeRpc
);
tsDnodeMnodeRpc
=
NULL
;
dPrint
(
"mnode rpc server is closed"
);
}
}
}
}
static
void
dnodeProcessMsgFromMnode
(
SRpcMsg
*
pMsg
)
{
static
void
dnodeProcessMsgFromMnode
(
SRpcMsg
*
pMsg
)
{
SRpcMsg
rspMsg
;
SRpcMsg
rspMsg
;
rspMsg
.
handle
=
pMsg
->
handle
;
rspMsg
.
handle
=
pMsg
->
handle
;
rspMsg
.
pCont
=
NULL
;
rspMsg
.
pCont
=
NULL
;
rspMsg
.
contLen
=
0
;
rspMsg
.
contLen
=
0
;
...
@@ -74,7 +75,7 @@ static void dnodeProcessMsgFromMnode(SRpcMsg *pMsg) {
...
@@ -74,7 +75,7 @@ static void dnodeProcessMsgFromMnode(SRpcMsg *pMsg) {
rspMsg
.
code
=
TSDB_CODE_NOT_READY
;
rspMsg
.
code
=
TSDB_CODE_NOT_READY
;
rpcSendResponse
(
&
rspMsg
);
rpcSendResponse
(
&
rspMsg
);
rpcFreeCont
(
pMsg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
dTrace
(
"
conn
:%p, query msg is ignored since dnode not running"
,
pMsg
->
handle
);
dTrace
(
"
thandle
:%p, query msg is ignored since dnode not running"
,
pMsg
->
handle
);
return
;
return
;
}
}
...
...
src/dnode/src/dnodeModule.c
浏览文件 @
b87ac4ab
...
@@ -74,7 +74,7 @@ int32_t dnodeInitModules() {
...
@@ -74,7 +74,7 @@ int32_t dnodeInitModules() {
for
(
int
mod
=
0
;
mod
<
TSDB_MOD_MAX
;
++
mod
)
{
for
(
int
mod
=
0
;
mod
<
TSDB_MOD_MAX
;
++
mod
)
{
if
(
tsModule
[
mod
].
num
!=
0
&&
tsModule
[
mod
].
initFp
)
{
if
(
tsModule
[
mod
].
num
!=
0
&&
tsModule
[
mod
].
initFp
)
{
if
((
*
tsModule
[
mod
].
initFp
)()
!=
0
)
{
if
((
*
tsModule
[
mod
].
initFp
)()
!=
0
)
{
dError
(
"
TDengine initialization failed
"
);
dError
(
"
failed to init modules
"
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -84,11 +84,44 @@ int32_t dnodeInitModules() {
...
@@ -84,11 +84,44 @@ int32_t dnodeInitModules() {
}
}
void
dnodeStartModules
()
{
void
dnodeStartModules
()
{
for
(
int
mod
=
1
;
mod
<
TSDB_MOD_MAX
;
++
mod
)
{
// for (int mod = 1; mod < TSDB_MOD_MAX; ++mod) {
if
(
tsModule
[
mod
].
num
!=
0
&&
tsModule
[
mod
].
startFp
)
{
// if (tsModule[mod].num != 0 && tsModule[mod].startFp) {
if
((
*
tsModule
[
mod
].
startFp
)()
!=
0
)
{
// if ((*tsModule[mod].startFp)() != 0) {
dError
(
"failed to start module:%d"
,
mod
);
// dError("failed to start module:%d", mod);
// }
// }
// }
}
void
dnodeProcessModuleStatus
(
uint32_t
moduleStatus
)
{
if
(
moduleStatus
==
tsModuleStatus
)
return
;
dPrint
(
"module status is received, old:%d, new:%d"
,
tsModuleStatus
,
moduleStatus
);
int
news
=
moduleStatus
;
int
olds
=
tsModuleStatus
;
for
(
int
moduleType
=
0
;
moduleType
<
TSDB_MOD_MAX
;
++
moduleType
)
{
int
newStatus
=
news
&
(
1
<<
moduleType
);
int
oldStatus
=
olds
&
(
1
<<
moduleType
);
if
(
oldStatus
>
0
)
{
if
(
newStatus
==
0
)
{
if
(
tsModule
[
moduleType
].
stopFp
)
{
dPrint
(
"module:%s is stopped on this node"
,
tsModule
[
moduleType
].
name
);
(
*
tsModule
[
moduleType
].
stopFp
)();
}
}
}
else
if
(
oldStatus
==
0
)
{
if
(
newStatus
>
0
)
{
if
(
tsModule
[
moduleType
].
startFp
)
{
dPrint
(
"module:%s is started on this node"
,
tsModule
[
moduleType
].
name
);
(
*
tsModule
[
moduleType
].
startFp
)();
}
}
}
}
}
else
{
}
}
}
tsModuleStatus
=
moduleStatus
;
}
}
src/dnode/src/dnodeShell.c
浏览文件 @
b87ac4ab
...
@@ -53,15 +53,15 @@ int32_t dnodeInitShell() {
...
@@ -53,15 +53,15 @@ int32_t dnodeInitShell() {
rpcInit
.
sessions
=
TSDB_SESSIONS_PER_DNODE
;
rpcInit
.
sessions
=
TSDB_SESSIONS_PER_DNODE
;
rpcInit
.
connType
=
TAOS_CONN_SERVER
;
rpcInit
.
connType
=
TAOS_CONN_SERVER
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1500
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1500
;
rpcInit
.
afp
=
rpcInit
.
afp
=
dnodeRetrieveUserAuthInfo
;
tsDnodeShellRpc
=
rpcOpen
(
&
rpcInit
);
tsDnodeShellRpc
=
rpcOpen
(
&
rpcInit
);
if
(
tsDnodeShellRpc
==
NULL
)
{
if
(
tsDnodeShellRpc
==
NULL
)
{
dError
(
"failed to init
connection from shell
"
);
dError
(
"failed to init
shell rpc server
"
);
return
-
1
;
return
-
1
;
}
}
dPrint
(
"
connection to shell
is opened"
);
dPrint
(
"
shell rpc server
is opened"
);
return
0
;
return
0
;
}
}
...
...
src/dnode/src/dnodeWrite.c
浏览文件 @
b87ac4ab
...
@@ -94,7 +94,7 @@ void dnodeWrite(SRpcMsg *pMsg) {
...
@@ -94,7 +94,7 @@ void dnodeWrite(SRpcMsg *pMsg) {
SRpcContext
*
pRpcContext
=
NULL
;
SRpcContext
*
pRpcContext
=
NULL
;
if
(
pMsg
->
msgType
==
TSDB_MSG_TYPE_SUBMIT
||
pMsg
->
msgType
==
TSDB_MSG_TYPE_MD_DROP_STABLE
)
{
if
(
pMsg
->
msgType
==
TSDB_MSG_TYPE_SUBMIT
||
pMsg
->
msgType
==
TSDB_MSG_TYPE_MD_DROP_STABLE
)
{
SMsgDesc
*
pDesc
=
pCont
;
SMsgDesc
*
pDesc
=
(
SMsgDesc
*
)
pCont
;
pDesc
->
numOfVnodes
=
htonl
(
pDesc
->
numOfVnodes
);
pDesc
->
numOfVnodes
=
htonl
(
pDesc
->
numOfVnodes
);
pCont
+=
sizeof
(
SMsgDesc
);
pCont
+=
sizeof
(
SMsgDesc
);
if
(
pDesc
->
numOfVnodes
>
1
)
{
if
(
pDesc
->
numOfVnodes
>
1
)
{
...
...
src/inc/mnode.h
浏览文件 @
b87ac4ab
...
@@ -40,47 +40,62 @@ extern "C" {
...
@@ -40,47 +40,62 @@ extern "C" {
#include "tutil.h"
#include "tutil.h"
typedef
struct
{
typedef
struct
{
int32_t
mnodeId
;
uint32_t
privateIp
;
uint32_t
privateIp
;
int32_t
sid
;
uint32_t
publicIp
;
uint32_t
moduleStatus
;
int32_t
openVnodes
;
int32_t
numOfVnodes
;
int32_t
numOfFreeVnodes
;
int64_t
createdTime
;
int64_t
createdTime
;
int64_t
lostTime
;
uint64_t
dbVersion
;
uint32_t
rack
;
uint16_t
idc
;
uint16_t
slot
;
int8_t
role
;
int8_t
status
;
int8_t
numOfMnodes
;
int32_t
numOfDnodes
;
char
mnodeName
[
TSDB_DNODE_NAME_LEN
+
1
];
char
reserved
[
7
];
char
updateEnd
[
1
];
int
syncFd
;
void
*
hbTimer
;
void
*
pSync
;
}
SMnodeObj
;
typedef
struct
{
int32_t
dnodeId
;
uint32_t
privateIp
;
uint32_t
publicIp
;
uint32_t
publicIp
;
int32_t
status
;
uint32_t
moduleStatus
;
int64_t
createdTime
;
uint32_t
lastAccess
;
uint32_t
lastAccess
;
uint32_t
rebootTimes
;
int32_t
openVnodes
;
uint32_t
lastReboot
;
// time stamp for last reboot
int32_t
numOfTotalVnodes
;
// from dnode status msg, config information
uint16_t
numOfCores
;
// from dnode status msg
uint8_t
alternativeRole
;
// from dnode status msg, 0-any, 1-mgmt, 2-dnode
uint8_t
reserveStatus
;
uint16_t
numOfTotalVnodes
;
// from dnode status msg, config information
uint16_t
unused
;
float
diskAvailable
;
// from dnode status msg
int32_t
bandwidthMb
;
// config by user
int16_t
cpuAvgUsage
;
// calc from sys.cpu
int16_t
memoryAvgUsage
;
// calc from sys.mem
int16_t
diskAvgUsage
;
// calc from sys.disk
int16_t
bandwidthUsage
;
// calc from sys.band
uint32_t
rack
;
uint32_t
rack
;
uint16_t
idc
;
uint16_t
idc
;
uint16_t
slot
;
uint16_t
slot
;
int32_t
customScore
;
// config by user
uint16_t
numOfCores
;
// from dnode status msg
int8_t
alternativeRole
;
// from dnode status msg, 0-any, 1-mgmt, 2-dnode
int8_t
lbStatus
;
// set in balance function
float
lbScore
;
// calc in balance function
float
lbScore
;
// calc in balance function
int16_t
lbStatus
;
// set in balance function
int32_t
customScore
;
// config by user
int16_t
lastAllocVnode
;
// increase while create vnode
char
dnodeName
[
TSDB_DNODE_NAME_LEN
+
1
];
SVnodeLoad
vload
[
TSDB_MAX_VNODES
];
char
reserved
[
7
];
char
reserved
[
16
];
char
updateEnd
[
1
];
char
updateEnd
[
1
];
void
*
thandle
;
SVnodeLoad
vload
[
TSDB_MAX_VNODES
];
int32_t
status
;
uint32_t
lastReboot
;
// time stamp for last reboot
float
diskAvailable
;
// from dnode status msg
int16_t
diskAvgUsage
;
// calc from sys.disk
int16_t
cpuAvgUsage
;
// calc from sys.cpu
int16_t
memoryAvgUsage
;
// calc from sys.mem
int16_t
bandwidthUsage
;
// calc from sys.band
}
SDnodeObj
;
}
SDnodeObj
;
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
uint32_t
ip
;
uint32_t
publicIp
;
int32_t
vnode
;
int32_t
vnode
;
uint32_t
privateIp
;
uint32_t
publicIp
;
}
SVnodeGid
;
}
SVnodeGid
;
typedef
struct
{
typedef
struct
{
...
@@ -149,15 +164,13 @@ typedef struct _vg_obj {
...
@@ -149,15 +164,13 @@ typedef struct _vg_obj {
uint32_t
vgId
;
uint32_t
vgId
;
char
dbName
[
TSDB_DB_NAME_LEN
+
1
];
char
dbName
[
TSDB_DB_NAME_LEN
+
1
];
int64_t
createdTime
;
int64_t
createdTime
;
uint64_t
lastCreate
;
uint64_t
lastRemove
;
int32_t
numOfVnodes
;
SVnodeGid
vnodeGid
[
TSDB_VNODES_SUPPORT
];
SVnodeGid
vnodeGid
[
TSDB_VNODES_SUPPORT
];
int32_t
numOfVnodes
;
int32_t
numOfTables
;
int32_t
numOfTables
;
int32_t
lbIp
;
int32_t
lbIp
;
int32_t
lbTime
;
int32_t
lbTime
;
int8_t
lbStatus
;
int8_t
lbStatus
;
int8_t
reserved
[
1
6
];
int8_t
reserved
[
1
4
];
int8_t
updateEnd
[
1
];
int8_t
updateEnd
[
1
];
struct
_vg_obj
*
prev
,
*
next
;
struct
_vg_obj
*
prev
,
*
next
;
void
*
idPool
;
void
*
idPool
;
...
@@ -169,8 +182,7 @@ typedef struct _db_obj {
...
@@ -169,8 +182,7 @@ typedef struct _db_obj {
int8_t
dirty
;
int8_t
dirty
;
int64_t
createdTime
;
int64_t
createdTime
;
SDbCfg
cfg
;
SDbCfg
cfg
;
int8_t
dropStatus
;
char
reserved
[
15
];
char
reserved
[
16
];
char
updateEnd
[
1
];
char
updateEnd
[
1
];
struct
_db_obj
*
prev
,
*
next
;
struct
_db_obj
*
prev
,
*
next
;
int32_t
numOfVgroups
;
int32_t
numOfVgroups
;
...
...
src/inc/taosdef.h
浏览文件 @
b87ac4ab
...
@@ -176,6 +176,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
...
@@ -176,6 +176,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_MAX_COLUMNS 256
#define TSDB_MAX_COLUMNS 256
#define TSDB_MIN_COLUMNS 2 //PRIMARY COLUMN(timestamp) + other columns
#define TSDB_MIN_COLUMNS 2 //PRIMARY COLUMN(timestamp) + other columns
#define TSDB_DNODE_NAME_LEN 63
#define TSDB_TABLE_NAME_LEN 192
#define TSDB_TABLE_NAME_LEN 192
#define TSDB_DB_NAME_LEN 32
#define TSDB_DB_NAME_LEN 32
#define TSDB_COL_NAME_LEN 64
#define TSDB_COL_NAME_LEN 64
...
...
src/inc/taosmsg.h
浏览文件 @
b87ac4ab
...
@@ -25,7 +25,6 @@ extern "C" {
...
@@ -25,7 +25,6 @@ extern "C" {
#include "taosdef.h"
#include "taosdef.h"
#include "taoserror.h"
#include "taoserror.h"
#include "taosdef.h"
#include "trpc.h"
#include "trpc.h"
// message type
// message type
...
@@ -523,21 +522,21 @@ typedef struct {
...
@@ -523,21 +522,21 @@ typedef struct {
}
SRetrieveTableRsp
;
}
SRetrieveTableRsp
;
typedef
struct
{
typedef
struct
{
uint32_t
vnode
;
int32_t
vgId
;
uint32_t
vgId
;
int32_t
vnode
;
uint8_t
status
;
uint8_t
dropStatus
;
uint8_t
accessState
;
int64_t
totalStorage
;
int64_t
totalStorage
;
int64_t
compStorage
;
int64_t
compStorage
;
int64_t
pointsWritten
;
int64_t
pointsWritten
;
uint8_t
status
;
uint8_t
syncStatus
;
uint8_t
syncStatus
;
uint8_t
reserved
[
15
];
uint8_t
accessState
;
uint8_t
reserved
[
5
];
}
SVnodeLoad
;
}
SVnodeLoad
;
typedef
struct
{
typedef
struct
{
uint32_t
vnode
;
uint32_t
vnode
;
char
accessState
;
uint8_t
accessState
;
uint8_t
reserved
[
3
];
}
SVnodeAccess
;
}
SVnodeAccess
;
/*
/*
...
@@ -585,14 +584,16 @@ typedef struct {
...
@@ -585,14 +584,16 @@ typedef struct {
}
SVnodeStatisticInfo
;
}
SVnodeStatisticInfo
;
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
uint32_t
moduleStatus
;
uint32_t
moduleStatus
;
uint32_t
createdTime
;
uint32_t
createdTime
;
uint32_t
numOfVnodes
;
uint32_t
numOfVnodes
;
uint32_t
reserved
;
}
SDnodeState
;
}
SDnodeState
;
typedef
struct
{
typedef
struct
{
uint32_t
version
;
uint32_t
version
;
int32_t
dnodeId
;
char
dnodeName
[
TSDB_DNODE_NAME_LEN
];
uint32_t
privateIp
;
uint32_t
privateIp
;
uint32_t
publicIp
;
uint32_t
publicIp
;
uint32_t
lastReboot
;
// time stamp for last reboot
uint32_t
lastReboot
;
// time stamp for last reboot
...
@@ -606,14 +607,12 @@ typedef struct {
...
@@ -606,14 +607,12 @@ typedef struct {
}
SDMStatusMsg
;
}
SDMStatusMsg
;
typedef
struct
{
typedef
struct
{
int32_t
code
;
SDnodeState
dnodeState
;
SRpcIpSet
ipList
;
SRpcIpSet
ipList
;
SDnodeState
dnodeState
;
SVnodeAccess
vnodeAccess
[];
SVnodeAccess
vnodeAccess
[];
}
SDMStatusRsp
;
}
SDMStatusRsp
;
typedef
struct
{
typedef
struct
{
int32_t
vnode
;
SVnodeCfg
cfg
;
SVnodeCfg
cfg
;
SVnodeDesc
vpeerDesc
[
TSDB_MAX_MPEERS
];
SVnodeDesc
vpeerDesc
[
TSDB_MAX_MPEERS
];
}
SMDCreateVnodeMsg
;
}
SMDCreateVnodeMsg
;
...
...
src/mnode/inc/mgmtBalance.h
浏览文件 @
b87ac4ab
...
@@ -23,6 +23,7 @@ extern "C" {
...
@@ -23,6 +23,7 @@ extern "C" {
int32_t
mgmtInitBalance
();
int32_t
mgmtInitBalance
();
void
mgmtCleanupBalance
();
void
mgmtCleanupBalance
();
void
mgmtStartBalanceTimer
(
int32_t
afterMs
)
;
int32_t
mgmtAllocVnodes
(
SVgObj
*
pVgroup
);
int32_t
mgmtAllocVnodes
(
SVgObj
*
pVgroup
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
src/mnode/inc/mgmtDServer.h
浏览文件 @
b87ac4ab
...
@@ -24,21 +24,6 @@ int32_t mgmtInitDServer();
...
@@ -24,21 +24,6 @@ int32_t mgmtInitDServer();
void
mgmtCleanupDServer
();
void
mgmtCleanupDServer
();
void
mgmtAddDServerMsgHandle
(
uint8_t
msgType
,
void
(
*
fp
)(
SRpcMsg
*
rpcMsg
));
void
mgmtAddDServerMsgHandle
(
uint8_t
msgType
,
void
(
*
fp
)(
SRpcMsg
*
rpcMsg
));
//extern void *mgmtStatusTimer;
//
//void mgmtSendCreateTableMsg(SMDCreateTableMsg *pCreate, SRpcIpSet *ipSet, void *ahandle);
//void mgmtSendDropTableMsg(SMDDropTableMsg *pRemove, SRpcIpSet *ipSet, void *ahandle);
//void mgmtSendAlterStreamMsg(STableInfo *pTable, SRpcIpSet *ipSet, void *ahandle);
//void mgmtSendDropVnodeMsg(int32_t vnode, SRpcIpSet *ipSet, void *ahandle);
//
//int32_t mgmtInitDnodeInt();
//void mgmtCleanUpDnodeInt();
//
//void mgmtSendMsgToDnode(SRpcIpSet *ipSet, 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);
//void mgmtProcessMsgFromDnode(char msgType, void *pCont, int32_t contLen, void *pConn, int32_t code);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
src/mnode/inc/mgmtDnode.h
浏览文件 @
b87ac4ab
...
@@ -25,7 +25,8 @@ int32_t mgmtInitDnodes();
...
@@ -25,7 +25,8 @@ int32_t mgmtInitDnodes();
void
mgmtCleanUpDnodes
();
void
mgmtCleanUpDnodes
();
int32_t
mgmtGetDnodesNum
();
int32_t
mgmtGetDnodesNum
();
int32_t
mgmtUpdateDnode
(
SDnodeObj
*
pDnode
);
int32_t
mgmtUpdateDnode
(
SDnodeObj
*
pDnode
);
SDnodeObj
*
mgmtGetDnode
(
uint32_t
ip
);
SDnodeObj
*
mgmtGetDnode
(
int32_t
dnodeId
);
SDnodeObj
*
mgmtGetDnodeByIp
(
uint32_t
ip
);
bool
mgmtCheckDnodeInRemoveState
(
SDnodeObj
*
pDnode
);
bool
mgmtCheckDnodeInRemoveState
(
SDnodeObj
*
pDnode
);
bool
mgmtCheckDnodeInOfflineState
(
SDnodeObj
*
pDnode
);
bool
mgmtCheckDnodeInOfflineState
(
SDnodeObj
*
pDnode
);
...
...
src/mnode/inc/mgmtMnode.h
浏览文件 @
b87ac4ab
...
@@ -22,6 +22,11 @@ extern "C" {
...
@@ -22,6 +22,11 @@ extern "C" {
bool
mgmtCheckRedirect
(
void
*
handle
);
bool
mgmtCheckRedirect
(
void
*
handle
);
void
mgmtGetMnodeIpList
(
SRpcIpSet
*
ipSet
);
int32_t
mgmtAddMnode
(
uint32_t
privateIp
,
uint32_t
publicIp
);
int32_t
mgmtRemoveMnode
(
uint32_t
privateIp
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
src/mnode/inc/mgmtVgroup.h
浏览文件 @
b87ac4ab
...
@@ -32,15 +32,15 @@ SVgObj *mgmtGetVgroupByVnode(uint32_t dnode, int32_t vnode);
...
@@ -32,15 +32,15 @@ SVgObj *mgmtGetVgroupByVnode(uint32_t dnode, int32_t vnode);
void
mgmtCreateVgroup
(
SQueuedMsg
*
pMsg
);
void
mgmtCreateVgroup
(
SQueuedMsg
*
pMsg
);
void
mgmtDropVgroup
(
SVgObj
*
pVgroup
,
void
*
ahandle
);
void
mgmtDropVgroup
(
SVgObj
*
pVgroup
,
void
*
ahandle
);
void
mgmtUpdateVgroup
(
SVgObj
*
pVgroup
);
void
mgmtUpdateVgroup
(
SVgObj
*
pVgroup
);
void
mgmtUpdateVgroupIp
(
SDnodeObj
*
pDnode
);
void
mgmtSetVgroupIdPool
();
void
mgmtSetVgroupIdPool
();
SVgObj
*
mgmtGetAvailableVgroup
(
SDbObj
*
pDb
);
SVgObj
*
mgmtGetAvailableVgroup
(
SDbObj
*
pDb
);
void
mgmtAddTableIntoVgroup
(
SVgObj
*
pVgroup
,
STableInfo
*
pTable
);
void
mgmtAddTableIntoVgroup
(
SVgObj
*
pVgroup
,
STableInfo
*
pTable
);
void
mgmtRemoveTableFromVgroup
(
SVgObj
*
pVgroup
,
STableInfo
*
pTable
);
void
mgmtRemoveTableFromVgroup
(
SVgObj
*
pVgroup
,
STableInfo
*
pTable
);
void
mgmtSendCreateVnodeMsg
(
SVgObj
*
pVgroup
,
SRpcIpSet
*
ipSet
,
void
*
ahandle
);
SMDCreateVnodeMsg
*
mgmtBuildCreateVnodeMsg
(
SVgObj
*
pVgroup
,
int32_t
vnode
);
void
mgmtSendDropVnodeMsg
(
int32_t
vgId
,
SRpcIpSet
*
ipSet
,
void
*
ahandle
);
void
mgmtSendCreateVnodeMsg
(
SVgObj
*
pVgroup
,
int32_t
vnode
,
SRpcIpSet
*
ipSet
,
void
*
ahandle
);
SRpcIpSet
mgmtGetIpSetFromVgroup
(
SVgObj
*
pVgroup
);
SRpcIpSet
mgmtGetIpSetFromVgroup
(
SVgObj
*
pVgroup
);
SRpcIpSet
mgmtGetIpSetFromIp
(
uint32_t
ip
);
SRpcIpSet
mgmtGetIpSetFromIp
(
uint32_t
ip
);
...
...
src/mnode/src/mgmtAcct.c
浏览文件 @
b87ac4ab
...
@@ -24,7 +24,7 @@ void (*mgmtCleanUpAcctsFp)() = NULL;
...
@@ -24,7 +24,7 @@ void (*mgmtCleanUpAcctsFp)() = NULL;
SAcctObj
*
(
*
mgmtGetAcctFp
)(
char
*
acctName
)
=
NULL
;
SAcctObj
*
(
*
mgmtGetAcctFp
)(
char
*
acctName
)
=
NULL
;
int32_t
(
*
mgmtCheckUserLimitFp
)(
SAcctObj
*
pAcct
)
=
NULL
;
int32_t
(
*
mgmtCheckUserLimitFp
)(
SAcctObj
*
pAcct
)
=
NULL
;
int32_t
(
*
mgmtCheckDbLimitFp
)(
SAcctObj
*
pAcct
)
=
NULL
;
int32_t
(
*
mgmtCheckDbLimitFp
)(
SAcctObj
*
pAcct
)
=
NULL
;
int32_t
(
*
mgmtCheckT
imeSeries
LimitFp
)(
SAcctObj
*
pAcct
,
int32_t
numOfTimeSeries
)
=
NULL
;
int32_t
(
*
mgmtCheckT
able
LimitFp
)(
SAcctObj
*
pAcct
,
int32_t
numOfTimeSeries
)
=
NULL
;
int32_t
mgmtAddDbIntoAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
int32_t
mgmtAddDbIntoAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pthread_mutex_lock
(
&
pAcct
->
mutex
);
...
@@ -137,8 +137,8 @@ int32_t mgmtCheckDbLimit(SAcctObj *pAcct) {
...
@@ -137,8 +137,8 @@ int32_t mgmtCheckDbLimit(SAcctObj *pAcct) {
}
}
int32_t
mgmtCheckTableLimit
(
SAcctObj
*
pAcct
,
int32_t
numOfTimeSeries
)
{
int32_t
mgmtCheckTableLimit
(
SAcctObj
*
pAcct
,
int32_t
numOfTimeSeries
)
{
if
(
mgmtCheckT
imeSeries
LimitFp
)
{
if
(
mgmtCheckT
able
LimitFp
)
{
return
(
*
mgmtCheckT
imeSeries
LimitFp
)(
pAcct
,
numOfTimeSeries
);
return
(
*
mgmtCheckT
able
LimitFp
)(
pAcct
,
numOfTimeSeries
);
}
else
{
}
else
{
return
0
;
return
0
;
}
}
...
...
src/mnode/src/mgmtBalance.c
浏览文件 @
b87ac4ab
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
int32_t
(
*
mgmtInitBalanceFp
)()
=
NULL
;
int32_t
(
*
mgmtInitBalanceFp
)()
=
NULL
;
void
(
*
mgmtCleanupBalanceFp
)()
=
NULL
;
void
(
*
mgmtCleanupBalanceFp
)()
=
NULL
;
void
(
*
mgmtStartBalanceTimerFp
)(
int32_t
afterMs
)
=
NULL
;
int32_t
(
*
mgmtAllocVnodesFp
)(
SVgObj
*
pVgroup
)
=
NULL
;
int32_t
(
*
mgmtAllocVnodesFp
)(
SVgObj
*
pVgroup
)
=
NULL
;
int32_t
mgmtInitBalance
()
{
int32_t
mgmtInitBalance
()
{
...
@@ -36,33 +37,28 @@ void mgmtCleanupBalance() {
...
@@ -36,33 +37,28 @@ void mgmtCleanupBalance() {
}
}
}
}
void
mgmtStartBalanceTimer
(
int32_t
afterMs
)
{
if
(
mgmtStartBalanceTimerFp
)
{
(
*
mgmtStartBalanceTimerFp
)(
afterMs
);
}
}
int32_t
mgmtAllocVnodes
(
SVgObj
*
pVgroup
)
{
int32_t
mgmtAllocVnodes
(
SVgObj
*
pVgroup
)
{
if
(
mgmtAllocVnodesFp
)
{
if
(
mgmtAllocVnodesFp
)
{
return
mgmtAllocVnodesFp
(
pVgroup
);
return
(
*
mgmtAllocVnodesFp
)
(
pVgroup
);
}
}
SDnodeObj
*
pDnode
=
mgmtGetDnode
(
0
);
SDnodeObj
*
pDnode
=
mgmtGetDnode
(
1
);
if
(
pDnode
==
NULL
)
return
TSDB_CODE_OTHERS
;
if
(
pDnode
==
NULL
)
return
TSDB_CODE_OTHERS
;
int32_t
selectedVnode
=
-
1
;
if
(
pDnode
->
openVnodes
<
pDnode
->
numOfTotalVnodes
)
{
int32_t
lastAllocVode
=
pDnode
->
lastAllocVnode
;
pVgroup
->
vnodeGid
[
0
].
dnodeId
=
pDnode
->
dnodeId
;
pVgroup
->
vnodeGid
[
0
].
privateIp
=
pDnode
->
privateIp
;
for
(
int32_t
i
=
0
;
i
<
pDnode
->
numOfVnodes
;
i
++
)
{
pVgroup
->
vnodeGid
[
0
].
publicIp
=
pDnode
->
publicIp
;
int32_t
vnode
=
(
i
+
lastAllocVode
)
%
pDnode
->
numOfVnodes
;
mTrace
(
"dnode:%d, alloc one vnode to vgroup"
,
pDnode
->
dnodeId
);
if
(
pDnode
->
vload
[
vnode
].
vgId
==
0
&&
pDnode
->
vload
[
vnode
].
status
==
TSDB_VN_STATUS_OFFLINE
)
{
return
TSDB_CODE_SUCCESS
;
selectedVnode
=
vnode
;
break
;
}
}
if
(
selectedVnode
==
-
1
)
{
mError
(
"alloc vnode failed, free vnodes:%d"
,
pDnode
->
numOfFreeVnodes
);
return
-
1
;
}
else
{
}
else
{
mTrace
(
"allocate vnode:%d, last allocated vnode:%d"
,
selectedVnode
,
lastAllocVode
);
mError
(
"dnode:%d, failed to alloc vnode to vgroup"
,
pDnode
->
dnodeId
);
pVgroup
->
vnodeGid
[
0
].
vnode
=
selectedVnode
;
return
TSDB_CODE_NO_ENOUGH_DNODES
;
pDnode
->
lastAllocVnode
=
selectedVnode
+
1
;
if
(
pDnode
->
lastAllocVnode
>=
pDnode
->
numOfVnodes
)
pDnode
->
lastAllocVnode
=
0
;
return
0
;
}
}
}
}
src/mnode/src/mgmtChildTable.c
浏览文件 @
b87ac4ab
...
@@ -76,26 +76,26 @@ void *mgmtChildTableActionInsert(void *row, char *str, int32_t size, int32_t *ss
...
@@ -76,26 +76,26 @@ void *mgmtChildTableActionInsert(void *row, char *str, int32_t size, int32_t *ss
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
if
(
pVgroup
==
NULL
)
{
if
(
pVgroup
==
NULL
)
{
mError
(
"
id:%s
not in vgroup:%d"
,
pTable
->
tableId
,
pTable
->
vgId
);
mError
(
"
ctable:%s,
not in vgroup:%d"
,
pTable
->
tableId
,
pTable
->
vgId
);
return
NULL
;
return
NULL
;
}
}
SDbObj
*
pDb
=
mgmtGetDb
(
pVgroup
->
dbName
);
SDbObj
*
pDb
=
mgmtGetDb
(
pVgroup
->
dbName
);
if
(
pDb
==
NULL
)
{
if
(
pDb
==
NULL
)
{
mError
(
"
vgroup:%d not in DB:%s"
,
pVgroup
->
vgId
,
pVgroup
->
dbName
);
mError
(
"
ctable:%s, vgroup:%d not in db:%s"
,
pTable
->
tableId
,
pVgroup
->
vgId
,
pVgroup
->
dbName
);
return
NULL
;
return
NULL
;
}
}
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
if
(
pAcct
==
NULL
)
{
if
(
pAcct
==
NULL
)
{
mError
(
"
account not exists"
);
mError
(
"
ctable:%s, account:%s not exists"
,
pTable
->
tableId
,
pDb
->
cfg
.
acct
);
return
NULL
;
return
NULL
;
}
}
if
(
!
sdbMaster
)
{
if
(
!
sdbMaster
)
{
int32_t
sid
=
taosAllocateId
(
pVgroup
->
idPool
);
int32_t
sid
=
taosAllocateId
(
pVgroup
->
idPool
);
if
(
sid
!=
pTable
->
sid
)
{
if
(
sid
!=
pTable
->
sid
)
{
mError
(
"
sid:%d is not matched from the master:%d"
,
sid
,
pTable
->
sid
);
mError
(
"
ctable:%s, sid:%d is not matched from the master:%d"
,
pTable
->
tableId
,
sid
,
pTable
->
sid
);
return
NULL
;
return
NULL
;
}
}
}
}
...
@@ -127,13 +127,13 @@ void *mgmtChildTableActionDelete(void *row, char *str, int32_t size, int32_t *ss
...
@@ -127,13 +127,13 @@ void *mgmtChildTableActionDelete(void *row, char *str, int32_t size, int32_t *ss
SDbObj
*
pDb
=
mgmtGetDb
(
pVgroup
->
dbName
);
SDbObj
*
pDb
=
mgmtGetDb
(
pVgroup
->
dbName
);
if
(
pDb
==
NULL
)
{
if
(
pDb
==
NULL
)
{
mError
(
"
vgroup:%d not in DB:%s"
,
pVgroup
->
vgId
,
pVgroup
->
dbName
);
mError
(
"
ctable:%s, vgroup:%d not in DB:%s"
,
pTable
->
tableId
,
pVgroup
->
vgId
,
pVgroup
->
dbName
);
return
NULL
;
return
NULL
;
}
}
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
if
(
pAcct
==
NULL
)
{
if
(
pAcct
==
NULL
)
{
mError
(
"
account not exists"
);
mError
(
"
ctable:%s, account:%s not exists"
,
pTable
->
tableId
,
pDb
->
cfg
.
acct
);
return
NULL
;
return
NULL
;
}
}
...
@@ -312,7 +312,7 @@ void *mgmtBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableObj *pTab
...
@@ -312,7 +312,7 @@ void *mgmtBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableObj *pTab
void
*
mgmtCreateChildTable
(
SCMCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
tid
)
{
void
*
mgmtCreateChildTable
(
SCMCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
tid
)
{
int32_t
numOfTables
=
sdbGetNumOfRows
(
tsChildTableSdb
);
int32_t
numOfTables
=
sdbGetNumOfRows
(
tsChildTableSdb
);
if
(
numOfTables
>=
tsMaxTables
)
{
if
(
numOfTables
>=
tsMaxTables
)
{
mError
(
"table:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
tableId
,
numOfTables
,
tsMaxTables
);
mError
(
"
c
table:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
tableId
,
numOfTables
,
tsMaxTables
);
terrno
=
TSDB_CODE_TOO_MANY_TABLES
;
terrno
=
TSDB_CODE_TOO_MANY_TABLES
;
return
NULL
;
return
NULL
;
}
}
...
@@ -320,14 +320,14 @@ void* mgmtCreateChildTable(SCMCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t
...
@@ -320,14 +320,14 @@ void* mgmtCreateChildTable(SCMCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t
char
*
pTagData
=
(
char
*
)
pCreate
->
schema
;
// it is a tag key
char
*
pTagData
=
(
char
*
)
pCreate
->
schema
;
// it is a tag key
SSuperTableObj
*
pSuperTable
=
mgmtGetSuperTable
(
pTagData
);
SSuperTableObj
*
pSuperTable
=
mgmtGetSuperTable
(
pTagData
);
if
(
pSuperTable
==
NULL
)
{
if
(
pSuperTable
==
NULL
)
{
mError
(
"table:%s, corresponding super table does not exist"
,
pCreate
->
tableId
);
mError
(
"
c
table:%s, corresponding super table does not exist"
,
pCreate
->
tableId
);
terrno
=
TSDB_CODE_INVALID_TABLE
;
terrno
=
TSDB_CODE_INVALID_TABLE
;
return
NULL
;
return
NULL
;
}
}
SChildTableObj
*
pTable
=
(
SChildTableObj
*
)
calloc
(
sizeof
(
SChildTableObj
),
1
);
SChildTableObj
*
pTable
=
(
SChildTableObj
*
)
calloc
(
sizeof
(
SChildTableObj
),
1
);
if
(
pTable
==
NULL
)
{
if
(
pTable
==
NULL
)
{
mError
(
"table:%s, failed to alloc memory"
,
pCreate
->
tableId
);
mError
(
"
c
table:%s, failed to alloc memory"
,
pCreate
->
tableId
);
terrno
=
TSDB_CODE_SERV_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_SERV_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
...
@@ -344,25 +344,25 @@ void* mgmtCreateChildTable(SCMCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t
...
@@ -344,25 +344,25 @@ void* mgmtCreateChildTable(SCMCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t
if
(
sdbInsertRow
(
tsChildTableSdb
,
pTable
,
0
)
<
0
)
{
if
(
sdbInsertRow
(
tsChildTableSdb
,
pTable
,
0
)
<
0
)
{
free
(
pTable
);
free
(
pTable
);
mError
(
"table:%s, update sdb error"
,
pCreate
->
tableId
);
mError
(
"
c
table:%s, update sdb error"
,
pCreate
->
tableId
);
terrno
=
TSDB_CODE_SDB_ERROR
;
terrno
=
TSDB_CODE_SDB_ERROR
;
return
NULL
;
return
NULL
;
}
}
mTrace
(
"table:%s, create ctable in vgroup, uid:%"
PRIu64
,
pTable
->
tableId
,
pTable
->
uid
);
mTrace
(
"
c
table:%s, create ctable in vgroup, uid:%"
PRIu64
,
pTable
->
tableId
,
pTable
->
uid
);
return
pTable
;
return
pTable
;
}
}
int32_t
mgmtDropChildTable
(
SQueuedMsg
*
newMsg
,
SChildTableObj
*
pTable
)
{
int32_t
mgmtDropChildTable
(
SQueuedMsg
*
newMsg
,
SChildTableObj
*
pTable
)
{
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
if
(
pVgroup
==
NULL
)
{
if
(
pVgroup
==
NULL
)
{
mError
(
"table:%s, failed to drop child table, vgroup not exist"
,
pTable
->
tableId
);
mError
(
"
c
table:%s, failed to drop child table, vgroup not exist"
,
pTable
->
tableId
);
return
TSDB_CODE_OTHERS
;
return
TSDB_CODE_OTHERS
;
}
}
SMDDropTableMsg
*
pDrop
=
rpcMallocCont
(
sizeof
(
SMDDropTableMsg
));
SMDDropTableMsg
*
pDrop
=
rpcMallocCont
(
sizeof
(
SMDDropTableMsg
));
if
(
pDrop
==
NULL
)
{
if
(
pDrop
==
NULL
)
{
mError
(
"table:%s, failed to drop child table, no enough memory"
,
pTable
->
tableId
);
mError
(
"
c
table:%s, failed to drop child table, no enough memory"
,
pTable
->
tableId
);
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
}
}
...
@@ -374,7 +374,7 @@ int32_t mgmtDropChildTable(SQueuedMsg *newMsg, SChildTableObj *pTable) {
...
@@ -374,7 +374,7 @@ int32_t mgmtDropChildTable(SQueuedMsg *newMsg, SChildTableObj *pTable) {
SRpcIpSet
ipSet
=
mgmtGetIpSetFromVgroup
(
pVgroup
);
SRpcIpSet
ipSet
=
mgmtGetIpSetFromVgroup
(
pVgroup
);
mTrace
(
"table:%s, send drop table msg"
,
pDrop
->
tableId
);
mTrace
(
"
c
table:%s, send drop table msg"
,
pDrop
->
tableId
);
SRpcMsg
rpcMsg
=
{
SRpcMsg
rpcMsg
=
{
.
handle
=
newMsg
,
.
handle
=
newMsg
,
.
pCont
=
pDrop
,
.
pCont
=
pDrop
,
...
@@ -394,6 +394,7 @@ void* mgmtGetChildTable(char *tableId) {
...
@@ -394,6 +394,7 @@ void* mgmtGetChildTable(char *tableId) {
}
}
int32_t
mgmtModifyChildTableTagValueByName
(
SChildTableObj
*
pTable
,
char
*
tagName
,
char
*
nContent
)
{
int32_t
mgmtModifyChildTableTagValueByName
(
SChildTableObj
*
pTable
,
char
*
tagName
,
char
*
nContent
)
{
// TODO: send message to dnode
// int32_t col = mgmtFindSuperTableTagIndex(pTable->superTable, tagName);
// int32_t col = mgmtFindSuperTableTagIndex(pTable->superTable, tagName);
// if (col < 0 || col > pTable->superTable->numOfTags) {
// if (col < 0 || col > pTable->superTable->numOfTags) {
// return TSDB_CODE_APP_ERROR;
// return TSDB_CODE_APP_ERROR;
...
@@ -461,7 +462,7 @@ int32_t mgmtGetChildTableMeta(SDbObj *pDb, SChildTableObj *pTable, STableMetaMsg
...
@@ -461,7 +462,7 @@ int32_t mgmtGetChildTableMeta(SDbObj *pDb, SChildTableObj *pTable, STableMetaMsg
if
(
usePublicIp
)
{
if
(
usePublicIp
)
{
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
publicIp
;
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
publicIp
;
}
else
{
}
else
{
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
i
p
;
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
privateI
p
;
}
}
pMeta
->
vpeerDesc
[
i
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
i
].
vnode
);
pMeta
->
vpeerDesc
[
i
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
i
].
vnode
);
}
}
...
...
src/mnode/src/mgmtDClient.c
浏览文件 @
b87ac4ab
...
@@ -83,90 +83,3 @@ static void mgmtProcessRspFromDnode(SRpcMsg *rpcMsg) {
...
@@ -83,90 +83,3 @@ static void mgmtProcessRspFromDnode(SRpcMsg *rpcMsg) {
rpcFreeCont
(
rpcMsg
->
pCont
);
rpcFreeCont
(
rpcMsg
->
pCont
);
}
}
//static void mgmtProcessDropTableRsp(SRpcMsg *rpcMsg) {
// mTrace("drop table rsp received, handle:%p code:%d", rpcMsg->handle, rpcMsg->code);
//}
//
//static void mgmtProcessAlterTableRsp(SRpcMsg *rpcMsg) {
// mTrace("alter table rsp received, handle:%p code:%d", rpcMsg->handle, rpcMsg->code);
//}
//
//
//static void mgmtProcessDropVnodeRsp(SRpcMsg *rpcMsg) {
// mTrace("drop vnode rsp received, handle:%p code:%d", rpcMsg->handle, rpcMsg->code);
//}
//
//static void mgmtProcessAlterVnodeRsp(SRpcMsg *rpcMsg) {
// mTrace("alter vnode rsp received, handle:%p code:%d", rpcMsg->handle, rpcMsg->code);
//}
//
//static void mgmtProcessDropStableRsp(SRpcMsg *rpcMsg) {
// mTrace("drop stable rsp received, handle:%p code:%d", rpcMsg->handle, rpcMsg->code);
//}
//
//static void mgmtProcessAlterStreamRsp(SRpcMsg *rpcMsg) {
// mTrace("alter stream rsp received, handle:%p code:%d", rpcMsg->handle, rpcMsg->code);
//}
//
//static void mgmtProcessConfigDnodeRsp(SRpcMsg *rpcMsg) {
// mTrace("config dnode rsp received, handle:%p code:%d", rpcMsg->handle, rpcMsg->code);
//}
//
//
//void mgmtSendAlterStreamMsg(STableInfo *pTable, SRpcIpSet *ipSet, void *ahandle) {
// mTrace("table:%s, send alter stream msg, ahandle:%p", pTable->tableId, pTable->sid, ahandle);
//}
//
//void mgmtSendDropVnodeMsg(int32_t vgId, int32_t vnode, SRpcIpSet *ipSet, void *ahandle) {
// mTrace("vnode:%d send free vnode msg, ahandle:%p", vnode, ahandle);
// SMDDropVnodeMsg *pDrop = rpcMallocCont(sizeof(SMDDropVnodeMsg));
// SRpcMsg rpcMsg = {
// .handle = ahandle,
// .pCont = pDrop,
// .contLen = pDrop ? sizeof(SMDDropVnodeMsg) : 0,
// .code = 0,
// .msgType = TSDB_MSG_TYPE_MD_DROP_VNODE
// };
// rpcSendRequest(tsMgmtDClientRpc, ipSet, &rpcMsg);
//}
//
////
////int32_t mgmtCfgDynamicOptions(SDnodeObj *pDnode, char *msg) {
//// char *option, *value;
//// int32_t olen, valen;
////
//// paGetToken(msg, &option, &olen);
//// if (strncasecmp(option, "unremove", 8) == 0) {
//// mgmtSetDnodeUnRemove(pDnode);
//// return TSDB_CODE_SUCCESS;
//// } else if (strncasecmp(option, "score", 5) == 0) {
//// paGetToken(option + olen + 1, &value, &valen);
//// if (valen > 0) {
//// int32_t score = atoi(value);
//// mTrace("dnode:%s, custom score set from:%d to:%d", taosIpStr(pDnode->privateIp), pDnode->customScore, score);
//// pDnode->customScore = score;
//// mgmtUpdateDnode(pDnode);
//// //mgmtStartBalanceTimer(15);
//// }
//// return TSDB_CODE_INVALID_SQL;
//// } else if (strncasecmp(option, "bandwidth", 9) == 0) {
//// paGetToken(msg, &value, &valen);
//// if (valen > 0) {
//// int32_t bandwidthMb = atoi(value);
//// if (bandwidthMb >= 0 && bandwidthMb < 10000000) {
//// mTrace("dnode:%s, bandwidth(Mb) set from:%d to:%d", taosIpStr(pDnode->privateIp), pDnode->bandwidthMb, bandwidthMb);
//// pDnode->bandwidthMb = bandwidthMb;
//// mgmtUpdateDnode(pDnode);
//// return TSDB_CODE_SUCCESS;
//// }
//// }
//// return TSDB_CODE_INVALID_SQL;
//// }
////
//// return -1;
////}
////
src/mnode/src/mgmtDServer.c
浏览文件 @
b87ac4ab
...
@@ -85,276 +85,3 @@ static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg) {
...
@@ -85,276 +85,3 @@ static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg) {
static
int
mgmtDServerRetrieveAuth
(
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
)
{
static
int
mgmtDServerRetrieveAuth
(
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
//
//
//static void mgmtProcessTableCfgMsg(int8_t msgType, int8_t *pCont, int32_t contLen, void *thandle) {
// SDMConfigTableMsg *pCfg = (SDMConfigTableMsg *) 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(thandle, msgType + 1, TSDB_CODE_REDIRECT, NULL, 0);
// return;
// }
//
// STableInfo *pTable = mgmtGetTableByPos(pCfg->dnode, pCfg->vnode, pCfg->sid);
// if (pTable == NULL) {
// mError("dnode:%s, vnode:%d, sid:%d, table not found", taosIpStr(pCfg->dnode), pCfg->vnode, pCfg->sid);
// mgmtSendRspToDnode(thandle, msgType + 1, TSDB_CODE_INVALID_TABLE, NULL, 0);
// return;
// }
//
// mgmtSendRspToDnode(thandle, msgType + 1, TSDB_CODE_SUCCESS, NULL, 0);
//
// //TODO
// SRpcIpSet ipSet = mgmtGetIpSetFromIp(pCfg->dnode);
// mgmtSendCreateTableMsg(NULL, &ipSet, NULL);
//}
//
//static void mgmtProcessVnodeCfgMsg(int8_t msgType, int8_t *pCont, int32_t contLen, void *pConn) {
// if (!sdbMaster) {
// mgmtSendRspToDnode(pConn, msgType + 1, TSDB_CODE_REDIRECT, NULL, 0);
// return;
// }
//
// SDMConfigVnodeMsg *pCfg = (SDMConfigVnodeMsg *) pCont;
// pCfg->dnode = htonl(pCfg->dnode);
// pCfg->vnode = htonl(pCfg->vnode);
//
// SVgObj *pVgroup = mgmtGetVgroupByVnode(pCfg->dnode, pCfg->vnode);
// if (pVgroup == NULL) {
// mTrace("dnode:%s, vnode:%d, no vgroup info", taosIpStr(pCfg->dnode), pCfg->vnode);
// mgmtSendRspToDnode(pConn, msgType + 1, TSDB_CODE_NOT_ACTIVE_VNODE, NULL, 0);
// return;
// }
//
// mgmtSendRspToDnode(pConn, msgType + 1, TSDB_CODE_SUCCESS, NULL, 0);
//
// SRpcIpSet ipSet = mgmtGetIpSetFromIp(pCfg->dnode);
// mgmtSendCreateVnodeMsg(pVgroup, pCfg->vnode, &ipSet, NULL);
//}
//
//static void mgmtProcessCreateTableRsp(int8_t msgType, int8_t *pCont, int32_t contLen, void *thandle, int32_t code) {
// mTrace("create table rsp received, thandle:%p code:%d", thandle, code);
// if (thandle == NULL) return;
//
// SProcessInfo *info = thandle;
// assert(info->type == TSDB_PROCESS_CREATE_TABLE || info->type == TSDB_PROCESS_CREATE_TABLE_GET_META);
// STableInfo *pTable = info->ahandle;
//
// if (code != TSDB_CODE_SUCCESS) {
// mError("table:%s, failed to create in dnode, code:%d, set it dirty", pTable->tableId);
// mgmtSetTableDirty(pTable, true);
// } else {
// mTrace("table:%s, created in dnode", pTable->tableId);
// mgmtSetTableDirty(pTable, false);
// }
//
// if (code != TSDB_CODE_SUCCESS) {
// SRpcMsg rpcMsg = {0};
// rpcMsg.code = code;
// rpcMsg.handle = info->thandle;
// rpcSendResponse(&rpcMsg);
// } else {
// if (info->type == TSDB_PROCESS_CREATE_TABLE_GET_META) {
// mTrace("table:%s, start to process get meta", pTable->tableId);
// mgmtProcessGetTableMeta(pTable, thandle);
// } else {
// SRpcMsg rpcMsg = {0};
// rpcMsg.code = code;
// rpcMsg.handle = info->thandle;
// rpcSendResponse(&rpcMsg);
// }
// }
//
// free(info);
//}
//
//static void mgmtProcessRemoveTableRsp(int8_t msgType, int8_t *pCont, int32_t contLen, void *thandle, int32_t code) {
// mTrace("remove table rsp received, thandle:%p code:%d", thandle, code);
//}
//
//
//static void mgmtProcessDropVnodeRsp(int8_t msgType, int8_t *pCont, int32_t contLen, void *thandle, int32_t code) {
// mTrace("free vnode rsp received, thandle:%p code:%d", thandle, code);
//}
//
//static void mgmtProcessDropStableRsp(int8_t msgType, int8_t *pCont, int32_t contLen, void *thandle, int32_t code) {
// mTrace("drop stable rsp received, thandle:%p code:%d", thandle, code);
//}
//
//static void mgmtProcessCreateVnodeRsp(int8_t msgType, int8_t *pCont, int32_t contLen, void *thandle, int32_t code) {
// mTrace("create vnode rsp received, thandle:%p code:%d", thandle, code);
// if (thandle == NULL) return;
//
// SProcessInfo *info = thandle;
// assert(info->type == TSDB_PROCESS_CREATE_VGROUP || info->type == TSDB_PROCESS_CREATE_VGROUP_GET_META);
// info->received++;
// SVgObj *pVgroup = info->ahandle;
//
// bool isGetMeta = false;
// if (info->type == TSDB_PROCESS_CREATE_VGROUP_GET_META) {
// isGetMeta = true;
// }
//
// mTrace("vgroup:%d, received:%d numOfVnodes:%d", pVgroup->vgId, info->received, pVgroup->numOfVnodes);
// if (info->received == pVgroup->numOfVnodes) {
// mgmtProcessCreateTable(pVgroup, info->cont, info->contLen, info->thandle, isGetMeta);
// free(info);
// }
//}
//
//void mgmtProcessMsgFromDnode(char msgType, void *pCont, int32_t contLen, void *pConn, int32_t code) {
// if (msgType < 0 || msgType >= TSDB_MSG_TYPE_MAX) {
// mError("invalid msg type:%d", msgType);
// return;
// }
//
// mTrace("msg:%d:%s is received from dnode, pConn:%p", msgType, taosMsg[(int8_t)msgType], pConn);
//
// if (msgType == TSDB_MSG_TYPE_DM_CONFIG_TABLE) {
// mgmtProcessTableCfgMsg(msgType, pCont, contLen, pConn);
// } else if (msgType == TSDB_MSG_TYPE_DM_CONFIG_VNODE) {
// mgmtProcessVnodeCfgMsg(msgType, pCont, contLen, pConn);
// } else if (msgType == TSDB_MSG_TYPE_MD_CREATE_TABLE_RSP) {
// mgmtProcessCreateTableRsp(msgType, pCont, contLen, pConn, code);
// } else if (msgType == TSDB_MSG_TYPE_MD_DROP_TABLE_RSP) {
// mgmtProcessRemoveTableRsp(msgType, pCont, contLen, pConn, code);
// } else if (msgType == TSDB_MSG_TYPE_MD_CREATE_VNODE_RSP) {
// mgmtProcessCreateVnodeRsp(msgType, pCont, contLen, pConn, code);
// } else if (msgType == TSDB_MSG_TYPE_MD_DROP_VNODE_RSP) {
// mgmtProcessDropVnodeRsp(msgType, pCont, contLen, pConn, code);
// } else if (msgType == TSDB_MSG_TYPE_MD_DROP_STABLE) {
// mgmtProcessDropStableRsp(msgType, pCont, contLen, pConn, code);
// } else if (msgType == TSDB_MSG_TYPE_MD_CONFIG_DNODE_RSP) {
// } else if (msgType == TSDB_MSG_TYPE_CM_ALTER_STREAM_RSP) {
// } else if (msgType == TSDB_MSG_TYPE_DM_STATUS) {
// mgmtProcessDnodeStatus(msgType, pCont, contLen, pConn, code);
// } else {
// mError("%s from dnode is not processed", taosMsg[(int8_t)msgType]);
// }
//
// //rpcFreeCont(pCont);
//}
//
//void mgmtSendAlterStreamMsg(STableInfo *pTable, SRpcIpSet *ipSet, void *ahandle) {
// mTrace("table:%s, sid:%d send alter stream msg, ahandle:%p", pTable->tableId, pTable->sid, ahandle);
//}
//
//void mgmtSendDropVnodeMsg(int32_t vnode, SRpcIpSet *ipSet, void *ahandle) {
// mTrace("vnode:%d send free vnode msg, ahandle:%p", vnode, ahandle);
//
// SMDDropVnodeMsg *pFreeVnode = rpcMallocCont(sizeof(SMDDropVnodeMsg));
// if (pFreeVnode != NULL) {
// pFreeVnode->vnode = htonl(vnode);
// mgmtSendMsgToDnode(ipSet, TSDB_MSG_TYPE_MD_DROP_VNODE, pFreeVnode, sizeof(SMDDropVnodeMsg), ahandle);
// }
//}
//
//int32_t mgmtCfgDynamicOptions(SDnodeObj *pDnode, char *msg) {
// char *option, *value;
// int32_t olen, valen;
//
// paGetToken(msg, &option, &olen);
// if (strncasecmp(option, "unremove", 8) == 0) {
// mgmtSetDnodeUnRemove(pDnode);
// return TSDB_CODE_SUCCESS;
// } else if (strncasecmp(option, "score", 5) == 0) {
// paGetToken(option + olen + 1, &value, &valen);
// if (valen > 0) {
// int32_t score = atoi(value);
// mTrace("dnode:%s, custom score set from:%d to:%d", taosIpStr(pDnode->privateIp), pDnode->customScore, score);
// pDnode->customScore = score;
// mgmtUpdateDnode(pDnode);
// //mgmtStartBalanceTimer(15);
// }
// return TSDB_CODE_INVALID_SQL;
// } else if (strncasecmp(option, "bandwidth", 9) == 0) {
// paGetToken(msg, &value, &valen);
// if (valen > 0) {
// int32_t bandwidthMb = atoi(value);
// if (bandwidthMb >= 0 && bandwidthMb < 10000000) {
// mTrace("dnode:%s, bandwidth(Mb) set from:%d to:%d", taosIpStr(pDnode->privateIp), pDnode->bandwidthMb, bandwidthMb);
// pDnode->bandwidthMb = bandwidthMb;
// mgmtUpdateDnode(pDnode);
// return TSDB_CODE_SUCCESS;
// }
// }
// return TSDB_CODE_INVALID_SQL;
// }
//
// return -1;
//}
//
//
//void mgmtCleanUpDnodeInt() {
// if (mgmtCleanUpDnodeIntFp) {
// mgmtCleanUpDnodeIntFp();
// }
//}
//
//void mgmtProcessDnodeStatus(int8_t msgType, void *pCont, int32_t contLen, void *pConn, int32_t code) {
// SDMStatusMsg *pStatus = (SDMStatusMsg *)pCont;
//
// SDnodeObj *pObj = mgmtGetDnode(htonl(pStatus->privateIp));
// if (pObj == NULL) {
// mError("dnode:%s not exist", taosIpStr(pObj->privateIp));
// mgmtSendRspToDnode(pConn, msgType + 1, TSDB_CODE_DNODE_NOT_EXIST, NULL, 0);
// return;
// }
//
// pObj->lastReboot = htonl(pStatus->lastReboot);
// pObj->numOfTotalVnodes = htons(pStatus->numOfTotalVnodes);
// pObj->openVnodes = htons(pStatus->openVnodes);
// pObj->numOfCores = htons(pStatus->numOfCores);
// pObj->diskAvailable = pStatus->diskAvailable;
// pObj->alternativeRole = pStatus->alternativeRole;
////
//// if (mgmtProcessDnodeStatusFp) {
//// mgmtProcessDnodeStatusFp(pStatus, pObj, pConn);
//// return;
//// }
//
// pObj->status = TSDB_DN_STATUS_READY;
//
//// // wait vnode dropped
//// for (int32_t vnode = 0; vnode < pObj->numOfVnodes; ++vnode) {
//// SVnodeLoad *pVload = &(pObj->vload[vnode]);
//// if (pVload->dropStatus == TSDB_VN_DROP_STATUS_DROPPING) {
//// bool existInDnode = false;
//// for (int32_t j = 0; j < pObj->openVnodes; ++j) {
//// if (htonl(pStatus->load[j].vnode) == vnode) {
//// existInDnode = true;
//// break;
//// }
//// }
////
//// if (!existInDnode) {
//// pVload->dropStatus = TSDB_VN_DROP_STATUS_READY;
//// pVload->status = TSDB_VN_STATUS_OFFLINE;
//// mgmtUpdateDnode(pObj);
//// mPrint("dnode:%s, vid:%d, drop finished", taosIpStr(pObj->privateIp), vnode);
//// taosTmrStart(mgmtMonitorDbDrop, 10000, NULL, tsMgmtTmr);
//// }
//// } else if (pVload->vgId == 0) {
//// /*
//// * In some cases, vnode information may be reported abnormally, recover it
//// */
//// if (pVload->dropStatus != TSDB_VN_DROP_STATUS_READY || pVload->status != TSDB_VN_STATUS_OFFLINE) {
//// mPrint("dnode:%s, vid:%d, vgroup:%d status:%s dropStatus:%s, set it to avail status",
//// taosIpStr(pObj->privateIp), vnode, pVload->vgId, taosGetVnodeStatusStr(pVload->status),
//// taosGetVnodeDropStatusStr(pVload->dropStatus));
//// pVload->dropStatus = TSDB_VN_DROP_STATUS_READY;
//// pVload->status = TSDB_VN_STATUS_OFFLINE;
//// mgmtUpdateDnode(pObj);
//// }
//// }
//// }
//}
src/mnode/src/mgmtDb.c
浏览文件 @
b87ac4ab
...
@@ -681,7 +681,7 @@ static int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *
...
@@ -681,7 +681,7 @@ static int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *
cols
++
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
pDb
->
d
ropStatus
!=
TSDB_DB_STATUS_READY
?
"dropping"
:
"ready"
);
strcpy
(
pWrite
,
pDb
->
d
irty
!=
TSDB_DB_STATUS_READY
?
"dropping"
:
"ready"
);
cols
++
;
cols
++
;
numOfRows
++
;
numOfRows
++
;
...
...
src/mnode/src/mgmtDnode.c
浏览文件 @
b87ac4ab
...
@@ -22,12 +22,14 @@
...
@@ -22,12 +22,14 @@
#include "mgmtDClient.h"
#include "mgmtDClient.h"
#include "mgmtMnode.h"
#include "mgmtMnode.h"
#include "mgmtShell.h"
#include "mgmtShell.h"
#include "mgmtDServer.h"
#include "mgmtUser.h"
#include "mgmtUser.h"
#include "mgmtVgroup.h"
#include "mgmtVgroup.h"
int32_t
(
*
mgmtInitDnodesFp
)()
=
NULL
;
int32_t
(
*
mgmtInitDnodesFp
)()
=
NULL
;
void
(
*
mgmtCleanUpDnodesFp
)()
=
NULL
;
void
(
*
mgmtCleanUpDnodesFp
)()
=
NULL
;
SDnodeObj
*
(
*
mgmtGetDnodeFp
)(
uint32_t
ip
)
=
NULL
;
SDnodeObj
*
(
*
mgmtGetDnodeFp
)(
uint32_t
ip
)
=
NULL
;
SDnodeObj
*
(
*
mgmtGetDnodeByIpFp
)(
int32_t
dnodeId
)
=
NULL
;
int32_t
(
*
mgmtGetDnodesNumFp
)()
=
NULL
;
int32_t
(
*
mgmtGetDnodesNumFp
)()
=
NULL
;
int32_t
(
*
mgmtUpdateDnodeFp
)(
SDnodeObj
*
pDnode
)
=
NULL
;
int32_t
(
*
mgmtUpdateDnodeFp
)(
SDnodeObj
*
pDnode
)
=
NULL
;
void
*
(
*
mgmtGetNextDnodeFp
)(
SShowObj
*
pShow
,
SDnodeObj
**
pDnode
)
=
NULL
;
void
*
(
*
mgmtGetNextDnodeFp
)(
SShowObj
*
pShow
,
SDnodeObj
**
pDnode
)
=
NULL
;
...
@@ -43,80 +45,29 @@ static int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, vo
...
@@ -43,80 +45,29 @@ static int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, vo
static
int32_t
mgmtGetVnodeMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtGetVnodeMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveVnodes
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mgmtRetrieveVnodes
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
void
mgmtProcessCfgDnodeMsg
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessCfgDnodeMsg
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessCfgDnodeMsgRsp
(
SRpcMsg
*
rpcMsg
)
;
static
void
mgmtProcessDnodeStatusMsg
(
SRpcMsg
*
rpcMsg
);
void
mgmtSetDnodeMaxVnodes
(
SDnodeObj
*
pDnode
)
{
void
mgmtSetDnodeMaxVnodes
(
SDnodeObj
*
pDnode
)
{
int32_t
maxVnodes
=
pDnode
->
numOfCores
*
tsNumOfVnodesPerCore
;
int32_t
maxVnodes
=
pDnode
->
numOfCores
*
tsNumOfVnodesPerCore
;
maxVnodes
=
maxVnodes
>
TSDB_MAX_VNODES
?
TSDB_MAX_VNODES
:
maxVnodes
;
maxVnodes
=
maxVnodes
>
TSDB_MAX_VNODES
?
TSDB_MAX_VNODES
:
maxVnodes
;
maxVnodes
=
maxVnodes
<
TSDB_MIN_VNODES
?
TSDB_MIN_VNODES
:
maxVnodes
;
maxVnodes
=
maxVnodes
<
TSDB_MIN_VNODES
?
TSDB_MIN_VNODES
:
maxVnodes
;
if
(
pDnode
->
numOfTotalVnodes
!=
0
)
{
maxVnodes
=
pDnode
->
numOfTotalVnodes
;
if
(
pDnode
->
numOfTotalVnodes
==
0
)
{
pDnode
->
numOfTotalVnodes
=
maxVnodes
;
}
}
if
(
pDnode
->
alternativeRole
==
TSDB_DNODE_ROLE_MGMT
)
{
if
(
pDnode
->
alternativeRole
==
TSDB_DNODE_ROLE_MGMT
)
{
max
Vnodes
=
0
;
pDnode
->
numOfTotal
Vnodes
=
0
;
}
}
pDnode
->
numOfVnodes
=
maxVnodes
;
pDnode
->
numOfFreeVnodes
=
maxVnodes
;
pDnode
->
openVnodes
=
0
;
pDnode
->
openVnodes
=
0
;
pDnode
->
status
=
TSDB_DN_STATUS_OFFLINE
;
pDnode
->
status
=
TSDB_DN_STATUS_OFFLINE
;
}
void
mgmtCalcNumOfFreeVnodes
(
SDnodeObj
*
pDnode
)
{
int32_t
totalVnodes
=
0
;
mTrace
(
"dnode:%s, begin calc free vnodes"
,
taosIpStr
(
pDnode
->
privateIp
));
for
(
int32_t
i
=
0
;
i
<
pDnode
->
numOfVnodes
;
++
i
)
{
SVnodeLoad
*
pVload
=
pDnode
->
vload
+
i
;
if
(
pVload
->
vgId
!=
0
)
{
mTrace
(
"%d-dnode:%s, calc free vnodes, exist vnode:%d, vgroup:%d, state:%d %s, dropstate:%d %s, syncstatus:%d %s"
,
totalVnodes
,
taosIpStr
(
pDnode
->
privateIp
),
i
,
pVload
->
vgId
,
pVload
->
status
,
taosGetVnodeStatusStr
(
pVload
->
status
),
pVload
->
dropStatus
,
taosGetVnodeDropStatusStr
(
pVload
->
dropStatus
),
pVload
->
syncStatus
,
taosGetVnodeSyncStatusStr
(
pVload
->
syncStatus
));
totalVnodes
++
;
}
}
pDnode
->
numOfFreeVnodes
=
pDnode
->
numOfVnodes
-
totalVnodes
;
mTrace
(
"dnode:%s, numOfVnodes:%d, numOfFreeVnodes:%d, totalVnodes:%d"
,
taosIpStr
(
pDnode
->
privateIp
),
pDnode
->
numOfVnodes
,
pDnode
->
numOfFreeVnodes
,
totalVnodes
);
}
void
mgmtSetDnodeVgid
(
SVnodeGid
vnodeGid
[],
int32_t
numOfVnodes
,
int32_t
vgId
)
{
mgmtUpdateDnode
(
pDnode
);
SDnodeObj
*
pDnode
;
for
(
int32_t
i
=
0
;
i
<
numOfVnodes
;
++
i
)
{
pDnode
=
mgmtGetDnode
(
vnodeGid
[
i
].
ip
);
if
(
pDnode
)
{
SVnodeLoad
*
pVload
=
pDnode
->
vload
+
vnodeGid
[
i
].
vnode
;
memset
(
pVload
,
0
,
sizeof
(
SVnodeLoad
));
pVload
->
vnode
=
vnodeGid
[
i
].
vnode
;
pVload
->
vgId
=
vgId
;
mTrace
(
"dnode:%s, vnode:%d add to vgroup:%d"
,
taosIpStr
(
pDnode
->
privateIp
),
vnodeGid
[
i
].
vnode
,
pVload
->
vgId
);
mgmtCalcNumOfFreeVnodes
(
pDnode
);
}
else
{
mError
(
"dnode:%s, not in dnode DB!!!"
,
taosIpStr
(
vnodeGid
[
i
].
ip
));
}
}
}
void
mgmtUnSetDnodeVgid
(
SVnodeGid
vnodeGid
[],
int32_t
numOfVnodes
)
{
SDnodeObj
*
pDnode
;
for
(
int32_t
i
=
0
;
i
<
numOfVnodes
;
++
i
)
{
pDnode
=
mgmtGetDnode
(
vnodeGid
[
i
].
ip
);
if
(
pDnode
)
{
SVnodeLoad
*
pVload
=
pDnode
->
vload
+
vnodeGid
[
i
].
vnode
;
mTrace
(
"dnode:%s, vnode:%d remove from vgroup:%d"
,
taosIpStr
(
vnodeGid
[
i
].
ip
),
vnodeGid
[
i
].
vnode
,
pVload
->
vgId
);
memset
(
pVload
,
0
,
sizeof
(
SVnodeLoad
));
mgmtCalcNumOfFreeVnodes
(
pDnode
);
}
else
{
mError
(
"dnode:%s not in dnode DB!!!"
,
taosIpStr
(
vnodeGid
[
i
].
ip
));
}
}
}
}
bool
mgmtCheckModuleInDnode
(
SDnodeObj
*
pDnode
,
int32_t
moduleType
)
{
bool
mgmtCheckModuleInDnode
(
SDnodeObj
*
pDnode
,
int32_t
moduleType
)
{
uint32_t
status
=
pDnode
->
moduleStatus
&
(
1
<<
moduleType
);
uint32_t
status
=
pDnode
->
moduleStatus
&
(
1
<<
moduleType
);
return
status
>
0
;
return
status
>
0
;
...
@@ -317,12 +268,6 @@ static int32_t mgmtGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pCo
...
@@ -317,12 +268,6 @@ static int32_t mgmtGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pCo
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
cols
++
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"vgid"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
12
;
pShow
->
bytes
[
cols
]
=
12
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"status"
);
strcpy
(
pSchema
[
cols
].
name
,
"status"
);
...
@@ -341,11 +286,10 @@ static int32_t mgmtGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pCo
...
@@ -341,11 +286,10 @@ static int32_t mgmtGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pCo
pShow
->
offset
[
0
]
=
0
;
pShow
->
offset
[
0
]
=
0
;
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
// TODO: if other thread drop dnode ????
SDnodeObj
*
pDnode
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
if
(
pShow
->
payloadLen
>
0
)
{
if
(
pShow
->
payloadLen
>
0
)
{
uint32_t
ip
=
ip2uint
(
pShow
->
payload
);
uint32_t
ip
=
ip2uint
(
pShow
->
payload
);
pDnode
=
mgmtGetDnode
(
ip
);
pDnode
=
mgmtGetDnode
ByIp
(
ip
);
if
(
NULL
==
pDnode
)
{
if
(
NULL
==
pDnode
)
{
return
TSDB_CODE_NODE_OFFLINE
;
return
TSDB_CODE_NODE_OFFLINE
;
}
}
...
@@ -398,10 +342,6 @@ static int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, voi
...
@@ -398,10 +342,6 @@ static int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, voi
cols
=
0
;
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
uint32_t
*
)
pWrite
=
pVnode
->
vnode
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
uint32_t
*
)
pWrite
=
pVnode
->
vgId
;
*
(
uint32_t
*
)
pWrite
=
pVnode
->
vgId
;
cols
++
;
cols
++
;
...
@@ -434,19 +374,22 @@ int32_t mgmtInitDnodes() {
...
@@ -434,19 +374,22 @@ int32_t mgmtInitDnodes() {
mgmtAddShellShowMetaHandle
(
TSDB_MGMT_TABLE_VNODES
,
mgmtGetVnodeMeta
);
mgmtAddShellShowMetaHandle
(
TSDB_MGMT_TABLE_VNODES
,
mgmtGetVnodeMeta
);
mgmtAddShellShowRetrieveHandle
(
TSDB_MGMT_TABLE_VNODES
,
mgmtRetrieveVnodes
);
mgmtAddShellShowRetrieveHandle
(
TSDB_MGMT_TABLE_VNODES
,
mgmtRetrieveVnodes
);
mgmtAddShellMsgHandle
(
TSDB_MSG_TYPE_CM_CONFIG_DNODE
,
mgmtProcessCfgDnodeMsg
);
mgmtAddShellMsgHandle
(
TSDB_MSG_TYPE_CM_CONFIG_DNODE
,
mgmtProcessCfgDnodeMsg
);
mgmtAddDClientRspHandle
(
TSDB_MSG_TYPE_MD_CONFIG_DNODE_RSP
,
mgmtProcessCfgDnodeMsgRsp
);
mgmtAddDServerMsgHandle
(
TSDB_MSG_TYPE_DM_STATUS
,
mgmtProcessDnodeStatusMsg
);
if
(
mgmtInitDnodesFp
)
{
if
(
mgmtInitDnodesFp
)
{
return
mgmtInitDnodesFp
();
return
mgmtInitDnodesFp
();
}
else
{
}
else
{
tsDnodeObj
.
privateIp
=
inet_addr
(
tsPrivateIp
);;
tsDnodeObj
.
dnodeId
=
1
;
tsDnodeObj
.
privateIp
=
inet_addr
(
tsPrivateIp
);
tsDnodeObj
.
publicIp
=
inet_addr
(
tsPublicIp
);
tsDnodeObj
.
createdTime
=
taosGetTimestampMs
();
tsDnodeObj
.
createdTime
=
taosGetTimestampMs
();
tsDnodeObj
.
lastReboot
=
taosGetTimestampSec
()
;
tsDnodeObj
.
numOfTotalVnodes
=
tsNumOfTotalVnodes
;
tsDnodeObj
.
numOfCores
=
(
uint16_t
)
tsNumOfCores
;
tsDnodeObj
.
numOfCores
=
(
uint16_t
)
tsNumOfCores
;
tsDnodeObj
.
status
=
TSDB_DN_STATUS_READY
;
tsDnodeObj
.
alternativeRole
=
TSDB_DNODE_ROLE_ANY
;
tsDnodeObj
.
alternativeRole
=
TSDB_DNODE_ROLE_ANY
;
tsDnodeObj
.
numOfTotalVnodes
=
tsNumOfTotalVnodes
;
tsDnodeObj
.
status
=
TSDB_DN_STATUS_OFFLINE
;
tsDnodeObj
.
thandle
=
(
void
*
)
(
1
);
//hack way
tsDnodeObj
.
lastReboot
=
taosGetTimestampSec
();
tsDnodeObj
.
status
=
TSDB_DN_STATUS_READY
;
sprintf
(
tsDnodeObj
.
dnodeName
,
"%d"
,
tsDnodeObj
.
dnodeId
)
;
mgmtSetDnodeMaxVnodes
(
&
tsDnodeObj
);
mgmtSetDnodeMaxVnodes
(
&
tsDnodeObj
);
tsDnodeObj
.
moduleStatus
|=
(
1
<<
TSDB_MOD_MGMT
);
tsDnodeObj
.
moduleStatus
|=
(
1
<<
TSDB_MOD_MGMT
);
...
@@ -462,21 +405,30 @@ int32_t mgmtInitDnodes() {
...
@@ -462,21 +405,30 @@ int32_t mgmtInitDnodes() {
void
mgmtCleanUpDnodes
()
{
void
mgmtCleanUpDnodes
()
{
if
(
mgmtCleanUpDnodesFp
)
{
if
(
mgmtCleanUpDnodesFp
)
{
mgmtCleanUpDnodesFp
();
(
*
mgmtCleanUpDnodesFp
)
();
}
}
}
}
SDnodeObj
*
mgmtGetDnode
(
uint32_t
ip
)
{
SDnodeObj
*
mgmtGetDnode
(
int32_t
dnodeId
)
{
if
(
mgmtGetDnodeFp
)
{
if
(
mgmtGetDnodeFp
)
{
return
mgmtGetDnodeFp
(
ip
);
return
(
*
mgmtGetDnodeFp
)(
dnodeId
);
}
else
{
}
if
(
dnodeId
==
1
)
{
return
&
tsDnodeObj
;
return
&
tsDnodeObj
;
}
}
return
NULL
;
}
SDnodeObj
*
mgmtGetDnodeByIp
(
uint32_t
ip
)
{
if
(
mgmtGetDnodeByIpFp
)
{
return
(
*
mgmtGetDnodeByIpFp
)(
ip
);
}
return
&
tsDnodeObj
;
}
}
int32_t
mgmtGetDnodesNum
()
{
int32_t
mgmtGetDnodesNum
()
{
if
(
mgmtGetDnodesNumFp
)
{
if
(
mgmtGetDnodesNumFp
)
{
return
mgmtGetDnodesNumFp
();
return
(
*
mgmtGetDnodesNumFp
)
();
}
else
{
}
else
{
return
1
;
return
1
;
}
}
...
@@ -484,7 +436,7 @@ int32_t mgmtGetDnodesNum() {
...
@@ -484,7 +436,7 @@ int32_t mgmtGetDnodesNum() {
int32_t
mgmtUpdateDnode
(
SDnodeObj
*
pDnode
)
{
int32_t
mgmtUpdateDnode
(
SDnodeObj
*
pDnode
)
{
if
(
mgmtUpdateDnodeFp
)
{
if
(
mgmtUpdateDnodeFp
)
{
return
mgmtUpdateDnodeFp
(
pDnode
);
return
(
*
mgmtUpdateDnodeFp
)
(
pDnode
);
}
else
{
}
else
{
return
0
;
return
0
;
}
}
...
@@ -492,7 +444,7 @@ int32_t mgmtUpdateDnode(SDnodeObj *pDnode) {
...
@@ -492,7 +444,7 @@ int32_t mgmtUpdateDnode(SDnodeObj *pDnode) {
void
*
mgmtGetNextDnode
(
SShowObj
*
pShow
,
SDnodeObj
**
pDnode
)
{
void
*
mgmtGetNextDnode
(
SShowObj
*
pShow
,
SDnodeObj
**
pDnode
)
{
if
(
mgmtGetNextDnodeFp
)
{
if
(
mgmtGetNextDnodeFp
)
{
return
mgmtGetNextDnodeFp
(
pShow
,
pDnode
);
return
(
*
mgmtGetNextDnodeFp
)
(
pShow
,
pDnode
);
}
else
{
}
else
{
if
(
*
pDnode
==
NULL
)
{
if
(
*
pDnode
==
NULL
)
{
*
pDnode
=
&
tsDnodeObj
;
*
pDnode
=
&
tsDnodeObj
;
...
@@ -506,14 +458,12 @@ void *mgmtGetNextDnode(SShowObj *pShow, SDnodeObj **pDnode) {
...
@@ -506,14 +458,12 @@ void *mgmtGetNextDnode(SShowObj *pShow, SDnodeObj **pDnode) {
void
mgmtSetDnodeUnRemove
(
SDnodeObj
*
pDnode
)
{
void
mgmtSetDnodeUnRemove
(
SDnodeObj
*
pDnode
)
{
if
(
mgmtSetDnodeUnRemoveFp
)
{
if
(
mgmtSetDnodeUnRemoveFp
)
{
mgmtSetDnodeUnRemoveFp
(
pDnode
);
(
*
mgmtSetDnodeUnRemoveFp
)
(
pDnode
);
}
}
}
}
bool
mgmtCheckConfigShow
(
SGlobalConfig
*
cfg
)
{
bool
mgmtCheckConfigShow
(
SGlobalConfig
*
cfg
)
{
if
(
cfg
->
cfgType
&
TSDB_CFG_CTYPE_B_CLUSTER
)
if
(
!
(
cfg
->
cfgType
&
TSDB_CFG_CTYPE_B_SHOW
))
return
false
;
if
(
cfg
->
cfgType
&
TSDB_CFG_CTYPE_B_NOT_PRINT
)
return
false
;
return
false
;
return
true
;
return
true
;
}
}
...
@@ -531,6 +481,11 @@ void mgmtProcessCfgDnodeMsg(SQueuedMsg *pMsg) {
...
@@ -531,6 +481,11 @@ void mgmtProcessCfgDnodeMsg(SQueuedMsg *pMsg) {
if
(
mgmtCheckRedirect
(
pMsg
->
thandle
))
return
;
if
(
mgmtCheckRedirect
(
pMsg
->
thandle
))
return
;
SCMCfgDnodeMsg
*
pCmCfgDnode
=
pMsg
->
pCont
;
SCMCfgDnodeMsg
*
pCmCfgDnode
=
pMsg
->
pCont
;
if
(
pCmCfgDnode
->
ip
[
0
]
==
0
)
{
strcpy
(
pCmCfgDnode
->
ip
,
tsPrivateIp
);
}
else
{
strcpy
(
pCmCfgDnode
->
ip
,
pCmCfgDnode
->
ip
);
}
uint32_t
dnodeIp
=
inet_addr
(
pCmCfgDnode
->
ip
);
uint32_t
dnodeIp
=
inet_addr
(
pCmCfgDnode
->
ip
);
if
(
strcmp
(
pMsg
->
pUser
->
pAcct
->
user
,
"root"
)
!=
0
)
{
if
(
strcmp
(
pMsg
->
pUser
->
pAcct
->
user
,
"root"
)
!=
0
)
{
...
@@ -557,3 +512,107 @@ void mgmtProcessCfgDnodeMsg(SQueuedMsg *pMsg) {
...
@@ -557,3 +512,107 @@ void mgmtProcessCfgDnodeMsg(SQueuedMsg *pMsg) {
rpcSendResponse
(
&
rpcRsp
);
rpcSendResponse
(
&
rpcRsp
);
}
}
static
void
mgmtProcessCfgDnodeMsgRsp
(
SRpcMsg
*
rpcMsg
)
{
mTrace
(
"cfg vnode rsp is received"
);
}
void
mgmtProcessDnodeStatusMsg
(
SRpcMsg
*
rpcMsg
)
{
if
(
mgmtCheckRedirect
(
rpcMsg
->
handle
))
return
;
SDMStatusMsg
*
pStatus
=
rpcMsg
->
pCont
;
pStatus
->
dnodeId
=
htonl
(
pStatus
->
dnodeId
);
SDnodeObj
*
pDnode
=
NULL
;
if
(
pStatus
->
dnodeId
==
0
)
{
pDnode
=
mgmtGetDnodeByIp
(
htonl
(
pStatus
->
privateIp
));
if
(
pDnode
==
NULL
)
{
mTrace
(
"dnode not created, privateIp:%s"
,
taosIpStr
(
htonl
(
pStatus
->
privateIp
)));
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_DNODE_NOT_EXIST
);
return
;
}
}
else
{
pDnode
=
mgmtGetDnode
(
pStatus
->
dnodeId
);
if
(
pDnode
==
NULL
)
{
mError
(
"dnode:%d, not exist, privateIp:%s"
,
taosIpStr
(
pStatus
->
dnodeId
),
pStatus
->
dnodeName
);
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_DNODE_NOT_EXIST
);
return
;
}
}
uint32_t
version
=
htonl
(
pStatus
->
version
);
if
(
version
!=
tsVersion
)
{
mError
(
"dnode:%d, status msg version:%d not equal with mnode:%d"
,
pDnode
->
dnodeId
,
version
,
tsVersion
);
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_INVALID_MSG_VERSION
);
return
;
}
uint32_t
lastPrivateIp
=
pDnode
->
privateIp
;
uint32_t
lastPublicIp
=
pDnode
->
publicIp
;
pDnode
->
privateIp
=
htonl
(
pStatus
->
privateIp
);
pDnode
->
publicIp
=
htonl
(
pStatus
->
publicIp
);
pDnode
->
lastReboot
=
htonl
(
pStatus
->
lastReboot
);
pDnode
->
numOfTotalVnodes
=
htons
(
pStatus
->
numOfTotalVnodes
);
pDnode
->
numOfCores
=
htons
(
pStatus
->
numOfCores
);
pDnode
->
diskAvailable
=
pStatus
->
diskAvailable
;
pDnode
->
alternativeRole
=
pStatus
->
alternativeRole
;
if
(
pStatus
->
dnodeId
==
0
)
{
mTrace
(
"dnode:%d, first access, privateIp:%s, name:%s, "
,
pDnode
->
dnodeId
,
taosIpStr
(
pDnode
->
privateIp
),
pDnode
->
dnodeName
);
mgmtSetDnodeMaxVnodes
(
pDnode
);
}
if
(
lastPrivateIp
!=
pDnode
->
privateIp
||
lastPublicIp
!=
pDnode
->
publicIp
)
{
mgmtUpdateVgroupIp
(
pDnode
);
//mgmtUpdateMnodeIp();
}
int32_t
openVnodes
=
htons
(
pStatus
->
openVnodes
);
for
(
int32_t
j
=
0
;
j
<
openVnodes
;
++
j
)
{
pDnode
->
vload
[
j
].
vgId
=
htonl
(
pStatus
->
load
[
j
].
vgId
);
pDnode
->
vload
[
j
].
totalStorage
=
htobe64
(
pStatus
->
load
[
j
].
totalStorage
);
pDnode
->
vload
[
j
].
compStorage
=
htobe64
(
pStatus
->
load
[
j
].
compStorage
);
pDnode
->
vload
[
j
].
pointsWritten
=
htobe64
(
pStatus
->
load
[
j
].
pointsWritten
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pDnode
->
vload
[
j
].
vgId
);
if
(
pVgroup
==
NULL
)
{
SRpcIpSet
ipSet
=
mgmtGetIpSetFromIp
(
pDnode
->
privateIp
);
mPrint
(
"dnode:%d, vnode:%d not exist in mnode, drop it"
,
pDnode
->
dnodeId
,
pDnode
->
vload
[
j
].
vgId
);
mgmtSendDropVnodeMsg
(
pDnode
->
vload
[
j
].
vgId
,
&
ipSet
,
NULL
);
}
}
if
(
pDnode
->
status
!=
TSDB_DN_STATUS_READY
)
{
mTrace
(
"dnode:%d, from offline to online"
,
pDnode
->
dnodeId
);
pDnode
->
status
=
TSDB_DN_STATUS_READY
;
mgmtStartBalanceTimer
(
200
);
}
int32_t
contLen
=
sizeof
(
SDMStatusRsp
)
+
TSDB_MAX_VNODES
*
sizeof
(
SVnodeAccess
);
SDMStatusRsp
*
pRsp
=
rpcMallocCont
(
contLen
);
if
(
pRsp
==
NULL
)
{
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_SERV_OUT_OF_MEMORY
);
return
;
}
mgmtGetMnodeIpList
(
&
pRsp
->
ipList
);
pRsp
->
dnodeState
.
dnodeId
=
htonl
(
pDnode
->
dnodeId
);
pRsp
->
dnodeState
.
moduleStatus
=
htonl
(
pDnode
->
moduleStatus
);
pRsp
->
dnodeState
.
createdTime
=
htonl
(
pDnode
->
createdTime
/
1000
);
pRsp
->
dnodeState
.
numOfVnodes
=
0
;
contLen
=
sizeof
(
SDMStatusRsp
);
//TODO: set vnode access
SRpcMsg
rpcRsp
=
{
.
handle
=
rpcMsg
->
handle
,
.
code
=
TSDB_CODE_SUCCESS
,
.
pCont
=
pRsp
,
.
contLen
=
contLen
};
rpcSendResponse
(
&
rpcRsp
);
}
src/mnode/src/mgmtMnode.c
浏览文件 @
b87ac4ab
...
@@ -15,8 +15,162 @@
...
@@ -15,8 +15,162 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "trpc.h"
#include "tschemautil.h"
#include "mgmtMnode.h"
#include "mgmtMnode.h"
#include "mgmtUser.h"
int32_t
(
*
mgmtAddMnodeFp
)(
uint32_t
privateIp
,
uint32_t
publicIp
)
=
NULL
;
int32_t
(
*
mgmtRemoveMnodeFp
)(
uint32_t
privateIp
)
=
NULL
;
int32_t
(
*
mgmtGetMnodesNumFp
)()
=
NULL
;
void
*
(
*
mgmtGetNextMnodeFp
)(
SShowObj
*
pShow
,
SMnodeObj
**
pMnode
)
=
NULL
;
static
SMnodeObj
tsMnodeObj
=
{
0
};
static
int32_t
mgmtGetMnodeMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveMnodes
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
bool
mgmtCheckRedirect
(
void
*
handle
)
{
bool
mgmtCheckRedirect
(
void
*
handle
)
{
return
false
;
return
false
;
}
}
int32_t
mgmtAddMnode
(
uint32_t
privateIp
,
uint32_t
publicIp
)
{
if
(
mgmtAddMnodeFp
)
{
return
(
*
mgmtAddMnodeFp
)(
privateIp
,
publicIp
);
}
else
{
return
0
;
}
}
int32_t
mgmtRemoveMnode
(
uint32_t
privateIp
)
{
if
(
mgmtRemoveMnodeFp
)
{
return
(
*
mgmtRemoveMnodeFp
)(
privateIp
);
}
else
{
return
0
;
}
}
static
int32_t
mgmtGetMnodesNum
()
{
if
(
mgmtGetMnodesNumFp
)
{
return
(
*
mgmtGetMnodesNumFp
)();
}
else
{
return
1
;
}
}
static
void
*
mgmtGetNextMnode
(
SShowObj
*
pShow
,
SMnodeObj
**
pMnode
)
{
if
(
mgmtGetNextMnodeFp
)
{
return
(
*
mgmtGetNextMnodeFp
)(
pShow
,
pMnode
);
}
else
{
if
(
*
pMnode
==
NULL
)
{
*
pMnode
=
&
tsMnodeObj
;
}
else
{
*
pMnode
=
NULL
;
}
}
return
*
pMnode
;
}
static
int32_t
mgmtGetMnodeMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
if
(
pUser
==
NULL
)
return
0
;
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
pShow
->
bytes
[
cols
]
=
16
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"private ip"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"create time"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
10
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"status"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
10
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"role"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
16
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"public ip"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pMeta
->
numOfColumns
=
htons
(
cols
);
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
{
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
pShow
->
numOfRows
=
mgmtGetMnodesNum
();
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
pNode
=
NULL
;
return
0
;
}
static
int32_t
mgmtRetrieveMnodes
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
int32_t
numOfRows
=
0
;
int32_t
cols
=
0
;
SMnodeObj
*
pMnode
=
NULL
;
char
*
pWrite
;
char
ipstr
[
32
];
while
(
numOfRows
<
rows
)
{
pShow
->
pNode
=
mgmtGetNextMnode
(
pShow
,
(
SMnodeObj
**
)
&
pMnode
);
if
(
pMnode
==
NULL
)
break
;
cols
=
0
;
tinet_ntoa
(
ipstr
,
pMnode
->
privateIp
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
ipstr
);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int64_t
*
)
pWrite
=
pMnode
->
createdTime
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
sdbStatusStr
[(
uint8_t
)
pMnode
->
status
]);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
sdbRoleStr
[(
uint8_t
)
pMnode
->
role
]);
cols
++
;
tinet_ntoa
(
ipstr
,
pMnode
->
publicIp
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
ipstr
);
cols
++
;
numOfRows
++
;
}
pShow
->
numOfReads
+=
numOfRows
;
return
numOfRows
;
}
void
mgmtGetMnodeIpList
(
SRpcIpSet
*
ipSet
)
{
ipSet
->
inUse
=
0
;
ipSet
->
port
=
htons
(
tsMnodeDnodePort
);
ipSet
->
numOfIps
=
1
;
ipSet
->
ip
[
0
]
=
htonl
(
inet_addr
(
tsMasterIp
));
}
\ No newline at end of file
src/mnode/src/mgmtNormalTable.c
浏览文件 @
b87ac4ab
...
@@ -542,7 +542,7 @@ int32_t mgmtGetNormalTableMeta(SDbObj *pDb, SNormalTableObj *pTable, STableMetaM
...
@@ -542,7 +542,7 @@ int32_t mgmtGetNormalTableMeta(SDbObj *pDb, SNormalTableObj *pTable, STableMetaM
if
(
usePublicIp
)
{
if
(
usePublicIp
)
{
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
publicIp
;
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
publicIp
;
}
else
{
}
else
{
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
i
p
;
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
privateI
p
;
}
}
pMeta
->
vpeerDesc
[
i
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
i
].
vnode
);
pMeta
->
vpeerDesc
[
i
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
i
].
vnode
);
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
b87ac4ab
...
@@ -392,7 +392,7 @@ static void mgmtProcessConnectMsg(SQueuedMsg *pMsg) {
...
@@ -392,7 +392,7 @@ static void mgmtProcessConnectMsg(SQueuedMsg *pMsg) {
}
}
if
(
pConnectMsg
->
db
[
0
])
{
if
(
pConnectMsg
->
db
[
0
])
{
char
dbName
[
TSDB_TABLE_ID_LEN
]
=
{
0
};
char
dbName
[
TSDB_TABLE_ID_LEN
*
3
]
=
{
0
};
sprintf
(
dbName
,
"%x%s%s"
,
pAcct
->
acctId
,
TS_PATH_DELIMITER
,
pConnectMsg
->
db
);
sprintf
(
dbName
,
"%x%s%s"
,
pAcct
->
acctId
,
TS_PATH_DELIMITER
,
pConnectMsg
->
db
);
SDbObj
*
pDb
=
mgmtGetDb
(
dbName
);
SDbObj
*
pDb
=
mgmtGetDb
(
dbName
);
if
(
pDb
==
NULL
)
{
if
(
pDb
==
NULL
)
{
...
...
src/mnode/src/mgmtSuperTable.c
浏览文件 @
b87ac4ab
...
@@ -61,8 +61,6 @@ static void mgmtSuperTableActionInit() {
...
@@ -61,8 +61,6 @@ static void mgmtSuperTableActionInit() {
mgmtSuperTableActionFp
[
SDB_TYPE_DECODE
]
=
mgmtSuperTableActionDecode
;
mgmtSuperTableActionFp
[
SDB_TYPE_DECODE
]
=
mgmtSuperTableActionDecode
;
mgmtSuperTableActionFp
[
SDB_TYPE_RESET
]
=
mgmtSuperTableActionReset
;
mgmtSuperTableActionFp
[
SDB_TYPE_RESET
]
=
mgmtSuperTableActionReset
;
mgmtSuperTableActionFp
[
SDB_TYPE_DESTROY
]
=
mgmtSuperTableActionDestroy
;
mgmtSuperTableActionFp
[
SDB_TYPE_DESTROY
]
=
mgmtSuperTableActionDestroy
;
mgmtAddShellShowMetaHandle
(
TSDB_MGMT_TABLE_METRIC
,
mgmtGetShowSuperTableMeta
);
mgmtAddShellShowRetrieveHandle
(
TSDB_MGMT_TABLE_METRIC
,
mgmtRetrieveShowSuperTables
);
}
}
void
*
mgmtSuperTableActionReset
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
void
*
mgmtSuperTableActionReset
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
b87ac4ab
...
@@ -55,6 +55,9 @@ static void mgmtProcessSuperTableMetaMsg(SQueuedMsg *queueMsg);
...
@@ -55,6 +55,9 @@ static void mgmtProcessSuperTableMetaMsg(SQueuedMsg *queueMsg);
static
void
mgmtProcessCreateTableRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mgmtProcessCreateTableRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mgmtProcessDropTableRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mgmtProcessDropTableRsp
(
SRpcMsg
*
rpcMsg
);
static
int32_t
mgmtGetShowTableMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtGetShowTableMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
void
mgmtProcessAlterTableRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mgmtProcessDropStableRsp
(
SRpcMsg
*
rpcMsg
);
static
int32_t
mgmtGetShowTableMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveShowTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mgmtRetrieveShowTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
void
mgmtProcessGetTableMeta
(
STableInfo
*
pTable
,
void
*
thandle
);
static
void
mgmtProcessGetTableMeta
(
STableInfo
*
pTable
,
void
*
thandle
);
...
@@ -86,8 +89,8 @@ int32_t mgmtInitTables() {
...
@@ -86,8 +89,8 @@ int32_t mgmtInitTables() {
mgmtAddShellShowRetrieveHandle
(
TSDB_MGMT_TABLE_TABLE
,
mgmtRetrieveShowTables
);
mgmtAddShellShowRetrieveHandle
(
TSDB_MGMT_TABLE_TABLE
,
mgmtRetrieveShowTables
);
mgmtAddDClientRspHandle
(
TSDB_MSG_TYPE_MD_CREATE_TABLE_RSP
,
mgmtProcessCreateTableRsp
);
mgmtAddDClientRspHandle
(
TSDB_MSG_TYPE_MD_CREATE_TABLE_RSP
,
mgmtProcessCreateTableRsp
);
mgmtAddDClientRspHandle
(
TSDB_MSG_TYPE_MD_DROP_TABLE_RSP
,
mgmtProcessDropTableRsp
);
mgmtAddDClientRspHandle
(
TSDB_MSG_TYPE_MD_DROP_TABLE_RSP
,
mgmtProcessDropTableRsp
);
mgmtAddDClientRspHandle
(
TSDB_MSG_TYPE_MD_ALTER_TABLE_RSP
,
NULL
);
mgmtAddDClientRspHandle
(
TSDB_MSG_TYPE_MD_ALTER_TABLE_RSP
,
mgmtProcessAlterTableRsp
);
mgmtAddDClientRspHandle
(
TSDB_MSG_TYPE_MD_DROP_STABLE_RSP
,
NULL
);
mgmtAddDClientRspHandle
(
TSDB_MSG_TYPE_MD_DROP_STABLE_RSP
,
mgmtProcessDropStableRsp
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -111,17 +114,15 @@ STableInfo* mgmtGetTable(char *tableId) {
...
@@ -111,17 +114,15 @@ STableInfo* mgmtGetTable(char *tableId) {
return
NULL
;
return
NULL
;
}
}
STableInfo
*
mgmtGetTableByPos
(
uint32_t
dnodeIp
,
int32_t
vnode
,
int32_t
sid
)
{
STableInfo
*
mgmtGetTableByPos
(
uint32_t
dnodeId
,
int32_t
vnode
,
int32_t
sid
)
{
SDnodeObj
*
pObj
=
mgmtGetDnode
(
dnodeIp
);
SDnodeObj
*
pObj
=
mgmtGetDnode
(
dnodeId
);
if
(
pObj
!=
NULL
&&
vnode
>=
0
&&
vnode
<
pObj
->
numOfVnodes
)
{
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
vnode
);
int32_t
vgId
=
pObj
->
vload
[
vnode
].
vgId
;
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
vgId
);
if
(
pVgroup
)
{
return
pVgroup
->
tableList
[
sid
];
}
}
if
(
pObj
==
NULL
||
pVgroup
==
NULL
)
{
return
NULL
;
return
NULL
;
}
return
pVgroup
->
tableList
[
sid
];
}
}
int32_t
mgmtGetTableMeta
(
SDbObj
*
pDb
,
STableInfo
*
pTable
,
STableMetaMsg
*
pMeta
,
bool
usePublicIp
)
{
int32_t
mgmtGetTableMeta
(
SDbObj
*
pDb
,
STableInfo
*
pTable
,
STableMetaMsg
*
pMeta
,
bool
usePublicIp
)
{
...
@@ -589,7 +590,7 @@ void mgmtProcessAlterTableMsg(SQueuedMsg *pMsg) {
...
@@ -589,7 +590,7 @@ void mgmtProcessAlterTableMsg(SQueuedMsg *pMsg) {
void
mgmtProcessGetTableMeta
(
STableInfo
*
pTable
,
void
*
thandle
)
{
void
mgmtProcessGetTableMeta
(
STableInfo
*
pTable
,
void
*
thandle
)
{
SRpcMsg
rpcRsp
=
{.
handle
=
thandle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
SRpcMsg
rpcRsp
=
{.
handle
=
thandle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pTable
->
tableId
);
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pTable
->
tableId
);
if
(
pDb
==
NULL
||
pDb
->
d
ropStatus
!=
TSDB_DB_STATUS_READY
)
{
if
(
pDb
==
NULL
||
pDb
->
d
irty
)
{
mError
(
"table:%s, failed to get table meta, db not selected"
,
pTable
->
tableId
);
mError
(
"table:%s, failed to get table meta, db not selected"
,
pTable
->
tableId
);
rpcRsp
.
code
=
TSDB_CODE_DB_NOT_SELECTED
;
rpcRsp
.
code
=
TSDB_CODE_DB_NOT_SELECTED
;
rpcSendResponse
(
&
rpcRsp
);
rpcSendResponse
(
&
rpcRsp
);
...
@@ -786,6 +787,10 @@ static void mgmtProcessCreateTableRsp(SRpcMsg *rpcMsg) {
...
@@ -786,6 +787,10 @@ static void mgmtProcessCreateTableRsp(SRpcMsg *rpcMsg) {
free
(
queueMsg
);
free
(
queueMsg
);
}
}
static
void
mgmtProcessAlterTableRsp
(
SRpcMsg
*
rpcMsg
)
{
mTrace
(
"alter table rsp received, handle:%p code:%d"
,
rpcMsg
->
handle
,
rpcMsg
->
code
);
}
static
void
mgmtProcessDropTableRsp
(
SRpcMsg
*
rpcMsg
)
{
static
void
mgmtProcessDropTableRsp
(
SRpcMsg
*
rpcMsg
)
{
if
(
rpcMsg
->
handle
==
NULL
)
return
;
if
(
rpcMsg
->
handle
==
NULL
)
return
;
...
@@ -834,3 +839,37 @@ static void mgmtProcessDropTableRsp(SRpcMsg *rpcMsg) {
...
@@ -834,3 +839,37 @@ static void mgmtProcessDropTableRsp(SRpcMsg *rpcMsg) {
mgmtSendSimpleResp
(
queueMsg
->
thandle
,
TSDB_CODE_SUCCESS
);
mgmtSendSimpleResp
(
queueMsg
->
thandle
,
TSDB_CODE_SUCCESS
);
free
(
queueMsg
);
free
(
queueMsg
);
}
}
static
void
mgmtProcessDropStableRsp
(
SRpcMsg
*
rpcMsg
)
{
mTrace
(
"drop stable rsp received, handle:%p code:%d"
,
rpcMsg
->
handle
,
rpcMsg
->
code
);
}
//
//
//static void mgmtProcessTableCfgMsg(int8_t msgType, int8_t *pCont, int32_t contLen, void *thandle) {
// SDMConfigTableMsg *pCfg = (SDMConfigTableMsg *) 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(thandle, msgType + 1, TSDB_CODE_REDIRECT, NULL, 0);
// return;
// }
//
// STableInfo *pTable = mgmtGetTableByPos(pCfg->dnode, pCfg->vnode, pCfg->sid);
// if (pTable == NULL) {
// mError("dnode:%s, vnode:%d, sid:%d, table not found", taosIpStr(pCfg->dnode), pCfg->vnode, pCfg->sid);
// mgmtSendRspToDnode(thandle, msgType + 1, TSDB_CODE_INVALID_TABLE, NULL, 0);
// return;
// }
//
// mgmtSendRspToDnode(thandle, msgType + 1, TSDB_CODE_SUCCESS, NULL, 0);
//
// //TODO
// SRpcIpSet ipSet = mgmtGetIpSetFromIp(pCfg->dnode);
// mgmtSendCreateTableMsg(NULL, &ipSet, NULL);
//}
//
\ No newline at end of file
src/mnode/src/mgmtVgroup.c
浏览文件 @
b87ac4ab
...
@@ -110,11 +110,11 @@ int32_t mgmtInitVgroups() {
...
@@ -110,11 +110,11 @@ int32_t mgmtInitVgroups() {
if
(
tsIsCluster
&&
pVgroup
->
vnodeGid
[
0
].
publicIp
==
0
)
{
if
(
tsIsCluster
&&
pVgroup
->
vnodeGid
[
0
].
publicIp
==
0
)
{
pVgroup
->
vnodeGid
[
0
].
publicIp
=
inet_addr
(
tsPublicIp
);
pVgroup
->
vnodeGid
[
0
].
publicIp
=
inet_addr
(
tsPublicIp
);
pVgroup
->
vnodeGid
[
0
].
i
p
=
inet_addr
(
tsPrivateIp
);
pVgroup
->
vnodeGid
[
0
].
privateI
p
=
inet_addr
(
tsPrivateIp
);
sdbUpdateRow
(
tsVgroupSdb
,
pVgroup
,
tsVgUpdateSize
,
1
);
sdbUpdateRow
(
tsVgroupSdb
,
pVgroup
,
tsVgUpdateSize
,
1
);
}
}
mgmtSetDnodeVgid
(
pVgroup
->
vnodeGid
,
pVgroup
->
numOfVnodes
,
pVgroup
->
vgId
);
//
mgmtSetDnodeVgid(pVgroup->vnodeGid, pVgroup->numOfVnodes, pVgroup->vgId);
}
}
mgmtAddShellShowMetaHandle
(
TSDB_MGMT_TABLE_VGROUP
,
mgmtGetVgroupMeta
);
mgmtAddShellShowMetaHandle
(
TSDB_MGMT_TABLE_VGROUP
,
mgmtGetVgroupMeta
);
...
@@ -130,9 +130,6 @@ SVgObj *mgmtGetVgroup(int32_t vgId) {
...
@@ -130,9 +130,6 @@ SVgObj *mgmtGetVgroup(int32_t vgId) {
return
(
SVgObj
*
)
sdbGetRow
(
tsVgroupSdb
,
&
vgId
);
return
(
SVgObj
*
)
sdbGetRow
(
tsVgroupSdb
,
&
vgId
);
}
}
/*
* TODO: check if there is enough sids
*/
SVgObj
*
mgmtGetAvailableVgroup
(
SDbObj
*
pDb
)
{
SVgObj
*
mgmtGetAvailableVgroup
(
SDbObj
*
pDb
)
{
return
pDb
->
pHead
;
return
pDb
->
pHead
;
}
}
...
@@ -161,13 +158,13 @@ void mgmtCreateVgroup(SQueuedMsg *pMsg) {
...
@@ -161,13 +158,13 @@ void mgmtCreateVgroup(SQueuedMsg *pMsg) {
pVgroup
->
idPool
=
taosInitIdPool
(
pDb
->
cfg
.
maxSessions
);
pVgroup
->
idPool
=
taosInitIdPool
(
pDb
->
cfg
.
maxSessions
);
mgmtAddVgroupIntoDb
(
pDb
,
pVgroup
);
mgmtAddVgroupIntoDb
(
pDb
,
pVgroup
);
mgmtSetDnodeVgid
(
pVgroup
->
vnodeGid
,
pVgroup
->
numOfVnodes
,
pVgroup
->
vgId
);
//
mgmtSetDnodeVgid(pVgroup->vnodeGid, pVgroup->numOfVnodes, pVgroup->vgId);
sdbInsertRow
(
tsVgroupSdb
,
pVgroup
,
0
);
sdbInsertRow
(
tsVgroupSdb
,
pVgroup
,
0
);
mPrint
(
"vgroup:%d, is created in mnode, db:%s replica:%d"
,
pVgroup
->
vgId
,
pDb
->
name
,
pVgroup
->
numOfVnodes
);
mPrint
(
"vgroup:%d, is created in mnode, db:%s replica:%d"
,
pVgroup
->
vgId
,
pDb
->
name
,
pVgroup
->
numOfVnodes
);
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
mPrint
(
"vgroup:%d, dnode:%
s vnode:%d"
,
pVgroup
->
vgId
,
taosIpStr
(
pVgroup
->
vnodeGid
[
i
].
ip
)
,
pVgroup
->
vnodeGid
[
i
].
vnode
);
mPrint
(
"vgroup:%d, dnode:%
d vnode:%d"
,
pVgroup
->
vgId
,
pVgroup
->
vnodeGid
[
i
].
dnodeId
,
pVgroup
->
vnodeGid
[
i
].
vnode
);
}
}
pMsg
->
ahandle
=
pVgroup
;
pMsg
->
ahandle
=
pVgroup
;
...
@@ -304,9 +301,9 @@ int32_t mgmtGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
...
@@ -304,9 +301,9 @@ int32_t mgmtGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
}
}
char
*
mgmtGetVnodeStatus
(
SVgObj
*
pVgroup
,
SVnodeGid
*
pVnode
)
{
char
*
mgmtGetVnodeStatus
(
SVgObj
*
pVgroup
,
SVnodeGid
*
pVnode
)
{
SDnodeObj
*
pDnode
=
mgmtGetDnode
(
pVnode
->
ip
);
SDnodeObj
*
pDnode
=
mgmtGetDnode
(
pVnode
->
dnodeId
);
if
(
pDnode
==
NULL
)
{
if
(
pDnode
==
NULL
)
{
mError
(
"
dnode:%s, vgroup:%d, vnode:%d dnode not exist"
,
taosIpStr
(
pVnode
->
ip
),
pVgroup
->
vgId
,
pVnode
->
vnode
);
mError
(
"
vgroup:%d, not exist in dnode:%d"
,
pVgroup
->
vgId
,
pDnode
->
dnodeId
);
return
"null"
;
return
"null"
;
}
}
...
@@ -314,14 +311,13 @@ char *mgmtGetVnodeStatus(SVgObj *pVgroup, SVnodeGid *pVnode) {
...
@@ -314,14 +311,13 @@ char *mgmtGetVnodeStatus(SVgObj *pVgroup, SVnodeGid *pVnode) {
return
"offline"
;
return
"offline"
;
}
}
SVnodeLoad
*
vload
=
pDnode
->
vload
+
pVnode
->
vnode
;
for
(
int
i
=
0
;
i
<
pDnode
->
openVnodes
;
++
i
)
{
if
(
vload
->
vgId
!=
pVgroup
->
vgId
||
vload
->
vnode
!=
pVnode
->
vnode
)
{
if
(
pDnode
->
vload
[
i
].
vgId
==
pVgroup
->
vgId
)
{
mError
(
"dnode:%s, vgroup:%d, vnode:%d not same with dnode vgroup:%d vnode:%d"
,
return
(
char
*
)
taosGetVnodeStatusStr
(
pDnode
->
vload
[
i
].
status
);
taosIpStr
(
pVnode
->
ip
),
pVgroup
->
vgId
,
pVnode
->
vnode
,
vload
->
vgId
,
vload
->
vnode
);
}
return
"null"
;
}
}
return
(
char
*
)
taosGetVnodeStatusStr
(
vload
->
status
)
;
return
"null"
;
}
}
int32_t
mgmtRetrieveVgroups
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
int32_t
mgmtRetrieveVgroups
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
...
@@ -361,7 +357,7 @@ int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pCo
...
@@ -361,7 +357,7 @@ int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pCo
cols
++
;
cols
++
;
for
(
int32_t
i
=
0
;
i
<
maxReplica
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
maxReplica
;
++
i
)
{
tinet_ntoa
(
ipstr
,
pVgroup
->
vnodeGid
[
i
].
i
p
);
tinet_ntoa
(
ipstr
,
pVgroup
->
vnodeGid
[
i
].
privateI
p
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
ipstr
);
strcpy
(
pWrite
,
ipstr
);
cols
++
;
cols
++
;
...
@@ -371,7 +367,7 @@ int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pCo
...
@@ -371,7 +367,7 @@ int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pCo
cols
++
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
if
(
pVgroup
->
vnodeGid
[
i
].
ip
!=
0
)
{
if
(
pVgroup
->
vnodeGid
[
i
].
dnodeId
!=
0
)
{
char
*
vnodeStatus
=
mgmtGetVnodeStatus
(
pVgroup
,
pVgroup
->
vnodeGid
+
i
);
char
*
vnodeStatus
=
mgmtGetVnodeStatus
(
pVgroup
,
pVgroup
->
vnodeGid
+
i
);
strcpy
(
pWrite
,
vnodeStatus
);
strcpy
(
pWrite
,
vnodeStatus
);
}
else
{
}
else
{
...
@@ -393,6 +389,11 @@ int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pCo
...
@@ -393,6 +389,11 @@ int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pCo
}
}
static
void
*
mgmtVgroupActionInsert
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
static
void
*
mgmtVgroupActionInsert
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
SVgObj
*
pVgroup
=
row
;
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
pVgroup
->
vnodeGid
[
i
].
vnode
=
pVgroup
->
vgId
;
}
return
NULL
;
return
NULL
;
}
}
...
@@ -404,7 +405,7 @@ static void *mgmtVgroupActionDelete(void *row, char *str, int32_t size, int32_t
...
@@ -404,7 +405,7 @@ static void *mgmtVgroupActionDelete(void *row, char *str, int32_t size, int32_t
mgmtRemoveVgroupFromDb
(
pDb
,
pVgroup
);
mgmtRemoveVgroupFromDb
(
pDb
,
pVgroup
);
}
}
mgmtUnSetDnodeVgid
(
pVgroup
->
vnodeGid
,
pVgroup
->
numOfVnodes
);
//
mgmtUnSetDnodeVgid(pVgroup->vnodeGid, pVgroup->numOfVnodes);
tfree
(
pVgroup
->
tableList
);
tfree
(
pVgroup
->
tableList
);
return
NULL
;
return
NULL
;
...
@@ -488,14 +489,13 @@ void mgmtRemoveTableFromVgroup(SVgObj *pVgroup, STableInfo *pTable) {
...
@@ -488,14 +489,13 @@ void mgmtRemoveTableFromVgroup(SVgObj *pVgroup, STableInfo *pTable) {
taosFreeId
(
pVgroup
->
idPool
,
pTable
->
sid
);
taosFreeId
(
pVgroup
->
idPool
,
pTable
->
sid
);
}
}
SMDCreateVnodeMsg
*
mgmtBuildCreateVnodeMsg
(
SVgObj
*
pVgroup
,
int32_t
vnode
)
{
SMDCreateVnodeMsg
*
mgmtBuildCreateVnodeMsg
(
SVgObj
*
pVgroup
)
{
SDbObj
*
pDb
=
mgmtGetDb
(
pVgroup
->
dbName
);
SDbObj
*
pDb
=
mgmtGetDb
(
pVgroup
->
dbName
);
if
(
pDb
==
NULL
)
return
NULL
;
if
(
pDb
==
NULL
)
return
NULL
;
SMDCreateVnodeMsg
*
pVnode
=
rpcMallocCont
(
sizeof
(
SMDCreateVnodeMsg
));
SMDCreateVnodeMsg
*
pVnode
=
rpcMallocCont
(
sizeof
(
SMDCreateVnodeMsg
));
if
(
pVnode
==
NULL
)
return
NULL
;
if
(
pVnode
==
NULL
)
return
NULL
;
pVnode
->
vnode
=
htonl
(
vnode
);
pVnode
->
cfg
=
pDb
->
cfg
;
pVnode
->
cfg
=
pDb
->
cfg
;
SVnodeCfg
*
pCfg
=
&
pVnode
->
cfg
;
SVnodeCfg
*
pCfg
=
&
pVnode
->
cfg
;
...
@@ -514,8 +514,7 @@ SMDCreateVnodeMsg *mgmtBuildCreateVnodeMsg(SVgObj *pVgroup, int32_t vnode) {
...
@@ -514,8 +514,7 @@ SMDCreateVnodeMsg *mgmtBuildCreateVnodeMsg(SVgObj *pVgroup, int32_t vnode) {
SVnodeDesc
*
vpeerDesc
=
pVnode
->
vpeerDesc
;
SVnodeDesc
*
vpeerDesc
=
pVnode
->
vpeerDesc
;
for
(
int32_t
j
=
0
;
j
<
pVgroup
->
numOfVnodes
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pVgroup
->
numOfVnodes
;
++
j
)
{
vpeerDesc
[
j
].
ip
=
htonl
(
pVgroup
->
vnodeGid
[
j
].
ip
);
vpeerDesc
[
j
].
ip
=
htonl
(
pVgroup
->
vnodeGid
[
j
].
privateIp
);
vpeerDesc
[
j
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
j
].
vnode
);
}
}
return
pVnode
;
return
pVnode
;
...
@@ -542,7 +541,7 @@ SRpcIpSet mgmtGetIpSetFromVgroup(SVgObj *pVgroup) {
...
@@ -542,7 +541,7 @@ SRpcIpSet mgmtGetIpSetFromVgroup(SVgObj *pVgroup) {
.
port
=
tsDnodeMnodePort
.
port
=
tsDnodeMnodePort
};
};
for
(
int
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
for
(
int
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
ipSet
.
ip
[
i
]
=
pVgroup
->
vnodeGid
[
i
].
i
p
;
ipSet
.
ip
[
i
]
=
pVgroup
->
vnodeGid
[
i
].
privateI
p
;
}
}
return
ipSet
;
return
ipSet
;
}
}
...
@@ -557,9 +556,9 @@ SRpcIpSet mgmtGetIpSetFromIp(uint32_t ip) {
...
@@ -557,9 +556,9 @@ SRpcIpSet mgmtGetIpSetFromIp(uint32_t ip) {
return
ipSet
;
return
ipSet
;
}
}
void
mgmtSendCreateVnodeMsg
(
SVgObj
*
pVgroup
,
int32_t
vnode
,
SRpcIpSet
*
ipSet
,
void
*
ahandle
)
{
void
mgmtSendCreateVnodeMsg
(
SVgObj
*
pVgroup
,
SRpcIpSet
*
ipSet
,
void
*
ahandle
)
{
mTrace
(
"vgroup:%d, send create vnode:%d msg, ahandle:%p"
,
pVgroup
->
vgId
,
vnode
,
ahandle
);
mTrace
(
"vgroup:%d, send create vnode:%d msg, ahandle:%p"
,
pVgroup
->
vgId
,
pVgroup
->
vgId
,
ahandle
);
SMDCreateVnodeMsg
*
pCreate
=
mgmtBuildCreateVnodeMsg
(
pVgroup
,
vnode
);
SMDCreateVnodeMsg
*
pCreate
=
mgmtBuildCreateVnodeMsg
(
pVgroup
);
SRpcMsg
rpcMsg
=
{
SRpcMsg
rpcMsg
=
{
.
handle
=
ahandle
,
.
handle
=
ahandle
,
.
pCont
=
pCreate
,
.
pCont
=
pCreate
,
...
@@ -573,8 +572,8 @@ void mgmtSendCreateVnodeMsg(SVgObj *pVgroup, int32_t vnode, SRpcIpSet *ipSet, vo
...
@@ -573,8 +572,8 @@ void mgmtSendCreateVnodeMsg(SVgObj *pVgroup, int32_t vnode, SRpcIpSet *ipSet, vo
void
mgmtSendCreateVgroupMsg
(
SVgObj
*
pVgroup
,
void
*
ahandle
)
{
void
mgmtSendCreateVgroupMsg
(
SVgObj
*
pVgroup
,
void
*
ahandle
)
{
mTrace
(
"vgroup:%d, send create all vnodes msg, ahandle:%p"
,
pVgroup
->
vgId
,
ahandle
);
mTrace
(
"vgroup:%d, send create all vnodes msg, ahandle:%p"
,
pVgroup
->
vgId
,
ahandle
);
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SRpcIpSet
ipSet
=
mgmtGetIpSetFromIp
(
pVgroup
->
vnodeGid
[
i
].
i
p
);
SRpcIpSet
ipSet
=
mgmtGetIpSetFromIp
(
pVgroup
->
vnodeGid
[
i
].
privateI
p
);
mgmtSendCreateVnodeMsg
(
pVgroup
,
pVgroup
->
vnodeGid
[
i
].
vnode
,
&
ipSet
,
ahandle
);
mgmtSendCreateVnodeMsg
(
pVgroup
,
&
ipSet
,
ahandle
);
}
}
}
}
...
@@ -613,17 +612,17 @@ static void mgmtProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
...
@@ -613,17 +612,17 @@ static void mgmtProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
free
(
queueMsg
);
free
(
queueMsg
);
}
}
static
SMDDropVnodeMsg
*
mgmtBuildDropVnodeMsg
(
SVgObj
*
pVgroup
)
{
static
SMDDropVnodeMsg
*
mgmtBuildDropVnodeMsg
(
int32_t
vgId
)
{
SMDDropVnodeMsg
*
pDrop
=
rpcMallocCont
(
sizeof
(
SMDDropVnodeMsg
));
SMDDropVnodeMsg
*
pDrop
=
rpcMallocCont
(
sizeof
(
SMDDropVnodeMsg
));
if
(
pDrop
==
NULL
)
return
NULL
;
if
(
pDrop
==
NULL
)
return
NULL
;
pDrop
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pDrop
->
vgId
=
htonl
(
vgId
);
return
pDrop
;
return
pDrop
;
}
}
static
void
mgmtSendDropVnodeMsg
(
SVgObj
*
pVgroup
,
SRpcIpSet
*
ipSet
,
void
*
ahandle
)
{
void
mgmtSendDropVnodeMsg
(
int32_t
vgId
,
SRpcIpSet
*
ipSet
,
void
*
ahandle
)
{
mTrace
(
"vgroup:%d, send drop vnode msg, ahandle:%p"
,
pVgroup
->
vgId
,
ahandle
);
mTrace
(
"vgroup:%d, send drop vnode msg, ahandle:%p"
,
vgId
,
ahandle
);
SMDDropVnodeMsg
*
pDrop
=
mgmtBuildDropVnodeMsg
(
pVgroup
);
SMDDropVnodeMsg
*
pDrop
=
mgmtBuildDropVnodeMsg
(
vgId
);
SRpcMsg
rpcMsg
=
{
SRpcMsg
rpcMsg
=
{
.
handle
=
ahandle
,
.
handle
=
ahandle
,
.
pCont
=
pDrop
,
.
pCont
=
pDrop
,
...
@@ -637,8 +636,8 @@ static void mgmtSendDropVnodeMsg(SVgObj *pVgroup, SRpcIpSet *ipSet, void *ahandl
...
@@ -637,8 +636,8 @@ static void mgmtSendDropVnodeMsg(SVgObj *pVgroup, SRpcIpSet *ipSet, void *ahandl
static
void
mgmtSendDropVgroupMsg
(
SVgObj
*
pVgroup
,
void
*
ahandle
)
{
static
void
mgmtSendDropVgroupMsg
(
SVgObj
*
pVgroup
,
void
*
ahandle
)
{
mTrace
(
"vgroup:%d, send drop all vnodes msg, ahandle:%p"
,
pVgroup
->
vgId
,
ahandle
);
mTrace
(
"vgroup:%d, send drop all vnodes msg, ahandle:%p"
,
pVgroup
->
vgId
,
ahandle
);
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SRpcIpSet
ipSet
=
mgmtGetIpSetFromIp
(
pVgroup
->
vnodeGid
[
i
].
i
p
);
SRpcIpSet
ipSet
=
mgmtGetIpSetFromIp
(
pVgroup
->
vnodeGid
[
i
].
privateI
p
);
mgmtSendDropVnodeMsg
(
pVgroup
,
&
ipSet
,
ahandle
);
mgmtSendDropVnodeMsg
(
pVgroup
->
vgId
,
&
ipSet
,
ahandle
);
}
}
}
}
...
@@ -674,3 +673,48 @@ static void mgmtProcessDropVnodeRsp(SRpcMsg *rpcMsg) {
...
@@ -674,3 +673,48 @@ static void mgmtProcessDropVnodeRsp(SRpcMsg *rpcMsg) {
free
(
queueMsg
);
free
(
queueMsg
);
}
}
void
mgmtUpdateVgroupIp
(
SDnodeObj
*
pDnode
)
{
void
*
pNode
=
NULL
;
SVgObj
*
pVgroup
=
NULL
;
while
(
1
)
{
pNode
=
sdbFetchRow
(
tsVgroupSdb
,
pNode
,
(
void
**
)
&
pVgroup
);
if
(
pVgroup
==
NULL
)
break
;
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SVnodeGid
*
vnodeGid
=
pVgroup
->
vnodeGid
+
i
;
if
(
vnodeGid
->
dnodeId
==
pDnode
->
dnodeId
)
{
mPrint
(
"vgroup:%d, dnode:%d, privateIp:%s change to %s, publicIp:%s change to %s"
,
pVgroup
->
vgId
,
vnodeGid
->
dnodeId
,
pDnode
->
privateIp
,
taosIpStr
(
vnodeGid
->
privateIp
),
pDnode
->
publicIp
,
taosIpStr
(
vnodeGid
->
publicIp
));
vnodeGid
->
publicIp
=
pDnode
->
publicIp
;
vnodeGid
->
privateIp
=
pDnode
->
privateIp
;
sdbUpdateRow
(
tsVgroupSdb
,
pVgroup
,
tsVgUpdateSize
,
1
);
}
}
}
}
//static void mgmtProcessVnodeCfgMsg(int8_t msgType, int8_t *pCont, int32_t contLen, void *pConn) {
// if (!sdbMaster) {
// mgmtSendRspToDnode(pConn, msgType + 1, TSDB_CODE_REDIRECT, NULL, 0);
// return;
// }
//
// SDMConfigVnodeMsg *pCfg = (SDMConfigVnodeMsg *) pCont;
// pCfg->dnode = htonl(pCfg->dnode);
// pCfg->vnode = htonl(pCfg->vnode);
//
// SVgObj *pVgroup = mgmtGetVgroupByVnode(pCfg->dnode, pCfg->vnode);
// if (pVgroup == NULL) {
// mTrace("dnode:%s, vnode:%d, no vgroup info", taosIpStr(pCfg->dnode), pCfg->vnode);
// mgmtSendRspToDnode(pConn, msgType + 1, TSDB_CODE_NOT_ACTIVE_VNODE, NULL, 0);
// return;
// }
//
// mgmtSendRspToDnode(pConn, msgType + 1, TSDB_CODE_SUCCESS, NULL, 0);
//
// SRpcIpSet ipSet = mgmtGetIpSetFromIp(pCfg->dnode);
// mgmtSendCreateVnodeMsg(pVgroup, pCfg->vnode, &ipSet, NULL);
//}
//
\ No newline at end of file
src/util/inc/ihash.h
浏览文件 @
b87ac4ab
...
@@ -36,7 +36,7 @@ int32_t taosHashInt(void *handle, uint64_t key);
...
@@ -36,7 +36,7 @@ int32_t taosHashInt(void *handle, uint64_t key);
void
taosCleanUpIntHashWithFp
(
void
*
handle
,
void
(
*
fp
)(
char
*
));
void
taosCleanUpIntHashWithFp
(
void
*
handle
,
void
(
*
fp
)(
char
*
));
char
*
taosVisitIntHashWithFp
(
void
*
handle
,
int
(
*
fp
)(
char
*
)
);
void
taosVisitIntHashWithFp
(
void
*
handle
,
void
(
*
fp
)(
char
*
,
void
*
),
void
*
param
);
int32_t
taosGetIntHashSize
(
void
*
handle
);
int32_t
taosGetIntHashSize
(
void
*
handle
);
...
...
src/util/src/ihash.c
浏览文件 @
b87ac4ab
...
@@ -187,7 +187,6 @@ void taosCleanUpIntHash(void *handle) {
...
@@ -187,7 +187,6 @@ void taosCleanUpIntHash(void *handle) {
free
(
pObj
);
free
(
pObj
);
}
}
void
taosCleanUpIntHashWithFp
(
void
*
handle
,
void
(
*
fp
)(
char
*
))
{
void
taosCleanUpIntHashWithFp
(
void
*
handle
,
void
(
*
fp
)(
char
*
))
{
IHashObj
*
pObj
;
IHashObj
*
pObj
;
IHashNode
*
pNode
,
*
pNext
;
IHashNode
*
pNode
,
*
pNext
;
...
@@ -202,7 +201,7 @@ void taosCleanUpIntHashWithFp(void *handle, void (*fp)(char *)) {
...
@@ -202,7 +201,7 @@ void taosCleanUpIntHashWithFp(void *handle, void (*fp)(char *)) {
pNode
=
pObj
->
hashList
[
i
];
pNode
=
pObj
->
hashList
[
i
];
while
(
pNode
)
{
while
(
pNode
)
{
pNext
=
pNode
->
next
;
pNext
=
pNode
->
next
;
if
(
fp
!=
NULL
)
fp
(
pNode
->
data
);
if
(
fp
!=
NULL
)
(
*
fp
)
(
pNode
->
data
);
free
(
pNode
);
free
(
pNode
);
pNode
=
pNext
;
pNode
=
pNext
;
}
}
...
@@ -219,7 +218,7 @@ void taosCleanUpIntHashWithFp(void *handle, void (*fp)(char *)) {
...
@@ -219,7 +218,7 @@ void taosCleanUpIntHashWithFp(void *handle, void (*fp)(char *)) {
free
(
pObj
);
free
(
pObj
);
}
}
char
*
taosVisitIntHashWithFp
(
void
*
handle
,
int
(
*
fp
)(
char
*
)
)
{
void
taosVisitIntHashWithFp
(
void
*
handle
,
int
(
*
fp
)(
char
*
,
void
*
),
void
*
param
)
{
IHashObj
*
pObj
;
IHashObj
*
pObj
;
IHashNode
*
pNode
,
*
pNext
;
IHashNode
*
pNode
,
*
pNext
;
char
*
pData
=
NULL
;
char
*
pData
=
NULL
;
...
@@ -234,21 +233,13 @@ char *taosVisitIntHashWithFp(void *handle, int (*fp)(char *)) {
...
@@ -234,21 +233,13 @@ char *taosVisitIntHashWithFp(void *handle, int (*fp)(char *)) {
pNode
=
pObj
->
hashList
[
i
];
pNode
=
pObj
->
hashList
[
i
];
while
(
pNode
)
{
while
(
pNode
)
{
pNext
=
pNode
->
next
;
pNext
=
pNode
->
next
;
int
flag
=
fp
(
pNode
->
data
);
(
*
fp
)(
pNode
->
data
,
param
);
if
(
flag
)
{
pData
=
pNode
->
data
;
goto
VisitEnd
;
}
pNode
=
pNext
;
pNode
=
pNext
;
}
}
}
}
}
}
VisitEnd:
pthread_mutex_unlock
(
&
pObj
->
mutex
);
pthread_mutex_unlock
(
&
pObj
->
mutex
);
return
pData
;
}
}
int32_t
taosGetIntHashSize
(
void
*
handle
)
{
int32_t
taosGetIntHashSize
(
void
*
handle
)
{
...
...
src/util/src/tglobalcfg.c
浏览文件 @
b87ac4ab
...
@@ -135,7 +135,7 @@ int tsOfflineThreshold = 864000; // seconds 10days
...
@@ -135,7 +135,7 @@ int tsOfflineThreshold = 864000; // seconds 10days
int
tsMgmtEqualVnodeNum
=
4
;
int
tsMgmtEqualVnodeNum
=
4
;
int
tsEnableHttpModule
=
1
;
int
tsEnableHttpModule
=
1
;
int
tsEnableMonitorModule
=
1
;
int
tsEnableMonitorModule
=
0
;
int
tsRestRowLimit
=
10240
;
int
tsRestRowLimit
=
10240
;
int
tsMaxSQLStringLen
=
TSDB_MAX_SQL_LEN
;
int
tsMaxSQLStringLen
=
TSDB_MAX_SQL_LEN
;
...
...
src/util/src/tstatus.c
浏览文件 @
b87ac4ab
...
@@ -18,13 +18,13 @@
...
@@ -18,13 +18,13 @@
char
*
taosGetVgroupStatusStr
(
int32_t
vgroupStatus
)
{
char
*
taosGetVgroupStatusStr
(
int32_t
vgroupStatus
)
{
switch
(
vgroupStatus
)
{
switch
(
vgroupStatus
)
{
case
TSDB_VG_STATUS_READY
:
return
tstrerror
(
vgroupStatus
);
case
TSDB_VG_STATUS_READY
:
return
(
char
*
)
tstrerror
(
vgroupStatus
);
case
TSDB_VG_STATUS_IN_PROGRESS
:
return
tstrerror
(
vgroupStatus
);
case
TSDB_VG_STATUS_IN_PROGRESS
:
return
(
char
*
)
tstrerror
(
vgroupStatus
);
case
TSDB_VG_STATUS_NO_DISK_PERMISSIONS
:
return
tstrerror
(
vgroupStatus
);
case
TSDB_VG_STATUS_NO_DISK_PERMISSIONS
:
return
(
char
*
)
tstrerror
(
vgroupStatus
);
case
TSDB_VG_STATUS_SERVER_NO_PACE
:
return
tstrerror
(
vgroupStatus
);
case
TSDB_VG_STATUS_SERVER_NO_PACE
:
return
(
char
*
)
tstrerror
(
vgroupStatus
);
case
TSDB_VG_STATUS_SERV_OUT_OF_MEMORY
:
return
tstrerror
(
vgroupStatus
);
case
TSDB_VG_STATUS_SERV_OUT_OF_MEMORY
:
return
(
char
*
)
tstrerror
(
vgroupStatus
);
case
TSDB_VG_STATUS_INIT_FAILED
:
return
tstrerror
(
vgroupStatus
);
case
TSDB_VG_STATUS_INIT_FAILED
:
return
(
char
*
)
tstrerror
(
vgroupStatus
);
case
TSDB_VG_STATUS_FULL
:
return
tstrerror
(
vgroupStatus
);
case
TSDB_VG_STATUS_FULL
:
return
(
char
*
)
tstrerror
(
vgroupStatus
);
default:
return
"undefined"
;
default:
return
"undefined"
;
}
}
}
}
...
...
src/vnode/tsdb/inc/tsdb.h
浏览文件 @
b87ac4ab
...
@@ -37,7 +37,6 @@ extern "C" {
...
@@ -37,7 +37,6 @@ extern "C" {
// --------- TSDB REPOSITORY CONFIGURATION DEFINITION
// --------- TSDB REPOSITORY CONFIGURATION DEFINITION
typedef
struct
{
typedef
struct
{
int8_t
precision
;
int8_t
precision
;
int32_t
vgId
;
int32_t
tsdbId
;
int32_t
tsdbId
;
int32_t
maxTables
;
// maximum number of tables this repository can have
int32_t
maxTables
;
// maximum number of tables this repository can have
int32_t
daysPerFile
;
// day per file sharding policy
int32_t
daysPerFile
;
// day per file sharding policy
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录