Skip to content

Commit 0837090

Browse files
committed
wip
Signed-off-by: Attila Mészáros <a_meszaros@apple.com> # Conflicts: # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/pool/DefaultInformerPool.java
1 parent a13c195 commit 0837090

4 files changed

Lines changed: 10 additions & 8 deletions

File tree

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/AbstractConfigurationService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ public synchronized InformerPool informerPool() {
200200
// can therefore share the underlying informers; synchronized so concurrent first-access from
201201
// multiple controllers cannot create (and share out) more than one pool instance
202202
if (informerPool == null) {
203-
informerPool = new DefaultInformerPool(this);
203+
informerPool = new DefaultInformerPool();
204+
informerPool.setConfigurationService(this);
204205
}
205206
return informerPool;
206207
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import io.fabric8.kubernetes.api.model.HasMetadata;
2727
import io.fabric8.kubernetes.client.KubernetesClient;
2828
import io.fabric8.kubernetes.client.informers.SharedIndexInformer;
29-
import io.javaoperatorsdk.operator.api.config.ConfigurationService;
3029

3130
public class DefaultInformerPool extends AbstractInformerPool {
3231

@@ -35,11 +34,6 @@ public class DefaultInformerPool extends AbstractInformerPool {
3534
private final Map<InformerClassifier<?>, SharedIndexInformer<?>> informers = new HashMap<>();
3635
private final Map<InformerClassifier<?>, AtomicInteger> counters = new HashMap<>();
3736

38-
public DefaultInformerPool(ConfigurationService service) {
39-
setConfigurationService(service);
40-
}
41-
42-
@Override
4337
@SuppressWarnings("unchecked")
4438
@Override
4539
public <R extends HasMetadata> SharedIndexInformer<R> getInformer(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@ <R extends HasMetadata> Optional<SharedIndexInformer<R>> releaseInformer(
5454
*/
5555
long numberOfInformersForResource(Class<? extends HasMetadata> resourceClass);
5656

57+
/** Injecting the configuration service, so users have a cleaner API creating the pool. */
5758
void setConfigurationService(ConfigurationService configurationService);
5859
}

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/informer/pool/DefaultInformerPoolTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package io.javaoperatorsdk.operator.processing.event.source.informer.pool;
1717

18+
import org.junit.jupiter.api.BeforeEach;
1819
import org.junit.jupiter.api.Test;
1920

2021
import io.fabric8.kubernetes.client.KubernetesClient;
@@ -38,7 +39,12 @@ class DefaultInformerPoolTest {
3839
private static final String ES_NAME = "event-source";
3940

4041
private final KubernetesClient client = MockKubernetesClient.client(TestCustomResource.class);
41-
private final DefaultInformerPool pool = new DefaultInformerPool(new BaseConfigurationService());
42+
private final DefaultInformerPool pool = new DefaultInformerPool();
43+
44+
@BeforeEach
45+
void setup() {
46+
pool.setConfigurationService(new BaseConfigurationService());
47+
}
4248

4349
@Test
4450
void sharesSingleInformerForTheSameClassifier() {

0 commit comments

Comments
 (0)