提交 b0c7a36e 编写于 作者: Z zyyang

change

上级 b5eebd09
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version> <version>2.12.4</version>
<configuration> <configuration>
<forkMode>pretest</forkMode> <forkMode>pertest</forkMode>
<argLine>${maven.test.jvmargs}</argLine> <argLine>${maven.test.jvmargs}</argLine>
<includes> <includes>
<include>**/*Test.java</include> <include>**/*Test.java</include>
......
...@@ -16,9 +16,6 @@ package com.taosdata.jdbc; ...@@ -16,9 +16,6 @@ package com.taosdata.jdbc;
import com.taosdata.jdbc.utils.TaosInfo; 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.SQLException;
import java.sql.SQLWarning; import java.sql.SQLWarning;
import java.util.List; import java.util.List;
...@@ -31,7 +28,6 @@ public class TSDBJNIConnector { ...@@ -31,7 +28,6 @@ public class TSDBJNIConnector {
static { static {
System.loadLibrary("taos"); System.loadLibrary("taos");
System.out.println("java.library.path:" + System.getProperty("java.library.path")); System.out.println("java.library.path:" + System.getProperty("java.library.path"));
} }
/** /**
...@@ -109,9 +105,7 @@ public class TSDBJNIConnector { ...@@ -109,9 +105,7 @@ public class TSDBJNIConnector {
throw new SQLException(TSDBConstants.WrapErrMsg(this.getErrMsg(0L)), "", this.getErrCode(0l)); throw new SQLException(TSDBConstants.WrapErrMsg(this.getErrMsg(0L)), "", this.getErrCode(0l));
} }
// invoke connectImp only here // invoke connectImp only here
int open = taosInfo.getOpen_count().incrementAndGet(); taosInfo.conn_open_increment();
int close = taosInfo.getClose_count().get();
System.out.println("open_count: " + open + ", close_count: " + close + ", connection_count: " + (taosInfo.getConnectionCount()));
return true; return true;
} }
...@@ -132,6 +126,7 @@ public class TSDBJNIConnector { ...@@ -132,6 +126,7 @@ public class TSDBJNIConnector {
Long pSql = 0l; Long pSql = 0l;
try { try {
pSql = this.executeQueryImp(sql.getBytes(TaosGlobalConfig.getCharset()), this.taos); pSql = this.executeQueryImp(sql.getBytes(TaosGlobalConfig.getCharset()), this.taos);
taosInfo.stmt_count_increment();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
this.freeResultSetImp(this.taos, pSql); this.freeResultSetImp(this.taos, pSql);
...@@ -276,9 +271,7 @@ public class TSDBJNIConnector { ...@@ -276,9 +271,7 @@ public class TSDBJNIConnector {
throw new SQLException("Undefined error code returned by TDengine when closing a connection"); throw new SQLException("Undefined error code returned by TDengine when closing a connection");
} }
// invoke closeConnectionImpl only here // invoke closeConnectionImpl only here
int open = taosInfo.getOpen_count().get(); taosInfo.connect_close_increment();
int close = taosInfo.getClose_count().incrementAndGet();
System.out.println("open_count: " + open + ", close_count: " + close + ", connection_count: " + (taosInfo.getConnectionCount()));
} }
private native int closeConnectionImp(long connection); private native int closeConnectionImp(long connection);
......
...@@ -14,13 +14,15 @@ ...@@ -14,13 +14,15 @@
*****************************************************************************/ *****************************************************************************/
package com.taosdata.jdbc; package com.taosdata.jdbc;
import com.taosdata.jdbc.utils.TaosInfo;
import java.sql.*; import java.sql.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
public class TSDBStatement implements Statement { public class TSDBStatement implements Statement {
private TSDBJNIConnector connector = null; private TSDBJNIConnector connector;
private TaosInfo taosInfo = TaosInfo.getInstance();
/** /**
* To store batched commands * To store batched commands
......
...@@ -3,12 +3,14 @@ package com.taosdata.jdbc.utils; ...@@ -3,12 +3,14 @@ package com.taosdata.jdbc.utils;
import javax.management.*; import javax.management.*;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
public class TaosInfo implements TaosInfoMBean { public class TaosInfo implements TaosInfoMBean {
private static volatile TaosInfo instance; private static volatile TaosInfo instance;
private AtomicInteger open_count = new AtomicInteger(); private AtomicLong connect_open = new AtomicLong();
private AtomicInteger close_count = new AtomicInteger(); private AtomicLong connect_close = new AtomicLong();
private AtomicLong statement_count = new AtomicLong();
static { static {
try { try {
...@@ -21,23 +23,40 @@ public class TaosInfo implements TaosInfoMBean { ...@@ -21,23 +23,40 @@ public class TaosInfo implements TaosInfoMBean {
} }
@Override @Override
public int getConnectionCount() { public long getConnect_open() {
return open_count.get() - close_count.get(); return connect_open.get();
} }
@Override @Override
public int getStatementCount() { public long getConnect_close() {
return 0; return connect_close.get();
} }
public AtomicInteger getOpen_count() { @Override
return open_count; 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_count() { public void stmt_count_increment() {
return close_count; statement_count.incrementAndGet();
} }
/********************************************************************************/
private TaosInfo() { private TaosInfo() {
} }
......
...@@ -2,7 +2,12 @@ package com.taosdata.jdbc.utils; ...@@ -2,7 +2,12 @@ package com.taosdata.jdbc.utils;
public interface TaosInfoMBean { 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.
先完成此消息的编辑!
想要评论请 注册