Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
71607ccb
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
71607ccb
编写于
4月 11, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-52] update status message
上级
78f7134e
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
278 addition
and
137 deletion
+278
-137
src/dnode/inc/dnodeMClient.h
src/dnode/inc/dnodeMClient.h
+1
-0
src/dnode/src/dnodeMClient.c
src/dnode/src/dnodeMClient.c
+160
-61
src/inc/mnode.h
src/inc/mnode.h
+2
-0
src/inc/mpeer.h
src/inc/mpeer.h
+13
-11
src/inc/taosmsg.h
src/inc/taosmsg.h
+14
-1
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+0
-2
src/mnode/src/mgmtDnode.c
src/mnode/src/mgmtDnode.c
+1
-3
src/mnode/src/mgmtMnode.c
src/mnode/src/mgmtMnode.c
+83
-52
src/mnode/src/mgmtProfile.c
src/mnode/src/mgmtProfile.c
+3
-6
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+1
-1
src/util/inc/cJSON.h
src/util/inc/cJSON.h
+0
-0
src/util/src/cJSON.c
src/util/src/cJSON.c
+0
-0
未找到文件。
src/dnode/inc/dnodeMClient.h
浏览文件 @
71607ccb
...
...
@@ -24,6 +24,7 @@ int32_t dnodeInitMClient();
void
dnodeCleanupMClient
();
void
dnodeSendMsgToMnode
(
SRpcMsg
*
rpcMsg
);
uint32_t
dnodeGetMnodeMasteIp
();
void
*
dnodeGetMpeerInfos
();
#ifdef __cplusplus
}
...
...
src/dnode/src/dnodeMClient.c
浏览文件 @
71607ccb
...
...
@@ -15,33 +15,46 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "cJSON.h"
#include "taosmsg.h"
#include "tlog.h"
#include "trpc.h"
#include "tutil.h"
#include "tsync.h"
#include "dnode.h"
#include "dnodeMClient.h"
#include "dnodeModule.h"
#include "dnodeMgmt.h"
#define MPEER_CONTENT_LEN 2000
static
bool
dnodeReadMnodeIpList
();
static
void
dnodeSaveMnodeIpList
();
static
void
dnodeProcessRspFromMnode
(
SRpcMsg
*
pMsg
);
static
void
dnodeProcessStatusRsp
(
SRpcMsg
*
pMsg
);
static
void
(
*
tsDnodeProcessMgmtRspFp
[
TSDB_MSG_TYPE_MAX
])(
SRpcMsg
*
);
static
void
*
tsDnodeMClientRpc
=
NULL
;
static
SRpcIpSet
tsDnodeMnodeIpList
=
{
0
};
static
SRpcIpSet
tsMpeerIpList
=
{
0
};
static
SDMNodeInfos
tsMpeerInfos
=
{
0
};
int32_t
dnodeInitMClient
()
{
if
(
!
dnodeReadMnodeIpList
())
{
dTrace
(
"failed to read mnode iplist, set it from cfg file"
);
memset
(
&
ts
DnodeMnodeIpList
,
0
,
sizeof
(
SRpcIpSet
));
ts
DnodeMnode
IpList
.
port
=
tsMnodeDnodePort
;
ts
DnodeMnode
IpList
.
numOfIps
=
1
;
ts
DnodeMnode
IpList
.
ip
[
0
]
=
inet_addr
(
tsMasterIp
);
memset
(
&
tsMpeerIpList
,
0
,
sizeof
(
SRpcIpSet
)
);
memset
(
&
ts
MpeerInfos
,
0
,
sizeof
(
SDMNodeInfos
));
ts
Mpeer
IpList
.
port
=
tsMnodeDnodePort
;
ts
Mpeer
IpList
.
numOfIps
=
1
;
ts
Mpeer
IpList
.
ip
[
0
]
=
inet_addr
(
tsMasterIp
);
if
(
tsSecondIp
[
0
])
{
tsDnodeMnodeIpList
.
numOfIps
=
2
;
tsDnodeMnodeIpList
.
ip
[
1
]
=
inet_addr
(
tsSecondIp
);
tsMpeerIpList
.
numOfIps
=
2
;
tsMpeerIpList
.
ip
[
1
]
=
inet_addr
(
tsSecondIp
);
}
}
else
{
SRpcIpSet
mgmtIpSet
=
{
0
};
tsMpeerIpList
.
inUse
=
tsMpeerInfos
.
inUse
;
tsMpeerIpList
.
numOfIps
=
tsMpeerInfos
.
nodeNum
;
tsMpeerIpList
.
port
=
tsMpeerInfos
.
nodeInfos
[
0
].
nodePort
;
for
(
int32_t
i
=
0
;
i
<
tsMpeerInfos
.
nodeNum
;
i
++
)
{
tsMpeerIpList
.
ip
[
i
]
=
tsMpeerInfos
.
nodeInfos
[
i
].
nodeIp
;
}
}
...
...
@@ -96,23 +109,31 @@ static void dnodeProcessStatusRsp(SRpcMsg *pMsg) {
}
SDMStatusRsp
*
pStatusRsp
=
pMsg
->
pCont
;
if
(
pStatusRsp
->
ipList
.
numOfIps
<=
0
)
{
dError
(
"status msg is invalid, num of ips is %d"
,
pStatusRsp
->
ipList
.
numOfIps
);
SDMNodeInfos
*
mpeers
=
&
pStatusRsp
->
mpeers
;
if
(
mpeers
->
nodeNum
<=
0
)
{
dError
(
"status msg is invalid, num of ips is %d"
,
mpeers
->
nodeNum
);
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
]);
SRpcIpSet
mgmtIpSet
=
{
0
};
mgmtIpSet
.
inUse
=
mpeers
->
inUse
;
mgmtIpSet
.
numOfIps
=
mpeers
->
nodeNum
;
mgmtIpSet
.
port
=
htons
(
mpeers
->
nodeInfos
[
0
].
nodePort
);
for
(
int32_t
i
=
0
;
i
<
mpeers
->
nodeNum
;
i
++
)
{
mgmtIpSet
.
ip
[
i
]
=
htonl
(
mpeers
->
nodeInfos
[
i
].
nodeIp
);
}
//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
]));
if
(
memcmp
(
&
mgmtIpSet
,
&
tsMpeerIpList
,
sizeof
(
SRpcIpSet
))
!=
0
)
{
memcpy
(
&
tsMpeerIpList
,
&
mgmtIpSet
,
sizeof
(
SRpcIpSet
));
memcpy
(
&
tsMpeerInfos
,
mpeers
,
sizeof
(
SDMNodeInfos
));
dPrint
(
"mnode ip list is changed, numOfIps:%d inUse:%d"
,
tsMpeerInfos
.
nodeNum
,
tsMpeerInfos
.
inUse
);
for
(
int32_t
i
=
0
;
i
<
mpeers
->
nodeNum
;
i
++
)
{
tsMpeerInfos
.
nodeInfos
[
i
].
nodeId
=
htonl
(
mpeers
->
nodeInfos
[
i
].
nodeId
);
tsMpeerInfos
.
nodeInfos
[
i
].
nodeIp
=
htonl
(
mpeers
->
nodeInfos
[
i
].
nodeIp
);
tsMpeerInfos
.
nodeInfos
[
i
].
nodePort
=
htons
(
mpeers
->
nodeInfos
[
i
].
nodePort
);
dPrint
(
"mnode:%d, ip:%s:%u name:%s"
,
tsMpeerInfos
.
nodeInfos
[
i
].
nodeId
,
taosIpStr
(
tsMpeerInfos
.
nodeInfos
[
i
].
nodeId
),
tsMpeerInfos
.
nodeInfos
[
i
].
nodePort
,
tsMpeerInfos
.
nodeInfos
[
i
].
nodeName
);
}
dnodeSaveMnodeIpList
();
}
...
...
@@ -129,70 +150,148 @@ static void dnodeProcessStatusRsp(SRpcMsg *pMsg) {
void
dnodeSendMsgToMnode
(
SRpcMsg
*
rpcMsg
)
{
if
(
tsDnodeMClientRpc
)
{
rpcSendRequest
(
tsDnodeMClientRpc
,
&
ts
DnodeMnode
IpList
,
rpcMsg
);
rpcSendRequest
(
tsDnodeMClientRpc
,
&
ts
Mpeer
IpList
,
rpcMsg
);
}
}
static
bool
dnodeReadMnodeIpList
()
{
char
ipFile
[
TSDB_FILENAME_LEN
]
=
{
0
};
sprintf
(
ipFile
,
"%s/iplist"
,
tsDnodeDir
);
sprintf
(
ipFile
,
"%s/mgmtIpList.json"
,
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
;;
if
(
!
fp
)
{
dTrace
(
"failed to read mnode mgmtIpList.json, file not exist"
);
return
false
;
}
num
=
fscanf
(
fp
,
"%s %d"
,
option
,
&
value
);
if
(
num
!=
2
)
return
false
;
if
(
strcmp
(
option
,
"numOfIps"
)
!=
0
)
return
false
;
tsDnodeMnodeIpList
.
numOfIps
=
(
int8_t
)
value
;
bool
ret
=
false
;
int
maxLen
=
2000
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
int
len
=
fread
(
content
,
1
,
maxLen
,
fp
);
if
(
len
<=
0
)
{
free
(
content
);
fclose
(
fp
);
dError
(
"failed to read mnode mgmtIpList.json, content is null"
);
return
false
;
}
num
=
fscanf
(
fp
,
"%s %d"
,
option
,
&
value
);
if
(
num
!=
2
)
return
false
;
if
(
strcmp
(
option
,
"port"
)
!=
0
)
return
false
;
tsDnodeMnodeIpList
.
port
=
(
uint16_t
)
value
;
cJSON
*
root
=
cJSON_Parse
(
content
);
if
(
root
==
NULL
)
{
dError
(
"failed to read mnode mgmtIpList.json, invalid json format"
);
goto
PARSE_OVER
;
}
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
;
cJSON
*
inUse
=
cJSON_GetObjectItem
(
root
,
"inUse"
);
if
(
!
inUse
||
inUse
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read mnode mgmtIpList.json, inUse not found"
);
goto
PARSE_OVER
;
}
tsMpeerInfos
.
inUse
=
inUse
->
valueint
;
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
]));
}
cJSON
*
nodeNum
=
cJSON_GetObjectItem
(
root
,
"nodeNum"
);
if
(
!
nodeNum
||
nodeNum
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read mnode mgmtIpList.json, nodeNum not found"
);
goto
PARSE_OVER
;
}
tsMpeerInfos
.
nodeNum
=
nodeNum
->
valueint
;
cJSON
*
nodeInfos
=
cJSON_GetObjectItem
(
root
,
"nodeInfos"
);
if
(
!
nodeInfos
||
nodeInfos
->
type
!=
cJSON_Array
)
{
dError
(
"failed to read mnode mgmtIpList.json, nodeInfos not found"
);
goto
PARSE_OVER
;
}
int
size
=
cJSON_GetArraySize
(
nodeInfos
);
if
(
size
!=
tsMpeerInfos
.
nodeNum
)
{
dError
(
"failed to read mnode mgmtIpList.json, nodeInfos size not matched"
);
goto
PARSE_OVER
;
}
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
cJSON
*
nodeInfo
=
cJSON_GetArrayItem
(
nodeInfos
,
i
);
if
(
nodeInfo
==
NULL
)
continue
;
cJSON
*
nodeId
=
cJSON_GetObjectItem
(
nodeInfo
,
"nodeId"
);
if
(
!
nodeId
||
nodeId
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read mnode mgmtIpList.json, nodeId not found"
);
goto
PARSE_OVER
;
}
tsMpeerInfos
.
nodeInfos
[
i
].
nodeId
=
nodeId
->
valueint
;
return
true
;
cJSON
*
nodeIp
=
cJSON_GetObjectItem
(
nodeInfo
,
"nodeIp"
);
if
(
!
nodeIp
||
nodeIp
->
type
!=
cJSON_String
||
nodeIp
->
valuestring
==
NULL
)
{
dError
(
"failed to read mnode mgmtIpList.json, nodeIp not found"
);
goto
PARSE_OVER
;
}
tsMpeerInfos
.
nodeInfos
[
i
].
nodeIp
=
inet_addr
(
nodeIp
->
valuestring
);
cJSON
*
nodePort
=
cJSON_GetObjectItem
(
nodeInfo
,
"nodePort"
);
if
(
!
nodePort
||
nodePort
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read mnode mgmtIpList.json, nodePort not found"
);
goto
PARSE_OVER
;
}
tsMpeerInfos
.
nodeInfos
[
i
].
nodePort
=
(
uint16_t
)
nodePort
->
valueint
;
cJSON
*
nodeName
=
cJSON_GetObjectItem
(
nodeInfo
,
"nodeName"
);
if
(
!
nodeIp
||
nodeName
->
type
!=
cJSON_String
||
nodeName
->
valuestring
==
NULL
)
{
dError
(
"failed to read mnode mgmtIpList.json, nodeName not found"
);
goto
PARSE_OVER
;
}
strncpy
(
tsMpeerInfos
.
nodeInfos
[
i
].
nodeName
,
nodeName
->
valuestring
,
TSDB_NODE_NAME_LEN
);
}
ret
=
true
;
dPrint
(
"read mnode iplist successed, numOfIps:%d inUse:%d"
,
tsMpeerInfos
.
nodeNum
,
tsMpeerInfos
.
inUse
);
for
(
int32_t
i
=
0
;
i
<
tsMpeerInfos
.
nodeNum
;
i
++
)
{
dPrint
(
"mnode:%d, ip:%s:%u name:%s"
,
tsMpeerInfos
.
nodeInfos
[
i
].
nodeId
,
taosIpStr
(
tsMpeerInfos
.
nodeInfos
[
i
].
nodeId
),
tsMpeerInfos
.
nodeInfos
[
i
].
nodePort
,
tsMpeerInfos
.
nodeInfos
[
i
].
nodeName
);
}
PARSE_OVER:
free
(
content
);
fclose
(
fp
);
return
ret
;
}
static
void
dnodeSaveMnodeIpList
()
{
char
ipFile
[
TSDB_FILENAME_LEN
]
=
{
0
};
sprintf
(
ipFile
,
"%s/iplist"
,
tsDnodeDir
);
sprintf
(
ipFile
,
"%s/mgmtIpList.json"
,
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
]);
int32_t
len
=
0
;
int32_t
maxLen
=
2000
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
inUse
\"
: %d,
\n
"
,
tsMpeerInfos
.
inUse
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
nodeNum
\"
: %d,
\n
"
,
tsMpeerInfos
.
nodeNum
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
nodeInfos
\"
: [{
\n
"
);
for
(
int32_t
i
=
0
;
i
<
tsMpeerInfos
.
nodeNum
;
i
++
)
{
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
nodeId
\"
: %d,
\n
"
,
tsMpeerInfos
.
nodeInfos
[
i
].
nodeId
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
nodeIp
\"
:
\"
%s
\"
,
\n
"
,
taosIpStr
(
tsMpeerInfos
.
nodeInfos
[
i
].
nodeIp
));
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
nodePort
\"
: %u,
\n
"
,
tsMpeerInfos
.
nodeInfos
[
i
].
nodePort
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
nodeName
\"
:
\"
%s
\"\n
"
,
tsMpeerInfos
.
nodeInfos
[
i
].
nodeName
);
if
(
i
<
tsMpeerInfos
.
nodeNum
-
1
)
{
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
" },{
\n
"
);
}
else
{
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
" }]
\n
"
);
}
}
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"}
\n
"
);
fwrite
(
content
,
1
,
len
,
fp
);
fclose
(
fp
);
free
(
content
);
dPrint
(
"save mnode iplist successed"
);
}
uint32_t
dnodeGetMnodeMasteIp
()
{
return
tsDnodeMnodeIpList
.
ip
[
0
];
return
tsMpeerIpList
.
ip
[
tsMpeerIpList
.
inUse
];
}
void
*
dnodeGetMpeerInfos
()
{
return
&
tsMpeerInfos
;
}
\ No newline at end of file
src/inc/mnode.h
浏览文件 @
71607ccb
...
...
@@ -52,8 +52,10 @@ typedef struct _mnode_obj {
int32_t
refCount
;
int8_t
role
;
int8_t
status
;
uint16_t
port
;
uint32_t
privateIp
;
uint32_t
publicIp
;
char
mnodeName
[
TSDB_NODE_NAME_LEN
+
1
];
}
SMnodeObj
;
typedef
struct
_dnode_obj
{
...
...
src/inc/mpeer.h
浏览文件 @
71607ccb
...
...
@@ -20,28 +20,30 @@
extern
"C"
{
#endif
enum
_TSDB_MN_STATUS
{
TSDB_MN_STATUS_OFFLINE
,
TSDB_MN_STATUS_UNSYNCED
,
TSDB_MN_STATUS_SYNCING
,
TSDB_MN_STATUS_SERVING
};
struct
_mnode_obj
;
enum
_T
SDB_MN_ROLE
{
T
SDB_MN_ROLE_UNDECIDED
,
T
SDB_MN_ROLE_SLAVE
,
T
SDB_MN_ROLE_MASTER
enum
_T
AOS_MN_STATUS
{
T
AOS_MN_STATUS_OFFLINE
,
T
AOS_MN_STATUS_DROPPING
,
T
AOS_MN_STATUS_READY
};
int32_t
mpeerInit
();
void
mpeerCleanup
();
int32_t
mpeerGetMnodesNum
();
void
*
mpeerGetNextMnode
(
void
*
pNode
,
struct
_mnode_obj
**
pMnode
);
void
mpeerReleaseMnode
(
struct
_mnode_obj
*
pMnode
);
bool
mpeerInServerStatus
();
bool
mpeerIsMaster
();
bool
mpeerCheckRedirect
();
bool
mpeerCheckRedirect
(
void
*
handle
);
void
mpeerGetPrivateIpList
(
SRpcIpSet
*
ipSet
);
void
mpeerGetPublicIpList
(
SRpcIpSet
*
ipSet
);
void
mpeerGetMpeerInfos
(
void
*
mpeers
);
char
*
mpeerGetMnodeStatusStr
(
int32_t
status
);
char
*
mpeerGetMnodeRoleStr
(
int32_t
role
);
#ifdef __cplusplus
}
...
...
src/inc/taosmsg.h
浏览文件 @
71607ccb
...
...
@@ -593,7 +593,20 @@ typedef struct {
}
SDMStatusMsg
;
typedef
struct
{
SRpcIpSet
ipList
;
int32_t
nodeId
;
uint32_t
nodeIp
;
uint16_t
nodePort
;
char
nodeName
[
TSDB_NODE_NAME_LEN
+
1
];
}
SDMNodeInfo
;
typedef
struct
{
int8_t
inUse
;
int8_t
nodeNum
;
SDMNodeInfo
nodeInfos
[
TSDB_MAX_MPEERS
];
}
SDMNodeInfos
;
typedef
struct
{
SDMNodeInfos
mpeers
;
SDnodeState
dnodeState
;
SVnodeAccess
vnodeAccess
[];
}
SDMStatusRsp
;
...
...
src/mnode/src/mgmtDb.c
浏览文件 @
71607ccb
...
...
@@ -678,8 +678,6 @@ static int32_t mgmtSetDbDropping(SDbObj *pDb) {
}
static
void
mgmtProcessCreateDbMsg
(
SQueuedMsg
*
pMsg
)
{
if
(
mpeerCheckRedirect
(
pMsg
->
thandle
))
return
;
SCMCreateDbMsg
*
pCreate
=
pMsg
->
pCont
;
pCreate
->
maxSessions
=
htonl
(
pCreate
->
maxSessions
);
pCreate
->
cacheBlockSize
=
htonl
(
pCreate
->
cacheBlockSize
);
...
...
src/mnode/src/mgmtDnode.c
浏览文件 @
71607ccb
...
...
@@ -141,8 +141,6 @@ static void clusterProcessCfgDnodeMsgRsp(SRpcMsg *rpcMsg) {
}
void
clusterProcessDnodeStatusMsg
(
SRpcMsg
*
rpcMsg
)
{
if
(
mpeerCheckRedirect
(
rpcMsg
->
handle
))
return
;
SDMStatusMsg
*
pStatus
=
rpcMsg
->
pCont
;
pStatus
->
dnodeId
=
htonl
(
pStatus
->
dnodeId
);
pStatus
->
privateIp
=
htonl
(
pStatus
->
privateIp
);
...
...
@@ -221,7 +219,7 @@ void clusterProcessDnodeStatusMsg(SRpcMsg *rpcMsg) {
return
;
}
mpeerGet
PrivateIpList
(
&
pRsp
->
ipList
);
mpeerGet
MpeerInfos
(
&
pRsp
->
mpeers
);
pRsp
->
dnodeState
.
dnodeId
=
htonl
(
pDnode
->
dnodeId
);
pRsp
->
dnodeState
.
moduleStatus
=
htonl
(
pDnode
->
moduleStatus
);
...
...
src/mnode/src/mgmtMnode.c
浏览文件 @
71607ccb
...
...
@@ -17,41 +17,36 @@
#include "os.h"
#include "taoserror.h"
#include "trpc.h"
#include "tsync.h"
#include "mpeer.h"
#include "mgmtSdb.h"
#include "mgmtShell.h"
#include "mgmtUser.h"
#ifndef _MPEER
static
SMnodeObj
tsMnodeObj
=
{
0
};
extern
int32_t
mpeerInitMnodes
();
extern
void
mpeerCleanupMnodes
();
static
int32_t
mgmtGetMnodeMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveMnodes
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
int32_t
mpeerInit
()
{
mgmtAddShellShowMetaHandle
(
TSDB_MGMT_TABLE_MNODE
,
mgmtGetMnodeMeta
);
mgmtAddShellShowRetrieveHandle
(
TSDB_MGMT_TABLE_MNODE
,
mgmtRetrieveMnodes
);
#ifndef _MPEER
static
SMnodeObj
tsMnodeObj
=
{
0
};
int32_t
mpeerInitMnodes
()
{
tsMnodeObj
.
mnodeId
=
1
;
tsMnodeObj
.
dnodeId
=
1
;
tsMnodeObj
.
privateIp
=
inet_addr
(
tsPrivateIp
);
tsMnodeObj
.
publicIp
=
inet_addr
(
tsPublicIp
);
tsMnodeObj
.
createdTime
=
taosGetTimestampMs
();
tsMnodeObj
.
role
=
TSDB_MN_ROLE_MASTER
;
tsMnodeObj
.
status
=
TSDB_MN_STATUS_SERVING
;
tsMnodeObj
.
role
=
TAOS_SYNC_ROLE_MASTER
;
tsMnodeObj
.
status
=
TAOS_MN_STATUS_READY
;
tsMnodeObj
.
port
=
tsMnodeDnodePort
;
sprintf
(
tsMnodeObj
.
mnodeName
,
"m%d"
,
tsMnodeObj
.
mnodeId
);
return
TSDB_CODE_SUCCESS
;
}
void
mpeerCleanup
()
{}
bool
mpeerInServerStatus
()
{
return
tsMnodeObj
.
status
==
TSDB_MN_STATUS_SERVING
;
}
bool
mpeerIsMaster
()
{
return
tsMnodeObj
.
role
==
TSDB_MN_ROLE_MASTER
;
}
bool
mpeerCheckRedirect
(
void
*
thandle
)
{
return
false
;
}
static
int32_t
mgmtGetMnodesNum
()
{
return
1
;
}
static
void
*
mgmtGetNextMnode
(
void
*
pNode
,
SMnodeObj
**
pMnode
)
{
void
*
mpeerGetNextMnode
(
void
*
pNode
,
SMnodeObj
**
pMnode
)
{
if
(
*
pMnode
==
NULL
)
{
*
pMnode
=
&
tsMnodeObj
;
}
else
{
...
...
@@ -61,22 +56,74 @@ static void *mgmtGetNextMnode(void *pNode, SMnodeObj **pMnode) {
return
*
pMnode
;
}
char
*
taosGetMnodeStatusStr
(
int32_t
mnodeStatus
)
{
switch
(
mnodeStatus
)
{
case
TSDB_MN_STATUS_OFFLINE
:
return
"offline"
;
case
TSDB_MN_STATUS_UNSYNCED
:
return
"unsynced"
;
case
TSDB_MN_STATUS_SYNCING
:
return
"syncing"
;
case
TSDB_MN_STATUS_SERVING
:
return
"serving"
;
default:
return
"undefined"
;
void
mpeerGetPrivateIpList
(
SRpcIpSet
*
ipSet
)
{
ipSet
->
inUse
=
0
;
ipSet
->
port
=
htons
(
tsMnodeDnodePort
);
ipSet
->
numOfIps
=
1
;
ipSet
->
ip
[
0
]
=
htonl
(
tsMnodeObj
.
privateIp
);
}
void
mpeerGetPublicIpList
(
SRpcIpSet
*
ipSet
)
{
ipSet
->
inUse
=
0
;
ipSet
->
port
=
htons
(
tsMnodeDnodePort
);
ipSet
->
numOfIps
=
1
;
ipSet
->
ip
[
0
]
=
htonl
(
tsMnodeObj
.
publicIp
);
}
void
mpeerGetMpeerInfos
(
void
*
param
)
{
SDMNodeInfos
*
mpeers
=
param
;
mpeers
->
nodeNum
=
1
;
mpeers
->
nodeInfos
[
0
].
nodeId
=
htonl
(
tsMnodeObj
.
mnodeId
);
mpeers
->
nodeInfos
[
0
].
nodeIp
=
htonl
(
tsMnodeObj
.
privateIp
);
mpeers
->
nodeInfos
[
0
].
nodePort
=
htons
(
tsMnodeObj
.
port
);
strcpy
(
mpeers
->
nodeInfos
[
0
].
nodeName
,
tsMnodeObj
.
mnodeName
);
}
void
mpeerCleanupDnodes
()
{}
int32_t
mpeerGetMnodesNum
()
{
return
1
;
}
void
mpeerReleaseMnode
(
struct
_mnode_obj
*
pMnode
)
{}
bool
mpeerInServerStatus
()
{
return
tsMnodeObj
.
status
==
TAOS_MN_STATUS_READY
;
}
bool
mpeerIsMaster
()
{
return
tsMnodeObj
.
role
==
TAOS_SYNC_ROLE_MASTER
;
}
bool
mpeerCheckRedirect
()
{
return
false
;
}
#endif
int32_t
mpeerInit
()
{
mgmtAddShellShowMetaHandle
(
TSDB_MGMT_TABLE_MNODE
,
mgmtGetMnodeMeta
);
mgmtAddShellShowRetrieveHandle
(
TSDB_MGMT_TABLE_MNODE
,
mgmtRetrieveMnodes
);
return
mpeerInitMnodes
();
}
void
mpeerCleanup
()
{
mpeerCleanupDnodes
();
}
char
*
mpeerGetMnodeStatusStr
(
int32_t
status
)
{
switch
(
status
)
{
case
TAOS_MN_STATUS_OFFLINE
:
return
"offline"
;
case
TAOS_MN_STATUS_DROPPING
:
return
"dropping"
;
case
TAOS_MN_STATUS_READY
:
return
"ready"
;
default:
return
"undefined"
;
}
}
char
*
taosGetMnodeRoleStr
(
int32_t
mnodeRole
)
{
switch
(
mnodeRole
)
{
case
TSDB_MN_ROLE_UNDECIDED
:
return
"undicided"
;
case
TSDB_MN_ROLE_SLAVE
:
return
"slave"
;
case
TSDB_MN_ROLE_MASTER
:
return
"master"
;
default:
return
"undefined"
;
char
*
mpeerGetMnodeRoleStr
(
int32_t
role
)
{
switch
(
role
)
{
case
TAOS_SYNC_ROLE_OFFLINE
:
return
"offline"
;
case
TAOS_SYNC_ROLE_UNSYNCED
:
return
"unsynced"
;
case
TAOS_SYNC_ROLE_SLAVE
:
return
"slave"
;
case
TAOS_SYNC_ROLE_MASTER
:
return
"master"
;
default:
return
"undefined"
;
}
}
...
...
@@ -133,7 +180,7 @@ static int32_t mgmtGetMnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pCo
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
pShow
->
numOfRows
=
m
gmt
GetMnodesNum
();
pShow
->
numOfRows
=
m
peer
GetMnodesNum
();
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
pNode
=
NULL
;
mgmtReleaseUser
(
pUser
);
...
...
@@ -149,7 +196,7 @@ static int32_t mgmtRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, voi
char
ipstr
[
32
];
while
(
numOfRows
<
rows
)
{
pShow
->
pNode
=
m
gmtGetNextMnode
(
pShow
->
pNode
,
(
SMnodeObj
**
)
&
pMnode
);
pShow
->
pNode
=
m
peerGetNextMnode
(
pShow
->
pNode
,
&
pMnode
);
if
(
pMnode
==
NULL
)
break
;
cols
=
0
;
...
...
@@ -173,11 +220,11 @@ static int32_t mgmtRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, voi
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
taos
GetMnodeStatusStr
(
pMnode
->
status
));
strcpy
(
pWrite
,
mpeer
GetMnodeStatusStr
(
pMnode
->
status
));
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
taos
GetMnodeRoleStr
(
pMnode
->
role
));
strcpy
(
pWrite
,
mpeer
GetMnodeRoleStr
(
pMnode
->
role
));
cols
++
;
numOfRows
++
;
...
...
@@ -186,20 +233,4 @@ static int32_t mgmtRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, voi
pShow
->
numOfReads
+=
numOfRows
;
return
numOfRows
;
}
void
mpeerGetPrivateIpList
(
SRpcIpSet
*
ipSet
)
{
ipSet
->
inUse
=
0
;
ipSet
->
port
=
htons
(
tsMnodeDnodePort
);
ipSet
->
numOfIps
=
1
;
ipSet
->
ip
[
0
]
=
htonl
(
tsMnodeObj
.
privateIp
);
}
void
mpeerGetPublicIpList
(
SRpcIpSet
*
ipSet
)
{
ipSet
->
inUse
=
0
;
ipSet
->
port
=
htons
(
tsMnodeDnodePort
);
ipSet
->
numOfIps
=
1
;
ipSet
->
ip
[
0
]
=
htonl
(
tsMnodeObj
.
publicIp
);
}
#endif
\ No newline at end of file
}
\ No newline at end of file
src/mnode/src/mgmtProfile.c
浏览文件 @
71607ccb
...
...
@@ -681,8 +681,7 @@ int32_t mgmtRetrieveConns(SShowObj *pShow, char *data, int32_t rows, void *pConn
void
mgmtProcessKillQueryMsg
(
SQueuedMsg
*
pMsg
)
{
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
thandle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
if
(
mpeerCheckRedirect
(
pMsg
->
thandle
))
return
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pMsg
->
thandle
,
NULL
);
if
(
pUser
==
NULL
)
{
rpcRsp
.
code
=
TSDB_CODE_INVALID_USER
;
...
...
@@ -705,8 +704,7 @@ void mgmtProcessKillQueryMsg(SQueuedMsg *pMsg) {
void
mgmtProcessKillStreamMsg
(
SQueuedMsg
*
pMsg
)
{
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
thandle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
if
(
mpeerCheckRedirect
(
pMsg
->
thandle
))
return
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pMsg
->
thandle
,
NULL
);
if
(
pUser
==
NULL
)
{
rpcRsp
.
code
=
TSDB_CODE_INVALID_USER
;
...
...
@@ -729,8 +727,7 @@ void mgmtProcessKillStreamMsg(SQueuedMsg *pMsg) {
void
mgmtProcessKillConnectionMsg
(
SQueuedMsg
*
pMsg
)
{
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
thandle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
if
(
mpeerCheckRedirect
(
pMsg
->
thandle
))
return
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pMsg
->
thandle
,
NULL
);
if
(
pUser
==
NULL
)
{
rpcRsp
.
code
=
TSDB_CODE_INVALID_USER
;
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
71607ccb
...
...
@@ -142,7 +142,7 @@ static void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) {
return
;
}
if
(
mpeerCheckRedirect
(
rpcMsg
->
handle
))
{
if
(
mpeerCheckRedirect
())
{
// rpcSendRedirectRsp(rpcMsg->handle, mgmtGetMnodeIpListForRedirect());
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_NO_MASTER
);
rpcFreeCont
(
rpcMsg
->
pCont
);
...
...
src/
plugins/http
/inc/cJSON.h
→
src/
util
/inc/cJSON.h
浏览文件 @
71607ccb
文件已移动
src/
plugins/http
/src/cJSON.c
→
src/
util
/src/cJSON.c
浏览文件 @
71607ccb
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录