Skip to content

Commit 3dae636

Browse files
committed
wip
1 parent 863016d commit 3dae636

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerManager.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,24 @@ public class InformerManager<T extends HasMetadata, C extends ResourceConfigurat
4646
private ResourceEventHandler<T> eventHandler;
4747
private final Map<String, Function<T, List<String>>> indexers = new HashMap<>();
4848

49+
public InformerManager(MixedOperation<T, KubernetesResourceList<T>, Resource<T>> client,
50+
C configuration,
51+
ResourceEventHandler<T> eventHandler) {
52+
this.client = client;
53+
this.configuration = configuration;
54+
this.eventHandler = eventHandler;
55+
}
56+
4957
@Override
5058
public void start() throws OperatorException {
59+
initSources();
5160
// make sure informers are all started before proceeding further
5261
sources.values().parallelStream().forEach(InformerWrapper::start);
5362
}
5463

55-
void initSources(MixedOperation<T, KubernetesResourceList<T>, Resource<T>> client,
56-
C configuration, ResourceEventHandler<T> eventHandler) {
64+
private void initSources() {
65+
sources.clear();
5766
cloner = ConfigurationServiceProvider.instance().getResourceCloner();
58-
this.configuration = configuration;
59-
this.client = client;
60-
this.eventHandler = eventHandler;
6167

6268
final var targetNamespaces = configuration.getEffectiveNamespaces();
6369
if (ResourceConfiguration.allNamespacesWatched(targetNamespaces)) {

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/ManagedInformerEventSource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ public abstract class ManagedInformerEventSource<R extends HasMetadata, P extend
3737
private static final Logger log = LoggerFactory.getLogger(ManagedInformerEventSource.class);
3838

3939
protected TemporaryResourceCache<R> temporaryResourceCache;
40-
protected InformerManager<R, C> cache = new InformerManager<>();
40+
protected InformerManager<R, C> cache;
4141
protected C configuration;
4242

4343
protected ManagedInformerEventSource(
4444
MixedOperation<R, KubernetesResourceList<R>, Resource<R>> client, C configuration) {
4545
super(configuration.getResourceClass());
4646
temporaryResourceCache = new TemporaryResourceCache<>(this);
47-
manager().initSources(client, configuration, this);
47+
cache = new InformerManager<>(client,configuration,this);
4848
this.configuration = configuration;
4949
}
5050

0 commit comments

Comments
 (0)