git-svn-id: http://code.alibabatech.com/svn/druid/trunk@413 b9813039-fb51-4c41-a8b9-e21c2acb5095

This commit is contained in:
wenshao
2011-07-13 07:36:20 +00:00
parent f765980f9a
commit d651652710
6 changed files with 30 additions and 284 deletions
@@ -31,7 +31,7 @@ public class Case3 extends TestCase {
private String validationQuery = "SELECT 1"; // "SELECT 1";
private int threadCount = 10;
private int TEST_COUNT = 3;
final int LOOP_COUNT = 1000 * 10;
final int LOOP_COUNT = 1000 * 1;
private boolean testOnBorrow = false;
private String connectionProperties = ""; // "bigStringTryClob=true;clientEncoding=GBK;defaultRowPrefetch=50;serverEncoding=ISO-8859-1";
private String sql = "SELECT 1";
@@ -43,11 +43,11 @@ public class Case3 extends TestCase {
user = "dragoon25";
password = "dragoon25";
//driverClass = "com.alibaba.druid.mock.MockDriver";
connectionProperties = "connectSleep=3;executeSleep=0";
// connectionProperties = "connectSleep=3;executeSleep=0";
jdbcUrl = "jdbc:mysql://10.20.153.104:3306/druid2";
user = "root";
password = "root";
// jdbcUrl = "jdbc:mysql://10.20.153.104:3306/druid2";
// user = "root";
// password = "root";
}
public void test_perf() throws Exception {
@@ -160,6 +160,8 @@ public class Case3 extends TestCase {
}
rs.close();
stmt.close();
Thread.sleep(1);
conn.close();
}
@@ -96,6 +96,7 @@ public class DruidDataSourceUIManager extends JFrame {
private AtomicInteger connectingCount = new AtomicInteger();
private AtomicInteger connectCount = new AtomicInteger();
private AtomicInteger closeCount = new AtomicInteger();
private AtomicInteger executingCount = new AtomicInteger();
private Thread statusThread;
@@ -406,15 +407,20 @@ public class DruidDataSourceUIManager extends JFrame {
return;
}
Statement stmt = conn.createStatement();
stmt.setQueryTimeout(5);
ResultSet rs = stmt.executeQuery("SELECT * FROM address LIMIT 10");
while (rs.next()) {
rs.getObject(1);
executingCount.incrementAndGet();
try {
Statement stmt = conn.createStatement();
stmt.setQueryTimeout(5);
ResultSet rs = stmt.executeQuery("SELECT 1");
while (rs.next()) {
rs.getObject(1);
}
Thread.sleep(1000 * 3);
rs.close();
stmt.close();
} finally {
executingCount.decrementAndGet();
}
rs.close();
stmt.close();
activeConnections.add(conn);
} catch (Exception ex) {
@@ -514,6 +520,7 @@ public class DruidDataSourceUIManager extends JFrame {
statusPanel.set("UI_GettingCount", connectingCount.get());
statusPanel.set("UI_GetCount", connectCount.get());
statusPanel.set("UI_ReleaseCount", closeCount.get());
statusPanel.set("UI_ExecutingCount", executingCount.get());
try {
Thread.sleep(100);
@@ -555,6 +562,8 @@ public class DruidDataSourceUIManager extends JFrame {
rs.close();
stmt.close();
Thread.sleep(1);
conn.close();
}
} catch (Exception ex) {
@@ -583,7 +592,7 @@ public class DruidDataSourceUIManager extends JFrame {
System.out.println("thread " + threadCount + " druid millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
}
};
executor.submit(task);
}
@@ -17,11 +17,13 @@ public class DruidDataStatusPanel extends JPanel {
private final String[] fieldNames = new String[] { //
"CreateCount", "CreateErrorCount", "CreateTimespanMillis", "CreateTimespanNano", "DestroyCount", //
"ConnectCount", "ConnectErrorCount", "CloseCount", "RecycleCount", "ActiveCount", //
"PoolingCount", "IdleCheckCount", "UI_GettingCount", "UI_GetCount", "UI_ReleaseCount" };
"PoolingCount", "IdleCheckCount", "UI_GettingCount", "UI_GetCount", "UI_ReleaseCount" //
, "UI_ExecutingCount" //
};
public DruidDataStatusPanel(){
this.setLayout(new GridLayout(5, 6));
this.setLayout(new GridLayout(6, 6));
for (String fieldName : fieldNames) {
JLabel label = new JLabel(fieldName + " : ");