Search in sources :

Example 1 with PoolLifeCycleListenerRegistry

use of com.sun.enterprise.resource.pool.PoolLifeCycleListenerRegistry in project Payara by payara.

the class JdbcPoolMonitoringExtension method registerPool.

/**
 * Register jdbc connection pool to the StatsProviderManager.
 * Add the pool lifecycle listeners for the pool to receive events on
 * change of any of the monitoring attribute values.
 * Finally, add this provider to the list of jdbc providers maintained.
 * @param poolInfo
 */
@Override
public void registerPool(PoolInfo poolInfo) {
    if (poolManager.getPool(poolInfo) != null) {
        getProbeProviderUtil().createJdbcProbeProvider();
        // Found in the pool table (pool has been initialized/created)
        JdbcConnPoolStatsProvider jdbcPoolStatsProvider = new JdbcConnPoolStatsProvider(poolInfo, logger);
        StatsProviderManager.register("jdbc-connection-pool", PluginPoint.SERVER, ConnectorsUtil.getPoolMonitoringSubTreeRoot(poolInfo, true), jdbcPoolStatsProvider);
        // String jdbcPoolName = jdbcPoolStatsProvider.getJdbcPoolName();
        PoolLifeCycleListenerRegistry registry = connectionPoolStatsProviderBootstrapProvider.get().registerPool(poolInfo, getProbeProviderUtil().getJdbcProbeProvider());
        jdbcPoolStatsProvider.setPoolRegistry(registry);
        jdbcStatsProviders.add(jdbcPoolStatsProvider);
    }
}
Also used : JdbcConnPoolStatsProvider(org.glassfish.jdbc.pool.monitor.JdbcConnPoolStatsProvider) PoolLifeCycleListenerRegistry(com.sun.enterprise.resource.pool.PoolLifeCycleListenerRegistry)

Example 2 with PoolLifeCycleListenerRegistry

use of com.sun.enterprise.resource.pool.PoolLifeCycleListenerRegistry in project Payara by payara.

the class ConnectionPoolStatsProviderBootstrap method registerPool.

/**
 * Registers the pool lifecycle listener for this pool by creating a
 * new ConnectionPoolEmitterImpl object for this pool.
 * @param poolInfo
 * @return registry of pool lifecycle listeners
 */
public PoolLifeCycleListenerRegistry registerPool(PoolInfo poolInfo, ConnectionPoolProbeProvider poolProvider) {
    PoolLifeCycleListenerRegistry poolRegistry = null;
    if (poolRegistries.get(poolInfo) == null) {
        poolRegistry = new PoolLifeCycleListenerRegistry(poolInfo);
        poolRegistries.put(poolInfo, poolRegistry);
    } else {
        poolRegistry = poolRegistries.get(poolInfo);
    }
    ConnectionPoolEmitterImpl emitter = new com.sun.enterprise.resource.pool.monitor.ConnectionPoolEmitterImpl(poolInfo, poolProvider);
    poolRegistry.registerPoolLifeCycleListener(emitter);
    addToPoolEmitters(poolInfo, emitter);
    return poolRegistry;
}
Also used : PoolLifeCycleListenerRegistry(com.sun.enterprise.resource.pool.PoolLifeCycleListenerRegistry)

Example 3 with PoolLifeCycleListenerRegistry

use of com.sun.enterprise.resource.pool.PoolLifeCycleListenerRegistry in project Payara by payara.

the class ConnectionPoolStatsProviderBootstrap method registerCcPool.

/**
 * Register connector connection pool to the StatsProviderManager.
 * Add the pool lifecycle listeners for the pool to receive events on
 * change of any of the monitoring attribute values.
 * Finally, add this provider to the list of connector connection pool
 * providers maintained.
 * @param poolInfo
 */
