Refine search
@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; }
public File getFile(final String relativePath, final byte repoId, final File localDeploymentFolder) { try { return channelHandler.executeRequest(new GetFileRequest(relativePath, localDeploymentFolder), null).getResult().get(); } catch (Exception e) { throw ServerLogger.ROOT_LOGGER.failedToGetFileFromRemoteRepository(e); } } }
@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(); } } });
@Override public void handleClose(final Channel old, final IOException e) { synchronized (ChannelStrategy.this) { if(ChannelStrategy.this.channel == old) { ChannelStrategy.this.handler.handleClose(old, e); ChannelStrategy.this.channel = null; } } handler.handleChannelClosed(old, e); } });
@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(); } }
@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(); } }
AsyncFuture<Long> future = null; try { if (interval < 1 || System.currentTimeMillis() - channelHandler.getLastMessageReceivedTime() > interval) { future = channelHandler.executeRequest(ManagementPingRequest.INSTANCE, null).getResult(); Long id = future.get(timeout, TimeUnit.MILLISECONDS); if (!cancelled && remoteConnectionID != null && !remoteConnectionID.equals(id)) { HostControllerLogger.DOMAIN_LOGGER.slaveHostControllerChanged(hostName); Channel channel = null; try { channel = channelHandler.getChannel(); } catch (IOException e) {
/** * Send the started notification */ synchronized void started() { try { if(isConnected()) { channelHandler.executeRequest(new ServerStartedRequest(), null).getResult().await(); } } catch (Exception e) { ServerLogger.AS_ROOT_LOGGER.debugf(e, "failed to send started notification"); } }
@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; }
ChannelStrategy(ExecutorService executorService) { this.handler = new ManagementChannelHandler(this, executorService); }
/** * Create a transactional protocol client. * * @param channelAssociation the channel handler * @return the transactional protocol client */ public static TransactionalProtocolClient createClient(final ManagementChannelHandler channelAssociation) { final TransactionalProtocolClientImpl client = new TransactionalProtocolClientImpl(channelAssociation); channelAssociation.addHandlerFactory(client); return client; }
/** * Connect to the HC and retrieve the current model updates. * * @param controller the server controller * @param callback the operation completed callback * * @throws IOException for any error */ synchronized void openConnection(final ModelController controller, final ActiveOperation.CompletedCallback<ModelNode> callback) throws Exception { boolean ok = false; final Connection connection = connectionManager.connect(); try { channelHandler.executeRequest(new ServerRegisterRequest(), null, callback); // HC is the same version, so it will support sending the subject channelHandler.getAttachments().attach(TransactionalProtocolClient.SEND_IDENTITY, Boolean.TRUE); channelHandler.getAttachments().attach(TransactionalProtocolClient.SEND_IN_VM, Boolean.TRUE); channelHandler.addHandlerFactory(new TransactionalProtocolOperationHandler(controller, channelHandler, responseAttachmentSupport)); ok = true; } finally { if(!ok) { connection.close(); } } }
@Override public void handleClose(final Channel closed, final IOException exception) { if(CLIModelControllerClient.this.state.get() == CLOSED) { return; } if(CLIModelControllerClient.this.state.compareAndSet(CONNECTING, LOST_CONNECTION)) { return; } synchronized(lock) { if (strategy != null) { if(strategy != originalStrategy) { new Exception("Channel close handler " + strategy + " " + originalStrategy).printStackTrace(); } strategy = null; closeHandler.handleClose(); } channelAssociation.handleChannelClosed(closed, exception); lock.notifyAll(); } // Closing the strategy in this handler may result in race conditions // with connection closing and then deadlocks in remoting // it's safer to close the strategy from the connection close handler closed.getConnection().addCloseHandler(new CloseHandler<Connection>(){ @Override public void handleClose(Connection closed, IOException exception) { StreamUtils.safeClose(originalStrategy); }}); } }
@Override public void run() { try { channelHandler.executeRequest(request, null); } catch (Throwable t) { // not much we can do. Likely an OOME } } };
/** * Connect to the HC and retrieve the current model updates. * * @param controller the server controller * @param callback the operation completed callback * @return the boot operations * @throws IOException for any error */ synchronized void openConnection(final ModelController controller, final ActiveOperation.CompletedCallback<ModelNode> callback) throws Exception { boolean ok = false; final Connection connection = connectionManager.connect(); try { channelHandler.executeRequest(new ServerRegisterRequest(), null, callback); channelHandler.addHandlerFactory(new TransactionalProtocolOperationHandler(controller, channelHandler)); ok = true; } finally { if(!ok) { connection.close(); } } }
@Override public void handleClose(final Channel closed, final IOException exception) { channelAssociation.handleChannelClosed(closed, exception); } });
@Override public void close() throws IOException { handler.shutdown(); }
@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, SERVER_CHANNEL_TYPE, configuration.getOptionMap()); if(setChannel(channel)) { channel.receiveMessage(channelHandler.getReceiver()); channel.addCloseHandler(channelHandler); } else { channel.closeAsync(); } }
AsyncFuture<Long> future = null; try { if (interval < 1 || System.currentTimeMillis() - channelHandler.getLastMessageReceivedTime() > interval) { future = channelHandler.executeRequest(ManagementPingRequest.INSTANCE, null).getResult(); Long id = future.get(timeout, TimeUnit.MILLISECONDS); if (!cancelled && remoteConnectionID != null && !remoteConnectionID.equals(id)) { HostControllerLogger.DOMAIN_LOGGER.slaveHostControllerChanged(hostName); Channel channel = null; try { channel = channelHandler.getChannel(); } catch (IOException e) {