Search in sources :

Example 1 with ManagementChannelRegistryService

use of org.jboss.as.remoting.management.ManagementChannelRegistryService in project wildfly-core by wildfly.

the class HttpManagementAddHandler method installServices.

@Override
protected List<ServiceName> installServices(OperationContext context, HttpInterfaceCommonPolicy commonPolicy, ModelNode model) throws OperationFailedException {
    populateHostControllerInfo(hostControllerInfo, context, model);
    CapabilityServiceTarget serviceTarget = context.getCapabilityServiceTarget();
    boolean onDemand = context.isBooting();
    String interfaceName = hostControllerInfo.getHttpManagementInterface();
    int port = hostControllerInfo.getHttpManagementPort();
    String secureInterfaceName = hostControllerInfo.getHttpManagementSecureInterface();
    int securePort = hostControllerInfo.getHttpManagementSecurePort();
    ROOT_LOGGER.creatingHttpManagementService(interfaceName, port, securePort);
    boolean consoleEnabled = HttpManagementResourceDefinition.CONSOLE_ENABLED.resolveModelAttribute(context, model).asBoolean();
    ConsoleMode consoleMode = ConsoleMode.CONSOLE;
    if (consoleEnabled) {
        if (context.getRunningMode() == RunningMode.ADMIN_ONLY) {
            consoleMode = ConsoleMode.ADMIN_ONLY;
        } else if (!hostControllerInfo.isMasterDomainController()) {
            consoleMode = ConsoleMode.SLAVE_HC;
        }
    } else {
        consoleMode = ConsoleMode.NO_CONSOLE;
    }
    NativeManagementServices.installManagementWorkerService(serviceTarget, context.getServiceRegistry(false));
    // Track active requests
    final ServiceName requestProcessorName = UndertowHttpManagementService.SERVICE_NAME.append("requests");
    HttpManagementRequestsService.installService(requestProcessorName, serviceTarget);
    final String httpAuthenticationFactory = commonPolicy.getHttpAuthenticationFactory();
    final String sslContext = commonPolicy.getSSLContext();
    if (httpAuthenticationFactory == null) {
        ROOT_LOGGER.httpManagementInterfaceIsUnsecured();
    }
    final CapabilityServiceBuilder<?> builder = serviceTarget.addCapability(EXTENSIBLE_HTTP_MANAGEMENT_CAPABILITY);
    final Consumer<HttpManagement> hmConsumer = builder.provides(EXTENSIBLE_HTTP_MANAGEMENT_CAPABILITY);
    final Supplier<ListenerRegistry> lrSupplier = builder.requires(RemotingServices.HTTP_LISTENER_REGISTRY);
    final Supplier<ModelController> mcSupplier = builder.requires(DomainModelControllerService.SERVICE_NAME);
    final Supplier<NetworkInterfaceBinding> ibSupplier = builder.requiresCapability("org.wildfly.network.interface", NetworkInterfaceBinding.class, interfaceName);
    final Supplier<NetworkInterfaceBinding> sibSupplier = builder.requiresCapability("org.wildfly.network.interface", NetworkInterfaceBinding.class, secureInterfaceName);
    final Supplier<ProcessStateNotifier> cpsnSupplier = builder.requiresCapability("org.wildfly.management.process-state-notifier", ProcessStateNotifier.class);
    final Supplier<ConsoleAvailability> caSupplier = builder.requiresCapability("org.wildfly.management.console-availability", ConsoleAvailability.class);
    final Supplier<ManagementHttpRequestProcessor> rpSupplier = builder.requires(requestProcessorName);
    final Supplier<XnioWorker> xwSupplier = builder.requires(ManagementWorkerService.SERVICE_NAME);
    final Supplier<Executor> eSupplier = builder.requires(ExternalManagementRequestExecutor.SERVICE_NAME);
    final Supplier<HttpAuthenticationFactory> hafSupplier = httpAuthenticationFactory != null ? builder.requiresCapability(HTTP_AUTHENTICATION_FACTORY_CAPABILITY, HttpAuthenticationFactory.class, httpAuthenticationFactory) : null;
    final Supplier<SSLContext> scSupplier = sslContext != null ? builder.requiresCapability(SSL_CONTEXT_CAPABILITY, SSLContext.class, sslContext) : null;
    final UndertowHttpManagementService service = new UndertowHttpManagementService(hmConsumer, lrSupplier, mcSupplier, null, null, null, ibSupplier, sibSupplier, cpsnSupplier, rpSupplier, xwSupplier, eSupplier, hafSupplier, scSupplier, port, securePort, commonPolicy.getAllowedOrigins(), consoleMode, environment.getProductConfig().getConsoleSlot(), commonPolicy.getConstantHeaders(), caSupplier);
    builder.setInstance(service);
    builder.setInitialMode(onDemand ? ServiceController.Mode.ON_DEMAND : ServiceController.Mode.ACTIVE).install();
    // Add service preventing the server from shutting down
    final ServiceName shutdownName = UndertowHttpManagementService.SERVICE_NAME.append("shutdown");
    final ServiceBuilder<?> sb = serviceTarget.addService(shutdownName);
    final Supplier<Executor> executorSupplier = sb.requires(HostControllerService.HC_EXECUTOR_SERVICE_NAME);
    final Supplier<ManagementHttpRequestProcessor> processorSupplier = sb.requires(requestProcessorName);
    final Supplier<ManagementChannelRegistryService> registrySupplier = sb.requires(ManagementChannelRegistryService.SERVICE_NAME);
    sb.requires(UndertowHttpManagementService.SERVICE_NAME);
    sb.setInstance(new HttpShutdownService(executorSupplier, processorSupplier, registrySupplier));
    sb.install();
    if (commonPolicy.isHttpUpgradeEnabled()) {
        NativeManagementServices.installRemotingServicesIfNotInstalled(serviceTarget, hostControllerInfo.getLocalHostName(), context.getServiceRegistry(true), onDemand);
        final String httpConnectorName;
        if (port > -1 || securePort < 0) {
            httpConnectorName = ManagementRemotingServices.HTTP_CONNECTOR;
        } else {
            httpConnectorName = ManagementRemotingServices.HTTPS_CONNECTOR;
        }
        RemotingHttpUpgradeService.installServices(context, ManagementRemotingServices.HTTP_CONNECTOR, httpConnectorName, ManagementRemotingServices.MANAGEMENT_ENDPOINT, commonPolicy.getConnectorOptions(), commonPolicy.getSaslAuthenticationFactory());
        return Arrays.asList(UndertowHttpManagementService.SERVICE_NAME, HTTP_UPGRADE_REGISTRY.append(httpConnectorName));
    }
    return Collections.singletonList(UndertowHttpManagementService.SERVICE_NAME);
}
Also used : UndertowHttpManagementService(org.jboss.as.server.mgmt.UndertowHttpManagementService) XnioWorker(org.xnio.XnioWorker) HttpAuthenticationFactory(org.wildfly.security.auth.server.HttpAuthenticationFactory) NetworkInterfaceBinding(org.jboss.as.network.NetworkInterfaceBinding) ManagementHttpRequestProcessor(org.jboss.as.domain.http.server.ManagementHttpRequestProcessor) Executor(java.util.concurrent.Executor) ExternalManagementRequestExecutor(org.jboss.as.server.ExternalManagementRequestExecutor) ManagementChannelRegistryService(org.jboss.as.remoting.management.ManagementChannelRegistryService) CapabilityServiceTarget(org.jboss.as.controller.CapabilityServiceTarget) HttpManagement(org.jboss.as.server.mgmt.domain.HttpManagement) HttpShutdownService(org.jboss.as.server.mgmt.HttpShutdownService) ListenerRegistry(io.undertow.server.ListenerRegistry) SSLContext(javax.net.ssl.SSLContext) ProcessStateNotifier(org.jboss.as.controller.ProcessStateNotifier) ConsoleMode(org.jboss.as.domain.http.server.ConsoleMode) ConsoleAvailability(org.jboss.as.domain.http.server.ConsoleAvailability) ServiceName(org.jboss.msc.service.ServiceName) ModelController(org.jboss.as.controller.ModelController)

