@Override public void close() throws IOException { log.info("Shutting down Pulsar Broker service"); if (pulsar.getConfigurationCache() != null) { pulsar.getConfigurationCache().policiesCache().unregisterListener(this); } // unloads all namespaces gracefully without disrupting mutually unloadNamespaceBundlesGracefully(); // close replication clients replicationClients.forEach((cluster, client) -> { try { client.shutdown(); } catch (PulsarClientException e) { log.warn("Error shutting down repl client for cluster {}", cluster, e); } }); acceptorGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); statsUpdater.shutdown(); inactivityMonitor.shutdown(); messageExpiryMonitor.shutdown(); compactionMonitor.shutdown(); backlogQuotaChecker.shutdown(); authenticationService.close(); pulsarStats.close(); ClientCnxnAspect.removeListener(zkStatsListener); ClientCnxnAspect.registerExecutor(null); topicOrderedExecutor.shutdown(); log.info("Broker service completely shut down"); }