private static int readSimpleByteBuffer(final TCPNIOConnection tcpConnection, final ByteBuffer byteBuffer) throws IOException { final SocketChannel socketChannel = (SocketChannel) tcpConnection.getChannel(); return socketChannel.read(byteBuffer); }
@Override public void failed(final Throwable throwable) { connection.checkConnectFailed(throwable); } }
/** * Method will be called, when some data was read on the connection */ protected final void onRead(Buffer data, int size) { if (size > 0) { notifyProbesRead(this, data, size); } checkEmptyRead(size); }
protected static void onConnectedAsync(final TCPNIOConnection connection, final CompletionHandler<Connection> completionHandler) throws IOException { final TCPNIOTransport tcpTransport = (TCPNIOTransport) connection.getTransport(); final SocketChannel channel = (SocketChannel) connection.getChannel(); try { if (!channel.isConnected()) { channel.finishConnect(); } connection.resetProperties(); // Deregister OP_CONNECT interest connection.disableIOEvent(IOEvent.CLIENT_CONNECTED); // we can call configure for ready channel tcpTransport.getChannelConfigurator().postConfigure(tcpTransport, channel); } catch (Exception e) { abortConnection(connection, completionHandler, e); throw Exceptions.makeIOException(e); } if (connection.notifyReady()) { tcpTransport.fireIOEvent(IOEvent.CONNECTED, connection, new EnableReadHandler(completionHandler)); } }
@Override public void onComplete(final Context context, final Object data) throws IOException { final TCPNIOConnection connection = (TCPNIOConnection) context.getConnection(); if (completionHandler != null) { completionHandler.completed(connection); } if (!connection.isStandalone()) { connection.enableInitialOpRead(); } }
public static Buffer allocateAndReadBuffer(final TCPNIOConnection connection) throws IOException { final MemoryManager memoryManager = connection.getMemoryManager(); final int receiveBufferSize = Math.min(TCPNIOTransport.MAX_RECEIVE_BUFFER_SIZE, connection.getReadBufferSize());
TCPNIOConnection obtainNIOConnection(final SocketChannel channel) { final TCPNIOConnection connection = new TCPNIOConnection(this, channel); configureNIOConnection(connection); return connection; }
protected void addRecord(Connection connection, Buffer buffer, CompletionHandler completionHandler, Interceptor<ReadResult> interceptor) { final AsyncReadQueueRecord record = AsyncReadQueueRecord.create( connection, buffer, completionHandler, interceptor); ((TCPNIOConnection) connection).getAsyncReadQueue().offer(record); }
private static void abortConnection(final TCPNIOConnection connection, final CompletionHandler<Connection> completionHandler, final Throwable failure) { connection.closeSilently(); if (completionHandler != null) { completionHandler.failed(failure); } }
protected static void onConnectedAsync(final TCPNIOConnection connection, final CompletionHandler<Connection> completionHandler) throws IOException { final TCPNIOTransport tcpTransport = (TCPNIOTransport) connection.getTransport(); final SocketChannel channel = (SocketChannel) connection.getChannel(); try { if (!channel.isConnected()) { channel.finishConnect(); } connection.resetProperties(); // Deregister OP_CONNECT interest connection.disableIOEvent(IOEvent.CLIENT_CONNECTED); // we can call configure for ready channel tcpTransport.getChannelConfigurator().postConfigure(tcpTransport, channel); } catch (Exception e) { abortConnection(connection, completionHandler, e); throw Exceptions.makeIOException(e); } if (connection.notifyReady()) { tcpTransport.fireIOEvent(IOEvent.CONNECTED, connection, new EnableReadHandler(completionHandler)); } }
@Override public void onComplete(final Context context, final Object data) throws IOException { final TCPNIOConnection connection = (TCPNIOConnection) context.getConnection(); if (completionHandler != null) { completionHandler.completed(connection); } if (!connection.isStandalone()) { connection.enableInitialOpRead(); } }
public static Buffer allocateAndReadBuffer(final TCPNIOConnection connection) throws IOException { final MemoryManager memoryManager = connection.getMemoryManager(); final int receiveBufferSize = Math.min(TCPNIOTransport.MAX_RECEIVE_BUFFER_SIZE, connection.getReadBufferSize());
TCPNIOConnection obtainNIOConnection(final SocketChannel channel) { final TCPNIOConnection connection = new TCPNIOConnection(this, channel); configureNIOConnection(connection); return connection; }
protected void addRecord(Connection connection, Buffer buffer, CompletionHandler completionHandler, Interceptor<ReadResult> interceptor) { final AsyncReadQueueRecord record = AsyncReadQueueRecord.create( connection, buffer, completionHandler, interceptor); ((TCPNIOConnection) connection).getAsyncReadQueue().offer(record); }
private static void abortConnection(final TCPNIOConnection connection, final CompletionHandler<Connection> completionHandler, final Throwable failure) { connection.closeSilently(); if (completionHandler != null) { completionHandler.failed(failure); } }
protected static void onConnectedAsync(final TCPNIOConnection connection, final CompletionHandler<Connection> completionHandler) throws IOException { final TCPNIOTransport tcpTransport = (TCPNIOTransport) connection.getTransport(); final SocketChannel channel = (SocketChannel) connection.getChannel(); try { if (!channel.isConnected()) { channel.finishConnect(); } connection.resetProperties(); // Deregister OP_CONNECT interest connection.disableIOEvent(IOEvent.CLIENT_CONNECTED); // we can call configure for ready channel tcpTransport.getChannelConfigurator().postConfigure(tcpTransport, channel); } catch (Exception e) { abortConnection(connection, completionHandler, e); throw Exceptions.makeIOException(e); } if (connection.notifyReady()) { tcpTransport.fireIOEvent(IOEvent.CONNECTED, connection, new EnableReadHandler(completionHandler)); } }
@Override public void onComplete(final Context context, final Object data) throws IOException { final TCPNIOConnection connection = (TCPNIOConnection) context.getConnection(); if (completionHandler != null) { completionHandler.completed(connection); } if (!connection.isStandalone()) { connection.enableInitialOpRead(); } }
/** * Method will be called, when some data was read on the connection */ protected final void onRead(Buffer data, int size) { if (size > 0) { notifyProbesRead(this, data, size); } checkEmptyRead(size); }
public static Buffer allocateAndReadBuffer(final TCPNIOConnection connection) throws IOException { final MemoryManager memoryManager = connection.getMemoryManager(); final int receiveBufferSize = Math.min(TCPNIOTransport.MAX_RECEIVE_BUFFER_SIZE, connection.getReadBufferSize());
TCPNIOConnection obtainNIOConnection(final SocketChannel channel) { final TCPNIOConnection connection = new TCPNIOConnection(this, channel); configureNIOConnection(connection); return connection; }