Search in sources :

Example 6 with StatisticsResourceDefinition

use of org.jboss.as.connector.dynamicresource.StatisticsResourceDefinition in project wildfly by wildfly.

the class DataSourceStatisticsService method start.

@Override
public void start(StartContext context) throws StartException {
    ROOT_LOGGER.debugf("Starting DataSourceStatisticsService");
    synchronized (JDBC_STATISTICS) {
        CommonDeployment deploymentMD = injectedDeploymentMD.getValue();
        StatisticsPlugin jdbcStats = deploymentMD.getDataSources()[0].getStatistics();
        StatisticsPlugin poolStats = deploymentMD.getDataSources()[0].getPool().getStatistics();
        jdbcStats.setEnabled(statsEnabled);
        poolStats.setEnabled(statsEnabled);
        int jdbcStatsSize = jdbcStats.getNames().size();
        int poolStatsSize = poolStats.getNames().size();
        if (jdbcStatsSize > 0 || poolStatsSize > 0) {
            if (registration != null) {
                if (jdbcStatsSize > 0) {
                    if (registration.getSubModel(PathAddress.pathAddress(JDBC_STATISTICS)) == null) {
                        // TODO WFLY-5285 get rid of redundant .setRuntimeOnly once WFCORE-959 is integrated
                        ManagementResourceRegistration jdbcRegistration = registration.registerSubModel(new StatisticsResourceDefinition(JDBC_STATISTICS, DataSourcesSubsystemProviders.RESOURCE_NAME, jdbcStats));
                        jdbcRegistration.setRuntimeOnly(true);
                    }
                }
                if (poolStatsSize > 0) {
                    if (registration.getSubModel(PathAddress.pathAddress(POOL_STATISTICS)) == null) {
                        // TODO WFLY-5285 get rid of redundant .setRuntimeOnly once WFCORE-959 is integrated
                        ManagementResourceRegistration poolRegistration = registration.registerSubModel(new StatisticsResourceDefinition(POOL_STATISTICS, DataSourcesSubsystemProviders.RESOURCE_NAME, poolStats));
                        poolRegistration.setRuntimeOnly(true);
                    }
                }
            }
        }
    }
}
Also used : CommonDeployment(org.jboss.jca.deployers.common.CommonDeployment) StatisticsResourceDefinition(org.jboss.as.connector.dynamicresource.StatisticsResourceDefinition) StatisticsPlugin(org.jboss.jca.core.spi.statistics.StatisticsPlugin) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration)

Aggregations

StatisticsResourceDefinition (org.jboss.as.connector.dynamicresource.StatisticsResourceDefinition)6 StatisticsPlugin (org.jboss.jca.core.spi.statistics.StatisticsPlugin)6 CommonDeployment (org.jboss.jca.deployers.common.CommonDeployment)6 PathElement (org.jboss.as.controller.PathElement)4 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)3 AdminObject (org.jboss.jca.core.api.management.AdminObject)2 ConnectionFactory (org.jboss.jca.core.api.management.ConnectionFactory)2 ConnectionManager (org.jboss.jca.core.connectionmanager.ConnectionManager)2 Locale (java.util.Locale)1 Map (java.util.Map)1 ClearStatisticsHandler (org.jboss.as.connector.dynamicresource.ClearStatisticsHandler)1 ResourceAdapterDeployment (org.jboss.as.connector.metadata.deployment.ResourceAdapterDeployment)1 PoolMetrics (org.jboss.as.connector.subsystems.common.pool.PoolMetrics)1 IronJacamarResource (org.jboss.as.connector.subsystems.resourceadapters.IronJacamarResource)1 IronJacamarResourceDefinition (org.jboss.as.connector.subsystems.resourceadapters.IronJacamarResourceDefinition)1 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)1 ResourceBuilder (org.jboss.as.controller.ResourceBuilder)1 OverrideDescriptionProvider (org.jboss.as.controller.descriptions.OverrideDescriptionProvider)1 StandardResourceDescriptionResolver (org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver)1 Resource (org.jboss.as.controller.registry.Resource)1