Example 2 with ManagementChannelRegistryService

use of org.jboss.as.remoting.management.ManagementChannelRegistryService in project wildfly-core by wildfly.

the class AbstractChannelOpenListenerService method start.

@Override
public synchronized void start(StartContext context) throws StartException {
    try {
        closed = false;
        RemotingLogger.ROOT_LOGGER.debugf("Registering channel listener for %s", channelName);
        final ManagementChannelRegistryService registry = this.registrySupplier.get();
        final Registration registration = endpointSupplier.get().registerService(channelName, this, optionMap);
        // Add to global registry
        registry.register(registration);
        trackerService = registry.getTrackerService();
    } catch (Exception e) {
        throw RemotingLogger.ROOT_LOGGER.couldNotStartChanelListener(e);
    }
}
Also used : ManagementChannelRegistryService(org.jboss.as.remoting.management.ManagementChannelRegistryService) Registration(org.jboss.remoting3.Registration) IOException(java.io.IOException) StartException(org.jboss.msc.service.StartException)

Example 3 with ManagementChannelRegistryService

use of org.jboss.as.remoting.management.ManagementChannelRegistryService in project wildfly-core by wildfly.

the class HttpManagementAddHandler method installServices.

@Override
protected List<ServiceName> installServices(OperationContext context, HttpInterfaceCommonPolicy commonPolicy, ModelNode model) throws OperationFailedException {
    final CapabilityServiceTarget serviceTarget = context.getCapabilityServiceTarget();
    // Socket-binding reference based config
    final String socketBindingName = SOCKET_BINDING.resolveModelAttribute(context, model).asStringOrNull();
    final String secureSocketBindingName = SECURE_SOCKET_BINDING.resolveModelAttribute(context, model).asStringOrNull();
    // Log the config
    if (socketBindingName != null) {
        if (secureSocketBindingName != null) {
            ServerLogger.ROOT_LOGGER.creatingHttpManagementServiceOnSocketAndSecureSocket(socketBindingName, secureSocketBindingName);
        } else {
            ServerLogger.ROOT_LOGGER.creatingHttpManagementServiceOnSocket(socketBindingName);
        }
    } else if (secureSocketBindingName != null) {
        ServerLogger.ROOT_LOGGER.creatingHttpManagementServiceOnSecureSocket(secureSocketBindingName);
    }
    ConsoleMode consoleMode = consoleMode(commonPolicy.isConsoleEnabled(), context.getRunningMode() == RunningMode.ADMIN_ONLY);
    // Track active requests
    final ServiceName requestProcessorName = UndertowHttpManagementService.SERVICE_NAME.append("requests");
    HttpManagementRequestsService.installService(requestProcessorName, serviceTarget);
    NativeManagementServices.installManagementWorkerService(serviceTarget, context.getServiceRegistry(false));
    final String httpAuthenticationFactory = commonPolicy.getHttpAuthenticationFactory();
    final String sslContext = commonPolicy.getSSLContext();
    if (httpAuthenticationFactory == null) {
        ServerLogger.ROOT_LOGGER.httpManagementInterfaceIsUnsecured();
    }
    ServerEnvironment environment = (ServerEnvironment) context.getServiceRegistry(false).getRequiredService(ServerEnvironmentService.SERVICE_NAME).getValue();
    final CapabilityServiceBuilder<?> builder = serviceTarget.addCapability(EXTENSIBLE_HTTP_MANAGEMENT_CAPABILITY);
    final Consumer<HttpManagement> hmConsumer = builder.provides(EXTENSIBLE_HTTP_MANAGEMENT_CAPABILITY);
    final Supplier<ListenerRegistry> lrSupplier = builder.requires(RemotingServices.HTTP_LISTENER_REGISTRY);
    final Supplier<ModelController> mcSupplier = builder.requires(Services.JBOSS_SERVER_CONTROLLER);
    final Supplier<SocketBinding> sbSupplier = socketBindingName != null ? builder.requiresCapability(SOCKET_BINDING_CAPABILITY_NAME, SocketBinding.class, socketBindingName) : null;
    final Supplier<SocketBinding> ssbSupplier = secureSocketBindingName != null ? builder.requiresCapability(SOCKET_BINDING_CAPABILITY_NAME, SocketBinding.class, secureSocketBindingName) : null;
    final Supplier<SocketBindingManager> sbmSupplier = builder.requiresCapability("org.wildfly.management.socket-binding-manager", SocketBindingManager.class);
    final Supplier<ProcessStateNotifier> cpsnSupplier = builder.requiresCapability("org.wildfly.management.process-state-notifier", ProcessStateNotifier.class);
    final Supplier<ConsoleAvailability> caSupplier = builder.requiresCapability("org.wildfly.management.console-availability", ConsoleAvailability.class);
    final Supplier<ManagementHttpRequestProcessor> rpSupplier = builder.requires(requestProcessorName);
    final Supplier<XnioWorker> xwSupplier = builder.requires(ManagementWorkerService.SERVICE_NAME);
    final Supplier<Executor> eSupplier = builder.requires(ExternalManagementRequestExecutor.SERVICE_NAME);
    final Supplier<HttpAuthenticationFactory> hafSupplier = httpAuthenticationFactory != null ? builder.requiresCapability(HTTP_AUTHENTICATION_FACTORY_CAPABILITY, HttpAuthenticationFactory.class, httpAuthenticationFactory) : null;
    final Supplier<SSLContext> scSupplier = sslContext != null ? builder.requiresCapability(SSL_CONTEXT_CAPABILITY, SSLContext.class, sslContext) : null;
    final UndertowHttpManagementService undertowService = new UndertowHttpManagementService(hmConsumer, lrSupplier, mcSupplier, sbSupplier, ssbSupplier, sbmSupplier, null, null, cpsnSupplier, rpSupplier, xwSupplier, eSupplier, hafSupplier, scSupplier, null, null, commonPolicy.getAllowedOrigins(), consoleMode, environment.getProductConfig().getConsoleSlot(), commonPolicy.getConstantHeaders(), caSupplier);
    builder.setInstance(undertowService);
    builder.install();
    // Add service preventing the server from shutting down
    final ServiceName shutdownName = UndertowHttpManagementService.SERVICE_NAME.append("shutdown");
    final ServiceBuilder<?> sb = serviceTarget.addService(shutdownName);
    final Supplier<Executor> executorSupplier = sb.requires(Services.JBOSS_SERVER_EXECUTOR);
    final Supplier<ManagementHttpRequestProcessor> processorSupplier = sb.requires(requestProcessorName);
    final Supplier<ManagementChannelRegistryService> registrySupplier = sb.requires(ManagementChannelRegistryService.SERVICE_NAME);
    sb.requires(UndertowHttpManagementService.SERVICE_NAME);
    sb.setInstance(new HttpShutdownService(executorSupplier, processorSupplier, registrySupplier));
    sb.install();
    if (commonPolicy.isHttpUpgradeEnabled()) {
        final String hostName = WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.NODE_NAME, null);
        NativeManagementServices.installRemotingServicesIfNotInstalled(serviceTarget, hostName, context.getServiceRegistry(false));
        final String httpConnectorName;
        if (socketBindingName != null || (secureSocketBindingName == null)) {
            httpConnectorName = ManagementRemotingServices.HTTP_CONNECTOR;
        } else {
            httpConnectorName = ManagementRemotingServices.HTTPS_CONNECTOR;
        }
        RemotingHttpUpgradeService.installServices(context, ManagementRemotingServices.HTTP_CONNECTOR, httpConnectorName, ManagementRemotingServices.MANAGEMENT_ENDPOINT, commonPolicy.getConnectorOptions(), commonPolicy.getSaslAuthenticationFactory());
        return Arrays.asList(UndertowHttpManagementService.SERVICE_NAME, HTTP_UPGRADE_REGISTRY.append(httpConnectorName));
    }
    return Collections.singletonList(UndertowHttpManagementService.SERVICE_NAME);
}
Also used : SocketBinding(org.jboss.as.network.SocketBinding) UndertowHttpManagementService(org.jboss.as.server.mgmt.UndertowHttpManagementService) XnioWorker(org.xnio.XnioWorker) HttpAuthenticationFactory(org.wildfly.security.auth.server.HttpAuthenticationFactory) ManagementHttpRequestProcessor(org.jboss.as.domain.http.server.ManagementHttpRequestProcessor) ExternalManagementRequestExecutor(org.jboss.as.server.ExternalManagementRequestExecutor) Executor(java.util.concurrent.Executor) ManagementChannelRegistryService(org.jboss.as.remoting.management.ManagementChannelRegistryService) ServerEnvironment(org.jboss.as.server.ServerEnvironment) CapabilityServiceTarget(org.jboss.as.controller.CapabilityServiceTarget) HttpManagement(org.jboss.as.server.mgmt.domain.HttpManagement) HttpShutdownService(org.jboss.as.server.mgmt.HttpShutdownService) ListenerRegistry(io.undertow.server.ListenerRegistry) SSLContext(javax.net.ssl.SSLContext) ProcessStateNotifier(org.jboss.as.controller.ProcessStateNotifier) ConsoleMode(org.jboss.as.domain.http.server.ConsoleMode) SocketBindingManager(org.jboss.as.network.SocketBindingManager) ConsoleAvailability(org.jboss.as.domain.http.server.ConsoleAvailability) ServiceName(org.jboss.msc.service.ServiceName) ModelController(org.jboss.as.controller.ModelController)

