Java Code Examples for org.jboss.as.controller.ProcessType#DOMAIN_SERVER

The following examples show how to use org.jboss.as.controller.ProcessType#DOMAIN_SERVER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractLegacyExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void initialize(ExtensionContext context) {

    if (context.getProcessType() == ProcessType.DOMAIN_SERVER) {
        // Do nothing. This allows an extension=cmp:add op that's really targeted
        // to legacy servers to work
        ControllerLogger.MGMT_OP_LOGGER.ignoringUnsupportedLegacyExtension(subsystemNames, extensionName);
        return;
    } else if (context.getProcessType() == ProcessType.STANDALONE_SERVER) {
        if (context.getRunningMode() == RunningMode.ADMIN_ONLY) {
            //log a message, but fall through and register the model
            ControllerLogger.MGMT_OP_LOGGER.removeUnsupportedLegacyExtension(subsystemNames, extensionName);
        } else {
            throw new UnsupportedOperationException(ControllerLogger.ROOT_LOGGER.unsupportedLegacyExtension(extensionName));
        }
    }

    Set<ManagementResourceRegistration> subsystemRoots = initializeLegacyModel(context);
    for (ManagementResourceRegistration subsystemRoot : subsystemRoots) {
        subsystemRoot.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION,
            new UnsupportedSubsystemDescribeHandler(extensionName));
    }
}
 
Example 2
Source File: ReadOperationDescriptionHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {

    String operationName = NAME.resolveModelAttribute(context, operation).asString();
    boolean accessControl = ACCESS_CONTROL.resolveModelAttribute(context, operation).asBoolean();

    final DescribedOp describedOp = getDescribedOp(context, operationName, operation, !accessControl);
    if (describedOp == null || (context.getProcessType() == ProcessType.DOMAIN_SERVER &&
            !(describedOp.flags.contains(OperationEntry.Flag.RUNTIME_ONLY) || describedOp.flags.contains(OperationEntry.Flag.READ_ONLY)))) {
        throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.operationNotRegistered(operationName, context.getCurrentAddress()));
    } else {
        ModelNode result = describedOp.getDescription();

        if (accessControl) {
            final PathAddress address = context.getCurrentAddress();
            ModelNode operationToCheck = Util.createOperation(operationName, address);
            operationToCheck.get(OPERATION_HEADERS).set(operation.get(OPERATION_HEADERS));
            AuthorizationResult authorizationResult = context.authorizeOperation(operationToCheck);
            result.get(ACCESS_CONTROL.getName(), EXECUTE).set(authorizationResult.getDecision() == Decision.PERMIT);

        }

        context.getResult().set(result);
    }
}
 
Example 3
Source File: OpTypesExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void registerOperations(ManagementResourceRegistration resourceRegistration) {
    super.registerOperations(resourceRegistration);

    resourceRegistration.registerOperationHandler(PUBLIC, ((context, operation) -> context.getResult().set(true)));
    resourceRegistration.registerOperationHandler(HIDDEN, NoopOperationStepHandler.WITH_RESULT);
    resourceRegistration.registerOperationHandler(PRIVATE, NoopOperationStepHandler.WITH_RESULT);
    resourceRegistration.registerOperationHandler(RUNTIME_ONLY, RuntimeOnlyHandler.INSTANCE);
    resourceRegistration.registerOperationHandler(RUNTIME_READ_ONLY, RuntimeOnlyHandler.INSTANCE);

    if (processType == ProcessType.DOMAIN_SERVER) {
        resourceRegistration.registerOperationHandler(DOMAIN_HIDDEN, NoopOperationStepHandler.WITH_RESULT);
        resourceRegistration.registerOperationHandler(DOMAIN_SERVER_PRIVATE, NoopOperationStepHandler.WITH_RESULT);
        resourceRegistration.registerOperationHandler(DOMAIN_SERVER_RUNTIME_PRIVATE, RuntimeOnlyHandler.INSTANCE);
    } else if (!processType.isServer()) {
        resourceRegistration.registerOperationHandler(DOMAIN_PRIVATE, NoopOperationStepHandler.WITH_RESULT);
        resourceRegistration.registerOperationHandler(DOMAIN_RUNTIME_PRIVATE, RuntimeOnlyHandler.INSTANCE);
    }
}
 
