/** * Flushes content of the session buffer to the channel and updates transport metrics. * * @return number of bytes written to the channel. * * @since 4.3 */ protected int flushToChannel() throws IOException { if (!this.buffer.hasData()) { return 0; } final int bytesWritten = this.buffer.flush(this.channel); if (bytesWritten > 0) { this.metrics.incrementBytesTransferred(bytesWritten); } return bytesWritten; }
if (this.buffer.hasData() || this.fragHint > 0) { if (src.remaining() <= this.fragHint) { final int capacity = this.fragHint - this.buffer.length(); if (this.buffer.hasData()) { if (this.buffer.length() >= this.fragHint || src.hasRemaining()) { final int bytesWritten = flushToChannel(); if (!this.buffer.hasData() && src.remaining() > this.fragHint) { final int bytesWritten = writeToChannel(src); total += bytesWritten;
/** * Flushes content of the session buffer to the channel and updates transport metrics. * * @return number of bytes written to the channel. * * @since 4.3 */ protected int flushToChannel() throws IOException { if (!this.buffer.hasData()) { return 0; } final int bytesWritten = this.buffer.flush(this.channel); if (bytesWritten > 0) { this.metrics.incrementBytesTransferred(bytesWritten); } return bytesWritten; }
if (this.buffer.hasData() || this.fragHint > 0) { if (src.remaining() <= this.fragHint) { final int capacity = this.fragHint - this.buffer.length(); if (this.buffer.hasData()) { if (this.buffer.length() >= this.fragHint || src.hasRemaining()) { final int bytesWritten = flushToChannel(); if (!this.buffer.hasData() && src.remaining() > this.fragHint) { final int bytesWritten = writeToChannel(src); total += bytesWritten;
@Override public long transfer( final FileChannel src, final long position, final long count) throws IOException { if (src == null) { return 0; } assertNotCompleted(); flushToChannel(); if (this.buffer.hasData()) { return 0; } final long bytesWritten = src.transferTo(position, count, this.channel); if (bytesWritten > 0) { this.metrics.incrementBytesTransferred(bytesWritten); } return bytesWritten; }
@Override public long transfer( final FileChannel src, final long position, final long count) throws IOException { if (src == null) { return 0; } assertNotCompleted(); flushToChannel(); if (this.buffer.hasData()) { return 0; } final long bytesWritten = src.transferTo(position, count, this.channel); if (bytesWritten > 0) { this.metrics.incrementBytesTransferred(bytesWritten); } return bytesWritten; }
@Override public long transfer( final FileChannel src, final long position, final long count) throws IOException { if (src == null) { return 0; } assertNotCompleted(); flushToChannel(); if (this.buffer.hasData()) { return 0; } final long chunk = Math.min(this.remaining, count); final long bytesWritten = src.transferTo(position, chunk, this.channel); if (bytesWritten > 0) { this.metrics.incrementBytesTransferred(bytesWritten); } this.remaining -= bytesWritten; if (this.remaining <= 0) { super.complete(); } return bytesWritten; }
@Override public long transfer( final FileChannel src, final long position, final long count) throws IOException { if (src == null) { return 0; } assertNotCompleted(); flushToChannel(); if (this.buffer.hasData()) { return 0; } final long chunk = Math.min(this.remaining, count); final long bytesWritten = src.transferTo(position, chunk, this.channel); if (bytesWritten > 0) { this.metrics.incrementBytesTransferred(bytesWritten); } this.remaining -= bytesWritten; if (this.remaining <= 0) { super.complete(); } return bytesWritten; }
if (this.buffer.hasData() || this.fragHint > 0) { final int chunk = nextChunk(src); if (chunk <= this.fragHint) { if (this.buffer.hasData()) { final int chunk = nextChunk(src); if (this.buffer.length() >= this.fragHint || chunk > 0) { if (!this.buffer.hasData()) { final int chunk = nextChunk(src); if (chunk > this.fragHint) {
if (this.buffer.hasData() || this.fragHint > 0) { final int chunk = nextChunk(src); if (chunk <= this.fragHint) { if (this.buffer.hasData()) { final int chunk = nextChunk(src); if (this.buffer.length() >= this.fragHint || chunk > 0) { if (!this.buffer.hasData()) { final int chunk = nextChunk(src); if (chunk > this.fragHint) {