Class StatusRecorder<STATUS extends CommonStatus<?>>
- java.lang.Object
-
- org.apache.flink.kubernetes.operator.utils.StatusRecorder<STATUS>
-
public class StatusRecorder<STATUS extends CommonStatus<?>> extends java.lang.ObjectHelper class for status management and updates.
-
-
Field Summary
Fields Modifier and Type Field Description protected com.fasterxml.jackson.databind.ObjectMapperobjectMapperprotected java.util.concurrent.ConcurrentHashMap<org.apache.flink.api.java.tuple.Tuple2<java.lang.String,java.lang.String>,com.fasterxml.jackson.databind.node.ObjectNode>statusCache
-
Constructor Summary
Constructors Constructor Description StatusRecorder(io.fabric8.kubernetes.client.KubernetesClient client, MetricManager<AbstractFlinkResource<?,STATUS>> metricManager, java.util.function.BiConsumer<AbstractFlinkResource<?,STATUS>,STATUS> statusUpdateListener)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <S extends CommonStatus<?>>
StatusRecorder<S>create(io.fabric8.kubernetes.client.KubernetesClient kubernetesClient, MetricManager<AbstractFlinkResource<?,S>> metricManager, java.util.Collection<FlinkResourceListener> listeners)protected static org.apache.flink.api.java.tuple.Tuple2<java.lang.String,java.lang.String>getKey(io.fabric8.kubernetes.api.model.HasMetadata resource)<T extends AbstractFlinkResource<?,STATUS>>
voidpatchAndCacheStatus(T resource)Update the status of the provided kubernetes resource on the k8s cluster.<T extends AbstractFlinkResource<?,STATUS>>
voidremoveCachedStatus(T resource)Remove cached status for Flink resource.<T extends AbstractFlinkResource<?,STATUS>>
voidupdateStatusFromCache(T 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.
-
-
-
Field Detail
-
objectMapper
protected final com.fasterxml.jackson.databind.ObjectMapper objectMapper
-
statusCache
protected final java.util.concurrent.ConcurrentHashMap<org.apache.flink.api.java.tuple.Tuple2<java.lang.String,java.lang.String>,com.fasterxml.jackson.databind.node.ObjectNode> statusCache
-
-
Constructor Detail
-
StatusRecorder
public StatusRecorder(io.fabric8.kubernetes.client.KubernetesClient client, MetricManager<AbstractFlinkResource<?,STATUS>> metricManager, java.util.function.BiConsumer<AbstractFlinkResource<?,STATUS>,STATUS> statusUpdateListener)
-
-
Method Detail
-
patchAndCacheStatus
public <T extends AbstractFlinkResource<?,STATUS>> void patchAndCacheStatus(T resource)
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.- Type Parameters:
T- Resource type.- Parameters:
resource- Resource for which status update should be performed
-
updateStatusFromCache
public <T extends AbstractFlinkResource<?,STATUS>> void updateStatusFromCache(T 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.
- Type Parameters:
T- Custom resource type.- Parameters:
resource- Resource for which the status should be updated from the cache
-
removeCachedStatus
public <T extends AbstractFlinkResource<?,STATUS>> void removeCachedStatus(T resource)
Remove cached status for Flink resource.- Type Parameters:
T- Resource type.- Parameters:
resource- Flink resource.
-
getKey
protected static org.apache.flink.api.java.tuple.Tuple2<java.lang.String,java.lang.String> getKey(io.fabric8.kubernetes.api.model.HasMetadata resource)
-
create
public static <S extends CommonStatus<?>> StatusRecorder<S> create(io.fabric8.kubernetes.client.KubernetesClient kubernetesClient, MetricManager<AbstractFlinkResource<?,S>> metricManager, java.util.Collection<FlinkResourceListener> listeners)
-
-