Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
306eafbd
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
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看板
提交
306eafbd
编写于
10月 17, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
decode acct
上级
6a24d82b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
91 addition
and
7 deletion
+91
-7
source/server/mnode/src/mnodeAcct.c
source/server/mnode/src/mnodeAcct.c
+82
-1
source/server/mnode/src/mnodeSdb.c
source/server/mnode/src/mnodeSdb.c
+9
-6
未找到文件。
source/server/mnode/src/mnodeAcct.c
浏览文件 @
306eafbd
...
...
@@ -18,7 +18,7 @@
#include "mnodeSdb.h"
static
void
mnodeCreateDefaultAcct
()
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SAcctObj
acctObj
=
{
0
};
tstrncpy
(
acctObj
.
acct
,
TSDB_DEFAULT_USER
,
TSDB_USER_LEN
);
...
...
@@ -39,6 +39,7 @@ int32_t mnodeEncodeAcct(SAcctObj *pAcct, char *buf, int32_t maxLen) {
int32_t
len
=
0
;
len
+=
snprintf
(
buf
+
len
,
maxLen
-
len
,
"{
\"
type
\"
:%d, "
,
MN_SDB_ACCT
);
len
+=
snprintf
(
buf
+
len
,
maxLen
-
len
,
"
\"
acct
\"
:
\"
%s
\"
, "
,
pAcct
->
acct
);
len
+=
snprintf
(
buf
+
len
,
maxLen
-
len
,
"
\"
acctId
\"
:
\"
%d
\"
, "
,
pAcct
->
acctId
);
len
+=
snprintf
(
buf
+
len
,
maxLen
-
len
,
"
\"
maxUsers
\"
:
\"
%d
\"
, "
,
pAcct
->
cfg
.
maxUsers
);
len
+=
snprintf
(
buf
+
len
,
maxLen
-
len
,
"
\"
maxDbs
\"
:
\"
%d
\"
, "
,
pAcct
->
cfg
.
maxDbs
);
...
...
@@ -53,7 +54,87 @@ int32_t mnodeEncodeAcct(SAcctObj *pAcct, char *buf, int32_t maxLen) {
}
SAcctObj
*
mnodeDecodeAcct
(
cJSON
*
root
)
{
int32_t
code
=
-
1
;
SAcctObj
*
pAcct
=
calloc
(
1
,
sizeof
(
SAcctObj
));
cJSON
*
acct
=
cJSON_GetObjectItem
(
root
,
"acct"
);
if
(
!
acct
||
acct
->
type
!=
cJSON_String
)
{
mError
(
"failed to parse acct since acct not found"
);
goto
DECODE_ACCT_OVER
;
}
tstrncpy
(
pAcct
->
acct
,
acct
->
valuestring
,
TSDB_USER_LEN
);
cJSON
*
acctId
=
cJSON_GetObjectItem
(
root
,
"acctId"
);
if
(
!
acctId
||
acctId
->
type
!=
cJSON_String
)
{
mError
(
"acct:%s, failed to parse since acctId not found"
,
pAcct
->
acct
);
goto
DECODE_ACCT_OVER
;
}
pAcct
->
acctId
=
atol
(
acctId
->
valuestring
);
cJSON
*
maxUsers
=
cJSON_GetObjectItem
(
root
,
"maxUsers"
);
if
(
!
maxUsers
||
maxUsers
->
type
!=
cJSON_String
)
{
mError
(
"acct:%s, failed to parse since maxUsers not found"
,
pAcct
->
acct
);
goto
DECODE_ACCT_OVER
;
}
pAcct
->
cfg
.
maxUsers
=
atol
(
maxUsers
->
valuestring
);
cJSON
*
maxDbs
=
cJSON_GetObjectItem
(
root
,
"maxDbs"
);
if
(
!
maxDbs
||
maxDbs
->
type
!=
cJSON_String
)
{
mError
(
"acct:%s, failed to parse since maxDbs not found"
,
pAcct
->
acct
);
goto
DECODE_ACCT_OVER
;
}
pAcct
->
cfg
.
maxDbs
=
atol
(
maxDbs
->
valuestring
);
cJSON
*
maxTimeSeries
=
cJSON_GetObjectItem
(
root
,
"maxTimeSeries"
);
if
(
!
maxTimeSeries
||
maxTimeSeries
->
type
!=
cJSON_String
)
{
mError
(
"acct:%s, failed to parse since maxTimeSeries not found"
,
pAcct
->
acct
);
goto
DECODE_ACCT_OVER
;
}
pAcct
->
cfg
.
maxTimeSeries
=
atol
(
maxTimeSeries
->
valuestring
);
cJSON
*
maxStreams
=
cJSON_GetObjectItem
(
root
,
"maxStreams"
);
if
(
!
maxStreams
||
maxStreams
->
type
!=
cJSON_String
)
{
mError
(
"acct:%s, failed to parse since maxStreams not found"
,
pAcct
->
acct
);
goto
DECODE_ACCT_OVER
;
}
pAcct
->
cfg
.
maxStreams
=
atol
(
maxStreams
->
valuestring
);
cJSON
*
maxStorage
=
cJSON_GetObjectItem
(
root
,
"maxStorage"
);
if
(
!
maxStorage
||
maxStorage
->
type
!=
cJSON_String
)
{
mError
(
"acct:%s, failed to parse since maxStorage not found"
,
pAcct
->
acct
);
goto
DECODE_ACCT_OVER
;
}
pAcct
->
cfg
.
maxStorage
=
atoll
(
maxStorage
->
valuestring
);
cJSON
*
accessState
=
cJSON_GetObjectItem
(
root
,
"accessState"
);
if
(
!
accessState
||
accessState
->
type
!=
cJSON_String
)
{
mError
(
"acct:%s, failed to parse since accessState not found"
,
pAcct
->
acct
);
goto
DECODE_ACCT_OVER
;
}
pAcct
->
cfg
.
accessState
=
atol
(
accessState
->
valuestring
);
cJSON
*
createdTime
=
cJSON_GetObjectItem
(
root
,
"createdTime"
);
if
(
!
createdTime
||
createdTime
->
type
!=
cJSON_String
)
{
mError
(
"acct:%s, failed to parse since createdTime not found"
,
pAcct
->
acct
);
goto
DECODE_ACCT_OVER
;
}
pAcct
->
createdTime
=
atol
(
createdTime
->
valuestring
);
cJSON
*
updateTime
=
cJSON_GetObjectItem
(
root
,
"updateTime"
);
if
(
!
updateTime
||
updateTime
->
type
!=
cJSON_String
)
{
mError
(
"acct:%s, failed to parse since updateTime not found"
,
pAcct
->
acct
);
goto
DECODE_ACCT_OVER
;
}
pAcct
->
updateTime
=
atol
(
updateTime
->
valuestring
);
code
=
0
;
mTrace
(
"acct:%s, parse success"
,
pAcct
->
acct
);
DECODE_ACCT_OVER:
if
(
code
!=
0
)
{
free
(
pAcct
);
pAcct
=
NULL
;
}
return
pAcct
;
}
...
...
source/server/mnode/src/mnodeSdb.c
浏览文件 @
306eafbd
...
...
@@ -96,7 +96,7 @@ static int32_t sdbReadDataFile() {
snprintf
(
file
,
sizeof
(
file
),
"%ssdb.data"
,
tsSdb
.
currDir
);
fp
=
fopen
(
file
,
"r"
);
if
(
!
fp
)
{
m
Error
(
"failed to open file:%s for read since %s"
,
file
,
strerror
(
errno
));
m
Debug
(
"failed to open file:%s for read since %s"
,
file
,
strerror
(
errno
));
goto
PARSE_SDB_DATA_ERROR
;
}
...
...
@@ -137,13 +137,16 @@ static int32_t sdbReadDataFile() {
continue
;
}
SdbDecodeFp
func
=
tsSdb
.
decodeFp
[
type
->
valueint
];
SdbHead
*
pHead
=
(
*
func
)(
root
);
SdbDecodeFp
decodeFp
=
tsSdb
.
decodeFp
[
type
->
valueint
];
SdbHead
*
pHead
=
(
*
decodeFp
)(
root
);
if
(
pHead
==
NULL
)
{
mError
(
"failed to parse since decode error, %s"
,
line
);
goto
PARSE_SDB_DATA_ERROR
;
}
pHead
->
type
=
type
->
valueint
;
pHead
->
status
=
MN_SDB_STAT_AVAIL
;
sdbInsertRow
(
pHead
->
type
,
pHead
);
cJSON_Delete
(
root
);
root
=
NULL
;
...
...
@@ -176,12 +179,12 @@ static int32_t sdbWriteDataFile() {
SHashObj
*
hash
=
tsSdb
.
hashObj
[
i
];
if
(
!
hash
)
continue
;
SdbEncodeFp
f
p
=
tsSdb
.
encodeFp
[
i
];
if
(
!
f
p
)
continue
;
SdbEncodeFp
encodeF
p
=
tsSdb
.
encodeFp
[
i
];
if
(
!
encodeF
p
)
continue
;
SdbHead
*
pHead
=
taosHashIterate
(
hash
,
NULL
);
while
(
pHead
!=
NULL
)
{
len
=
(
*
f
p
)(
pHead
,
buf
,
maxLen
);
len
=
(
*
encodeF
p
)(
pHead
,
buf
,
maxLen
);
if
(
len
>=
0
)
{
taosWriteFile
(
fd
,
buf
,
len
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录