Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
04ea2358
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
04ea2358
编写于
11月 26, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact dnode
上级
19865f3b
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
215 addition
and
249 deletion
+215
-249
include/common/tglobal.h
include/common/tglobal.h
+0
-4
include/dnode/mnode/mnode.h
include/dnode/mnode/mnode.h
+1
-1
include/dnode/vnode/vnode.h
include/dnode/vnode/vnode.h
+1
-1
include/util/tdef.h
include/util/tdef.h
+0
-6
source/common/src/tglobal.c
source/common/src/tglobal.c
+0
-9
source/dnode/mgmt/impl/inc/dndDnode.h
source/dnode/mgmt/impl/inc/dndDnode.h
+1
-1
source/dnode/mgmt/impl/inc/dndInt.h
source/dnode/mgmt/impl/inc/dndInt.h
+13
-13
source/dnode/mgmt/impl/src/dndDnode.c
source/dnode/mgmt/impl/src/dndDnode.c
+198
-213
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+1
-1
未找到文件。
include/common/tglobal.h
浏览文件 @
04ea2358
...
@@ -28,10 +28,6 @@ extern char tsSecond[];
...
@@ -28,10 +28,6 @@ extern char tsSecond[];
extern
char
tsLocalFqdn
[];
extern
char
tsLocalFqdn
[];
extern
char
tsLocalEp
[];
extern
char
tsLocalEp
[];
extern
uint16_t
tsServerPort
;
extern
uint16_t
tsServerPort
;
extern
uint16_t
tsDnodeShellPort
;
extern
uint16_t
tsDnodeDnodePort
;
extern
uint16_t
tsSyncPort
;
extern
uint16_t
tsArbitratorPort
;
extern
int32_t
tsStatusInterval
;
extern
int32_t
tsStatusInterval
;
extern
int32_t
tsNumOfMnodes
;
extern
int32_t
tsNumOfMnodes
;
extern
int8_t
tsEnableVnodeBak
;
extern
int8_t
tsEnableVnodeBak
;
...
...
include/dnode/mnode/mnode.h
浏览文件 @
04ea2358
...
@@ -26,7 +26,7 @@ typedef struct SMnode SMnode;
...
@@ -26,7 +26,7 @@ typedef struct SMnode SMnode;
typedef
struct
SMnodeMsg
SMnodeMsg
;
typedef
struct
SMnodeMsg
SMnodeMsg
;
typedef
void
(
*
SendMsgToDnodeFp
)(
SDnode
*
pDnd
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendMsgToDnodeFp
)(
SDnode
*
pDnd
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendMsgToMnodeFp
)(
SDnode
*
pDnd
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendMsgToMnodeFp
)(
SDnode
*
pDnd
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendRedirectMsgFp
)(
SDnode
*
pDnd
,
struct
SRpcMsg
*
rpcMsg
,
bool
forShell
);
typedef
void
(
*
SendRedirectMsgFp
)(
SDnode
*
pDnd
,
struct
SRpcMsg
*
rpcMsg
);
typedef
int32_t
(
*
PutMsgToMnodeQFp
)(
SDnode
*
pDnd
,
SMnodeMsg
*
pMsg
);
typedef
int32_t
(
*
PutMsgToMnodeQFp
)(
SDnode
*
pDnd
,
SMnodeMsg
*
pMsg
);
typedef
struct
SMnodeLoad
{
typedef
struct
SMnodeLoad
{
...
...
include/dnode/vnode/vnode.h
浏览文件 @
04ea2358
...
@@ -187,7 +187,7 @@ typedef struct {
...
@@ -187,7 +187,7 @@ typedef struct {
typedef
struct
SDnode
SDnode
;
typedef
struct
SDnode
SDnode
;
typedef
void
(
*
SendMsgToDnodeFp
)(
SDnode
*
pDnd
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendMsgToDnodeFp
)(
SDnode
*
pDnd
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendMsgToMnodeFp
)(
SDnode
*
pDnd
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendMsgToMnodeFp
)(
SDnode
*
pDnd
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendRedirectMsgFp
)(
SDnode
*
pDnd
,
struct
SRpcMsg
*
rpcMsg
,
bool
forShell
);
typedef
void
(
*
SendRedirectMsgFp
)(
SDnode
*
pDnd
,
struct
SRpcMsg
*
rpcMsg
);
typedef
int32_t
(
*
PutMsgToVnodeQFp
)(
SDnode
*
pDnd
,
int32_t
vgId
,
SVnodeMsg
*
pMsg
);
typedef
int32_t
(
*
PutMsgToVnodeQFp
)(
SDnode
*
pDnd
,
int32_t
vgId
,
SVnodeMsg
*
pMsg
);
typedef
struct
{
typedef
struct
{
...
...
include/util/tdef.h
浏览文件 @
04ea2358
...
@@ -358,12 +358,6 @@ do { \
...
@@ -358,12 +358,6 @@ do { \
#define TSDB_DEFAULT_STABLES_HASH_SIZE 100
#define TSDB_DEFAULT_STABLES_HASH_SIZE 100
#define TSDB_DEFAULT_CTABLES_HASH_SIZE 20000
#define TSDB_DEFAULT_CTABLES_HASH_SIZE 20000
#define TSDB_PORT_DNODESHELL 0
#define TSDB_PORT_DNODEDNODE 5
#define TSDB_PORT_SYNC 10
#define TSDB_PORT_HTTP 11
#define TSDB_PORT_ARBITRATOR 12
#define TSDB_MAX_WAL_SIZE (1024*1024*3)
#define TSDB_MAX_WAL_SIZE (1024*1024*3)
#define TSDB_ARB_DUMMY_TIME 4765104000000 // 2121-01-01 00:00:00.000, :P
#define TSDB_ARB_DUMMY_TIME 4765104000000 // 2121-01-01 00:00:00.000, :P
...
...
source/common/src/tglobal.c
浏览文件 @
04ea2358
...
@@ -33,10 +33,6 @@ char tsArbitrator[TSDB_EP_LEN] = {0};
...
@@ -33,10 +33,6 @@ char tsArbitrator[TSDB_EP_LEN] = {0};
char
tsLocalFqdn
[
TSDB_FQDN_LEN
]
=
{
0
};
char
tsLocalFqdn
[
TSDB_FQDN_LEN
]
=
{
0
};
char
tsLocalEp
[
TSDB_EP_LEN
]
=
{
0
};
// Local End Point, hostname:port
char
tsLocalEp
[
TSDB_EP_LEN
]
=
{
0
};
// Local End Point, hostname:port
uint16_t
tsServerPort
=
6030
;
uint16_t
tsServerPort
=
6030
;
uint16_t
tsDnodeShellPort
=
6030
;
// udp[6035-6039] tcp[6035]
uint16_t
tsDnodeDnodePort
=
6035
;
// udp/tcp
uint16_t
tsSyncPort
=
6040
;
uint16_t
tsArbitratorPort
=
6042
;
int32_t
tsStatusInterval
=
1
;
// second
int32_t
tsStatusInterval
=
1
;
// second
int32_t
tsNumOfMnodes
=
1
;
int32_t
tsNumOfMnodes
=
1
;
int8_t
tsEnableVnodeBak
=
1
;
int8_t
tsEnableVnodeBak
=
1
;
...
@@ -1726,11 +1722,6 @@ int32_t taosCheckGlobalCfg() {
...
@@ -1726,11 +1722,6 @@ int32_t taosCheckGlobalCfg() {
}
}
}
}
tsDnodeShellPort
=
tsServerPort
+
TSDB_PORT_DNODESHELL
;
// udp[6035-6039] tcp[6035]
tsDnodeDnodePort
=
tsServerPort
+
TSDB_PORT_DNODEDNODE
;
// udp/tcp
tsSyncPort
=
tsServerPort
+
TSDB_PORT_SYNC
;
tsHttpPort
=
tsServerPort
+
TSDB_PORT_HTTP
;
if
(
tsQueryBufferSize
>=
0
)
{
if
(
tsQueryBufferSize
>=
0
)
{
tsQueryBufferSizeBytes
=
tsQueryBufferSize
*
1048576UL
;
tsQueryBufferSizeBytes
=
tsQueryBufferSize
*
1048576UL
;
}
}
...
...
source/dnode/mgmt/impl/inc/dndDnode.h
浏览文件 @
04ea2358
...
@@ -30,7 +30,7 @@ int32_t dndGetDnodeId(SDnode *pDnd);
...
@@ -30,7 +30,7 @@ int32_t dndGetDnodeId(SDnode *pDnd);
int64_t
dndGetClusterId
(
SDnode
*
pDnd
);
int64_t
dndGetClusterId
(
SDnode
*
pDnd
);
void
dndGetDnodeEp
(
SDnode
*
pDnd
,
int32_t
dnodeId
,
char
*
pEp
,
char
*
pFqdn
,
uint16_t
*
pPort
);
void
dndGetDnodeEp
(
SDnode
*
pDnd
,
int32_t
dnodeId
,
char
*
pEp
,
char
*
pFqdn
,
uint16_t
*
pPort
);
void
dndGetMnodeEpSet
(
SDnode
*
pDnd
,
SEpSet
*
pEpSet
);
void
dndGetMnodeEpSet
(
SDnode
*
pDnd
,
SEpSet
*
pEpSet
);
void
dndSendRedirectMsg
(
SDnode
*
pDnd
,
SRpcMsg
*
pMsg
,
bool
forShell
);
void
dndSendRedirectMsg
(
SDnode
*
pDnd
,
SRpcMsg
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mgmt/impl/inc/dndInt.h
浏览文件 @
04ea2358
...
@@ -31,9 +31,10 @@ extern "C" {
...
@@ -31,9 +31,10 @@ extern "C" {
#include "tthread.h"
#include "tthread.h"
#include "ttime.h"
#include "ttime.h"
#include "tworker.h"
#include "tworker.h"
#include "dnode.h"
#include "mnode.h"
#include "mnode.h"
#include "vnode.h"
#include "vnode.h"
#include "dnode.h"
extern
int32_t
dDebugFlag
;
extern
int32_t
dDebugFlag
;
...
@@ -55,16 +56,15 @@ typedef struct {
...
@@ -55,16 +56,15 @@ typedef struct {
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
uint32_t
rebootTime
;
int32_t
dropped
;
int32_t
dropped
;
uint32_t
rebootTime
;
int64_t
clusterId
;
int64_t
clusterId
;
SEpSet
shellEpSet
;
SEpSet
mnodeEpSet
;
SEpSet
peerEpSet
;
char
*
file
;
char
*
file
;
SHashObj
*
dnodeHash
;
SHashObj
*
dnodeHash
;
SDnodeEps
*
dnodeEps
;
SDnodeEps
*
dnodeEps
;
pthread_t
*
threadId
;
pthread_t
*
threadId
;
pthread_mutex_t
mutex
;
SRWLatch
latch
;
}
SDnodeMgmt
;
}
SDnodeMgmt
;
typedef
struct
{
typedef
struct
{
...
@@ -108,7 +108,7 @@ typedef struct SDnode {
...
@@ -108,7 +108,7 @@ typedef struct SDnode {
EStat
stat
;
EStat
stat
;
SDnodeOpt
opt
;
SDnodeOpt
opt
;
SDnodeDir
dir
;
SDnodeDir
dir
;
SDnodeMgmt
d
;
SDnodeMgmt
d
mgmt
;
SMnodeMgmt
m
;
SMnodeMgmt
m
;
SVnodesMgmt
vmgmt
;
SVnodesMgmt
vmgmt
;
STransMgmt
t
;
STransMgmt
t
;
...
...
source/dnode/mgmt/impl/src/dndDnode.c
浏览文件 @
04ea2358
...
@@ -18,28 +18,32 @@
...
@@ -18,28 +18,32 @@
#include "dndTransport.h"
#include "dndTransport.h"
#include "dndVnodes.h"
#include "dndVnodes.h"
static
inline
void
dnd
LockDnode
(
SDnode
*
pDnd
)
{
pthread_mutex_lock
(
&
pDnd
->
d
.
mutex
);
}
static
inline
void
dnd
RLockDnode
(
SDnode
*
pDnode
)
{
taosRLockLatch
(
&
pDnode
->
dmgmt
.
latch
);
}
static
inline
void
dnd
UnLockDnode
(
SDnode
*
pDnd
)
{
pthread_mutex_unlock
(
&
pDnd
->
d
.
mutex
);
}
static
inline
void
dnd
RUnLockDnode
(
SDnode
*
pDnode
)
{
taosRUnLockLatch
(
&
pDnode
->
dmgmt
.
latch
);
}
int32_t
dndGetDnodeId
(
SDnode
*
pDnd
)
{
static
inline
void
dndWLockDnode
(
SDnode
*
pDnode
)
{
taosWLockLatch
(
&
pDnode
->
dmgmt
.
latch
);
}
dndLockDnode
(
pDnd
);
int32_t
dnodeId
=
pDnd
->
d
.
dnodeId
;
static
inline
void
dndWUnLockDnode
(
SDnode
*
pDnode
)
{
taosWUnLockLatch
(
&
pDnode
->
dmgmt
.
latch
);
}
dndUnLockDnode
(
pDnd
);
int32_t
dndGetDnodeId
(
SDnode
*
pDnode
)
{
dndRLockDnode
(
pDnode
);
int32_t
dnodeId
=
pDnode
->
dmgmt
.
dnodeId
;
dndRUnLockDnode
(
pDnode
);
return
dnodeId
;
return
dnodeId
;
}
}
int64_t
dndGetClusterId
(
SDnode
*
pDn
d
)
{
int64_t
dndGetClusterId
(
SDnode
*
pDn
ode
)
{
dnd
LockDnode
(
pDnd
);
dnd
RLockDnode
(
pDnode
);
int64_t
clusterId
=
pDn
d
->
d
.
clusterId
;
int64_t
clusterId
=
pDn
ode
->
dmgmt
.
clusterId
;
dnd
UnLockDnode
(
pDnd
);
dnd
RUnLockDnode
(
pDnode
);
return
clusterId
;
return
clusterId
;
}
}
void
dndGetDnodeEp
(
SDnode
*
pDn
d
,
int32_t
dnodeId
,
char
*
pEp
,
char
*
pFqdn
,
uint16_t
*
pPort
)
{
void
dndGetDnodeEp
(
SDnode
*
pDn
ode
,
int32_t
dnodeId
,
char
*
pEp
,
char
*
pFqdn
,
uint16_t
*
pPort
)
{
dnd
LockDnode
(
pDnd
);
dnd
RLockDnode
(
pDnode
);
SDnodeEp
*
pDnodeEp
=
taosHashGet
(
pDn
d
->
d
.
dnodeHash
,
&
dnodeId
,
sizeof
(
int32_t
));
SDnodeEp
*
pDnodeEp
=
taosHashGet
(
pDn
ode
->
dmgmt
.
dnodeHash
,
&
dnodeId
,
sizeof
(
int32_t
));
if
(
pDnodeEp
!=
NULL
)
{
if
(
pDnodeEp
!=
NULL
)
{
if
(
pPort
!=
NULL
)
{
if
(
pPort
!=
NULL
)
{
*
pPort
=
pDnodeEp
->
port
;
*
pPort
=
pDnodeEp
->
port
;
...
@@ -52,41 +56,26 @@ void dndGetDnodeEp(SDnode *pDnd, int32_t dnodeId, char *pEp, char *pFqdn, uint16
...
@@ -52,41 +56,26 @@ void dndGetDnodeEp(SDnode *pDnd, int32_t dnodeId, char *pEp, char *pFqdn, uint16
}
}
}
}
dndUnLockDnode
(
pDnd
);
dndRUnLockDnode
(
pDnode
);
}
void
dndGetMnodeEpSet
(
SDnode
*
pDnd
,
SEpSet
*
pEpSet
)
{
dndLockDnode
(
pDnd
);
*
pEpSet
=
pDnd
->
d
.
peerEpSet
;
dndUnLockDnode
(
pDnd
);
}
}
void
dndGet
ShellEpSet
(
SDnode
*
pDnd
,
SEpSet
*
pEpSet
)
{
void
dndGet
MnodeEpSet
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
)
{
dnd
LockDnode
(
pDnd
);
dnd
RLockDnode
(
pDnode
);
*
pEpSet
=
pDn
d
->
d
.
shell
EpSet
;
*
pEpSet
=
pDn
ode
->
dmgmt
.
mnode
EpSet
;
dnd
UnLockDnode
(
pDnd
);
dnd
RUnLockDnode
(
pDnode
);
}
}
void
dndSendRedirectMsg
(
SDnode
*
pDn
d
,
SRpcMsg
*
pMsg
,
bool
forShell
)
{
void
dndSendRedirectMsg
(
SDnode
*
pDn
ode
,
SRpcMsg
*
pMsg
)
{
int32_t
msgType
=
pMsg
->
msgType
;
int32_t
msgType
=
pMsg
->
msgType
;
SEpSet
epSet
=
{
0
};
SEpSet
epSet
=
{
0
};
if
(
forShell
)
{
dndGetMnodeEpSet
(
pDnode
,
&
epSet
);
dndGetShellEpSet
(
pDnd
,
&
epSet
);
}
else
{
dndGetMnodeEpSet
(
pDnd
,
&
epSet
);
}
dDebug
(
"RPC %p, msg:%s is redirected, num:%d use:%d"
,
pMsg
->
handle
,
taosMsg
[
msgType
],
epSet
.
numOfEps
,
epSet
.
inUse
);
dDebug
(
"RPC %p, msg:%s is redirected, num:%d inUse:%d"
,
pMsg
->
handle
,
taosMsg
[
msgType
],
epSet
.
numOfEps
,
epSet
.
inUse
);
for
(
int32_t
i
=
0
;
i
<
epSet
.
numOfEps
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
epSet
.
numOfEps
;
++
i
)
{
dDebug
(
"mnode index:%d %s:%u"
,
i
,
epSet
.
fqdn
[
i
],
epSet
.
port
[
i
]);
dDebug
(
"mnode index:%d %s:%u"
,
i
,
epSet
.
fqdn
[
i
],
epSet
.
port
[
i
]);
if
(
strcmp
(
epSet
.
fqdn
[
i
],
pDnd
->
opt
.
localFqdn
)
==
0
)
{
if
(
strcmp
(
epSet
.
fqdn
[
i
],
pDnode
->
opt
.
localFqdn
)
==
0
&&
epSet
.
port
[
i
]
==
pDnode
->
opt
.
serverPort
)
{
if
((
epSet
.
port
[
i
]
==
pDnd
->
opt
.
serverPort
+
TSDB_PORT_DNODEDNODE
&&
!
forShell
)
||
(
epSet
.
port
[
i
]
==
pDnd
->
opt
.
serverPort
&&
forShell
))
{
epSet
.
inUse
=
(
i
+
1
)
%
epSet
.
numOfEps
;
epSet
.
inUse
=
(
i
+
1
)
%
epSet
.
numOfEps
;
dDebug
(
"mnode index:%d %s:%d set inUse to %d"
,
i
,
epSet
.
fqdn
[
i
],
epSet
.
port
[
i
],
epSet
.
inUse
);
}
}
}
epSet
.
port
[
i
]
=
htons
(
epSet
.
port
[
i
]);
epSet
.
port
[
i
]
=
htons
(
epSet
.
port
[
i
]);
...
@@ -96,220 +85,218 @@ void dndSendRedirectMsg(SDnode *pDnd, SRpcMsg *pMsg, bool forShell) {
...
@@ -96,220 +85,218 @@ void dndSendRedirectMsg(SDnode *pDnd, SRpcMsg *pMsg, bool forShell) {
}
}
static
void
dndUpdateMnodeEpSet
(
SDnode
*
pDnd
,
SEpSet
*
pEpSet
)
{
static
void
dndUpdateMnodeEpSet
(
SDnode
*
pDnd
,
SEpSet
*
pEpSet
)
{
dInfo
(
"mnode is changed, num:%d
u
se:%d"
,
pEpSet
->
numOfEps
,
pEpSet
->
inUse
);
dInfo
(
"mnode is changed, num:%d
inU
se:%d"
,
pEpSet
->
numOfEps
,
pEpSet
->
inUse
);
dndLockDnode
(
pDnd
);
dnd
W
LockDnode
(
pDnd
);
pDnd
->
d
.
peer
EpSet
=
*
pEpSet
;
pDnd
->
d
mgmt
.
mnode
EpSet
=
*
pEpSet
;
for
(
int32_t
i
=
0
;
i
<
pEpSet
->
numOfEps
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pEpSet
->
numOfEps
;
++
i
)
{
pEpSet
->
port
[
i
]
-=
TSDB_PORT_DNODEDNODE
;
dInfo
(
"mnode index:%d %s:%u"
,
i
,
pEpSet
->
fqdn
[
i
],
pEpSet
->
port
[
i
]);
dInfo
(
"mnode index:%d %s:%u"
,
i
,
pEpSet
->
fqdn
[
i
],
pEpSet
->
port
[
i
]);
}
}
pDnd
->
d
.
shellEpSet
=
*
pEpSet
;
dndUnLockDnode
(
pDnd
);
dnd
W
UnLockDnode
(
pDnd
);
}
}
static
void
dndPrintDnodes
(
SDnode
*
pDn
d
)
{
static
void
dndPrintDnodes
(
SDnode
*
pDn
ode
)
{
SDnodeMgmt
*
p
Dnode
=
&
pDnd
->
d
;
SDnodeMgmt
*
p
Mgmt
=
&
pDnode
->
dmgmt
;
dDebug
(
"print dnode e
ndpoint list, num:%d"
,
pDnode
->
dnodeEps
->
num
);
dDebug
(
"print dnode e
p list, num:%d"
,
pMgmt
->
dnodeEps
->
num
);
for
(
int32_t
i
=
0
;
i
<
p
Dnode
->
dnodeEps
->
num
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
p
Mgmt
->
dnodeEps
->
num
;
i
++
)
{
SDnodeEp
*
pEp
=
&
p
Dnode
->
dnodeEps
->
eps
[
i
];
SDnodeEp
*
pEp
=
&
p
Mgmt
->
dnodeEps
->
eps
[
i
];
dDebug
(
"dnode:%d, fqdn:%s port:%u isMnode:%d"
,
pEp
->
id
,
pEp
->
fqdn
,
pEp
->
port
,
pEp
->
isMnode
);
dDebug
(
"dnode:%d, fqdn:%s port:%u isMnode:%d"
,
pEp
->
id
,
pEp
->
fqdn
,
pEp
->
port
,
pEp
->
isMnode
);
}
}
}
}
static
void
dndResetDnodes
(
SDnode
*
pDn
d
,
SDnodeEps
*
pDnodeEps
)
{
static
void
dndResetDnodes
(
SDnode
*
pDn
ode
,
SDnodeEps
*
pDnodeEps
)
{
SDnodeMgmt
*
p
Dnode
=
&
pDnd
->
d
;
SDnodeMgmt
*
p
Mgmt
=
&
pDnode
->
dmgmt
;
int32_t
size
=
sizeof
(
SDnodeEps
)
+
pDnodeEps
->
num
*
sizeof
(
SDnodeEp
);
int32_t
size
=
sizeof
(
SDnodeEps
)
+
pDnodeEps
->
num
*
sizeof
(
SDnodeEp
);
if
(
pDnodeEps
->
num
>
pMgmt
->
dnodeEps
->
num
)
{
if
(
pDnodeEps
->
num
>
pDnode
->
dnodeEps
->
num
)
{
SDnodeEps
*
tmp
=
calloc
(
1
,
size
);
SDnodeEps
*
tmp
=
calloc
(
1
,
size
);
if
(
tmp
==
NULL
)
return
;
if
(
tmp
==
NULL
)
return
;
tfree
(
p
Dnode
->
dnodeEps
);
tfree
(
p
Mgmt
->
dnodeEps
);
p
Dnode
->
dnodeEps
=
tmp
;
p
Mgmt
->
dnodeEps
=
tmp
;
}
}
if
(
p
Dnode
->
dnodeEps
!=
pDnodeEps
)
{
if
(
p
Mgmt
->
dnodeEps
!=
pDnodeEps
)
{
memcpy
(
p
Dnode
->
dnodeEps
,
pDnodeEps
,
size
);
memcpy
(
p
Mgmt
->
dnodeEps
,
pDnodeEps
,
size
);
}
}
pDnode
->
peerEpSet
.
inUse
=
0
;
pMgmt
->
mnodeEpSet
.
inUse
=
0
;
pDnode
->
shellEpSet
.
inUse
=
0
;
int32_t
mIndex
=
0
;
int32_t
mIndex
=
0
;
for
(
int32_t
i
=
0
;
i
<
p
Dnode
->
dnodeEps
->
num
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
p
Mgmt
->
dnodeEps
->
num
;
i
++
)
{
SDnodeEp
*
pDnodeEp
=
&
p
Dnode
->
dnodeEps
->
eps
[
i
];
SDnodeEp
*
pDnodeEp
=
&
p
Mgmt
->
dnodeEps
->
eps
[
i
];
if
(
!
pDnodeEp
->
isMnode
)
continue
;
if
(
!
pDnodeEp
->
isMnode
)
continue
;
if
(
mIndex
>=
TSDB_MAX_REPLICA
)
continue
;
if
(
mIndex
>=
TSDB_MAX_REPLICA
)
continue
;
strcpy
(
pDnode
->
shellEpSet
.
fqdn
[
mIndex
],
pDnodeEp
->
fqdn
);
strcpy
(
pMgmt
->
mnodeEpSet
.
fqdn
[
mIndex
],
pDnodeEp
->
fqdn
);
strcpy
(
pDnode
->
peerEpSet
.
fqdn
[
mIndex
],
pDnodeEp
->
fqdn
);
pMgmt
->
mnodeEpSet
.
port
[
mIndex
]
=
pDnodeEp
->
port
;
pDnode
->
shellEpSet
.
port
[
mIndex
]
=
pDnodeEp
->
port
;
pDnode
->
shellEpSet
.
port
[
mIndex
]
=
pDnodeEp
->
port
+
TSDB_PORT_DNODEDNODE
;
mIndex
++
;
mIndex
++
;
}
}
for
(
int32_t
i
=
0
;
i
<
p
Dnode
->
dnodeEps
->
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
p
Mgmt
->
dnodeEps
->
num
;
++
i
)
{
SDnodeEp
*
pDnodeEp
=
&
p
Dnode
->
dnodeEps
->
eps
[
i
];
SDnodeEp
*
pDnodeEp
=
&
p
Mgmt
->
dnodeEps
->
eps
[
i
];
taosHashPut
(
p
Dnode
->
dnodeHash
,
&
pDnodeEp
->
id
,
sizeof
(
int32_t
),
pDnodeEp
,
sizeof
(
SDnodeEp
));
taosHashPut
(
p
Mgmt
->
dnodeHash
,
&
pDnodeEp
->
id
,
sizeof
(
int32_t
),
pDnodeEp
,
sizeof
(
SDnodeEp
));
}
}
dndPrintDnodes
(
pDn
d
);
dndPrintDnodes
(
pDn
ode
);
}
}
static
bool
dndIsEpChanged
(
SDnode
*
pDn
d
,
int32_t
dnodeId
)
{
static
bool
dndIsEpChanged
(
SDnode
*
pDn
ode
,
int32_t
dnodeId
,
char
*
pEp
)
{
bool
changed
=
false
;
bool
changed
=
false
;
dnd
LockDnode
(
pDnd
);
dnd
RLockDnode
(
pDnode
);
SDnodeEp
*
pDnodeEp
=
taosHashGet
(
pDn
d
->
d
.
dnodeHash
,
&
dnodeId
,
sizeof
(
int32_t
));
SDnodeEp
*
pDnodeEp
=
taosHashGet
(
pDn
ode
->
dmgmt
.
dnodeHash
,
&
dnodeId
,
sizeof
(
int32_t
));
if
(
pDnodeEp
!=
NULL
)
{
if
(
pDnodeEp
!=
NULL
)
{
char
epstr
[
TSDB_EP_LEN
+
1
];
char
epstr
[
TSDB_EP_LEN
+
1
];
snprintf
(
epstr
,
TSDB_EP_LEN
,
"%s:%u"
,
pDnodeEp
->
fqdn
,
pDnodeEp
->
port
);
snprintf
(
epstr
,
TSDB_EP_LEN
,
"%s:%u"
,
pDnodeEp
->
fqdn
,
pDnodeEp
->
port
);
changed
=
strcmp
(
p
Dnd
->
opt
.
local
Ep
,
epstr
)
!=
0
;
changed
=
strcmp
(
pEp
,
epstr
)
!=
0
;
}
}
dnd
UnLockDnode
(
pDnd
);
dnd
RUnLockDnode
(
pDnode
);
return
changed
;
return
changed
;
}
}
static
int32_t
dndReadDnodes
(
SDnode
*
pDn
d
)
{
static
int32_t
dndReadDnodes
(
SDnode
*
pDn
ode
)
{
SDnodeMgmt
*
p
Dnode
=
&
pDnd
->
d
;
SDnodeMgmt
*
p
Mgmt
=
&
pDnode
->
dmgmt
;
int32_t
code
=
TSDB_CODE_DND_DNODE_READ_FILE_ERROR
;
int32_t
len
=
0
;
int32_t
len
=
0
;
int32_t
maxLen
=
30000
;
int32_t
maxLen
=
30000
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
cJSON
*
root
=
NULL
;
cJSON
*
root
=
NULL
;
FILE
*
fp
=
NULL
;
FILE
*
fp
=
NULL
;
fp
=
fopen
(
pDnode
->
file
,
"r"
);
fp
=
fopen
(
pMgmt
->
file
,
"r"
);
if
(
!
fp
)
{
if
(
fp
==
NULL
)
{
dDebug
(
"file %s not exist"
,
pDnode
->
file
);
dDebug
(
"file %s not exist"
,
pMgmt
->
file
);
code
=
0
;
goto
PRASE_DNODE_OVER
;
goto
PRASE_DNODE_OVER
;
}
}
len
=
(
int32_t
)
fread
(
content
,
1
,
maxLen
,
fp
);
len
=
(
int32_t
)
fread
(
content
,
1
,
maxLen
,
fp
);
if
(
len
<=
0
)
{
if
(
len
<=
0
)
{
dError
(
"failed to read %s since content is null"
,
p
Dnode
->
file
);
dError
(
"failed to read %s since content is null"
,
p
Mgmt
->
file
);
goto
PRASE_DNODE_OVER
;
goto
PRASE_DNODE_OVER
;
}
}
content
[
len
]
=
0
;
content
[
len
]
=
0
;
root
=
cJSON_Parse
(
content
);
root
=
cJSON_Parse
(
content
);
if
(
root
==
NULL
)
{
if
(
root
==
NULL
)
{
dError
(
"failed to read %s since invalid json format"
,
p
Dnode
->
file
);
dError
(
"failed to read %s since invalid json format"
,
p
Mgmt
->
file
);
goto
PRASE_DNODE_OVER
;
goto
PRASE_DNODE_OVER
;
}
}
cJSON
*
dnodeId
=
cJSON_GetObjectItem
(
root
,
"dnodeId"
);
cJSON
*
dnodeId
=
cJSON_GetObjectItem
(
root
,
"dnodeId"
);
if
(
!
dnodeId
||
dnodeId
->
type
!=
cJSON_String
)
{
if
(
!
dnodeId
||
dnodeId
->
type
!=
cJSON_String
)
{
dError
(
"failed to read %s since dnodeId not found"
,
p
Dnode
->
file
);
dError
(
"failed to read %s since dnodeId not found"
,
p
Mgmt
->
file
);
goto
PRASE_DNODE_OVER
;
goto
PRASE_DNODE_OVER
;
}
}
p
Dnode
->
dnodeId
=
atoi
(
dnodeId
->
valuestring
);
p
Mgmt
->
dnodeId
=
atoi
(
dnodeId
->
valuestring
);
cJSON
*
clusterId
=
cJSON_GetObjectItem
(
root
,
"clusterId"
);
cJSON
*
clusterId
=
cJSON_GetObjectItem
(
root
,
"clusterId"
);
if
(
!
clusterId
||
clusterId
->
type
!=
cJSON_String
)
{
if
(
!
clusterId
||
clusterId
->
type
!=
cJSON_String
)
{
dError
(
"failed to read %s since clusterId not found"
,
p
Dnode
->
file
);
dError
(
"failed to read %s since clusterId not found"
,
p
Mgmt
->
file
);
goto
PRASE_DNODE_OVER
;
goto
PRASE_DNODE_OVER
;
}
}
p
Dnode
->
clusterId
=
atoll
(
clusterId
->
valuestring
);
p
Mgmt
->
clusterId
=
atoll
(
clusterId
->
valuestring
);
cJSON
*
dropped
=
cJSON_GetObjectItem
(
root
,
"dropped"
);
cJSON
*
dropped
=
cJSON_GetObjectItem
(
root
,
"dropped"
);
if
(
!
dropped
||
dropped
->
type
!=
cJSON_String
)
{
if
(
!
dropped
||
dropped
->
type
!=
cJSON_String
)
{
dError
(
"failed to read %s since dropped not found"
,
p
Dnode
->
file
);
dError
(
"failed to read %s since dropped not found"
,
p
Mgmt
->
file
);
goto
PRASE_DNODE_OVER
;
goto
PRASE_DNODE_OVER
;
}
}
p
Dnode
->
dropped
=
atoi
(
dropped
->
valuestring
);
p
Mgmt
->
dropped
=
atoi
(
dropped
->
valuestring
);
cJSON
*
dnodeInfos
=
cJSON_GetObjectItem
(
root
,
"dnodeInfos"
);
cJSON
*
dnodeInfos
=
cJSON_GetObjectItem
(
root
,
"dnodeInfos"
);
if
(
!
dnodeInfos
||
dnodeInfos
->
type
!=
cJSON_Array
)
{
if
(
!
dnodeInfos
||
dnodeInfos
->
type
!=
cJSON_Array
)
{
dError
(
"failed to read %s since dnodeInfos not found"
,
p
Dnode
->
file
);
dError
(
"failed to read %s since dnodeInfos not found"
,
p
Mgmt
->
file
);
goto
PRASE_DNODE_OVER
;
goto
PRASE_DNODE_OVER
;
}
}
int32_t
dnodeInfosSize
=
cJSON_GetArraySize
(
dnodeInfos
);
int32_t
dnodeInfosSize
=
cJSON_GetArraySize
(
dnodeInfos
);
if
(
dnodeInfosSize
<=
0
)
{
if
(
dnodeInfosSize
<=
0
)
{
dError
(
"failed to read %s since dnodeInfos size:%d invalid"
,
p
Dnode
->
file
,
dnodeInfosSize
);
dError
(
"failed to read %s since dnodeInfos size:%d invalid"
,
p
Mgmt
->
file
,
dnodeInfosSize
);
goto
PRASE_DNODE_OVER
;
goto
PRASE_DNODE_OVER
;
}
}
p
Dnode
->
dnodeEps
=
calloc
(
1
,
dnodeInfosSize
*
sizeof
(
SDnodeEp
)
+
sizeof
(
SDnodeEps
));
p
Mgmt
->
dnodeEps
=
calloc
(
1
,
dnodeInfosSize
*
sizeof
(
SDnodeEp
)
+
sizeof
(
SDnodeEps
));
if
(
p
Dnode
->
dnodeEps
==
NULL
)
{
if
(
p
Mgmt
->
dnodeEps
==
NULL
)
{
dError
(
"failed to calloc dnodeEpList since %s"
,
strerror
(
errno
));
dError
(
"failed to calloc dnodeEpList since %s"
,
strerror
(
errno
));
goto
PRASE_DNODE_OVER
;
goto
PRASE_DNODE_OVER
;
}
}
p
Dnode
->
dnodeEps
->
num
=
dnodeInfosSize
;
p
Mgmt
->
dnodeEps
->
num
=
dnodeInfosSize
;
for
(
int32_t
i
=
0
;
i
<
dnodeInfosSize
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
dnodeInfosSize
;
++
i
)
{
cJSON
*
dnodeInfo
=
cJSON_GetArrayItem
(
dnodeInfos
,
i
);
cJSON
*
dnodeInfo
=
cJSON_GetArrayItem
(
dnodeInfos
,
i
);
if
(
dnodeInfo
==
NULL
)
break
;
if
(
dnodeInfo
==
NULL
)
break
;
SDnodeEp
*
pDnodeEp
=
&
p
Dnode
->
dnodeEps
->
eps
[
i
];
SDnodeEp
*
pDnodeEp
=
&
p
Mgmt
->
dnodeEps
->
eps
[
i
];
cJSON
*
dnodeId
=
cJSON_GetObjectItem
(
dnodeInfo
,
"dnodeId"
);
cJSON
*
dnodeId
=
cJSON_GetObjectItem
(
dnodeInfo
,
"dnodeId"
);
if
(
!
dnodeId
||
dnodeId
->
type
!=
cJSON_String
)
{
if
(
!
dnodeId
||
dnodeId
->
type
!=
cJSON_String
)
{
dError
(
"failed to read %s, dnodeId not found"
,
p
Dnode
->
file
);
dError
(
"failed to read %s, dnodeId not found"
,
p
Mgmt
->
file
);
goto
PRASE_DNODE_OVER
;
goto
PRASE_DNODE_OVER
;
}
}
pDnodeEp
->
id
=
atoi
(
dnodeId
->
valuestring
);
pDnodeEp
->
id
=
atoi
(
dnodeId
->
valuestring
);
cJSON
*
isMnode
=
cJSON_GetObjectItem
(
dnodeInfo
,
"isMnode"
);
cJSON
*
isMnode
=
cJSON_GetObjectItem
(
dnodeInfo
,
"isMnode"
);
if
(
!
isMnode
||
isMnode
->
type
!=
cJSON_String
)
{
if
(
!
isMnode
||
isMnode
->
type
!=
cJSON_String
)
{
dError
(
"failed to read %s, isMnode not found"
,
p
Dnode
->
file
);
dError
(
"failed to read %s, isMnode not found"
,
p
Mgmt
->
file
);
goto
PRASE_DNODE_OVER
;
goto
PRASE_DNODE_OVER
;
}
}
pDnodeEp
->
isMnode
=
atoi
(
isMnode
->
valuestring
);
pDnodeEp
->
isMnode
=
atoi
(
isMnode
->
valuestring
);
cJSON
*
dnodeFqdn
=
cJSON_GetObjectItem
(
dnodeInfo
,
"dnodeFqdn"
);
cJSON
*
dnodeFqdn
=
cJSON_GetObjectItem
(
dnodeInfo
,
"dnodeFqdn"
);
if
(
!
dnodeFqdn
||
dnodeFqdn
->
type
!=
cJSON_String
||
dnodeFqdn
->
valuestring
==
NULL
)
{
if
(
!
dnodeFqdn
||
dnodeFqdn
->
type
!=
cJSON_String
||
dnodeFqdn
->
valuestring
==
NULL
)
{
dError
(
"failed to read %s, dnodeFqdn not found"
,
p
Dnode
->
file
);
dError
(
"failed to read %s, dnodeFqdn not found"
,
p
Mgmt
->
file
);
goto
PRASE_DNODE_OVER
;
goto
PRASE_DNODE_OVER
;
}
}
tstrncpy
(
pDnodeEp
->
fqdn
,
dnodeFqdn
->
valuestring
,
TSDB_FQDN_LEN
);
tstrncpy
(
pDnodeEp
->
fqdn
,
dnodeFqdn
->
valuestring
,
TSDB_FQDN_LEN
);
cJSON
*
dnodePort
=
cJSON_GetObjectItem
(
dnodeInfo
,
"dnodePort"
);
cJSON
*
dnodePort
=
cJSON_GetObjectItem
(
dnodeInfo
,
"dnodePort"
);
if
(
!
dnodePort
||
dnodePort
->
type
!=
cJSON_String
)
{
if
(
!
dnodePort
||
dnodePort
->
type
!=
cJSON_String
)
{
dError
(
"failed to read %s, dnodePort not found"
,
p
Dnode
->
file
);
dError
(
"failed to read %s, dnodePort not found"
,
p
Mgmt
->
file
);
goto
PRASE_DNODE_OVER
;
goto
PRASE_DNODE_OVER
;
}
}
pDnodeEp
->
port
=
atoi
(
dnodePort
->
valuestring
);
pDnodeEp
->
port
=
atoi
(
dnodePort
->
valuestring
);
}
}
dInfo
(
"succcessed to read file %s"
,
pDnode
->
file
);
code
=
0
;
dndPrintDnodes
(
pDnd
);
dInfo
(
"succcessed to read file %s"
,
pMgmt
->
file
);
dndPrintDnodes
(
pDnode
);
PRASE_DNODE_OVER:
PRASE_DNODE_OVER:
if
(
content
!=
NULL
)
free
(
content
);
if
(
content
!=
NULL
)
free
(
content
);
if
(
root
!=
NULL
)
cJSON_Delete
(
root
);
if
(
root
!=
NULL
)
cJSON_Delete
(
root
);
if
(
fp
!=
NULL
)
fclose
(
fp
);
if
(
fp
!=
NULL
)
fclose
(
fp
);
if
(
dndIsEpChanged
(
pDn
d
,
pDnode
->
dnodeId
))
{
if
(
dndIsEpChanged
(
pDn
ode
,
pMgmt
->
dnodeId
,
pDnode
->
opt
.
localEp
))
{
dError
(
"localEp %s different with %s and need reconfigured"
,
pDn
d
->
opt
.
localEp
,
pDnode
->
file
);
dError
(
"localEp %s different with %s and need reconfigured"
,
pDn
ode
->
opt
.
localEp
,
pMgmt
->
file
);
return
-
1
;
return
-
1
;
}
}
if
(
p
Dnode
->
dnodeEps
==
NULL
)
{
if
(
p
Mgmt
->
dnodeEps
==
NULL
)
{
p
Dnode
->
dnodeEps
=
calloc
(
1
,
sizeof
(
SDnodeEps
)
+
sizeof
(
SDnodeEp
));
p
Mgmt
->
dnodeEps
=
calloc
(
1
,
sizeof
(
SDnodeEps
)
+
sizeof
(
SDnodeEp
));
p
Dnode
->
dnodeEps
->
num
=
1
;
p
Mgmt
->
dnodeEps
->
num
=
1
;
p
Dnode
->
dnodeEps
->
eps
[
0
].
port
=
pDnd
->
opt
.
serverPort
;
p
Mgmt
->
dnodeEps
->
eps
[
0
].
port
=
pDnode
->
opt
.
serverPort
;
tstrncpy
(
p
Dnode
->
dnodeEps
->
eps
[
0
].
fqdn
,
pDnd
->
opt
.
localFqdn
,
TSDB_FQDN_LEN
);
tstrncpy
(
p
Mgmt
->
dnodeEps
->
eps
[
0
].
fqdn
,
pDnode
->
opt
.
localFqdn
,
TSDB_FQDN_LEN
);
}
}
dndResetDnodes
(
pDn
d
,
pDnode
->
dnodeEps
);
dndResetDnodes
(
pDn
ode
,
pMgmt
->
dnodeEps
);
terrno
=
0
;
terrno
=
0
;
return
0
;
return
0
;
}
}
static
int32_t
dndWriteDnodes
(
SDnode
*
pDn
d
)
{
static
int32_t
dndWriteDnodes
(
SDnode
*
pDn
ode
)
{
SDnodeMgmt
*
p
Dnode
=
&
pDnd
->
d
;
SDnodeMgmt
*
p
Mgmt
=
&
pDnode
->
dmgmt
;
FILE
*
fp
=
fopen
(
pDnode
->
file
,
"w"
);
FILE
*
fp
=
fopen
(
pMgmt
->
file
,
"w"
);
if
(
!
fp
)
{
if
(
fp
==
NULL
)
{
dError
(
"failed to write %s since %s"
,
pDnode
->
file
,
strerror
(
errno
));
dError
(
"failed to write %s since %s"
,
pMgmt
->
file
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
}
}
...
@@ -318,17 +305,17 @@ static int32_t dndWriteDnodes(SDnode *pDnd) {
...
@@ -318,17 +305,17 @@ static int32_t dndWriteDnodes(SDnode *pDnd) {
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dnodeId
\"
:
\"
%d
\"
,
\n
"
,
p
Dnode
->
dnodeId
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dnodeId
\"
:
\"
%d
\"
,
\n
"
,
p
Mgmt
->
dnodeId
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
clusterId
\"
:
\"
%"
PRId64
"
\"
,
\n
"
,
p
Dnode
->
clusterId
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
clusterId
\"
:
\"
%"
PRId64
"
\"
,
\n
"
,
p
Mgmt
->
clusterId
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dropped
\"
:
\"
%d
\"
,
\n
"
,
p
Dnode
->
dropped
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dropped
\"
:
\"
%d
\"
,
\n
"
,
p
Mgmt
->
dropped
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dnodeInfos
\"
: [{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dnodeInfos
\"
: [{
\n
"
);
for
(
int32_t
i
=
0
;
i
<
p
Dnode
->
dnodeEps
->
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
p
Mgmt
->
dnodeEps
->
num
;
++
i
)
{
SDnodeEp
*
pDnodeEp
=
&
p
Dnode
->
dnodeEps
->
eps
[
i
];
SDnodeEp
*
pDnodeEp
=
&
p
Mgmt
->
dnodeEps
->
eps
[
i
];
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dnodeId
\"
:
\"
%d
\"
,
\n
"
,
pDnodeEp
->
id
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dnodeId
\"
:
\"
%d
\"
,
\n
"
,
pDnodeEp
->
id
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
isMnode
\"
:
\"
%d
\"
,
\n
"
,
pDnodeEp
->
isMnode
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
isMnode
\"
:
\"
%d
\"
,
\n
"
,
pDnodeEp
->
isMnode
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dnodeFqdn
\"
:
\"
%s
\"
,
\n
"
,
pDnodeEp
->
fqdn
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dnodeFqdn
\"
:
\"
%s
\"
,
\n
"
,
pDnodeEp
->
fqdn
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dnodePort
\"
:
\"
%u
\"\n
"
,
pDnodeEp
->
port
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dnodePort
\"
:
\"
%u
\"\n
"
,
pDnodeEp
->
port
);
if
(
i
<
p
Dnode
->
dnodeEps
->
num
-
1
)
{
if
(
i
<
p
Mgmt
->
dnodeEps
->
num
-
1
)
{
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
" },{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
" },{
\n
"
);
}
else
{
}
else
{
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
" }]
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
" }]
\n
"
);
...
@@ -342,105 +329,105 @@ static int32_t dndWriteDnodes(SDnode *pDnd) {
...
@@ -342,105 +329,105 @@ static int32_t dndWriteDnodes(SDnode *pDnd) {
free
(
content
);
free
(
content
);
terrno
=
0
;
terrno
=
0
;
dInfo
(
"successed to write %s"
,
p
Dnode
->
file
);
dInfo
(
"successed to write %s"
,
p
Mgmt
->
file
);
return
0
;
return
0
;
}
}
static
void
dndSendStatusMsg
(
SDnode
*
pDn
d
)
{
static
void
dndSendStatusMsg
(
SDnode
*
pDn
ode
)
{
int32_t
contLen
=
sizeof
(
SStatusMsg
)
+
TSDB_MAX_VNODES
*
sizeof
(
SVnodeLoad
);
int32_t
contLen
=
sizeof
(
SStatusMsg
)
+
TSDB_MAX_VNODES
*
sizeof
(
SVnodeLoad
);
SStatusMsg
*
pStatus
=
rpcMallocCont
(
contLen
);
SStatusMsg
*
pStatus
=
rpcMallocCont
(
contLen
);
if
(
pStatus
==
NULL
)
{
if
(
pStatus
==
NULL
)
{
dError
(
"failed to malloc status message"
);
dError
(
"failed to malloc status message"
);
return
;
return
;
}
}
dnd
LockDnode
(
pDnd
);
dnd
RLockDnode
(
pDnode
);
pStatus
->
sversion
=
htonl
(
pDn
d
->
opt
.
sver
);
pStatus
->
sversion
=
htonl
(
pDn
ode
->
opt
.
sver
);
pStatus
->
dnodeId
=
htonl
(
pDn
d
->
d
.
dnodeId
);
pStatus
->
dnodeId
=
htonl
(
pDn
ode
->
dmgmt
.
dnodeId
);
pStatus
->
clusterId
=
htobe64
(
pDn
d
->
d
.
clusterId
);
pStatus
->
clusterId
=
htobe64
(
pDn
ode
->
dmgmt
.
clusterId
);
pStatus
->
rebootTime
=
htonl
(
pDn
d
->
d
.
rebootTime
);
pStatus
->
rebootTime
=
htonl
(
pDn
ode
->
dmgmt
.
rebootTime
);
pStatus
->
numOfCores
=
htonl
(
pDn
d
->
opt
.
numOfCores
);
pStatus
->
numOfCores
=
htonl
(
pDn
ode
->
opt
.
numOfCores
);
tstrncpy
(
pStatus
->
dnodeEp
,
pDn
d
->
opt
.
localEp
,
TSDB_EP_LEN
);
tstrncpy
(
pStatus
->
dnodeEp
,
pDn
ode
->
opt
.
localEp
,
TSDB_EP_LEN
);
pStatus
->
clusterCfg
.
statusInterval
=
htonl
(
pDn
d
->
opt
.
statusInterval
);
pStatus
->
clusterCfg
.
statusInterval
=
htonl
(
pDn
ode
->
opt
.
statusInterval
);
tstrncpy
(
pStatus
->
clusterCfg
.
timezone
,
pDn
d
->
opt
.
timezone
,
TSDB_TIMEZONE_LEN
);
tstrncpy
(
pStatus
->
clusterCfg
.
timezone
,
pDn
ode
->
opt
.
timezone
,
TSDB_TIMEZONE_LEN
);
tstrncpy
(
pStatus
->
clusterCfg
.
locale
,
pDn
d
->
opt
.
locale
,
TSDB_LOCALE_LEN
);
tstrncpy
(
pStatus
->
clusterCfg
.
locale
,
pDn
ode
->
opt
.
locale
,
TSDB_LOCALE_LEN
);
tstrncpy
(
pStatus
->
clusterCfg
.
charset
,
pDn
d
->
opt
.
charset
,
TSDB_LOCALE_LEN
);
tstrncpy
(
pStatus
->
clusterCfg
.
charset
,
pDn
ode
->
opt
.
charset
,
TSDB_LOCALE_LEN
);
pStatus
->
clusterCfg
.
checkTime
=
0
;
pStatus
->
clusterCfg
.
checkTime
=
0
;
char
timestr
[
32
]
=
"1970-01-01 00:00:00.00"
;
char
timestr
[
32
]
=
"1970-01-01 00:00:00.00"
;
(
void
)
taosParseTime
(
timestr
,
&
pStatus
->
clusterCfg
.
checkTime
,
(
int32_t
)
strlen
(
timestr
),
TSDB_TIME_PRECISION_MILLI
,
0
);
(
void
)
taosParseTime
(
timestr
,
&
pStatus
->
clusterCfg
.
checkTime
,
(
int32_t
)
strlen
(
timestr
),
TSDB_TIME_PRECISION_MILLI
,
0
);
dnd
UnLockDnode
(
pDnd
);
dnd
RUnLockDnode
(
pDnode
);
dndGetVnodeLoads
(
pDn
d
,
&
pStatus
->
vnodeLoads
);
dndGetVnodeLoads
(
pDn
ode
,
&
pStatus
->
vnodeLoads
);
contLen
=
sizeof
(
SStatusMsg
)
+
pStatus
->
vnodeLoads
.
num
*
sizeof
(
SVnodeLoad
);
contLen
=
sizeof
(
SStatusMsg
)
+
pStatus
->
vnodeLoads
.
num
*
sizeof
(
SVnodeLoad
);
SRpcMsg
rpcMsg
=
{.
pCont
=
pStatus
,
.
contLen
=
contLen
,
.
msgType
=
TSDB_MSG_TYPE_STATUS
};
SRpcMsg
rpcMsg
=
{.
pCont
=
pStatus
,
.
contLen
=
contLen
,
.
msgType
=
TSDB_MSG_TYPE_STATUS
};
dndSendMsgToMnode
(
pDn
d
,
&
rpcMsg
);
dndSendMsgToMnode
(
pDn
ode
,
&
rpcMsg
);
}
}
static
void
dndUpdateDnodeCfg
(
SDnode
*
pDnd
,
SDnodeCfg
*
pCfg
)
{
static
void
dndUpdateDnodeCfg
(
SDnode
*
pDnode
,
SDnodeCfg
*
pCfg
)
{
SDnodeMgmt
*
pDnode
=
&
pDnd
->
d
;
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
if
(
pDnode
->
dnodeId
!=
0
&&
pDnode
->
dropped
!=
pCfg
->
dropped
)
return
;
if
(
pMgmt
->
dnodeId
==
0
||
pMgmt
->
dropped
!=
pCfg
->
dropped
)
{
dndLockDnode
(
pDnd
);
pDnode
->
dnodeId
=
pCfg
->
dnodeId
;
pDnode
->
clusterId
=
pCfg
->
clusterId
;
pDnode
->
dropped
=
pCfg
->
dropped
;
dInfo
(
"set dnodeId:%d clusterId:%"
PRId64
" dropped:%d"
,
pCfg
->
dnodeId
,
pCfg
->
clusterId
,
pCfg
->
dropped
);
dInfo
(
"set dnodeId:%d clusterId:%"
PRId64
" dropped:%d"
,
pCfg
->
dnodeId
,
pCfg
->
clusterId
,
pCfg
->
dropped
);
dndWriteDnodes
(
pDnd
);
dndWLockDnode
(
pDnode
);
dndUnLockDnode
(
pDnd
);
pMgmt
->
dnodeId
=
pCfg
->
dnodeId
;
pMgmt
->
clusterId
=
pCfg
->
clusterId
;
pMgmt
->
dropped
=
pCfg
->
dropped
;
(
void
)
dndWriteDnodes
(
pDnode
);
dndWUnLockDnode
(
pDnode
);
}
}
}
static
void
dndUpdateDnodeEps
(
SDnode
*
pDn
d
,
SDnodeEps
*
pDnodeEps
)
{
static
void
dndUpdateDnodeEps
(
SDnode
*
pDn
ode
,
SDnodeEps
*
pDnodeEps
)
{
if
(
pDnodeEps
==
NULL
||
pDnodeEps
->
num
<=
0
)
return
;
if
(
pDnodeEps
==
NULL
||
pDnodeEps
->
num
<=
0
)
return
;
dnd
LockDnode
(
pDnd
);
dnd
WLockDnode
(
pDnode
);
if
(
pDnodeEps
->
num
!=
pDn
d
->
d
.
dnodeEps
->
num
)
{
if
(
pDnodeEps
->
num
!=
pDn
ode
->
dmgmt
.
dnodeEps
->
num
)
{
dndResetDnodes
(
pDn
d
,
pDnodeEps
);
dndResetDnodes
(
pDn
ode
,
pDnodeEps
);
dndWriteDnodes
(
pDn
d
);
dndWriteDnodes
(
pDn
ode
);
}
else
{
}
else
{
int32_t
size
=
pDnodeEps
->
num
*
sizeof
(
SDnodeEp
)
+
sizeof
(
SDnodeEps
);
int32_t
size
=
pDnodeEps
->
num
*
sizeof
(
SDnodeEp
)
+
sizeof
(
SDnodeEps
);
if
(
memcmp
(
pDn
d
->
d
.
dnodeEps
,
pDnodeEps
,
size
)
!=
0
)
{
if
(
memcmp
(
pDn
ode
->
dmgmt
.
dnodeEps
,
pDnodeEps
,
size
)
!=
0
)
{
dndResetDnodes
(
pDn
d
,
pDnodeEps
);
dndResetDnodes
(
pDn
ode
,
pDnodeEps
);
dndWriteDnodes
(
pDn
d
);
dndWriteDnodes
(
pDn
ode
);
}
}
}
}
dnd
UnLockDnode
(
pDnd
);
dnd
WUnLockDnode
(
pDnode
);
}
}
static
void
dndProcessStatusRsp
(
SDnode
*
pDn
d
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
static
void
dndProcessStatusRsp
(
SDnode
*
pDn
ode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
if
(
pEpSet
&&
pEpSet
->
numOfEps
>
0
)
{
if
(
pEpSet
&&
pEpSet
->
numOfEps
>
0
)
{
dndUpdateMnodeEpSet
(
pDn
d
,
pEpSet
);
dndUpdateMnodeEpSet
(
pDn
ode
,
pEpSet
);
}
}
if
(
pMsg
->
code
!=
TSDB_CODE_SUCCESS
)
return
;
if
(
pMsg
->
code
!=
TSDB_CODE_SUCCESS
)
return
;
SStatusRsp
*
p
Status
Rsp
=
pMsg
->
pCont
;
SStatusRsp
*
pRsp
=
pMsg
->
pCont
;
SDnodeCfg
*
pCfg
=
&
p
Status
Rsp
->
dnodeCfg
;
SDnodeCfg
*
pCfg
=
&
pRsp
->
dnodeCfg
;
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
pCfg
->
clusterId
=
htobe64
(
pCfg
->
clusterId
);
pCfg
->
clusterId
=
htobe64
(
pCfg
->
clusterId
);
dndUpdateDnodeCfg
(
pDn
d
,
pCfg
);
dndUpdateDnodeCfg
(
pDn
ode
,
pCfg
);
if
(
pCfg
->
dropped
)
return
;
if
(
pCfg
->
dropped
)
return
;
SDnodeEps
*
pDnodeEps
=
&
p
Status
Rsp
->
dnodeEps
;
SDnodeEps
*
pDnodeEps
=
&
pRsp
->
dnodeEps
;
pDnodeEps
->
num
=
htonl
(
pDnodeEps
->
num
);
pDnodeEps
->
num
=
htonl
(
pDnodeEps
->
num
);
for
(
int32_t
i
=
0
;
i
<
pDnodeEps
->
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pDnodeEps
->
num
;
++
i
)
{
pDnodeEps
->
eps
[
i
].
id
=
htonl
(
pDnodeEps
->
eps
[
i
].
id
);
pDnodeEps
->
eps
[
i
].
id
=
htonl
(
pDnodeEps
->
eps
[
i
].
id
);
pDnodeEps
->
eps
[
i
].
port
=
htons
(
pDnodeEps
->
eps
[
i
].
port
);
pDnodeEps
->
eps
[
i
].
port
=
htons
(
pDnodeEps
->
eps
[
i
].
port
);
}
}
dndUpdateDnodeEps
(
pDn
d
,
pDnodeEps
);
dndUpdateDnodeEps
(
pDn
ode
,
pDnodeEps
);
}
}
static
void
dndProcessAuthRsp
(
SDnode
*
pDn
d
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
assert
(
1
);
}
static
void
dndProcessAuthRsp
(
SDnode
*
pDn
ode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
assert
(
1
);
}
static
void
dndProcessGrantRsp
(
SDnode
*
pDn
d
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
assert
(
1
);
}
static
void
dndProcessGrantRsp
(
SDnode
*
pDn
ode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
assert
(
1
);
}
static
void
dndProcessConfigDnodeReq
(
SDnode
*
pDn
d
,
SRpcMsg
*
pMsg
)
{
static
void
dndProcessConfigDnodeReq
(
SDnode
*
pDn
ode
,
SRpcMsg
*
pMsg
)
{
SCfgDnodeMsg
*
pCfg
=
pMsg
->
pCont
;
SCfgDnodeMsg
*
pCfg
=
pMsg
->
pCont
;
int32_t
code
=
TSDB_CODE_OPS_NOT_SUPPORT
;
int32_t
code
=
TSDB_CODE_OPS_NOT_SUPPORT
;
...
@@ -449,11 +436,11 @@ static void dndProcessConfigDnodeReq(SDnode *pDnd, SRpcMsg *pMsg) {
...
@@ -449,11 +436,11 @@ static void dndProcessConfigDnodeReq(SDnode *pDnd, SRpcMsg *pMsg) {
rpcFreeCont
(
pMsg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
}
}
static
void
dndProcessStartupReq
(
SDnode
*
pDn
d
,
SRpcMsg
*
pMsg
)
{
static
void
dndProcessStartupReq
(
SDnode
*
pDn
ode
,
SRpcMsg
*
pMsg
)
{
dInfo
(
"startup msg is received"
);
dInfo
(
"startup msg is received"
);
SStartupMsg
*
pStartup
=
rpcMallocCont
(
sizeof
(
SStartupMsg
));
SStartupMsg
*
pStartup
=
rpcMallocCont
(
sizeof
(
SStartupMsg
));
dndGetStartup
(
pDn
d
,
pStartup
);
dndGetStartup
(
pDn
ode
,
pStartup
);
dInfo
(
"startup msg is sent, step:%s desc:%s finished:%d"
,
pStartup
->
name
,
pStartup
->
desc
,
pStartup
->
finished
);
dInfo
(
"startup msg is sent, step:%s desc:%s finished:%d"
,
pStartup
->
name
,
pStartup
->
desc
,
pStartup
->
finished
);
...
@@ -463,52 +450,52 @@ static void dndProcessStartupReq(SDnode *pDnd, SRpcMsg *pMsg) {
...
@@ -463,52 +450,52 @@ static void dndProcessStartupReq(SDnode *pDnd, SRpcMsg *pMsg) {
}
}
static
void
*
dnodeThreadRoutine
(
void
*
param
)
{
static
void
*
dnodeThreadRoutine
(
void
*
param
)
{
SDnode
*
pDn
d
=
param
;
SDnode
*
pDn
ode
=
param
;
int32_t
ms
=
pDn
d
->
opt
.
statusInterval
*
1000
;
int32_t
ms
=
pDn
ode
->
opt
.
statusInterval
*
1000
;
while
(
true
)
{
while
(
true
)
{
taosMsleep
(
ms
);
taosMsleep
(
ms
);
if
(
dndGetStat
(
pDn
d
)
!=
DND_STAT_RUNNING
)
{
if
(
dndGetStat
(
pDn
ode
)
!=
DND_STAT_RUNNING
)
{
continue
;
continue
;
}
}
pthread_testcancel
();
pthread_testcancel
();
dndSendStatusMsg
(
pDn
d
);
dndSendStatusMsg
(
pDn
ode
);
}
}
}
}
int32_t
dndInitDnode
(
SDnode
*
pDn
d
)
{
int32_t
dndInitDnode
(
SDnode
*
pDn
ode
)
{
SDnodeMgmt
*
p
Dnode
=
&
pDnd
->
d
;
SDnodeMgmt
*
p
Mgmt
=
&
pDnode
->
dmgmt
;
p
Dnode
->
dnodeId
=
0
;
p
Mgmt
->
dnodeId
=
0
;
p
Dnode
->
rebootTime
=
taosGetTimestampSec
();
p
Mgmt
->
rebootTime
=
taosGetTimestampSec
();
p
Dnode
->
dropped
=
0
;
p
Mgmt
->
dropped
=
0
;
p
Dnode
->
clusterId
=
0
;
p
Mgmt
->
clusterId
=
0
;
char
path
[
PATH_MAX
];
char
path
[
PATH_MAX
];
snprintf
(
path
,
PATH_MAX
,
"%s/dnode.json"
,
pDn
d
->
dir
.
dnode
);
snprintf
(
path
,
PATH_MAX
,
"%s/dnode.json"
,
pDn
ode
->
dir
.
dnode
);
p
Dnode
->
file
=
strdup
(
path
);
p
Mgmt
->
file
=
strdup
(
path
);
if
(
p
Dnode
->
file
==
NULL
)
{
if
(
p
Mgmt
->
file
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
p
Dnode
->
dnodeHash
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
p
Mgmt
->
dnodeHash
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
if
(
p
Dnode
->
dnodeHash
==
NULL
)
{
if
(
p
Mgmt
->
dnodeHash
==
NULL
)
{
dError
(
"failed to init dnode hash"
);
dError
(
"failed to init dnode hash"
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
if
(
dndReadDnodes
(
pDn
d
)
!=
0
)
{
if
(
dndReadDnodes
(
pDn
ode
)
!=
0
)
{
dError
(
"failed to read file:%s since %s"
,
p
Dnode
->
file
,
terrstr
());
dError
(
"failed to read file:%s since %s"
,
p
Mgmt
->
file
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
pthread_mutex_init
(
&
pDnode
->
mutex
,
NULL
);
taosInitRWLatch
(
&
pMgmt
->
latch
);
p
Dnode
->
threadId
=
taosCreateThread
(
dnodeThreadRoutine
,
pDnd
);
p
Mgmt
->
threadId
=
taosCreateThread
(
dnodeThreadRoutine
,
pDnode
);
if
(
p
Dnode
->
threadId
==
NULL
)
{
if
(
p
Mgmt
->
threadId
==
NULL
)
{
dError
(
"failed to init dnode thread"
);
dError
(
"failed to init dnode thread"
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
...
@@ -518,44 +505,42 @@ int32_t dndInitDnode(SDnode *pDnd) {
...
@@ -518,44 +505,42 @@ int32_t dndInitDnode(SDnode *pDnd) {
return
0
;
return
0
;
}
}
void
dndCleanupDnode
(
SDnode
*
pDn
d
)
{
void
dndCleanupDnode
(
SDnode
*
pDn
ode
)
{
SDnodeMgmt
*
p
Dnode
=
&
pDnd
->
d
;
SDnodeMgmt
*
p
Mgmt
=
&
pDnode
->
dmgmt
;
if
(
p
Dnode
->
threadId
!=
NULL
)
{
if
(
p
Mgmt
->
threadId
!=
NULL
)
{
taosDestoryThread
(
p
Dnode
->
threadId
);
taosDestoryThread
(
p
Mgmt
->
threadId
);
p
Dnode
->
threadId
=
NULL
;
p
Mgmt
->
threadId
=
NULL
;
}
}
dnd
LockDnode
(
pDnd
);
dnd
WLockDnode
(
pDnode
);
if
(
p
Dnode
->
dnodeEps
!=
NULL
)
{
if
(
p
Mgmt
->
dnodeEps
!=
NULL
)
{
free
(
p
Dnode
->
dnodeEps
);
free
(
p
Mgmt
->
dnodeEps
);
p
Dnode
->
dnodeEps
=
NULL
;
p
Mgmt
->
dnodeEps
=
NULL
;
}
}
if
(
p
Dnode
->
dnodeHash
!=
NULL
)
{
if
(
p
Mgmt
->
dnodeHash
!=
NULL
)
{
taosHashCleanup
(
p
Dnode
->
dnodeHash
);
taosHashCleanup
(
p
Mgmt
->
dnodeHash
);
p
Dnode
->
dnodeHash
=
NULL
;
p
Mgmt
->
dnodeHash
=
NULL
;
}
}
if
(
p
Dnode
->
file
!=
NULL
)
{
if
(
p
Mgmt
->
file
!=
NULL
)
{
free
(
p
Dnode
->
file
);
free
(
p
Mgmt
->
file
);
p
Dnode
->
file
=
NULL
;
p
Mgmt
->
file
=
NULL
;
}
}
dndUnLockDnode
(
pDnd
);
dndWUnLockDnode
(
pDnode
);
pthread_mutex_destroy
(
&
pDnode
->
mutex
);
dInfo
(
"dnd-dnode is cleaned up"
);
dInfo
(
"dnd-dnode is cleaned up"
);
}
}
void
dndProcessDnodeReq
(
SDnode
*
pDn
d
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
void
dndProcessDnodeReq
(
SDnode
*
pDn
ode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
switch
(
pMsg
->
msgType
)
{
switch
(
pMsg
->
msgType
)
{
case
TSDB_MSG_TYPE_NETWORK_TEST
:
case
TSDB_MSG_TYPE_NETWORK_TEST
:
dndProcessStartupReq
(
pDn
d
,
pMsg
);
dndProcessStartupReq
(
pDn
ode
,
pMsg
);
break
;
break
;
case
TSDB_MSG_TYPE_CONFIG_DNODE_IN
:
case
TSDB_MSG_TYPE_CONFIG_DNODE_IN
:
dndProcessConfigDnodeReq
(
pDn
d
,
pMsg
);
dndProcessConfigDnodeReq
(
pDn
ode
,
pMsg
);
break
;
break
;
default:
default:
dError
(
"RPC %p, dnode req:%s not processed"
,
pMsg
->
handle
,
taosMsg
[
pMsg
->
msgType
]);
dError
(
"RPC %p, dnode req:%s not processed"
,
pMsg
->
handle
,
taosMsg
[
pMsg
->
msgType
]);
...
@@ -565,16 +550,16 @@ void dndProcessDnodeReq(SDnode *pDnd, SRpcMsg *pMsg, SEpSet *pEpSet) {
...
@@ -565,16 +550,16 @@ void dndProcessDnodeReq(SDnode *pDnd, SRpcMsg *pMsg, SEpSet *pEpSet) {
}
}
}
}
void
dndProcessDnodeRsp
(
SDnode
*
pDn
d
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
void
dndProcessDnodeRsp
(
SDnode
*
pDn
ode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
switch
(
pMsg
->
msgType
)
{
switch
(
pMsg
->
msgType
)
{
case
TSDB_MSG_TYPE_STATUS_RSP
:
case
TSDB_MSG_TYPE_STATUS_RSP
:
dndProcessStatusRsp
(
pDn
d
,
pMsg
,
pEpSet
);
dndProcessStatusRsp
(
pDn
ode
,
pMsg
,
pEpSet
);
break
;
break
;
case
TSDB_MSG_TYPE_AUTH_RSP
:
case
TSDB_MSG_TYPE_AUTH_RSP
:
dndProcessAuthRsp
(
pDn
d
,
pMsg
,
pEpSet
);
dndProcessAuthRsp
(
pDn
ode
,
pMsg
,
pEpSet
);
break
;
break
;
case
TSDB_MSG_TYPE_GRANT_RSP
:
case
TSDB_MSG_TYPE_GRANT_RSP
:
dndProcessGrantRsp
(
pDn
d
,
pMsg
,
pEpSet
);
dndProcessGrantRsp
(
pDn
ode
,
pMsg
,
pEpSet
);
break
;
break
;
default:
default:
dError
(
"RPC %p, dnode rsp:%s not processed"
,
pMsg
->
handle
,
taosMsg
[
pMsg
->
msgType
]);
dError
(
"RPC %p, dnode rsp:%s not processed"
,
pMsg
->
handle
,
taosMsg
[
pMsg
->
msgType
]);
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
04ea2358
...
@@ -53,7 +53,7 @@ void mnodeSendMsgToMnode(SMnode *pMnode, struct SRpcMsg *rpcMsg) {
...
@@ -53,7 +53,7 @@ void mnodeSendMsgToMnode(SMnode *pMnode, struct SRpcMsg *rpcMsg) {
void
mnodeSendRedirectMsg
(
SMnode
*
pMnode
,
struct
SRpcMsg
*
rpcMsg
,
bool
forShell
)
{
void
mnodeSendRedirectMsg
(
SMnode
*
pMnode
,
struct
SRpcMsg
*
rpcMsg
,
bool
forShell
)
{
assert
(
pMnode
);
assert
(
pMnode
);
(
*
pMnode
->
sendRedirectMsgFp
)(
pMnode
->
pServer
,
rpcMsg
,
forShell
);
(
*
pMnode
->
sendRedirectMsgFp
)(
pMnode
->
pServer
,
rpcMsg
);
}
}
static
int32_t
mnodeInitTimer
()
{
static
int32_t
mnodeInitTimer
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录