Search in sources :

Example 1 with WorkManagerRuntimeAttributeReadHandler

use of org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeReadHandler 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)

Example 2 with WorkManagerRuntimeAttributeReadHandler

use of org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeReadHandler 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)

Aggregations

ClearWorkManagerStatisticsHandler (org.jboss.as.connector.dynamicresource.ClearWorkManagerStatisticsHandler)2 WorkManagerRuntimeAttributeReadHandler (org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeReadHandler)2 WorkManagerRuntimeAttributeWriteHandler (org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeWriteHandler)2 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)2 PathElement (org.jboss.as.controller.PathElement)2 ResourceBuilder (org.jboss.as.controller.ResourceBuilder)2 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)2 StandardResourceDescriptionResolver (org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver)2 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)2 DistributedWorkManager (org.jboss.jca.core.api.workmanager.DistributedWorkManager)1 WorkManager (org.jboss.jca.core.api.workmanager.WorkManager)1