Example 4
Source File: GlobalNotifications.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void registerGlobalNotifications(ManagementResourceRegistration root, ProcessType processType) {
    root.registerNotification(RESOURCE_ADDED, true);
    root.registerNotification(RESOURCE_REMOVED, true);

    if (processType != ProcessType.DOMAIN_SERVER) {
        root.registerNotification(ATTRIBUTE_VALUE_WRITTEN, true);
    }
}
 
Example 5
Source File: ChildFirstClassLoaderKernelServicesFactory.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static KernelServices create(String mainSubsystemName, String extensionClassName, AdditionalInitialization additionalInit, ModelTestOperationValidatorFilter validateOpsFilter,
        List<ModelNode> bootOperations, ModelVersion legacyModelVersion, boolean persistXml) throws Exception {
    Extension extension = (Extension) Class.forName(extensionClassName).newInstance();

    ExtensionRegistry extensionRegistry = new ExtensionRegistry(ProcessType.DOMAIN_SERVER, new RunningModeControl(RunningMode.ADMIN_ONLY));
    ModelTestParser testParser = new TestParser(mainSubsystemName, extensionRegistry);

    //TODO this should get serialized properly
    if (additionalInit == null) {
        additionalInit = AdditionalInitialization.MANAGEMENT;
    }
    return AbstractKernelServicesImpl.create(null, mainSubsystemName, additionalInit, validateOpsFilter,
            extensionRegistry, bootOperations, testParser, extension, legacyModelVersion, false, persistXml);
}
 
Example 6
Source File: AbstractGlobalOperationsTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void assertGlobalOperations(Set<String> ops) {
    assertTrue(ops.contains(READ_RESOURCE_OPERATION));
    assertTrue(ops.contains(READ_ATTRIBUTE_OPERATION));
    assertTrue(ops.contains(READ_ATTRIBUTE_GROUP_OPERATION));
    assertTrue(ops.contains(READ_ATTRIBUTE_GROUP_NAMES_OPERATION));
    assertTrue(ops.contains(READ_RESOURCE_DESCRIPTION_OPERATION));
    assertTrue(ops.contains(READ_CHILDREN_NAMES_OPERATION));
    assertTrue(ops.contains(READ_CHILDREN_TYPES_OPERATION));
    assertTrue(ops.contains(READ_CHILDREN_RESOURCES_OPERATION));
    assertTrue(ops.contains(READ_OPERATION_NAMES_OPERATION));
    assertTrue(ops.contains(READ_OPERATION_DESCRIPTION_OPERATION));
    assertTrue(ops.contains("list-get"));
    assertTrue(ops.contains("map-get"));
    if (processType == ProcessType.DOMAIN_SERVER) {
        assertFalse(ops.contains(WRITE_ATTRIBUTE_OPERATION));
        assertFalse(ops.contains("list-add"));
        assertFalse(ops.contains("list-remove"));
        assertFalse(ops.contains("list-clear"));
        assertFalse(ops.contains("map-put"));
        assertFalse(ops.contains("map-remove"));
        assertFalse(ops.contains("map-clear"));
    } else {
        assertTrue(ops.contains(WRITE_ATTRIBUTE_OPERATION));
        assertTrue(ops.contains("list-add"));
        assertTrue(ops.contains("list-remove"));
        assertTrue(ops.contains("list-clear"));
        assertTrue(ops.contains("map-put"));
        assertTrue(ops.contains("map-remove"));
        assertTrue(ops.contains("map-clear"));
    }
}
 
Example 7
Source File: BootCliHookTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test(expected = IllegalStateException.class)
public void testNotStandaloneOrEmbedded() throws Exception {
    super.processType = ProcessType.DOMAIN_SERVER;
    createCliScript("One\nTwo");
    WildFlySecurityManager.setPropertyPrivileged(AdditionalBootCliScriptInvoker.CLI_SCRIPT_PROPERTY, cliFile.getAbsolutePath());
    startController();
}
 
