Class KubernetesAutoScalerStateStore
- java.lang.Object
-
- org.apache.flink.kubernetes.operator.autoscaler.state.KubernetesAutoScalerStateStore
-
- All Implemented Interfaces:
AutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
public class KubernetesAutoScalerStateStore extends java.lang.Object implements AutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
An AutoscalerStateStore which persists its state in Kubernetes ConfigMaps.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
COLLECTED_METRICS_KEY
protected static java.lang.String
CONFIG_OVERRIDES_KEY
protected static java.lang.String
DELAYED_SCALE_DOWN
protected static int
MAX_CM_BYTES
protected static java.lang.String
PARALLELISM_OVERRIDES_KEY
protected static java.lang.String
SCALING_HISTORY_KEY
protected static java.lang.String
SCALING_TRACKING_KEY
protected static org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper
YAML_MAPPER
-
Constructor Summary
Constructors Constructor Description KubernetesAutoScalerStateStore(ConfigMapStore configMapStore)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearAll(KubernetesJobAutoScalerContext jobContext)
Removes all data from this context.void
flush(KubernetesJobAutoScalerContext jobContext)
Flushing is needed because we do not persist data for all store methods until this method is called.java.util.SortedMap<java.time.Instant,CollectedMetrics>
getCollectedMetrics(KubernetesJobAutoScalerContext jobContext)
ConfigChanges
getConfigChanges(KubernetesJobAutoScalerContext jobContext)
DelayedScaleDown
getDelayedScaleDown(KubernetesJobAutoScalerContext jobContext)
java.util.Map<java.lang.String,java.lang.String>
getParallelismOverrides(KubernetesJobAutoScalerContext jobContext)
java.util.Map<org.apache.flink.runtime.jobgraph.JobVertexID,java.util.SortedMap<java.time.Instant,ScalingSummary>>
getScalingHistory(KubernetesJobAutoScalerContext jobContext)
ScalingTracking
getScalingTracking(KubernetesJobAutoScalerContext jobContext)
void
removeCollectedMetrics(KubernetesJobAutoScalerContext jobContext)
void
removeConfigChanges(KubernetesJobAutoScalerContext jobContext)
void
removeParallelismOverrides(KubernetesJobAutoScalerContext jobContext)
void
removeScalingHistory(KubernetesJobAutoScalerContext jobContext)
protected static java.lang.String
serializeEvaluatedMetrics(java.util.SortedMap<java.time.Instant,CollectedMetrics> evaluatedMetrics)
protected static java.lang.String
serializeScalingHistory(java.util.Map<org.apache.flink.runtime.jobgraph.JobVertexID,java.util.SortedMap<java.time.Instant,ScalingSummary>> scalingHistory)
protected static java.lang.String
serializeScalingTracking(ScalingTracking scalingTracking)
void
storeCollectedMetrics(KubernetesJobAutoScalerContext jobContext, java.util.SortedMap<java.time.Instant,CollectedMetrics> metrics)
void
storeConfigChanges(KubernetesJobAutoScalerContext jobContext, ConfigChanges overrides)
void
storeDelayedScaleDown(KubernetesJobAutoScalerContext jobContext, DelayedScaleDown delayedScaleDown)
void
storeParallelismOverrides(KubernetesJobAutoScalerContext jobContext, java.util.Map<java.lang.String,java.lang.String> parallelismOverrides)
void
storeScalingHistory(KubernetesJobAutoScalerContext jobContext, java.util.Map<org.apache.flink.runtime.jobgraph.JobVertexID,java.util.SortedMap<java.time.Instant,ScalingSummary>> scalingHistory)
void
storeScalingTracking(KubernetesJobAutoScalerContext jobContext, ScalingTracking scalingTrack)
protected void
trimHistoryToMaxCmSize(KubernetesJobAutoScalerContext context)
-
-
-
Field Detail
-
SCALING_HISTORY_KEY
@VisibleForTesting protected static final java.lang.String SCALING_HISTORY_KEY
- See Also:
- Constant Field Values
-
SCALING_TRACKING_KEY
@VisibleForTesting protected static final java.lang.String SCALING_TRACKING_KEY
- See Also:
- Constant Field Values
-
COLLECTED_METRICS_KEY
@VisibleForTesting protected static final java.lang.String COLLECTED_METRICS_KEY
- See Also:
- Constant Field Values
-
PARALLELISM_OVERRIDES_KEY
@VisibleForTesting protected static final java.lang.String PARALLELISM_OVERRIDES_KEY
- See Also:
- Constant Field Values
-
CONFIG_OVERRIDES_KEY
protected static final java.lang.String CONFIG_OVERRIDES_KEY
- See Also:
- Constant Field Values
-
DELAYED_SCALE_DOWN
@VisibleForTesting protected static final java.lang.String DELAYED_SCALE_DOWN
- See Also:
- Constant Field Values
-
MAX_CM_BYTES
@VisibleForTesting protected static final int MAX_CM_BYTES
- See Also:
- Constant Field Values
-
YAML_MAPPER
protected static final org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper YAML_MAPPER
-
-
Constructor Detail
-
KubernetesAutoScalerStateStore
public KubernetesAutoScalerStateStore(ConfigMapStore configMapStore)
-
-
Method Detail
-
storeScalingHistory
public void storeScalingHistory(KubernetesJobAutoScalerContext jobContext, java.util.Map<org.apache.flink.runtime.jobgraph.JobVertexID,java.util.SortedMap<java.time.Instant,ScalingSummary>> scalingHistory)
- Specified by:
storeScalingHistory
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
storeScalingTracking
public void storeScalingTracking(KubernetesJobAutoScalerContext jobContext, ScalingTracking scalingTrack)
- Specified by:
storeScalingTracking
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
getScalingHistory
@Nonnull public java.util.Map<org.apache.flink.runtime.jobgraph.JobVertexID,java.util.SortedMap<java.time.Instant,ScalingSummary>> getScalingHistory(KubernetesJobAutoScalerContext jobContext)
- Specified by:
getScalingHistory
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
getScalingTracking
public ScalingTracking getScalingTracking(KubernetesJobAutoScalerContext jobContext)
- Specified by:
getScalingTracking
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
removeScalingHistory
public void removeScalingHistory(KubernetesJobAutoScalerContext jobContext)
- Specified by:
removeScalingHistory
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
storeCollectedMetrics
public void storeCollectedMetrics(KubernetesJobAutoScalerContext jobContext, java.util.SortedMap<java.time.Instant,CollectedMetrics> metrics)
- Specified by:
storeCollectedMetrics
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
getCollectedMetrics
@Nonnull public java.util.SortedMap<java.time.Instant,CollectedMetrics> getCollectedMetrics(KubernetesJobAutoScalerContext jobContext)
- Specified by:
getCollectedMetrics
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
removeCollectedMetrics
public void removeCollectedMetrics(KubernetesJobAutoScalerContext jobContext)
- Specified by:
removeCollectedMetrics
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
storeParallelismOverrides
public void storeParallelismOverrides(KubernetesJobAutoScalerContext jobContext, java.util.Map<java.lang.String,java.lang.String> parallelismOverrides)
- Specified by:
storeParallelismOverrides
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
getParallelismOverrides
@Nonnull public java.util.Map<java.lang.String,java.lang.String> getParallelismOverrides(KubernetesJobAutoScalerContext jobContext)
- Specified by:
getParallelismOverrides
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
getConfigChanges
@Nonnull public ConfigChanges getConfigChanges(KubernetesJobAutoScalerContext jobContext)
- Specified by:
getConfigChanges
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
storeConfigChanges
public void storeConfigChanges(KubernetesJobAutoScalerContext jobContext, ConfigChanges overrides)
- Specified by:
storeConfigChanges
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
removeConfigChanges
public void removeConfigChanges(KubernetesJobAutoScalerContext jobContext)
- Specified by:
removeConfigChanges
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
removeParallelismOverrides
public void removeParallelismOverrides(KubernetesJobAutoScalerContext jobContext)
- Specified by:
removeParallelismOverrides
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
storeDelayedScaleDown
public void storeDelayedScaleDown(KubernetesJobAutoScalerContext jobContext, DelayedScaleDown delayedScaleDown) throws java.lang.Exception
- Specified by:
storeDelayedScaleDown
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
- Throws:
java.lang.Exception
-
getDelayedScaleDown
@Nonnull public DelayedScaleDown getDelayedScaleDown(KubernetesJobAutoScalerContext jobContext)
- Specified by:
getDelayedScaleDown
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
clearAll
public void clearAll(KubernetesJobAutoScalerContext jobContext)
Description copied from interface:AutoScalerStateStore
Removes all data from this context. Flush stil needs to be called.- Specified by:
clearAll
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
flush
public void flush(KubernetesJobAutoScalerContext jobContext)
Description copied from interface:AutoScalerStateStore
Flushing is needed because we do not persist data for all store methods until this method is called. Note: The state store implementation should try to avoid write operations unless data was changed through this interface.- Specified by:
flush
in interfaceAutoScalerStateStore<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext>
-
serializeScalingHistory
protected static java.lang.String serializeScalingHistory(java.util.Map<org.apache.flink.runtime.jobgraph.JobVertexID,java.util.SortedMap<java.time.Instant,ScalingSummary>> scalingHistory)
-
serializeScalingTracking
protected static java.lang.String serializeScalingTracking(ScalingTracking scalingTracking)
-
serializeEvaluatedMetrics
@VisibleForTesting protected static java.lang.String serializeEvaluatedMetrics(java.util.SortedMap<java.time.Instant,CollectedMetrics> evaluatedMetrics)
-
trimHistoryToMaxCmSize
@VisibleForTesting protected void trimHistoryToMaxCmSize(KubernetesJobAutoScalerContext context)
-
-