dcapwell commented on code in PR #3493:
URL: https://github.com/apache/cassandra/pull/3493#discussion_r1731838555
##########
src/java/org/apache/cassandra/service/accord/AccordJournal.java:
##########
@@ -643,81 +654,94 @@ private void runOnce()
signal.get().signal();
}
- public void run()
+ @Override
+ public void run(Interruptible.State state) throws InterruptedException
{
- while (!Thread.currentThread().isInterrupted() &&
isRunnable(status))
+ if (state != NORMAL || !Thread.currentThread().isInterrupted() &&
!isRunnable(status))
+ return;
+
+ try
{
- try
+ Condition signal = Condition.newOneTimeCondition();
+ this.signal.set(signal);
+ // First, poll delayed requests, put them into by epoch
+ while (!delayedRequests.isEmpty())
{
- Condition signal = Condition.newOneTimeCondition();
- this.signal.set(signal);
- // First, poll delayed requests, put them into by epoch
- while (!delayedRequests.isEmpty())
+ RequestContext context = delayedRequests.poll();
+ long waitForEpoch = context.waitForEpoch;
+
+ List<RequestContext> l =
byEpoch.computeIfAbsent(waitForEpoch, (ignore) -> new ArrayList<>());
+ if (l.isEmpty())
+ waitForEpochs.pushLong(waitForEpoch);
+ l.add(context);
+ BiConsumer<Void, Throwable> withEpochCallback = new
BiConsumer<>()
{
- RequestContext context = delayedRequests.poll();
- long waitForEpoch = context.waitForEpoch;
-
- List<RequestContext> l =
byEpoch.computeIfAbsent(waitForEpoch, (ignore) -> new ArrayList<>());
- if (l.isEmpty())
- waitForEpochs.pushLong(waitForEpoch);
- l.add(context);
- BiConsumer<Void, Throwable> withEpochCallback = new
BiConsumer<>()
+ @Override
+ public void accept(Void unused, Throwable
withEpochFailure)
{
- @Override
- public void accept(Void unused, Throwable
withEpochFailure)
+ if (withEpochFailure != null)
{
- if (withEpochFailure != null)
+ // Nothing to do but keep waiting
+ if (withEpochFailure instanceof Timeout)
{
- // Nothing to do but keep waiting
- if (withEpochFailure instanceof Timeout)
- {
- node.withEpoch(waitForEpoch, this);
- return;
- }
- else
- throw new
RuntimeException(withEpochFailure);
+ node.withEpoch(waitForEpoch, this);
+ return;
}
- runOnce();
+ else
+ throw new
RuntimeException(withEpochFailure);
}
- };
- node.withEpoch(waitForEpoch, withEpochCallback);
- }
+ runOnce();
+ }
+ };
+ node.withEpoch(waitForEpoch, withEpochCallback);
+ }
- // Next, process all delayed epochs
- for (int i = 0; i < waitForEpochs.size(); i++)
+ // Next, process all delayed epochs
+ for (int i = 0; i < waitForEpochs.size(); i++)
+ {
+ long epoch = waitForEpochs.getLong(i);
+ if (node.topology().hasEpoch(epoch))
{
- long epoch = waitForEpochs.getLong(i);
- if (node.topology().hasEpoch(epoch))
+ List<RequestContext> requests = byEpoch.remove(epoch);
+ assert requests != null : String.format("%s %s (%d)",
byEpoch, waitForEpochs, epoch);
+ for (RequestContext request : requests)
{
- List<RequestContext> requests =
byEpoch.remove(epoch);
- assert requests != null : String.format("%s %s
(%d)", byEpoch, waitForEpochs, epoch);
- for (RequestContext request : requests)
+ try
{
- try
- {
- request.process(node, endpointMapper);
- }
- catch (Throwable t)
- {
- logger.error(String.format("Caught an
exception while processing a delayed request %s", request), t);
- }
+ request.process(node, endpointMapper);
+ }
+ catch (Throwable t)
+ {
+ logger.error(String.format("Caught an
exception while processing a delayed request %s", request), t);
Review Comment:
```suggestion
logger.error("Caught an exception while
processing a delayed request {}", request, t);
```
I don't know why I keep seeing people use `String.format` w/e there is an
exception... slf4j supports this case just fine...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]