use logger with level arg
This commit is contained in:
parent
8a92b3f45c
commit
c2b05476f2
3 changed files with 18 additions and 11 deletions
|
@ -149,8 +149,10 @@ public class Pool implements BagStateListener {
|
||||||
int maxPoolSize = config.getMaximumPoolSize();
|
int maxPoolSize = config.getMaximumPoolSize();
|
||||||
LinkedBlockingQueue<Runnable> addConnectionQueue = new LinkedBlockingQueue<>(maxPoolSize);
|
LinkedBlockingQueue<Runnable> addConnectionQueue = new LinkedBlockingQueue<>(maxPoolSize);
|
||||||
this.addConnectionQueueReadOnlyView = Collections.unmodifiableCollection(addConnectionQueue);
|
this.addConnectionQueueReadOnlyView = Collections.unmodifiableCollection(addConnectionQueue);
|
||||||
this.addConnectionExecutor = createThreadPoolExecutor(addConnectionQueue, poolName + " connection adder", threadFactory, new ThreadPoolExecutor.DiscardOldestPolicy());
|
this.addConnectionExecutor = createThreadPoolExecutor(addConnectionQueue,
|
||||||
this.closeConnectionExecutor = createThreadPoolExecutor(maxPoolSize, poolName + " connection closer", threadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
|
poolName + " connection adder", threadFactory, new ThreadPoolExecutor.DiscardOldestPolicy());
|
||||||
|
this.closeConnectionExecutor = createThreadPoolExecutor(maxPoolSize,
|
||||||
|
poolName + " connection closer", threadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
|
||||||
this.leakTaskFactory = new ProxyLeakTaskFactory(config.getLeakDetectionThreshold(), houseKeepingExecutorService);
|
this.leakTaskFactory = new ProxyLeakTaskFactory(config.getLeakDetectionThreshold(), houseKeepingExecutorService);
|
||||||
this.houseKeeperTask = houseKeepingExecutorService.scheduleWithFixedDelay(new HouseKeeper(this), 100L, config.getHousekeepingPeriodMs(), TimeUnit.MILLISECONDS);
|
this.houseKeeperTask = houseKeepingExecutorService.scheduleWithFixedDelay(new HouseKeeper(this), 100L, config.getHousekeepingPeriodMs(), TimeUnit.MILLISECONDS);
|
||||||
if (Boolean.getBoolean("org.xbib.jdbc.connection.pool.blockUntilFilled") && config.getInitializationFailTimeout() > 1) {
|
if (Boolean.getBoolean("org.xbib.jdbc.connection.pool.blockUntilFilled") && config.getInitializationFailTimeout() > 1) {
|
||||||
|
|
|
@ -29,12 +29,17 @@ public class DriverDataSource implements DataSource {
|
||||||
|
|
||||||
private Driver driver;
|
private Driver driver;
|
||||||
|
|
||||||
public DriverDataSource(String jdbcUrl, String driverClassName, Properties properties, String username, String password) {
|
public DriverDataSource(String jdbcUrl,
|
||||||
|
String driverClassName,
|
||||||
|
Properties properties,
|
||||||
|
String username,
|
||||||
|
String password) {
|
||||||
this.jdbcUrl = jdbcUrl;
|
this.jdbcUrl = jdbcUrl;
|
||||||
this.driverProperties = new Properties();
|
this.driverProperties = new Properties();
|
||||||
for (Entry<Object, Object> entry : properties.entrySet()) {
|
for (Entry<Object, Object> entry : properties.entrySet()) {
|
||||||
driverProperties.setProperty(entry.getKey().toString(), entry.getValue().toString());
|
driverProperties.setProperty(entry.getKey().toString(), entry.getValue().toString());
|
||||||
}
|
}
|
||||||
|
logger.log(Level.INFO, "DriverManager looking for JDBC URL " + jdbcUrl);
|
||||||
if (username != null) {
|
if (username != null) {
|
||||||
setUser(username);
|
setUser(username);
|
||||||
}
|
}
|
||||||
|
@ -51,25 +56,25 @@ public class DriverDataSource implements DataSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (driver == null) {
|
if (driver == null) {
|
||||||
logger.warning("Registered driver with driverClassName was not found, trying direct instantiation: " + driverClassName);
|
logger.log(Level.WARNING, "Registered driver with driverClassName was not found, trying direct instantiation: " + driverClassName);
|
||||||
Class<?> driverClass = null;
|
Class<?> driverClass = null;
|
||||||
ClassLoader threadContextClassLoader = Thread.currentThread().getContextClassLoader();
|
ClassLoader threadContextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||||
try {
|
try {
|
||||||
if (threadContextClassLoader != null) {
|
if (threadContextClassLoader != null) {
|
||||||
try {
|
try {
|
||||||
driverClass = threadContextClassLoader.loadClass(driverClassName);
|
driverClass = threadContextClassLoader.loadClass(driverClassName);
|
||||||
logger.fine("Driver class found in Thread context class loader: " + driverClassName + " " + threadContextClassLoader);
|
logger.log(Level.FINE, "Driver class found in Thread context class loader: " + driverClassName + " " + threadContextClassLoader);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
logger.fine("Driver class not found in Thread context class loader, trying classloader: " +
|
logger.log(Level.FINE, "Driver class not found in Thread context class loader, trying classloader: " +
|
||||||
driverClassName + " " + threadContextClassLoader + " " + this.getClass().getClassLoader());
|
driverClassName + " " + threadContextClassLoader + " " + this.getClass().getClassLoader());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (driverClass == null) {
|
if (driverClass == null) {
|
||||||
driverClass = this.getClass().getClassLoader().loadClass(driverClassName);
|
driverClass = this.getClass().getClassLoader().loadClass(driverClassName);
|
||||||
logger.fine("Driver class found in the PoolConfig class classloader:" + driverClassName + " " + this.getClass().getClassLoader());
|
logger.log(Level.FINE, "Driver class found in the PoolConfig class classloader:" + driverClassName + " " + this.getClass().getClassLoader());
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
logger.fine("Failed to load driver class from PoolConfig class classloader: " + driverClassName + " " + this.getClass().getClassLoader());
|
logger.log(Level.FINE, "Failed to load driver class from PoolConfig class classloader: " + driverClassName + " " + this.getClass().getClassLoader());
|
||||||
}
|
}
|
||||||
if (driverClass != null) {
|
if (driverClass != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -84,7 +89,7 @@ public class DriverDataSource implements DataSource {
|
||||||
try {
|
try {
|
||||||
if (driver == null) {
|
if (driver == null) {
|
||||||
driver = DriverManager.getDriver(jdbcUrl);
|
driver = DriverManager.getDriver(jdbcUrl);
|
||||||
logger.fine("Loaded driver with class name for jdbcUrl " + driver.getClass().getName() + " " + sanitizedUrl);
|
logger.log(Level.FINE, "Loaded driver with class name for jdbcUrl " + driver.getClass().getName() + " " + sanitizedUrl);
|
||||||
} else if (!driver.acceptsURL(jdbcUrl)) {
|
} else if (!driver.acceptsURL(jdbcUrl)) {
|
||||||
throw new RuntimeException("Driver " + driverClassName + " claims to not accept jdbcUrl " + sanitizedUrl);
|
throw new RuntimeException("Driver " + driverClassName + " claims to not accept jdbcUrl " + sanitizedUrl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class DatabaseImpl implements Database {
|
||||||
@Override
|
@Override
|
||||||
public void commitNow() {
|
public void commitNow() {
|
||||||
if (options.ignoreTransactionControl()) {
|
if (options.ignoreTransactionControl()) {
|
||||||
logger.fine("Ignoring call to commitNow()");
|
logger.log(Level.FINE, "Ignoring call to commitNow()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!options.allowTransactionControl()) {
|
if (!options.allowTransactionControl()) {
|
||||||
|
@ -118,7 +118,7 @@ public class DatabaseImpl implements Database {
|
||||||
@Override
|
@Override
|
||||||
public void rollbackNow() {
|
public void rollbackNow() {
|
||||||
if (options.ignoreTransactionControl()) {
|
if (options.ignoreTransactionControl()) {
|
||||||
logger.fine("Ignoring call to rollbackNow()");
|
logger.log(Level.FINE, "Ignoring call to rollbackNow()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!options.allowTransactionControl()) {
|
if (!options.allowTransactionControl()) {
|
||||||
|
|
Loading…
Reference in a new issue