@Override public synchronized void connectionOpened() { if (!closeOnOpen) upstreamConnection.connectionOpened(); }
@Override public synchronized void connectionOpened() { if (!closeOnOpen) upstreamConnection.connectionOpened(); }
@Override public synchronized void connectionOpened() { if (!closeOnOpen) upstreamConnection.connectionOpened(); }
@Override public synchronized void connectionOpened() { if (!closeOnOpen) upstreamConnection.connectionOpened(); }
private void handleKey(Selector selector, SelectionKey key) throws IOException { if (key.isValid() && key.isAcceptable()) { // Accept a new connection, give it a stream connection as an attachment SocketChannel newChannel = sc.accept(); newChannel.configureBlocking(false); SelectionKey newKey = newChannel.register(selector, SelectionKey.OP_READ); try { ConnectionHandler handler = new ConnectionHandler(connectionFactory, newKey); newKey.attach(handler); handler.connection.connectionOpened(); } catch (IOException e) { // This can happen if ConnectionHandler's call to get a new handler returned null log.error("Error handling new connection", Throwables.getRootCause(e).getMessage()); newKey.channel().close(); } } else { // Got a closing channel or a channel to a client connection ConnectionHandler.handleKey(key); } }
private void handleKey(Selector selector, SelectionKey key) throws IOException { if (key.isValid() && key.isAcceptable()) { // Accept a new connection, give it a stream connection as an attachment SocketChannel newChannel = sc.accept(); newChannel.configureBlocking(false); SelectionKey newKey = newChannel.register(selector, SelectionKey.OP_READ); try { ConnectionHandler handler = new ConnectionHandler(connectionFactory, newKey); newKey.attach(handler); handler.connection.connectionOpened(); } catch (IOException e) { // This can happen if ConnectionHandler's call to get a new handler returned null log.error("Error handling new connection", Throwables.getRootCause(e).getMessage()); newKey.channel().close(); } } else { // Got a closing channel or a channel to a client connection ConnectionHandler.handleKey(key); } }
private void handleKey(Selector selector, SelectionKey key) throws IOException { if (key.isValid() && key.isAcceptable()) { // Accept a new connection, give it a stream connection as an attachment SocketChannel newChannel = sc.accept(); newChannel.configureBlocking(false); SelectionKey newKey = newChannel.register(selector, SelectionKey.OP_READ); try { ConnectionHandler handler = new ConnectionHandler(connectionFactory, newKey); newKey.attach(handler); handler.connection.connectionOpened(); } catch (IOException e) { // This can happen if ConnectionHandler's call to get a new handler returned null log.error("Error handling new connection", Throwables.getRootCause(e).getMessage()); newKey.channel().close(); } } else { // Got a closing channel or a channel to a client connection ConnectionHandler.handleKey(key); } }
private void handleKey(Selector selector, SelectionKey key) throws IOException { if (key.isValid() && key.isAcceptable()) { // Accept a new connection, give it a stream connection as an attachment SocketChannel newChannel = sc.accept(); newChannel.configureBlocking(false); SelectionKey newKey = newChannel.register(selector, SelectionKey.OP_READ); try { ConnectionHandler handler = new ConnectionHandler(connectionFactory, newKey); newKey.attach(handler); handler.connection.connectionOpened(); } catch (IOException e) { // This can happen if ConnectionHandler's call to get a new handler returned null log.error("Error handling new connection", Throwables.getRootCause(e).getMessage()); newKey.channel().close(); } } else { // Got a closing channel or a channel to a client connection ConnectionHandler.handleKey(key); } }
@Override public void run() { Context.propagate(context); if (clientSet != null) clientSet.add(BlockingClient.this); try { socket.connect(serverAddress, connectTimeoutMillis); connection.connectionOpened(); connectFuture.set(serverAddress); InputStream stream = socket.getInputStream(); runReadLoop(stream, connection); } catch (Exception e) { if (!vCloseRequested) { log.error("Error trying to open/read from connection: {}: {}", serverAddress, e.getMessage()); connectFuture.setException(e); } } finally { try { socket.close(); } catch (IOException e1) { // At this point there isn't much we can do, and we can probably assume the channel is closed } if (clientSet != null) clientSet.remove(BlockingClient.this); connection.connectionClosed(); } } };
@Override public void run() { Context.propagate(context); if (clientSet != null) clientSet.add(BlockingClient.this); try { socket.connect(serverAddress, connectTimeoutMillis); connection.connectionOpened(); connectFuture.set(serverAddress); InputStream stream = socket.getInputStream(); runReadLoop(stream, connection); } catch (Exception e) { if (!vCloseRequested) { log.error("Error trying to open/read from connection: {}: {}", serverAddress, e.getMessage()); connectFuture.setException(e); } } finally { try { socket.close(); } catch (IOException e1) { // At this point there isn't much we can do, and we can probably assume the channel is closed } if (clientSet != null) clientSet.remove(BlockingClient.this); connection.connectionClosed(); } } };
@Override public void run() { Context.propagate(context); if (clientSet != null) clientSet.add(BlockingClient.this); try { socket.connect(serverAddress, connectTimeoutMillis); connection.connectionOpened(); connectFuture.set(serverAddress); InputStream stream = socket.getInputStream(); runReadLoop(stream, connection); } catch (Exception e) { if (!vCloseRequested) { log.error("Error trying to open/read from connection: {}: {}", serverAddress, e.getMessage()); connectFuture.setException(e); } } finally { try { socket.close(); } catch (IOException e1) { // At this point there isn't much we can do, and we can probably assume the channel is closed } if (clientSet != null) clientSet.remove(BlockingClient.this); connection.connectionClosed(); } } };
log.info("Connected to {}", sc.socket().getRemoteSocketAddress()); key.interestOps((key.interestOps() | SelectionKey.OP_READ) & ~SelectionKey.OP_CONNECT).attach(handler); connection.connectionOpened(); data.future.set(data.address); } else {
@Override public void run() { Context.propagate(context); if (clientSet != null) clientSet.add(BlockingClient.this); try { socket.connect(serverAddress, connectTimeoutMillis); connection.connectionOpened(); connectFuture.set(serverAddress); InputStream stream = socket.getInputStream(); runReadLoop(stream, connection); } catch (Exception e) { if (!vCloseRequested) { log.error("Error trying to open/read from connection: {}: {}", serverAddress, e.getMessage()); connectFuture.setException(e); } } finally { try { socket.close(); } catch (IOException e1) { // At this point there isn't much we can do, and we can probably assume the channel is closed } if (clientSet != null) clientSet.remove(BlockingClient.this); connection.connectionClosed(); } } };
log.info("Connected to {}", sc.socket().getRemoteSocketAddress()); key.interestOps((key.interestOps() | SelectionKey.OP_READ) & ~SelectionKey.OP_CONNECT).attach(handler); connection.connectionOpened(); data.future.set(data.address); } else {
log.info("Connected to {}", sc.socket().getRemoteSocketAddress()); key.interestOps((key.interestOps() | SelectionKey.OP_READ) & ~SelectionKey.OP_CONNECT).attach(handler); connection.connectionOpened(); data.future.set(data.address); } else {
log.info("Connected to {}", sc.socket().getRemoteSocketAddress()); key.interestOps((key.interestOps() | SelectionKey.OP_READ) & ~SelectionKey.OP_CONNECT).attach(handler); connection.connectionOpened(); data.future.set(data.address); } else {