Skip to content

Rackaware placement policy support local node awareness by hostname#4057

Merged
hangc0276 merged 3 commits into
apache:masterfrom
hangc0276:chenhang/new-ensemble-rack-aware-local-node
Sep 20, 2023
Merged

Rackaware placement policy support local node awareness by hostname#4057
hangc0276 merged 3 commits into
apache:masterfrom
hangc0276:chenhang/new-ensemble-rack-aware-local-node

Conversation

@hangc0276

Copy link
Copy Markdown
Contributor

Motivation

Rack-aware placement policies enable preference for bookies that reside in the same rack as the bookie client.

However, when resolving the local node's rack information, we use IP to resolve the rack name, which is unfriendly with k8s deployment.

bn = createDummyLocalBookieNode(InetAddress.getLocalHost().getHostAddress());

In k8s deployment, we usually use the hostname as bookieId and Pulsar broker name instead of IP, because the IP will be changed when the pods migrated to other nodes.

Modification

In order not to bring break change to the current behavior, I introduced a flag useHostnameResolveLocalNodePlacementPolicy in the BookKeeper client configuration to control whether to use the hostname to resolve the bookie client's local node rack information. The flag is false by default, which is the same behavior as the current logic.

Due to this PR doesn't introduce any break changes, I think we can cherry-pick it back to the patch releases (branch-4.14, branch-4.15 and branch-4.16)

@hangc0276

Copy link
Copy Markdown
Contributor Author

@horizonzy Please help take a look, thanks.

@horizonzy horizonzy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@hangc0276
hangc0276 merged commit abb5981 into apache:master Sep 20, 2023
@hangc0276 hangc0276 added this to the 4.17.0 milestone Oct 7, 2023
Ghatage pushed a commit to sijie/bookkeeper that referenced this pull request Jul 12, 2024
…pache#4057)

### Motivation
Rack-aware placement policies enable preference for bookies that reside in the same rack as the bookie client.
- Initiate local node by resolving the rack information
https://github.com/apache/bookkeeper/blob/5b5c05331757e7356579076970e61f119f5d34ae/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java#L207-L215
- When generating new ensembles for a ledger, the selecting algorithm will set the localNode's rack to `curRack` and select one bookie from `curRack` first 
https://github.com/apache/bookkeeper/blob/5b5c05331757e7356579076970e61f119f5d34ae/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java#L420-L426

However, when resolving the local node's rack information, we use IP to resolve the rack name, which is unfriendly with k8s deployment.
https://github.com/apache/bookkeeper/blob/5b5c05331757e7356579076970e61f119f5d34ae/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java#L209

In k8s deployment, we usually use the hostname as bookieId and Pulsar broker name instead of IP, because the IP will be changed when the pods migrated to other nodes.

### Modification
In order not to bring break change to the current behavior, I introduced a flag `useHostnameResolveLocalNodePlacementPolicy` in the BookKeeper client configuration to control whether to use the hostname to resolve the bookie client's local node rack information. The flag is `false` by default, which is the same behavior as the current logic. 

Due to this PR doesn't introduce any break changes, I think we can cherry-pick it back to the patch releases (branch-4.14, branch-4.15 and branch-4.16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants