Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e63637fc
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e63637fc
编写于
11月 29, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-10431 rename some functions
上级
6ee88322
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
111 addition
and
238 deletion
+111
-238
source/dnode/mnode/impl/inc/mndMnode.h
source/dnode/mnode/impl/inc/mndMnode.h
+2
-2
source/dnode/mnode/impl/inc/mndSync.h
source/dnode/mnode/impl/inc/mndSync.h
+2
-3
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+2
-2
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+2
-2
source/dnode/mnode/impl/src/mndTelem.c
source/dnode/mnode/impl/src/mndTelem.c
+49
-49
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+24
-30
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+30
-150
未找到文件。
source/dnode/mnode/impl/inc/mndMnode.h
浏览文件 @
e63637fc
...
...
@@ -24,8 +24,8 @@ extern "C" {
int32_t
mndInitMnode
();
void
mndCleanupMnode
();
void
mn
ode
GetMnodeEpSetForPeer
(
SEpSet
*
epSet
,
bool
redirect
);
void
mn
ode
GetMnodeEpSetForShell
(
SEpSet
*
epSet
,
bool
redirect
);
void
mn
d
GetMnodeEpSetForPeer
(
SEpSet
*
epSet
,
bool
redirect
);
void
mn
d
GetMnodeEpSetForShell
(
SEpSet
*
epSet
,
bool
redirect
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/inc/mndSync.h
浏览文件 @
e63637fc
...
...
@@ -24,9 +24,8 @@ extern "C" {
int32_t
mndInitSync
();
void
mndCleanupSync
();
int32_t
mnodeSyncPropose
(
SSdbRaw
*
pRaw
,
void
*
pData
);
bool
mnodeIsMaster
();
bool
mndIsMaster
();
int32_t
mndSyncPropose
(
SSdbRaw
*
pRaw
,
void
*
pData
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
e63637fc
...
...
@@ -20,5 +20,5 @@
int32_t
mndInitMnode
()
{
return
0
;
}
void
mndCleanupMnode
()
{}
void
mnodeGetMnodeEpSetForPeer
(
SEpSet
*
epSet
,
bool
redirect
)
{}
void
mnodeGetMnodeEpSetForShell
(
SEpSet
*
epSet
,
bool
redirect
)
{}
\ No newline at end of file
void
mndGetMnodeEpSetForPeer
(
SEpSet
*
epSet
,
bool
redirect
)
{}
void
mndGetMnodeEpSetForShell
(
SEpSet
*
epSet
,
bool
redirect
)
{}
\ No newline at end of file
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
e63637fc
...
...
@@ -21,10 +21,10 @@
int32_t
mndInitSync
()
{
return
0
;
}
void
mndCleanupSync
()
{}
int32_t
mn
ode
SyncPropose
(
SSdbRaw
*
pRaw
,
void
*
pData
)
{
int32_t
mn
d
SyncPropose
(
SSdbRaw
*
pRaw
,
void
*
pData
)
{
trnApply
(
pData
,
pData
,
0
);
free
(
pData
);
return
0
;
}
bool
mnodeIsMaster
()
{
return
true
;
}
\ No newline at end of file
bool
mndIsMaster
()
{
return
true
;
}
\ No newline at end of file
source/dnode/mnode/impl/src/mndTelem.c
浏览文件 @
e63637fc
...
...
@@ -36,9 +36,9 @@ static struct {
char
email
[
TSDB_FQDN_LEN
];
}
tsTelem
;
static
void
mn
ode
BeginObject
(
SBufferWriter
*
bw
)
{
tbufWriteChar
(
bw
,
'{'
);
}
static
void
mn
d
BeginObject
(
SBufferWriter
*
bw
)
{
tbufWriteChar
(
bw
,
'{'
);
}
static
void
mn
ode
CloseObject
(
SBufferWriter
*
bw
)
{
static
void
mn
d
CloseObject
(
SBufferWriter
*
bw
)
{
size_t
len
=
tbufTell
(
bw
);
if
(
tbufGetData
(
bw
,
false
)[
len
-
1
]
==
','
)
{
tbufWriteCharAt
(
bw
,
len
-
1
,
'}'
);
...
...
@@ -64,14 +64,14 @@ static void closeArray(SBufferWriter* bw) {
}
#endif
static
void
mn
ode
WriteString
(
SBufferWriter
*
bw
,
const
char
*
str
)
{
static
void
mn
d
WriteString
(
SBufferWriter
*
bw
,
const
char
*
str
)
{
tbufWriteChar
(
bw
,
'"'
);
tbufWrite
(
bw
,
str
,
strlen
(
str
));
tbufWriteChar
(
bw
,
'"'
);
}
static
void
mn
ode
AddIntField
(
SBufferWriter
*
bw
,
const
char
*
k
,
int64_t
v
)
{
mn
ode
WriteString
(
bw
,
k
);
static
void
mn
d
AddIntField
(
SBufferWriter
*
bw
,
const
char
*
k
,
int64_t
v
)
{
mn
d
WriteString
(
bw
,
k
);
tbufWriteChar
(
bw
,
':'
);
char
buf
[
32
];
sprintf
(
buf
,
"%"
PRId64
,
v
);
...
...
@@ -79,14 +79,14 @@ static void mnodeAddIntField(SBufferWriter* bw, const char* k, int64_t v) {
tbufWriteChar
(
bw
,
','
);
}
static
void
mn
ode
AddStringField
(
SBufferWriter
*
bw
,
const
char
*
k
,
const
char
*
v
)
{
mn
ode
WriteString
(
bw
,
k
);
static
void
mn
d
AddStringField
(
SBufferWriter
*
bw
,
const
char
*
k
,
const
char
*
v
)
{
mn
d
WriteString
(
bw
,
k
);
tbufWriteChar
(
bw
,
':'
);
mn
ode
WriteString
(
bw
,
v
);
mn
d
WriteString
(
bw
,
v
);
tbufWriteChar
(
bw
,
','
);
}
static
void
mn
ode
AddCpuInfo
(
SBufferWriter
*
bw
)
{
static
void
mn
d
AddCpuInfo
(
SBufferWriter
*
bw
)
{
char
*
line
=
NULL
;
size_t
size
=
0
;
int32_t
done
=
0
;
...
...
@@ -100,11 +100,11 @@ static void mnodeAddCpuInfo(SBufferWriter* bw) {
line
[
size
-
1
]
=
'\0'
;
if
(((
done
&
1
)
==
0
)
&&
strncmp
(
line
,
"model name"
,
10
)
==
0
)
{
const
char
*
v
=
strchr
(
line
,
':'
)
+
2
;
mn
ode
AddStringField
(
bw
,
"cpuModel"
,
v
);
mn
d
AddStringField
(
bw
,
"cpuModel"
,
v
);
done
|=
1
;
}
else
if
(((
done
&
2
)
==
0
)
&&
strncmp
(
line
,
"cpu cores"
,
9
)
==
0
)
{
const
char
*
v
=
strchr
(
line
,
':'
)
+
2
;
mn
ode
WriteString
(
bw
,
"numOfCpu"
);
mn
d
WriteString
(
bw
,
"numOfCpu"
);
tbufWriteChar
(
bw
,
':'
);
tbufWrite
(
bw
,
v
,
strlen
(
v
));
tbufWriteChar
(
bw
,
','
);
...
...
@@ -116,7 +116,7 @@ static void mnodeAddCpuInfo(SBufferWriter* bw) {
fclose
(
fp
);
}
static
void
mn
ode
AddOsInfo
(
SBufferWriter
*
bw
)
{
static
void
mn
d
AddOsInfo
(
SBufferWriter
*
bw
)
{
char
*
line
=
NULL
;
size_t
size
=
0
;
...
...
@@ -133,7 +133,7 @@ static void mnodeAddOsInfo(SBufferWriter* bw) {
p
++
;
line
[
size
-
2
]
=
0
;
}
mn
ode
AddStringField
(
bw
,
"os"
,
p
);
mn
d
AddStringField
(
bw
,
"os"
,
p
);
break
;
}
}
...
...
@@ -142,7 +142,7 @@ static void mnodeAddOsInfo(SBufferWriter* bw) {
fclose
(
fp
);
}
static
void
mn
ode
AddMemoryInfo
(
SBufferWriter
*
bw
)
{
static
void
mn
d
AddMemoryInfo
(
SBufferWriter
*
bw
)
{
char
*
line
=
NULL
;
size_t
size
=
0
;
...
...
@@ -156,7 +156,7 @@ static void mnodeAddMemoryInfo(SBufferWriter* bw) {
if
(
strncmp
(
line
,
"MemTotal"
,
8
)
==
0
)
{
const
char
*
p
=
strchr
(
line
,
':'
)
+
1
;
while
(
*
p
==
' '
)
p
++
;
mn
ode
AddStringField
(
bw
,
"memory"
,
p
);
mn
d
AddStringField
(
bw
,
"memory"
,
p
);
break
;
}
}
...
...
@@ -165,32 +165,32 @@ static void mnodeAddMemoryInfo(SBufferWriter* bw) {
fclose
(
fp
);
}
static
void
mn
ode
AddVersionInfo
(
SBufferWriter
*
bw
)
{
mn
ode
AddStringField
(
bw
,
"version"
,
version
);
mn
ode
AddStringField
(
bw
,
"buildInfo"
,
buildinfo
);
mn
ode
AddStringField
(
bw
,
"gitInfo"
,
gitinfo
);
mn
ode
AddStringField
(
bw
,
"email"
,
tsTelem
.
email
);
static
void
mn
d
AddVersionInfo
(
SBufferWriter
*
bw
)
{
mn
d
AddStringField
(
bw
,
"version"
,
version
);
mn
d
AddStringField
(
bw
,
"buildInfo"
,
buildinfo
);
mn
d
AddStringField
(
bw
,
"gitInfo"
,
gitinfo
);
mn
d
AddStringField
(
bw
,
"email"
,
tsTelem
.
email
);
}
static
void
mn
ode
AddRuntimeInfo
(
SBufferWriter
*
bw
)
{
static
void
mn
d
AddRuntimeInfo
(
SBufferWriter
*
bw
)
{
SMnodeLoad
load
=
{
0
};
if
(
mndGetLoad
(
NULL
,
&
load
)
!=
0
)
{
return
;
}
mn
ode
AddIntField
(
bw
,
"numOfDnode"
,
load
.
numOfDnode
);
mn
ode
AddIntField
(
bw
,
"numOfMnode"
,
load
.
numOfMnode
);
mn
ode
AddIntField
(
bw
,
"numOfVgroup"
,
load
.
numOfVgroup
);
mn
ode
AddIntField
(
bw
,
"numOfDatabase"
,
load
.
numOfDatabase
);
mn
ode
AddIntField
(
bw
,
"numOfSuperTable"
,
load
.
numOfSuperTable
);
mn
ode
AddIntField
(
bw
,
"numOfChildTable"
,
load
.
numOfChildTable
);
mn
ode
AddIntField
(
bw
,
"numOfColumn"
,
load
.
numOfColumn
);
mn
ode
AddIntField
(
bw
,
"numOfPoint"
,
load
.
totalPoints
);
mn
ode
AddIntField
(
bw
,
"totalStorage"
,
load
.
totalStorage
);
mn
ode
AddIntField
(
bw
,
"compStorage"
,
load
.
compStorage
);
mn
d
AddIntField
(
bw
,
"numOfDnode"
,
load
.
numOfDnode
);
mn
d
AddIntField
(
bw
,
"numOfMnode"
,
load
.
numOfMnode
);
mn
d
AddIntField
(
bw
,
"numOfVgroup"
,
load
.
numOfVgroup
);
mn
d
AddIntField
(
bw
,
"numOfDatabase"
,
load
.
numOfDatabase
);
mn
d
AddIntField
(
bw
,
"numOfSuperTable"
,
load
.
numOfSuperTable
);
mn
d
AddIntField
(
bw
,
"numOfChildTable"
,
load
.
numOfChildTable
);
mn
d
AddIntField
(
bw
,
"numOfColumn"
,
load
.
numOfColumn
);
mn
d
AddIntField
(
bw
,
"numOfPoint"
,
load
.
totalPoints
);
mn
d
AddIntField
(
bw
,
"totalStorage"
,
load
.
totalStorage
);
mn
d
AddIntField
(
bw
,
"compStorage"
,
load
.
compStorage
);
}
static
void
mn
ode
SendTelemetryReport
()
{
static
void
mn
d
SendTelemetryReport
()
{
char
buf
[
128
]
=
{
0
};
uint32_t
ip
=
taosGetIpv4FromFqdn
(
TELEMETRY_SERVER
);
if
(
ip
==
0xffffffff
)
{
...
...
@@ -208,15 +208,15 @@ static void mnodeSendTelemetryReport() {
snprintf
(
clusterIdStr
,
sizeof
(
clusterIdStr
),
"%"
PRId64
,
clusterId
);
SBufferWriter
bw
=
tbufInitWriter
(
NULL
,
false
);
mn
ode
BeginObject
(
&
bw
);
mn
ode
AddStringField
(
&
bw
,
"instanceId"
,
clusterIdStr
);
mn
ode
AddIntField
(
&
bw
,
"reportVersion"
,
1
);
mn
ode
AddOsInfo
(
&
bw
);
mn
ode
AddCpuInfo
(
&
bw
);
mn
ode
AddMemoryInfo
(
&
bw
);
mn
ode
AddVersionInfo
(
&
bw
);
mn
ode
AddRuntimeInfo
(
&
bw
);
mn
ode
CloseObject
(
&
bw
);
mn
d
BeginObject
(
&
bw
);
mn
d
AddStringField
(
&
bw
,
"instanceId"
,
clusterIdStr
);
mn
d
AddIntField
(
&
bw
,
"reportVersion"
,
1
);
mn
d
AddOsInfo
(
&
bw
);
mn
d
AddCpuInfo
(
&
bw
);
mn
d
AddMemoryInfo
(
&
bw
);
mn
d
AddVersionInfo
(
&
bw
);
mn
d
AddRuntimeInfo
(
&
bw
);
mn
d
CloseObject
(
&
bw
);
const
char
*
header
=
"POST /report HTTP/1.1
\n
"
...
...
@@ -240,12 +240,12 @@ static void mnodeSendTelemetryReport() {
taosCloseSocket
(
fd
);
}
static
void
*
mn
ode
TelemThreadFp
(
void
*
param
)
{
static
void
*
mn
d
TelemThreadFp
(
void
*
param
)
{
struct
timespec
end
=
{
0
};
clock_gettime
(
CLOCK_REALTIME
,
&
end
);
end
.
tv_sec
+=
300
;
// wait 5 minutes before send first report
setThreadName
(
"mn
ode
-telem"
);
setThreadName
(
"mn
d
-telem"
);
while
(
!
tsTelem
.
exit
)
{
int32_t
r
=
0
;
...
...
@@ -256,8 +256,8 @@ static void* mnodeTelemThreadFp(void* param) {
if
(
r
==
0
)
break
;
if
(
r
!=
ETIMEDOUT
)
continue
;
if
(
mn
ode
IsMaster
())
{
mn
ode
SendTelemetryReport
();
if
(
mn
d
IsMaster
())
{
mn
d
SendTelemetryReport
();
}
end
.
tv_sec
+=
REPORT_INTERVAL
;
}
...
...
@@ -265,7 +265,7 @@ static void* mnodeTelemThreadFp(void* param) {
return
NULL
;
}
static
void
mn
ode
GetEmail
(
char
*
filepath
)
{
static
void
mn
d
GetEmail
(
char
*
filepath
)
{
int32_t
fd
=
taosOpenFileRead
(
filepath
);
if
(
fd
<
0
)
{
return
;
...
...
@@ -287,19 +287,19 @@ int32_t mndInitTelem() {
pthread_cond_init
(
&
tsTelem
.
cond
,
NULL
);
tsTelem
.
email
[
0
]
=
0
;
mn
ode
GetEmail
(
"/usr/local/taos/email"
);
mn
d
GetEmail
(
"/usr/local/taos/email"
);
pthread_attr_t
attr
;
pthread_attr_init
(
&
attr
);
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_JOINABLE
);
int32_t
code
=
pthread_create
(
&
tsTelem
.
thread
,
&
attr
,
mn
ode
TelemThreadFp
,
NULL
);
int32_t
code
=
pthread_create
(
&
tsTelem
.
thread
,
&
attr
,
mn
d
TelemThreadFp
,
NULL
);
pthread_attr_destroy
(
&
attr
);
if
(
code
!=
0
)
{
mTrace
(
"failed to create telemetry thread since :%s"
,
strerror
(
code
));
}
mInfo
(
"mn
ode
telemetry is initialized"
);
mInfo
(
"mn
d
telemetry is initialized"
);
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
e63637fc
...
...
@@ -15,14 +15,12 @@
#define _DEFAULT_SOURCE
#include "mndSync.h"
#include "os.h"
#include "tglobal.h"
#include "tkey.h"
#include "mndTrans.h"
#define SDB_USER_VER 1
static
SSdbRaw
*
mn
ode
UserActionEncode
(
SUserObj
*
pUser
)
{
static
SSdbRaw
*
mn
d
UserActionEncode
(
SUserObj
*
pUser
)
{
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_USER
,
SDB_USER_VER
,
sizeof
(
SAcctObj
));
if
(
pRaw
==
NULL
)
return
NULL
;
...
...
@@ -38,7 +36,7 @@ static SSdbRaw *mnodeUserActionEncode(SUserObj *pUser) {
return
pRaw
;
}
static
SSdbRow
*
mn
ode
UserActionDecode
(
SSdbRaw
*
pRaw
)
{
static
SSdbRow
*
mn
d
UserActionDecode
(
SSdbRaw
*
pRaw
)
{
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
return
NULL
;
...
...
@@ -62,7 +60,7 @@ static SSdbRow *mnodeUserActionDecode(SSdbRaw *pRaw) {
return
pRow
;
}
static
int32_t
mn
ode
UserActionInsert
(
SUserObj
*
pUser
)
{
static
int32_t
mn
d
UserActionInsert
(
SUserObj
*
pUser
)
{
pUser
->
prohibitDbHash
=
taosHashInit
(
8
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
pUser
->
prohibitDbHash
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -78,7 +76,7 @@ static int32_t mnodeUserActionInsert(SUserObj *pUser) {
return
0
;
}
static
int32_t
mn
ode
UserActionDelete
(
SUserObj
*
pUser
)
{
static
int32_t
mn
d
UserActionDelete
(
SUserObj
*
pUser
)
{
if
(
pUser
->
prohibitDbHash
)
{
taosHashCleanup
(
pUser
->
prohibitDbHash
);
pUser
->
prohibitDbHash
=
NULL
;
...
...
@@ -92,14 +90,14 @@ static int32_t mnodeUserActionDelete(SUserObj *pUser) {
return
0
;
}
static
int32_t
mn
ode
UserActionUpdate
(
SUserObj
*
pSrcUser
,
SUserObj
*
pDstUser
)
{
static
int32_t
mn
d
UserActionUpdate
(
SUserObj
*
pSrcUser
,
SUserObj
*
pDstUser
)
{
SUserObj
tObj
;
int32_t
len
=
(
int32_t
)((
int8_t
*
)
tObj
.
prohibitDbHash
-
(
int8_t
*
)
&
tObj
);
memcpy
(
pDstUser
,
pSrcUser
,
len
);
return
0
;
}
static
int32_t
mn
ode
CreateDefaultUser
(
char
*
acct
,
char
*
user
,
char
*
pass
)
{
static
int32_t
mn
d
CreateDefaultUser
(
char
*
acct
,
char
*
user
,
char
*
pass
)
{
SUserObj
userObj
=
{
0
};
tstrncpy
(
userObj
.
user
,
user
,
TSDB_USER_LEN
);
tstrncpy
(
userObj
.
acct
,
acct
,
TSDB_USER_LEN
);
...
...
@@ -111,30 +109,26 @@ static int32_t mnodeCreateDefaultUser(char *acct, char *user, char *pass) {
userObj
.
rootAuth
=
1
;
}
SSdbRaw
*
pRaw
=
mn
ode
UserActionEncode
(
&
userObj
);
SSdbRaw
*
pRaw
=
mn
d
UserActionEncode
(
&
userObj
);
if
(
pRaw
==
NULL
)
return
-
1
;
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
return
sdbWrite
(
pRaw
);
}
static
int32_t
mn
ode
CreateDefaultUsers
()
{
if
(
mn
ode
CreateDefaultUser
(
TSDB_DEFAULT_USER
,
TSDB_DEFAULT_USER
,
TSDB_DEFAULT_PASS
)
!=
0
)
{
static
int32_t
mn
d
CreateDefaultUsers
()
{
if
(
mn
d
CreateDefaultUser
(
TSDB_DEFAULT_USER
,
TSDB_DEFAULT_USER
,
TSDB_DEFAULT_PASS
)
!=
0
)
{
return
-
1
;
}
if
(
mnodeCreateDefaultUser
(
TSDB_DEFAULT_USER
,
"monitor"
,
tsInternalPass
)
!=
0
)
{
return
-
1
;
}
if
(
mnodeCreateDefaultUser
(
TSDB_DEFAULT_USER
,
"_"
TSDB_DEFAULT_USER
,
tsInternalPass
)
!=
0
)
{
if
(
mndCreateDefaultUser
(
TSDB_DEFAULT_USER
,
"_"
TSDB_DEFAULT_USER
,
TSDB_DEFAULT_PASS
)
!=
0
)
{
return
-
1
;
}
return
0
;
}
static
int32_t
mn
ode
CreateUser
(
char
*
acct
,
char
*
user
,
char
*
pass
,
SMnodeMsg
*
pMsg
)
{
static
int32_t
mn
d
CreateUser
(
char
*
acct
,
char
*
user
,
char
*
pass
,
SMnodeMsg
*
pMsg
)
{
SUserObj
userObj
=
{
0
};
tstrncpy
(
userObj
.
user
,
user
,
TSDB_USER_LEN
);
tstrncpy
(
userObj
.
acct
,
acct
,
TSDB_USER_LEN
);
...
...
@@ -146,7 +140,7 @@ static int32_t mnodeCreateUser(char *acct, char *user, char *pass, SMnodeMsg *pM
STrans
*
pTrans
=
trnCreate
(
TRN_POLICY_ROLLBACK
,
pMsg
->
rpcMsg
.
handle
);
if
(
pTrans
==
NULL
)
return
-
1
;
SSdbRaw
*
pRedoRaw
=
mn
ode
UserActionEncode
(
&
userObj
);
SSdbRaw
*
pRedoRaw
=
mn
d
UserActionEncode
(
&
userObj
);
if
(
pRedoRaw
==
NULL
||
trnAppendRedoLog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
mError
(
"failed to append redo log since %s"
,
terrstr
());
trnDrop
(
pTrans
);
...
...
@@ -154,7 +148,7 @@ static int32_t mnodeCreateUser(char *acct, char *user, char *pass, SMnodeMsg *pM
}
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_CREATING
);
SSdbRaw
*
pUndoRaw
=
mn
ode
UserActionEncode
(
&
userObj
);
SSdbRaw
*
pUndoRaw
=
mn
d
UserActionEncode
(
&
userObj
);
if
(
pUndoRaw
==
NULL
||
trnAppendUndoLog
(
pTrans
,
pUndoRaw
)
!=
0
)
{
mError
(
"failed to append undo log since %s"
,
terrstr
());
trnDrop
(
pTrans
);
...
...
@@ -162,7 +156,7 @@ static int32_t mnodeCreateUser(char *acct, char *user, char *pass, SMnodeMsg *pM
}
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_DROPPED
);
SSdbRaw
*
pCommitRaw
=
mn
ode
UserActionEncode
(
&
userObj
);
SSdbRaw
*
pCommitRaw
=
mn
d
UserActionEncode
(
&
userObj
);
if
(
pCommitRaw
==
NULL
||
trnAppendCommitLog
(
pTrans
,
pCommitRaw
)
!=
0
)
{
mError
(
"failed to append commit log since %s"
,
terrstr
());
trnDrop
(
pTrans
);
...
...
@@ -170,7 +164,7 @@ static int32_t mnodeCreateUser(char *acct, char *user, char *pass, SMnodeMsg *pM
}
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
);
if
(
trnPrepare
(
pTrans
,
mn
ode
SyncPropose
)
!=
0
)
{
if
(
trnPrepare
(
pTrans
,
mn
d
SyncPropose
)
!=
0
)
{
trnDrop
(
pTrans
);
return
-
1
;
}
...
...
@@ -179,7 +173,7 @@ static int32_t mnodeCreateUser(char *acct, char *user, char *pass, SMnodeMsg *pM
return
0
;
}
static
int32_t
mn
ode
ProcessCreateUserMsg
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
)
{
static
int32_t
mn
d
ProcessCreateUserMsg
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
)
{
SCreateUserMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
if
(
pCreate
->
user
[
0
]
==
0
)
{
...
...
@@ -209,7 +203,7 @@ static int32_t mnodeProcessCreateUserMsg(SMnode *pMnode, SMnodeMsg *pMsg) {
return
-
1
;
}
int32_t
code
=
mn
ode
CreateUser
(
pOperUser
->
acct
,
pCreate
->
user
,
pCreate
->
pass
,
pMsg
);
int32_t
code
=
mn
d
CreateUser
(
pOperUser
->
acct
,
pCreate
->
user
,
pCreate
->
pass
,
pMsg
);
sdbRelease
(
pOperUser
);
if
(
code
!=
0
)
{
...
...
@@ -223,15 +217,15 @@ static int32_t mnodeProcessCreateUserMsg(SMnode *pMnode, SMnodeMsg *pMsg) {
int32_t
mndInitUser
()
{
SSdbTable
table
=
{.
sdbType
=
SDB_USER
,
.
keyType
=
SDB_KEY_BINARY
,
.
deployFp
=
(
SdbDeployFp
)
mn
ode
CreateDefaultUsers
,
.
encodeFp
=
(
SdbEncodeFp
)
mn
ode
UserActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
mn
ode
UserActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
mn
ode
UserActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mn
ode
UserActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mn
ode
UserActionDelete
};
.
deployFp
=
(
SdbDeployFp
)
mn
d
CreateDefaultUsers
,
.
encodeFp
=
(
SdbEncodeFp
)
mn
d
UserActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
mn
d
UserActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
mn
d
UserActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mn
d
UserActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mn
d
UserActionDelete
};
sdbSetTable
(
table
);
mndSetMsgHandle
(
NULL
,
TSDB_MSG_TYPE_CREATE_USER
,
mn
ode
ProcessCreateUserMsg
);
mndSetMsgHandle
(
NULL
,
TSDB_MSG_TYPE_CREATE_USER
,
mn
d
ProcessCreateUserMsg
);
return
0
;
}
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
e63637fc
...
...
@@ -278,28 +278,44 @@ void mndSendRsp(SMnodeMsg *pMsg, int32_t code) {}
static
void
mndProcessRpcMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
int32_t
code
=
0
;
int32_t
msgType
=
pMsg
->
rpcMsg
.
msgType
;
void
*
ahandle
=
pMsg
->
rpcMsg
.
ahandle
;
bool
isReq
=
(
msgType
%
2
==
1
);
if
(
!
mnodeIsMaster
(
pMnode
))
{
mndSendRedirectMsg
(
pMnode
,
&
pMsg
->
rpcMsg
);
mndCleanupMsg
(
pMsg
);
return
;
if
(
isReq
&&
!
mndIsMaster
(
pMnode
))
{
code
=
TSDB_CODE_APP_NOT_READY
;
goto
PROCESS_RPC_END
;
}
if
(
isReq
&&
pMsg
->
rpcMsg
.
pCont
==
NULL
)
{
mError
(
"msg:%p, app:%p type:%s content is null"
,
pMsg
,
ahandle
,
taosMsg
[
msgType
]);
code
=
TSDB_CODE_MND_INVALID_MSG_LEN
;
goto
PROCESS_RPC_END
;
}
int32_t
msgType
=
pMsg
->
rpcMsg
.
msgType
;
MndMsgFp
fp
=
pMnode
->
msgFp
[
msgType
];
if
(
fp
==
NULL
)
{
mError
(
"RPC %p, req:%s is not processed"
,
pMsg
->
rpcMsg
.
handle
,
taosMsg
[
msgType
]);
SRpcMsg
rspMsg
=
{.
handle
=
pMsg
->
rpcMsg
.
handle
,
.
code
=
TSDB_CODE_MSG_NOT_PROCESSED
};
rpcSendResponse
(
&
rspMsg
);
mndCleanupMsg
(
pMsg
);
return
;
mError
(
"msg:%p, app:%p type:%s not processed"
,
pMsg
,
ahandle
,
taosMsg
[
msgType
]);
code
=
TSDB_CODE_MSG_NOT_PROCESSED
;
goto
PROCESS_RPC_END
;
}
int32_t
code
=
(
*
fp
)(
pMnode
,
pMsg
);
code
=
(
*
fp
)(
pMnode
,
pMsg
);
if
(
code
!=
0
)
{
mError
(
"RPC %p, req:%s processed error since %s"
,
pMsg
->
rpcMsg
.
handle
,
taosMsg
[
msgType
],
tstrerror
(
code
));
SRpcMsg
rspMsg
=
{.
handle
=
pMsg
->
rpcMsg
.
handle
,
.
code
=
TSDB_CODE_MSG_NOT_PROCESSED
};
rpcSendResponse
(
&
rspMsg
);
mError
(
"msg:%p, app:%p type:%s failed to process since %s"
,
pMsg
,
ahandle
,
taosMsg
[
msgType
],
tstrerror
(
code
));
goto
PROCESS_RPC_END
;
}
PROCESS_RPC_END:
if
(
isReq
)
{
if
(
code
==
TSDB_CODE_APP_NOT_READY
)
{
mndSendRedirectMsg
(
pMnode
,
&
pMsg
->
rpcMsg
);
}
else
if
(
code
!=
0
)
{
SRpcMsg
rspMsg
=
{.
handle
=
pMsg
->
rpcMsg
.
handle
,
.
code
=
code
};
rpcSendResponse
(
&
rspMsg
);
}
else
{
}
}
mndCleanupMsg
(
pMsg
);
...
...
@@ -318,139 +334,3 @@ void mndProcessWriteMsg(SMnodeMsg *pMsg) { mndProcessRpcMsg(pMsg); }
void
mndProcessSyncMsg
(
SMnodeMsg
*
pMsg
)
{
mndProcessRpcMsg
(
pMsg
);
}
void
mndProcessApplyMsg
(
SMnodeMsg
*
pMsg
)
{}
#if 0
static void mnodeProcessWriteReq(SMnodeMsg *pMsg, void *unused) {
int32_t msgType = pMsg->rpcMsg.msgType;
void *ahandle = pMsg->rpcMsg.ahandle;
int32_t code = 0;
if (pMsg->rpcMsg.pCont == NULL) {
mError("msg:%p, app:%p type:%s content is null", pMsg, ahandle, taosMsg[msgType]);
code = TSDB_CODE_MND_INVALID_MSG_LEN;
goto PROCESS_WRITE_REQ_END;
}
if (!mnodeIsMaster()) {
SMnodeRsp *rpcRsp = &pMsg->rpcRsp;
SEpSet *epSet = rpcMallocCont(sizeof(SEpSet));
mnodeGetMnodeEpSetForShell(epSet, true);
rpcRsp->rsp = epSet;
rpcRsp->len = sizeof(SEpSet);
mDebug("msg:%p, app:%p type:%s in write queue, is redirected, numOfEps:%d inUse:%d", pMsg, ahandle,
taosMsg[msgType], epSet->numOfEps, epSet->inUse);
code = TSDB_CODE_RPC_REDIRECT;
goto PROCESS_WRITE_REQ_END;
}
if (tsMworker.writeMsgFp[msgType] == NULL) {
mError("msg:%p, app:%p type:%s not processed", pMsg, ahandle, taosMsg[msgType]);
code = TSDB_CODE_MND_MSG_NOT_PROCESSED;
goto PROCESS_WRITE_REQ_END;
}
code = (*tsMworker.writeMsgFp[msgType])(pMsg);
PROCESS_WRITE_REQ_END:
mndSendRsp(pMsg, code);
}
static void mnodeProcessReadReq(SMnodeMsg *pMsg, void *unused) {
int32_t msgType = pMsg->rpcMsg.msgType;
void *ahandle = pMsg->rpcMsg.ahandle;
int32_t code = 0;
if (pMsg->rpcMsg.pCont == NULL) {
mError("msg:%p, app:%p type:%s in mread queue, content is null", pMsg, ahandle, taosMsg[msgType]);
code = TSDB_CODE_MND_INVALID_MSG_LEN;
goto PROCESS_READ_REQ_END;
}
if (!mnodeIsMaster()) {
SMnodeRsp *rpcRsp = &pMsg->rpcRsp;
SEpSet *epSet = rpcMallocCont(sizeof(SEpSet));
if (!epSet) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto PROCESS_READ_REQ_END;
}
mnodeGetMnodeEpSetForShell(epSet, true);
rpcRsp->rsp = epSet;
rpcRsp->len = sizeof(SEpSet);
mDebug("msg:%p, app:%p type:%s in mread queue is redirected, numOfEps:%d inUse:%d", pMsg, ahandle, taosMsg[msgType],
epSet->numOfEps, epSet->inUse);
code = TSDB_CODE_RPC_REDIRECT;
goto PROCESS_READ_REQ_END;
}
if (tsMworker.readMsgFp[msgType] == NULL) {
mError("msg:%p, app:%p type:%s in mread queue, not processed", pMsg, ahandle, taosMsg[msgType]);
code = TSDB_CODE_MND_MSG_NOT_PROCESSED;
goto PROCESS_READ_REQ_END;
}
mTrace("msg:%p, app:%p type:%s will be processed in mread queue", pMsg, ahandle, taosMsg[msgType]);
code = (*tsMworker.readMsgFp[msgType])(pMsg);
PROCESS_READ_REQ_END:
mndSendRsp(pMsg, code);
}
static void mnodeProcessPeerReq(SMnodeMsg *pMsg, void *unused) {
int32_t msgType = pMsg->rpcMsg.msgType;
void *ahandle = pMsg->rpcMsg.ahandle;
int32_t code = 0;
if (pMsg->rpcMsg.pCont == NULL) {
mError("msg:%p, ahandle:%p type:%s in mpeer queue, content is null", pMsg, ahandle, taosMsg[msgType]);
code = TSDB_CODE_MND_INVALID_MSG_LEN;
goto PROCESS_PEER_REQ_END;
}
if (!mnodeIsMaster()) {
SMnodeRsp *rpcRsp = &pMsg->rpcRsp;
SEpSet *epSet = rpcMallocCont(sizeof(SEpSet));
mnodeGetMnodeEpSetForPeer(epSet, true);
rpcRsp->rsp = epSet;
rpcRsp->len = sizeof(SEpSet);
mDebug("msg:%p, ahandle:%p type:%s in mpeer queue is redirected, numOfEps:%d inUse:%d", pMsg, ahandle,
taosMsg[msgType], epSet->numOfEps, epSet->inUse);
code = TSDB_CODE_RPC_REDIRECT;
goto PROCESS_PEER_REQ_END;
}
if (tsMworker.peerReqFp[msgType] == NULL) {
mError("msg:%p, ahandle:%p type:%s in mpeer queue, not processed", pMsg, ahandle, taosMsg[msgType]);
code = TSDB_CODE_MND_MSG_NOT_PROCESSED;
goto PROCESS_PEER_REQ_END;
}
code = (*tsMworker.peerReqFp[msgType])(pMsg);
PROCESS_PEER_REQ_END:
mndSendRsp(pMsg, code);
}
static void mnodeProcessPeerRsp(SMnodeMsg *pMsg, void *unused) {
int32_t msgType = pMsg->rpcMsg.msgType;
SRpcMsg *pRpcMsg = &pMsg->rpcMsg;
if (!mnodeIsMaster()) {
mError("msg:%p, ahandle:%p type:%s not processed for not master", pRpcMsg, pRpcMsg->ahandle, taosMsg[msgType]);
mndCleanupMsg2(pMsg);
}
if (tsMworker.peerRspFp[msgType]) {
(*tsMworker.peerRspFp[msgType])(pRpcMsg);
} else {
mError("msg:%p, ahandle:%p type:%s is not processed", pRpcMsg, pRpcMsg->ahandle, taosMsg[msgType]);
}
mndCleanupMsg2(pMsg);
}
#endif
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录