diff --git a/managed-ledger/src/test/java/org/apache/zookeeper/MockZooKeeper.java b/managed-ledger/src/test/java/org/apache/zookeeper/MockZooKeeper.java index 488ec07fcfc92..d3493d0940313 100644 --- a/managed-ledger/src/test/java/org/apache/zookeeper/MockZooKeeper.java +++ b/managed-ledger/src/test/java/org/apache/zookeeper/MockZooKeeper.java @@ -62,12 +62,16 @@ public class MockZooKeeper extends ZooKeeper { private long sessionId = 0L; public static MockZooKeeper newInstance() { + return newInstance(null); + } + + public static MockZooKeeper newInstance(ExecutorService executor) { try { ReflectionFactory rf = ReflectionFactory.getReflectionFactory(); Constructor objDef = Object.class.getDeclaredConstructor(new Class[0]); Constructor intConstr = rf.newConstructorForSerialization(MockZooKeeper.class, objDef); MockZooKeeper zk = MockZooKeeper.class.cast(intConstr.newInstance()); - zk.init(); + zk.init(executor); return zk; } catch (RuntimeException e) { throw e; @@ -76,9 +80,13 @@ public static MockZooKeeper newInstance() { } } - private void init() { + private void init(ExecutorService executor) { tree = Maps.newTreeMap(); - executor = Executors.newFixedThreadPool(1, new DefaultThreadFactory("mock-zookeeper")); + if (executor != null) { + this.executor = executor; + } else { + this.executor = Executors.newFixedThreadPool(1, new DefaultThreadFactory("mock-zookeeper")); + } SetMultimap w = HashMultimap.create(); watchers = Multimaps.synchronizedSetMultimap(w); stopped = false; diff --git a/pulsar-broker/src/main/java/com/yahoo/pulsar/broker/admin/Clusters.java b/pulsar-broker/src/main/java/com/yahoo/pulsar/broker/admin/Clusters.java index 65f8ccf10f7ec..b636258b177a4 100644 --- a/pulsar-broker/src/main/java/com/yahoo/pulsar/broker/admin/Clusters.java +++ b/pulsar-broker/src/main/java/com/yahoo/pulsar/broker/admin/Clusters.java @@ -125,7 +125,9 @@ public void updateCluster(@PathParam("cluster") String cluster, ClusterData clus validatePoliciesReadOnlyAccess(); try { - globalZk().setData(path("clusters", cluster), jsonMapper().writeValueAsBytes(clusterData), -1); + String clusterPath = path("clusters", cluster); + globalZk().setData(clusterPath, jsonMapper().writeValueAsBytes(clusterData), -1); + globalZkCache().invalidate(clusterPath); log.info("[{}] Updated cluster {}", clientAppId(), cluster); } catch (KeeperException.NoNodeException e) { log.warn("[{}] Failed to update cluster {}: Does not exist", clientAppId(), cluster); @@ -186,8 +188,9 @@ public void deleteCluster(@PathParam("cluster") String cluster) { } try { - globalZk().delete(path("clusters", cluster), -1); - clustersCache().invalidate(path("clusters", cluster)); + String clusterPath = path("clusters", cluster); + globalZk().delete(clusterPath, -1); + globalZkCache().invalidate(clusterPath); log.info("[{}] Deleted cluster {}", clientAppId(), cluster); } catch (KeeperException.NoNodeException e) { log.warn("[{}] Failed to delete cluster {} - Does not exist", clientAppId(), cluster); diff --git a/pulsar-broker/src/main/java/com/yahoo/pulsar/broker/admin/PersistentTopics.java b/pulsar-broker/src/main/java/com/yahoo/pulsar/broker/admin/PersistentTopics.java index 782dadb72a315..f8ca0dd78b712 100644 --- a/pulsar-broker/src/main/java/com/yahoo/pulsar/broker/admin/PersistentTopics.java +++ b/pulsar-broker/src/main/java/com/yahoo/pulsar/broker/admin/PersistentTopics.java @@ -296,11 +296,12 @@ public void revokePermissionsOnDestination(@PathParam("property") String propert try { // Write the new policies to zookeeper - globalZk().setData(path("policies", property, cluster, namespace), jsonMapper().writeValueAsBytes(policies), - nodeStat.getVersion()); + String namespacePath = path("policies", property, cluster, namespace); + globalZk().setData(namespacePath, jsonMapper().writeValueAsBytes(policies), nodeStat.getVersion()); // invalidate the local cache to force update - policiesCache().invalidate(path("policies", property, cluster, namespace)); + policiesCache().invalidate(namespacePath); + globalZkCache().invalidate(namespacePath); log.info("[{}] Successfully revoke access for role {} - destination {}", clientAppId(), role, destinationUri); diff --git a/pulsar-broker/src/main/java/com/yahoo/pulsar/broker/admin/Properties.java b/pulsar-broker/src/main/java/com/yahoo/pulsar/broker/admin/Properties.java index d9b824b33b999..a79bfce4d972e 100644 --- a/pulsar-broker/src/main/java/com/yahoo/pulsar/broker/admin/Properties.java +++ b/pulsar-broker/src/main/java/com/yahoo/pulsar/broker/admin/Properties.java @@ -150,7 +150,9 @@ public void updateProperty(@PathParam("property") String property, PropertyAdmin throw new RestException(Status.CONFLICT, msg); } } - globalZk().setData(path("policies", property), jsonMapper().writeValueAsBytes(newPropertyAdmin), -1); + String propertyPath = path("policies", property); + globalZk().setData(propertyPath, jsonMapper().writeValueAsBytes(newPropertyAdmin), -1); + globalZkCache().invalidate(propertyPath); log.info("[{}] updated property {}", clientAppId(), property); } catch (RestException re) { throw re; diff --git a/pulsar-broker/src/main/java/com/yahoo/pulsar/broker/service/BrokerService.java b/pulsar-broker/src/main/java/com/yahoo/pulsar/broker/service/BrokerService.java index 800cb9e1f5b86..13ae08728bb79 100644 --- a/pulsar-broker/src/main/java/com/yahoo/pulsar/broker/service/BrokerService.java +++ b/pulsar-broker/src/main/java/com/yahoo/pulsar/broker/service/BrokerService.java @@ -279,7 +279,7 @@ public void close() throws IOException { // unloads all namespaces gracefully without disrupting mutually unloadNamespaceBundlesGracefully(); - + // close replication clients replicationClients.forEach((cluster, client) -> { try { @@ -307,12 +307,14 @@ public void close() throws IOException { *
  • Second it starts unloading namespace bundle one by one without closing the connection in order to avoid * disruption for other namespacebundles which are sharing the same connection from the same client.
  • *