public ManagementChannelHandler(final Channel channel, final ExecutorService executorService) { this(ManagementClientChannelStrategy.create(channel), executorService); }
/** {@inheritDoc} */ @Override public Channel getChannel() throws IOException { return strategy.getChannel(); }
/** * Create a new establishing management client channel-strategy * * @param baseConfig the base connection configuration * @param handler the {@code ManagementMessageHandler} * @param cbHandler a callback handler * @param saslOptions the sasl options * @param sslContext the ssl context * @param closeHandler a close handler * @return the management client channel strategy */ public static ManagementClientChannelStrategy create(final ProtocolConnectionConfiguration baseConfig, final ManagementMessageHandler handler, final CallbackHandler cbHandler, final Map<String, String> saslOptions, final SSLContext sslContext, final CloseHandler<Channel> closeHandler) { return create(createConfiguration(baseConfig, saslOptions, cbHandler, sslContext), ManagementChannelReceiver.createDelegating(handler), closeHandler); }
if (strategy == null) { final ChannelCloseHandler channelCloseHandler = new ChannelCloseHandler(); localStrategy = ManagementClientChannelStrategy.create(channelConfig, channelAssociation, handler, saslOptions, sslContext, channelCloseHandler); channelCloseHandler.setOriginalStrategy(localStrategy); ch = localStrategy.getChannel(); synchronized(lock) { strategy = localStrategy;
if (strategy == null) { final ChannelCloseHandler channelCloseHandler = new ChannelCloseHandler(); localStrategy = ManagementClientChannelStrategy.create(channelConfig, channelAssociation, handler, saslOptions, sslContext, channelCloseHandler); channelCloseHandler.setOriginalStrategy(localStrategy); ch = localStrategy.getChannel(); synchronized(lock) { strategy = localStrategy;
public ManagementChannelHandler(final Channel channel, final ExecutorService executorService, final ManagementRequestHandlerFactory... initial) { this(ManagementClientChannelStrategy.create(channel), executorService, initial); }
protected Channel getOrCreateChannel() throws IOException { synchronized (closeable) { if (closeable.closed) { throw ControllerClientLogger.ROOT_LOGGER.objectIsClosed(ModelControllerClient.class.getSimpleName()); } if (closeable.strategy == null) { try { closeable.endpoint = Endpoint.builder().setEndpointName("management-client").build(); final ProtocolConnectionConfiguration configuration = ProtocolConfigurationFactory.create(closeable.clientConfiguration, closeable.endpoint); closeable.strategy = ManagementClientChannelStrategy.create(configuration, closeable.channelAssociation, closeable.clientConfiguration.getCallbackHandler(), closeable.clientConfiguration.getSaslOptions(), closeable.clientConfiguration.getSSLContext(), new CloseHandler<Channel>() { @Override public void handleClose(final Channel closed, final IOException exception) { closeable.channelAssociation.handleChannelClosed(closed, exception); } }); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } } return closeable.strategy.getChannel(); } }
/** * Create a new establishing management client channel-strategy * * @param baseConfig the base connection configuration * @param handler the {@code ManagementMessageHandler} * @param cbHandler a callback handler * @param saslOptions the sasl options * @param sslContext the ssl context * @param closeHandler a close handler * @return the management client channel strategy */ public static ManagementClientChannelStrategy create(final ProtocolConnectionConfiguration baseConfig, final ManagementMessageHandler handler, final CallbackHandler cbHandler, final Map<String, String> saslOptions, final SSLContext sslContext, final CloseHandler<Channel> closeHandler) { return create(createConfiguration(baseConfig, saslOptions, cbHandler, sslContext), ManagementChannelReceiver.createDelegating(handler), closeHandler); }
/** {@inheritDoc} */ @Override public Channel getChannel() throws IOException { return strategy.getChannel(); }
@Override public ManagementChannelHandler startReceiving(Channel channel) { final ManagementChannelHandler handler = new ManagementChannelHandler(ManagementClientChannelStrategy.create(channel), getExecutor()); UserInfo userInfo = channel.getConnection().getUserInfo(); final Subject subject; if (userInfo instanceof SubjectUserInfo) { subject = ((SubjectUserInfo) userInfo).getSubject(); } else { subject = new Subject(); } handler.addHandlerFactory(new ModelControllerClientOperationHandler(getController(), handler, subject)); channel.receiveMessage(handler.getReceiver()); return handler; } }
strategy = ManagementClientChannelStrategy.create(setup, channelAssociation, clientConfiguration.getCallbackHandler(), clientConfiguration.getSaslOptions(), clientConfiguration.getSSLContext(), new CloseHandler<Channel>() { return strategy.getChannel();
/** * Create a new establishing management client channel-strategy * * @param setup the remoting setup * @param handler the {@code ManagementMessageHandler} * @param cbHandler a callback handler * @param saslOptions the sasl options * @param sslContext the ssl context * @param closeHandler a close handler * @return the management client channel strategy */ public static ManagementClientChannelStrategy create(final ProtocolChannelClient setup, final ManagementMessageHandler handler, final CallbackHandler cbHandler, final Map<String, String> saslOptions, final SSLContext sslContext, final CloseHandler<Channel> closeHandler) { return create(createConfiguration(setup.getConfiguration(), saslOptions, cbHandler, sslContext), ManagementChannelReceiver.createDelegating(handler), closeHandler); }
/** {@inheritDoc} */ @Override public Channel getChannel() throws IOException { return strategy.getChannel(); }
/** * Create a model controller client which is exclusively receiving messages on an existing channel. * * @param channel the channel * @param executorService an executor * @return the created client */ public static ModelControllerClient createReceiving(final Channel channel, final ExecutorService executorService) { final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel); final ManagementChannelHandler handler = new ManagementChannelHandler(strategy, 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; }
/** {@inheritDoc} */ @Override public <T, A> AsyncFuture<T> executeRequest(final ActiveOperation<T, A> support, final ManagementRequest<T, A> request) throws IOException { return super.executeRequest(request, strategy.getChannel(), support); }
@Override public ManagementChannelHandler startReceiving(final Channel channel) { final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel); final ManagementChannelHandler channelHandler = new ManagementChannelHandler(strategy, executorService); channelHandler.getAttachments().attach(ManagementChannelHandler.TEMP_DIR, tempDir); final ServerToHostProtocolHandler registrationHandler = new ServerToHostProtocolHandler(serverInventory.getValue(), operationExecutor, domainController, channelHandler, registrations, expressionResolver); channelHandler.addHandlerFactory(new ManagementPongRequestHandler()); channelHandler.addHandlerFactory(registrationHandler); channel.receiveMessage(channelHandler.getReceiver()); return channelHandler; }
/** {@inheritDoc} */ @Override public <T, A> AsyncFuture<T> executeRequest(final ActiveOperation<T, A> support, final ManagementRequest<T, A> request) throws IOException { return super.executeRequest(request, strategy.getChannel(), support); }
@Override public ManagementChannelHandler startReceiving(final Channel channel) { final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel); final ManagementChannelHandler channelHandler = new ManagementChannelHandler(strategy, executorService); channelHandler.getAttachments().attach(ManagementChannelHandler.TEMP_DIR, tempDir); final ServerToHostProtocolHandler registrationHandler = new ServerToHostProtocolHandler(serverInventory.getValue(), operationExecutor, domainController, channelHandler, registrations, expressionResolver); channelHandler.addHandlerFactory(new ManagementPongRequestHandler()); channelHandler.addHandlerFactory(registrationHandler); channel.receiveMessage(channelHandler.getReceiver()); return channelHandler; }
/** {@inheritDoc} */ @Override public <T, A> AsyncFuture<T> executeRequest(final ActiveOperation<T, A> support, final ManagementRequest<T, A> request) throws IOException { return super.executeRequest(request, strategy.getChannel(), support); }
@Override public ManagementChannelHandler startReceiving(Channel channel) { final ManagementChannelHandler handler = new ManagementChannelHandler(ManagementClientChannelStrategy.create(channel), getExecutor()); handler.addHandlerFactory(new ModelControllerClientOperationHandler(getController(), handler, getResponseAttachmentSupport(), getClientRequestExecutor(), channel.getConnection().getLocalIdentity())); channel.receiveMessage(handler.getReceiver()); return handler; } }