pratapaditya04 commented on code in PR #4166:
URL: https://github.com/apache/gobblin/pull/4166#discussion_r2831676652


##########
gobblin-temporal/src/main/java/org/apache/gobblin/temporal/joblauncher/GobblinJobLauncher.java:
##########
@@ -132,15 +135,164 @@ public GobblinJobLauncher(Properties jobProps, Path 
appWorkDir,
             this.stateStores.getTaskStateStore(), this.outputTaskStateDir, 
this.getIssueRepository());
     this.executor = Executors.newSingleThreadScheduledExecutor(
         ExecutorsUtils.newThreadFactory(Optional.of(log), 
Optional.of("GobblinJobLauncher")));
+
+    this.shutdownCleanupTimeoutSeconds = Long.parseLong(jobProps.getProperty(
+        GobblinTemporalConfigurationKeys.SHUTDOWN_CLEANUP_TIMEOUT_SECONDS,
+        
GobblinTemporalConfigurationKeys.DEFAULT_SHUTDOWN_CLEANUP_TIMEOUT_SECONDS));
+
+    registerCleanupShutdownHook();
   }
 
-  @Override
-  public void close() throws IOException {
+  /**
+   * Registers a JVM shutdown hook that loads JobState from file and runs 
cleanup methods in parallel.
+   */
+  private void registerCleanupShutdownHook() {
+    Runtime.getRuntime().addShutdownHook(
+        new Thread(this::performShutdownCleanup, "GobblinJobLauncher-Cleanup-" 
+ this.jobContext.getJobId()));

Review Comment:
   We don't mind if cleanup happens even in success cases, 



-- 
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]

Reply via email to