Skip to content

Commit

Permalink
#11932 refactor H3 message flusher to have ICB succeeded and failed f…
Browse files Browse the repository at this point in the history
…inal

Signed-off-by: Ludovic Orban <[email protected]>
  • Loading branch information
lorban committed Jun 25, 2024
1 parent bd3bd8e commit 05356d8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected Action process()
return Action.SCHEDULED;
}

int generated = generator.generate(accumulator, entry.endPoint.getStreamId(), frame, this::failed);
int generated = generator.generate(accumulator, entry.endPoint.getStreamId(), frame, this::onGenerateFailure);
if (generated < 0)
return Action.SCHEDULED;

Expand All @@ -88,35 +88,48 @@ protected Action process()
return Action.SCHEDULED;
}

// TODO this should be onSuccess()
@Override
public void succeeded()
private void onGenerateFailure(Throwable cause)
{
if (LOG.isDebugEnabled())
LOG.debug("succeeded to write {} on {}", entry, this);
LOG.debug("failed to generate {} on {}", entry, this, cause);

accumulator.release();

entry.callback.succeeded();
entry.callback.failed(cause);
entry = null;

super.succeeded();
// Continue the iteration.
succeeded();
}

@Override
public void failed(Throwable x)
protected void onSuccess()
{
if (LOG.isDebugEnabled())
LOG.debug("failed to write {} on {}", entry, this, x);
LOG.debug("succeeded to write {} on {}", entry, this);

accumulator.release();

entry.callback.failed(x);
entry = null;
if (entry != null)
{
entry.callback.succeeded();
entry = null;
}
}

// Continue the iteration.
// TODO this is pure evil!
super.succeeded();
@Override
protected void onCompleteFailure(Throwable cause)
{
if (LOG.isDebugEnabled())
LOG.debug("failed to write {} on {}", entry, this, cause);

accumulator.release();

if (entry != null)
{
entry.callback.failed(cause);
entry = null;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ else if (notifyCompleteFailure != null)
* to call {@code super.succeeded()}.
*/
@Override
public void succeeded()
public final void succeeded()
{
boolean process = false;
try (AutoLock ignored = _lock.lock())
Expand Down Expand Up @@ -409,7 +409,7 @@ public void succeeded()
* @see #isFailed()
*/
@Override
public void failed(Throwable x)
public final void failed(Throwable x)
{
boolean failure = false;
try (AutoLock ignored = _lock.lock())
Expand Down

0 comments on commit 05356d8

Please sign in to comment.