Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Tonvia
TDengine
提交
6d196847
T
TDengine
项目概览
Tonvia
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6d196847
编写于
8月 20, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-5992] add set config interface for connector
上级
d3c9fc73
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
46 addition
and
42 deletion
+46
-42
src/client/CMakeLists.txt
src/client/CMakeLists.txt
+8
-4
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+35
-0
src/util/inc/tconfig.h
src/util/inc/tconfig.h
+1
-0
src/util/src/tconfig.c
src/util/src/tconfig.c
+2
-38
未找到文件。
src/client/CMakeLists.txt
浏览文件 @
6d196847
...
...
@@ -8,10 +8,11 @@ AUX_SOURCE_DIRECTORY(src SRC)
IF
(
TD_LINUX
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/jni/linux
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/cJson/inc
)
# set the static lib name
ADD_LIBRARY
(
taos_static STATIC
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
taos_static common query trpc tutil pthread m rt
${
VAR_TSZ
}
)
TARGET_LINK_LIBRARIES
(
taos_static common query trpc tutil pthread
cJson
m rt
${
VAR_TSZ
}
)
SET_TARGET_PROPERTIES
(
taos_static PROPERTIES OUTPUT_NAME
"taos_static"
)
SET_TARGET_PROPERTIES
(
taos_static PROPERTIES CLEAN_DIRECT_OUTPUT 1
)
...
...
@@ -34,10 +35,11 @@ IF (TD_LINUX)
ELSEIF
(
TD_DARWIN
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/jni/linux
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/cJson/inc
)
# set the static lib name
ADD_LIBRARY
(
taos_static STATIC
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
taos_static common query trpc tutil pthread m lua
)
TARGET_LINK_LIBRARIES
(
taos_static common query trpc tutil pthread m lua
cJson
)
SET_TARGET_PROPERTIES
(
taos_static PROPERTIES OUTPUT_NAME
"taos_static"
)
SET_TARGET_PROPERTIES
(
taos_static PROPERTIES CLEAN_DIRECT_OUTPUT 1
)
...
...
@@ -57,11 +59,12 @@ ELSEIF (TD_DARWIN)
ELSEIF
(
TD_WINDOWS
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/jni/windows
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/jni/windows/win32
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/cJson/inc
)
CONFIGURE_FILE
(
"
${
TD_COMMUNITY_DIR
}
/src/client/src/taos.rc.in"
"
${
TD_COMMUNITY_DIR
}
/src/client/src/taos.rc"
)
ADD_LIBRARY
(
taos_static STATIC
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
taos_static trpc tutil query
)
TARGET_LINK_LIBRARIES
(
taos_static trpc tutil
cJson
query
)
# generate dynamic library (*.dll)
ADD_LIBRARY
(
taos SHARED
${
SRC
}
${
TD_COMMUNITY_DIR
}
/src/client/src/taos.rc
)
...
...
@@ -73,9 +76,10 @@ ELSEIF (TD_WINDOWS)
ELSEIF
(
TD_DARWIN
)
SET
(
CMAKE_MACOSX_RPATH 1
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/jni/linux
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/cJson/inc
)
ADD_LIBRARY
(
taos_static STATIC
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
taos_static query trpc tutil pthread m lua
)
TARGET_LINK_LIBRARIES
(
taos_static query trpc tutil pthread
cJson
m lua
)
SET_TARGET_PROPERTIES
(
taos_static PROPERTIES OUTPUT_NAME
"taos_static"
)
# generate dynamic library (*.dylib)
...
...
src/client/src/tscSystem.c
浏览文件 @
6d196847
...
...
@@ -120,6 +120,41 @@ int32_t tscAcquireRpc(const char *key, const char *user, const char *secretEncry
return
0
;
}
#include "cJSON.h"
static
pthread_mutex_t
setConfMutex
=
PTHREAD_MUTEX_INITIALIZER
;
static
bool
setConfFlag
=
false
;
int
taos_set_config
(
const
char
*
config
){
if
(
taos_init
()
==
false
){
tscError
(
"failed to call taos_init"
);
return
-
1
;
}
pthread_mutex_lock
(
&
setConfMutex
);
if
(
setConfFlag
)
{
tscError
(
"already set config"
);
return
0
;
}
cJSON
*
root
=
cJSON_Parse
(
config
);
if
(
root
==
NULL
)
{
tscError
(
"failed to set config, invalid json format: %s"
,
config
);
return
-
1
;
}
int
size
=
cJSON_GetArraySize
(
root
);
for
(
int
i
=
0
;
i
<
size
;
i
++
){
cJSON
*
item
=
cJSON_GetArrayItem
(
root
,
i
);
if
(
!
item
)
{
tscError
(
"failed to read index:%d"
,
i
);
continue
;
}
taosReadConfigOption
(
item
->
string
,
item
->
valuestring
,
NULL
,
NULL
);
}
setConfFlag
=
true
;
pthread_mutex_unlock
(
&
setConfMutex
);
return
0
;
}
void
taos_init_imp
(
void
)
{
char
temp
[
128
]
=
{
0
};
...
...
src/util/inc/tconfig.h
浏览文件 @
6d196847
...
...
@@ -89,6 +89,7 @@ void taosDumpGlobalCfg();
void
taosInitConfigOption
(
SGlobalCfg
cfg
);
SGlobalCfg
*
taosGetConfigOption
(
const
char
*
option
);
void
taosReadConfigOption
(
const
char
*
option
,
char
*
value
,
char
*
value2
,
char
*
value3
);
#ifdef __cplusplus
}
...
...
src/util/src/tconfig.c
浏览文件 @
6d196847
...
...
@@ -258,7 +258,7 @@ SGlobalCfg *taosGetConfigOption(const char *option) {
return
NULL
;
}
static
void
taosReadConfigOption
(
const
char
*
option
,
char
*
value
,
char
*
value2
,
char
*
value3
)
{
void
taosReadConfigOption
(
const
char
*
option
,
char
*
value
,
char
*
value2
,
char
*
value3
)
{
for
(
int
i
=
0
;
i
<
tsGlobalConfigNum
;
++
i
)
{
SGlobalCfg
*
cfg
=
tsGlobalConfig
+
i
;
if
(
!
(
cfg
->
cfgType
&
TSDB_CFG_CTYPE_B_CONFIG
))
continue
;
...
...
@@ -560,40 +560,4 @@ void taosDumpGlobalCfg() {
taosDumpCfg
(
cfg
);
}
}
#include "cJSON.h"
static
pthread_mutex_t
setConfMutex
=
PTHREAD_MUTEX_INITIALIZER
;
static
bool
setConfFlag
=
false
;
int
taos_set_config
(
const
char
*
config
){
if
(
taos_init
()
==
false
){
uError
(
"failed to call taos_init"
);
return
-
1
;
}
pthread_mutex_lock
(
&
setConfMutex
);
if
(
setConfFlag
)
{
uError
(
"already set config"
);
return
0
;
}
cJSON
*
root
=
cJSON_Parse
(
config
);
if
(
root
==
NULL
)
{
uError
(
"failed to set config, invalid json format: %s"
,
config
);
return
-
1
;
}
int
size
=
cJSON_GetArraySize
(
root
);
for
(
int
i
=
0
;
i
<
size
;
i
++
){
cJSON
*
item
=
cJSON_GetArrayItem
(
root
,
i
);
if
(
!
item
)
{
uError
(
"failed to read index:%d"
,
i
);
continue
;
}
taosReadConfigOption
(
item
->
string
,
item
->
valuestring
,
NULL
,
NULL
);
}
setConfFlag
=
true
;
pthread_mutex_unlock
(
&
setConfMutex
);
return
0
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录