Search in sources :

Example 1 with StatisticsResourceDefinition

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

the class IronJacamarActivationResourceService method start.

@Override
public void start(StartContext context) throws StartException {
    final CommonDeployment deploymentMD = deployment.getValue().getDeployment();
    final String deploymentName = deploymentMD.getDeploymentName();
    ROOT_LOGGER.debugf("Starting IronJacamarActivationResourceService %s", deploymentName);
    try {
        Connector connector = deploymentMD.getConnector();
        if (connector != null && connector.getResourceAdapter() != null) {
            final OverrideDescriptionProvider OD_PROVIDER = new OverrideDescriptionProvider() {

                @Override
                public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
                    return Collections.emptyMap();
                }

                @Override
                public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
                    return Collections.emptyMap();
                }
            };
            final PathElement EXTENDED_STATS = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
            final PathAddress EXTENDED_STATS_ADDR = PathAddress.pathAddress(EXTENDED_STATS);
            final PathAddress CON_DEF_ADDR = PathAddress.EMPTY_ADDRESS.append(Constants.CONNECTIONDEFINITIONS_NAME);
            ManagementResourceRegistration raRegistration = registration.getSubModel(RA_ADDRESS).registerOverrideModel(deploymentName, OD_PROVIDER);
            ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(EXTENDED_STATS, new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));
            ManagementResourceRegistration raStatsSubRegistration = raRegistration.registerSubModel(resourceBuilder.build());
            StatisticsPlugin raStats = connector.getResourceAdapter().getStatistics();
            if (raStats != null) {
                raStats.setEnabled(statsEnabled);
                PoolMetrics.ParametrizedPoolMetricsHandler handler = new PoolMetrics.ParametrizedPoolMetricsHandler(raStats);
                for (AttributeDefinition attribute : StatisticsResourceDefinition.getAttributesFromPlugin(raStats)) {
                    raStatsSubRegistration.registerMetric(attribute, handler);
                }
                raStatsSubRegistration.registerOperationHandler(ClearStatisticsHandler.DEFINITION, new ClearStatisticsHandler(raStats));
            }
            List<ConnectionFactory> connectionFactories = connector.getConnectionFactories();
            if (connectionFactories != null) {
                for (ConnectionFactory cf : connectionFactories) {
                    ManagedConnectionFactory mcf = cf.getManagedConnectionFactory();
                    StatisticsPlugin extendStats = mcf == null ? null : mcf.getStatistics();
                    if (extendStats != null) {
                        extendStats.setEnabled(statsEnabled);
                        if (!extendStats.getNames().isEmpty()) {
                            ManagementResourceRegistration cdRegistration = raRegistration.getSubModel(CON_DEF_ADDR);
                            ManagementResourceRegistration overrideCdRegistration = cdRegistration.registerOverrideModel(cf.getJndiName(), OD_PROVIDER);
                            if (overrideCdRegistration.getSubModel(EXTENDED_STATS_ADDR) == null) {
                                overrideCdRegistration.registerSubModel(new StatisticsResourceDefinition(EXTENDED_STATS, CommonAttributes.RESOURCE_NAME, extendStats));
                            }
                        }
                    }
                }
            }
            ConnectionManager[] connectionManagers = deploymentMD.getConnectionManagers();
            if (connectionManagers != null) {
                PathElement POOL_STATS = PathElement.pathElement(Constants.STATISTICS_NAME, "pool");
                PathAddress POOL_STATS_ADDR = PathAddress.pathAddress(POOL_STATS);
                for (ConnectionManager cm : connectionManagers) {
                    if (cm.getPool() != null) {
                        StatisticsPlugin poolStats = cm.getPool().getStatistics();
                        poolStats.setEnabled(statsEnabled);
                        if (!poolStats.getNames().isEmpty()) {
                            ManagementResourceRegistration cdRegistration = raRegistration.getSubModel(CON_DEF_ADDR);
                            ManagementResourceRegistration overrideCdRegistration = cdRegistration.registerOverrideModel(cm.getJndiName(), OD_PROVIDER);
                            if (overrideCdRegistration.getSubModel(POOL_STATS_ADDR) == null) {
                                overrideCdRegistration.registerSubModel(new StatisticsResourceDefinition(POOL_STATS, CommonAttributes.RESOURCE_NAME, poolStats));
                            }
                        }
                    }
                }
            }
            List<AdminObject> adminObjects = connector.getAdminObjects();
            if (adminObjects != null) {
                PathAddress AO_ADDR = PathAddress.EMPTY_ADDRESS.append(Constants.ADMIN_OBJECTS_NAME);
                for (AdminObject ao : adminObjects) {
                    StatisticsPlugin extendStats = ao.getStatistics();
                    if (extendStats != null) {
                        extendStats.setEnabled(statsEnabled);
                        if (!extendStats.getNames().isEmpty()) {
                            ManagementResourceRegistration cdRegistration = raRegistration.getSubModel(AO_ADDR);
                            ManagementResourceRegistration overrideCdRegistration = cdRegistration.registerOverrideModel(ao.getJndiName(), OD_PROVIDER);
                            if (overrideCdRegistration.getSubModel(EXTENDED_STATS_ADDR) == null) {
                                overrideCdRegistration.registerSubModel(new StatisticsResourceDefinition(EXTENDED_STATS, CommonAttributes.RESOURCE_NAME, extendStats));
                            }
                        }
                    }
                }
            }
        }
    } catch (IllegalArgumentException e) {
    // ignore it, already restered
    }
    Resource subsystemResource;
    if (!deploymentResource.hasChild(SUBSYSTEM_PATH_ELEMENT)) {
        subsystemResource = new IronJacamarResource.IronJacamarRuntimeResource();
        deploymentResource.registerChild(SUBSYSTEM_PATH_ELEMENT, subsystemResource);
    } else {
        subsystemResource = deploymentResource.getChild(SUBSYSTEM_PATH_ELEMENT);
    }
    IronJacamarResourceCreator.INSTANCE.execute(subsystemResource, mdr.getValue(), deployment.getValue().getRaName());
}
Also used : Locale(java.util.Locale) Connector(org.jboss.jca.core.api.management.Connector) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) IronJacamarResource(org.jboss.as.connector.subsystems.resourceadapters.IronJacamarResource) OverrideDescriptionProvider(org.jboss.as.controller.descriptions.OverrideDescriptionProvider) StandardResourceDescriptionResolver(org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) PoolMetrics(org.jboss.as.connector.subsystems.common.pool.PoolMetrics) ConnectionFactory(org.jboss.jca.core.api.management.ConnectionFactory) ManagedConnectionFactory(org.jboss.jca.core.api.management.ManagedConnectionFactory) ConnectionManager(org.jboss.jca.core.connectionmanager.ConnectionManager) PathElement(org.jboss.as.controller.PathElement) ClearStatisticsHandler(org.jboss.as.connector.dynamicresource.ClearStatisticsHandler) AdminObject(org.jboss.jca.core.api.management.AdminObject) StatisticsResourceDefinition(org.jboss.as.connector.dynamicresource.StatisticsResourceDefinition) ResourceBuilder(org.jboss.as.controller.ResourceBuilder) StatisticsPlugin(org.jboss.jca.core.spi.statistics.StatisticsPlugin) Resource(org.jboss.as.controller.registry.Resource) IronJacamarResource(org.jboss.as.connector.subsystems.resourceadapters.IronJacamarResource) CommonDeployment(org.jboss.jca.deployers.common.CommonDeployment) ManagedConnectionFactory(org.jboss.jca.core.api.management.ManagedConnectionFactory) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 2 with StatisticsResourceDefinition

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

