change
This commit is contained in:
parent
b5eebd099c
commit
b0c7a36e73
|
@ -123,7 +123,7 @@
|
|||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.12.4</version>
|
||||
<configuration>
|
||||
<forkMode>pretest</forkMode>
|
||||
<forkMode>pertest</forkMode>
|
||||
<argLine>${maven.test.jvmargs}</argLine>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
|
|
|
@ -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(0l));
|
||||
}
|
||||
// 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 = 0l;
|
||||
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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
public AtomicInteger getClose_count() {
|
||||
return close_count;
|
||||
@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 void stmt_count_increment() {
|
||||
statement_count.incrementAndGet();
|
||||
}
|
||||
|
||||
/********************************************************************************/
|
||||
private TaosInfo() {
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue