dmvk commented on code in PR #19372:
URL: https://github.com/apache/flink/pull/19372#discussion_r847258427
##########
flink-runtime/src/main/java/org/apache/flink/runtime/security/token/KerberosDelegationTokenManager.java:
##########
@@ -110,13 +126,84 @@ public void obtainDelegationTokens(Credentials
credentials) {
* task managers.
*/
@Override
- public void start() {
- LOG.info("Starting renewal task");
+ public void start() throws Exception {
+ checkState(renewalExecutor == null, "Manager is already started");
+
+ if (!isRenewalPossible()) {
+ LOG.info("Renewal is NOT possible, skipping to start renewal
task");
+ return;
+ }
+
+ ThreadFactory threadFactory =
+ new ThreadFactoryBuilder()
+ .setDaemon(true)
+ .setNameFormat("Credential Renewal Thread")
+ .build();
+ renewalExecutor = new ScheduledThreadPoolExecutor(1, threadFactory);
Review Comment:
I'd love to avoid adding a new executor here (in general we try to avoid a
thread pollution where possible). We should be able to reuse the existing
executors that are already available to the `ResourceManager`:
- ComponentMainThreadExecutor (main thread for the ResourceManager endpoint;
can be used for scheduling; can't have blocking runnables otherwise we'd
disrupt the endpoint availability)
- ioExecutor (for blocking io heavy calls)
Basically the start method would become something along these lines:
```java
public void start(ComponentMainThreadExecutor mainThreadExecutor,
Executor ioExecutor) {
final long tgtRenewalPeriod =
configuration.get(KERBEROS_RELOGIN_PERIOD).toMillis();
// The renewal future needs to be cancelled during close.
final ScheduledFuture<?> renewalFuture =
mainThreadExecutor.schedule(
() ->
ioExecutor.execute(
() -> {
// Todo...
}),
tgtRenewalPeriod,
TimeUnit.MILLISECONDS);
}
```
WDYT?
--
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]