Example 8
Source File: ReadOperationNamesHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static boolean isVisible(OperationEntry operationEntry, OperationContext context) {
    Set<OperationEntry.Flag> flags = operationEntry.getFlags();
    return operationEntry.getType() == OperationEntry.EntryType.PUBLIC
            && !flags.contains(OperationEntry.Flag.HIDDEN)
            && (context.getProcessType() != ProcessType.DOMAIN_SERVER || flags.contains(OperationEntry.Flag.RUNTIME_ONLY)
            || flags.contains(OperationEntry.Flag.READ_ONLY));

}
 
Example 9
Source File: ExtensionRegistry.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void preCacheParserDescription(XMLElementReader<List<ModelNode>> reader) {
    if (ExtensionRegistry.this.processType != ProcessType.DOMAIN_SERVER
            && reader instanceof PersistentResourceXMLParser) {
        // In a standard WildFly boot this method is being called as part of concurrent
        // work on multiple extensions. Generating the PersistentResourceXMLDescription
        // used by PersistentResourceXMLParser involves a lot of classloading and static
        // field initialization that can benefit by being done as part of this concurrent
        // work instead of being deferred to the single-threaded parsing phase. So, we ask
        // the parser to generate and cache that description for later use during parsing.
        //noinspection deprecation
        ((PersistentResourceXMLParser) reader).cacheXMLDescription();
    }
}
 
Example 10
Source File: ExtensionRegistry.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void attemptCurrentParserInitialization() {
    if (ExtensionRegistry.this.processType != ProcessType.DOMAIN_SERVER
            && !hasNonSupplierParser && latestSupplier != null) {
        // We've only been passed suppliers for parsers, which means the model
        // initialization work commonly performed when a parser is constructed or
        // by a PersistentResourceXMLParser may not have been done. And we want
        // it done now, and not during parsing, as this may be called by a
        // parallel boot thread while parsing is single threaded.
        preCacheParserDescription(latestSupplier.get());
    }
}
 
Example 11
Source File: AbstractLegacyExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void initializeParsers(ExtensionParsingContext context) {

    if (context.getProcessType() == ProcessType.DOMAIN_SERVER) {
        // Do nothing. This allows the extension=cmp:add op that's really targeted
        // to legacy servers to work
        return;
    } else if (context.getProcessType() == ProcessType.STANDALONE_SERVER && context.getRunningMode() != RunningMode.ADMIN_ONLY) {
        throw new UnsupportedOperationException(ControllerLogger.ROOT_LOGGER.unsupportedLegacyExtension(extensionName));
    }

    initializeLegacyParsers(context);
}
 
Example 12
Source File: RemotingSubsystemAdd.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {

    // WFCORE-4510 -- the effective endpoint configuration is from the root subsystem resource,
    // not from the placeholder configuration=endpoint child resource.
    ModelNode endpointModel = resource.getModel();
    String workerName = WORKER.resolveModelAttribute(context, endpointModel).asString();

    final OptionMap map = EndpointConfigFactory.populate(context, endpointModel);

    // create endpoint
    final String nodeName = WildFlySecurityManager.getPropertyPrivileged(RemotingExtension.NODE_NAME_PROPERTY, null);

    // In case of a managed server the subsystem endpoint might already be installed {@see DomainServerCommunicationServices}
    if (context.getProcessType() == ProcessType.DOMAIN_SERVER) {
        final ServiceController<?> controller = context.getServiceRegistry(false).getService(RemotingServices.SUBSYSTEM_ENDPOINT);
        if (controller != null) {
            // if installed, just skip the rest
            return;
        }
    }

    final CapabilityServiceBuilder<?> builder = context.getCapabilityServiceTarget().addCapability(REMOTING_ENDPOINT_CAPABILITY);
    final Consumer<Endpoint> endpointConsumer = builder.provides(REMOTING_ENDPOINT_CAPABILITY);
    final Supplier<XnioWorker> workerSupplier = builder.requiresCapability(IO_WORKER_CAPABILITY_NAME, XnioWorker.class, workerName);
    builder.setInstance(new EndpointService(endpointConsumer, workerSupplier, nodeName, EndpointService.EndpointType.SUBSYSTEM, map));
    builder.install();
}
 
