There is just one tenant listener, remove list
@@ -95,7 +95,7 @@ public class TenantRepository {
private final Map<TenantName, Tenant> tenants = Collections.synchronizedMap(new LinkedHashMap<>());
private final Locks<TenantName> tenantLocks = new Locks<>(1, TimeUnit.MINUTES);
private final HostRegistry hostRegistry;
- private final List<TenantListener> tenantListeners = Collections.synchronizedList(new ArrayList<>());
+ private final TenantListener tenantListener;
private final Curator curator;
private final Metrics metrics;
private final MetricUpdater metricUpdater;
@@ -112,7 +112,6 @@ public class TenantRepository {
private final ModelFactoryRegistry modelFactoryRegistry;
private final ConfigDefinitionRepo configDefinitionRepo;
private final ReloadListener reloadListener;
- private final TenantListener tenantListener;
private final ExecutorService bootstrapExecutor;
private final ScheduledExecutorService checkForRemovedApplicationsService =
new ScheduledThreadPoolExecutor(1, new DaemonThreadFactory("check for removed applications"));
@@ -179,7 +178,6 @@ public class TenantRepository {
this.curator = curator;
this.metrics = metrics;
metricUpdater = metrics.getOrCreateMetricUpdater(Collections.emptyMap());
- this.tenantListeners.add(tenantListener);
this.zkCacheExecutor = zkCacheExecutor;
this.zkWatcherExecutor = zkWatcherExecutor;
this.fileDistributionFactory = fileDistributionFactory;
@@ -213,10 +211,8 @@ public class TenantRepository {
}
private void notifyTenantsLoaded() {
- for (TenantListener tenantListener : tenantListeners) {
tenantListener.onTenantsLoaded();
}
- }
public Tenant addTenant(TenantName tenantName) {
try (Lock lock = tenantLocks.lock(tenantName)) {
@@ -376,15 +372,11 @@ public class TenantRepository {
}
private void notifyNewTenant(Tenant tenant) {
- for (TenantListener listener : tenantListeners) {
- listener.onTenantCreate(tenant);
- }
+ tenantListener.onTenantCreate(tenant);
}
private void notifyRemovedTenant(TenantName name) {
- for (TenantListener listener : tenantListeners) {
- listener.onTenantDelete(name);
- }
+ tenantListener.onTenantDelete(name);
}
/**
