yt526 commented on a change in pull request #7414: [FLINK-11253] Add shutdown hook for yarn session client in attached mode URL: https://github.com/apache/flink/pull/7414#discussion_r246985655
########## File path: flink-yarn/src/main/java/org/apache/flink/yarn/cli/FlinkYarnSessionCli.java ########## @@ -705,6 +680,47 @@ public int run(String[] args) throws CliArgsException, FlinkException { return 0; } + private void shutdownCluster(AbstractYarnClusterDescriptor yarnClusterDescriptor, + ClusterClient clusterClient, ScheduledExecutorService scheduledExecutorService, + YarnApplicationStatusMonitor yarnApplicationStatusMonitor, ApplicationId yarnApplicationId) { + try { + yarnApplicationStatusMonitor.close(); + } catch (Exception e) { + LOG.info("Could not properly close the Yarn application status monitor.", e); + } + + clusterClient.shutDownCluster(); + + try { + clusterClient.shutdown(); + } catch (Exception e) { + LOG.info("Could not properly shutdown cluster client.", e); + } + + // shut down the scheduled executor service + ExecutorUtils.gracefulShutdown( + 1000L, + TimeUnit.MILLISECONDS, + scheduledExecutorService); + + deleteYarnPropertiesFile(); + + ApplicationReport applicationReport; + + try { + applicationReport = yarnClusterDescriptor + .getYarnClient() + .getApplicationReport(yarnApplicationId); + } catch (YarnException | IOException e) { + LOG.info("Could not log the final application report.", e); + applicationReport = null; + } + + if (applicationReport != null) { + logFinalApplicationReport(applicationReport); + } Review comment: Make sense to me. Thanks. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services