-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Select broker based on query context parameter brokerService
#11495
Select broker based on query context parameter brokerService
#11495
Conversation
brokerServiceName
and corresponding broker selector strategybrokerServiceName
and corresponding broker selector strategy
brokerServiceName
and corresponding broker selector strategybrokerService
and corresponding broker selector strategy
brokerService
and corresponding broker selector strategybrokerService
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.
@kfaraz - LGTM except some minor comments. can we rename queryContext
strategy to something less implementation specific e.g. manual
?
if (isValidBrokerService(contextBrokerService, tierConfig)) { | ||
// If the broker service in the query context is valid, use that | ||
return Optional.of(contextBrokerService); | ||
} else if (isValidBrokerService(fallbackBrokerService, tierConfig)) { |
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.
could we perform this check in the constructor itself? your class would have Optional broker that would either be Optional.absent() or Optional.of(fallbackBrokerService). you can return the field as it is.
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.
We don't have the TieredBrokerConfig
in the constructor, because the object is being constructed from deserialization of config and not by Guice.
docs/design/router.md
Outdated
@@ -109,6 +109,19 @@ Including this strategy means all timeBoundary queries are always routed to the | |||
|
|||
Queries with a priority set to less than minPriority are routed to the lowest priority Broker. Queries with priority set to greater than maxPriority are routed to the highest priority Broker. By default, minPriority is 0 and maxPriority is 1. Using these default values, if a query with priority 0 (the default query priority is 0) is sent, the query skips the priority selection logic. | |||
|
|||
#### queryContext | |||
|
|||
This strategy reads the parameter `brokerService` from the query context and routes the query accordingly. If no valid `brokerService` is specified in the query context, the field `fallbackBrokerService` is used if set to a valid non-null value. |
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.
can we call fallbackBrokerService
defaultBrokerService
instead? Latter looks more common in druid codebase.
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.
Renamed to defaultManualBrokerService
Co-authored-by: Abhishek Agarwal <1477457+abhishekagarwal87@users.noreply.github.com>
server/src/main/java/org/apache/druid/server/router/ManualTieredBrokerSelectorStrategy.java
Outdated
Show resolved
Hide resolved
// If the fallbackBrokerService is valid, use that | ||
return Optional.of(defaultManualBrokerService); | ||
} else { | ||
log.debug( |
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.
Should this be error level or at least warning to indicate that some config (either queryContext and/or defaultManualBrokerService) are set incorrect?
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.
Fixed.
```json | ||
{ | ||
"type": "manual", | ||
"defaultManualBrokerService": "druid:broker-hot" |
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.
is defaultManualBrokerService required?
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.
No, it is an optional field.
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.
Minor comments but overall LGTM
…uid into select_broker_by_query_context
Merging since CI failure (kafka integration test) is unrelated |
Description
This change allows the selection of a specific broker service (or broker tier) by the Router.
The newly added
ManualTieredBrokerSelectorStrategy
works as follows:brokerService
in the query context. If this is a valid broker service, use it.defaultManualBrokerService
has been set in the strategy. If this is a valid broker service, use it.Changes in this PR
ManualTieredBrokerSelectorStrategy
brokerService
inQueryContexts
This PR has: