You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/04/23 15:37:19 UTC

[GitHub] [flink-kubernetes-operator] Aitozi commented on a diff in pull request #176: [FLINK-27279] Extract common status interfaces

Aitozi commented on code in PR #176:
URL: https://github.com/apache/flink-kubernetes-operator/pull/176#discussion_r856933400


##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/reconciler/ReconcileTarget.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.kubernetes.operator.reconciler;
+
+import org.apache.flink.kubernetes.operator.crd.spec.JobSpec;
+import org.apache.flink.kubernetes.operator.crd.status.ReconciliationStatus;
+
+import javax.annotation.Nullable;
+
+/**
+ * The interface is responsible to handle the reconciliation result. For the common logic, it
+ * provides method to extract the common view between the {@link
+ * org.apache.flink.kubernetes.operator.crd.FlinkDeployment} and {@link
+ * org.apache.flink.kubernetes.operator.crd.FlinkSessionJob} to simplify the custom resource
+ * manipulation. For the special part of each custom resource, we can extend the interface to let
+ * the target custom resource react to the reconciliation result correspondingly.
+ *
+ * @param <SPEC> the common view of the custom resource getSpec
+ */
+public interface ReconcileTarget<SPEC extends ReconcileTarget.SpecView> {
+
+    /** The common view of the spec. */
+    interface SpecView {
+        JobSpec getJobSpec();
+    }
+
+    /**
+     * Get the current getSpec of the custom resource.
+     *
+     * @return the current getSpec.
+     */
+    SPEC getSpec();
+
+    /**
+     * Get the current reconciliation status.
+     *
+     * @return the current reconciliation status.
+     */
+    ReconciliationStatus<SPEC> getReconcileStatus();
+
+    /**
+     * Let the target custom resource handle the reconciliation error.
+     *
+     * @param error The error to be handled.
+     */
+    void handleError(@Nullable String error);

Review Comment:
   Good suggestion, I have refactor based on your suggestion, please take a look again.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org