/** * Closes the underlying socket channel. * * @throws java.io.IOException for issues closing underlying stream */ @Override public void close() throws IOException { channel.close(); } }
@Override public void close() throws IOException { socketChannel.socket().close(); socketChannel.close(); }
@Override public void close() throws IOException { getChannel().close(); } }
@Override public void close() throws IOException { getChannel().close(); } }
private KafkaChannel buildAndAttachKafkaChannel(SocketChannel socketChannel, String id, SelectionKey key) throws IOException { try { KafkaChannel channel = channelBuilder.buildChannel(id, key, maxReceiveSize, memoryPool); key.attach(channel); return channel; } catch (Exception e) { try { socketChannel.close(); } finally { key.cancel(); } throw new IOException("Channel could not be created for socket " + socketChannel, e); } }
public void close() { if (this.socketChannel != null) { try { this.socketChannel.close(); } catch (IOException e) { HAConnection.log.error("", e); } } }
private void clearKey(SelectionKey key) throws IOException { if (key.isValid()) { SocketChannel socketChannel = (SocketChannel) key.channel(); socketChannel.close(); key.attach(null); key.cancel(); } }
private void clearKey(SelectionKey key) throws IOException { if (key.isValid()) { SocketChannel socketChannel = (SocketChannel) key.channel(); socketChannel.close(); key.attach(null); key.cancel(); } }
public void closeSocketChannels() throws IOException { for (SocketChannel channel : socketChannels) { channel.close(); } socketChannels.clear(); }
@Override protected void doClose() throws Exception { super.doClose(); javaChannel().close(); }
protected void cancel( SelectionKey key, SocketChannel c ) throws IOException { NioEndpoint p = (NioEndpoint)key.attachment(); log.log( Level.FINE, "Closing channel endpoint:{0}.", p ); Object o = endpointKeys.remove(p); log.log( Level.FINE, "Endpoint keys size:{0}", endpointKeys.size() ); key.cancel(); c.close(); removeEndpoint( p, c ); }
@Override protected void doClose() throws Exception { super.doClose(); javaChannel().close(); }
private void closeMaster() { if (null != this.socketChannel) { try { SelectionKey sk = this.socketChannel.keyFor(this.selector); if (sk != null) { sk.cancel(); } this.socketChannel.close(); this.socketChannel = null; } catch (IOException e) { log.warn("closeMaster exception. ", e); } this.lastWriteTimestamp = 0; this.dispatchPostion = 0; this.byteBufferBackup.position(0); this.byteBufferBackup.limit(READ_MAX_BUFFER_SIZE); this.byteBufferRead.position(0); this.byteBufferRead.limit(READ_MAX_BUFFER_SIZE); } }
public void close() throws IOException { sslEngine.closeOutbound(); sslEngine.getSession().invalidate(); if( socketChannel.isOpen() ) socketChannel.write( wrap( emptybuffer ) );// FIXME what if not all bytes can be written socketChannel.close(); }
@Override void connect(InetSocketAddress addr) throws IOException { SocketChannel sock = createSock(); try { registerAndConnect(sock, addr); } catch (IOException e) { LOG.error("Unable to open socket to " + addr); sock.close(); throw e; } initialized = false; /* * Reset incomingBuffer */ lenBuffer.clear(); incomingBuffer = lenBuffer; }
@Override protected void doClose() throws Exception { super.doClose(); javaChannel().close(); }
/** * This method should be called when this peer wants to explicitly close the connection * or when a close message has arrived from the other peer, in order to provide an orderly shutdown. * <p/> * It first calls {@link SSLEngine#closeOutbound()} which prepares this peer to send its own close message and * sets {@link SSLEngine} to the <code>NEED_WRAP</code> state. Then, it delegates the exchange of close messages * to the handshake method and finally, it closes socket channel. * * @throws IOException if an I/O error occurs to the socket channel. */ private void closeConnection() throws IOException { engine.closeOutbound(); try { doHandshake(); } catch ( IOException e ) { //Just ignore this exception since we are closing the connection already } socketChannel.close(); }
@Override protected int doReadMessages(List<Object> buf) throws Exception { SocketChannel ch = SocketUtils.accept(javaChannel()); try { if (ch != null) { buf.add(new NioSocketChannel(this, ch)); return 1; } } catch (Throwable t) { logger.warn("Failed to create a new channel from an accepted socket.", t); try { ch.close(); } catch (Throwable t2) { logger.warn("Failed to close a socket.", t2); } } return 0; }
protected void closeAction() throws IOException { try { conduit.cancelKey(false); conduit.getSocketChannel().close(); } catch (ClosedChannelException ignored) { } finally { final ChannelClosed closedHandle = this.closedHandle; if (closedHandle!= null) closedHandle.channelClosed(); } }
@Override protected int doReadMessages(List<Object> buf) throws Exception { SocketChannel ch = SocketUtils.accept(javaChannel()); try { if (ch != null) { buf.add(new NioSocketChannel(this, ch)); return 1; } } catch (Throwable t) { logger.warn("Failed to create a new channel from an accepted socket.", t); try { ch.close(); } catch (Throwable t2) { logger.warn("Failed to close a socket.", t2); } } return 0; }