Aggregations

ManagementChannelRegistryService (org.jboss.as.remoting.management.ManagementChannelRegistryService)3 ListenerRegistry (io.undertow.server.ListenerRegistry)2 Executor (java.util.concurrent.Executor)2 SSLContext (javax.net.ssl.SSLContext)2 CapabilityServiceTarget (org.jboss.as.controller.CapabilityServiceTarget)2 ModelController (org.jboss.as.controller.ModelController)2 ProcessStateNotifier (org.jboss.as.controller.ProcessStateNotifier)2 ConsoleAvailability (org.jboss.as.domain.http.server.ConsoleAvailability)2 ConsoleMode (org.jboss.as.domain.http.server.ConsoleMode)2 ManagementHttpRequestProcessor (org.jboss.as.domain.http.server.ManagementHttpRequestProcessor)2 ExternalManagementRequestExecutor (org.jboss.as.server.ExternalManagementRequestExecutor)2 HttpShutdownService (org.jboss.as.server.mgmt.HttpShutdownService)2 UndertowHttpManagementService (org.jboss.as.server.mgmt.UndertowHttpManagementService)2 HttpManagement (org.jboss.as.server.mgmt.domain.HttpManagement)2 ServiceName (org.jboss.msc.service.ServiceName)2 HttpAuthenticationFactory (org.wildfly.security.auth.server.HttpAuthenticationFactory)2 XnioWorker (org.xnio.XnioWorker)2 IOException (java.io.IOException)1 NetworkInterfaceBinding (org.jboss.as.network.NetworkInterfaceBinding)1 SocketBinding (org.jboss.as.network.SocketBinding)1