Commit df64f0e7 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Implemented toString to provide info about internal stats.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6674 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1720b365
/**
* $RCSfile$
* $Revision$
* $Date$
* $Revision: $
* $Date: $
*
* Copyright (C) 2004 Jive Software. All rights reserved.
* Copyright (C) 2007 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
......@@ -12,12 +12,13 @@
package org.jivesoftware.database;
import org.jivesoftware.util.ClassUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import java.io.IOException;
import java.sql.*;
import java.util.*;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Database connection pool.
......@@ -45,6 +46,8 @@ public class ConnectionPool implements Runnable {
private Object waitLock = new Object();
private Object conCountLock = new Object();
private AtomicInteger used = new AtomicInteger(0);
public ConnectionPool(String driver, String serverURL, String username,
String password, int minCon, int maxCon,
double conTimeout, boolean mysqlUseUnicode) throws IOException {
......@@ -175,6 +178,7 @@ public class ConnectionPool implements Runnable {
}
public void freeConnection() {
used.decrementAndGet();
synchronized (waitLock) {
if (waitingForCon > 0) {
waitLock.notifyAll();
......@@ -395,6 +399,7 @@ public class ConnectionPool implements Runnable {
wrapper.exception = new Exception();
wrapper.hasLoggedException = false;
}
used.incrementAndGet();
return wrapper;
}
......@@ -409,6 +414,7 @@ public class ConnectionPool implements Runnable {
ConnectionWrapper con = createCon(conCount);
conCount++;
used.incrementAndGet();
return con;
}
}
......@@ -482,4 +488,8 @@ public class ConnectionPool implements Runnable {
throw new SQLException(e.getMessage());
}
}
public String toString() {
return minCon + "," + maxCon + "," + conCount + "," + used.intValue();
}
}
\ No newline at end of file
......@@ -3,7 +3,7 @@
* $Revision$
* $Date$
*
* Copyright (C) 2004 Jive Software. All rights reserved.
* Copyright (C) 2007 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
......@@ -317,4 +317,8 @@ public class DefaultConnectionProvider implements ConnectionProvider {
JiveGlobals.setXMLProperty("database.defaultProvider.connectionTimeout",
Double.toString(connectionTimeout));
}
public String toString() {
return connectionPool.toString();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment