@Override public Channel getChannel() throws IOException { if(channel == null) { synchronized (this) { if(channel == null) { final Connection connection = connect(); channel = openChannel(connection); channel.receiveMessage(handler.getReceiver()); } } } return channel; }
@Override public Channel getChannel() throws IOException { if(channel == null) { synchronized (this) { if(channel == null) { final Connection connection = connect(); channel = openChannel(connection); channel.receiveMessage(handler.getReceiver()); } } } return channel; }
@Override public void connectionOpened(final Connection connection) throws IOException { final Channel channel = openChannel(connection, SERVER_CHANNEL_TYPE, configuration.getOptionMap()); if(setChannel(channel)) { channel.receiveMessage(channelHandler.getReceiver()); channel.addCloseHandler(channelHandler); } else { channel.closeAsync(); } }
@Override public void connectionOpened(final Connection connection) throws IOException { final Channel channel = openChannel(connection, SERVER_CHANNEL_TYPE, configuration.getOptionMap()); if(setChannel(channel)) { channel.receiveMessage(channelHandler.getReceiver()); channel.addCloseHandler(channelHandler); } else { channel.closeAsync(); } }
@Override public void connectionOpened(final Connection connection) throws IOException { final Channel channel = openChannel(connection, SERVER_CHANNEL_TYPE, configuration.getOptionMap()); if(setChannel(channel)) { channel.receiveMessage(channelHandler.getReceiver()); channel.addCloseHandler(channelHandler); } else { channel.closeAsync(); } }
@Override public void connectionOpened(final Connection connection) throws IOException { final Channel channel = openChannel(connection, SERVER_CHANNEL_TYPE, configuration.getOptionMap()); if(setChannel(channel)) { channel.receiveMessage(channelHandler.getReceiver()); channel.addCloseHandler(channelHandler); } else { channel.closeAsync(); } }
@Override public HandleableCloseable.Key startReceiving(final Channel channel) { final ManagementChannelHandler channelHandler = new ManagementChannelHandler(channel, executorService); final ServerToHostProtocolHandler registrationHandler = new ServerToHostProtocolHandler(serverInventory.getValue(), operationExecutor, domainController, channelHandler, registrations, expressionResolver); channelHandler.addHandlerFactory(new ManagementPongRequestHandler()); channelHandler.addHandlerFactory(registrationHandler); channel.receiveMessage(channelHandler.getReceiver()); return null; }
@Override public void connectionOpened(final Connection connection) throws IOException { final Channel channel = openChannel(connection, CHANNEL_SERVICE_TYPE, configuration.getOptionMap()); if(setChannel(channel)) { channel.receiveMessage(channelHandler.getReceiver()); channel.addCloseHandler(channelHandler); try { // Start the registration process channelHandler.executeRequest(new RegisterHostControllerRequest(), null).getResult().get(); } catch (Exception e) { if(e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new IOException(e); } // Registered registered(); } else { channel.closeAsync(); } }
/** * 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 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; }
@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; } }
/** * 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; }
@Override public void connectionOpened(final Connection connection) throws IOException { final Channel channel = openChannel(connection, CHANNEL_SERVICE_TYPE, configuration.getOptionMap()); if(setChannel(channel)) { channel.receiveMessage(channelHandler.getReceiver()); channel.addCloseHandler(channelHandler); try { if (runningMode == RunningMode.ADMIN_ONLY) { // Fetch the domain configuration channelHandler.executeRequest(new FetchDomainConfigurationRequest(), null).getResult().get(); } else { // Start the registration process channelHandler.executeRequest(new RegisterHostControllerRequest(), null).getResult().get(); } } catch (Exception e) { if(e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new IOException(e); } // Registered registered(); } else { channel.closeAsync(); } }
@Override public void connectionOpened(final Connection connection) throws IOException { final Channel channel = openChannel(connection, CHANNEL_SERVICE_TYPE, configuration.getOptionMap()); if(setChannel(channel)) { channel.receiveMessage(channelHandler.getReceiver()); channel.addCloseHandler(channelHandler); try { if (runningMode == RunningMode.ADMIN_ONLY) { // Fetch the domain configuration channelHandler.executeRequest(new FetchDomainConfigurationRequest(), null).getResult().get(); } else { // Start the registration process channelHandler.executeRequest(new RegisterHostControllerRequest(), null).getResult().get(); } } catch (Exception e) { if(e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new IOException(e); } // Registered registered(); } else { channel.closeAsync(); } }
@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; } }
@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; }
@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; }
@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; } }
channel.receiveMessage(handler.getReceiver()); return key;
@Override public ManagementChannelHandler startReceiving(final Channel 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; }
@Override public ManagementChannelHandler startReceiving(final Channel 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; }