the class ConnectionDefinitionStatisticsService method start.

@Override
public void start(StartContext context) throws StartException {
    ROOT_LOGGER.debugf("Starting ConnectionDefinitionStatisticsService %s", jndiName);
    synchronized (this) {
        final CommonDeployment deploymentMD = deployment.getValue().getDeployment();
        PathElement pePoolStats = PathElement.pathElement(Constants.STATISTICS_NAME, "pool");
        PathElement peExtendedStats = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
        if (deploymentMD.getConnector() != null && deploymentMD.getConnector().getConnectionFactories() != null) {
            for (ConnectionFactory cf : deploymentMD.getConnector().getConnectionFactories()) {
                if (cf.getManagedConnectionFactory() != null && cf.getManagedConnectionFactory().getStatistics() != null) {
                    StatisticsPlugin extendStats = cf.getManagedConnectionFactory().getStatistics();
                    extendStats.setEnabled(statsEnabled);
                    if (!extendStats.getNames().isEmpty() && overrideRegistration.getSubModel(PathAddress.pathAddress(peExtendedStats)) == null) {
                        overrideRegistration.registerSubModel(new StatisticsResourceDefinition(peExtendedStats, CommonAttributes.RESOURCE_NAME, extendStats));
                    }
                }
            }
        }
        if (deploymentMD.getConnectionManagers() != null) {
            for (ConnectionManager cm : deploymentMD.getConnectionManagers()) {
                if (cm.getPool() != null && cm.getJndiName() != null && cm.getJndiName().equals(jndiName)) {
                    StatisticsPlugin poolStats = cm.getPool().getStatistics();
                    poolStats.setEnabled(statsEnabled);
                    if (!poolStats.getNames().isEmpty() && overrideRegistration.getSubModel(PathAddress.pathAddress(pePoolStats)) == null) {
                        overrideRegistration.registerSubModel(new StatisticsResourceDefinition(pePoolStats, CommonAttributes.RESOURCE_NAME, poolStats));
                    }
                }
            }
        }
    }
}
Also used : CommonDeployment(org.jboss.jca.deployers.common.CommonDeployment) StatisticsResourceDefinition(org.jboss.as.connector.dynamicresource.StatisticsResourceDefinition) ConnectionFactory(org.jboss.jca.core.api.management.ConnectionFactory) ConnectionManager(org.jboss.jca.core.connectionmanager.ConnectionManager) PathElement(org.jboss.as.controller.PathElement) StatisticsPlugin(org.jboss.jca.core.spi.statistics.StatisticsPlugin)

