-
Notifications
You must be signed in to change notification settings - Fork 604
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 BrokerSetAwareGoal #1809
Add BrokerSetAwareGoal #1809
Conversation
Thanks for the PR @mohitpali -- quick note, looks like there are some JavaDoc formatting issues -- i.e.
|
Done |
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
cruise-control/src/test/java/com/linkedin/kafka/cruisecontrol/common/DeterministicCluster.java
Outdated
Show resolved
Hide resolved
cruise-control/src/test/java/com/linkedin/kafka/cruisecontrol/common/DeterministicCluster.java
Show resolved
Hide resolved
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.
@mohitpali Thanks for the PR!
I started the review and left some comments. I am midway through the review.
...se-control/src/main/java/com/linkedin/kafka/cruisecontrol/config/BrokerSetFileDataStore.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
cruise-control/src/main/java/com/linkedin/kafka/cruisecontrol/config/BrokerSetDataHelper.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
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.
Added more comments -- will continue the review.
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
Hi @mohitpali , while you're updating the PR, I have some thoughts here to discuss/confirm with you. Essentially here we need to solve 3 problems:
For Prob.1, this PR provides a static file. For Prob.2, this PR decides to move topic to it's original broker set, making an assumption of topic lives within a broker set at creation time.
For Prob.3, this PR allows the replicas goes to any eligible brokers in the target broker set. This looks fine for me. Given the above observation, we may need to provide some pluggable component to solve Prob.1 and Prob.2. These are my current understanding. @mohitpali @efeg Please feel free to share your thoughts about it! |
18fbc4b
to
0c5b037
Compare
I think this sounds correct. The outstanding issue is the topic to BrokerSet mapping policy - I will look into this. |
cruise-control/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/BalancingConstraint.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Show resolved
Hide resolved
.../src/main/java/com/linkedin/kafka/cruisecontrol/config/DefaultBrokerSetAssignmentPolicy.java
Outdated
Show resolved
Hide resolved
0c5b037
to
773a836
Compare
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Show resolved
Hide resolved
773a836
to
4538f6e
Compare
cruise-control/src/main/java/com/linkedin/kafka/cruisecontrol/config/BrokerSetFileResolver.java
Outdated
Show resolved
Hide resolved
cruise-control/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/BalancingConstraint.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Show resolved
Hide resolved
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.
Thanks for the updates -- left some comments.
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
// If the brokerSet awareness condition is violated. Move replica to an eligible broker | ||
Set<Broker> eligibleBrokers = _brokersByBrokerSet.get(eligibleBrokerSetIdForReplica) | ||
.stream() | ||
.filter(b -> clusterModel.aliveBrokers().contains(b)) |
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 we change _brokersByBrokerSet
with something like _aliveBrokersByBrokerSet
? That way we can drop the need for filtering here. As far as I can tell we never use brokers that are no alive for this goal.
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 tried filtering this on the BrokerSetResolverHelper but the ExcludedBrokersForLeaderShipTest fails since it marks excluded brokers as dead and clusterModel.aliveBrokers() do not contain the excluded broker for leadership.
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.
2 questions:
- Could you point me to where it marks excluded brokers as dead?
- Even if clusterModel.aliveBrokers() does not contain excluded broker, the test should succeed? E.g. if you have enough alive brokers, I don't see the reason why this goal can fail.
...control/src/main/java/com/linkedin/kafka/cruisecontrol/config/BrokerSetResolutionHelper.java
Outdated
Show resolved
Hide resolved
...c/main/java/com/linkedin/kafka/cruisecontrol/config/TopicNameHashBrokerSetMappingPolicy.java
Outdated
Show resolved
Hide resolved
...c/main/java/com/linkedin/kafka/cruisecontrol/config/TopicNameHashBrokerSetMappingPolicy.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
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.
Made a full pass - left a few more comments.
...c/main/java/com/linkedin/kafka/cruisecontrol/config/TopicNameHashBrokerSetMappingPolicy.java
Outdated
Show resolved
Hide resolved
...-control/src/main/java/com/linkedin/kafka/cruisecontrol/config/constants/AnalyzerConfig.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
...-control/src/test/java/com/linkedin/kafka/cruisecontrol/KafkaCruiseControlUnitTestUtils.java
Outdated
Show resolved
Hide resolved
...c/test/java/com/linkedin/kafka/cruisecontrol/analyzer/ExcludedBrokersForReplicaMoveTest.java
Show resolved
Hide resolved
4538f6e
to
96fd464
Compare
Hi @mohitpali , I just realized another issue during my testing. It turns out that BrokerSetAwareGoal will naturally conflict with MinTopicLeadersPerBrokerGoal, as MinTopicLeadersPerBrokerGoal requires the topic exists on all brokers. As a result, optimization would fail whenever both goals are added as hard goals. I'm wondering if it's a good idea to exclude the topics defined in topics.with.min.leaders.per.broker when we do replica movements in BrokerSetAwareGoal. @efeg fyi. |
Another observation is: if a broker dies, BrokerAwareGoal is still trying to rebalance for that broker. This is arguable. When I implement my custom BrokerSetResolver, I would only color the alive brokers. With my implementation, today it's throwing "Failed to resolve BrokerSet for Broker Broker[id=XXX,rack=,state=DEAD" exception when the broker is dead. I'm wondering if one should always assign all brokers with a color, dead or alive, in the custom BrokerSetResolver. If that's the case, maybe we can add something in the java doc in the BrokerSetResolver interface like "All brokers including dead ones should be assigned with a color". (And sorry I accidentally closed the PR and reopened it... Hope that doesn't break anything) |
I think it is because of below code -
The reason the above code was introduced was since if a brokerSetId is ever found to be null, we would not be able to map the brokers for a brokerSetId. In your case I suspect since the Broker object changed during the goal run (state went from ALIVE to DEAD), the cached map did not have the mapping
I can modify it to instead map by BrokerId, and if the Broker object state has changed, it wouldn't throw this exception. There could be other cases like race condition where during the goal run, a broker is added on the cluster but the brokerSet map does not have information on it. The BrokerSet resolution and ClusterModel's list of brokers may not match during this time. I would assume that a good brokerSet resolver is dynamic and even if a race condition fails optimization, next iteration of optimization will get fixed if the info has synched up. |
96fd464
to
1750369
Compare
I have excluded the topics with regex for MinTopicLeadersPerBrokerGoal |
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Outdated
Show resolved
Hide resolved
...ontrol/src/main/java/com/linkedin/kafka/cruisecontrol/analyzer/goals/BrokerSetAwareGoal.java
Show resolved
Hide resolved
We should add this goal to cruisecontrol.properties, in the goals properties. Make sure not adding this to default.goals and hard.goals. |
Hi @mohitpali, I think there's a change needed in AnalyzerConfig to match the change in your latest commit. E.g. add the goal in the static DEFAULT_GOALS string. It should reflect/match the default values for "goals" property. |
Hi @mohitpali, I know this is closed, but would like to ask your opinion on this: Do you think it would be a good idea to "write back" the broker assignment to brokerSet.json file? That case no matter we have the original file or not, we can create/update the latest broker assignment info to that file, and then read it from anywhere we want. |
This PR resolves #1782
Currently, cruise-control does not have a way to limit the leader and replica movement plan within a Broker Group. We would like to make cruise-control aware of the Broker Groups and propose optimizations where each optimization does leader movement or replica movement within a Broker Group. In short, each optimization should be limited within the boundary of Broker Group.
In this PR :
BrokerSetAwareGoal
(Hard Goal).BrokerSetDataStore
interface.BrokerSet
Information calledBrokerSetFileDataStore