Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
e1502677
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
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看板
提交
e1502677
编写于
7月 05, 2020
作者:
P
Ping Xiao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
jdbc test
上级
48d0543d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
470 addition
and
8 deletion
+470
-8
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/TDNode.java
...or/jdbc/src/main/java/com/taosdata/jdbc/utils/TDNode.java
+233
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/TDNodes.java
...r/jdbc/src/main/java/com/taosdata/jdbc/utils/TDNodes.java
+120
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/TDSimClient.java
...bc/src/main/java/com/taosdata/jdbc/utils/TDSimClient.java
+91
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/BaseTest.java
...nector/jdbc/src/test/java/com/taosdata/jdbc/BaseTest.java
+26
-8
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/TDNode.java
0 → 100644
浏览文件 @
e1502677
package
com.taosdata.jdbc.utils
;
import
java.io.File
;
import
java.util.concurrent.TimeUnit
;
public
class
TDNode
{
private
int
index
;
private
int
running
;
private
int
deployed
;
private
boolean
testCluster
;
private
int
valgrind
;
private
String
path
;
private
String
cfgDir
;
private
String
dataDir
;
private
String
logDir
;
private
String
cfgPath
;
public
TDNode
(
int
index
)
{
this
.
index
=
index
;
running
=
0
;
deployed
=
0
;
testCluster
=
false
;
valgrind
=
0
;
}
public
void
setPath
(
String
path
)
{
this
.
path
=
path
;
}
public
void
setValgrind
(
int
valgrind
)
{
this
.
valgrind
=
valgrind
;
}
public
void
setTestCluster
(
boolean
testCluster
)
{
this
.
testCluster
=
testCluster
;
}
public
void
start
()
{
String
selfPath
=
System
.
getProperty
(
"user.dir"
);
String
binPath
=
""
;
String
projDir
=
selfPath
+
"../../../"
;
File
dir
=
new
File
(
projDir
);
File
[]
fileList
=
dir
.
listFiles
();
if
(
fileList
==
null
||
fileList
.
length
==
0
)
{
System
.
out
.
println
(
"The project path doens't exist"
);
return
;
}
for
(
File
file
:
fileList
)
{
if
(
file
.
getName
().
equals
(
"taosd"
)
&&
!
file
.
getAbsolutePath
().
contains
(
"packing"
))
{
binPath
=
file
.
getAbsolutePath
();
break
;
}
}
if
(
binPath
.
equals
(
""
))
{
System
.
out
.
println
(
"taosd not found"
);
return
;
}
else
{
System
.
out
.
println
(
"taosd found in "
+
binPath
);
}
if
(
this
.
deployed
==
0
)
{
System
.
out
.
println
(
"dnode"
+
index
+
"is not deployed"
);
return
;
}
String
cmd
=
""
;
if
(
this
.
valgrind
==
0
)
{
cmd
=
"nohup "
+
binPath
+
" -c "
+
this
.
cfgDir
+
" > /dev/null 2>&1 & "
;
}
else
{
String
valgrindCmdline
=
"valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes"
;
cmd
=
"nohup "
+
valgrindCmdline
+
" "
+
binPath
+
" -c "
+
this
.
cfgDir
+
" 2>&1 & "
;
}
try
{
if
(
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
()
!=
0
)
{
return
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
this
.
running
=
1
;
}
public
void
stop
()
{
String
toBeKilled
=
""
;
if
(
this
.
valgrind
==
0
)
{
toBeKilled
=
"taosd"
;
}
else
{
toBeKilled
=
"valgrind.bin"
;
}
if
(
this
.
running
!=
0
)
{
String
psCmd
=
"ps -ef|grep -w %s| grep -v grep | awk '{print "
+
toBeKilled
+
"}'"
;
try
{
Process
ps
=
Runtime
.
getRuntime
().
exec
(
psCmd
);
ps
.
waitFor
();
long
pid
=
ps
.
pid
();
String
killCmd
=
"kill -9 "
+
pid
;
Runtime
.
getRuntime
().
exec
(
killCmd
).
waitFor
();
for
(
int
port
=
6030
;
port
<
6041
;
port
++)
{
String
fuserCmd
=
"fuser -k -n tcp "
+
port
;
Runtime
.
getRuntime
().
exec
(
fuserCmd
).
waitFor
();
}
if
(
this
.
valgrind
==
1
)
{
TimeUnit
.
SECONDS
.
sleep
(
2
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
this
.
running
=
0
;
System
.
out
.
println
(
"dnode:"
+
this
.
index
+
"is stopped by kill -9"
);
}
}
public
void
startIP
()
{
try
{
String
cmd
=
"sudo ifconfig lo:"
+
index
+
"192.168.0."
+
index
+
" up"
;
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
void
stopIP
()
{
try
{
String
cmd
=
"sudo ifconfig lo:"
+
index
+
"192.168.0."
+
index
+
" down"
;
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
void
setCfgConfig
(
String
option
,
String
value
)
{
try
{
String
cmd
=
"echo "
+
option
+
" "
+
value
+
" >> "
+
this
.
cfgPath
;
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
String
getDnodeRootDir
()
{
String
dnodeRootDir
=
this
.
path
+
"/sim/psim/dnode"
+
this
.
index
;
return
dnodeRootDir
;
}
public
String
getDnodesRootDir
()
{
String
dnodesRootDir
=
this
.
path
+
"/sim/psim"
+
this
.
index
;
return
dnodesRootDir
;
}
public
void
deploy
()
{
this
.
logDir
=
this
.
path
+
"/sim/dnode"
+
this
.
index
+
"/log"
;
this
.
dataDir
=
this
.
path
+
"/sim/dnode"
+
this
.
index
+
"/data"
;
this
.
cfgDir
=
this
.
path
+
"/sim/dnode"
+
this
.
index
+
"/cfg"
;
this
.
cfgPath
=
this
.
path
+
"/sim/dnode"
+
this
.
index
+
"/cfg/taos.cfg"
;
try
{
String
cmd
=
"rm -rf "
+
this
.
logDir
;
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
();
cmd
=
"rm -rf "
+
this
.
cfgDir
;
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
();
cmd
=
"rm -rf "
+
this
.
dataDir
;
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
();
cmd
=
"mkdir -p "
+
this
.
logDir
;
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
();
cmd
=
"mkdir -p "
+
this
.
cfgDir
;
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
();
cmd
=
"mkdir -p "
+
this
.
dataDir
;
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
();
cmd
=
"touch "
+
this
.
cfgPath
;
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
this
.
testCluster
)
{
startIP
();
setCfgConfig
(
"masterIp"
,
"192.168.0.1"
);
setCfgConfig
(
"secondIp"
,
"192.168.0.2"
);
setCfgConfig
(
"publicIp"
,
"192.168.0."
+
this
.
index
);
setCfgConfig
(
"internalIp"
,
"192.168.0."
+
this
.
index
);
setCfgConfig
(
"privateIp"
,
"192.168.0."
+
this
.
index
);
}
setCfgConfig
(
"dataDir"
,
this
.
dataDir
);
setCfgConfig
(
"logDir"
,
this
.
logDir
);
setCfgConfig
(
"numOfLogLines"
,
"100000000"
);
setCfgConfig
(
"mnodeEqualVnodeNum"
,
"0"
);
setCfgConfig
(
"walLevel"
,
"1"
);
setCfgConfig
(
"statusInterval"
,
"1"
);
setCfgConfig
(
"numOfTotalVnodes"
,
"64"
);
setCfgConfig
(
"numOfMnodes"
,
"3"
);
setCfgConfig
(
"numOfThreadsPerCore"
,
"2.0"
);
setCfgConfig
(
"monitor"
,
"0"
);
setCfgConfig
(
"maxVnodeConnections"
,
"30000"
);
setCfgConfig
(
"maxMgmtConnections"
,
"30000"
);
setCfgConfig
(
"maxMeterConnections"
,
"30000"
);
setCfgConfig
(
"maxShellConns"
,
"30000"
);
setCfgConfig
(
"locale"
,
"en_US.UTF-8"
);
setCfgConfig
(
"charset"
,
"UTF-8"
);
setCfgConfig
(
"asyncLog"
,
"0"
);
setCfgConfig
(
"anyIp"
,
"0"
);
setCfgConfig
(
"dDebugFlag"
,
"135"
);
setCfgConfig
(
"mDebugFlag"
,
"135"
);
setCfgConfig
(
"sdbDebugFlag"
,
"135"
);
setCfgConfig
(
"rpcDebugFlag"
,
"135"
);
setCfgConfig
(
"tmrDebugFlag"
,
"131"
);
setCfgConfig
(
"cDebugFlag"
,
"135"
);
setCfgConfig
(
"httpDebugFlag"
,
"135"
);
setCfgConfig
(
"monitorDebugFlag"
,
"135"
);
setCfgConfig
(
"udebugFlag"
,
"135"
);
setCfgConfig
(
"jnidebugFlag"
,
"135"
);
setCfgConfig
(
"qdebugFlag"
,
"135"
);
this
.
deployed
=
1
;
}
}
\ No newline at end of file
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/TDNodes.java
0 → 100644
浏览文件 @
e1502677
package
com.taosdata.jdbc.utils
;
import
java.io.File
;
import
java.util.*
;
public
class
TDNodes
{
private
ArrayList
<
TDNode
>
tdNodes
;
private
boolean
simDeployed
;
private
boolean
testCluster
;
private
int
valgrind
;
private
String
path
;
public
TDNodes
()
{
tdNodes
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<
11
;
i
++)
{
tdNodes
.
add
(
new
TDNode
(
i
));
}
this
.
simDeployed
=
false
;
path
=
""
;
}
public
TDNodes
(
String
path
)
{
try
{
String
psCmd
=
"ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'"
;
Process
ps
=
Runtime
.
getRuntime
().
exec
(
psCmd
);
ps
.
wait
();
String
killCmd
=
"kill -9 "
+
ps
.
pid
();
Runtime
.
getRuntime
().
exec
(
killCmd
).
waitFor
();
psCmd
=
"ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'"
;
ps
=
Runtime
.
getRuntime
().
exec
(
psCmd
);
ps
.
wait
();
killCmd
=
"kill -9 "
+
ps
.
pid
();
Runtime
.
getRuntime
().
exec
(
killCmd
).
waitFor
();
String
binPath
=
System
.
getProperty
(
"user.dir"
);
binPath
+=
"/../../../debug"
;
System
.
out
.
println
(
"binPath: "
+
binPath
);
File
file
=
new
File
(
path
);
binPath
=
file
.
getCanonicalPath
();
System
.
out
.
println
(
"binPath real path: "
+
binPath
);
if
(
path
.
isEmpty
())
{
file
=
new
File
(
path
+
"/../../"
);
path
=
file
.
getCanonicalPath
();
}
for
(
int
i
=
0
;
i
<
tdNodes
.
size
();
i
++)
{
tdNodes
.
get
(
i
).
setPath
(
path
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
void
setTestCluster
(
boolean
testCluster
)
{
this
.
testCluster
=
testCluster
;
}
public
void
setValgrid
(
int
valgrind
)
{
this
.
valgrind
=
valgrind
;
}
public
void
setPath
(
String
path
)
{
this
.
path
=
path
;
}
public
void
check
(
int
index
)
{
if
(
index
<
1
||
index
>
10
)
{
System
.
out
.
println
(
"index: "
+
index
+
" should on a scale of [1, 10]"
);
return
;
}
}
public
void
deploy
(
int
index
)
{
System
.
out
.
println
(
"======Start deploying tsim====="
);
TDSimClient
sim
=
new
TDSimClient
();
sim
.
setPath
(
path
);
System
.
out
.
println
(
"====== "
+
path
+
"====="
);
sim
.
setTestCluster
(
this
.
testCluster
);
if
(
this
.
simDeployed
==
false
)
{
sim
.
deploy
();
this
.
simDeployed
=
true
;
}
check
(
index
);
tdNodes
.
get
(
index
-
1
).
setTestCluster
(
this
.
testCluster
);
tdNodes
.
get
(
index
-
1
).
setValgrind
(
valgrind
);
tdNodes
.
get
(
index
-
1
).
deploy
();
}
public
void
cfg
(
int
index
,
String
option
,
String
value
)
{
check
(
index
);
tdNodes
.
get
(
index
-
1
).
setCfgConfig
(
option
,
value
);
}
public
void
start
(
int
index
)
{
check
(
index
);
tdNodes
.
get
(
index
-
1
).
start
();
}
public
void
stop
(
int
index
)
{
check
(
index
);
tdNodes
.
get
(
index
-
1
).
stop
();
}
public
void
startIP
(
int
index
)
{
check
(
index
);
tdNodes
.
get
(
index
-
1
).
startIP
();
}
public
void
stopIP
(
int
index
)
{
check
(
index
);
tdNodes
.
get
(
index
-
1
).
stopIP
();
}
}
\ No newline at end of file
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/TDSimClient.java
0 → 100644
浏览文件 @
e1502677
package
com.taosdata.jdbc.utils
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
public
class
TDSimClient
{
private
boolean
testCluster
;
private
String
path
;
private
String
cfgDir
;
private
String
logDir
;
private
String
cfgPath
;
public
TDSimClient
()
{
testCluster
=
false
;
}
public
void
setTestCluster
(
boolean
testCluster
)
{
this
.
testCluster
=
testCluster
;
}
public
void
setPath
(
String
path
)
{
this
.
path
=
path
;
}
public
void
setCfgConfig
(
String
option
,
String
value
)
{
String
cmd
=
"echo "
+
option
+
" "
+
value
+
" >> "
+
this
.
cfgPath
;
try
{
Process
ps
=
Runtime
.
getRuntime
().
exec
(
cmd
);
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
ps
.
getInputStream
()));
while
(
br
.
readLine
()
!=
null
)
{
System
.
out
.
println
(
br
.
readLine
());
}
ps
.
waitFor
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
void
deploy
()
{
this
.
logDir
=
this
.
path
+
"/sim/psim/log"
;
System
.
out
.
println
(
"======logDir: "
+
logDir
+
"====="
);
this
.
cfgDir
=
this
.
path
+
"/sim/psim/cfg"
;
System
.
out
.
println
(
"======cfgDir: "
+
cfgDir
+
"====="
);
this
.
cfgPath
=
this
.
path
+
"/sim/psim/cfg/taos.cfg"
;
System
.
out
.
println
(
"======cfgPath: "
+
cfgPath
+
"====="
);
try
{
String
cmd
=
"rm -rf "
+
this
.
logDir
;
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
();
cmd
=
"rm -rf "
+
this
.
cfgDir
;
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
();
cmd
=
"mkdir -p "
+
this
.
logDir
;
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
();
cmd
=
"mkdir -p "
+
this
.
cfgDir
;
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
();
cmd
=
"touch "
+
this
.
cfgPath
;
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
this
.
testCluster
)
{
setCfgConfig
(
"masterIp"
,
"192.168.0.1"
);
setCfgConfig
(
"secondIp"
,
"192.168.0.2"
);
}
setCfgConfig
(
"logDir"
,
this
.
logDir
);
setCfgConfig
(
"numOfLogLines"
,
"100000000"
);
setCfgConfig
(
"numOfThreadsPerCore"
,
"2.0"
);
setCfgConfig
(
"locale"
,
"en_US.UTF-8"
);
setCfgConfig
(
"charset"
,
"UTF-8"
);
setCfgConfig
(
"asyncLog"
,
"0"
);
setCfgConfig
(
"anyIp"
,
"0"
);
setCfgConfig
(
"sdbDebugFlag"
,
"135"
);
setCfgConfig
(
"rpcDebugFlag"
,
"135"
);
setCfgConfig
(
"tmrDebugFlag"
,
"131"
);
setCfgConfig
(
"cDebugFlag"
,
"135"
);
setCfgConfig
(
"udebugFlag"
,
"135"
);
setCfgConfig
(
"jnidebugFlag"
,
"135"
);
setCfgConfig
(
"qdebugFlag"
,
"135"
);
}
}
\ No newline at end of file
src/connector/jdbc/src/test/java/com/taosdata/jdbc/BaseTest.java
浏览文件 @
e1502677
package
com.taosdata.jdbc
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.InputStreamReader
;
import
com.taosdata.jdbc.utils.TDNodes
;
import
org.junit.BeforeClass
;
public
class
BaseTest
{
private
static
boolean
testCluster
=
false
;
private
static
String
deployPath
=
System
.
getProperty
(
"user.dir"
);
private
static
int
valgrind
=
0
;
@BeforeClass
public
static
void
setupEnv
()
{
try
{
String
path
=
System
.
getProperty
(
"user.dir"
);
String
bashPath
=
path
+
"/buildTDengine.sh"
;
// String path = System.getProperty("user.dir");
// String bashPath = path + "/buildTDengine.sh";
// Process ps = Runtime.getRuntime().exec(bashPath);
// ps.waitFor();
// BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));
// while(br.readLine() != null) {
// System.out.println(br.readLine());
// }
File
file
=
new
File
(
deployPath
+
"/../../../"
);
String
rootPath
=
file
.
getCanonicalPath
();
Process
ps
=
Runtime
.
getRuntime
().
exec
(
bashPath
);
ps
.
waitFor
();
TDNodes
tdNodes
=
new
TDNodes
();
tdNodes
.
setPath
(
rootPath
);
tdNodes
.
setTestCluster
(
testCluster
);
tdNodes
.
setValgrid
(
valgrind
);
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
ps
.
getInputStream
()));
while
(
br
.
readLine
()
!=
null
)
{
System
.
out
.
println
(
br
.
readLine
());
}
tdNodes
.
deploy
(
1
);
tdNodes
.
start
(
1
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录