|
7 | 7 | import java.util.Set;
|
8 | 8 | import java.util.concurrent.ExecutorService;
|
9 | 9 | import java.util.concurrent.ScheduledThreadPoolExecutor;
|
10 |
| -import java.util.concurrent.TimeUnit; |
11 | 10 | import java.util.concurrent.locks.ReentrantLock;
|
12 | 11 | import java.util.function.Predicate;
|
13 | 12 |
|
@@ -123,13 +122,7 @@ private void executeBufferedEvents(String customResourceUid) {
|
123 | 122 | latestCustomResource.get(),
|
124 | 123 | retryInfo(customResourceUid));
|
125 | 124 | log.debug("Executing events for custom resource. Scope: {}", executionScope);
|
126 |
| - executor.execute(() -> { |
127 |
| - // change thread name for easier debugging |
128 |
| - Thread.currentThread().setName("EventHandler-" + controllerName); |
129 |
| - PostExecutionControl<R> postExecutionControl = |
130 |
| - eventDispatcher.handleExecution(executionScope); |
131 |
| - eventProcessingFinished(executionScope, postExecutionControl); |
132 |
| - }); |
| 125 | + executor.execute(new ControllerExecution(executionScope)); |
133 | 126 | } else {
|
134 | 127 | log.debug(
|
135 | 128 | "Skipping executing controller for resource id: {}. Events in queue: {}."
|
@@ -276,4 +269,26 @@ private void setUnderExecutionProcessing(String customResourceUid) {
|
276 | 269 | private void unsetUnderExecution(String customResourceUid) {
|
277 | 270 | underProcessing.remove(customResourceUid);
|
278 | 271 | }
|
| 272 | + |
| 273 | + private class ControllerExecution implements Runnable { |
| 274 | + private final ExecutionScope<R> executionScope; |
| 275 | + |
| 276 | + private ControllerExecution(ExecutionScope<R> executionScope) { |
| 277 | + this.executionScope = executionScope; |
| 278 | + } |
| 279 | + |
| 280 | + @Override |
| 281 | + public void run() { |
| 282 | + // change thread name for easier debugging |
| 283 | + Thread.currentThread().setName("EventHandler-" + controllerName); |
| 284 | + PostExecutionControl<R> postExecutionControl = |
| 285 | + eventDispatcher.handleExecution(executionScope); |
| 286 | + eventProcessingFinished(executionScope, postExecutionControl); |
| 287 | + } |
| 288 | + |
| 289 | + @Override |
| 290 | + public String toString() { |
| 291 | + return controllerName + " -> " + executionScope; |
| 292 | + } |
| 293 | + } |
279 | 294 | }
|
0 commit comments