Search in sources :

Example 1 with ManagedExecutorHungTasksPeriodicTerminationService

use of org.jboss.as.ee.concurrent.service.ManagedExecutorHungTasksPeriodicTerminationService in project wildfly by wildfly.

the class EeSubsystemAdd method performBoottime.

protected void performBoottime(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException {
    ModelNode model = resource.getModel();
    final EEJndiViewExtension extension = new EEJndiViewExtension();
    context.getServiceTarget().addService(EEJndiViewExtension.SERVICE_NAME, extension).addDependency(JndiViewExtensionRegistry.SERVICE_NAME, JndiViewExtensionRegistry.class, extension.getRegistryInjector()).install();
    final boolean appclient = context.getProcessType() == ProcessType.APPLICATION_CLIENT;
    final ModelNode globalModules = GlobalModulesDefinition.INSTANCE.resolveModelAttribute(context, model);
    // see if the ear subdeployment isolation flag is set. By default, we don't isolate subdeployments, so that
    // they can see each other's classes.
    final boolean earSubDeploymentsIsolated = EeSubsystemRootResource.EAR_SUBDEPLOYMENTS_ISOLATED.resolveModelAttribute(context, model).asBoolean();
    final boolean specDescriptorPropertyReplacement = EeSubsystemRootResource.SPEC_DESCRIPTOR_PROPERTY_REPLACEMENT.resolveModelAttribute(context, model).asBoolean();
    final boolean jbossDescriptorPropertyReplacement = EeSubsystemRootResource.JBOSS_DESCRIPTOR_PROPERTY_REPLACEMENT.resolveModelAttribute(context, model).asBoolean();
    final boolean ejbAnnotationPropertyReplacement = EeSubsystemRootResource.ANNOTATION_PROPERTY_REPLACEMENT.resolveModelAttribute(context, model).asBoolean();
    moduleDependencyProcessor.setGlobalModules(GlobalModulesDefinition.createModuleList(context, globalModules));
    isolationProcessor.setEarSubDeploymentsIsolated(earSubDeploymentsIsolated);
    specDescriptorPropertyReplacementProcessor.setDescriptorPropertyReplacement(specDescriptorPropertyReplacement);
    jbossDescriptorPropertyReplacementProcessor.setDescriptorPropertyReplacement(jbossDescriptorPropertyReplacement);
    ejbAnnotationPropertyReplacementProcessor.setDescriptorPropertyReplacement(ejbAnnotationPropertyReplacement);
    CapabilityServiceSupport capabilitySupport = context.getCapabilityServiceSupport();
    final boolean elytronJacc = capabilitySupport.hasCapability(ELYTRON_JACC_CAPABILITY);
    final boolean legacyJacc = !elytronJacc && capabilitySupport.hasCapability(LEGACY_JACC_CAPABILITY);
    context.addStep(new AbstractDeploymentChainStep() {

        protected void execute(DeploymentProcessorTarget processorTarget) {
            ROOT_LOGGER.debug("Activating EE subsystem");
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EE_DEPLOYMENT_PROPERTIES, new DeploymentPropertiesProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EE_DEPLOYMENT_PROPERTY_RESOLVER, new DeploymentPropertyResolverProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EE_FUNCTIONAL_RESOLVERS, new FunctionalResolverProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EE_SYSTEM_PROPERTY_RESOLVER, new SystemPropertyResolverProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EE_PROPERTY_RESOLVER, new PropertyResolverProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_REGISTER_JBOSS_ALL_EE_APP, new JBossAllXmlParserRegisteringProcessor<JBossAppMetaData>(AppJBossAllParser.ROOT_ELEMENT, AppJBossAllParser.ATTACHMENT_KEY, new AppJBossAllParser()));
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EE_SPEC_DESC_PROPERTY_REPLACEMENT, specDescriptorPropertyReplacementProcessor);
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EE_JBOSS_DESC_PROPERTY_REPLACEMENT, jbossDescriptorPropertyReplacementProcessor);
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EE_EJB_ANNOTATION_PROPERTY_REPLACEMENT, ejbAnnotationPropertyReplacementProcessor);
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EAR_DEPLOYMENT_INIT, new EarInitializationProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EAR_APP_XML_PARSE, new EarMetaDataParsingProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_JBOSS_EJB_CLIENT_XML_PARSE, new EJBClientDescriptorParsingProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EJB_EAR_APPLICATION_NAME, new EarApplicationNameProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EAR, new EarStructureProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EJB_JAR_IN_EAR, new EjbJarDeploymentProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_APPLICATION_CLIENT_IN_EAR, new ApplicationClientDeploymentProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_MANAGED_BEAN_JAR_IN_EAR, new ManagedBeanSubDeploymentMarkingProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EAR_SUB_DEPLYOMENTS_ISOLATED, isolationProcessor);
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EE_MODULE_INIT, new EEModuleInitialProcessor(context.getProcessType() == ProcessType.APPLICATION_CLIENT));
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EE_RESOURCE_INJECTION_REGISTRY, new ResourceReferenceRegistrySetupProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_GLOBAL_MODULES, moduleDependencyProcessor);
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_GLOBAL_DIRECTORIES, directoryDependencyProcessor);
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EE_MODULE_NAME, new EEModuleNameProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EE_ANNOTATIONS, new EEAnnotationProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_LIFECYCLE_ANNOTATION, new LifecycleAnnotationParsingProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_AROUNDINVOKE_ANNOTATION, new AroundInvokeAnnotationParsingProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_DISTINCT_NAME, new EEDistinctNameProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EAR_MESSAGE_DESTINATIONS, new EarMessageDestinationProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_MANAGED_BEAN_ANNOTATION, new ManagedBeanAnnotationProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_DESCRIPTOR_LIFECYCLE_METHOD_RESOLUTION, new DescriptorEnvironmentLifecycleMethodProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_EE_PERMISSIONS, new EEDefaultPermissionsProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_MANAGED_BEAN, new JavaEEDependencyProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_EE_CLASS_DESCRIPTIONS, new ApplicationClassesAggregationProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EAR_DEPENDENCY, new EarDependencyProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_INITIALIZE_IN_ORDER, new InitializeInOrderProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_INJECTION_ANNOTATION, new ResourceInjectionAnnotationParsingProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_ENV_ENTRY, new ResourceReferenceProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_INTERCEPTOR_ANNOTATIONS, new InterceptorAnnotationProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_NAMING_CONTEXT, new ModuleContextProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_IN_APP_CLIENT, new InApplicationClientBindingProcessor(appclient));
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EE_INSTANCE_NAME, new InstanceNameBindingProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_APP_NAMING_CONTEXT, new ApplicationContextProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EE_CONCURRENT_CONTEXT, new EEConcurrentContextProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EE_STARTUP_COUNTDOWN, new EEStartupCountdownProcessor());
            if (legacyJacc || elytronJacc) {
                processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_JACC_POLICY, new JaccEarDeploymentProcessor(elytronJacc ? ELYTRON_JACC_CAPABILITY : LEGACY_JACC_CAPABILITY));
            }
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_RESOLVE_MESSAGE_DESTINATIONS, new MessageDestinationResolutionProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_COMPONENT_AGGREGATION, new ComponentAggregationProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_DEFAULT_BINDINGS_EE_CONCURRENCY, new EEConcurrentDefaultBindingProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_MODULE_JNDI_BINDINGS, new ModuleJndiBindingProcessor(appclient));
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_EE_MODULE_CONFIG, new EEModuleConfigurationProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_EE_COMPONENT, new ComponentInstallProcessor());
            processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.CLEANUP, Phase.CLEANUP_EE, new EECleanUpProcessor());
        }
    }, OperationContext.Stage.RUNTIME);
    context.getServiceTarget().addService(ReflectiveClassIntrospector.SERVICE_NAME, new ReflectiveClassIntrospector()).install();
    // installs the service which manages managed executor's hung task periodic termination
    new ManagedExecutorHungTasksPeriodicTerminationService().install(context);
}
Also used : EarMetaDataParsingProcessor(org.jboss.as.ee.structure.EarMetaDataParsingProcessor) ApplicationClientDeploymentProcessor(org.jboss.as.ee.structure.ApplicationClientDeploymentProcessor) DescriptorEnvironmentLifecycleMethodProcessor(org.jboss.as.ee.component.deployers.DescriptorEnvironmentLifecycleMethodProcessor) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) InterceptorAnnotationProcessor(org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor) LifecycleAnnotationParsingProcessor(org.jboss.as.ee.component.deployers.LifecycleAnnotationParsingProcessor) JndiViewExtensionRegistry(org.jboss.as.naming.management.JndiViewExtensionRegistry) EarInitializationProcessor(org.jboss.as.ee.structure.EarInitializationProcessor) ManagedExecutorHungTasksPeriodicTerminationService(org.jboss.as.ee.concurrent.service.ManagedExecutorHungTasksPeriodicTerminationService) EEModuleInitialProcessor(org.jboss.as.ee.component.deployers.EEModuleInitialProcessor) MessageDestinationResolutionProcessor(org.jboss.as.ee.component.deployers.MessageDestinationResolutionProcessor) JavaEEDependencyProcessor(org.jboss.as.ee.managedbean.processors.JavaEEDependencyProcessor) ResourceReferenceRegistrySetupProcessor(org.jboss.as.ee.component.deployers.ResourceReferenceRegistrySetupProcessor) ComponentInstallProcessor(org.jboss.as.ee.component.deployers.ComponentInstallProcessor) ResourceInjectionAnnotationParsingProcessor(org.jboss.as.ee.component.deployers.ResourceInjectionAnnotationParsingProcessor) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep) EEDefaultPermissionsProcessor(org.jboss.as.ee.component.deployers.EEDefaultPermissionsProcessor) ModelNode(org.jboss.dmr.ModelNode) InitializeInOrderProcessor(org.jboss.as.ee.structure.InitializeInOrderProcessor) ModuleContextProcessor(org.jboss.as.ee.naming.ModuleContextProcessor) EEAnnotationProcessor(org.jboss.as.ee.component.deployers.EEAnnotationProcessor) SystemPropertyResolverProcessor(org.jboss.as.ee.metadata.property.SystemPropertyResolverProcessor) EarApplicationNameProcessor(org.jboss.as.ee.component.deployers.EarApplicationNameProcessor) EEModuleNameProcessor(org.jboss.as.ee.component.deployers.EEModuleNameProcessor) EEModuleConfigurationProcessor(org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor) InstanceNameBindingProcessor(org.jboss.as.ee.naming.InstanceNameBindingProcessor) FunctionalResolverProcessor(org.jboss.as.ee.metadata.property.FunctionalResolverProcessor) ModuleJndiBindingProcessor(org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor) JaccEarDeploymentProcessor(org.jboss.as.ee.security.JaccEarDeploymentProcessor) ApplicationContextProcessor(org.jboss.as.ee.naming.ApplicationContextProcessor) ComponentAggregationProcessor(org.jboss.as.ee.structure.ComponentAggregationProcessor) EjbJarDeploymentProcessor(org.jboss.as.ee.structure.EjbJarDeploymentProcessor) EJBClientDescriptorParsingProcessor(org.jboss.as.ee.structure.EJBClientDescriptorParsingProcessor) EEDistinctNameProcessor(org.jboss.as.ee.component.deployers.EEDistinctNameProcessor) ApplicationClassesAggregationProcessor(org.jboss.as.ee.component.deployers.ApplicationClassesAggregationProcessor) DeploymentPropertiesProcessor(org.jboss.as.ee.metadata.property.DeploymentPropertiesProcessor) JBossAllXmlParserRegisteringProcessor(org.jboss.as.server.deployment.jbossallxml.JBossAllXmlParserRegisteringProcessor) ManagedBeanSubDeploymentMarkingProcessor(org.jboss.as.ee.managedbean.processors.ManagedBeanSubDeploymentMarkingProcessor) EarMessageDestinationProcessor(org.jboss.as.ee.component.deployers.EarMessageDestinationProcessor) ReflectiveClassIntrospector(org.jboss.as.ee.component.ReflectiveClassIntrospector) ResourceReferenceProcessor(org.jboss.as.ee.component.deployers.ResourceReferenceProcessor) EEConcurrentDefaultBindingProcessor(org.jboss.as.ee.concurrent.deployers.EEConcurrentDefaultBindingProcessor) SystemPropertyResolverProcessor(org.jboss.as.ee.metadata.property.SystemPropertyResolverProcessor) PropertyResolverProcessor(org.jboss.as.ee.metadata.property.PropertyResolverProcessor) DeploymentPropertyResolverProcessor(org.jboss.as.ee.metadata.property.DeploymentPropertyResolverProcessor) AppJBossAllParser(org.jboss.as.ee.structure.AppJBossAllParser) EarStructureProcessor(org.jboss.as.ee.structure.EarStructureProcessor) EEConcurrentContextProcessor(org.jboss.as.ee.concurrent.deployers.EEConcurrentContextProcessor) DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) EarDependencyProcessor(org.jboss.as.ee.structure.EarDependencyProcessor) EECleanUpProcessor(org.jboss.as.ee.component.deployers.EECleanUpProcessor) AroundInvokeAnnotationParsingProcessor(org.jboss.as.ee.component.deployers.AroundInvokeAnnotationParsingProcessor) ManagedBeanAnnotationProcessor(org.jboss.as.ee.managedbean.processors.ManagedBeanAnnotationProcessor) DeploymentPropertyResolverProcessor(org.jboss.as.ee.metadata.property.DeploymentPropertyResolverProcessor) InApplicationClientBindingProcessor(org.jboss.as.ee.naming.InApplicationClientBindingProcessor)

