Revert over-aggressive optimization, and various cleanup.

pull/192/head
Brett Wooldridge 10 years ago
parent 3b83896e68
commit b64dc6fbf0

@ -52,13 +52,17 @@ public final class HikariMBeanElf
* @param configuration a HikariConfig instance
* @param pool a HikariPool instance
*/
public static void registerMBeans(HikariConfig configuration, HikariPool pool)
public static void registerMBeans(final HikariConfig configuration, final HikariPool pool)
{
if (!configuration.isRegisterMbeans()) {
return;
}
try {
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName poolConfigName = new ObjectName("com.zaxxer.hikari:type=PoolConfig (" + configuration.getPoolName() + ")");
ObjectName poolName = new ObjectName("com.zaxxer.hikari:type=Pool (" + configuration.getPoolName() + ")");
final ObjectName poolConfigName = new ObjectName("com.zaxxer.hikari:type=PoolConfig (" + configuration.getPoolName() + ")");
final ObjectName poolName = new ObjectName("com.zaxxer.hikari:type=Pool (" + configuration.getPoolName() + ")");
if (!mBeanServer.isRegistered(poolConfigName)) {
mBeanServer.registerMBean(configuration, poolConfigName);
mBeanServer.registerMBean(pool, poolName);
@ -78,13 +82,13 @@ public final class HikariMBeanElf
* @param configuration a HikariConfig instance
* @param pool a HikariPool instance
*/
public static void unregisterMBeans(HikariConfig configuration, HikariPool pool)
public static void unregisterMBeans(final HikariConfig configuration, final HikariPool pool)
{
try {
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName poolConfigName = new ObjectName("com.zaxxer.hikari:type=PoolConfig (" + configuration.getPoolName() + ")");
ObjectName poolName = new ObjectName("com.zaxxer.hikari:type=Pool (" + configuration.getPoolName() + ")");
final ObjectName poolConfigName = new ObjectName("com.zaxxer.hikari:type=PoolConfig (" + configuration.getPoolName() + ")");
final ObjectName poolName = new ObjectName("com.zaxxer.hikari:type=Pool (" + configuration.getPoolName() + ")");
if (mBeanServer.isRegistered(poolConfigName)) {
mBeanServer.unregisterMBean(poolConfigName);
mBeanServer.unregisterMBean(poolName);

@ -92,7 +92,6 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
private final String username;
private final String password;
private final boolean isRecordMetrics;
private final boolean isRegisteredMbeans;
private final boolean isIsolateInternalQueries;
private final long leakDetectionThreshold;
@ -131,7 +130,6 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
this.isReadOnly = configuration.isReadOnly();
this.isAutoCommit = configuration.isAutoCommit();
this.isRegisteredMbeans = configuration.isRegisterMbeans();
this.catalog = configuration.getCatalog();
this.connectionCustomizer = initializeCustomizer();
@ -146,9 +144,7 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
setLoginTimeout(dataSource, configuration.getConnectionTimeout(), LOGGER);
if (isRegisteredMbeans) {
HikariMBeanElf.registerMBeans(configuration, this);
}
HikariMBeanElf.registerMBeans(configuration, this);
addConnectionExecutor = createThreadPoolExecutor(configuration.getMaximumPoolSize(), "HikariCP connection filler (pool " + configuration.getPoolName() + ")", configuration.getThreadFactory(), new ThreadPoolExecutor.DiscardPolicy());
closeConnectionExecutor = createThreadPoolExecutor(4, "HikariCP connection closer (pool " + configuration.getPoolName() + ")", configuration.getThreadFactory(), new ThreadPoolExecutor.CallerRunsPolicy());
@ -432,7 +428,9 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
connection.setAutoCommit(isAutoCommit);
connection.setTransactionIsolation(transactionIsolation);
connection.setReadOnly(isReadOnly);
connection.setCatalog(catalog);
if (catalog != null) {
connection.setCatalog(catalog);
}
setNetworkTimeout(houseKeepingExecutorService, connection, networkTimeout, isUseNetworkTimeout);

@ -52,13 +52,17 @@ public final class HikariMBeanElf
* @param configuration a HikariConfig instance
* @param pool a HikariPool instance
*/
public static void registerMBeans(HikariConfig configuration, HikariPool pool)
public static void registerMBeans(final HikariConfig configuration, final HikariPool pool)
{
if (!configuration.isRegisterMbeans()) {
return;
}
try {
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName poolConfigName = new ObjectName("com.zaxxer.hikari:type=PoolConfig (" + configuration.getPoolName() + ")");
ObjectName poolName = new ObjectName("com.zaxxer.hikari:type=Pool (" + configuration.getPoolName() + ")");
final ObjectName poolConfigName = new ObjectName("com.zaxxer.hikari:type=PoolConfig (" + configuration.getPoolName() + ")");
final ObjectName poolName = new ObjectName("com.zaxxer.hikari:type=Pool (" + configuration.getPoolName() + ")");
if (!mBeanServer.isRegistered(poolConfigName)) {
mBeanServer.registerMBean(configuration, poolConfigName);
mBeanServer.registerMBean(pool, poolName);

@ -91,7 +91,6 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
private final String username;
private final String password;
private final boolean isRecordMetrics;
private final boolean isRegisteredMbeans;
private final boolean isIsolateInternalQueries;
private final long leakDetectionThreshold;
@ -130,7 +129,6 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
this.isReadOnly = configuration.isReadOnly();
this.isAutoCommit = configuration.isAutoCommit();
this.isRegisteredMbeans = configuration.isRegisterMbeans();
this.catalog = configuration.getCatalog();
this.connectionCustomizer = initializeCustomizer();
@ -145,9 +143,7 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
setLoginTimeout(dataSource, configuration.getConnectionTimeout(), LOGGER);
if (isRegisteredMbeans) {
HikariMBeanElf.registerMBeans(configuration, this);
}
HikariMBeanElf.registerMBeans(configuration, this);
addConnectionExecutor = createThreadPoolExecutor(configuration.getMaximumPoolSize(), "HikariCP connection filler (pool " + configuration.getPoolName() + ")", configuration.getThreadFactory(), new ThreadPoolExecutor.DiscardPolicy());
closeConnectionExecutor = createThreadPoolExecutor(4, "HikariCP connection closer (pool " + configuration.getPoolName() + ")", configuration.getThreadFactory(), new ThreadPoolExecutor.CallerRunsPolicy());
@ -415,7 +411,9 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
connection.setAutoCommit(isAutoCommit);
connection.setTransactionIsolation(transactionIsolation);
connection.setReadOnly(isReadOnly);
connection.setCatalog(catalog);
if (catalog != null) {
connection.setCatalog(catalog);
}
setNetworkTimeout(houseKeepingExecutorService, connection, networkTimeout, isUseNetworkTimeout);

Loading…
Cancel
Save