Search in sources :

Example 1 with ManagementChannelInitialization

use of org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization in project wildfly-core by wildfly.

the class ManagementRemotingServices method installManagementChannelOpenListenerService.

/**
 * Set up the services to create a channel listener. This assumes that an endpoint service called {@code endpointName} exists.
 *  @param serviceTarget the service target to install the services into
 * @param endpointName the name of the endpoint to install a channel listener into
 * @param channelName the name of the channel
 * @param operationHandlerName the name of the operation handler to handle request for this channel
 * @param options the remoting options
 * @param onDemand whether to install the services on demand
 */
public static void installManagementChannelOpenListenerService(final ServiceTarget serviceTarget, final ServiceName endpointName, final String channelName, final ServiceName operationHandlerName, final OptionMap options, final boolean onDemand) {
    final ServiceName serviceName = RemotingServices.channelServiceName(endpointName, channelName);
    final ServiceBuilder<?> builder = serviceTarget.addService(serviceName);
    final Supplier<ManagementChannelInitialization> ohfSupplier = builder.requires(operationHandlerName);
    final Supplier<ExecutorService> esSupplier = builder.requires(SHUTDOWN_EXECUTOR_NAME);
    final Supplier<Endpoint> eSupplier = builder.requires(endpointName);
    final Supplier<ManagementChannelRegistryService> rSupplier = builder.requires(ManagementChannelRegistryService.SERVICE_NAME);
    builder.setInstance(new ManagementChannelOpenListenerService(ohfSupplier, esSupplier, eSupplier, rSupplier, channelName, options));
    builder.setInitialMode(onDemand ? ON_DEMAND : ACTIVE);
    builder.install();
}
Also used : Endpoint(org.jboss.remoting3.Endpoint) ServiceName(org.jboss.msc.service.ServiceName) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService) ManagementChannelInitialization(org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization)

Example 2 with ManagementChannelInitialization

use of org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization in project wildfly-core by wildfly.

the class ModelControllerClientTestCase method setupTestClient.

private ModelControllerClient setupTestClient(final ModelController controller) throws IOException {
    try {
        channels.setupRemoting(new ManagementChannelInitialization() {

            @Override
            public ManagementChannelHandler startReceiving(Channel channel) {
                final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel);
                final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
                support.addHandlerFactory(new ModelControllerClientOperationHandler(controller, support, new ResponseAttachmentInputStreamSupport(), getClientRequestExecutor()));
                channel.receiveMessage(support.getReceiver());
                return support;
            }

            private ExecutorService getClientRequestExecutor() {
                final BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<Runnable>(512);
                final ThreadFactory threadFactory = doPrivileged(new PrivilegedAction<ThreadFactory>() {

                    public ThreadFactory run() {
                        return new JBossThreadFactory(new ThreadGroup("management-handler-thread"), Boolean.FALSE, null, "%G - %t", null, null);
                    }
                });
                ThreadPoolExecutor executor = new ThreadPoolExecutor(4, 4, 250L, TimeUnit.MILLISECONDS, workQueue, threadFactory);
                // Allow the core threads to time out as well
                executor.allowCoreThreadTimeOut(true);
                return executor;
            }
        });
        channels.startClientConnetion();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    final Channel clientChannel = channels.getClientChannel();
    return ExistingChannelModelControllerClient.createReceiving(clientChannel, channels.getExecutorService());
}
Also used : ManagementClientChannelStrategy(org.jboss.as.protocol.mgmt.ManagementClientChannelStrategy) ModelControllerClientOperationHandler(org.jboss.as.controller.remote.ModelControllerClientOperationHandler) BlockingQueue(java.util.concurrent.BlockingQueue) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) ManagementChannelHandler(org.jboss.as.protocol.mgmt.ManagementChannelHandler) ThreadFactory(java.util.concurrent.ThreadFactory) JBossThreadFactory(org.jboss.threads.JBossThreadFactory) JBossThreadFactory(org.jboss.threads.JBossThreadFactory) Channel(org.jboss.remoting3.Channel) ResponseAttachmentInputStreamSupport(org.jboss.as.controller.remote.ResponseAttachmentInputStreamSupport) ManagementChannelInitialization(org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization) IOException(java.io.IOException) PrivilegedAction(java.security.PrivilegedAction) ExecutorService(java.util.concurrent.ExecutorService) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 3 with ManagementChannelInitialization

use of org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization in project wildfly-core by wildfly.

the class RemoteProxyControllerProtocolTestCase method setupProxyHandlers.