Example 2 with ManagedExecutorHungTasksPeriodicTerminationService

use of org.jboss.as.ee.concurrent.service.ManagedExecutorHungTasksPeriodicTerminationService in project wildfly by wildfly.

the class ManagedScheduledExecutorServiceAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final String name = context.getCurrentAddressValue();
    final String jndiName = ManagedExecutorServiceResourceDefinition.JNDI_NAME_AD.resolveModelAttribute(context, model).asString();
    final long hungTaskTerminationPeriod = ManagedScheduledExecutorServiceResourceDefinition.HUNG_TASK_TERMINATION_PERIOD_AD.resolveModelAttribute(context, model).asLong();
    final long hungTaskThreshold = ManagedScheduledExecutorServiceResourceDefinition.HUNG_TASK_THRESHOLD_AD.resolveModelAttribute(context, model).asLong();
    final boolean longRunningTasks = ManagedScheduledExecutorServiceResourceDefinition.LONG_RUNNING_TASKS_AD.resolveModelAttribute(context, model).asBoolean();
    final int coreThreads;
    final ModelNode coreThreadsModel = ManagedScheduledExecutorServiceResourceDefinition.CORE_THREADS_AD.resolveModelAttribute(context, model);
    // value 0 means the same as undefined
    if (coreThreadsModel.isDefined() && coreThreadsModel.asInt() != 0) {
        coreThreads = coreThreadsModel.asInt();
    } else {
        coreThreads = (ProcessorInfo.availableProcessors() * 2);
    }
    final long keepAliveTime = ManagedScheduledExecutorServiceResourceDefinition.KEEPALIVE_TIME_AD.resolveModelAttribute(context, model).asLong();
    final TimeUnit keepAliveTimeUnit = TimeUnit.MILLISECONDS;
    final long threadLifeTime = 0L;
    final AbstractManagedExecutorService.RejectPolicy rejectPolicy = AbstractManagedExecutorService.RejectPolicy.valueOf(ManagedScheduledExecutorServiceResourceDefinition.REJECT_POLICY_AD.resolveModelAttribute(context, model).asString());
    final Integer threadPriority;
    if (model.hasDefined(ManagedScheduledExecutorServiceResourceDefinition.THREAD_PRIORITY) || !model.hasDefined(ManagedScheduledExecutorServiceResourceDefinition.THREAD_FACTORY)) {
        // defined, or use default value in case deprecated thread-factory also not defined
        threadPriority = ManagedScheduledExecutorServiceResourceDefinition.THREAD_PRIORITY_AD.resolveModelAttribute(context, model).asInt();
    } else {
        // not defined and deprecated thread-factory is defined, use it instead
        threadPriority = null;
    }
    final CapabilityServiceBuilder serviceBuilder = context.getCapabilityServiceTarget().addCapability(ManagedScheduledExecutorServiceResourceDefinition.CAPABILITY);
    final Supplier<ManagedExecutorHungTasksPeriodicTerminationService> hungTasksPeriodicTerminationService = serviceBuilder.requires(ConcurrentServiceNames.HUNG_TASK_PERIODIC_TERMINATION_SERVICE_NAME);
    final ManagedScheduledExecutorServiceService service = new ManagedScheduledExecutorServiceService(name, jndiName, hungTaskThreshold, hungTaskTerminationPeriod, longRunningTasks, coreThreads, keepAliveTime, keepAliveTimeUnit, threadLifeTime, rejectPolicy, threadPriority, hungTasksPeriodicTerminationService);
    serviceBuilder.setInstance(service);
    String contextService = null;
    if (model.hasDefined(ManagedScheduledExecutorServiceResourceDefinition.CONTEXT_SERVICE)) {
        contextService = ManagedScheduledExecutorServiceResourceDefinition.CONTEXT_SERVICE_AD.resolveModelAttribute(context, model).asString();
    }
    if (contextService != null) {
        serviceBuilder.addCapabilityRequirement(ContextServiceResourceDefinition.CAPABILITY.getName(), ContextServiceImpl.class, service.getContextServiceInjector(), contextService);
    }
    String threadFactory = null;
    if (model.hasDefined(ManagedScheduledExecutorServiceResourceDefinition.THREAD_FACTORY)) {
        threadFactory = ManagedScheduledExecutorServiceResourceDefinition.THREAD_FACTORY_AD.resolveModelAttribute(context, model).asString();
    }
    if (threadFactory != null) {
        serviceBuilder.addCapabilityRequirement(ManagedThreadFactoryResourceDefinition.CAPABILITY.getName(), ManagedThreadFactoryImpl.class, service.getManagedThreadFactoryInjector(), threadFactory);
    }
    if (context.hasOptionalCapability(REQUEST_CONTROLLER_CAPABILITY_NAME, null, null)) {
        serviceBuilder.addCapabilityRequirement(REQUEST_CONTROLLER_CAPABILITY_NAME, RequestController.class, service.getRequestController());
    }
    serviceBuilder.install();
}
Also used : AbstractManagedExecutorService(org.glassfish.enterprise.concurrent.AbstractManagedExecutorService) CapabilityServiceBuilder(org.jboss.as.controller.CapabilityServiceBuilder) TimeUnit(java.util.concurrent.TimeUnit) ModelNode(org.jboss.dmr.ModelNode) ManagedExecutorHungTasksPeriodicTerminationService(org.jboss.as.ee.concurrent.service.ManagedExecutorHungTasksPeriodicTerminationService) ManagedScheduledExecutorServiceService(org.jboss.as.ee.concurrent.service.ManagedScheduledExecutorServiceService)