private void registerCcPool(PoolInfo poolInfo) {
    if (poolManager.getPool(poolInfo) != null) {
        getProbeProviderUtil().createJcaProbeProvider();
        // Found in the pool table (pool has been initialized/created)
        ConnectorConnPoolStatsProvider ccPoolStatsProvider = new ConnectorConnPoolStatsProvider(poolInfo, logger);
        StatsProviderManager.register("connector-connection-pool", PluginPoint.SERVER, ConnectorsUtil.getPoolMonitoringSubTreeRoot(poolInfo, true), ccPoolStatsProvider);
        PoolLifeCycleListenerRegistry registry = registerPool(poolInfo, getProbeProviderUtil().getJcaProbeProvider());
        ccPoolStatsProvider.setPoolRegistry(registry);
        ccStatsProviders.add(ccPoolStatsProvider);
        if (!ConnectorsUtil.isApplicationScopedResource(poolInfo)) {
            ResourcesUtil resourcesUtil = ResourcesUtil.createInstance();
            ResourcePool pool = resourcesUtil.getPoolConfig(poolInfo);
            Resources resources = resourcesUtil.getResources(poolInfo);
            String raName = resourcesUtil.getRarNameOfResource(pool, resources);
            ConnectorConnPoolStatsProvider connectorServicePoolStatsProvider = new ConnectorConnPoolStatsProvider(poolInfo, logger);
            String dottedNamesHierarchy = null;
            String monitoringModuleName = null;
            if (ConnectorsUtil.isJMSRA(raName)) {
                monitoringModuleName = ConnectorConstants.MONITORING_JMS_SERVICE_MODULE_NAME;
                dottedNamesHierarchy = ConnectorConstants.MONITORING_JMS_SERVICE + ConnectorConstants.MONITORING_SEPARATOR + ConnectorConstants.MONITORING_CONNECTION_FACTORIES + ConnectorConstants.MONITORING_SEPARATOR + ConnectorsUtil.escapeResourceNameForMonitoring(poolInfo.getName());
            } else {
                monitoringModuleName = ConnectorConstants.MONITORING_CONNECTOR_SERVICE_MODULE_NAME;
                dottedNamesHierarchy = ConnectorConstants.MONITORING_CONNECTOR_SERVICE_MODULE_NAME + ConnectorConstants.MONITORING_SEPARATOR + raName + ConnectorConstants.MONITORING_SEPARATOR + ConnectorsUtil.escapeResourceNameForMonitoring(poolInfo.getName());
            }
            StatsProviderManager.register(monitoringModuleName, PluginPoint.SERVER, dottedNamesHierarchy, connectorServicePoolStatsProvider);
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, "Registered pool-monitoring stats [ " + dottedNamesHierarchy + " ]  " + "for [ " + raName + " ] with monitoring-stats-registry.");
            }
            /* no need to create multiple probe provider instances, one per pool will
                   work for multiple stats providers 
                PoolLifeCycleListenerRegistry poolLifeCycleListenerRegistry = registerPool(
                        poolInfo, getProbeProviderUtil().getJcaProbeProvider());
                */
            connectorServicePoolStatsProvider.setPoolRegistry(registry);
            ccStatsProviders.add(connectorServicePoolStatsProvider);
        }
    }
}
Also used : PoolLifeCycleListenerRegistry(com.sun.enterprise.resource.pool.PoolLifeCycleListenerRegistry) ResourcesUtil(com.sun.enterprise.connectors.util.ResourcesUtil) ResourcePool(com.sun.enterprise.config.serverbeans.ResourcePool) Resources(com.sun.enterprise.config.serverbeans.Resources)

Example 4 with PoolLifeCycleListenerRegistry

use of com.sun.enterprise.resource.pool.PoolLifeCycleListenerRegistry in project Payara by payara.

the class ConnectionPoolStatsProviderBootstrap method unregisterPool.

/**
 * Unregister Connector Connection pool from the StatsProviderManager.
 * Remove the pool lifecycle listeners associated with this pool.
 * @param poolInfo
 */
private void unregisterPool(PoolInfo poolInfo) {
    if (ccStatsProviders != null) {
        Iterator i = ccStatsProviders.iterator();
        while (i.hasNext()) {
            ConnectorConnPoolStatsProvider ccPoolStatsProvider = (ConnectorConnPoolStatsProvider) i.next();
            if (poolInfo.equals(ccPoolStatsProvider.getPoolInfo())) {
                // Get registry and unregister this pool from the registry
                PoolLifeCycleListenerRegistry poolRegistry = ccPoolStatsProvider.getPoolRegistry();
                poolRegistry.unRegisterPoolLifeCycleListener(poolInfo);
                StatsProviderManager.unregister(ccPoolStatsProvider);
                i.remove();
            }
        }
    }
    postUnregisterPool(poolInfo);
}
Also used : PoolLifeCycleListenerRegistry(com.sun.enterprise.resource.pool.PoolLifeCycleListenerRegistry)

Example 5 with PoolLifeCycleListenerRegistry

use of com.sun.enterprise.resource.pool.PoolLifeCycleListenerRegistry in project Payara by payara.

the class JdbcPoolMonitoringExtension method unregisterPool.

/**
 * Unregister Jdbc Connection pool from the StatsProviderManager.
 * Remove the pool lifecycle listeners associated with this pool.
 * @param poolInfo
 */
@Override
public void unregisterPool(PoolInfo poolInfo) {
    if (jdbcStatsProviders != null) {
        Iterator i = jdbcStatsProviders.iterator();
        while (i.hasNext()) {
            JdbcConnPoolStatsProvider jdbcPoolStatsProvider = (JdbcConnPoolStatsProvider) i.next();
            if (poolInfo.equals(jdbcPoolStatsProvider.getPoolInfo())) {
                // Get registry and unregister this pool from the registry
                PoolLifeCycleListenerRegistry poolRegistry = jdbcPoolStatsProvider.getPoolRegistry();
                poolRegistry.unRegisterPoolLifeCycleListener(poolInfo);
                StatsProviderManager.unregister(jdbcPoolStatsProvider);
                i.remove();
            }
        }
    }
    connectionPoolStatsProviderBootstrapProvider.get().postUnregisterPool(poolInfo);
}
Also used : JdbcConnPoolStatsProvider(org.glassfish.jdbc.pool.monitor.JdbcConnPoolStatsProvider) PoolLifeCycleListenerRegistry(com.sun.enterprise.resource.pool.PoolLifeCycleListenerRegistry) Iterator(java.util.Iterator)

Aggregations

PoolLifeCycleListenerRegistry (com.sun.enterprise.resource.pool.PoolLifeCycleListenerRegistry)5 JdbcConnPoolStatsProvider (org.glassfish.jdbc.pool.monitor.JdbcConnPoolStatsProvider)2 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)1 Resources (com.sun.enterprise.config.serverbeans.Resources)1 ResourcesUtil (com.sun.enterprise.connectors.util.ResourcesUtil)1 Iterator (java.util.Iterator)1