Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
de30e247
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
de30e247
编写于
8月 24, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/TD-5992' of github.com:taosdata/TDengine into feature/TD-5992
上级
9cc88d1f
1b1ffab3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
80 addition
and
71 deletion
+80
-71
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+7
-11
src/client/tests/cliTest.cpp
src/client/tests/cliTest.cpp
+3
-3
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
...dbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
+8
-4
src/connector/jdbc/src/test/java/com/taosdata/jdbc/SetConfigurationInJNITest.java
...est/java/com/taosdata/jdbc/SetConfigurationInJNITest.java
+31
-37
src/util/inc/tconfig.h
src/util/inc/tconfig.h
+1
-1
src/util/src/tconfig.c
src/util/src/tconfig.c
+30
-15
未找到文件。
src/client/src/tscSystem.c
浏览文件 @
de30e247
...
...
@@ -442,12 +442,13 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
static
int
taos_set_config_imp
(
const
char
*
config
){
static
bool
setConfFlag
=
false
;
if
(
setConfFlag
)
{
tscError
(
"already set config"
);
printf
(
"already set config"
);
return
0
;
}
taosInitGlobalCfg
();
cJSON
*
root
=
cJSON_Parse
(
config
);
if
(
root
==
NULL
)
{
tscError
(
"failed to set config, invalid json format: %s"
,
config
);
printf
(
"failed to set config, invalid json format: %s"
,
config
);
return
-
1
;
}
...
...
@@ -456,30 +457,25 @@ static int taos_set_config_imp(const char *config){
for
(
int
i
=
0
;
i
<
size
;
i
++
){
cJSON
*
item
=
cJSON_GetArrayItem
(
root
,
i
);
if
(
!
item
)
{
tscError
(
"failed to read index:%d"
,
i
);
printf
(
"failed to read index:%d"
,
i
);
ret
=
-
2
;
continue
;
}
if
(
!
taosReadConfigOption
(
item
->
string
,
item
->
valuestring
,
NULL
,
NULL
)){
if
(
!
taosReadConfigOption
(
item
->
string
,
item
->
valuestring
,
NULL
,
NULL
,
TAOS_CFG_CSTATUS_OPTION
)){
printf
(
"set failed:%s->%s"
,
item
->
string
,
item
->
valuestring
);
ret
=
-
2
;
}
}
taosPrintGlobalCfg
();
setConfFlag
=
true
;
return
ret
;
}
int
taos_set_config
(
const
char
*
config
){
if
(
taos_init
()){
tscError
(
"failed to call taos_init"
);
return
-
1
;
}
static
int32_t
lock
=
0
;
for
(
int
i
=
1
;
atomic_val_compare_exchange_32
(
&
lock
,
0
,
1
)
!=
0
;
++
i
)
{
if
(
i
%
1000
==
0
)
{
tscInfo
(
"haven't acquire lock after spin %d times."
,
i
);
printf
(
"haven't acquire lock after spin %d times."
,
i
);
sched_yield
();
}
}
...
...
src/client/tests/cliTest.cpp
浏览文件 @
de30e247
...
...
@@ -259,12 +259,12 @@ void validateResultFields() {
}
/* test parse time function */
TEST
(
testCase
,
result_field_test
)
{
const
char
*
config
=
"{
\"
debugFlag
\"
:
\"
135
\"
}"
;
taos_set_config
(
config
);
taos_set_config
(
config
);
taos_options
(
TSDB_OPTION_CONFIGDIR
,
"~/first/cfg"
);
taos_init
();
const
char
*
config
=
"{
\"
tempDir
\"
:
\"
/root/tmp/
\"
,
\"
serverPort
\"
:
\"
3333
\"
}"
;
taos_set_config
(
config
);
taos_set_config
(
config
);
validateResultFields
();
stmtInsertTest
();
}
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
浏览文件 @
de30e247
...
...
@@ -57,13 +57,17 @@ public class TSDBJNIConnector {
}
}
p
ublic
static
native
void
initImp
(
String
configDir
);
p
rivate
static
native
void
initImp
(
String
configDir
);
p
ublic
static
native
int
setOptions
(
int
optionIndex
,
String
optionValue
);
p
rivate
static
native
int
setOptions
(
int
optionIndex
,
String
optionValue
);
p
ublic
static
native
String
getTsCharset
();
p
rivate
static
native
String
getTsCharset
();
public
static
native
int
setConfig
(
String
config
);
public
static
void
setConfig
(
String
config
)
{
setConfigImp
(
config
);
}
private
static
native
int
setConfigImp
(
String
config
);
public
boolean
connect
(
String
host
,
int
port
,
String
dbName
,
String
user
,
String
password
)
throws
SQLException
{
if
(
this
.
taos
!=
TSDBConstants
.
JNI_NULL_POINTER
)
{
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/SetConfigurationInJNITest.java
浏览文件 @
de30e247
package
com.taosdata.jdbc
;
import
org.junit.After
;
import
org.junit.Test
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.SQLException
;
import
java.util.Arrays
;
import
static
org
.
junit
.
Assert
.*;
import
java.sql.Statement
;
public
class
SetConfigurationInJNITest
{
private
String
host
=
"127.0.0.1"
;
private
String
dbname
=
"test_jni"
;
private
String
debugFlagJSON
=
"{ \"debugFlag\": \"135\"}"
;
private
long
maxSQLLength
=
1024000
;
private
String
debugFlagJSON
=
"{ \"debugFlag\": 135}"
;
private
String
maxSqlLengthJSON
=
"{ \"maxSQLLength\": "
+
maxSQLLength
+
"}"
;
@Test
public
void
testDebugFlag
()
{
public
void
setConfigBeforeConnectIsValid
()
{
try
{
// init
TSDBJNIConnector
.
initImp
(
null
);
TSDBJNIConnector
.
setOptions
(
0
,
null
);
TSDBJNIConnector
.
setOptions
(
1
,
null
);
TSDBJNIConnector
.
setOptions
(
2
,
null
);
String
tsCharset
=
TSDBJNIConnector
.
getTsCharset
();
assertEquals
(
""
,
tsCharset
);
TSDBJNIConnector
.
setConfig
(
debugFlagJSON
);
// connect
TSDBJNIConnector
jniConnector
=
new
TSDBJNIConnector
();
boolean
connected
=
jniConnector
.
connect
(
host
,
0
,
null
,
"root"
,
"taosdata"
);
assertTrue
(
connected
);
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/?user=root&password=taosdata"
);
Statement
stmt
=
conn
.
createStatement
();
String
[]
setupSqls
=
{
"drop database if exists "
+
dbname
,
"create database if not exists "
+
dbname
,
"use "
+
dbname
,
"create table weather(ts timestamp, f1 int) tags(loc nchar(10))"
,
"insert into t1 using weather tags('beijing') values(now, 1)"
,
"drop database if exists "
+
dbname
};
Arrays
.
asList
(
setupSqls
).
forEach
(
sql
->
{
try
{
long
setupSql
=
jniConnector
.
executeQuery
(
sql
);
if
(
jniConnector
.
isUpdateQuery
(
setupSql
))
{
jniConnector
.
freeResultSet
(
setupSql
);
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
});
stmt
.
execute
(
"drop database if exists "
+
dbname
);
stmt
.
execute
(
"create database if not exists "
+
dbname
);
stmt
.
execute
(
"use "
+
dbname
);
stmt
.
execute
(
"create table weather(ts timestamp, f1 int) tags(loc nchar(10))"
);
stmt
.
close
();
conn
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
testMaxSQLLength
()
{
public
void
setConfigAfterConnectIsInvalid
()
{
try
{
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/?user=root&password=taosdata"
);
TSDBJNIConnector
.
setConfig
(
debugFlagJSON
);
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop database if exists "
+
dbname
);
stmt
.
execute
(
"create database if not exists "
+
dbname
);
stmt
.
execute
(
"use "
+
dbname
);
stmt
.
execute
(
"create table weather(ts timestamp, f1 int) tags(loc nchar(10))"
);
stmt
.
close
();
conn
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
\ No newline at end of file
src/util/inc/tconfig.h
浏览文件 @
de30e247
...
...
@@ -89,7 +89,7 @@ void taosDumpGlobalCfg();
void
taosInitConfigOption
(
SGlobalCfg
cfg
);
SGlobalCfg
*
taosGetConfigOption
(
const
char
*
option
);
bool
taosReadConfigOption
(
const
char
*
option
,
char
*
value
,
char
*
value2
,
char
*
value3
);
bool
taosReadConfigOption
(
const
char
*
option
,
char
*
value
,
char
*
value2
,
char
*
value3
,
int8_t
cfgStatus
);
#ifdef __cplusplus
}
...
...
src/util/src/tconfig.c
浏览文件 @
de30e247
...
...
@@ -293,7 +293,9 @@ SGlobalCfg *taosGetConfigOption(const char *option) {
return
NULL
;
}
bool
taosReadConfigOption
(
const
char
*
option
,
char
*
value
,
char
*
value2
,
char
*
value3
)
{
bool
taosReadConfigOption
(
const
char
*
option
,
char
*
value
,
char
*
value2
,
char
*
value3
,
int8_t
cfgStatus
)
{
bool
ret
=
false
;
for
(
int
i
=
0
;
i
<
tsGlobalConfigNum
;
++
i
)
{
SGlobalCfg
*
cfg
=
tsGlobalConfig
+
i
;
if
(
!
(
cfg
->
cfgType
&
TSDB_CFG_CTYPE_B_CONFIG
))
continue
;
...
...
@@ -301,35 +303,48 @@ bool taosReadConfigOption(const char *option, char *value, char *value2, char *v
switch
(
cfg
->
valType
)
{
case
TAOS_CFG_VTYPE_INT8
:
return
taosReadInt8Config
(
cfg
,
value
);
ret
=
taosReadInt8Config
(
cfg
,
value
);
break
;
case
TAOS_CFG_VTYPE_INT16
:
return
taosReadInt16Config
(
cfg
,
value
);
ret
=
taosReadInt16Config
(
cfg
,
value
);
break
;
case
TAOS_CFG_VTYPE_INT32
:
return
taosReadInt32Config
(
cfg
,
value
);
ret
=
taosReadInt32Config
(
cfg
,
value
);
break
;
case
TAOS_CFG_VTYPE_UINT16
:
return
taosReadUInt16Config
(
cfg
,
value
);
ret
=
taosReadUInt16Config
(
cfg
,
value
);
break
;
case
TAOS_CFG_VTYPE_FLOAT
:
return
taosReadFloatConfig
(
cfg
,
value
);
ret
=
taosReadFloatConfig
(
cfg
,
value
);
break
;
case
TAOS_CFG_VTYPE_DOUBLE
:
return
taosReadDoubleConfig
(
cfg
,
value
);
ret
=
taosReadDoubleConfig
(
cfg
,
value
);
break
;
case
TAOS_CFG_VTYPE_STRING
:
return
taosReadStringConfig
(
cfg
,
value
);
ret
=
taosReadStringConfig
(
cfg
,
value
);
break
;
case
TAOS_CFG_VTYPE_IPSTR
:
return
taosReadIpStrConfig
(
cfg
,
value
);
ret
=
taosReadIpStrConfig
(
cfg
,
value
);
break
;
case
TAOS_CFG_VTYPE_DIRECTORY
:
return
taosReadDirectoryConfig
(
cfg
,
value
);
ret
=
taosReadDirectoryConfig
(
cfg
,
value
);
break
;
case
TAOS_CFG_VTYPE_DATA_DIRCTORY
:
if
(
taosReadDirectoryConfig
(
cfg
,
value
))
{
taosReadDataDirCfg
(
value
,
value2
,
value3
);
ret
urn
true
;
ret
=
true
;
}
return
false
;
ret
=
false
;
break
;
default:
uError
(
"config option:%s, input value:%s, can't be recognized"
,
option
,
value
);
return
false
;
ret
=
false
;
}
if
(
ret
&&
cfgStatus
==
TAOS_CFG_CSTATUS_OPTION
){
cfg
->
cfgStatus
=
TAOS_CFG_CSTATUS_OPTION
;
}
}
return
false
;
return
ret
;
}
void
taosInitConfigOption
(
SGlobalCfg
cfg
)
{
...
...
@@ -464,7 +479,7 @@ bool taosReadGlobalCfg() {
if
(
vlen3
!=
0
)
value3
[
vlen3
]
=
0
;
}
taosReadConfigOption
(
option
,
value
,
value2
,
value3
);
taosReadConfigOption
(
option
,
value
,
value2
,
value3
,
TAOS_CFG_CSTATUS_FILE
);
}
fclose
(
fp
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录