wangyang0918 commented on a change in pull request #13644:
URL: https://github.com/apache/flink/pull/13644#discussion_r507358801



##########
File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/kubeclient/FlinkKubeClient.java
##########
@@ -104,6 +107,67 @@ KubernetesWatch watchPodsAndDoCallback(
                Map<String, String> labels,
                WatchCallbackHandler<KubernetesPod> podCallbackHandler);
 
+       /**
+        * Create the ConfigMap with specified content. If the ConfigMap 
already exists, nothing will happen.
+        *
+        * @param configMap ConfigMap.
+        *
+        * @return Return the ConfigMap create future.
+        */
+       CompletableFuture<Void> createConfigMap(KubernetesConfigMap configMap);
+
+       /**
+        * Get the ConfigMap with specified name.
+        *
+        * @param name ConfigMap name.
+        *
+        * @return Return empty if the ConfigMap does not exist.
+        */
+       Optional<KubernetesConfigMap> getConfigMap(String name);
+
+       /**
+        * Update an existing ConfigMap with the data.
+        *
+        * @param configMapName ConfigMap to be replaced with. Benefit from <a 
href=https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions>
+        *                      resource version</a> and combined with {@link 
#getConfigMap(String)}, we could perform a get-check-and-update
+        *                      transactional operation. Since concurrent 
modification could happen on a same ConfigMap,
+        *                      the update operation may fail. We need to retry 
internally. The max retry attempts could be
+        *                      configured via {@link 
org.apache.flink.kubernetes.configuration.KubernetesConfigOptions#KUBERNETES_MAX_RETRY_ATTEMPTS}.
+        * @param checker       Only the checker return true, the ConfigMap 
will be updated.
+        * @param function      The obtained ConfigMap will be applied to this 
function and get a new one to replace.
+        *
+        * @return Return the ConfigMap update future.
+        */
+       CompletableFuture<Boolean> checkAndUpdateConfigMap(
+               String configMapName,
+               Predicate<KubernetesConfigMap> checker,
+               FunctionWithException<KubernetesConfigMap, KubernetesConfigMap, 
?> function);

Review comment:
       Hmm. This is a useful suggestion. I agree with you that returning an 
`Optional<KubernetesConfigMap>` could make the contract easier to use.




----------------------------------------------------------------
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.

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


Reply via email to