You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by GitBox <gi...@apache.org> on 2022/03/13 12:13:35 UTC

[GitHub] [flink-kubernetes-operator] Aitozi opened a new pull request #55: [FLINK-26546] Extract Observer Interface

Aitozi opened a new pull request #55:
URL: https://github.com/apache/flink-kubernetes-operator/pull/55


   This PR is mean to extract the `Observer` interface to simplify the observe logic. The main logic is aligned to the `Reconciler` interface 


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

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



[GitHub] [flink-kubernetes-operator] gyfora merged pull request #55: [FLINK-26546] Extract Observer Interface

Posted by GitBox <gi...@apache.org>.
gyfora merged pull request #55:
URL: https://github.com/apache/flink-kubernetes-operator/pull/55


   


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

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



[GitHub] [flink-kubernetes-operator] Aitozi commented on a change in pull request #55: [FLINK-26546] Extract Observer Interface

Posted by GitBox <gi...@apache.org>.
Aitozi commented on a change in pull request #55:
URL: https://github.com/apache/flink-kubernetes-operator/pull/55#discussion_r825702811



##########
File path: flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/observer/BaseObserver.java
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.observer;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.kubernetes.operator.config.FlinkOperatorConfiguration;
+import org.apache.flink.kubernetes.operator.crd.FlinkDeployment;
+import org.apache.flink.kubernetes.operator.crd.status.FlinkDeploymentStatus;
+import org.apache.flink.kubernetes.operator.exception.DeploymentFailedException;
+import org.apache.flink.kubernetes.operator.service.FlinkService;
+
+import io.fabric8.kubernetes.api.model.apps.Deployment;
+import io.fabric8.kubernetes.api.model.apps.DeploymentCondition;
+import io.fabric8.kubernetes.api.model.apps.DeploymentSpec;
+import io.fabric8.kubernetes.api.model.apps.DeploymentStatus;
+import io.javaoperatorsdk.operator.api.reconciler.Context;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Optional;
+
+/** The base observer. */
+public abstract class BaseObserver implements Observer {
+
+    protected final Logger logger = LoggerFactory.getLogger(this.getClass());

Review comment:
       It's intended for the sharing of `logger` in subclass




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

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



[GitHub] [flink-kubernetes-operator] wangyang0918 commented on pull request #55: [FLINK-26546] Extract Observer Interface

Posted by GitBox <gi...@apache.org>.
wangyang0918 commented on pull request #55:
URL: https://github.com/apache/flink-kubernetes-operator/pull/55#issuecomment-1066285269


   Just a personal taste, compared to inheritance, I prefer composition. The problem of inheritance is that we do not know which methods in `BaseReconciler` and `BaseObserver` will be overridden by a subclass. Currently, it is not a major problem since we have very few methods in the interface.
   
   Note: I do not mean we have to change in this PR.


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

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



[GitHub] [flink-kubernetes-operator] gyfora commented on pull request #55: [FLINK-26546] Extract Observer Interface

Posted by GitBox <gi...@apache.org>.
gyfora commented on pull request #55:
URL: https://github.com/apache/flink-kubernetes-operator/pull/55#issuecomment-1066092790


   Thanks @Aitozi, looks good at a first glance, I will review this in detail tomorrow morning :) 


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

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



[GitHub] [flink-kubernetes-operator] gyfora commented on pull request #55: [FLINK-26546] Extract Observer Interface

Posted by GitBox <gi...@apache.org>.
gyfora commented on pull request #55:
URL: https://github.com/apache/flink-kubernetes-operator/pull/55#issuecomment-1066719422


   I also like the BaseXX approach, I think now we have a nice clean separation of observers, and reconcilers :) 


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

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



[GitHub] [flink-kubernetes-operator] Aitozi commented on pull request #55: [FLINK-26546] Extract Observer Interface

Posted by GitBox <gi...@apache.org>.
Aitozi commented on pull request #55:
URL: https://github.com/apache/flink-kubernetes-operator/pull/55#issuecomment-1066319457


   @wangyang0918 Thanks for sharing your insights. IMO, one of the benefits of inherited `BaseXX` class is that it can provide the `template` ability and leave it implemented by the subclass. The composition seems can not achieve the same effect. 
   For example, in the `BaseReconciler#cleanup` provide the common template part, and the both subclass only have to handle how to `shutdown` the corresponding component. 


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

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



[GitHub] [flink-kubernetes-operator] Aitozi commented on pull request #55: [FLINK-26546] Extract Observer Interface

Posted by GitBox <gi...@apache.org>.
Aitozi commented on pull request #55:
URL: https://github.com/apache/flink-kubernetes-operator/pull/55#issuecomment-1066091349


   cc @morhidi @gyfora @wangyang0918 


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

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



[GitHub] [flink-kubernetes-operator] bgeng777 commented on a change in pull request #55: [FLINK-26546] Extract Observer Interface

Posted by GitBox <gi...@apache.org>.
bgeng777 commented on a change in pull request #55:
URL: https://github.com/apache/flink-kubernetes-operator/pull/55#discussion_r825657374



##########
File path: flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/observer/BaseObserver.java
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.observer;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.kubernetes.operator.config.FlinkOperatorConfiguration;
+import org.apache.flink.kubernetes.operator.crd.FlinkDeployment;
+import org.apache.flink.kubernetes.operator.crd.status.FlinkDeploymentStatus;
+import org.apache.flink.kubernetes.operator.exception.DeploymentFailedException;
+import org.apache.flink.kubernetes.operator.service.FlinkService;
+
+import io.fabric8.kubernetes.api.model.apps.Deployment;
+import io.fabric8.kubernetes.api.model.apps.DeploymentCondition;
+import io.fabric8.kubernetes.api.model.apps.DeploymentSpec;
+import io.fabric8.kubernetes.api.model.apps.DeploymentStatus;
+import io.javaoperatorsdk.operator.api.reconciler.Context;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Optional;
+
+/** The base observer. */
+public abstract class BaseObserver implements Observer {
+
+    protected final Logger logger = LoggerFactory.getLogger(this.getClass());

Review comment:
       nit: the logger can be static to reduce extra memory footprint.




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

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