Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ec47ae9c
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看板
提交
ec47ae9c
编写于
7月 22, 2020
作者:
P
Ping Xiao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-978: adjust kill command
上级
73c3446e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
62 addition
and
49 deletion
+62
-49
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/TDNode.java
...or/jdbc/src/main/java/com/taosdata/jdbc/utils/TDNode.java
+44
-7
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/TDNodes.java
...r/jdbc/src/main/java/com/taosdata/jdbc/utils/TDNodes.java
+5
-27
src/connector/jdbc/src/test/java/com/taosdata/jdbc/BaseTest.java
...nector/jdbc/src/test/java/com/taosdata/jdbc/BaseTest.java
+13
-15
未找到文件。
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/TDNode.java
浏览文件 @
ec47ae9c
package
com.taosdata.jdbc.utils
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.InputStreamReader
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -31,6 +33,10 @@ public class TDNode {
this
.
testCluster
=
testCluster
;
}
public
void
setRunning
(
int
running
)
{
this
.
running
=
running
;
}
public
void
searchTaosd
(
File
dir
,
ArrayList
<
String
>
taosdPath
)
{
File
[]
fileList
=
dir
.
listFiles
();
...
...
@@ -102,15 +108,46 @@ public class TDNode {
this
.
running
=
1
;
}
public
void
stop
()
{
String
toBeKilled
=
"taosd"
;
public
Integer
getTaosdPid
()
{
String
cmd
=
"ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'"
;
String
[]
cmds
=
{
"sh"
,
"-c"
,
cmd
};
try
{
Process
process
=
Runtime
.
getRuntime
().
exec
(
cmds
);
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getInputStream
()));
String
line
=
null
;
Integer
res
=
null
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
if
(!
line
.
isEmpty
())
{
res
=
Integer
.
valueOf
(
line
);
break
;
}
}
return
res
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
public
void
stop
()
{
if
(
this
.
running
!=
0
)
{
String
killCmd
=
"pkill -kill -x "
+
toBeKilled
;
String
[]
killCmds
=
{
"sh"
,
"-c"
,
killCmd
};
try
{
Runtime
.
getRuntime
().
exec
(
killCmds
).
waitFor
();
Integer
pid
=
null
;
while
((
pid
=
getTaosdPid
())
!=
null
)
{
String
killCmd
=
"kill -term "
+
pid
;
String
[]
killCmds
=
{
"sh"
,
"-c"
,
killCmd
};
try
{
Runtime
.
getRuntime
().
exec
(
killCmds
).
waitFor
();
TimeUnit
.
SECONDS
.
sleep
(
2
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
try
{
for
(
int
port
=
6030
;
port
<
6041
;
port
++)
{
String
fuserCmd
=
"fuser -k -n tcp "
+
port
;
Runtime
.
getRuntime
().
exec
(
fuserCmd
).
waitFor
();
...
...
@@ -120,7 +157,7 @@ public class TDNode {
}
this
.
running
=
0
;
System
.
out
.
println
(
"dnode:"
+
this
.
index
+
" is stopped by
pkill
"
);
System
.
out
.
println
(
"dnode:"
+
this
.
index
+
" is stopped by
kill -term
"
);
}
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/TDNodes.java
浏览文件 @
ec47ae9c
...
...
@@ -14,33 +14,6 @@ public class TDNodes {
}
}
public
void
setPath
(
String
path
)
{
try
{
String
killCmd
=
"pkill -kill -x taosd"
;
String
[]
killCmds
=
{
"sh"
,
"-c"
,
killCmd
};
Runtime
.
getRuntime
().
exec
(
killCmds
).
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
;
}
...
...
@@ -70,6 +43,11 @@ public class TDNodes {
check
(
index
);
tdNodes
.
get
(
index
-
1
).
setCfgConfig
(
option
,
value
);
}
public
TDNode
getTDNode
(
int
index
)
{
check
(
index
);
return
tdNodes
.
get
(
index
-
1
);
}
public
void
start
(
int
index
)
{
check
(
index
);
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/BaseTest.java
浏览文件 @
ec47ae9c
package
com.taosdata.jdbc
;
import
java.io.File
;
import
com.taosdata.jdbc.utils.TDNodes
;
import
org.junit.AfterClass
;
...
...
@@ -8,31 +7,30 @@ import org.junit.BeforeClass;
public
class
BaseTest
{
private
static
boolean
testCluster
=
false
;
private
static
String
deployPath
=
System
.
getProperty
(
"user.dir"
);
private
static
TDNodes
tdNodes
=
new
TDNodes
();
private
static
boolean
testCluster
=
false
;
private
static
TDNodes
nodes
=
new
TDNodes
();
@BeforeClass
public
static
void
setupEnv
()
{
try
{
File
file
=
new
File
(
deployPath
+
"/../../../"
);
String
rootPath
=
file
.
getCanonicalPath
(
);
tdNodes
.
setPath
(
rootPath
);
tdNodes
.
setTestCluster
(
testCluster
);
try
{
if
(
nodes
.
getTDNode
(
1
).
getTaosdPid
()
!=
null
)
{
System
.
out
.
println
(
"Kill taosd before running JDBC test"
);
nodes
.
getTDNode
(
1
).
setRunning
(
1
);
nodes
.
stop
(
1
);
}
tdNodes
.
deploy
(
1
);
tdNodes
.
start
(
1
);
nodes
.
setTestCluster
(
testCluster
);
nodes
.
deploy
(
1
);
nodes
.
start
(
1
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
(
"Base Test Exception"
);
e
.
printStackTrace
();
}
}
@AfterClass
public
static
void
cleanUpEnv
()
{
tdN
odes
.
stop
(
1
);
n
odes
.
stop
(
1
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录