Example 13
Source File: JMXSubsystemAdd.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static void launchServices(OperationContext context, ModelNode model, ManagedAuditLogger auditLoggerInfo,
                           JmxAuthorizer authorizer, Supplier<SecurityIdentity> securityIdentitySupplier, RuntimeHostControllerInfoAccessor hostInfoAccessor) throws OperationFailedException {

    // Add the MBean service
    String resolvedDomain = getDomainName(context, model, CommonAttributes.RESOLVED);
    String expressionsDomain = getDomainName(context, model, CommonAttributes.EXPRESSION);
    boolean legacyWithProperPropertyFormat = false;
    if (model.hasDefined(CommonAttributes.PROPER_PROPERTY_FORMAT)) {
        legacyWithProperPropertyFormat = ExposeModelResourceExpression.DOMAIN_NAME.resolveModelAttribute(context, model).asBoolean();
    }
    boolean coreMBeanSensitivity = JMXSubsystemRootResource.CORE_MBEAN_SENSITIVITY.resolveModelAttribute(context, model).asBoolean();
    final boolean isMasterHc;
    if (context.getProcessType().isHostController()) {
        isMasterHc = hostInfoAccessor.getHostControllerInfo(context).isMasterHc();
    } else {
        isMasterHc = false;
    }
    JmxEffect jmxEffect = null;
    if (context.getProcessType() == ProcessType.DOMAIN_SERVER) {
        ModelNode rootModel = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getModel();
        String hostName = null;
        if(rootModel.hasDefined(HOST)) {
            hostName = rootModel.get(HOST).asString();
        }
        String serverGroup = null;
        if(rootModel.hasDefined(SERVER_GROUP)) {
            serverGroup = rootModel.get(SERVER_GROUP).asString();
        }
        jmxEffect = new JmxEffect(hostName, serverGroup);
    }
    MBeanServerService.addService(context, resolvedDomain, expressionsDomain, legacyWithProperPropertyFormat,
                        coreMBeanSensitivity, auditLoggerInfo, authorizer, securityIdentitySupplier, jmxEffect, context.getProcessType(), isMasterHc);
}
 
Example 14
Source File: OpTypesExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    boolean forMe = context.getProcessType() == ProcessType.DOMAIN_SERVER;
    if (!forMe) {
        String targetHost = TARGET_HOST.resolveModelAttribute(context, operation).asStringOrNull();
        if (targetHost != null) {
            Set<String> hosts = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getChildrenNames(HOST);
            String name = hosts.size() > 1 ? "master": hosts.iterator().next();
            forMe = targetHost.equals(name);
        }
    }
    if (forMe) {
        context.addStep((ctx, op) -> ctx.getResult().set(true), OperationContext.Stage.RUNTIME);
    }
}
 
Example 15
Source File: DomainServerGlobalOperationsTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public DomainServerGlobalOperationsTestCase() {
    super(ProcessType.DOMAIN_SERVER, AccessType.READ_ONLY);
}
 
Example 16
Source File: OperationTransformationTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public ProcessType getProcessType() {
    return ProcessType.DOMAIN_SERVER;
}
 
