mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor clob wrap
This commit is contained in:
@@ -977,7 +977,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
}
|
||||
|
||||
if (obj instanceof Clob) {
|
||||
return wrap(resultSet.getStatementProxy().getConnectionProxy(), (Clob) obj);
|
||||
return wrap(resultSet.getStatementProxy(), (Clob) obj);
|
||||
}
|
||||
|
||||
return obj;
|
||||
@@ -996,7 +996,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
}
|
||||
|
||||
if (obj instanceof Clob) {
|
||||
return wrap(resultSet.getStatementProxy().getConnectionProxy(), (Clob) obj);
|
||||
return wrap(resultSet.getStatementProxy(), (Clob) obj);
|
||||
}
|
||||
|
||||
return obj;
|
||||
@@ -1653,7 +1653,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
}
|
||||
|
||||
if (obj instanceof Clob) {
|
||||
return wrap(resultSet.getStatementProxy().getConnectionProxy(), (Clob) obj);
|
||||
return wrap(resultSet.getStatementProxy(), (Clob) obj);
|
||||
}
|
||||
|
||||
return obj;
|
||||
@@ -1683,7 +1683,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
|
||||
Clob clob = resultSet.getResultSetRaw().getClob(columnIndex);
|
||||
|
||||
return wrap(resultSet.getStatementProxy().getConnectionProxy(), clob);
|
||||
return wrap(resultSet.getStatementProxy(), clob);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1711,7 +1711,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
}
|
||||
|
||||
if (obj instanceof Clob) {
|
||||
return wrap(resultSet.getStatementProxy().getConnectionProxy(), (Clob) obj);
|
||||
return wrap(resultSet.getStatementProxy(), (Clob) obj);
|
||||
}
|
||||
|
||||
return obj;
|
||||
@@ -1741,7 +1741,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
|
||||
Clob clob = resultSet.getResultSetRaw().getClob(columnLabel);
|
||||
|
||||
return wrap(resultSet.getStatementProxy().getConnectionProxy(), clob);
|
||||
return wrap(resultSet.getStatementProxy(), clob);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3394,7 +3394,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
}
|
||||
|
||||
if (obj instanceof Clob) {
|
||||
return wrap(statement.getConnectionProxy(), (Clob) obj);
|
||||
return wrap(statement, (Clob) obj);
|
||||
}
|
||||
|
||||
return obj;
|
||||
@@ -3414,7 +3414,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
}
|
||||
|
||||
if (obj instanceof Clob) {
|
||||
return wrap(statement.getConnectionProxy(), (Clob) obj);
|
||||
return wrap(statement, (Clob) obj);
|
||||
}
|
||||
|
||||
return obj;
|
||||
@@ -3434,7 +3434,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
}
|
||||
|
||||
if (obj instanceof Clob) {
|
||||
return wrap(statement.getConnectionProxy(), (Clob) obj);
|
||||
return wrap(statement, (Clob) obj);
|
||||
}
|
||||
|
||||
return obj;
|
||||
@@ -3454,7 +3454,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
}
|
||||
|
||||
if (obj instanceof Clob) {
|
||||
return wrap(statement.getConnectionProxy(), (Clob) obj);
|
||||
return wrap(statement, (Clob) obj);
|
||||
}
|
||||
|
||||
return obj;
|
||||
@@ -3493,7 +3493,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
|
||||
Clob clob = statement.getRawObject().getClob(parameterIndex);
|
||||
|
||||
return wrap(statement.getConnectionProxy(), clob);
|
||||
return wrap(statement, clob);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3965,7 +3965,7 @@ public class FilterChainImpl implements FilterChain {
|
||||
|
||||
Clob clob = statement.getRawObject().getClob(parameterName);
|
||||
|
||||
return wrap(statement.getConnectionProxy(), clob);
|
||||
return wrap(statement, clob);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -4469,25 +4469,45 @@ public class FilterChainImpl implements FilterChain {
|
||||
return new ResultSetProxyImpl(statement, resultSet, dataSource.createResultSetId(),
|
||||
statement.getLastExecuteSql());
|
||||
}
|
||||
|
||||
public ClobProxy wrap(ConnectionProxy connection, Clob clob) {
|
||||
|
||||
public ClobProxy wrap(ConnectionProxy conn, Clob clob) {
|
||||
if (clob == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (clob instanceof NClob) {
|
||||
return wrap(connection, (NClob) clob);
|
||||
return wrap(conn, (NClob) clob);
|
||||
}
|
||||
|
||||
return new ClobProxyImpl(dataSource, connection, clob);
|
||||
|
||||
return new ClobProxyImpl(dataSource, conn, clob);
|
||||
}
|
||||
|
||||
public NClobProxy wrap(ConnectionProxy conn, NClob clob) {
|
||||
if (clob == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new NClobProxyImpl(dataSource, conn, clob);
|
||||
}
|
||||
|
||||
public NClobProxy wrap(ConnectionProxy connection, NClob nclob) {
|
||||
public ClobProxy wrap(StatementProxy stmt, Clob clob) {
|
||||
if (clob == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (clob instanceof NClob) {
|
||||
return wrap(stmt, (NClob) clob);
|
||||
}
|
||||
|
||||
return new ClobProxyImpl(dataSource, stmt.getConnectionProxy(), clob);
|
||||
}
|
||||
|
||||
public NClobProxy wrap(StatementProxy stmt, NClob nclob) {
|
||||
if (nclob == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new NClobProxyImpl(dataSource, connection, nclob);
|
||||
return new NClobProxyImpl(dataSource, stmt.getConnectionProxy(), nclob);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -68,6 +68,8 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
|
||||
private boolean removed = false;
|
||||
|
||||
private final AtomicLong clobOpenCount = new AtomicLong();
|
||||
|
||||
private final Histogram histogram = new Histogram(new long[] { //
|
||||
//
|
||||
1, 10, 100, 1000, 10 * 1000, //
|
||||
@@ -213,6 +215,8 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
fetchRowCountHistogram.reset();
|
||||
updateCountHistogram.reset();
|
||||
executeAndResultHoldTimeHistogram.reset();
|
||||
|
||||
clobOpenCount.set(0);
|
||||
}
|
||||
|
||||
public long getConcurrentMax() {
|
||||
@@ -226,7 +230,7 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
public void addUpdateCount(int delta) {
|
||||
if (delta > 0) {
|
||||
this.updateCount.addAndGet(delta);
|
||||
}
|
||||
}
|
||||
for (;;) {
|
||||
long max = updateCountMax.get();
|
||||
if (delta <= max) break;
|
||||
@@ -241,7 +245,8 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
public long getUpdateCount() {
|
||||
return updateCount.get();
|
||||
}
|
||||
public long getUpdateCountMax() {
|
||||
|
||||
public long getUpdateCountMax() {
|
||||
return updateCountMax.get();
|
||||
}
|
||||
|
||||
@@ -249,10 +254,18 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
return fetchRowCount.get();
|
||||
}
|
||||
|
||||
public long getFetchRowCountMax() {
|
||||
public long getFetchRowCountMax() {
|
||||
return fetchRowCountMax.get();
|
||||
|
||||
}
|
||||
|
||||
public long getClobOpenCount() {
|
||||
return clobOpenCount.get();
|
||||
}
|
||||
|
||||
public void incrementClobOpenCount() {
|
||||
clobOpenCount.incrementAndGet();
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -292,7 +305,7 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
}
|
||||
|
||||
public void addFetchRowCount(long delta) {
|
||||
this.fetchRowCount.addAndGet(delta);
|
||||
this.fetchRowCount.addAndGet(delta);
|
||||
for (;;) {
|
||||
long max = fetchRowCountMax.get();
|
||||
if (delta <= max) break;
|
||||
@@ -361,7 +374,7 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
|
||||
public void addExecuteTime(StatementExecuteType executeType, boolean firstResultSet, long nanoSpan) {
|
||||
addExecuteTime(nanoSpan);
|
||||
|
||||
|
||||
if (StatementExecuteType.ExecuteQuery != executeType && !firstResultSet) {
|
||||
executeAndResultHoldTimeHistogram.record((nanoSpan) / 1000 / 1000);
|
||||
}
|
||||
@@ -516,16 +529,16 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
|
||||
// 25 - 29
|
||||
"Histogram", //
|
||||
"LastSlowParameters", //
|
||||
"ResultSetHoldTime", //
|
||||
"ExecuteAndResultSetHoldTime", //
|
||||
"LastSlowParameters", //
|
||||
"ResultSetHoldTime", //
|
||||
"ExecuteAndResultSetHoldTime", //
|
||||
"FetchRowCountHistogram", //
|
||||
|
||||
// 30
|
||||
"EffectedRowCountHistogram", //
|
||||
"EffectedRowCountHistogram", //
|
||||
"ExecuteAndResultHoldTimeHistogram", //
|
||||
"EffectedRowCountMax", //
|
||||
"FetchRowCountMax"
|
||||
"FetchRowCountMax"
|
||||
|
||||
//
|
||||
};
|
||||
@@ -555,7 +568,7 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
map.put("MaxTimespan", getExecuteMillisMax());
|
||||
map.put("LastError", JMXUtils.getErrorCompositeData(this.getExecuteErrorLast()));
|
||||
map.put("EffectedRowCount", getUpdateCount());
|
||||
|
||||
|
||||
// 10 - 14
|
||||
map.put("FetchRowCount", getFetchRowCount());
|
||||
map.put("MaxTimespanOccurTime", getExecuteNanoSpanMaxOccurTime());
|
||||
|
||||
Reference in New Issue
Block a user