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$ * $RCSfile$
* $Revision$ * $Revision: $
* $Date$ * $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), * This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution. * a copy of which is included in this distribution.
...@@ -12,12 +12,13 @@ ...@@ -12,12 +12,13 @@
package org.jivesoftware.database; package org.jivesoftware.database;
import org.jivesoftware.util.ClassUtils; import org.jivesoftware.util.ClassUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import java.io.IOException; import java.io.IOException;
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
/** /**
* Database connection pool. * Database connection pool.
...@@ -45,6 +46,8 @@ public class ConnectionPool implements Runnable { ...@@ -45,6 +46,8 @@ public class ConnectionPool implements Runnable {
private Object waitLock = new Object(); private Object waitLock = new Object();
private Object conCountLock = new Object(); private Object conCountLock = new Object();
private AtomicInteger used = new AtomicInteger(0);
public ConnectionPool(String driver, String serverURL, String username, public ConnectionPool(String driver, String serverURL, String username,
String password, int minCon, int maxCon, String password, int minCon, int maxCon,
double conTimeout, boolean mysqlUseUnicode) throws IOException { double conTimeout, boolean mysqlUseUnicode) throws IOException {
...@@ -175,6 +178,7 @@ public class ConnectionPool implements Runnable { ...@@ -175,6 +178,7 @@ public class ConnectionPool implements Runnable {
} }
public void freeConnection() { public void freeConnection() {
used.decrementAndGet();
synchronized (waitLock) { synchronized (waitLock) {
if (waitingForCon > 0) { if (waitingForCon > 0) {
waitLock.notifyAll(); waitLock.notifyAll();
...@@ -395,6 +399,7 @@ public class ConnectionPool implements Runnable { ...@@ -395,6 +399,7 @@ public class ConnectionPool implements Runnable {
wrapper.exception = new Exception(); wrapper.exception = new Exception();
wrapper.hasLoggedException = false; wrapper.hasLoggedException = false;
} }
used.incrementAndGet();
return wrapper; return wrapper;
} }
...@@ -409,6 +414,7 @@ public class ConnectionPool implements Runnable { ...@@ -409,6 +414,7 @@ public class ConnectionPool implements Runnable {
ConnectionWrapper con = createCon(conCount); ConnectionWrapper con = createCon(conCount);
conCount++; conCount++;
used.incrementAndGet();
return con; return con;
} }
} }
...@@ -482,4 +488,8 @@ public class ConnectionPool implements Runnable { ...@@ -482,4 +488,8 @@ public class ConnectionPool implements Runnable {
throw new SQLException(e.getMessage()); throw new SQLException(e.getMessage());
} }
} }
public String toString() {
return minCon + "," + maxCon + "," + conCount + "," + used.intValue();
}
} }
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* $Revision$ * $Revision$
* $Date$ * $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), * This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution. * a copy of which is included in this distribution.
...@@ -317,4 +317,8 @@ public class DefaultConnectionProvider implements ConnectionProvider { ...@@ -317,4 +317,8 @@ public class DefaultConnectionProvider implements ConnectionProvider {
JiveGlobals.setXMLProperty("database.defaultProvider.connectionTimeout", JiveGlobals.setXMLProperty("database.defaultProvider.connectionTimeout",
Double.toString(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