Github user mxm commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2085#discussion_r66805492
  
    --- Diff: 
flink-yarn/src/main/java/org/apache/flink/yarn/AbstractYarnClusterDescriptor.java
 ---
    @@ -300,18 +309,82 @@ public static boolean allocateResource(int[] 
nodeManagers, int toAllocate) {
                return false;
        }
     
    -   @Override
        public void setDetachedMode(boolean detachedMode) {
                this.detached = detachedMode;
        }
     
    -   @Override
    -   public boolean isDetached() {
    +   public boolean isDetachedMode() {
                return detached;
        }
     
    +
    +   /**
    +    * Gets a Hadoop Yarn client
    +    * @return Returns a YarnClient which has to be shutdown manually
    +    */
    +   private static YarnClient getYarnClient(Configuration conf) {
    +           YarnClient yarnClient = YarnClient.createYarnClient();
    +           yarnClient.init(conf);
    +           yarnClient.start();
    +           return yarnClient;
    +   }
    +
    +   /**
    +    * Retrieves the Yarn application and cluster from the config
    +    * @param config The config with entries to retrieve the cluster
    +    * @return YarnClusterClient
    +    * @deprecated This should be removed in the future
    +    */
    +   public YarnClusterClient 
retrieveFromConfig(org.apache.flink.configuration.Configuration config) throws  
Exception {
    +           String jobManagerHost = 
config.getString(ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY, null);
    +           int jobManagerPort = 
config.getInteger(ConfigConstants.JOB_MANAGER_IPC_PORT_KEY, -1);
    +
    +           if (jobManagerHost != null && jobManagerPort != -1) {
    +
    +                   YarnClient yarnClient = getYarnClient(conf);
    +                   List<ApplicationReport> applicationReports = 
yarnClient.getApplications();
    +                   for (ApplicationReport report : applicationReports) {
    +                           if (report.getHost().equals(jobManagerHost) && 
report.getRpcPort() == jobManagerPort) {
    +                                   LOG.info("Found application '{}' " +
    +                                           "with JobManager host name '{}' 
and port '{}' from Yarn properties file.",
    +                                           report.getApplicationId(), 
jobManagerHost, jobManagerPort);
    +                                   return 
retrieve(report.getApplicationId().toString());
    +                           }
    +                   }
    +
    --- End diff --
    
    Good idea.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to