Search in sources :

Example 41 with PathElement

use of org.jboss.as.controller.PathElement 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 42 with PathElement

use of org.jboss.as.controller.PathElement in project wildfly by wildfly.

the class WorkManagerStatisticsService method start.

@Override
public void start(StartContext context) throws StartException {
    synchronized (this) {
        WorkManager wm = workManager.getValue();
        wm.setStatisticsEnabled(statsEnabled);
        if (wm.getStatistics() != null) {
            PathElement peLocaldWm = PathElement.pathElement(Constants.STATISTICS_NAME, "local");
            ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peLocaldWm, new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));
            ManagementResourceRegistration wmSubRegistration = overrideRegistration.registerSubModel(resourceBuilder.build());
            OperationStepHandler metricHandler = new WorkManagerRuntimeAttributeReadHandler(wm, wm.getStatistics(), false);
            for (SimpleAttributeDefinition metric : Constants.WORKMANAGER_METRICS) {
                wmSubRegistration.registerMetric(metric, metricHandler);
            }
            OperationStepHandler readHandler = new WorkManagerRuntimeAttributeReadHandler(wm, wm.getStatistics(), false);
            OperationStepHandler writeHandler = new WorkManagerRuntimeAttributeWriteHandler(wm, false, Constants.WORKMANAGER_RW_ATTRIBUTES);
            for (SimpleAttributeDefinition attribute : Constants.WORKMANAGER_RW_ATTRIBUTES) {
                wmSubRegistration.registerReadWriteAttribute(attribute, readHandler, writeHandler);
            }
            wmSubRegistration.registerOperationHandler(ClearWorkManagerStatisticsHandler.DEFINITION, new ClearWorkManagerStatisticsHandler(wm));
        }
    }
}
Also used : ResourceBuilder(org.jboss.as.controller.ResourceBuilder) PathElement(org.jboss.as.controller.PathElement) WorkManagerRuntimeAttributeWriteHandler(org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeWriteHandler) WorkManager(org.jboss.jca.core.api.workmanager.WorkManager) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) StandardResourceDescriptionResolver(org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) WorkManagerRuntimeAttributeReadHandler(org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeReadHandler) ClearWorkManagerStatisticsHandler(org.jboss.as.connector.dynamicresource.ClearWorkManagerStatisticsHandler)

Example 43 with PathElement

use of org.jboss.as.controller.PathElement 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 44 with PathElement

use of org.jboss.as.controller.PathElement 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 45 with PathElement

use of org.jboss.as.controller.PathElement in project wildfly by wildfly.

the class DistributedWorkManagerStatisticsService method start.

@Override
public void start(StartContext context) throws StartException {
    synchronized (this) {
        DistributedWorkManager dwm = distributedWorkManager.getValue();
        dwm.setDistributedStatisticsEnabled(statsEnabled);
        if (dwm.getDistributedStatistics() != null) {
            PathElement peDistributedWm = PathElement.pathElement(Constants.STATISTICS_NAME, "distributed");
            ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peDistributedWm, new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));
            ManagementResourceRegistration dwmSubRegistration = overrideRegistration.registerSubModel(resourceBuilder.build());
            OperationStepHandler metricHandler = new WorkManagerRuntimeAttributeReadHandler(dwm, dwm.getDistributedStatistics(), false);
            for (SimpleAttributeDefinition metric : Constants.WORKMANAGER_METRICS) {
                dwmSubRegistration.registerMetric(metric, metricHandler);
            }
            OperationStepHandler readHandler = new WorkManagerRuntimeAttributeReadHandler(dwm, dwm.getDistributedStatistics(), false);
            OperationStepHandler writeHandler = new WorkManagerRuntimeAttributeWriteHandler(dwm, false, Constants.DISTRIBUTED_WORKMANAGER_RW_ATTRIBUTES);
            for (SimpleAttributeDefinition attribute : Constants.DISTRIBUTED_WORKMANAGER_RW_ATTRIBUTES) {
                dwmSubRegistration.registerReadWriteAttribute(attribute, readHandler, writeHandler);
            }
            dwmSubRegistration.registerOperationHandler(ClearWorkManagerStatisticsHandler.DEFINITION, new ClearWorkManagerStatisticsHandler(dwm));
        }
    }
}
Also used : ResourceBuilder(org.jboss.as.controller.ResourceBuilder) DistributedWorkManager(org.jboss.jca.core.api.workmanager.DistributedWorkManager) PathElement(org.jboss.as.controller.PathElement) WorkManagerRuntimeAttributeWriteHandler(org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeWriteHandler) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) StandardResourceDescriptionResolver(org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) WorkManagerRuntimeAttributeReadHandler(org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeReadHandler) ClearWorkManagerStatisticsHandler(org.jboss.as.connector.dynamicresource.ClearWorkManagerStatisticsHandler)

Aggregations

PathElement (org.jboss.as.controller.PathElement)84 PathAddress (org.jboss.as.controller.PathAddress)47 ModelNode (org.jboss.dmr.ModelNode)46 Resource (org.jboss.as.controller.registry.Resource)24 OperationFailedException (org.jboss.as.controller.OperationFailedException)12 ServiceName (org.jboss.msc.service.ServiceName)12 Test (org.junit.Test)10 Map (java.util.Map)9 ArrayList (java.util.ArrayList)8 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)8 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)7 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)7 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)7 DeploymentResourceSupport (org.jboss.as.server.deployment.DeploymentResourceSupport)7 AbstractSubsystemBaseTest (org.jboss.as.subsystem.test.AbstractSubsystemBaseTest)7 ServiceTarget (org.jboss.msc.service.ServiceTarget)6 StatisticsResourceDefinition (org.jboss.as.connector.dynamicresource.StatisticsResourceDefinition)4 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)4 OperationContext (org.jboss.as.controller.OperationContext)4 StandardResourceDescriptionResolver (org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver)4