Search in sources :

Example 1 with DeploymentMetricProcessor

use of org.wildfly.extension.metrics.deployment.DeploymentMetricProcessor in project wildfly by wildfly.

the class MetricsSubsystemAdd method performBoottime.

@Override
protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    super.performBoottime(context, operation, model);
    List<String> exposedSubsystems = MetricsSubsystemDefinition.EXPOSED_SUBSYSTEMS.unwrap(context, model);
    boolean exposeAnySubsystem = exposedSubsystems.remove("*");
    String prefix = MetricsSubsystemDefinition.PREFIX.resolveModelAttribute(context, model).asStringOrNull();
    boolean securityEnabled = MetricsSubsystemDefinition.SECURITY_ENABLED.resolveModelAttribute(context, model).asBoolean();
    WildFlyMetricRegistryService.install(context);
    MetricsCollectorService.install(context);
    MetricsContextService.install(context, securityEnabled);
    // handles that instead.
    if (!context.getCapabilityServiceSupport().hasCapability(MetricsSubsystemDefinition.METRICS_SCAN_CAPABILITY)) {
        context.addStep(new AbstractDeploymentChainStep() {

            public void execute(DeploymentProcessorTarget processorTarget) {
                processorTarget.addDeploymentProcessor(SUBSYSTEM_NAME, INSTALL, POST_MODULE_METRICS, new DeploymentMetricProcessor(exposeAnySubsystem, exposedSubsystems, prefix));
            }
        }, RUNTIME);
        // delay the registration of the metrics in the VERIFY stage so that all resources
        // created during the RUNTIME phase will have been registered in the MRR.
        context.addStep(new OperationStepHandler() {

            @Override
            public void execute(OperationContext operationContext, ModelNode modelNode) {
                ServiceController<?> serviceController = context.getServiceRegistry(false).getService(WILDFLY_COLLECTOR);
                MetricCollector metricCollector = MetricCollector.class.cast(serviceController.getValue());
                ServiceController<?> wildflyRegistryController = context.getServiceRegistry(false).getService(METRICS_REGISTRY_RUNTIME_CAPABILITY.getCapabilityServiceName());
                WildFlyMetricRegistry metricRegistry = WildFlyMetricRegistry.class.cast(wildflyRegistryController.getValue());
                ImmutableManagementResourceRegistration rootResourceRegistration = context.getRootResourceRegistration();
                Resource rootResource = context.readResourceFromRoot(EMPTY_ADDRESS);
                MetricRegistration registration = new MetricRegistration(metricRegistry);
                metricCollector.collectResourceMetrics(rootResource, rootResourceRegistration, Function.identity(), exposeAnySubsystem, exposedSubsystems, prefix, registration);
            }
        }, VERIFY);
    }
    LOGGER.activatingSubsystem();
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) Resource(org.jboss.as.controller.registry.Resource) DeploymentMetricProcessor(org.wildfly.extension.metrics.deployment.DeploymentMetricProcessor) DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep) ServiceController(org.jboss.msc.service.ServiceController) ImmutableManagementResourceRegistration(org.jboss.as.controller.registry.ImmutableManagementResourceRegistration) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

OperationContext (org.jboss.as.controller.OperationContext)1 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)1 ImmutableManagementResourceRegistration (org.jboss.as.controller.registry.ImmutableManagementResourceRegistration)1 Resource (org.jboss.as.controller.registry.Resource)1 AbstractDeploymentChainStep (org.jboss.as.server.AbstractDeploymentChainStep)1 DeploymentProcessorTarget (org.jboss.as.server.DeploymentProcessorTarget)1 ModelNode (org.jboss.dmr.ModelNode)1 ServiceController (org.jboss.msc.service.ServiceController)1 DeploymentMetricProcessor (org.wildfly.extension.metrics.deployment.DeploymentMetricProcessor)1