in src/main/java/org/apache/pulsar/manager/service/impl/EnvironmentCacheServiceImpl.java [182:206]
public void reloadEnvironment(EnvironmentEntity environment) {
List<String> clustersList;
try {
clustersList = pulsarAdminService.clusters(environment.getBroker()).getClusters();
} catch(PulsarAdminException e) {
PulsarAdminOperationException pulsarAdminOperationException
= new PulsarAdminOperationException("Failed to get clusters list.");
log.error(pulsarAdminOperationException.getMessage(), e);
throw pulsarAdminOperationException;
}
log.info("Reload cluster list for environment {} : {}", environment.getName(), clustersList);
Set<String> newClusters = Sets.newHashSet(clustersList);
Map<String, ClusterData> clusterDataMap = environments.computeIfAbsent(
environment.getName(),
(e) -> new ConcurrentHashMap<>());
Set<String> oldClusters = clusterDataMap.keySet();
Set<String> goneClusters = Sets.difference(oldClusters, newClusters);
for (String cluster : goneClusters) {
log.info("Remove cluster {} from environment {}.", cluster, environment.getName());
clusterDataMap.remove(cluster);
}
for (String cluster : clustersList) {
reloadCluster(environment, cluster);
}
}