Example 17
Source File: ServerService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
     * Add this service to the given service target.
     *  @param serviceTarget the service target
     * @param configuration the bootstrap configuration
     */
    public static void addService(final ServiceTarget serviceTarget, final Bootstrap.Configuration configuration,
                                  final ControlledProcessState processState, final BootstrapListener bootstrapListener,
                                  final RunningModeControl runningModeControl, final AbstractVaultReader vaultReader, final ManagedAuditLogger auditLogger,
                                  final DelegatingConfigurableAuthorizer authorizer, final ManagementSecurityIdentitySupplier securityIdentitySupplier,
                                  final SuspendController suspendController) {

        // Install Executor services
        final ThreadGroup threadGroup = new ThreadGroup("ServerService ThreadGroup");
        final String namePattern = "ServerService Thread Pool -- %t";
        final ThreadFactory threadFactory = doPrivileged(new PrivilegedAction<ThreadFactory>() {
            public ThreadFactory run() {
                return new JBossThreadFactory(threadGroup, Boolean.FALSE, null, namePattern, null, null);
            }
        });

        // TODO determine why QueuelessThreadPoolService makes boot take > 35 secs
//        final QueuelessThreadPoolService serverExecutorService = new QueuelessThreadPoolService(Integer.MAX_VALUE, false, new TimeSpec(TimeUnit.SECONDS, 5));
//        serverExecutorService.getThreadFactoryInjector().inject(threadFactory);
        final boolean forDomain = ProcessType.DOMAIN_SERVER == getProcessType(configuration.getServerEnvironment());
        final ServerExecutorService serverExecutorService = new ServerExecutorService(threadFactory, forDomain);
        serviceTarget.addService(MANAGEMENT_EXECUTOR, serverExecutorService)
                .addAliases(Services.JBOSS_SERVER_EXECUTOR, ManagementRemotingServices.SHUTDOWN_EXECUTOR_NAME) // Use this executor for mgmt shutdown for now
                .install();
        final ServerScheduledExecutorService serverScheduledExecutorService = new ServerScheduledExecutorService(threadFactory);
        serviceTarget.addService(JBOSS_SERVER_SCHEDULED_EXECUTOR, serverScheduledExecutorService)
                .addAliases(JBOSS_SERVER_SCHEDULED_EXECUTOR)
                .addDependency(MANAGEMENT_EXECUTOR, ExecutorService.class, serverScheduledExecutorService.executorInjector)
                .install();

        final CapabilityRegistry capabilityRegistry = configuration.getCapabilityRegistry();

        ServiceBuilder<?> serviceBuilder = serviceTarget.addService(Services.JBOSS_SERVER_CONTROLLER);
        final boolean allowMCE = configuration.getServerEnvironment().isAllowModelControllerExecutor();
        final Supplier<ExecutorService> esSupplier = allowMCE ? serviceBuilder.requires(MANAGEMENT_EXECUTOR) : null;
        final boolean isDomainEnv = configuration.getServerEnvironment().getLaunchType() == ServerEnvironment.LaunchType.DOMAIN;
        final Supplier<ControllerInstabilityListener> cilSupplier = isDomainEnv ? serviceBuilder.requires(HostControllerConnectionService.SERVICE_NAME) : null;
        ServerService service = new ServerService(esSupplier, cilSupplier, configuration, processState, null, bootstrapListener, new ServerDelegatingResourceDefinition(),
                runningModeControl, vaultReader, auditLogger, authorizer, securityIdentitySupplier, capabilityRegistry, suspendController);
        serviceBuilder.setInstance(service);
        serviceBuilder.addDependency(DeploymentMountProvider.SERVICE_NAME,DeploymentMountProvider.class, service.injectedDeploymentRepository);
        serviceBuilder.addDependency(ContentRepository.SERVICE_NAME, ContentRepository.class, service.injectedContentRepository);
        serviceBuilder.addDependency(Services.JBOSS_SERVICE_MODULE_LOADER, ServiceModuleLoader.class, service.injectedModuleLoader);
        serviceBuilder.addDependency(EXTERNAL_MODULE_CAPABILITY.getCapabilityServiceName(), ExternalModule.class,
                service.injectedExternalModule);
        serviceBuilder.addDependency(PATH_MANAGER_CAPABILITY.getCapabilityServiceName(), PathManager.class, service.injectedPathManagerService);
        serviceBuilder.requires(CONSOLE_AVAILABILITY_CAPABILITY.getCapabilityServiceName());

        serviceBuilder.install();

        ExternalManagementRequestExecutor.install(serviceTarget, threadGroup, EXECUTOR_CAPABILITY.getCapabilityServiceName(), service.getStabilityMonitor());

    }