8
8
import io .fabric8 .kubernetes .client .dsl .MixedOperation ;
9
9
import io .javaoperatorsdk .operator .api .ResourceController ;
10
10
import io .javaoperatorsdk .operator .api .RetryInfo ;
11
+ import io .javaoperatorsdk .operator .api .config .ConfigurationService ;
11
12
import io .javaoperatorsdk .operator .api .config .ControllerConfiguration ;
12
13
import io .javaoperatorsdk .operator .processing .event .DefaultEventSourceManager ;
13
14
import io .javaoperatorsdk .operator .processing .event .Event ;
@@ -41,6 +42,7 @@ public class DefaultEventHandler implements EventHandler {
41
42
private final Retry retry ;
42
43
private final Map <String , RetryExecution > retryState = new HashMap <>();
43
44
private final String controllerName ;
45
+ private final int terminationTimeout ;
44
46
private DefaultEventSourceManager eventSourceManager ;
45
47
46
48
private final ReentrantLock lock = new ReentrantLock ();
@@ -51,18 +53,34 @@ public DefaultEventHandler(
51
53
new EventDispatcher (controller , configuration , client ),
52
54
configuration .getName (),
53
55
GenericRetry .fromConfiguration (configuration .getRetryConfiguration ()),
54
- configuration .getConfigurationService ().concurrentReconciliationThreads ());
56
+ configuration .getConfigurationService ().concurrentReconciliationThreads (),
57
+ configuration .getConfigurationService ().getTerminationTimeoutSeconds ());
55
58
}
56
59
57
60
DefaultEventHandler (
58
61
EventDispatcher eventDispatcher ,
59
62
String relatedControllerName ,
60
63
Retry retry ,
61
64
int concurrentReconciliationThreads ) {
65
+ this (
66
+ eventDispatcher ,
67
+ relatedControllerName ,
68
+ retry ,
69
+ concurrentReconciliationThreads ,
70
+ ConfigurationService .DEFAULT_TERMINATION_TIMEOUT_SECONDS );
71
+ }
72
+
73
+ private DefaultEventHandler (
74
+ EventDispatcher eventDispatcher ,
75
+ String relatedControllerName ,
76
+ Retry retry ,
77
+ int concurrentReconciliationThreads ,
78
+ int terminationTimeout ) {
62
79
this .eventDispatcher = eventDispatcher ;
63
80
this .retry = retry ;
64
81
this .controllerName = relatedControllerName ;
65
82
eventBuffer = new EventBuffer ();
83
+ this .terminationTimeout = terminationTimeout ;
66
84
executor =
67
85
new ScheduledThreadPoolExecutor (
68
86
concurrentReconciliationThreads ,
@@ -73,7 +91,7 @@ public DefaultEventHandler(
73
91
public void close () {
74
92
try {
75
93
log .debug ("Closing handler for {}" , controllerName );
76
- executor .awaitTermination (10 , TimeUnit .SECONDS );
94
+ executor .awaitTermination (terminationTimeout , TimeUnit .SECONDS );
77
95
} catch (InterruptedException e ) {
78
96
log .debug ("Exception closing handler for {}: {}" , controllerName , e .getLocalizedMessage ());
79
97
}
0 commit comments