gaozhangmin commented on a change in pull request #12025:
URL: https://github.com/apache/pulsar/pull/12025#discussion_r790434237
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
##########
@@ -1480,22 +1485,77 @@ public void openLedgerFailed(ManagedLedgerException
exception, Object ctx) {
);
}
-
ManagedLedgerConfig managedLedgerConfig = new
ManagedLedgerConfig();
managedLedgerConfig.setEnsembleSize(persistencePolicies.getBookkeeperEnsemble());
managedLedgerConfig.setWriteQuorumSize(persistencePolicies.getBookkeeperWriteQuorum());
managedLedgerConfig.setAckQuorumSize(persistencePolicies.getBookkeeperAckQuorum());
- if (localPolicies.isPresent() &&
localPolicies.get().bookieAffinityGroup != null) {
- managedLedgerConfig
- .setBookKeeperEnsemblePlacementPolicyClassName(
-
IsolatedBookieEnsemblePlacementPolicy.class);
- Map<String, Object> properties = Maps.newHashMap();
-
properties.put(IsolatedBookieEnsemblePlacementPolicy.ISOLATION_BOOKIE_GROUPS,
-
localPolicies.get().bookieAffinityGroup.getBookkeeperAffinityGroupPrimary());
-
properties.put(IsolatedBookieEnsemblePlacementPolicy.SECONDARY_ISOLATION_BOOKIE_GROUPS,
-
localPolicies.get().bookieAffinityGroup.getBookkeeperAffinityGroupSecondary());
-
managedLedgerConfig.setBookKeeperEnsemblePlacementPolicyProperties(properties);
+
+ if (serviceConfig.isStrictBookieAffinityEnabled()) {
+ try {
+ Optional<GetResult> racksData =
+ this.pulsar.getLocalMetadataStore().
+
get(ZkBookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH).join();
+ if (racksData.isPresent()) {
+ BookiesRackConfiguration
allGroupsBookieMapping =
+ ObjectMapperFactory.getThreadLocal().
+
readValue(racksData.get().getValue(), BookiesRackConfiguration.class);
+ if (allGroupsBookieMapping.size() > 0) {
+ managedLedgerConfig
+
.setBookKeeperEnsemblePlacementPolicyClassName(
+
ZkIsolatedBookieEnsemblePlacementPolicy.class);
+ if (localPolicies.isPresent()
+ &&
localPolicies.get().bookieAffinityGroup != null) {
+ Map<String, Object> properties =
Maps.newHashMap();
+
properties.put(ZkIsolatedBookieEnsemblePlacementPolicy
+
.ISOLATION_BOOKIE_GROUPS,
+
localPolicies.get().bookieAffinityGroup
+
.getBookkeeperAffinityGroupPrimary());
+
properties.put(ZkIsolatedBookieEnsemblePlacementPolicy
+
.SECONDARY_ISOLATION_BOOKIE_GROUPS,
+
localPolicies.get().bookieAffinityGroup
+
.getBookkeeperAffinityGroupSecondary());
+ managedLedgerConfig.
+
setBookKeeperEnsemblePlacementPolicyProperties(properties);
+ } else if
(namespace.getTenant().equals("pulsar")) {
+ Map<String, Object> properties =
Maps.newHashMap();
+
properties.put(ZkIsolatedBookieEnsemblePlacementPolicy
+ .ISOLATION_BOOKIE_GROUPS, "*");
+
properties.put(ZkIsolatedBookieEnsemblePlacementPolicy
+
.SECONDARY_ISOLATION_BOOKIE_GROUPS, "*");
+ managedLedgerConfig.
+
setBookKeeperEnsemblePlacementPolicyProperties(properties);
+ } else {
+ Map<String, Object> properties =
Maps.newHashMap();
+
properties.put(ZkIsolatedBookieEnsemblePlacementPolicy
+ .ISOLATION_BOOKIE_GROUPS, "");
+
properties.put(ZkIsolatedBookieEnsemblePlacementPolicy
+
.SECONDARY_ISOLATION_BOOKIE_GROUPS, "");
+ managedLedgerConfig.
+
setBookKeeperEnsemblePlacementPolicyProperties(properties);
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.error("Error getting bookie isolation info
from zk");
+ throw new IllegalStateException(e);
Review comment:
this is from eolivelli's review.
we should fail,
otherwise the broker will continue with a wrong configuration
and we will push the data to the wrong bookies probably
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]