Search in sources :

Example 1 with ModelControllerClientOperationHandler

use of org.jboss.as.controller.remote.ModelControllerClientOperationHandler 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 2 with ModelControllerClientOperationHandler

use of org.jboss.as.controller.remote.ModelControllerClientOperationHandler in project wildfly-core by wildfly.

the class MasterDomainControllerOperationHandlerService method startReceiving.

@Override
public ManagementChannelHandler startReceiving(final Channel channel) {
    DomainControllerLogger.ROOT_LOGGER.debugf("Starting receiving from a remote HostController on channel %s", channel);
    final ManagementChannelHandler handler = new ManagementChannelHandler(ManagementClientChannelStrategy.create(channel), getExecutor());
    handler.getAttachments().attach(ManagementChannelHandler.TEMP_DIR, tempDir);
    // Assemble the request handlers for the domain channel
    handler.addHandlerFactory(new HostControllerRegistrationHandler(handler, domainController, operationExecutor, getExecutor(), slaveHostRegistrations, domainHostExcludeRegistry));
    handler.addHandlerFactory(new ModelControllerClientOperationHandler(getController(), handler, getResponseAttachmentSupport(), getClientRequestExecutor()));
    handler.addHandlerFactory(new MasterDomainControllerOperationHandlerImpl(domainController, getExecutor()));
    handler.addHandlerFactory(pongRequestHandler);
    handler.addHandlerFactory(new DomainTransactionalProtocolOperationHandler(txOperationExecutor, handler, getResponseAttachmentSupport()));
    channel.receiveMessage(handler.getReceiver());
    return handler;
}
Also used : ModelControllerClientOperationHandler(org.jboss.as.controller.remote.ModelControllerClientOperationHandler) ManagementChannelHandler(org.jboss.as.protocol.mgmt.ManagementChannelHandler)

Aggregations

ModelControllerClientOperationHandler (org.jboss.as.controller.remote.ModelControllerClientOperationHandler)2 ManagementChannelHandler (org.jboss.as.protocol.mgmt.ManagementChannelHandler)2 IOException (java.io.IOException)1 PrivilegedAction (java.security.PrivilegedAction)1 BlockingQueue (java.util.concurrent.BlockingQueue)1 ExecutorService (java.util.concurrent.ExecutorService)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 ResponseAttachmentInputStreamSupport (org.jboss.as.controller.remote.ResponseAttachmentInputStreamSupport)1 ManagementClientChannelStrategy (org.jboss.as.protocol.mgmt.ManagementClientChannelStrategy)1 ManagementChannelInitialization (org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization)1 Channel (org.jboss.remoting3.Channel)1 JBossThreadFactory (org.jboss.threads.JBossThreadFactory)1