Subject | CPU utilization with org.firebirdsql.pool.FBWrappingDataSource |
---|---|
Author | Thomas Steinmaurer |
Post date | 2008-02-11T14:32:47Z |
Hello,
I've a multi-threaded socket server which handles one client per thread
and inserts data into a Firebird 2.0.3 database.
I want to use the JayBird built-in connection pooling facility by using
org.firebirdsql.pool.FBWrappingDataSource. When doing this, CPU
utilization of my socket server application constantly stays on 50%
after the first connection has been obtained from the pool.
I have my own Connection class written like that:
public class EODOltpConnection
{
private static FBWrappingDataSource fbwds = null;
private Connection conn = null;
public EODOltpConnection()
{
}
public static void initConnectionPool() {
fbwds = new FBWrappingDataSource();
fbwds.setDatabase(EODProperties.getOltpDatabasePath());
fbwds.setUserName(EODProperties.getOltpDatabaseUser());
fbwds.setPassword(EODProperties.getOltpDatabasePassword());
fbwds.setMaxIdleTime(30);
fbwds.setPooling(true);
fbwds.setMinPoolSize(5);
fbwds.setMaxPoolSize(100);
fbwds.setLoginTimeout(10);
}
public Connection getConnection() throws SQLException {
if (conn == null) {
conn = fbwds.getConnection();
}
return conn;
}
public void freeConnection() throws SQLException {
try {
if (conn != null ) {
conn.close();
}
} catch (SQLException sqlE) {
logger.error("Couldn't close connection", sqlE);
throw sqlE;
}
}
}
The static initConnectionPool() method gets called from the socket
server app upon startup. Everytime a thread needs to obtain a new
connection from the pool, the thread calls the getConnection() method.
But after that, CPU utilization stays at ~ 50%.
freeConnection() is called all over the place if I don't need the
particular connection anymore.
Any ideas what I'm doing wrong?
Thanks!
Thomas
I've a multi-threaded socket server which handles one client per thread
and inserts data into a Firebird 2.0.3 database.
I want to use the JayBird built-in connection pooling facility by using
org.firebirdsql.pool.FBWrappingDataSource. When doing this, CPU
utilization of my socket server application constantly stays on 50%
after the first connection has been obtained from the pool.
I have my own Connection class written like that:
public class EODOltpConnection
{
private static FBWrappingDataSource fbwds = null;
private Connection conn = null;
public EODOltpConnection()
{
}
public static void initConnectionPool() {
fbwds = new FBWrappingDataSource();
fbwds.setDatabase(EODProperties.getOltpDatabasePath());
fbwds.setUserName(EODProperties.getOltpDatabaseUser());
fbwds.setPassword(EODProperties.getOltpDatabasePassword());
fbwds.setMaxIdleTime(30);
fbwds.setPooling(true);
fbwds.setMinPoolSize(5);
fbwds.setMaxPoolSize(100);
fbwds.setLoginTimeout(10);
}
public Connection getConnection() throws SQLException {
if (conn == null) {
conn = fbwds.getConnection();
}
return conn;
}
public void freeConnection() throws SQLException {
try {
if (conn != null ) {
conn.close();
}
} catch (SQLException sqlE) {
logger.error("Couldn't close connection", sqlE);
throw sqlE;
}
}
}
The static initConnectionPool() method gets called from the socket
server app upon startup. Everytime a thread needs to obtain a new
connection from the pool, the thread calls the getConnection() method.
But after that, CPU utilization stays at ~ 50%.
freeConnection() is called all over the place if I don't need the
particular connection anymore.
Any ideas what I'm doing wrong?
Thanks!
Thomas