Example 3 with ManagedExecutorHungTasksPeriodicTerminationService

use of org.jboss.as.ee.concurrent.service.ManagedExecutorHungTasksPeriodicTerminationService in project wildfly by wildfly.

the class ManagedExecutorServiceAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final String name = context.getCurrentAddressValue();
    final String jndiName = ManagedExecutorServiceResourceDefinition.JNDI_NAME_AD.resolveModelAttribute(context, model).asString();
    final long hungTaskTerminationPeriod = ManagedExecutorServiceResourceDefinition.HUNG_TASK_TERMINATION_PERIOD_AD.resolveModelAttribute(context, model).asLong();
    final long hungTaskThreshold = ManagedExecutorServiceResourceDefinition.HUNG_TASK_THRESHOLD_AD.resolveModelAttribute(context, model).asLong();
    final boolean longRunningTasks = ManagedExecutorServiceResourceDefinition.LONG_RUNNING_TASKS_AD.resolveModelAttribute(context, model).asBoolean();
    final int coreThreads;
    final ModelNode coreThreadsModel = ManagedExecutorServiceResourceDefinition.CORE_THREADS_AD.resolveModelAttribute(context, model);
    if (coreThreadsModel.isDefined()) {
        coreThreads = coreThreadsModel.asInt();
    } else {
        coreThreads = (ProcessorInfo.availableProcessors() * 2);
    }
    final int maxThreads;
    final ModelNode maxThreadsModel = ManagedExecutorServiceResourceDefinition.MAX_THREADS_AD.resolveModelAttribute(context, model);
    if (maxThreadsModel.isDefined()) {
        maxThreads = maxThreadsModel.asInt();
    } else {
        maxThreads = coreThreads;
    }
    // Note that this must be done in the runtime stage since the core-threads value may be calculated
    if (maxThreads < coreThreads) {
        throw EeLogger.ROOT_LOGGER.invalidMaxThreads(maxThreads, coreThreads);
    }
    final long keepAliveTime = ManagedExecutorServiceResourceDefinition.KEEPALIVE_TIME_AD.resolveModelAttribute(context, model).asLong();
    final TimeUnit keepAliveTimeUnit = TimeUnit.MILLISECONDS;
    final long threadLifeTime = 0L;
    final int queueLength;
    final ModelNode queueLengthModel = ManagedExecutorServiceResourceDefinition.QUEUE_LENGTH_AD.resolveModelAttribute(context, model);
    if (queueLengthModel.isDefined()) {
        queueLength = queueLengthModel.asInt();
    } else {
        queueLength = Integer.MAX_VALUE;
    }
    final AbstractManagedExecutorService.RejectPolicy rejectPolicy = AbstractManagedExecutorService.RejectPolicy.valueOf(ManagedExecutorServiceResourceDefinition.REJECT_POLICY_AD.resolveModelAttribute(context, model).asString());
    final Integer threadPriority;
    if (model.hasDefined(ManagedExecutorServiceResourceDefinition.THREAD_PRIORITY) || !model.hasDefined(ManagedExecutorServiceResourceDefinition.THREAD_FACTORY)) {
        // defined, or use default value in case deprecated thread-factory also not defined
        threadPriority = ManagedExecutorServiceResourceDefinition.THREAD_PRIORITY_AD.resolveModelAttribute(context, model).asInt();
    } else {
        // not defined and deprecated thread-factory is defined, use it instead
        threadPriority = null;
    }
    final CapabilityServiceBuilder serviceBuilder = context.getCapabilityServiceTarget().addCapability(ManagedExecutorServiceResourceDefinition.CAPABILITY);
    final Supplier<ManagedExecutorHungTasksPeriodicTerminationService> hungTasksPeriodicTerminationService = serviceBuilder.requires(ConcurrentServiceNames.HUNG_TASK_PERIODIC_TERMINATION_SERVICE_NAME);
    final ManagedExecutorServiceService service = new ManagedExecutorServiceService(name, jndiName, hungTaskThreshold, hungTaskTerminationPeriod, longRunningTasks, coreThreads, maxThreads, keepAliveTime, keepAliveTimeUnit, threadLifeTime, queueLength, rejectPolicy, threadPriority, hungTasksPeriodicTerminationService);
    serviceBuilder.setInstance(service);
    String contextService = null;
    if (model.hasDefined(ManagedExecutorServiceResourceDefinition.CONTEXT_SERVICE)) {
        contextService = ManagedExecutorServiceResourceDefinition.CONTEXT_SERVICE_AD.resolveModelAttribute(context, model).asString();
    }
    if (contextService != null) {
        serviceBuilder.addCapabilityRequirement(ContextServiceResourceDefinition.CAPABILITY.getName(), ContextServiceImpl.class, service.getContextServiceInjector(), contextService);
    }
    String threadFactory = null;
    if (model.hasDefined(ManagedExecutorServiceResourceDefinition.THREAD_FACTORY)) {
        threadFactory = ManagedExecutorServiceResourceDefinition.THREAD_FACTORY_AD.resolveModelAttribute(context, model).asString();
    }
    if (threadFactory != null) {
        serviceBuilder.addCapabilityRequirement(ManagedThreadFactoryResourceDefinition.CAPABILITY.getName(), ManagedThreadFactoryImpl.class, service.getManagedThreadFactoryInjector(), threadFactory);
    }
    if (context.hasOptionalCapability(REQUEST_CONTROLLER_CAPABILITY_NAME, null, null)) {
        serviceBuilder.addCapabilityRequirement(REQUEST_CONTROLLER_CAPABILITY_NAME, RequestController.class, service.getRequestController());
    }
    serviceBuilder.install();
}
Also used : ManagedExecutorServiceService(org.jboss.as.ee.concurrent.service.ManagedExecutorServiceService) AbstractManagedExecutorService(org.glassfish.enterprise.concurrent.AbstractManagedExecutorService) CapabilityServiceBuilder(org.jboss.as.controller.CapabilityServiceBuilder) TimeUnit(java.util.concurrent.TimeUnit) ModelNode(org.jboss.dmr.ModelNode) ManagedExecutorHungTasksPeriodicTerminationService(org.jboss.as.ee.concurrent.service.ManagedExecutorHungTasksPeriodicTerminationService)

