Skip to content

Commit 7a0a246

Browse files
committed
cleanup
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent dc7072b commit 7a0a246

6 files changed

Lines changed: 11 additions & 35 deletions

File tree

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventSourceManager.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private void logEventSourceEvent(EventSource eventSource, String event) {
127127
private <R> Void startEventSource(EventSource<R, P> eventSource) {
128128
try {
129129
logEventSourceEvent(eventSource, "Starting");
130-
eventSource.start(false);
130+
eventSource.start();
131131
logEventSourceEvent(eventSource, "Started");
132132
} catch (MissingCRDException e) {
133133
throw e; // leave untouched
@@ -249,9 +249,7 @@ public <R> EventSource<R, P> dynamicallyRegisterEventSource(EventSource<R, P> ev
249249
registerEventSource(eventSource);
250250
}
251251
}
252-
// The start itself is blocking thus blocking only the threads which are attempt to start the
253-
// actual event source. Think of this as a form of lock striping.
254-
eventSource.start(true);
252+
eventSource.start();
255253
return eventSource;
256254
}
257255

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

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import java.util.Set;
2020

2121
import io.fabric8.kubernetes.api.model.HasMetadata;
22-
import io.javaoperatorsdk.operator.OperatorException;
2322
import io.javaoperatorsdk.operator.health.EventSourceHealthIndicator;
2423
import io.javaoperatorsdk.operator.health.Status;
24+
import io.javaoperatorsdk.operator.processing.LifecycleAware;
2525
import io.javaoperatorsdk.operator.processing.event.EventHandler;
2626
import io.javaoperatorsdk.operator.processing.event.source.filter.GenericFilter;
2727
import io.javaoperatorsdk.operator.processing.event.source.filter.OnAddFilter;
@@ -37,7 +37,8 @@
3737
* @param <P> the primary resource type which reconciler needs to be triggered when events occur on
3838
* resources of type R
3939
*/
40-
public interface EventSource<R, P extends HasMetadata> extends EventSourceHealthIndicator {
40+
public interface EventSource<R, P extends HasMetadata>
41+
extends LifecycleAware, EventSourceHealthIndicator {
4142

4243
static String generateName(EventSource<?, ?> eventSource) {
4344
return eventSource.getClass().getName() + "@" + Integer.toHexString(eventSource.hashCode());
@@ -118,22 +119,4 @@ default Optional<R> getSecondaryResource(P primary) {
118119
default Status getStatus() {
119120
return Status.UNKNOWN;
120121
}
121-
122-
/**
123-
* Start the event source. Normally, should synchronously populate caches, before the method
124-
* returns.
125-
*
126-
* @since 5.6.0
127-
* @param dynamicRegistration true if event source registered dynamically, false otherwise
128-
*/
129-
default void start(boolean dynamicRegistration) {
130-
start();
131-
}
132-
133-
/** Only for backwards compatible purposes. Use {@link #start(boolean)}. */
134-
@Deprecated(forRemoval = true)
135-
void start() throws OperatorException;
136-
137-
/** Strop the event source */
138-
void stop() throws OperatorException;
139122
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ protected void handleEvent(
167167
}
168168

169169
@Override
170-
public synchronized void start(boolean dynamicRegistration) {
170+
public synchronized void start() {
171171
if (isRunning()) {
172172
return;
173173
}
174-
super.start(dynamicRegistration);
174+
super.start();
175175
// this makes sure that on first reconciliation all resources are
176176
// present on the index
177177
manager().list().forEach(r -> primaryToSecondaryIndex.onAddOrUpdate(r, null));

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ protected abstract void handleEvent(
156156
Set<ResourceID> relatedPrimaryIDs);
157157

158158
@Override
159-
public synchronized void start(boolean dynamicRegistration) {
159+
public synchronized void start() {
160160
if (isRunning()) {
161161
return;
162162
}
@@ -173,11 +173,6 @@ public synchronized void start(boolean dynamicRegistration) {
173173
super.start();
174174
}
175175

176-
@Override
177-
public void start() throws OperatorException {
178-
start(false);
179-
}
180-
181176
@Override
182177
public synchronized void stop() {
183178
if (!isRunning()) {

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/EventSourceManagerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ public void startCascadesToEventSources() {
9696

9797
eventSourceManager.start();
9898

99-
verify(eventSource, times(1)).start(false);
100-
verify(eventSource2, times(1)).start(false);
99+
verify(eventSource, times(1)).start();
100+
verify(eventSource2, times(1)).start();
101101
}
102102

103103
@Test

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/AbstractEventSourceTestBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void setUpSource(
6565
source.setEventHandler(eventHandler);
6666

6767
if (start) {
68-
source.start(false);
68+
source.start();
6969
}
7070
}
7171
}

0 commit comments

Comments
 (0)