Class JdbcAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
- java.lang.Object
-
- org.apache.flink.autoscaler.jdbc.state.JdbcAutoScalerStateStore<KEY,Context>
-
- Type Parameters:
KEY
- The job key.Context
- The job autoscaler context.
- All Implemented Interfaces:
AutoScalerStateStore<KEY,Context>
@Experimental public class JdbcAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>> extends java.lang.Object implements AutoScalerStateStore<KEY,Context>
The state store which persists its state in JDBC related database.
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper
YAML_MAPPER
-
Constructor Summary
Constructors Constructor Description JdbcAutoScalerStateStore(JdbcStateStore jdbcStateStore)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearAll(Context jobContext)
Removes all data from this context.void
flush(Context 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(Context jobContext)
ConfigChanges
getConfigChanges(Context jobContext)
java.util.Map<java.lang.String,java.lang.String>
getParallelismOverrides(Context jobContext)
java.util.Map<org.apache.flink.runtime.jobgraph.JobVertexID,java.util.SortedMap<java.time.Instant,ScalingSummary>>
getScalingHistory(Context jobContext)
ScalingTracking
getScalingTracking(Context jobContext)
void
removeCollectedMetrics(Context jobContext)
void
removeConfigChanges(Context jobContext)
void
removeInfoFromCache(KEY jobKey)
Clean up all information related to the current job.void
removeParallelismOverrides(Context jobContext)
void
removeScalingHistory(Context 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(Context jobContext, java.util.SortedMap<java.time.Instant,CollectedMetrics> metrics)
void
storeConfigChanges(Context jobContext, ConfigChanges configChanges)
void
storeParallelismOverrides(Context jobContext, java.util.Map<java.lang.String,java.lang.String> parallelismOverrides)
void
storeScalingHistory(Context jobContext, java.util.Map<org.apache.flink.runtime.jobgraph.JobVertexID,java.util.SortedMap<java.time.Instant,ScalingSummary>> scalingHistory)
void
storeScalingTracking(Context jobContext, ScalingTracking scalingTrack)
-
-
-
Constructor Detail
-
JdbcAutoScalerStateStore
public JdbcAutoScalerStateStore(JdbcStateStore jdbcStateStore)
-
-
Method Detail
-
storeScalingHistory
public void storeScalingHistory(Context jobContext, java.util.Map<org.apache.flink.runtime.jobgraph.JobVertexID,java.util.SortedMap<java.time.Instant,ScalingSummary>> scalingHistory) throws java.lang.Exception
- Specified by:
storeScalingHistory
in interfaceAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
- Throws:
java.lang.Exception
-
getScalingHistory
@Nonnull public java.util.Map<org.apache.flink.runtime.jobgraph.JobVertexID,java.util.SortedMap<java.time.Instant,ScalingSummary>> getScalingHistory(Context jobContext)
- Specified by:
getScalingHistory
in interfaceAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
-
removeScalingHistory
public void removeScalingHistory(Context jobContext)
- Specified by:
removeScalingHistory
in interfaceAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
-
storeScalingTracking
public void storeScalingTracking(Context jobContext, ScalingTracking scalingTrack) throws java.lang.Exception
- Specified by:
storeScalingTracking
in interfaceAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
- Throws:
java.lang.Exception
-
getScalingTracking
public ScalingTracking getScalingTracking(Context jobContext)
- Specified by:
getScalingTracking
in interfaceAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
-
storeCollectedMetrics
public void storeCollectedMetrics(Context jobContext, java.util.SortedMap<java.time.Instant,CollectedMetrics> metrics) throws java.lang.Exception
- Specified by:
storeCollectedMetrics
in interfaceAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
- Throws:
java.lang.Exception
-
getCollectedMetrics
@Nonnull public java.util.SortedMap<java.time.Instant,CollectedMetrics> getCollectedMetrics(Context jobContext)
- Specified by:
getCollectedMetrics
in interfaceAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
-
removeCollectedMetrics
public void removeCollectedMetrics(Context jobContext)
- Specified by:
removeCollectedMetrics
in interfaceAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
-
storeParallelismOverrides
public void storeParallelismOverrides(Context jobContext, java.util.Map<java.lang.String,java.lang.String> parallelismOverrides)
- Specified by:
storeParallelismOverrides
in interfaceAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
-
getParallelismOverrides
@Nonnull public java.util.Map<java.lang.String,java.lang.String> getParallelismOverrides(Context jobContext)
- Specified by:
getParallelismOverrides
in interfaceAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
-
removeParallelismOverrides
public void removeParallelismOverrides(Context jobContext)
- Specified by:
removeParallelismOverrides
in interfaceAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
-
storeConfigChanges
public void storeConfigChanges(Context jobContext, ConfigChanges configChanges)
- Specified by:
storeConfigChanges
in interfaceAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
-
getConfigChanges
@Nonnull public ConfigChanges getConfigChanges(Context jobContext)
- Specified by:
getConfigChanges
in interfaceAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
-
removeConfigChanges
public void removeConfigChanges(Context jobContext)
- Specified by:
removeConfigChanges
in interfaceAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
-
clearAll
public void clearAll(Context jobContext)
Description copied from interface:AutoScalerStateStore
Removes all data from this context. Flush stil needs to be called.- Specified by:
clearAll
in interfaceAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
-
flush
public void flush(Context jobContext) throws java.lang.Exception
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<KEY,Context extends JobAutoScalerContext<KEY>>
- Throws:
java.lang.Exception
-
removeInfoFromCache
public void removeInfoFromCache(KEY jobKey)
Description copied from interface:AutoScalerStateStore
Clean up all information related to the current job.- Specified by:
removeInfoFromCache
in interfaceAutoScalerStateStore<KEY,Context extends JobAutoScalerContext<KEY>>
-
serializeScalingHistory
protected static java.lang.String serializeScalingHistory(java.util.Map<org.apache.flink.runtime.jobgraph.JobVertexID,java.util.SortedMap<java.time.Instant,ScalingSummary>> scalingHistory) throws java.lang.Exception
- Throws:
java.lang.Exception
-
serializeScalingTracking
protected static java.lang.String serializeScalingTracking(ScalingTracking scalingTracking) throws java.lang.Exception
- Throws:
java.lang.Exception
-
serializeEvaluatedMetrics
@VisibleForTesting protected static java.lang.String serializeEvaluatedMetrics(java.util.SortedMap<java.time.Instant,CollectedMetrics> evaluatedMetrics) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-