mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
修正connection.id,statement.id, resultSet.id生成不正确的问题
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@227 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -43,7 +43,6 @@ import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import com.alibaba.druid.proxy.jdbc.CallableStatementProxy;
|
||||
import com.alibaba.druid.proxy.jdbc.CallableStatementProxyImpl;
|
||||
@@ -4123,7 +4122,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ConnectionProxyImpl(dataSource, connection, info, createConnectionId());
|
||||
return new ConnectionProxyImpl(dataSource, connection, info, dataSource.createConnectionId());
|
||||
}
|
||||
|
||||
public StatementProxy wrap(ConnectionProxy connection, Statement statement) {
|
||||
@@ -4131,7 +4130,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new StatementProxyImpl(connection, statement, createStatementId());
|
||||
return new StatementProxyImpl(connection, statement, dataSource.createStatementId());
|
||||
}
|
||||
|
||||
public PreparedStatementProxy wrap(ConnectionProxy connection, PreparedStatement statement, String sql) {
|
||||
@@ -4139,7 +4138,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new PreparedStatementProxyImpl(connection, statement, sql, createStatementId());
|
||||
return new PreparedStatementProxyImpl(connection, statement, sql, dataSource.createStatementId());
|
||||
}
|
||||
|
||||
public CallableStatementProxy wrap(ConnectionProxy connection, CallableStatement statement, String sql) {
|
||||
@@ -4147,7 +4146,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new CallableStatementProxyImpl(connection, statement, sql, createStatementId());
|
||||
return new CallableStatementProxyImpl(connection, statement, sql, dataSource.createStatementId());
|
||||
}
|
||||
|
||||
public ResultSetProxy wrap(StatementProxy statement, ResultSet resultSet) {
|
||||
@@ -4155,7 +4154,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ResultSetProxyImpl(statement, resultSet, createResultSetId(), statement.getLastExecuteSql());
|
||||
return new ResultSetProxyImpl(statement, resultSet, dataSource.createResultSetId(), statement.getLastExecuteSql());
|
||||
}
|
||||
|
||||
public ClobProxy wrap(ConnectionProxy connection, Clob clob) {
|
||||
@@ -4174,19 +4173,5 @@ public class FilterChainImpl implements FilterChain {
|
||||
return new NClobProxyImpl(dataSource, connection, nclob);
|
||||
}
|
||||
|
||||
private final AtomicLong connectionIdSeed = new AtomicLong(10000);
|
||||
private final AtomicLong statementIdSeed = new AtomicLong(20000);
|
||||
private final AtomicLong resultSetIdSeed = new AtomicLong(50000);
|
||||
|
||||
public long createConnectionId() {
|
||||
return connectionIdSeed.incrementAndGet();
|
||||
}
|
||||
|
||||
public long createStatementId() {
|
||||
return statementIdSeed.getAndIncrement();
|
||||
}
|
||||
|
||||
public long createResultSetId() {
|
||||
return resultSetIdSeed.getAndIncrement();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@@ -685,4 +686,20 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
private final AtomicLong connectionIdSeed = new AtomicLong(10000);
|
||||
private final AtomicLong statementIdSeed = new AtomicLong(20000);
|
||||
private final AtomicLong resultSetIdSeed = new AtomicLong(50000);
|
||||
|
||||
public long createConnectionId() {
|
||||
return connectionIdSeed.incrementAndGet();
|
||||
}
|
||||
|
||||
public long createStatementId() {
|
||||
return statementIdSeed.getAndIncrement();
|
||||
}
|
||||
|
||||
public long createResultSetId() {
|
||||
return resultSetIdSeed.getAndIncrement();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.alibaba.druid.filter.Filter;
|
||||
public interface DataSourceProxy {
|
||||
|
||||
String getName();
|
||||
|
||||
|
||||
String getDbType();
|
||||
|
||||
Driver getRawDriver();
|
||||
@@ -36,4 +36,10 @@ public interface DataSourceProxy {
|
||||
String getRawJdbcUrl();
|
||||
|
||||
List<Filter> getFilters();
|
||||
|
||||
long createConnectionId();
|
||||
|
||||
long createStatementId();
|
||||
|
||||
long createResultSetId();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import javax.management.JMException;
|
||||
import javax.management.openmbean.ArrayType;
|
||||
@@ -55,6 +56,10 @@ public class DataSourceProxyImpl implements DataSourceProxy, DataSourceProxyImpl
|
||||
|
||||
private String dbType;
|
||||
|
||||
private final AtomicLong connectionIdSeed = new AtomicLong(10000);
|
||||
private final AtomicLong statementIdSeed = new AtomicLong(20000);
|
||||
private final AtomicLong resultSetIdSeed = new AtomicLong(50000);
|
||||
|
||||
public DataSourceProxyImpl(Driver rawDriver, DataSourceProxyConfig config){
|
||||
super();
|
||||
this.rawDriver = rawDriver;
|
||||
@@ -214,4 +219,15 @@ public class DataSourceProxyImpl implements DataSourceProxy, DataSourceProxyImpl
|
||||
return config.getRawUrl();
|
||||
}
|
||||
|
||||
public long createConnectionId() {
|
||||
return connectionIdSeed.incrementAndGet();
|
||||
}
|
||||
|
||||
public long createStatementId() {
|
||||
return statementIdSeed.getAndIncrement();
|
||||
}
|
||||
|
||||
public long createResultSetId() {
|
||||
return resultSetIdSeed.getAndIncrement();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class JdbcTraceManager extends NotificationBroadcasterSupport implements
|
||||
|
||||
@Override
|
||||
public void fireEvent(TraceEvent event) {
|
||||
Notification notification = new Notification(event.getEventType(), null, sequenceNumber++);
|
||||
Notification notification = new Notification(event.getEventType(), JdbcTraceManager.class.getName(), sequenceNumber++);
|
||||
notification.setTimeStamp(event.getEventTime().getTime());
|
||||
notification.setUserData(event.getContext());
|
||||
|
||||
|
||||
@@ -15,13 +15,12 @@
|
||||
*/
|
||||
package com.alibaba.druid.stat;
|
||||
|
||||
import com.alibaba.druid.stat.JdbcTraceManager.NotificationTraceEventListener;
|
||||
|
||||
public interface JdbcTraceManagerMBean {
|
||||
|
||||
void setNotificationEnable(boolean notificationEnable);
|
||||
|
||||
NotificationTraceEventListener getNotificationListener();
|
||||
boolean isNotificationEnable();
|
||||
|
||||
long getEventFiredCount();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user