eolivelli commented on a change in pull request #12025:
URL: https://github.com/apache/pulsar/pull/12025#discussion_r716678271
##########
File path:
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerBookieIsolationTest.java
##########
@@ -264,6 +264,152 @@ public void testBookieIsolation() throws Exception {
assertEquals(clientConf.getProperty(REPP_DNS_RESOLVER_CLASS),
ZkBookieRackAffinityMapping.class.getName());
}
+ @Test
Review comment:
can you please add a comment that explains why this test is different ?
in one line what it is "strict bookie isolation"
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
##########
@@ -1336,22 +1340,70 @@ 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(
-
ZkIsolatedBookieEnsemblePlacementPolicy.class);
- 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);
+
+ if (serviceConfig.isStrictBookieAffinityEnabled()) {
+ Optional<GetResult> racksData =
+ this.pulsar.getLocalMetadataStore().
+
get(ZkBookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH).join();
+ if (racksData.isPresent()) {
+ try {
+ 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 {
+ 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.warn("Error getting bookie isolation info
from zk", e);
Review comment:
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]