This is an automated email from the ASF dual-hosted git repository. mmerli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push: new 2333e2c PIP-45: If they're connecting to same service, share local & config MetadataStores (#12183) 2333e2c is described below commit 2333e2cd72aa4e0f86c28855acd4ddf0254ba50b Author: Matteo Merli <mme...@apache.org> AuthorDate: Sat Sep 25 09:18:38 2021 -0700 PIP-45: If they're connecting to same service, share local & config MetadataStores (#12183) --- .../main/java/org/apache/pulsar/broker/PulsarService.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java index 32c0e0c..2596b9e 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java @@ -251,6 +251,8 @@ public class PulsarService implements AutoCloseable, ShutdownService { private TransactionBufferSnapshotService transactionBufferSnapshotService; private MetadataStore configurationMetadataStore; + private boolean shouldShutdownConfigurationMetadataStore; + private PulsarResources pulsarResources; private TransactionPendingAckStoreProvider transactionPendingAckStoreProvider; @@ -481,7 +483,7 @@ public class PulsarService implements AutoCloseable, ShutdownService { if (localMetadataStore != null) { localMetadataStore.close(); } - if (configurationMetadataStore != null) { + if (configurationMetadataStore != null && shouldShutdownConfigurationMetadataStore) { configurationMetadataStore.close(); } @@ -604,7 +606,13 @@ public class PulsarService implements AutoCloseable, ShutdownService { coordinationService = new CoordinationServiceImpl(localMetadataStore); - configurationMetadataStore = createConfigurationMetadataStore(); + if (!StringUtils.equals(config.getConfigurationStoreServers(), config.getZookeeperServers())) { + configurationMetadataStore = createConfigurationMetadataStore(); + shouldShutdownConfigurationMetadataStore = true; + } else { + configurationMetadataStore = localMetadataStore; + shouldShutdownConfigurationMetadataStore = false; + } pulsarResources = new PulsarResources(localMetadataStore, configurationMetadataStore, config.getZooKeeperOperationTimeoutSeconds());