Class StatusRecorder<CR extends io.fabric8.kubernetes.client.CustomResource<?,STATUS>,STATUS>
- java.lang.Object
-
- org.apache.flink.kubernetes.operator.utils.StatusRecorder<CR,STATUS>
-
public class StatusRecorder<CR extends io.fabric8.kubernetes.client.CustomResource<?,STATUS>,STATUS> extends java.lang.Object
Helper class for status management and updates.
-
-
Field Summary
Fields 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
-
Constructor Summary
Constructors Constructor Description StatusRecorder(MetricManager<CR> metricManager, java.util.function.BiConsumer<CR,STATUS> statusUpdateListener)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <S extends CommonStatus<?>,CR extends AbstractFlinkResource<?,S>>
StatusRecorder<CR,S>create(io.fabric8.kubernetes.client.KubernetesClient kubernetesClient, MetricManager<CR> metricManager, java.util.Collection<FlinkResourceListener> listeners)
static StatusRecorder<FlinkStateSnapshot,FlinkStateSnapshotStatus>
createForFlinkStateSnapshot(io.fabric8.kubernetes.client.KubernetesClient kubernetesClient, MetricManager<FlinkStateSnapshot> metricManager, java.util.Collection<FlinkResourceListener> listeners)
void
notifyListeners(CR resource, STATUS prevStatus)
Notifies status update listeners of changes made to a resource.void
patchAndCacheStatus(CR resource, io.fabric8.kubernetes.client.KubernetesClient client)
Update the status of the provided kubernetes resource on the k8s cluster.void
removeCachedStatus(CR resource)
Remove cached status for Flink resource.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.
-
-
-
Constructor Detail
-
StatusRecorder
public StatusRecorder(MetricManager<CR> metricManager, java.util.function.BiConsumer<CR,STATUS> statusUpdateListener)
-
-
Method Detail
-
notifyListeners
public void notifyListeners(CR resource, STATUS prevStatus)
Notifies status update listeners of changes made to a resource.- Parameters:
resource
- resource that has been updatedprevStatus
- previous status of resource
-
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.- Parameters:
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.
- Parameters:
resource
- Resource for which the status should be updated from the cache
-
removeCachedStatus
public void removeCachedStatus(CR resource)
Remove cached status for Flink resource.- Parameters:
resource
- Flink resource.
-
create
public static <S extends CommonStatus<?>,CR extends AbstractFlinkResource<?,S>> StatusRecorder<CR,S> create(io.fabric8.kubernetes.client.KubernetesClient kubernetesClient, MetricManager<CR> metricManager, java.util.Collection<FlinkResourceListener> listeners)
-
createForFlinkStateSnapshot
public static StatusRecorder<FlinkStateSnapshot,FlinkStateSnapshotStatus> createForFlinkStateSnapshot(io.fabric8.kubernetes.client.KubernetesClient kubernetesClient, MetricManager<FlinkStateSnapshot> metricManager, java.util.Collection<FlinkResourceListener> listeners)
-
-