Package org.jboss.as.protocol.mgmt

Examples of org.jboss.as.protocol.mgmt.ManagementChannelHandler


        return "domain-mgmt-handler-thread";
    }

    @Override
    public Channel.Key startReceiving(final Channel channel) {
        final ManagementChannelHandler handler = new ManagementChannelHandler(ManagementClientChannelStrategy.create(channel), getExecutor());
        // Assemble the request handlers for the domain channel
        handler.addHandlerFactory(new HostControllerRegistrationHandler(handler, getController(), domainController));
        handler.addHandlerFactory(new ModelControllerClientOperationHandler(getController(), handler));
        handler.addHandlerFactory(new MasterDomainControllerOperationHandlerImpl(domainController));
        final Channel.Key key = channel.addCloseHandler(new CloseHandler<Channel>() {
            @Override
            public void handleClose(Channel closed, IOException exception) {
                handler.shutdown();
                try {
                    handler.awaitCompletion(100, TimeUnit.MILLISECONDS);
                } catch (Exception e) {
                    ROOT_LOGGER.serviceShutdownIncomplete(e);
                } finally {
                    handler.shutdownNow();
                }
            }
        });
        channel.receiveMessage(handler.getReceiver());
        return key;
    }
View Full Code Here


    private RemoteProxyController setupProxyHandlers(final ModelController proxiedController) {
        try {
            channels.setupRemoting(new ManagementChannelInitialization() {
                @Override
                public HandleableCloseable.Key startReceiving(Channel channel) {
                    final ManagementChannelHandler support = new ManagementChannelHandler(channel, channels.getExecutorService());
                    support.addHandlerFactory(new TransactionalModelControllerOperationHandler(proxiedController, support));
                    channel.addCloseHandler(new CloseHandler<Channel>() {
                        @Override
                        public void handleClose(Channel closed, IOException exception) {
                            support.shutdownNow();
                        }
                    });
                    channel.receiveMessage(support.getReceiver());
                    return null;
                }
            });
            channels.startClientConnetion();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        final Channel clientChannel = channels.getClientChannel();
        final ManagementChannelHandler support = new ManagementChannelHandler(clientChannel, 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;
    }
View Full Code Here

    /** {@inheritDoc} */
    @Override
    public synchronized void start(StartContext context) throws StartException {
        final RemoteDomainConnection connection;
        final ManagementChannelHandler handler;
        try {

            // Include additional local host information when registering at the DC
            final ModelNode hostInfo = createLocalHostHostInfo(localHostInfo, productConfig);

View Full Code Here

     * @param channel the channel
     * @param executorService a executor
     * @return the created client
     */
    public static ModelControllerClient createReceiving(final Channel channel, final ExecutorService executorService) {
        final ManagementChannelHandler handler = new ManagementChannelHandler(channel, executorService);
        final ExistingChannelModelControllerClient client = new ExistingChannelModelControllerClient(handler);
        handler.addHandlerFactory(client);
        channel.addCloseHandler(new CloseHandler<Channel>() {
            @Override
            public void handleClose(Channel closed, IOException exception) {
                handler.shutdown();
                try {
                    handler.awaitCompletion(1, TimeUnit.SECONDS);
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                } finally {
                    handler.shutdownNow();
                }
            }
        });
        channel.receiveMessage(handler.getReceiver());
        return client;
    }
View Full Code Here

*/
public class ModelControllerClientOperationHandlerFactoryService extends AbstractModelControllerOperationHandlerFactoryService {

    @Override
    public HandleableCloseable.Key startReceiving(Channel channel) {
        final ManagementChannelHandler handler = new ManagementChannelHandler(ManagementClientChannelStrategy.create(channel),
                getExecutor());
        UserInfo userInfo = channel.getConnection().getUserInfo();
        if (userInfo instanceof SubjectUserInfo) {
            handler.addHandlerFactory(new ModelControllerClientOperationHandler(getController(), handler,
                    ((SubjectUserInfo) userInfo).getSubject()));
        } else {
            handler.addHandlerFactory(new ModelControllerClientOperationHandler(getController(), handler));
        }


        final HandleableCloseable.Key key = channel.addCloseHandler(new CloseHandler<Channel>() {
            @Override
            public void handleClose(Channel closed, IOException exception) {
                handler.shutdown();
                try {
                    handler.awaitCompletion(100, TimeUnit.MILLISECONDS);
                } catch (Exception e) {
                    ControllerLogger.ROOT_LOGGER.warnf(e , "service shutdown did not complete");
                } finally {
                    handler.shutdownNow();
                }
            }
        });
        channel.receiveMessage(handler.getReceiver());
        return key;
    }
View Full Code Here

*/
public class ModelControllerClientOperationHandlerFactoryService extends AbstractModelControllerOperationHandlerFactoryService {

    @Override
    public HandleableCloseable.Key startReceiving(Channel channel) {
        final ManagementChannelHandler handler = new ManagementChannelHandler(ManagementClientChannelStrategy.create(channel),
                getExecutor());
        UserInfo userInfo = channel.getConnection().getUserInfo();
        if (userInfo instanceof SubjectUserInfo) {
            handler.addHandlerFactory(new ModelControllerClientOperationHandler(getController(), handler,
                    ((SubjectUserInfo) userInfo).getSubject()));
        } else {
            handler.addHandlerFactory(new ModelControllerClientOperationHandler(getController(), handler));
        }


        final HandleableCloseable.Key key = channel.addCloseHandler(new CloseHandler<Channel>() {
            @Override
            public void handleClose(Channel closed, IOException exception) {
                handler.shutdown();
                boolean interrupted = false;
                try {
                    if (!handler.awaitCompletion(CHANNEL_SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS)) {
                        ControllerLogger.ROOT_LOGGER.gracefulManagementChannelHandlerShutdownTimedOut(CHANNEL_SHUTDOWN_TIMEOUT);
                    }
                } catch (InterruptedException e) {
                    interrupted = true;
                    ControllerLogger.ROOT_LOGGER.gracefulManagementChannelHandlerShutdownFailed(e);
                } catch (Exception e) {
                    ControllerLogger.ROOT_LOGGER.gracefulManagementChannelHandlerShutdownFailed(e);
                } finally {
                    handler.shutdownNow();
                    if (interrupted) {
                        Thread.currentThread().interrupt();
                    }
                }
            }
        });
        channel.receiveMessage(handler.getReceiver());
        return key;
    }
View Full Code Here

     * @param executorService the executor service
     * @return the controller client
     */
    protected DomainTestClient createClient(final ExecutorService executorService) {
        final ChannelStrategy strategy = new ChannelStrategy(executorService);
        final ManagementChannelHandler handler = strategy.handler;
        final DomainTestClient client = new DomainTestClient() {
            @Override
            Connection getConnection() {
                return connection;
            }

            @Override
            protected ManagementChannelAssociation getChannelAssociation() throws IOException {
                return handler;
            }

            @Override
            Channel getChannel() {
                return strategy.channel;
            }

            @Override
            public void close() throws IOException {
                strategy.close();
            }
        };
        handler.addHandlerFactory(client);
        return client;
    }
View Full Code Here

        volatile Channel channel;

        private final ManagementChannelHandler handler;
        ChannelStrategy(ExecutorService executorService) {
            this.handler = new ManagementChannelHandler(this, executorService);
        }
View Full Code Here

    /** {@inheritDoc} */
    @Override
    public synchronized void start(StartContext context) throws StartException {
        final RemoteDomainConnection connection;
        final ManagementChannelHandler handler;
        try {
            // Include additional local host information when registering at the DC
            final ModelNode hostInfo = createLocalHostHostInfo(localHostInfo, productConfig);
            final OptionMap options = OptionMap.EMPTY;

View Full Code Here

                final Runnable task = new Runnable() {
                    @Override
                    public void run() {
                        CONTROLLER_MANAGEMENT_LOGGER.serverRegistered(serverName, channel);
                        // Create the server mgmt handler
                        final ManagementChannelHandler handler = new ManagementChannelHandler(channel, executorService, new ServerHandlerFactory(serverName));
                        // Register the communication channel
                        inventory.serverCommunicationRegistered(serverName, handler);
                        // Send the response once the server is fully registered
                        safeWriteResponse(channel, header, null);
                        // Onto the next message
                        channel.receiveMessage(handler.getReceiver());
                    }
                };
                executorService.execute(task);
            // Handle the server reconnect request
            } else if(type == DomainServerProtocol.SERVER_RECONNECT_REQUEST) {
                expectHeader(input, DomainServerProtocol.PARAM_SERVER_NAME);
                final String serverName = input.readUTF();
                final Runnable task = new Runnable() {
                    @Override
                    public void run() {
                        CONTROLLER_MANAGEMENT_LOGGER.serverRegistered(serverName, channel);
                        // Create the server mgmt handler
                        final ManagementChannelHandler handler = new ManagementChannelHandler(channel, executorService, new ServerHandlerFactory(serverName));
                        // Check if the server is still in sync with the domain model
                        final byte param;
                        if(inventory.serverReconnected(serverName, handler)) {
                            param = DomainServerProtocol.PARAM_OK;
                        } else {
                            param = DomainServerProtocol.PARAM_RESTART_REQUIRED;
                        }
                        // Notify the server whether configuration is still in sync or it requires a reload
                        safeWriteResponse(channel, header, param);
                        // Onto the next message
                        channel.receiveMessage(handler.getReceiver());
                    }
                };
                executorService.execute(task);
            } else {
                safeWriteResponse(channel, header, MESSAGES.unrecognizedType(type));
View Full Code Here

TOP

Related Classes of org.jboss.as.protocol.mgmt.ManagementChannelHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.