tillrohrmann commented on a change in pull request #16806:
URL: https://github.com/apache/flink/pull/16806#discussion_r692154118
##########
File path:
flink-yarn/src/main/java/org/apache/flink/yarn/YarnClusterClientFactory.java
##########
@@ -81,6 +91,57 @@ private YarnClusterDescriptor
getClusterDescriptor(Configuration configuration)
yarnClient.init(yarnConfiguration);
yarnClient.start();
+ if (configuration.contains(YarnConfigOptions.APPLICATION_NAME)) {
+ try {
+ Set<String> applicationTypes = Sets.newHashSet();
+ applicationTypes.add("Apache Flink");
Review comment:
I think the application type can be something different than `"Apache
Flink"`. See `YarnConfigOptions.APPLICATION_TYPE`.
##########
File path:
flink-yarn/src/main/java/org/apache/flink/yarn/YarnClusterClientFactory.java
##########
@@ -81,6 +91,57 @@ private YarnClusterDescriptor
getClusterDescriptor(Configuration configuration)
yarnClient.init(yarnConfiguration);
yarnClient.start();
+ if (configuration.contains(YarnConfigOptions.APPLICATION_NAME)) {
+ try {
+ Set<String> applicationTypes = Sets.newHashSet();
+ applicationTypes.add("Apache Flink");
+ EnumSet<YarnApplicationState> applicationStates =
+ EnumSet.noneOf(YarnApplicationState.class);
+ applicationStates.add(YarnApplicationState.RUNNING);
+ List<ApplicationReport> applicationReports =
+ yarnClient.getApplications(applicationTypes,
applicationStates);
+ Collections.sort(
+ applicationReports,
+ (o1, o2) -> {
+ long o1Time =
o1.getApplicationId().getClusterTimestamp();
+ long o2Time =
o2.getApplicationId().getClusterTimestamp();
+ long o1Id = o1.getApplicationId().getId();
+ long o2Id = o2.getApplicationId().getId();
+ if (o1Time > o2Time) {
+ return -1;
+ } else if (o1Time == o2Time) {
+ return (o1Id < o2Id) ? 1 : -1;
+ } else {
+ return 1;
+ }
+ });
+ if (CollectionUtils.isNotEmpty(applicationReports)) {
+ for (ApplicationReport applicationReport :
applicationReports) {
+ if (StringUtils.equals(
+ applicationReport.getName(),
+
configuration.get(YarnConfigOptions.APPLICATION_NAME))) {
+ if
(configuration.contains(YarnConfigOptions.APPLICATION_QUEUE)) {
+ if (StringUtils.equals(
+ applicationReport.getQueue(),
+
configuration.get(YarnConfigOptions.APPLICATION_QUEUE))) {
+ configuration.setString(
+ YarnConfigOptions.APPLICATION_ID,
+
applicationReport.getApplicationId().toString());
+ break;
+ }
+ } else {
+ configuration.setString(
+ YarnConfigOptions.APPLICATION_ID,
+
applicationReport.getApplicationId().toString());
+ break;
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
Review comment:
In case of a failure, we should propagate the exception.
--
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]