Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
412d3437
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看板
提交
412d3437
编写于
8月 01, 2022
作者:
wafwerar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add cloud grant cfg
上级
a73ea6f9
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
68 addition
and
21 deletion
+68
-21
include/common/tgrant.h
include/common/tgrant.h
+30
-0
include/util/taoserror.h
include/util/taoserror.h
+2
-0
source/common/CMakeLists.txt
source/common/CMakeLists.txt
+13
-3
source/common/src/systable.c
source/common/src/systable.c
+2
-16
source/common/src/tglobal.c
source/common/src/tglobal.c
+6
-1
source/dnode/mgmt/mgmt_dnode/CMakeLists.txt
source/dnode/mgmt/mgmt_dnode/CMakeLists.txt
+4
-0
source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
+2
-0
source/libs/command/src/command.c
source/libs/command/src/command.c
+2
-1
source/util/CMakeLists.txt
source/util/CMakeLists.txt
+5
-0
source/util/src/tconfig.c
source/util/src/tconfig.c
+2
-0
未找到文件。
include/common/tgrant.h
浏览文件 @
412d3437
...
...
@@ -22,6 +22,9 @@ extern "C" {
#include "os.h"
#include "taoserror.h"
#ifdef GRANTS_CFG
#include "tgrantCfg.h"
#endif
typedef
enum
{
TSDB_GRANT_ALL
,
...
...
@@ -37,10 +40,37 @@ typedef enum {
TSDB_GRANT_CONNS
,
TSDB_GRANT_STREAMS
,
TSDB_GRANT_CPU_CORES
,
TSDB_GRANT_STABLE
,
TSDB_GRANT_TABLE
,
}
EGrantType
;
int32_t
grantCheck
(
EGrantType
grant
);
#ifndef GRANTS_CFG
#define GRANTS_SCHEMA static const SSysDbTableSchema grantsSchema[] = { \
{.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "expire time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "storage(GB)", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "databases", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "users", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "accounts", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "connections", .bytes = 11 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "streams", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "cpu cores", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "speed(PPS)", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "querytime", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
}
#define GRANT_CFG_ADD
#define GRANT_CFG_SET
#define GRANT_CFG_CHECK
#define GRANT_CFG_SKIP
#define GRANT_CFG_DECLARE
#define GRANT_CFG_EXTERN
#endif
#ifdef __cplusplus
}
#endif
...
...
include/util/taoserror.h
浏览文件 @
412d3437
...
...
@@ -405,6 +405,8 @@ int32_t* taosGetErrno();
#define TSDB_CODE_GRANT_STORAGE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0809)
#define TSDB_CODE_GRANT_QUERYTIME_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080A)
#define TSDB_CODE_GRANT_CPU_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080B)
#define TSDB_CODE_GRANT_STABLE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080C)
#define TSDB_CODE_GRANT_TABLE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080D)
// sync
#define TSDB_CODE_SYN_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0903)
...
...
source/common/CMakeLists.txt
浏览文件 @
412d3437
aux_source_directory
(
src COMMON_SRC
)
add_library
(
common STATIC
${
COMMON_SRC
}
)
if
(
DEFINED GRANT_CFG_INCLUDE_DIR
)
add_definitions
(
-DGRANTS_CFG
)
endif
()
target_include_directories
(
common
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/common"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
PRIVATE
"
${
GRANT_CFG_INCLUDE_DIR
}
"
)
IF
(
${
TD_WINDOWS
}
)
PRIVATE
"
${
TD_SOURCE_DIR
}
/contrib/pthread"
PRIVATE
"
${
TD_SOURCE_DIR
}
/contrib/msvcregex"
target_include_directories
(
common
PRIVATE
"
${
TD_SOURCE_DIR
}
/contrib/pthread"
PRIVATE
"
${
TD_SOURCE_DIR
}
/contrib/msvcregex"
)
ENDIF
()
)
target_link_libraries
(
common
PUBLIC os
...
...
source/common/src/systable.c
浏览文件 @
412d3437
...
...
@@ -17,6 +17,7 @@
#include "taos.h"
#include "tdef.h"
#include "types.h"
#include "tgrant.h"
#define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
#define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
...
...
@@ -188,22 +189,7 @@ static const SSysDbTableSchema userUsersSchema[] = {
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
};
static
const
SSysDbTableSchema
grantsSchema
[]
=
{
{.
name
=
"version"
,
.
bytes
=
9
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"expire time"
,
.
bytes
=
19
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"expired"
,
.
bytes
=
5
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"storage(GB)"
,
.
bytes
=
21
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"timeseries"
,
.
bytes
=
21
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"databases"
,
.
bytes
=
10
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"users"
,
.
bytes
=
10
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"accounts"
,
.
bytes
=
10
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"dnodes"
,
.
bytes
=
10
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"connections"
,
.
bytes
=
11
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"streams"
,
.
bytes
=
9
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"cpu cores"
,
.
bytes
=
9
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"speed(PPS)"
,
.
bytes
=
9
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"querytime"
,
.
bytes
=
9
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
GRANTS_SCHEMA
;
static
const
SSysDbTableSchema
vgroupsSchema
[]
=
{
{.
name
=
"vgroup_id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
...
...
source/common/src/tglobal.c
浏览文件 @
412d3437
...
...
@@ -19,6 +19,9 @@
#include "tconfig.h"
#include "tdatablock.h"
#include "tlog.h"
#include "tgrant.h"
GRANT_CFG_DECLARE
;
SConfig
*
tsCfg
=
NULL
;
...
...
@@ -441,6 +444,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
if
(
cfgAddInt32
(
pCfg
,
"ttlPushInterval"
,
tsTtlPushInterval
,
1
,
100000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"udf"
,
tsStartUdfd
,
0
)
!=
0
)
return
-
1
;
GRANT_CFG_ADD
;
return
0
;
}
...
...
@@ -590,7 +594,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
if
(
tsQueryBufferSize
>=
0
)
{
tsQueryBufferSizeBytes
=
tsQueryBufferSize
*
1048576UL
;
}
GRANT_CFG_GET
;
return
0
;
}
...
...
@@ -603,6 +607,7 @@ void taosLocalCfgForbiddenToChange(char* name, bool* forbidden) {
*
forbidden
=
true
;
return
;
}
GRANT_CFG_CHECK
;
*
forbidden
=
false
;
}
...
...
source/dnode/mgmt/mgmt_dnode/CMakeLists.txt
浏览文件 @
412d3437
aux_source_directory
(
src MGMT_DNODE
)
add_library
(
mgmt_dnode STATIC
${
MGMT_DNODE
}
)
if
(
DEFINED GRANT_CFG_INCLUDE_DIR
)
add_definitions
(
-DGRANTS_CFG
)
endif
()
target_include_directories
(
mgmt_dnode
PUBLIC
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
PUBLIC
"
${
GRANT_CFG_INCLUDE_DIR
}
"
)
target_link_libraries
(
mgmt_dnode node_util
...
...
source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
浏览文件 @
412d3437
...
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#include "dmInt.h"
#include "systable.h"
#include "tgrant.h"
extern
SConfig
*
tsCfg
;
...
...
@@ -223,6 +224,7 @@ int32_t dmAppendVariablesToBlock(SSDataBlock *pBlock, int32_t dnodeId) {
for
(
int32_t
i
=
0
,
c
=
0
;
i
<
numOfCfg
;
++
i
,
c
=
0
)
{
SConfigItem
*
pItem
=
taosArrayGet
(
tsCfg
->
array
,
i
);
GRANT_CFG_SKIP
;
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
c
++
);
colDataAppend
(
pColInfo
,
i
,
(
const
char
*
)
&
dnodeId
,
false
);
...
...
source/libs/command/src/command.c
浏览文件 @
412d3437
...
...
@@ -19,6 +19,7 @@
#include "scheduler.h"
#include "tdatablock.h"
#include "tglobal.h"
#include "tgrant.h"
extern
SConfig
*
tsCfg
;
...
...
@@ -563,7 +564,7 @@ int32_t setLocalVariablesResultIntoDataBlock(SSDataBlock* pBlock) {
for
(
int32_t
i
=
0
,
c
=
0
;
i
<
numOfCfg
;
++
i
,
c
=
0
)
{
SConfigItem
*
pItem
=
taosArrayGet
(
tsCfg
->
array
,
i
);
GRANT_CFG_SKIP
;
char
name
[
TSDB_CONFIG_OPTION_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
name
,
pItem
->
name
,
TSDB_CONFIG_OPTION_LEN
+
VARSTR_HEADER_SIZE
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
c
++
);
...
...
source/util/CMakeLists.txt
浏览文件 @
412d3437
configure_file
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/version.c.in"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/version.c"
)
aux_source_directory
(
src UTIL_SRC
)
add_library
(
util STATIC
${
UTIL_SRC
}
)
if
(
DEFINED GRANT_CFG_INCLUDE_DIR
)
add_definitions
(
-DGRANTS_CFG
)
endif
()
target_include_directories
(
util
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/util"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
PRIVATE
"
${
TD_SOURCE_DIR
}
/include/common"
PRIVATE
"
${
GRANT_CFG_INCLUDE_DIR
}
"
)
target_link_libraries
(
util
...
...
source/util/src/tconfig.c
浏览文件 @
412d3437
...
...
@@ -21,6 +21,7 @@
#include "tenv.h"
#include "cJSON.h"
#include "tjson.h"
#include "tgrant.h"
#define CFG_NAME_PRINT_LEN 24
#define CFG_SRC_PRINT_LEN 12
...
...
@@ -301,6 +302,7 @@ static int32_t cfgSetTfsItem(SConfig *pCfg, const char *name, const char *value,
}
int32_t
cfgSetItem
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
value
,
ECfgSrcType
stype
)
{
GRANT_CFG_SET
;
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
name
);
if
(
pItem
==
NULL
)
{
return
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录