kumar-mallikarjuna commented on code in PR #25027:
URL: https://github.com/apache/flink/pull/25027#discussion_r1681117423
##########
flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DefaultJobManagerRunnerRegistry.java:
##########
@@ -97,6 +106,14 @@ public JobManagerRunner unregister(JobID jobId) {
return this.jobManagerRunners.remove(jobId);
}
+ public void setMainThreadExecutor(ComponentMainThreadExecutor executor) {
+ mainThreadExecutor = executor;
+ }
+
+ public ComponentMainThreadExecutor getMainThreadExecutor() {
+ return mainThreadExecutor;
+ }
+
Review Comment:
The main problem here seems to be the constructor chain we have in
`Dispatcher`.
Here are the two non-private constructors:
I:
```java
public Dispatcher(
RpcService rpcService,
DispatcherId fencingToken,
Collection<JobGraph> recoveredJobs,
Collection<JobResult> recoveredDirtyJobs,
DispatcherBootstrapFactory dispatcherBootstrapFactory,
DispatcherServices dispatcherServices)
```
and
II:
```java
protected Dispatcher(
RpcService rpcService,
DispatcherId fencingToken,
Collection<JobGraph> recoveredJobs,
Collection<JobResult> recoveredDirtyJobs,
DispatcherBootstrapFactory dispatcherBootstrapFactory,
DispatcherServices dispatcherServices,
JobManagerRunnerRegistry jobManagerRunnerRegistry,
ResourceCleanerFactory resourceCleanerFactory)
```
I see three approaches to do this:
1. [Initializing these
attributes](https://github.com/apache/flink/blob/583aadf97b2e3ddc87d4d244c5d62823e82513b1/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java#L272-L333)
outside of the `Dispatcher` constructor in say an `initDispatcher(...)` method
- probably not a good idea since the attributes would need to be not `final`.
Instead of having the constructor chain, we would have two "base"
constructors for `Dispatcher` only:
which call `super()` and a method `initDispatcher(...)` - to populate the
attributes.
This way, we'll have a separate constructor for tests which can receive
`jobManagerRunnerRegistry/resourceCleanerFactory` and we can build these two
params in constructor (I).
2. We can have two separate constructors which have redundant
initializations of the attributes.
3. Constructor (I) would call (II) as:
```java
public Dispatcher(
RpcService rpcService,
DispatcherId fencingToken,
Collection<JobGraph> recoveredJobs,
Collection<JobResult> recoveredDirtyJobs,
DispatcherBootstrapFactory dispatcherBootstrapFactory,
DispatcherServices dispatcherServices) {
this(
rpcService,
fencingToken,
recoveredJobs,
recoveredDirtyJobs,
dispatcherBootstrapFactory,
dispatcherServices,
null,
null);
}
```
In the base constructor, we'll initialize
`jobManagerRunnerRegistry/resourceCleanerFactory` when they're `null`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]