Skip to content

Commit

Permalink
Issue #12023 - Remove WriteFlusher.Listener.
Browse files Browse the repository at this point in the history
WriteFlusher.Listener functionality was removed, and the class deprecated in 12.0.10 as part of the work for #9778 and #11839.

Signed-off-by: Simone Bordet <[email protected]>
  • Loading branch information
sbordet committed Jul 19, 2024
1 parent a0d8f07 commit b267345
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,6 @@ protected ByteBuffer[] flush(SocketAddress address, ByteBuffer[] buffers) throws
if (LOG.isDebugEnabled())
LOG.debug("Flushed={} written={} remaining={} {}", flushed, written, after, this);

if (written > 0)
{
Connection connection = _endPoint.getConnection();
if (connection instanceof Listener listener)
listener.onFlushed(written);
}

if (flushed)
return null;

Expand Down Expand Up @@ -577,30 +570,4 @@ public String toString()
State s = _state.get();
return String.format("WriteFlusher@%x{%s}->%s", hashCode(), s, s instanceof PendingState ? ((PendingState)s)._callback : null);
}

/**
* <p>A listener of {@link WriteFlusher} events.
* If implemented by a Connection class, the {@link #onFlushed(long)} event will be delivered to it.</p>
*
* @deprecated functionality removed, no replacement
*/
@Deprecated(since = "12.0.10", forRemoval = true)
public interface Listener
{
/**
* <p>Invoked when a {@link WriteFlusher} flushed bytes in a non-blocking way,
* as part of a - possibly larger - write.</p>
* <p>This method may be invoked multiple times, for example when writing a large
* buffer: a first flush of bytes, then the connection became TCP congested, and
* a subsequent flush of bytes when the connection became writable again.</p>
* <p>This method is never invoked concurrently, but may be invoked by different
* threads, so implementations may not rely on thread-local variables.</p>
* <p>Implementations may throw an {@link IOException} to signal that the write
* should fail, for example if the implementation enforces a minimum data rate.</p>
*
* @param bytes the number of bytes flushed
* @throws IOException if the write should fail
*/
void onFlushed(long bytes) throws IOException;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
import java.util.concurrent.CancellationException;
import java.util.concurrent.TimeUnit;

import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletOutputStream;
Expand Down Expand Up @@ -1244,30 +1243,6 @@ public void setBufferSize(int size)
_commitSize = size;
}

/**
* <p>Invoked when bytes have been flushed to the network.</p>
*
* @param bytes the number of bytes flushed
* @throws IOException if the minimum data rate, when set, is not respected
* @see org.eclipse.jetty.io.WriteFlusher.Listener
*/
public void onFlushed(long bytes) throws IOException
{
if (_firstByteNanoTime == -1 || _firstByteNanoTime == Long.MAX_VALUE)
return;
long minDataRate = _servletChannel.getConnectionMetaData().getHttpConfiguration().getMinResponseDataRate();
_flushed += bytes;
long minFlushed = minDataRate * NanoTime.millisSince(_firstByteNanoTime) / TimeUnit.SECONDS.toMillis(1);
if (LOG.isDebugEnabled())
LOG.debug("Flushed bytes min/actual {}/{}", minFlushed, _flushed);
if (_flushed < minFlushed)
{
IOException ioe = new IOException(String.format("Response content data rate < %d B/s", minDataRate));
_servletChannel.abort(ioe);
throw ioe;
}
}

public void recycle()
{
try (AutoLock ignored = _channelState.lock())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
import java.util.concurrent.CancellationException;
import java.util.concurrent.TimeUnit;

import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletOutputStream;
Expand Down Expand Up @@ -1246,30 +1245,6 @@ public void setBufferSize(int size)
_commitSize = size;
}

/**
* <p>Invoked when bytes have been flushed to the network.</p>
*
* @param bytes the number of bytes flushed
* @throws IOException if the minimum data rate, when set, is not respected
* @see org.eclipse.jetty.io.WriteFlusher.Listener
*/
public void onFlushed(long bytes) throws IOException
{
if (_firstByteNanoTime == -1 || _firstByteNanoTime == Long.MAX_VALUE)
return;
long minDataRate = _servletChannel.getConnectionMetaData().getHttpConfiguration().getMinResponseDataRate();
_flushed += bytes;
long minFlushed = minDataRate * NanoTime.millisSince(_firstByteNanoTime) / TimeUnit.SECONDS.toMillis(1);
if (LOG.isDebugEnabled())
LOG.debug("Flushed bytes min/actual {}/{}", minFlushed, _flushed);
if (_flushed < minFlushed)
{
IOException ioe = new IOException(String.format("Response content data rate < %d B/s", minDataRate));
_servletChannel.abort(ioe);
throw ioe;
}
}

public void recycle()
{
try (AutoLock ignored = _channelState.lock())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
import java.util.concurrent.CancellationException;
import java.util.concurrent.TimeUnit;

import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletOutputStream;
Expand Down Expand Up @@ -1418,35 +1417,6 @@ public void setBufferSize(int size)
_commitSize = size;
}

/**
* <p>Invoked when bytes have been flushed to the network.</p>
* <p>The number of flushed bytes may be different from the bytes written
* by the application if an {@link Interceptor} changed them, for example
* by compressing them.</p>
*
* @param bytes the number of bytes flushed
* @throws IOException if the minimum data rate, when set, is not respected
* @see org.eclipse.jetty.io.WriteFlusher.Listener
*/
public void onFlushed(long bytes) throws IOException
{
// TODO not called.... do we need this now?
if (_firstByteNanoTime == -1 || _firstByteNanoTime == Long.MAX_VALUE)
return;
long minDataRate = getHttpChannel().getHttpConfiguration().getMinResponseDataRate();
_flushed += bytes;
long elapsed = NanoTime.since(_firstByteNanoTime);
long minFlushed = minDataRate * TimeUnit.NANOSECONDS.toMillis(elapsed) / TimeUnit.SECONDS.toMillis(1);
if (LOG.isDebugEnabled())
LOG.debug("Flushed bytes min/actual {}/{}", minFlushed, _flushed);
if (_flushed < minFlushed)
{
IOException ioe = new IOException(String.format("Response content data rate < %d B/s", minDataRate));
_channel.abort(ioe);
throw ioe;
}
}

public void recycle()
{
try (AutoLock l = _channelState.lock())
Expand Down

0 comments on commit b267345

Please sign in to comment.