/** {@inheritDoc} */ public ConnectionProvider createInstance(final ConnectionProviderContext context, final OptionMap optionMap, final String protocolName) throws IOException { return new RemoteConnectionProvider(optionMap, context, protocolName); } }
protected void closeAction() { try { final Cancellable[] cancellables; synchronized (pendingInboundConnections) { cancellables = pendingInboundConnections.toArray(new Cancellable[pendingInboundConnections.size()]); pendingInboundConnections.clear(); } for (Cancellable pendingConnection: cancellables) { pendingConnection.cancel(); } closeComplete(); } finally { if (server != null && objectName != null) { try { server.unregisterMBean(objectName); } catch (Throwable ignored) { } } } }
private String doGetConnectionState() { final StringBuilder b = new StringBuilder(); doGetConnectionState(b); return b.toString(); }
public Cancellable connect(final URI destination, final SocketAddress bindAddress, final OptionMap connectOptions, final Result<ConnectionHandlerFactory> result, final AuthenticationConfiguration authenticationConfiguration, final SSLContext sslContext, final UnaryOperator<SaslClientFactory> saslClientFactoryOperator, final Collection<String> serverMechs) { if (! isOpen()) { throw new IllegalStateException("Connection provider is closed"); final IoFuture<? extends StreamConnection> future; if (useSsl) { future = createSslConnection(destination, (InetSocketAddress) bindAddress, address, connectOptions, authenticationConfiguration, sslContext, openListener); } else { future = createConnection(destination, (InetSocketAddress) bindAddress, address, connectOptions, openListener);
/** * Make this method visible. */ protected void closeComplete() { super.closeComplete(); remoteConnection.getRemoteConnectionProvider().removeConnectionHandler(this); }
final RemoteConnectionHandler connectionHandler = new RemoteConnectionHandler( connectionContext, connection, maxInboundChannels, maxOutboundChannels, AnonymousPrincipal.getInstance(), remoteEndpointName, behavior, authCap, offeredMechanisms, peerName, serverName); connection.getRemoteConnectionProvider().addConnectionHandler(connectionHandler); final SecurityIdentity identity = (SecurityIdentity) saslServer.getNegotiatedProperty(WildFlySasl.SECURITY_IDENTITY); connection.setIdentity(identity == null ? saslAuthenticationFactory.getSecurityDomain().getAnonymousSecurityIdentity() : identity);
public Cancellable connect(final SocketAddress bindAddress, final SocketAddress destination, final OptionMap connectOptions, final Result<ConnectionHandlerFactory> result, final CallbackHandler callbackHandler, XnioSsl xnioSsl) throws IllegalArgumentException { if (! isOpen()) { throw new IllegalStateException("Connection provider is closed"); xnioSsl = xnio.getSslProvider(connectOptions); } catch (GeneralSecurityException e) { result.setException(sslConfigFailure(e)); return IoUtils.nullCancellable();
RemoteConnection(final StreamConnection connection, final SslChannel sslChannel, final OptionMap optionMap, final RemoteConnectionProvider remoteConnectionProvider) { this.connection = connection; this.messageReader = new MessageReader(connection.getSourceChannel(), writeListener.queue); this.sslChannel = sslChannel; this.optionMap = optionMap; heartbeatInterval = optionMap.get(RemotingOptions.HEARTBEAT_INTERVAL, RemotingOptions.DEFAULT_HEARTBEAT_INTERVAL); Messages.conn.tracef("Initialized connection from %s to %s with options %s", connection.getPeerAddress(), connection.getLocalAddress(), optionMap); this.executor = remoteConnectionProvider.getExecutor(); this.remoteConnectionProvider = remoteConnectionProvider; }
}, optionMap); addCloseHandler((closed, exception) -> safeClose(result)); result.resumeAccepts(); return result;
protected IoFuture<StreamConnection> createConnection(final URI uri, final InetSocketAddress bindAddress, final InetSocketAddress destination, final OptionMap connectOptions, final ChannelListener<StreamConnection> openListener) { final URI newUri; try { newUri = new URI("http", "", uri.getHost(), uri.getPort(), "/", "", ""); } catch (URISyntaxException e) { return new FailedIoFuture<>(new IOException(e)); } final FutureResult<StreamConnection> returnedFuture = new FutureResult<>(getExecutor()); ChannelListener<StreamConnection> upgradeListener = new UpgradeListener<StreamConnection>(StreamConnection.class, newUri, openListener, returnedFuture); IoFuture<StreamConnection> rawFuture = super.createConnection(uri, bindAddress, destination, connectOptions, upgradeListener); rawFuture.addNotifier( new IoFuture.HandlingNotifier<StreamConnection, FutureResult<StreamConnection>>() { @Override public void handleCancelled(FutureResult<StreamConnection> attachment) { attachment.setCancelled(); } @Override public void handleFailed(IOException exception, FutureResult<StreamConnection> attachment) { attachment.setException(exception); } } , returnedFuture); return returnedFuture.getIoFuture(); }
protected IoFuture<SslConnection> createSslConnection(final URI uri, final InetSocketAddress bindAddress, final InetSocketAddress destination, final OptionMap options, final AuthenticationConfiguration configuration, final SSLContext sslContext, final ChannelListener<StreamConnection> openListener) { final URI newUri; try { newUri = new URI("https", "", uri.getHost(), uri.getPort(), "/", "", ""); } catch (URISyntaxException e) { return new FailedIoFuture<>(new IOException(e)); } final FutureResult<SslConnection> returnedFuture = new FutureResult<>(getExecutor()); final OptionMap modifiedOptions = OptionMap.builder().addAll(options).set(Options.SSL_STARTTLS, false).getMap(); ChannelListener<StreamConnection> upgradeListener = new UpgradeListener<SslConnection>(SslConnection.class, newUri, openListener, returnedFuture); IoFuture<SslConnection> rawFuture = super.createSslConnection(uri, bindAddress, destination, modifiedOptions, configuration, sslContext, upgradeListener); rawFuture.addNotifier( new IoFuture.HandlingNotifier<StreamConnection, FutureResult<SslConnection>>() { @Override public void handleCancelled(FutureResult<SslConnection> attachment) { attachment.setCancelled(); } @Override public void handleFailed(IOException exception, FutureResult<SslConnection> attachment) { attachment.setException(exception); } } , returnedFuture); return returnedFuture.getIoFuture(); }
public Cancellable connect(final URI destination, final SocketAddress bindAddress, final OptionMap connectOptions, final Result<ConnectionHandlerFactory> result, final AuthenticationConfiguration authenticationConfiguration, final SSLContext sslContext, final UnaryOperator<SaslClientFactory> saslClientFactoryOperator, final Collection<String> serverMechs) { if (! isOpen()) { throw new IllegalStateException("Connection provider is closed"); final IoFuture<? extends StreamConnection> future; if (useSsl) { future = createSslConnection(destination, (InetSocketAddress) bindAddress, address, connectOptions, authenticationConfiguration, sslContext, openListener); } else { future = createConnection(destination, (InetSocketAddress) bindAddress, address, connectOptions, openListener);
protected void closeAction() throws IOException { sendCloseRequest(); remoteConnection.shutdownWrites(); remoteConnection.getMessageReader().shutdownReads(); // now these guys can't send useless messages closePendingChannels(); closeAllChannels(); remoteConnection.getRemoteConnectionProvider().removeConnectionHandler(this); }
final RemoteConnectionHandler connectionHandler = new RemoteConnectionHandler(connectionContext, connection, maxInboundChannels, maxOutboundChannels, principalObj instanceof Principal ? (Principal) principalObj : AnonymousPrincipal.getInstance(), remoteEndpointName, behavior, authCap, offeredMechanisms, serverName, hostName); connection.setReadListener(new RemoteReadListener(connectionHandler, connection), false); connection.getRemoteConnectionProvider().addConnectionHandler(connectionHandler); return connectionHandler; };
RemoteConnection(final Pool<ByteBuffer> messageBufferPool, final ConnectedStreamChannel underlyingChannel, final ConnectedMessageChannel channel, final OptionMap optionMap, final RemoteConnectionProvider remoteConnectionProvider) { this.messageBufferPool = messageBufferPool; this.underlyingChannel = underlyingChannel; this.channel = channel; this.optionMap = optionMap; heartbeatInterval = optionMap.get(RemotingOptions.HEARTBEAT_INTERVAL, RemotingOptions.DEFAULT_HEARTBEAT_INTERVAL); RemoteLogger.conn.tracef("Initialized connection from %s to %s with options %s", underlyingChannel.getPeerAddress(), underlyingChannel.getLocalAddress(), optionMap); this.executor = remoteConnectionProvider.getExecutor(); this.remoteConnectionProvider = remoteConnectionProvider; }
public AcceptingChannel<? extends ConnectedStreamChannel> createServer(final SocketAddress bindAddress, final OptionMap optionMap, final ServerAuthenticationProvider authenticationProvider, XnioSsl xnioSsl) throws IOException { final AccessControlContext accessControlContext = AccessController.getContext(); final boolean sslCapable = sslEnabled; final AcceptListener acceptListener = new AcceptListener(optionMap, authenticationProvider, accessControlContext); final AcceptingChannel<? extends ConnectedStreamChannel> result; if (sslCapable && optionMap.get(Options.SSL_ENABLED, true)) { if (xnioSsl == null) { try { xnioSsl = xnio.getSslProvider(optionMap); } catch (GeneralSecurityException e) { throw sslConfigFailure(e); } } result = xnioSsl.createSslTcpServer(xnioWorker, (InetSocketAddress) bindAddress, acceptListener, optionMap); } else { result = xnioWorker.createStreamServer(bindAddress, acceptListener, optionMap); } addCloseHandler(new CloseHandler<ConnectionProvider>() { public void handleClose(final ConnectionProvider closed, final IOException exception) { IoUtils.safeClose(result); } }); result.resumeAccepts(); return result; } }
protected IoFuture<StreamConnection> createConnection(final URI uri, final InetSocketAddress bindAddress, final InetSocketAddress destination, final OptionMap connectOptions, final ChannelListener<StreamConnection> openListener) { final URI newUri; try { newUri = new URI("http", "", uri.getHost(), uri.getPort(), "/", "", ""); } catch (URISyntaxException e) { return new FailedIoFuture<>(new IOException(e)); } final FutureResult<StreamConnection> returnedFuture = new FutureResult<>(getExecutor()); ChannelListener<StreamConnection> upgradeListener = new UpgradeListener<StreamConnection>(StreamConnection.class, newUri, openListener, returnedFuture); IoFuture<StreamConnection> rawFuture = super.createConnection(uri, bindAddress, destination, connectOptions, upgradeListener); rawFuture.addNotifier( new IoFuture.HandlingNotifier<StreamConnection, FutureResult<StreamConnection>>() { @Override public void handleCancelled(FutureResult<StreamConnection> attachment) { attachment.setCancelled(); } @Override public void handleFailed(IOException exception, FutureResult<StreamConnection> attachment) { attachment.setException(exception); } } , returnedFuture); return returnedFuture.getIoFuture(); }
protected IoFuture<SslConnection> createSslConnection(final URI uri, final InetSocketAddress bindAddress, final InetSocketAddress destination, final OptionMap options, final AuthenticationConfiguration configuration, final SSLContext sslContext, final ChannelListener<StreamConnection> openListener) { final URI newUri; try { newUri = new URI("https", "", uri.getHost(), uri.getPort(), "/", "", ""); } catch (URISyntaxException e) { return new FailedIoFuture<>(new IOException(e)); } final FutureResult<SslConnection> returnedFuture = new FutureResult<>(getExecutor()); final OptionMap modifiedOptions = OptionMap.builder().addAll(options).set(Options.SSL_STARTTLS, false).getMap(); ChannelListener<StreamConnection> upgradeListener = new UpgradeListener<SslConnection>(SslConnection.class, newUri, openListener, returnedFuture); IoFuture<SslConnection> rawFuture = super.createSslConnection(uri, bindAddress, destination, modifiedOptions, configuration, sslContext, upgradeListener); rawFuture.addNotifier( new IoFuture.HandlingNotifier<StreamConnection, FutureResult<SslConnection>>() { @Override public void handleCancelled(FutureResult<SslConnection> attachment) { attachment.setCancelled(); } @Override public void handleFailed(IOException exception, FutureResult<SslConnection> attachment) { attachment.setException(exception); } } , returnedFuture); return returnedFuture.getIoFuture(); }
private void doDumpConnectionState() { final StringBuilder b = new StringBuilder(); doGetConnectionState(b); log.info(b); }
/** * Make this method visible. */ protected void closeComplete() { super.closeComplete(); remoteConnection.getRemoteConnectionProvider().removeConnectionHandler(this); }