private RemoteProxyController setupProxyHandlers(final ModelController proxiedController) {
    try {
        channels = new RemoteChannelPairSetup();
        channels.setupRemoting(new ManagementChannelInitialization() {

            @Override
            public ManagementChannelHandler startReceiving(Channel channel) {
                final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel);
                final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
                support.addHandlerFactory(new TransactionalProtocolOperationHandler(proxiedController, support, responseAttachmentSupport));
                channel.addCloseHandler(new CloseHandler<Channel>() {

                    @Override
                    public void handleClose(Channel closed, IOException exception) {
                        support.shutdownNow();
                    }
                });
                channel.receiveMessage(support.getReceiver());
                return support;
            }
        });
        channels.startClientConnetion();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    final Channel clientChannel = channels.getClientChannel();
    final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(clientChannel);
    final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
    final RemoteProxyController proxyController = RemoteProxyController.create(support, PathAddress.pathAddress(), ProxyOperationAddressTranslator.HOST);
    clientChannel.addCloseHandler(new CloseHandler<Channel>() {

        @Override
        public void handleClose(Channel closed, IOException exception) {
            support.shutdownNow();
        }
    });
    clientChannel.receiveMessage(support.getReceiver());
    return proxyController;
}
Also used : ManagementClientChannelStrategy(org.jboss.as.protocol.mgmt.ManagementClientChannelStrategy) ManagementChannelHandler(org.jboss.as.protocol.mgmt.ManagementChannelHandler) Channel(org.jboss.remoting3.Channel) ManagementChannelInitialization(org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization) IOException(java.io.IOException) IOException(java.io.IOException) RemoteChannelPairSetup(org.jboss.as.controller.support.RemoteChannelPairSetup) CloseHandler(org.jboss.remoting3.CloseHandler) RemoteProxyController(org.jboss.as.controller.remote.RemoteProxyController) TransactionalProtocolOperationHandler(org.jboss.as.controller.remote.TransactionalProtocolOperationHandler)

Example 4 with ManagementChannelInitialization

use of org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization in project wildfly-core by wildfly.

the class RemoteChannelProxyControllerTestCase method createProxyController.

@Override
protected ProxyController createProxyController(final ModelController proxiedController, final PathAddress proxyNodeAddress) {
    try {
        channels = new RemoteChannelPairSetup();
        channels.setupRemoting(new ManagementChannelInitialization() {

            @Override
            public ManagementChannelHandler startReceiving(Channel channel) {
                final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel);
                final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
                support.addHandlerFactory(new TransactionalProtocolOperationHandler(proxiedController, support, new ResponseAttachmentInputStreamSupport()));
                channel.addCloseHandler(new CloseHandler<Channel>() {

                    @Override
                    public void handleClose(Channel closed, IOException exception) {
                        support.shutdownNow();
                    }
                });
                channel.receiveMessage(support.getReceiver());
                return support;
            }
        });
        channels.startClientConnetion();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    final Channel clientChannel = channels.getClientChannel();
    final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(clientChannel);
    final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
    final RemoteProxyController proxyController = RemoteProxyController.create(support, proxyNodeAddress, ProxyOperationAddressTranslator.SERVER);
    clientChannel.addCloseHandler(new CloseHandler<Channel>() {

        @Override
        public void handleClose(Channel closed, IOException exception) {
            support.shutdownNow();
        }
    });
    clientChannel.receiveMessage(support.getReceiver());
    return proxyController;
}
Also used : ManagementClientChannelStrategy(org.jboss.as.protocol.mgmt.ManagementClientChannelStrategy) ManagementChannelHandler(org.jboss.as.protocol.mgmt.ManagementChannelHandler) Channel(org.jboss.remoting3.Channel) ResponseAttachmentInputStreamSupport(org.jboss.as.controller.remote.ResponseAttachmentInputStreamSupport) ManagementChannelInitialization(org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization) IOException(java.io.IOException) IOException(java.io.IOException) RemoteChannelPairSetup(org.jboss.as.controller.support.RemoteChannelPairSetup) CloseHandler(org.jboss.remoting3.CloseHandler) RemoteProxyController(org.jboss.as.controller.remote.RemoteProxyController) TransactionalProtocolOperationHandler(org.jboss.as.controller.remote.TransactionalProtocolOperationHandler)

Example 5 with ManagementChannelInitialization

use of org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization in project wildfly-core by wildfly.

the class ManagementChannelOpenListenerService method handleChannelOpened.

@Override
protected ManagementChannelShutdownHandle handleChannelOpened(final Channel channel) {
    final ManagementChannelInitialization initialization = operationHandlerFactorySupplier.get();
    RemotingLogger.ROOT_LOGGER.tracef("Opened %s: %s with handler %s", channelName, channel, initialization);
    return initialization.startReceiving(channel);
}
Also used : ManagementChannelInitialization(org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization)

Aggregations

ManagementChannelInitialization (org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization)5 IOException (java.io.IOException)3 ManagementChannelHandler (org.jboss.as.protocol.mgmt.ManagementChannelHandler)3 ManagementClientChannelStrategy (org.jboss.as.protocol.mgmt.ManagementClientChannelStrategy)3 Channel (org.jboss.remoting3.Channel)3 ExecutorService (java.util.concurrent.ExecutorService)2 RemoteProxyController (org.jboss.as.controller.remote.RemoteProxyController)2 ResponseAttachmentInputStreamSupport (org.jboss.as.controller.remote.ResponseAttachmentInputStreamSupport)2 TransactionalProtocolOperationHandler (org.jboss.as.controller.remote.TransactionalProtocolOperationHandler)2 RemoteChannelPairSetup (org.jboss.as.controller.support.RemoteChannelPairSetup)2 CloseHandler (org.jboss.remoting3.CloseHandler)2 PrivilegedAction (java.security.PrivilegedAction)1 BlockingQueue (java.util.concurrent.BlockingQueue)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 ModelControllerClientOperationHandler (org.jboss.as.controller.remote.ModelControllerClientOperationHandler)1 ServiceName (org.jboss.msc.service.ServiceName)1 Endpoint (org.jboss.remoting3.Endpoint)1