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
Add support for registering custom circuit breaker #8795
Conversation
@dakrone what do you think about this PR? |
@clintongormley I am planning on looking at it |
@seut I like the idea of registering breakers, and that plugins could register their own breakers. I have some ideas about this though: I think instead of having to register a name, and then registering the breaker, I think it would be better if we do it all in the register breaker method (since we have access to I think we can remove the built in breaker list, and then in the constructor for If the registerBreaker method rebuilds the |
@dakrone Thanks for looking at it! Yes I'd prefer to register the names inside the And yes I've thought to refactor it so built-in breakers would be registered by the new |
I think we can move to For the synchronized breaker map, I think it is fine to move to a |
I thought about changing |
If this is a 2.0 change only, you can change the streaming of it (since 2.0 requires a restart). If this goes to 1.x you can use the |
@dakrone After thinking again about the |
Sorry, I wasn't clear when I talked about changing the streaming, your solution is what I was suggesting. If you want to target 1.x you'll need to add backwards compatibility (using the |
@dakrone just pushed a fixup commit including all discussed changes. will squash it if everything is fine now. |
@dakrone ah yeah and I will create another PR for a 1.x backport of this once this PR is accepted |
} | ||
public static final String PARENT = "PARENT"; | ||
public static final String FIELDDATA = "FIELDDATA"; | ||
public static final String REQUEST = "REQUEST"; |
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 think it's okay to make these lowercase now that they aren't enums
@seut I added a couple of comments, but this is looking good! I also think it would be extremely useful to add an integration test for this to test that breaker stats correctly include custom circuit breakers. You should be able to put it in Iterable<CircuitBreakerService> serviceIter = internalCluster().getInstances(CircuitBreakerService.class);
for (CircuitBreakerService s : serviceIter) {
s.registerBreaker(...);
}
// Maybe increment the breaker here
NodesStatsResponse resp = client().admin().cluster().prepareNodesStats().clear().setBreaker(true).get();
// Check response to get the circuit breaker service, then you can register a custom breaker and issue a nodes stats to ensure that the stats include the custom breaker (you can also increment/decrement the breaker there). Does that make sense? I'm happy to help if not. |
@dakrone pushed a fixup including all discussed changes + an integration test. because ConcurrentMap.replace() does not support null values, I had to implement it slightly different to harden it against race conditions of concurrent calls. please let me know if you see any other issues. thx! |
any review news? ;) |
@seut I'm looking at this and hoping to merge it in today, sorry for taking so long |
ah wanted to squash my review fixups first, but anyway, thanks for merging! :) |
Thanks for submitting the feature! |
This PR adds support for registering custom circuit breakers besides PARENT, REQUEST and FIELDDATA.
We needed to account memory consumption of different contexts than request or fielddata caches, but of course, this makes only sense by hooking up a new circuit breaker into the breaker hierarchy.
Maybe this is also interesting for someone else like plugin developers.