-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pool can have a companion ticker thread #236
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me. LogTicker
should be great for debugging.
ticker.close(); | ||
} | ||
}; | ||
this.pool.execute(ticker); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing to note here. When using the Pool
with a Runnable
, it fails fast if the Runnable
throws an exception. So you could have a case where the ticker
throws an exception before the queue
method even gets to the next line.
I'd be curious to see what happens if you test this with a Ticker
implementation that looks like:
public class ExceptionTicker extends Ticker
{
public ExceptionTicker(final String name, final Duration tickerTime)
{
super(name, tickerTime);
}
@Override
protected void tickAction(final Duration sinceStart)
{
throw new RuntimeException("Error!");
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I follow here... What I have is a wrapper that makes sure to tell the ticker thread to stop when the initial command failed. I don't think the ticker itself needs to throw an exception, it can just stop... Here the try block does not have a catch, so the command would still push its own exception even after the ticker is closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually you are right, let me add ticker error handling!
Rhaaaaaa! |
logger.info("{}: {}", getName(), sinceStart); | ||
if ("Ticker 3".equals(getName())) | ||
{ | ||
throw new CoreException("I am rogue Ticker 3"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hahaha "rogue ticker" I love this :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice functionality and tests!
Description:
This change brings the ability to schedule a companion ticker thread that allows time-based reporting on the initial Runnable or Callable execution.
Potential Impact:
No impact, it is a new feature.
Unit Test Approach:
Tested the new option with Callable and Runnable, and made sure they still report errors properly.
Test Results:
Companion thread has the same lifespan as other thread.
In doubt: Contributing Guidelines