#11932 make succeeded and failed in ICB final + introduce onSuccess
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
parent
3091012393
commit
6d0bddc07a
|
@ -347,17 +347,10 @@ public class ContentDocs
|
|||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
protected void onSuccess()
|
||||
{
|
||||
// After every successful write, release the chunk.
|
||||
chunk.release();
|
||||
super.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable x)
|
||||
{
|
||||
super.failed(x);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -347,17 +347,10 @@ public class ContentDocs
|
|||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
protected void onSuccess()
|
||||
{
|
||||
// After every successful write, release the chunk.
|
||||
chunk.release();
|
||||
super.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable x)
|
||||
{
|
||||
super.failed(x);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -543,7 +543,7 @@ public abstract class HttpSender
|
|||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
protected void onSuccess()
|
||||
{
|
||||
boolean proceed = true;
|
||||
if (committed)
|
||||
|
@ -588,8 +588,6 @@ public abstract class HttpSender
|
|||
// There was some concurrent error, terminate.
|
||||
complete = true;
|
||||
}
|
||||
|
||||
super.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -235,17 +235,9 @@ public class HttpSenderOverHTTP extends HttpSender
|
|||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
protected void onSuccess()
|
||||
{
|
||||
release();
|
||||
super.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable x)
|
||||
{
|
||||
release();
|
||||
super.failed(x);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -259,6 +251,7 @@ public class HttpSenderOverHTTP extends HttpSender
|
|||
protected void onCompleteFailure(Throwable cause)
|
||||
{
|
||||
super.onCompleteFailure(cause);
|
||||
release();
|
||||
callback.failed(cause);
|
||||
}
|
||||
|
||||
|
|
|
@ -101,12 +101,11 @@ public class Flusher
|
|||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
protected void onSuccess()
|
||||
{
|
||||
if (active != null)
|
||||
active.succeeded();
|
||||
active = null;
|
||||
super.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -294,7 +294,7 @@ public class HTTP2Flusher extends IteratingCallback implements Dumpable
|
|||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
protected void onSuccess()
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Written {} buffers - entries processed/pending {}/{}: {}/{}",
|
||||
|
@ -304,7 +304,6 @@ public class HTTP2Flusher extends IteratingCallback implements Dumpable
|
|||
processedEntries,
|
||||
pendingEntries);
|
||||
finish();
|
||||
super.succeeded();
|
||||
}
|
||||
|
||||
private void finish()
|
||||
|
|
|
@ -515,17 +515,15 @@ public class RawHTTP2ProxyTest
|
|||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
protected void onSuccess()
|
||||
{
|
||||
frameInfo.callback.succeeded();
|
||||
super.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable failure)
|
||||
protected void onCompleteFailure(Throwable cause)
|
||||
{
|
||||
frameInfo.callback.failed(failure);
|
||||
super.failed(failure);
|
||||
frameInfo.callback.failed(cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -671,17 +669,15 @@ public class RawHTTP2ProxyTest
|
|||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
protected void onSuccess()
|
||||
{
|
||||
frameInfo.callback.succeeded();
|
||||
super.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable failure)
|
||||
protected void onCompleteFailure(Throwable cause)
|
||||
{
|
||||
frameInfo.callback.failed(failure);
|
||||
super.failed(failure);
|
||||
frameInfo.callback.failed(cause);
|
||||
}
|
||||
|
||||
private void offer(Stream stream, Frame frame, Callback callback)
|
||||
|
|
|
@ -108,7 +108,7 @@ public class ControlFlusher extends IteratingCallback
|
|||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
protected void onSuccess()
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("succeeded to write {} on {}", entries, this);
|
||||
|
@ -119,8 +119,6 @@ public class ControlFlusher extends IteratingCallback
|
|||
entries.clear();
|
||||
|
||||
invocationType = InvocationType.NON_BLOCKING;
|
||||
|
||||
super.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -104,14 +104,12 @@ public class InstructionFlusher extends IteratingCallback
|
|||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
protected void onSuccess()
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("succeeded to write {} buffers on {}", accumulator.getByteBuffers().size(), this);
|
||||
|
||||
accumulator.release();
|
||||
|
||||
super.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -89,7 +89,7 @@ public class MessageFlusher extends IteratingCallback
|
|||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
protected void onSuccess()
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("succeeded to write {} on {}", entry, this);
|
||||
|
@ -98,19 +98,17 @@ public class MessageFlusher extends IteratingCallback
|
|||
|
||||
entry.callback.succeeded();
|
||||
entry = null;
|
||||
|
||||
super.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable x)
|
||||
protected void onCompleteFailure(Throwable cause)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("failed to write {} on {}", entry, this, x);
|
||||
LOG.debug("failed to write {} on {}", entry, this, cause);
|
||||
|
||||
accumulator.release();
|
||||
|
||||
entry.callback.failed(x);
|
||||
entry.callback.failed(cause);
|
||||
entry = null;
|
||||
|
||||
// Continue the iteration.
|
||||
|
|
|
@ -287,13 +287,12 @@ public class BufferedContentSink implements Content.Sink
|
|||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
protected void onSuccess()
|
||||
{
|
||||
_buffer = null;
|
||||
Callback callback = _callback;
|
||||
_callback = null;
|
||||
callback.succeeded();
|
||||
super.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -372,17 +372,9 @@ public abstract class QuicConnection extends AbstractConnection
|
|||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
protected void onSuccess()
|
||||
{
|
||||
entry.callback.succeeded();
|
||||
super.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable x)
|
||||
{
|
||||
entry.callback.failed(x);
|
||||
super.failed(x);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -394,10 +386,11 @@ public abstract class QuicConnection extends AbstractConnection
|
|||
@Override
|
||||
protected void onCompleteFailure(Throwable cause)
|
||||
{
|
||||
entry.callback.failed(cause);
|
||||
QuicConnection.this.close();
|
||||
}
|
||||
|
||||
private class Entry
|
||||
private static class Entry
|
||||
{
|
||||
private final Callback callback;
|
||||
private final SocketAddress address;
|
||||
|
|
|
@ -521,12 +521,11 @@ public abstract class QuicSession extends ContainerLifeCycle
|
|||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
protected void onSuccess()
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("written cipher bytes on {}", QuicSession.this);
|
||||
cipherBuffer.release();
|
||||
super.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -760,17 +760,11 @@ public class ConnectHandler extends Handler.Wrapper
|
|||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
protected void onSuccess()
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Wrote {} bytes {}", filled, TunnelConnection.this);
|
||||
buffer.release();
|
||||
super.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCompleteSuccess()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -237,7 +237,8 @@ public class CustomTransportTest
|
|||
channels.put(channel.id, channel);
|
||||
|
||||
// Register for read interest with the EndPoint.
|
||||
endPoint.fillInterested(new EndPointToChannelCallback(channel));
|
||||
EndPointToChannelCallback endPointToChannelCallback = new EndPointToChannelCallback(channel);
|
||||
endPoint.fillInterested(Callback.from(endPointToChannelCallback::iterate));
|
||||
}
|
||||
|
||||
// Called when there data to read from the Gateway on the given Channel.
|
||||
|
@ -322,18 +323,10 @@ public class CustomTransportTest
|
|||
endPoint.fillInterested(this);
|
||||
return Action.IDLE;
|
||||
}
|
||||
channel.write(this, buffer);
|
||||
channel.write(Callback.from(this::iterate), buffer);
|
||||
return Action.SCHEDULED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
{
|
||||
// There is data to read from the EndPoint.
|
||||
// Iterate to read it and send it to the Gateway.
|
||||
iterate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCompleteSuccess()
|
||||
{
|
||||
|
|
|
@ -167,6 +167,13 @@ public abstract class IteratingCallback implements Callback
|
|||
*/
|
||||
protected abstract Action process() throws Throwable;
|
||||
|
||||
/**
|
||||
* Invoked when one task has completed successfully.
|
||||
*/
|
||||
protected void onSuccess()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when the overall task has completed successfully.
|
||||
*
|
||||
|
@ -239,6 +246,7 @@ public abstract class IteratingCallback implements Callback
|
|||
boolean notifyCompleteSuccess = false;
|
||||
Throwable notifyCompleteFailure = null;
|
||||
|
||||
boolean callOnSuccess = false;
|
||||
// While we are processing
|
||||
processing:
|
||||
while (true)
|
||||
|
@ -247,6 +255,11 @@ public abstract class IteratingCallback implements Callback
|
|||
Action action = null;
|
||||
try
|
||||
{
|
||||
if (callOnSuccess)
|
||||
{
|
||||
onSuccess();
|
||||
callOnSuccess = false;
|
||||
}
|
||||
action = process();
|
||||
}
|
||||
catch (Throwable x)
|
||||
|
@ -309,6 +322,7 @@ public abstract class IteratingCallback implements Callback
|
|||
throw new IllegalStateException(String.format("%s[action=%s]", this, action));
|
||||
// we lost the race, so we have to keep processing
|
||||
_state = State.PROCESSING;
|
||||
callOnSuccess = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -374,7 +388,10 @@ public abstract class IteratingCallback implements Callback
|
|||
}
|
||||
}
|
||||
if (process)
|
||||
{
|
||||
onSuccess();
|
||||
processing();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -192,10 +192,9 @@ public class AsyncProxyServlet extends ProxyServlet
|
|||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable x)
|
||||
protected void onCompleteFailure(Throwable cause)
|
||||
{
|
||||
super.failed(x);
|
||||
onError(x);
|
||||
onError(cause);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -192,10 +192,9 @@ public class AsyncProxyServlet extends ProxyServlet
|
|||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable x)
|
||||
protected void onCompleteFailure(Throwable cause)
|
||||
{
|
||||
super.failed(x);
|
||||
onError(x);
|
||||
onError(cause);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue