Class StatusRecorder<CR extends AbstractFlinkResource<?,​STATUS>,​STATUS extends CommonStatus<?>>

  • public class StatusRecorder<CR extends AbstractFlinkResource<?,​STATUS>,​STATUS extends CommonStatus<?>>
    extends java.lang.Object
    Helper class for status management and updates.
    • Field Summary

      Modifier and Type Field Description
      protected com.fasterxml.jackson.databind.ObjectMapper objectMapper  
      protected java.util.concurrent.ConcurrentHashMap<io.javaoperatorsdk.operator.processing.event.ResourceID,​com.fasterxml.jackson.databind.node.ObjectNode> statusCache  
    • Field Detail

      • objectMapper

        protected final com.fasterxml.jackson.databind.ObjectMapper objectMapper
      • statusCache

        protected final java.util.concurrent.ConcurrentHashMap<io.javaoperatorsdk.operator.processing.event.ResourceID,​com.fasterxml.jackson.databind.node.ObjectNode> statusCache
    • Constructor Detail

      • StatusRecorder

        public StatusRecorder​(MetricManager<CR> metricManager,
                              java.util.function.BiConsumer<CR,​STATUS> statusUpdateListener)
    • Method Detail

      • patchAndCacheStatus

        public void patchAndCacheStatus​(CR resource,
                                        io.fabric8.kubernetes.client.KubernetesClient client)
        Update the status of the provided kubernetes resource on the k8s cluster. We use patch together with null resourceVersion to try to guarantee that the status update succeeds even if the underlying resource spec was update in the meantime. This is necessary for the correct operator behavior.
        resource - Resource for which status update should be performed
      • updateStatusFromCache

        public void updateStatusFromCache​(CR resource)
        Update the custom resource status based on the in-memory cached to ensure that any status updates that we made previously are always visible in the reconciliation loop. This is required due to our custom status patching logic.

        If the cache doesn't have a status stored, we do no update. This happens when the operator reconciles a resource for the first time after a restart.

        resource - Resource for which the status should be updated from the cache
      • removeCachedStatus

        public void removeCachedStatus​(CR resource)
        Remove cached status for Flink resource.
        resource - Flink resource.