eemario commented on code in PR #27307:
URL: https://github.com/apache/flink/pull/27307#discussion_r2629822005
##########
flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/ApplicationStatus.java:
##########
@@ -89,4 +90,41 @@ public JobStatus deriveJobStatus() {
return JOB_STATUS_APPLICATION_STATUS_BI_MAP.inverse().get(this);
}
+
+ /**
+ * A bidirectional mapping between {@code ApplicationState} and {@code
ApplicationStatus}.
+ *
+ * <p>{@code ApplicationState} covers the entire lifecycle of an
application, representing
+ * various stages from created to finish.
+ *
+ * <p>{@code ApplicationStatus}, on the other hand, describes the final
state of the cluster
+ * when shutdown. The class name may be changed in the future after
refactoring its usage.
+ */
+ private static final BiMap<ApplicationState, ApplicationStatus>
+ APPLICATION_STATE_APPLICATION_STATUS_BI_MAP =
+ EnumBiMap.create(ApplicationState.class,
ApplicationStatus.class);
+
+ static {
+ APPLICATION_STATE_APPLICATION_STATUS_BI_MAP.put(
+ ApplicationState.FAILED, ApplicationStatus.FAILED);
+ APPLICATION_STATE_APPLICATION_STATUS_BI_MAP.put(
+ ApplicationState.CANCELED, ApplicationStatus.CANCELED);
+ APPLICATION_STATE_APPLICATION_STATUS_BI_MAP.put(
+ ApplicationState.FINISHED, ApplicationStatus.SUCCEEDED);
+ }
+
+ /**
+ * Derives the {@link ApplicationState} from the {@code ApplicationStatus}.
+ *
+ * @return The corresponding {@code ApplicationState}.
+ * @throws UnsupportedOperationException for {@link #UNKNOWN}.
+ */
+ public ApplicationState deriveApplicationState() {
Review Comment:
Updated: refactor JobResult to use JobStatus instead of ApplicationStatus,
thus eliminating the awkward ApplicationStatus -> ApplicationState mapping.
--
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]