private static void writeRequest(AsyncChannelWrapper channel, ByteBuffer request, long timeout) throws TimeoutException, InterruptedException, ExecutionException { int toWrite = request.limit(); Future<Integer> fWrite = channel.write(request); Integer thisWrite = fWrite.get(timeout, TimeUnit.MILLISECONDS); toWrite -= thisWrite.intValue(); while (toWrite > 0) { fWrite = channel.write(request); thisWrite = fWrite.get(timeout, TimeUnit.MILLISECONDS); toWrite -= thisWrite.intValue(); } }
private static void writeRequest(AsyncChannelWrapper channel, ByteBuffer request, long timeout) throws TimeoutException, InterruptedException, ExecutionException { int toWrite = request.limit(); Future<Integer> fWrite = channel.write(request); Integer thisWrite = fWrite.get(timeout, TimeUnit.MILLISECONDS); toWrite -= thisWrite.intValue(); while (toWrite > 0) { fWrite = channel.write(request); thisWrite = fWrite.get(timeout, TimeUnit.MILLISECONDS); toWrite -= thisWrite.intValue(); } }
private static void writeRequest(AsyncChannelWrapper channel, ByteBuffer request, long timeout) throws TimeoutException, InterruptedException, ExecutionException { int toWrite = request.limit(); Future<Integer> fWrite = channel.write(request); Integer thisWrite = fWrite.get(timeout, TimeUnit.MILLISECONDS); toWrite -= thisWrite.intValue(); while (toWrite > 0) { fWrite = channel.write(request); thisWrite = fWrite.get(timeout, TimeUnit.MILLISECONDS); toWrite -= thisWrite.intValue(); } }
@Override protected void doWrite(SendHandler handler, ByteBuffer... data) { long timeout = getSendTimeout(); if (timeout < 1) { timeout = Long.MAX_VALUE; } SendHandlerToCompletionHandler sh2ch = new SendHandlerToCompletionHandler(handler); channel.write(data, 0, data.length, timeout, TimeUnit.MILLISECONDS, null, sh2ch); }
@Override protected void doWrite(SendHandler handler, ByteBuffer... data) { long timeout = getSendTimeout(); if (timeout < 1) { timeout = Long.MAX_VALUE; } SendHandlerToCompletionHandler sh2ch = new SendHandlerToCompletionHandler(handler); try { channel.write(data, 0, data.length, timeout, TimeUnit.MILLISECONDS, null, sh2ch); } catch (IllegalStateException ise) { sh2ch.failed(ise, null); } }
@Override protected void doWrite(SendHandler handler, ByteBuffer... data) { long timeout = getSendTimeout(); if (timeout < 1) { timeout = Long.MAX_VALUE; } SendHandlerToCompletionHandler sh2ch = new SendHandlerToCompletionHandler(handler); try { channel.write(data, 0, data.length, timeout, TimeUnit.MILLISECONDS, null, sh2ch); } catch (IllegalStateException ise) { sh2ch.failed(ise, null); } }
@Override protected void doWrite(SendHandler handler, long blockingWriteTimeoutExpiry, ByteBuffer... data) { long timeout; for (ByteBuffer byteBuffer : data) { if (blockingWriteTimeoutExpiry == -1) { timeout = getSendTimeout(); if (timeout < 1) { timeout = Long.MAX_VALUE; } } else { timeout = blockingWriteTimeoutExpiry - System.currentTimeMillis(); if (timeout < 0) { SendResult sr = new SendResult(new IOException("Blocking write timeout")); handler.onResult(sr); } } try { channel.write(byteBuffer).get(timeout, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { handler.onResult(new SendResult(e)); return; } } handler.onResult(SENDRESULT_OK); }
@Override protected void doWrite(SendHandler handler, long blockingWriteTimeoutExpiry, ByteBuffer... data) { long timeout; for (ByteBuffer byteBuffer : data) { if (blockingWriteTimeoutExpiry == -1) { timeout = getSendTimeout(); if (timeout < 1) { timeout = Long.MAX_VALUE; } } else { timeout = blockingWriteTimeoutExpiry - System.currentTimeMillis(); if (timeout < 0) { SendResult sr = new SendResult(new IOException("Blocking write timeout")); handler.onResult(sr); } } try { channel.write(byteBuffer).get(timeout, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { handler.onResult(new SendResult(e)); return; } } handler.onResult(SENDRESULT_OK); }