Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
b0c7a36e
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看板
提交
b0c7a36e
编写于
2月 01, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change
上级
b5eebd09
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
44 addition
and
25 deletion
+44
-25
src/connector/jdbc/pom.xml
src/connector/jdbc/pom.xml
+1
-1
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
...dbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
+3
-10
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
+4
-2
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/TaosInfo.java
.../jdbc/src/main/java/com/taosdata/jdbc/utils/TaosInfo.java
+29
-10
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/TaosInfoMBean.java
.../src/main/java/com/taosdata/jdbc/utils/TaosInfoMBean.java
+7
-2
未找到文件。
src/connector/jdbc/pom.xml
浏览文件 @
b0c7a36e
...
...
@@ -123,7 +123,7 @@
<artifactId>
maven-surefire-plugin
</artifactId>
<version>
2.12.4
</version>
<configuration>
<forkMode>
p
re
test
</forkMode>
<forkMode>
p
er
test
</forkMode>
<argLine>
${maven.test.jvmargs}
</argLine>
<includes>
<include>
**/*Test.java
</include>
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
浏览文件 @
b0c7a36e
...
...
@@ -16,9 +16,6 @@ package com.taosdata.jdbc;
import
com.taosdata.jdbc.utils.TaosInfo
;
import
javax.management.MBeanServer
;
import
javax.management.ObjectName
;
import
java.lang.management.ManagementFactory
;
import
java.sql.SQLException
;
import
java.sql.SQLWarning
;
import
java.util.List
;
...
...
@@ -31,7 +28,6 @@ public class TSDBJNIConnector {
static
{
System
.
loadLibrary
(
"taos"
);
System
.
out
.
println
(
"java.library.path:"
+
System
.
getProperty
(
"java.library.path"
));
}
/**
...
...
@@ -109,9 +105,7 @@ public class TSDBJNIConnector {
throw
new
SQLException
(
TSDBConstants
.
WrapErrMsg
(
this
.
getErrMsg
(
0L
)),
""
,
this
.
getErrCode
(
0
l
));
}
// invoke connectImp only here
int
open
=
taosInfo
.
getOpen_count
().
incrementAndGet
();
int
close
=
taosInfo
.
getClose_count
().
get
();
System
.
out
.
println
(
"open_count: "
+
open
+
", close_count: "
+
close
+
", connection_count: "
+
(
taosInfo
.
getConnectionCount
()));
taosInfo
.
conn_open_increment
();
return
true
;
}
...
...
@@ -132,6 +126,7 @@ public class TSDBJNIConnector {
Long
pSql
=
0
l
;
try
{
pSql
=
this
.
executeQueryImp
(
sql
.
getBytes
(
TaosGlobalConfig
.
getCharset
()),
this
.
taos
);
taosInfo
.
stmt_count_increment
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
this
.
freeResultSetImp
(
this
.
taos
,
pSql
);
...
...
@@ -276,9 +271,7 @@ public class TSDBJNIConnector {
throw
new
SQLException
(
"Undefined error code returned by TDengine when closing a connection"
);
}
// invoke closeConnectionImpl only here
int
open
=
taosInfo
.
getOpen_count
().
get
();
int
close
=
taosInfo
.
getClose_count
().
incrementAndGet
();
System
.
out
.
println
(
"open_count: "
+
open
+
", close_count: "
+
close
+
", connection_count: "
+
(
taosInfo
.
getConnectionCount
()));
taosInfo
.
connect_close_increment
();
}
private
native
int
closeConnectionImp
(
long
connection
);
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
浏览文件 @
b0c7a36e
...
...
@@ -14,13 +14,15 @@
*****************************************************************************/
package
com.taosdata.jdbc
;
import
com.taosdata.jdbc.utils.TaosInfo
;
import
java.sql.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
public
class
TSDBStatement
implements
Statement
{
private
TSDBJNIConnector
connector
=
null
;
private
TSDBJNIConnector
connector
;
private
TaosInfo
taosInfo
=
TaosInfo
.
getInstance
();
/**
* To store batched commands
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/TaosInfo.java
浏览文件 @
b0c7a36e
...
...
@@ -3,12 +3,14 @@ package com.taosdata.jdbc.utils;
import
javax.management.*
;
import
java.lang.management.ManagementFactory
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicLong
;
public
class
TaosInfo
implements
TaosInfoMBean
{
private
static
volatile
TaosInfo
instance
;
private
AtomicInteger
open_count
=
new
AtomicInteger
();
private
AtomicInteger
close_count
=
new
AtomicInteger
();
private
AtomicLong
connect_open
=
new
AtomicLong
();
private
AtomicLong
connect_close
=
new
AtomicLong
();
private
AtomicLong
statement_count
=
new
AtomicLong
();
static
{
try
{
...
...
@@ -21,23 +23,40 @@ public class TaosInfo implements TaosInfoMBean {
}
@Override
public
int
getConnectionCount
()
{
return
open_count
.
get
()
-
close_count
.
get
();
public
long
getConnect_open
()
{
return
connect_open
.
get
();
}
@Override
public
int
getStatementCount
()
{
return
0
;
public
long
getConnect_close
()
{
return
connect_close
.
get
()
;
}
public
AtomicInteger
getOpen_count
()
{
return
open_count
;
@Override
public
long
getConnect_active
()
{
return
connect_open
.
get
()
-
connect_close
.
get
();
}
@Override
public
long
getStatement_count
()
{
return
statement_count
.
get
();
}
/*******************************************************/
public
void
conn_open_increment
()
{
connect_open
.
incrementAndGet
();
}
public
void
connect_close_increment
()
{
connect_close
.
incrementAndGet
();
}
public
AtomicInteger
getClose_cou
nt
()
{
return
close_count
;
public
void
stmt_count_increme
nt
()
{
statement_count
.
incrementAndGet
()
;
}
/********************************************************************************/
private
TaosInfo
()
{
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/TaosInfoMBean.java
浏览文件 @
b0c7a36e
...
...
@@ -2,7 +2,12 @@ package com.taosdata.jdbc.utils;
public
interface
TaosInfoMBean
{
int
getConnectionCount
();
long
getConnect_open
();
long
getConnect_close
();
long
getConnect_active
();
long
getStatement_count
();
int
getStatementCount
();
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录