Example 3 with StatisticsResourceDefinition

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

the class AdminObjectStatisticsService method start.

@Override
public void start(StartContext context) throws StartException {
    ROOT_LOGGER.debugf("Starting ResourceAdapterStatusicService");
    synchronized (this) {
        final CommonDeployment deploymentMD = deployment.getValue().getDeployment();
        PathElement peExtendedStats = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
        if (deploymentMD.getConnector() != null && deploymentMD.getConnector().getAdminObjects() != null) {
            for (AdminObject ao : deploymentMD.getConnector().getAdminObjects()) {
                if (ao.getStatistics() != null) {
                    StatisticsPlugin extendStats = ao.getStatistics();
                    extendStats.setEnabled(statsEnabled);
                    if (!extendStats.getNames().isEmpty() && overrideRegistration.getSubModel(PathAddress.pathAddress(peExtendedStats)) == null) {
                        overrideRegistration.registerSubModel(new StatisticsResourceDefinition(peExtendedStats, CommonAttributes.RESOURCE_NAME, extendStats));
                    }
                }
            }
        }
    }
}
Also used : CommonDeployment(org.jboss.jca.deployers.common.CommonDeployment) StatisticsResourceDefinition(org.jboss.as.connector.dynamicresource.StatisticsResourceDefinition) PathElement(org.jboss.as.controller.PathElement) StatisticsPlugin(org.jboss.jca.core.spi.statistics.StatisticsPlugin) AdminObject(org.jboss.jca.core.api.management.AdminObject)

Example 4 with StatisticsResourceDefinition

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

the class ResourceAdapterStatisticsService method start.

@Override
public void start(StartContext context) throws StartException {
    ROOT_LOGGER.debugf("Starting ResourceAdapterStatusicService");
    synchronized (this) {
        PathElement peExtendedStats = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
        final CommonDeployment deploymentMD = deployment.getValue().getDeployment();
        if (deploymentMD.getConnector() != null && deploymentMD.getConnector().getResourceAdapter() != null && deploymentMD.getConnector().getResourceAdapter().getStatistics() != null) {
            StatisticsPlugin raStats = deploymentMD.getConnector().getResourceAdapter().getStatistics();
            raStats.setEnabled(statsEnabled);
            overrideRegistration.registerSubModel(new StatisticsResourceDefinition(peExtendedStats, CommonAttributes.RESOURCE_NAME, raStats));
        }
    }
}
Also used : CommonDeployment(org.jboss.jca.deployers.common.CommonDeployment) StatisticsResourceDefinition(org.jboss.as.connector.dynamicresource.StatisticsResourceDefinition) PathElement(org.jboss.as.controller.PathElement) StatisticsPlugin(org.jboss.jca.core.spi.statistics.StatisticsPlugin)

Example 5 with StatisticsResourceDefinition

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

the class PooledConnectionFactoryStatisticsService method start.

@Override
public void start(StartContext context) throws StartException {
    ROOT_LOGGER.debugf("start PooledConnectionFactoryStatisticsService");
    synchronized (POOL_STATISTICS) {
        ResourceAdapterDeployment raDeployment = injectedRADeployment.getValue();
        CommonDeployment deployment = raDeployment.getDeployment();
        StatisticsPlugin poolStats = deployment.getConnectionManagers()[0].getPool().getStatistics();
        poolStats.setEnabled(statsEnabled);
        int poolStatsSize = poolStats.getNames().size();
        if (poolStatsSize > 0 && registration != null && 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 : ResourceAdapterDeployment(org.jboss.as.connector.metadata.deployment.ResourceAdapterDeployment) 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 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 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)1 PathAddress (org.jboss.as.controller.PathAddress)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 ModelNode (org.jboss.dmr.ModelNode)1