public ConnectorConnectionPool createConnectorConnectionPool( JdbcConnectionPool adminPool, PoolInfo poolInfo) throws ConnectorRuntimeException { String moduleName = JdbcResourcesUtil.createInstance().getRANameofJdbcConnectionPool(adminPool); int txSupport = getTxSupport(moduleName); ConnectorDescriptor connDesc = runtime.getConnectorDescriptor(moduleName); // Create the connector Connection Pool object from the configbean object ConnectorConnectionPool conConnPool = new ConnectorConnectionPool(poolInfo); conConnPool.setTransactionSupport(txSupport); setConnectorConnectionPoolAttributes(conConnPool, adminPool); // Initially create the ConnectorDescriptor ConnectorDescriptorInfo connDescInfo = createConnectorDescriptorInfo(connDesc, moduleName); connDescInfo.setMCFConfigProperties(getMCFConfigProperties(adminPool, conConnPool, connDesc)); // since we are deploying a 1.0 RAR, this is null connDescInfo.setResourceAdapterConfigProperties((Set) null); conConnPool.setConnectorDescriptorInfo(connDescInfo); return conConnPool; }
/** * Undeploy the resource from the server's runtime naming context * * @param poolInfo a resource object * @throws UnsupportedOperationException Currently we are not supporting this method. */ private synchronized void actualUndeployResource(PoolInfo poolInfo) throws Exception { runtime.deleteConnectorConnectionPool(poolInfo); // performance issue related fix : IT 15784 ConnectorRegistry.getInstance().removeTransparentDynamicReconfigPool(poolInfo); if (_logger.isLoggable(Level.FINEST)) { _logger.finest("Pool Undeployed"); } }
private void recreatePool(ConnectorConnectionPool connConnPool) { try { runtime.recreateConnectorConnectionPool(connConnPool); debug("Pool [" + connConnPool.getName() + "] recreation done"); } catch (ConnectorRuntimeException cre) { Object params[] = new Object[] {connConnPool.getName(), cre}; _logger.log(Level.WARNING, "error.redeploying.jdbc.pool", params); } }
/** * Deploy the resource into the server's runtime naming context * * @param resource a resource object * @throws Exception thrown if fail */ public void actualDeployResource(Object resource, PoolInfo poolInfo) { if (_logger.isLoggable(Level.FINE)) { _logger.fine(" JdbcConnectionPoolDeployer - actualDeployResource : " + poolInfo); } JdbcConnectionPool adminPool = (JdbcConnectionPool) resource; try { ConnectorConnectionPool connConnPool = createConnectorConnectionPool(adminPool, poolInfo); registerTransparentDynamicReconfigPool(poolInfo, adminPool); // now do internal book keeping runtime.createConnectorConnectionPool(connConnPool); } catch (Exception e) { Object params[] = new Object[] {poolInfo, e}; _logger.log(Level.WARNING, "error.creating.jdbc.pool", params); } }
/** * Register the jdbc connection pool Stats Provider object to the monitoring framework under the * specific application name monitoring sub tree. * * @param appName * @return */ @Override public ConnectionPoolAppProbeProvider registerConnectionPool(PoolInfo poolInfo, String appName) { ConnectionPoolAppProbeProvider probeAppProvider = null; ResourcePool pool = runtime.getConnectionPoolConfig(poolInfo); if (pool instanceof JdbcConnectionPool) { probeAppProvider = new JdbcConnPoolAppProbeProvider(); JdbcConnPoolAppStatsProvider jdbcPoolAppStatsProvider = new JdbcConnPoolAppStatsProvider(poolInfo, appName); StatsProviderManager.register( "jdbc-connection-pool", PluginPoint.SERVER, "resources/" + ConnectorsUtil.escapeResourceNameForMonitoring(poolInfo.getName()) + "/" + appName, jdbcPoolAppStatsProvider); jdbcPoolAppStatsProviders.add(jdbcPoolAppStatsProvider); } return probeAppProvider; }
/** * Reset pool statistics. When annotated with @Reset, this method is invoked whenever monitoring * is turned to HIGH from OFF, thereby setting the statistics to appropriate values. */ @Reset public void reset() { if (logger.isLoggable(Level.FINEST)) { logger.finest("Reset event received - poolInfo = " + poolInfo); } PoolStatus status = ConnectorRuntime.getRuntime().getPoolManager().getPoolStatus(poolInfo); numConnUsed.setCurrent(status.getNumConnUsed()); numConnFree.setCurrent(status.getNumConnFree()); numConnCreated.reset(); numConnDestroyed.reset(); numConnFailedValidation.reset(); numConnTimedOut.reset(); numConnAcquired.reset(); numConnReleased.reset(); connRequestWaitTime.reset(); numConnSuccessfullyMatched.reset(); numConnNotSuccessfullyMatched.reset(); numPotentialConnLeak.reset(); averageConnWaitTime.reset(); totalConnRequestWaitTime.reset(); waitQueueLength.reset(); }
public JdbcPoolMonitoringExtension() { jdbcStatsProviders = new ArrayList<JdbcConnPoolStatsProvider>(); jdbcPoolAppStatsProviders = new ArrayList<JdbcConnPoolAppStatsProvider>(); runtime = ConnectorRuntime.getRuntime(); }
private void handlePoolRecreation(final ConnectorConnectionPool connConnPool) throws ConnectorRuntimeException { debug("[DRC] Pool recreation required"); final long reconfigWaitTimeout = connConnPool.getDynamicReconfigWaitTimeout(); PoolInfo poolInfo = new PoolInfo( connConnPool.getName(), connConnPool.getApplicationName(), connConnPool.getModuleName()); final ResourcePool oldPool = runtime.getPoolManager().getPool(poolInfo); if (reconfigWaitTimeout > 0) { oldPool.blockRequests(reconfigWaitTimeout); if (oldPool.getPoolWaitQueue().getQueueLength() > 0 || oldPool.getPoolStatus().getNumConnUsed() > 0) { Runnable thread = new Runnable() { @Override public void run() { try { long numSeconds = 5000L; // poll every 5 seconds long steps = reconfigWaitTimeout / numSeconds; if (steps == 0) { waitForCompletion(steps, oldPool, reconfigWaitTimeout); } else { for (long i = 0; i < steps; i++) { waitForCompletion(steps, oldPool, reconfigWaitTimeout); if (oldPool.getPoolWaitQueue().getQueueLength() == 0 && oldPool.getPoolStatus().getNumConnUsed() == 0) { debug("wait-queue is empty and num-con-used is 0"); break; } } } handlePoolRecreationForExistingProxies(connConnPool); PoolWaitQueue reconfigWaitQueue = oldPool.getReconfigWaitQueue(); debug("checking reconfig-wait-queue for notification"); if (reconfigWaitQueue.getQueueContents().size() > 0) { for (Object o : reconfigWaitQueue.getQueueContents()) { debug("notifying reconfig-wait-queue object [ " + o + " ]"); synchronized (o) { o.notify(); } } } } catch (InterruptedException ie) { if (_logger.isLoggable(Level.FINEST)) { _logger.log( Level.FINEST, "Interrupted while waiting for all existing clients to return connections to pool", ie); } } if (_logger.isLoggable(Level.FINEST)) { _logger.finest( "woke-up after giving time for in-use connections to return, " + "WaitQueue-Length : [" + oldPool.getPoolWaitQueue().getQueueContents() + "], " + "Num-Conn-Used : [" + oldPool.getPoolStatus().getNumConnUsed() + "]"); } } }; Callable c = Executors.callable(thread); ArrayList list = new ArrayList(); list.add(c); try { execService.invokeAll(list); } catch (Exception e) { Object[] params = new Object[] {connConnPool.getName(), e}; _logger.log(Level.WARNING, "exception.redeploying.pool.transparently", params); } } else { handlePoolRecreationForExistingProxies(connConnPool); } } else if (oldPool.getReconfigWaitTime() > 0) { // reconfig is being switched off, invalidate proxies Collection<BindableResource> resources = JdbcResourcesUtil.getResourcesOfPool( runtime.getResources(oldPool.getPoolInfo()), oldPool.getPoolInfo().getName()); ConnectorRegistry registry = ConnectorRegistry.getInstance(); for (BindableResource resource : resources) { ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(resource); registry.removeResourceFactories(resourceInfo); } // recreate the pool now. recreatePool(connConnPool); } else { recreatePool(connConnPool); } }
/** {@inheritDoc} */ @Override public synchronized void redeployResource(Object resource) throws Exception { final JdbcConnectionPool adminPool = (JdbcConnectionPool) resource; PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(adminPool); // Only if pool has already been deployed in this server-instance // reconfig this pool if (!runtime.isConnectorConnectionPoolDeployed(poolInfo)) { if (_logger.isLoggable(Level.FINE)) { _logger.fine( "The JDBC connection pool " + poolInfo + " is not referred or not yet created in this server " + "instance and hence pool redeployment is ignored"); } return; } final ConnectorConnectionPool connConnPool = createConnectorConnectionPool(adminPool, poolInfo); if (connConnPool == null) { throw new ConnectorRuntimeException( "Unable to create ConnectorConnectionPool" + "from JDBC connection pool"); } // now do internal book keeping HashSet excludes = new HashSet(); // add MCF config props to the set that need to be excluded // in checking for the equality of the props with old pool excludes.add("TransactionIsolation"); excludes.add("GuaranteeIsolationLevel"); excludes.add("ValidationTableName"); excludes.add("ConnectionValidationRequired"); excludes.add("ValidationMethod"); excludes.add("StatementWrapping"); excludes.add("StatementTimeout"); excludes.add("ValidationClassName"); excludes.add("StatementCacheSize"); excludes.add("StatementCacheType"); excludes.add("StatementLeakTimeoutInSeconds"); excludes.add("StatementLeakReclaim"); try { if (_logger.isLoggable(Level.FINEST)) { _logger.finest("Calling reconfigure pool"); } boolean requirePoolRecreation = runtime.reconfigureConnectorConnectionPool(connConnPool, excludes); if (requirePoolRecreation) { if (runtime.isServer() || runtime.isEmbedded()) { handlePoolRecreation(connConnPool); } else { recreatePool(connConnPool); } } } catch (ConnectorRuntimeException cre) { Object params[] = new Object[] {poolInfo, cre}; _logger.log(Level.WARNING, "error.redeploying.jdbc.pool", params); throw cre; } }