public boolean flush() throws IOException { return sink.flush(); }
public boolean flush() throws IOException { return channel.flush(); }
@Override protected void flush() throws IOException { StreamSinkChannel channel = UndertowServerHttpResponse.this.responseChannel; if (channel != null) { if (rsWriteFlushLogger.isTraceEnabled()) { rsWriteFlushLogger.trace(getLogPrefix() + "flush"); } channel.flush(); } }
@Override protected void flush() throws IOException { StreamSinkChannel channel = UndertowServerHttpResponse.this.responseChannel; if (channel != null) { if (rsWriteFlushLogger.isTraceEnabled()) { rsWriteFlushLogger.trace(getLogPrefix() + "flush"); } channel.flush(); } }
@Override public boolean flush() throws IOException { if (isFinished()) { return true; } return delegate.flush(); }
@Override public boolean send() throws IOException { if (!shutdown) { shutdown = true; responseChannel.shutdownWrites(); } return responseChannel.flush(); }
/** {@inheritDoc} */ public void flush() throws IOException { final StreamSinkChannel delegate = this.delegate; if (! delegate.flush()) { long start = System.nanoTime(); long elapsed = 0L, writeTimeout; do { writeTimeout = this.writeTimeout; if (writeTimeout == 0L || writeTimeout == Long.MAX_VALUE) { delegate.awaitWritable(); } else if (writeTimeout <= elapsed) { throw msg.writeTimeout(); } else { delegate.awaitWritable(writeTimeout - elapsed, TimeUnit.NANOSECONDS); } elapsed = System.nanoTime() - start; } while (! delegate.flush()); } }
/** {@inheritDoc} */ public void flush() throws IOException { final StreamSinkChannel delegate = this.delegate; if (! delegate.flush()) { long start = System.nanoTime(); long elapsed = 0L, writeTimeout; do { writeTimeout = this.writeTimeout; if (writeTimeout == 0L || writeTimeout == Long.MAX_VALUE) { delegate.awaitWritable(); } else if (writeTimeout <= elapsed) { throw msg.writeTimeout(); } else { delegate.awaitWritable(writeTimeout - elapsed, TimeUnit.NANOSECONDS); } elapsed = System.nanoTime() - start; } while (! delegate.flush()); } }
public boolean flush() throws IOException { int oldVal, newVal; oldVal = state; if (allAreSet(oldVal, FLAG_CLOSE_COMP)) { return true; } final boolean flushed = delegate.flush(); if (! flushed) { return false; } do { if (allAreClear(oldVal, FLAG_CLOSE_REQ)) { return true; } newVal = oldVal | FLAG_CLOSE_COMP; } while (! stateUpdater.compareAndSet(this, oldVal, newVal)); invokeChannelListener(this, closeListener); return true; }
/** {@inheritDoc} */ public void flush() throws IOException { final boolean closed = enter(); try { final StreamSinkChannel channel = this.channel; 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(closed); } }
if(!sink.flush()) { sink.getWriteSetter().set(ChannelListeners.flushingChannelListener(null, new ChannelExceptionHandler<StreamSinkChannel>() { @Override
/** {@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); } } }
private void flushChannel(StreamSinkChannel stream) throws IOException { stream.shutdownWrites(); if (!stream.flush()) { stream.getWriteSetter().set(ChannelListeners.flushingChannelListener(null, writeExceptionHandler())); stream.resumeWrites(); } }
public boolean flush() throws IOException { int state = this.state; if (anyAreSet(state, FLAG_CLOSE_COMPLETE)) { return true; } boolean flushed = false; try { return flushed = delegate.flush(); } finally { if (flushed && allAreSet(state, FLAG_CLOSE_REQUESTED)) { this.state = state | FLAG_CLOSE_COMPLETE; callFinish(); callClosed(); if (count != 0) { throw msg.fixedUnderflow(count); } } } }
if (!result.getRequestChannel().flush()) { result.getRequestChannel().getWriteSetter() .set(ChannelListeners.<StreamSinkChannel>flushingChannelListener(null, null));
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); } } }
@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)); } } }
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/event-stream; charset=UTF-8"); exchange.setPersistent(false); final StreamSinkChannel sink = exchange.getResponseChannel(); if(!sink.flush()) { sink.getWriteSetter().set(ChannelListeners.flushingChannelListener(new ChannelListener<StreamSinkChannel>() { @Override public void handleEvent(StreamSinkChannel channel) { handleConnect(channel, exchange); } }, new ChannelExceptionHandler<StreamSinkChannel>() { @Override public void handleException(StreamSinkChannel channel, IOException exception) { IoUtils.safeClose(exchange.getConnection()); } })); sink.resumeWrites(); } else { exchange.dispatch(exchange.getIoThread(), new Runnable() { @Override public void run() { handleConnect(sink, exchange); } }); } }
@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(); } }
try { responseChannel.shutdownWrites(); if (!responseChannel.flush()) { responseChannel.getWriteSetter().set(ChannelListeners.flushingChannelListener( new ChannelListener<StreamSinkChannel>() {