public void shutdownWrites() throws IOException { sink.shutdownWrites(); }
public void terminateWrites() throws IOException { channel.shutdownWrites(); }
public void shutdownWrites() throws IOException { int oldVal, newVal; do { oldVal = state; if (allAreSet(oldVal, FLAG_CLOSE_REQ)) { return; } newVal = oldVal | FLAG_CLOSE_REQ; } while (! stateUpdater.compareAndSet(this, oldVal, newVal)); delegate.shutdownWrites(); }
@Override public boolean send() throws IOException { if (!shutdown) { shutdown = true; responseChannel.shutdownWrites(); } return responseChannel.flush(); }
@Override public void shutdownWrites() throws IOException { if (isFinished()) { return; } delegate.shutdownWrites(); }
/** * Writes out the data in the buffer to the channel. If all the data is written out * then the channel will have its writes shutdown. * * @param channel The channel * @param src The buffer * @return The number of bytes written * @throws IOException */ public static int writeFinalBasic(StreamSinkChannel channel, ByteBuffer src) throws IOException { int res = channel.write(src); if(!src.hasRemaining()) { channel.shutdownWrites(); } return res; }
public void shutdownWrites() throws IOException { final int state = this.state; if (allAreSet(state, FLAG_CLOSE_REQUESTED)) { return; // idempotent } this.state = state | FLAG_CLOSE_REQUESTED; if (allAreSet(state, FLAG_PASS_CLOSE)) { delegate.shutdownWrites(); } }
/** * Writes out the data in the buffer to the channel. If all the data is written out * then the channel will have its writes shutdown. * * @param channel The channel * @param srcs The buffers * @param offset The offset into the srcs array * @param length The number buffers to write * @return The number of bytes written * @throws IOException */ public static long writeFinalBasic(StreamSinkChannel channel, ByteBuffer[] srcs, int offset, int length) throws IOException { final long res = channel.write(srcs, offset, length); if (!Buffers.hasRemaining(srcs, offset, length)) { channel.shutdownWrites(); } return res; }
sink.shutdownWrites(); if(!sink.flush()) { sink.getWriteSetter().set(ChannelListeners.flushingChannelListener(null, new ChannelExceptionHandler<StreamSinkChannel>() {
private void flushChannel(StreamSinkChannel stream) throws IOException { stream.shutdownWrites(); if (!stream.flush()) { stream.getWriteSetter().set(ChannelListeners.flushingChannelListener(null, writeExceptionHandler())); stream.resumeWrites(); } }
/** {@inheritDoc} */ public void close() throws IOException { final boolean closed = enter(); try { if (closed) return; final StreamSinkChannel channel = this.channel; channel.shutdownWrites(); if (! channel.flush()) { long timeout; long start = System.nanoTime(); long elapsed = 0L; do { timeout = this.timeout; if (timeout == 0L) { channel.awaitWritable(); } else if (timeout < elapsed) { throw msg.writeTimeout(); } else { channel.awaitWritable(timeout - elapsed, TimeUnit.NANOSECONDS); } elapsed = System.nanoTime() - start; } while (! channel.flush()); } } finally { exit(true); } } }
result.getRequestChannel().write(ByteBuffer.wrap(body.getBytes())); result.getRequestChannel().shutdownWrites(); if (!result.getRequestChannel().flush()) { result.getRequestChannel().getWriteSetter()
@Override public void handleEvent(final StreamSinkChannel channel) { HeaderMap trailers = source.getAttachment(HttpAttachments.REQUEST_TRAILERS); if (trailers != null) { target.putAttachment(HttpAttachments.RESPONSE_TRAILERS, trailers); } try { channel.shutdownWrites(); if (!channel.flush()) { channel.getWriteSetter().set(ChannelListeners.flushingChannelListener(new ChannelListener<StreamSinkChannel>() { @Override public void handleEvent(StreamSinkChannel channel) { channel.suspendWrites(); channel.getWriteSetter().set(null); } }, ChannelListeners.closingChannelExceptionHandler())); channel.resumeWrites(); } else { channel.getWriteSetter().set(null); channel.shutdownWrites(); } } catch (IOException e) { handleFailure(exchange, proxyClientHandler, idempotentPredicate, e); } catch (Exception e) { handleFailure(exchange, proxyClientHandler, idempotentPredicate, new IOException(e)); } } }
protected void writeDone(final StreamSinkChannel channel) { try { channel.shutdownWrites(); if (!channel.flush()) { channel.getWriteSetter().set(ChannelListeners.flushingChannelListener(new ChannelListener<StreamSinkChannel>() { @Override public void handleEvent(StreamSinkChannel o) { IoUtils.safeClose(channel); } }, ChannelListeners.closingChannelExceptionHandler())); channel.resumeWrites(); } } catch (IOException e) { handleError(channel, e); } } }
result.getRequestChannel().shutdownWrites(); if(!result.getRequestChannel().flush()) { result.getRequestChannel().getWriteSetter().set(ChannelListeners.<StreamSinkChannel>flushingChannelListener(null, null));
channel.shutdownWrites(); Channels.flushBlocking(channel); } finally {
Channels.transferBlocking(response, fileChannel, 0, Files.size(file)); log.tracef("Finished serving %s, shutting down (blocking)", fileChannel); response.shutdownWrites(); log.tracef("Finished serving %s, flushing (blocking)", fileChannel); Channels.flushBlocking(response);
@Override public void completed(final ClientExchange result) { if (exchangeListener.isDone()) { IoUtils.safeClose(proxyConnection.getConnection()); return; } exchangeListener.exchange = result; result.setResponseListener(exchangeListener); try { result.getRequestChannel().shutdownWrites(); if (!result.getRequestChannel().flush()) { result.getRequestChannel().getWriteSetter().set(ChannelListeners.flushingChannelListener(null, new ChannelExceptionHandler<StreamSinkChannel>() { @Override public void handleException(StreamSinkChannel channel, IOException exception) { IoUtils.safeClose(proxyConnection.getConnection()); exchangeListener.taskFailed(); } })); result.getRequestChannel().resumeWrites(); } } catch (IOException e) { IoUtils.safeClose(proxyConnection.getConnection()); exchangeListener.taskFailed(); } }
channel.shutdownWrites(); if (!channel.flush()) { channel.getWriteSetter().set(ChannelListeners.flushingChannelListener(
final StreamSinkChannel responseChannel = newExchange.getResponseChannel(); try { responseChannel.shutdownWrites(); if (!responseChannel.flush()) { responseChannel.getWriteSetter().set(ChannelListeners.flushingChannelListener(