Aggregations

ManagedExecutorHungTasksPeriodicTerminationService (org.jboss.as.ee.concurrent.service.ManagedExecutorHungTasksPeriodicTerminationService)3 TimeUnit (java.util.concurrent.TimeUnit)2 AbstractManagedExecutorService (org.glassfish.enterprise.concurrent.AbstractManagedExecutorService)2 CapabilityServiceBuilder (org.jboss.as.controller.CapabilityServiceBuilder)2 ModelNode (org.jboss.dmr.ModelNode)2 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)1 ReflectiveClassIntrospector (org.jboss.as.ee.component.ReflectiveClassIntrospector)1 ApplicationClassesAggregationProcessor (org.jboss.as.ee.component.deployers.ApplicationClassesAggregationProcessor)1 AroundInvokeAnnotationParsingProcessor (org.jboss.as.ee.component.deployers.AroundInvokeAnnotationParsingProcessor)1 ComponentInstallProcessor (org.jboss.as.ee.component.deployers.ComponentInstallProcessor)1 DescriptorEnvironmentLifecycleMethodProcessor (org.jboss.as.ee.component.deployers.DescriptorEnvironmentLifecycleMethodProcessor)1 EEAnnotationProcessor (org.jboss.as.ee.component.deployers.EEAnnotationProcessor)1 EECleanUpProcessor (org.jboss.as.ee.component.deployers.EECleanUpProcessor)1 EEDefaultPermissionsProcessor (org.jboss.as.ee.component.deployers.EEDefaultPermissionsProcessor)1 EEDistinctNameProcessor (org.jboss.as.ee.component.deployers.EEDistinctNameProcessor)1 EEModuleConfigurationProcessor (org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor)1 EEModuleInitialProcessor (org.jboss.as.ee.component.deployers.EEModuleInitialProcessor)1 EEModuleNameProcessor (org.jboss.as.ee.component.deployers.EEModuleNameProcessor)1 EarApplicationNameProcessor (org.jboss.as.ee.component.deployers.EarApplicationNameProcessor)1 EarMessageDestinationProcessor (org.jboss.as.ee.component.deployers.EarMessageDestinationProcessor)1